diff options
Diffstat (limited to 'deps/v8/src/objects/shared-function-info.h')
-rw-r--r-- | deps/v8/src/objects/shared-function-info.h | 133 |
1 files changed, 73 insertions, 60 deletions
diff --git a/deps/v8/src/objects/shared-function-info.h b/deps/v8/src/objects/shared-function-info.h index baaacd538c..bf382fc4f8 100644 --- a/deps/v8/src/objects/shared-function-info.h +++ b/deps/v8/src/objects/shared-function-info.h @@ -6,11 +6,13 @@ #define V8_OBJECTS_SHARED_FUNCTION_INFO_H_ #include "src/bailout-reason.h" +#include "src/function-kind.h" #include "src/objects.h" #include "src/objects/builtin-function-id.h" #include "src/objects/script.h" #include "src/objects/smi.h" #include "src/objects/struct.h" +#include "torque-generated/class-definitions-from-dsl.h" // Has to be the last include (doesn't have include guards): #include "src/objects/object-macros.h" @@ -102,6 +104,9 @@ class UncompiledData : public HeapObject { DECL_INT32_ACCESSORS(end_position) DECL_INT32_ACCESSORS(function_literal_id) + // Returns true if the UncompiledData contains a valid function_literal_id. + inline bool has_function_literal_id(); + DECL_CAST(UncompiledData) inline static void Initialize( @@ -186,7 +191,7 @@ class UncompiledDataWithPreparseData : public UncompiledData { #undef UNCOMPILED_DATA_WITH_PREPARSE_DATA_FIELDS // Make sure the size is aligned - STATIC_ASSERT(kSize == POINTER_SIZE_ALIGN(kSize)); + STATIC_ASSERT(IsAligned(kSize, kTaggedSize)); typedef SubclassBodyDescriptor< UncompiledData::BodyDescriptor, @@ -318,12 +323,6 @@ class SharedFunctionInfo : public HeapObject { // function. The value is only reliable when the function has been compiled. DECL_UINT8_ACCESSORS(expected_nof_properties) -#if V8_SFI_HAS_UNIQUE_ID - // [unique_id] - For --trace-maps purposes, an identifier that's persistent - // even if the GC moves this SharedFunctionInfo. - DECL_INT_ACCESSORS(unique_id) -#endif - // [function data]: This field holds some additional data for function. // Currently it has one of: // - a FunctionTemplateInfo to make benefit the API [IsApiFunction()]. @@ -493,6 +492,17 @@ class SharedFunctionInfo : public HeapObject { // is only executed once. DECL_BOOLEAN_ACCESSORS(is_oneshot_iife) + // Indicates that the function represented by the shared function info + // cannot observe the actual parameters passed at a call site, which + // means the function doesn't use the arguments object, doesn't use + // rest parameters, and is also in strict mode (meaning that there's + // no way to get to the actual arguments via the non-standard "arguments" + // accessor on sloppy mode functions). This can be used to speed up calls + // to this function even in the presence of arguments mismatch. + // See http://bit.ly/v8-faster-calls-with-arguments-mismatch for more + // information on this. + DECL_BOOLEAN_ACCESSORS(is_safe_to_skip_arguments_adaptor) + // Indicates that the function has been reported for binary code coverage. DECL_BOOLEAN_ACCESSORS(has_reported_binary_coverage) @@ -585,6 +595,12 @@ class SharedFunctionInfo : public HeapObject { void SetFunctionTokenPosition(int function_token_position, int start_position); + static void EnsureSourcePositionsAvailable( + Isolate* isolate, Handle<SharedFunctionInfo> shared_info); + + // Hash based on function literal id and script id. + uint32_t Hash(); + inline bool construct_as_builtin() const; // Determines and sets the ConstructAsBuiltinBit in |flags|, based on the @@ -630,7 +646,7 @@ class SharedFunctionInfo : public HeapObject { Script::Iterator script_iterator_; WeakArrayList::Iterator noscript_sfi_iterator_; SharedFunctionInfo::ScriptIterator sfi_iterator_; - DISALLOW_HEAP_ALLOCATION(no_gc_); + DISALLOW_HEAP_ALLOCATION(no_gc_) DISALLOW_COPY_AND_ASSIGN(GlobalIterator); }; @@ -643,65 +659,37 @@ class SharedFunctionInfo : public HeapObject { static const uint16_t kFunctionTokenOutOfRange = static_cast<uint16_t>(-1); STATIC_ASSERT(kMaximumFunctionTokenOffset + 1 == kFunctionTokenOutOfRange); -#if V8_SFI_HAS_UNIQUE_ID - static const int kUniqueIdFieldSize = kInt32Size; -#else - // Just to not break the postmortrem support with conditional offsets - static const int kUniqueIdFieldSize = 0; -#endif - -// Layout description. -#define SHARED_FUNCTION_INFO_FIELDS(V) \ - /* Pointer fields. */ \ - V(kStartOfPointerFieldsOffset, 0) \ - V(kFunctionDataOffset, kTaggedSize) \ - V(kStartOfAlwaysStrongPointerFieldsOffset, 0) \ - V(kNameOrScopeInfoOffset, kTaggedSize) \ - V(kOuterScopeInfoOrFeedbackMetadataOffset, kTaggedSize) \ - V(kScriptOrDebugInfoOffset, kTaggedSize) \ - V(kEndOfTaggedFieldsOffset, 0) \ - /* Raw data fields. */ \ - V(kUniqueIdOffset, kUniqueIdFieldSize) \ - V(kLengthOffset, kUInt16Size) \ - V(kFormalParameterCountOffset, kUInt16Size) \ - V(kExpectedNofPropertiesOffset, kUInt8Size) \ - V(kBuiltinFunctionId, kUInt8Size) \ - V(kFunctionTokenOffsetOffset, kUInt16Size) \ - V(kFlagsOffset, kInt32Size) \ - /* Total size. */ \ - V(kSize, 0) - DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, - SHARED_FUNCTION_INFO_FIELDS) -#undef SHARED_FUNCTION_INFO_FIELDS + TORQUE_GENERATED_SHARED_FUNCTION_INFO_FIELDS) static const int kAlignedSize = POINTER_SIZE_ALIGN(kSize); class BodyDescriptor; // Bit positions in |flags|. -#define FLAGS_BIT_FIELDS(V, _) \ - V(IsNativeBit, bool, 1, _) \ - V(IsStrictBit, bool, 1, _) \ - V(IsWrappedBit, bool, 1, _) \ - V(IsClassConstructorBit, bool, 1, _) \ - V(IsDerivedConstructorBit, bool, 1, _) \ - V(FunctionKindBits, FunctionKind, 5, _) \ - V(HasDuplicateParametersBit, bool, 1, _) \ - V(AllowLazyCompilationBit, bool, 1, _) \ - V(NeedsHomeObjectBit, bool, 1, _) \ - V(IsDeclarationBit, bool, 1, _) \ - V(IsAsmWasmBrokenBit, bool, 1, _) \ - V(FunctionMapIndexBits, int, 5, _) \ - V(DisabledOptimizationReasonBits, BailoutReason, 4, _) \ - V(RequiresInstanceMembersInitializer, bool, 1, _) \ - V(ConstructAsBuiltinBit, bool, 1, _) \ - V(IsAnonymousExpressionBit, bool, 1, _) \ - V(NameShouldPrintAsAnonymousBit, bool, 1, _) \ - V(HasReportedBinaryCoverageBit, bool, 1, _) \ - V(IsNamedExpressionBit, bool, 1, _) \ - V(IsTopLevelBit, bool, 1, _) \ - V(IsOneshotIIFEBit, bool, 1, _) +#define FLAGS_BIT_FIELDS(V, _) \ + /* Have FunctionKind first to make it cheaper to access */ \ + V(FunctionKindBits, FunctionKind, 5, _) \ + V(IsNativeBit, bool, 1, _) \ + V(IsStrictBit, bool, 1, _) \ + V(IsWrappedBit, bool, 1, _) \ + V(IsClassConstructorBit, bool, 1, _) \ + V(HasDuplicateParametersBit, bool, 1, _) \ + V(AllowLazyCompilationBit, bool, 1, _) \ + V(NeedsHomeObjectBit, bool, 1, _) \ + V(IsDeclarationBit, bool, 1, _) \ + V(IsAsmWasmBrokenBit, bool, 1, _) \ + V(FunctionMapIndexBits, int, 5, _) \ + V(DisabledOptimizationReasonBits, BailoutReason, 4, _) \ + V(RequiresInstanceMembersInitializer, bool, 1, _) \ + V(ConstructAsBuiltinBit, bool, 1, _) \ + V(IsAnonymousExpressionBit, bool, 1, _) \ + V(NameShouldPrintAsAnonymousBit, bool, 1, _) \ + V(HasReportedBinaryCoverageBit, bool, 1, _) \ + V(IsNamedExpressionBit, bool, 1, _) \ + V(IsTopLevelBit, bool, 1, _) \ + V(IsOneshotIIFEBit, bool, 1, _) \ + V(IsSafeToSkipArgumentsAdaptorBit, bool, 1, _) DEFINE_BIT_FIELDS(FLAGS_BIT_FIELDS) #undef FLAGS_BIT_FIELDS @@ -716,6 +704,14 @@ class SharedFunctionInfo : public HeapObject { // This is needed to set up the [[HomeObject]] on the function instance. inline bool needs_home_object() const; + V8_INLINE bool IsSharedFunctionInfoWithID() const { +#if V8_SFI_HAS_UNIQUE_ID + return true; +#else + return false; +#endif + } + private: // [name_or_scope_info]: Function name string, kNoSharedNameSentinel or // ScopeInfo. @@ -742,6 +738,23 @@ class SharedFunctionInfo : public HeapObject { OBJECT_CONSTRUCTORS(SharedFunctionInfo, HeapObject); }; +class SharedFunctionInfoWithID : public SharedFunctionInfo { + public: + // [unique_id] - For --trace-maps purposes, an identifier that's persistent + // even if the GC moves this SharedFunctionInfo. + DECL_INT_ACCESSORS(unique_id) + + DECL_CAST(SharedFunctionInfoWithID) + + DEFINE_FIELD_OFFSET_CONSTANTS( + SharedFunctionInfo::kSize, + TORQUE_GENERATED_SHARED_FUNCTION_INFO_WITH_ID_FIELDS) + + static const int kAlignedSize = POINTER_SIZE_ALIGN(kSize); + + OBJECT_CONSTRUCTORS(SharedFunctionInfoWithID, SharedFunctionInfo); +}; + // Printing support. struct SourceCodeOf { explicit SourceCodeOf(SharedFunctionInfo v, int max = -1) |