OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // - Object | 44 // - Object |
45 // - Smi (immediate small integer) | 45 // - Smi (immediate small integer) |
46 // - HeapObject (superclass for everything allocated in the heap) | 46 // - HeapObject (superclass for everything allocated in the heap) |
47 // - JSReceiver (suitable for property access) | 47 // - JSReceiver (suitable for property access) |
48 // - JSObject | 48 // - JSObject |
49 // - JSArray | 49 // - JSArray |
50 // - JSArrayBuffer | 50 // - JSArrayBuffer |
51 // - JSArrayBufferView | 51 // - JSArrayBufferView |
52 // - JSTypedArray | 52 // - JSTypedArray |
53 // - JSDataView | 53 // - JSDataView |
| 54 // - JSBoundFunction |
54 // - JSCollection | 55 // - JSCollection |
55 // - JSSet | 56 // - JSSet |
56 // - JSMap | 57 // - JSMap |
57 // - JSSetIterator | 58 // - JSSetIterator |
58 // - JSMapIterator | 59 // - JSMapIterator |
59 // - JSWeakCollection | 60 // - JSWeakCollection |
60 // - JSWeakMap | 61 // - JSWeakMap |
61 // - JSWeakSet | 62 // - JSWeakSet |
62 // - JSRegExp | 63 // - JSRegExp |
63 // - JSFunction | 64 // - JSFunction |
64 // - JSGeneratorObject | 65 // - JSGeneratorObject |
65 // - JSModule | 66 // - JSModule |
66 // - JSGlobalObject | 67 // - JSGlobalObject |
67 // - JSGlobalProxy | 68 // - JSGlobalProxy |
68 // - JSValue | 69 // - JSValue |
69 // - JSDate | 70 // - JSDate |
70 // - JSMessageObject | 71 // - JSMessageObject |
71 // - JSProxy | 72 // - JSProxy |
72 // - FixedArrayBase | 73 // - FixedArrayBase |
73 // - ByteArray | 74 // - ByteArray |
74 // - BytecodeArray | 75 // - BytecodeArray |
75 // - FixedArray | 76 // - FixedArray |
76 // - DescriptorArray | 77 // - DescriptorArray |
77 // - LiteralsArray | 78 // - LiteralsArray |
78 // - BindingsArray | |
79 // - HashTable | 79 // - HashTable |
80 // - Dictionary | 80 // - Dictionary |
81 // - StringTable | 81 // - StringTable |
82 // - CompilationCacheTable | 82 // - CompilationCacheTable |
83 // - CodeCacheHashTable | 83 // - CodeCacheHashTable |
84 // - MapCache | 84 // - MapCache |
85 // - OrderedHashTable | 85 // - OrderedHashTable |
86 // - OrderedHashSet | 86 // - OrderedHashSet |
87 // - OrderedHashMap | 87 // - OrderedHashMap |
88 // - Context | 88 // - Context |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 V(JS_SET_TYPE) \ | 430 V(JS_SET_TYPE) \ |
431 V(JS_MAP_TYPE) \ | 431 V(JS_MAP_TYPE) \ |
432 V(JS_SET_ITERATOR_TYPE) \ | 432 V(JS_SET_ITERATOR_TYPE) \ |
433 V(JS_MAP_ITERATOR_TYPE) \ | 433 V(JS_MAP_ITERATOR_TYPE) \ |
434 V(JS_ITERATOR_RESULT_TYPE) \ | 434 V(JS_ITERATOR_RESULT_TYPE) \ |
435 V(JS_WEAK_MAP_TYPE) \ | 435 V(JS_WEAK_MAP_TYPE) \ |
436 V(JS_WEAK_SET_TYPE) \ | 436 V(JS_WEAK_SET_TYPE) \ |
437 V(JS_PROMISE_TYPE) \ | 437 V(JS_PROMISE_TYPE) \ |
438 V(JS_REGEXP_TYPE) \ | 438 V(JS_REGEXP_TYPE) \ |
439 \ | 439 \ |
| 440 V(JS_BOUND_FUNCTION_TYPE) \ |
440 V(JS_FUNCTION_TYPE) \ | 441 V(JS_FUNCTION_TYPE) \ |
441 V(DEBUG_INFO_TYPE) \ | 442 V(DEBUG_INFO_TYPE) \ |
442 V(BREAK_POINT_INFO_TYPE) | 443 V(BREAK_POINT_INFO_TYPE) |
443 | 444 |
444 | 445 |
445 // Since string types are not consecutive, this macro is used to | 446 // Since string types are not consecutive, this macro is used to |
446 // iterate over them. | 447 // iterate over them. |
447 #define STRING_TYPE_LIST(V) \ | 448 #define STRING_TYPE_LIST(V) \ |
448 V(STRING_TYPE, kVariableSizeSentinel, string, String) \ | 449 V(STRING_TYPE, kVariableSizeSentinel, string, String) \ |
449 V(ONE_BYTE_STRING_TYPE, kVariableSizeSentinel, one_byte_string, \ | 450 V(ONE_BYTE_STRING_TYPE, kVariableSizeSentinel, one_byte_string, \ |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 JS_DATA_VIEW_TYPE, | 726 JS_DATA_VIEW_TYPE, |
726 JS_SET_TYPE, | 727 JS_SET_TYPE, |
727 JS_MAP_TYPE, | 728 JS_MAP_TYPE, |
728 JS_SET_ITERATOR_TYPE, | 729 JS_SET_ITERATOR_TYPE, |
729 JS_MAP_ITERATOR_TYPE, | 730 JS_MAP_ITERATOR_TYPE, |
730 JS_ITERATOR_RESULT_TYPE, | 731 JS_ITERATOR_RESULT_TYPE, |
731 JS_WEAK_MAP_TYPE, | 732 JS_WEAK_MAP_TYPE, |
732 JS_WEAK_SET_TYPE, | 733 JS_WEAK_SET_TYPE, |
733 JS_PROMISE_TYPE, | 734 JS_PROMISE_TYPE, |
734 JS_REGEXP_TYPE, | 735 JS_REGEXP_TYPE, |
| 736 JS_BOUND_FUNCTION_TYPE, |
735 JS_FUNCTION_TYPE, // LAST_JS_OBJECT_TYPE, LAST_JS_RECEIVER_TYPE | 737 JS_FUNCTION_TYPE, // LAST_JS_OBJECT_TYPE, LAST_JS_RECEIVER_TYPE |
736 | 738 |
737 // Pseudo-types | 739 // Pseudo-types |
738 FIRST_TYPE = 0x0, | 740 FIRST_TYPE = 0x0, |
739 LAST_TYPE = JS_FUNCTION_TYPE, | 741 LAST_TYPE = JS_FUNCTION_TYPE, |
740 FIRST_NAME_TYPE = FIRST_TYPE, | 742 FIRST_NAME_TYPE = FIRST_TYPE, |
741 LAST_NAME_TYPE = SYMBOL_TYPE, | 743 LAST_NAME_TYPE = SYMBOL_TYPE, |
742 FIRST_UNIQUE_NAME_TYPE = INTERNALIZED_STRING_TYPE, | 744 FIRST_UNIQUE_NAME_TYPE = INTERNALIZED_STRING_TYPE, |
743 LAST_UNIQUE_NAME_TYPE = SYMBOL_TYPE, | 745 LAST_UNIQUE_NAME_TYPE = SYMBOL_TYPE, |
744 FIRST_NONSTRING_TYPE = SYMBOL_TYPE, | 746 FIRST_NONSTRING_TYPE = SYMBOL_TYPE, |
745 FIRST_PRIMITIVE_TYPE = FIRST_NAME_TYPE, | 747 FIRST_PRIMITIVE_TYPE = FIRST_NAME_TYPE, |
746 LAST_PRIMITIVE_TYPE = ODDBALL_TYPE, | 748 LAST_PRIMITIVE_TYPE = ODDBALL_TYPE, |
| 749 FIRST_FUNCTION_TYPE = JS_BOUND_FUNCTION_TYPE, |
| 750 LAST_FUNCTION_TYPE = JS_FUNCTION_TYPE, |
747 // Boundaries for testing for a fixed typed array. | 751 // Boundaries for testing for a fixed typed array. |
748 FIRST_FIXED_TYPED_ARRAY_TYPE = FIXED_INT8_ARRAY_TYPE, | 752 FIRST_FIXED_TYPED_ARRAY_TYPE = FIXED_INT8_ARRAY_TYPE, |
749 LAST_FIXED_TYPED_ARRAY_TYPE = FIXED_UINT8_CLAMPED_ARRAY_TYPE, | 753 LAST_FIXED_TYPED_ARRAY_TYPE = FIXED_UINT8_CLAMPED_ARRAY_TYPE, |
750 // Boundary for promotion to old space. | 754 // Boundary for promotion to old space. |
751 LAST_DATA_TYPE = FILLER_TYPE, | 755 LAST_DATA_TYPE = FILLER_TYPE, |
752 // Boundary for objects represented as JSReceiver (i.e. JSObject or JSProxy). | 756 // Boundary for objects represented as JSReceiver (i.e. JSObject or JSProxy). |
753 // Note that there is no range for JSObject or JSProxy, since their subtypes | 757 // Note that there is no range for JSObject or JSProxy, since their subtypes |
754 // are not continuous in this enum! The enum ranges instead reflect the | 758 // are not continuous in this enum! The enum ranges instead reflect the |
755 // external class names, where proxies are treated as either ordinary objects, | 759 // external class names, where proxies are treated as either ordinary objects, |
756 // or functions. | 760 // or functions. |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 V(BytecodeArray) \ | 927 V(BytecodeArray) \ |
924 V(FreeSpace) \ | 928 V(FreeSpace) \ |
925 V(JSReceiver) \ | 929 V(JSReceiver) \ |
926 V(JSObject) \ | 930 V(JSObject) \ |
927 V(JSContextExtensionObject) \ | 931 V(JSContextExtensionObject) \ |
928 V(JSGeneratorObject) \ | 932 V(JSGeneratorObject) \ |
929 V(JSModule) \ | 933 V(JSModule) \ |
930 V(LayoutDescriptor) \ | 934 V(LayoutDescriptor) \ |
931 V(Map) \ | 935 V(Map) \ |
932 V(DescriptorArray) \ | 936 V(DescriptorArray) \ |
933 V(BindingsArray) \ | |
934 V(TransitionArray) \ | 937 V(TransitionArray) \ |
935 V(LiteralsArray) \ | 938 V(LiteralsArray) \ |
936 V(TypeFeedbackMetadata) \ | 939 V(TypeFeedbackMetadata) \ |
937 V(TypeFeedbackVector) \ | 940 V(TypeFeedbackVector) \ |
938 V(DeoptimizationInputData) \ | 941 V(DeoptimizationInputData) \ |
939 V(DeoptimizationOutputData) \ | 942 V(DeoptimizationOutputData) \ |
940 V(DependentCode) \ | 943 V(DependentCode) \ |
941 V(HandlerTable) \ | 944 V(HandlerTable) \ |
942 V(FixedArray) \ | 945 V(FixedArray) \ |
943 V(FixedDoubleArray) \ | 946 V(FixedDoubleArray) \ |
944 V(WeakFixedArray) \ | 947 V(WeakFixedArray) \ |
945 V(ArrayList) \ | 948 V(ArrayList) \ |
946 V(Context) \ | 949 V(Context) \ |
947 V(ScriptContextTable) \ | 950 V(ScriptContextTable) \ |
948 V(NativeContext) \ | 951 V(NativeContext) \ |
949 V(ScopeInfo) \ | 952 V(ScopeInfo) \ |
| 953 V(JSBoundFunction) \ |
950 V(JSFunction) \ | 954 V(JSFunction) \ |
951 V(Code) \ | 955 V(Code) \ |
952 V(Oddball) \ | 956 V(Oddball) \ |
953 V(SharedFunctionInfo) \ | 957 V(SharedFunctionInfo) \ |
954 V(JSValue) \ | 958 V(JSValue) \ |
955 V(JSDate) \ | 959 V(JSDate) \ |
956 V(JSMessageObject) \ | 960 V(JSMessageObject) \ |
957 V(StringWrapper) \ | 961 V(StringWrapper) \ |
958 V(Foreign) \ | 962 V(Foreign) \ |
959 V(Boolean) \ | 963 V(Boolean) \ |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 | 1047 |
1044 INLINE(bool IsStruct() const); | 1048 INLINE(bool IsStruct() const); |
1045 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \ | 1049 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \ |
1046 INLINE(bool Is##Name() const); | 1050 INLINE(bool Is##Name() const); |
1047 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) | 1051 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) |
1048 #undef DECLARE_STRUCT_PREDICATE | 1052 #undef DECLARE_STRUCT_PREDICATE |
1049 | 1053 |
1050 // ES6, section 7.2.2 IsArray. NOT to be confused with %_IsArray. | 1054 // ES6, section 7.2.2 IsArray. NOT to be confused with %_IsArray. |
1051 MUST_USE_RESULT static Maybe<bool> IsArray(Handle<Object> object); | 1055 MUST_USE_RESULT static Maybe<bool> IsArray(Handle<Object> object); |
1052 | 1056 |
| 1057 // Test for JSBoundFunction or JSFunction. |
| 1058 INLINE(bool IsFunction() const); |
| 1059 |
1053 // ES6, section 7.2.3 IsCallable. | 1060 // ES6, section 7.2.3 IsCallable. |
1054 INLINE(bool IsCallable() const); | 1061 INLINE(bool IsCallable() const); |
1055 | 1062 |
1056 // ES6, section 7.2.4 IsConstructor. | 1063 // ES6, section 7.2.4 IsConstructor. |
1057 INLINE(bool IsConstructor() const); | 1064 INLINE(bool IsConstructor() const); |
1058 | 1065 |
1059 INLINE(bool IsTemplateInfo()) const; | 1066 INLINE(bool IsTemplateInfo()) const; |
1060 INLINE(bool IsNameDictionary() const); | 1067 INLINE(bool IsNameDictionary() const); |
1061 INLINE(bool IsGlobalDictionary() const); | 1068 INLINE(bool IsGlobalDictionary() const); |
1062 INLINE(bool IsSeededNumberDictionary() const); | 1069 INLINE(bool IsSeededNumberDictionary() const); |
(...skipping 3594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4657 DECLARE_CAST(LiteralsArray) | 4664 DECLARE_CAST(LiteralsArray) |
4658 | 4665 |
4659 private: | 4666 private: |
4660 inline Object* get(int index) const; | 4667 inline Object* get(int index) const; |
4661 inline void set(int index, Object* value); | 4668 inline void set(int index, Object* value); |
4662 inline void set(int index, Smi* value); | 4669 inline void set(int index, Smi* value); |
4663 inline void set(int index, Object* value, WriteBarrierMode mode); | 4670 inline void set(int index, Object* value, WriteBarrierMode mode); |
4664 }; | 4671 }; |
4665 | 4672 |
4666 | 4673 |
4667 // A bindings array contains the bindings for a bound function. It also holds | |
4668 // the type feedback vector. | |
4669 class BindingsArray : public FixedArray { | |
4670 public: | |
4671 inline TypeFeedbackVector* feedback_vector() const; | |
4672 inline void set_feedback_vector(TypeFeedbackVector* vector); | |
4673 | |
4674 inline JSReceiver* bound_function() const; | |
4675 inline void set_bound_function(JSReceiver* function); | |
4676 inline Object* bound_this() const; | |
4677 inline void set_bound_this(Object* bound_this); | |
4678 | |
4679 inline Object* binding(int binding_index) const; | |
4680 inline void set_binding(int binding_index, Object* binding); | |
4681 inline int bindings_count() const; | |
4682 | |
4683 static Handle<BindingsArray> New(Isolate* isolate, | |
4684 Handle<TypeFeedbackVector> vector, | |
4685 Handle<JSReceiver> bound_function, | |
4686 Handle<Object> bound_this, | |
4687 int number_of_bindings); | |
4688 | |
4689 static Handle<JSArray> CreateBoundArguments(Handle<BindingsArray> bindings); | |
4690 static Handle<JSArray> CreateRuntimeBindings(Handle<BindingsArray> bindings); | |
4691 | |
4692 DECLARE_CAST(BindingsArray) | |
4693 | |
4694 private: | |
4695 static const int kVectorIndex = 0; | |
4696 static const int kBoundFunctionIndex = 1; | |
4697 static const int kBoundThisIndex = 2; | |
4698 static const int kFirstBindingIndex = 3; | |
4699 | |
4700 inline Object* get(int index) const; | |
4701 inline void set(int index, Object* value); | |
4702 inline void set(int index, Smi* value); | |
4703 inline void set(int index, Object* value, WriteBarrierMode mode); | |
4704 | |
4705 inline int length() const; | |
4706 }; | |
4707 | |
4708 | |
4709 // HandlerTable is a fixed array containing entries for exception handlers in | 4674 // HandlerTable is a fixed array containing entries for exception handlers in |
4710 // the code object it is associated with. The tables comes in two flavors: | 4675 // the code object it is associated with. The tables comes in two flavors: |
4711 // 1) Based on ranges: Used for unoptimized code. Contains one entry per | 4676 // 1) Based on ranges: Used for unoptimized code. Contains one entry per |
4712 // exception handler and a range representing the try-block covered by that | 4677 // exception handler and a range representing the try-block covered by that |
4713 // handler. Layout looks as follows: | 4678 // handler. Layout looks as follows: |
4714 // [ range-start , range-end , handler-offset , stack-depth ] | 4679 // [ range-start , range-end , handler-offset , stack-depth ] |
4715 // 2) Based on return addresses: Used for turbofanned code. Contains one entry | 4680 // 2) Based on return addresses: Used for turbofanned code. Contains one entry |
4716 // per call-site that could throw an exception. Layout looks as follows: | 4681 // per call-site that could throw an exception. Layout looks as follows: |
4717 // [ return-address-offset , handler-offset ] | 4682 // [ return-address-offset , handler-offset ] |
4718 class HandlerTable : public FixedArray { | 4683 class HandlerTable : public FixedArray { |
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5557 // Tells whether the object in the prototype property will be used | 5522 // Tells whether the object in the prototype property will be used |
5558 // for instances created from this function. If the prototype | 5523 // for instances created from this function. If the prototype |
5559 // property is set to a value that is not a JSObject, the prototype | 5524 // property is set to a value that is not a JSObject, the prototype |
5560 // property will not be used to create instances of the function. | 5525 // property will not be used to create instances of the function. |
5561 // See ECMA-262, 13.2.2. | 5526 // See ECMA-262, 13.2.2. |
5562 inline void set_non_instance_prototype(bool value); | 5527 inline void set_non_instance_prototype(bool value); |
5563 inline bool has_non_instance_prototype(); | 5528 inline bool has_non_instance_prototype(); |
5564 | 5529 |
5565 // Tells whether the instance has a [[Construct]] internal method. | 5530 // Tells whether the instance has a [[Construct]] internal method. |
5566 // This property is implemented according to ES6, section 7.2.4. | 5531 // This property is implemented according to ES6, section 7.2.4. |
5567 inline void set_is_constructor(bool value); | 5532 inline void set_is_constructor(); |
5568 inline bool is_constructor() const; | 5533 inline bool is_constructor() const; |
5569 | 5534 |
5570 // Tells whether the instance with this map should be ignored by the | 5535 // Tells whether the instance with this map should be ignored by the |
5571 // Object.getPrototypeOf() function and the __proto__ accessor. | 5536 // Object.getPrototypeOf() function and the __proto__ accessor. |
5572 inline void set_is_hidden_prototype(); | 5537 inline void set_is_hidden_prototype(); |
5573 inline bool is_hidden_prototype() const; | 5538 inline bool is_hidden_prototype() const; |
5574 | 5539 |
5575 // Records and queries whether the instance has a named interceptor. | 5540 // Records and queries whether the instance has a named interceptor. |
5576 inline void set_has_named_interceptor(); | 5541 inline void set_has_named_interceptor(); |
5577 inline bool has_named_interceptor(); | 5542 inline bool has_named_interceptor(); |
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6732 | 6697 |
6733 // Indicate that this function should always be inlined in optimized code. | 6698 // Indicate that this function should always be inlined in optimized code. |
6734 DECL_BOOLEAN_ACCESSORS(force_inline) | 6699 DECL_BOOLEAN_ACCESSORS(force_inline) |
6735 | 6700 |
6736 // Indicates that the function was created by the Function function. | 6701 // Indicates that the function was created by the Function function. |
6737 // Though it's anonymous, toString should treat it as if it had the name | 6702 // Though it's anonymous, toString should treat it as if it had the name |
6738 // "anonymous". We don't set the name itself so that the system does not | 6703 // "anonymous". We don't set the name itself so that the system does not |
6739 // see a binding for it. | 6704 // see a binding for it. |
6740 DECL_BOOLEAN_ACCESSORS(name_should_print_as_anonymous) | 6705 DECL_BOOLEAN_ACCESSORS(name_should_print_as_anonymous) |
6741 | 6706 |
6742 // Indicates whether the function is a bound function created using | |
6743 // the bind function. | |
6744 DECL_BOOLEAN_ACCESSORS(bound) | |
6745 | |
6746 // Indicates that the function is anonymous (the name field can be set | 6707 // Indicates that the function is anonymous (the name field can be set |
6747 // through the API, which does not change this flag). | 6708 // through the API, which does not change this flag). |
6748 DECL_BOOLEAN_ACCESSORS(is_anonymous) | 6709 DECL_BOOLEAN_ACCESSORS(is_anonymous) |
6749 | 6710 |
6750 // Is this a function or top-level/eval code. | 6711 // Is this a function or top-level/eval code. |
6751 DECL_BOOLEAN_ACCESSORS(is_function) | 6712 DECL_BOOLEAN_ACCESSORS(is_function) |
6752 | 6713 |
6753 // Indicates that code for this function cannot be compiled with Crankshaft. | 6714 // Indicates that code for this function cannot be compiled with Crankshaft. |
6754 DECL_BOOLEAN_ACCESSORS(dont_crankshaft) | 6715 DECL_BOOLEAN_ACCESSORS(dont_crankshaft) |
6755 | 6716 |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7025 kAllowLazyCompilationWithoutContext, | 6986 kAllowLazyCompilationWithoutContext, |
7026 kOptimizationDisabled, | 6987 kOptimizationDisabled, |
7027 kNative, | 6988 kNative, |
7028 kStrictModeFunction, | 6989 kStrictModeFunction, |
7029 kStrongModeFunction, | 6990 kStrongModeFunction, |
7030 kUsesArguments, | 6991 kUsesArguments, |
7031 kNeedsHomeObject, | 6992 kNeedsHomeObject, |
7032 // byte 1 | 6993 // byte 1 |
7033 kHasDuplicateParameters, | 6994 kHasDuplicateParameters, |
7034 kForceInline, | 6995 kForceInline, |
7035 kBoundFunction, | 6996 kIsAsmFunction, |
7036 kIsAnonymous, | 6997 kIsAnonymous, |
7037 kNameShouldPrintAsAnonymous, | 6998 kNameShouldPrintAsAnonymous, |
7038 kIsFunction, | 6999 kIsFunction, |
7039 kDontCrankshaft, | 7000 kDontCrankshaft, |
7040 kDontFlush, | 7001 kDontFlush, |
7041 // byte 2 | 7002 // byte 2 |
7042 kFunctionKind, | 7003 kFunctionKind, |
7043 kIsArrow = kFunctionKind, | 7004 kIsArrow = kFunctionKind, |
7044 kIsGenerator, | 7005 kIsGenerator, |
7045 kIsConciseMethod, | 7006 kIsConciseMethod, |
7046 kIsAccessorFunction, | 7007 kIsAccessorFunction, |
7047 kIsDefaultConstructor, | 7008 kIsDefaultConstructor, |
7048 kIsSubclassConstructor, | 7009 kIsSubclassConstructor, |
7049 kIsBaseConstructor, | 7010 kIsBaseConstructor, |
7050 kIsInObjectLiteral, | 7011 kIsInObjectLiteral, |
7051 // byte 3 | 7012 // byte 3 |
7052 kIsAsmFunction, | |
7053 kDeserialized, | 7013 kDeserialized, |
7054 kNeverCompiled, | 7014 kNeverCompiled, |
7055 kCompilerHintsCount, // Pseudo entry | 7015 kCompilerHintsCount, // Pseudo entry |
7056 }; | 7016 }; |
7057 // Add hints for other modes when they're added. | 7017 // Add hints for other modes when they're added. |
7058 STATIC_ASSERT(LANGUAGE_END == 3); | 7018 STATIC_ASSERT(LANGUAGE_END == 3); |
7059 // kFunctionKind has to be byte-aligned | 7019 // kFunctionKind has to be byte-aligned |
7060 STATIC_ASSERT((kFunctionKind % kBitsPerByte) == 0); | 7020 STATIC_ASSERT((kFunctionKind % kBitsPerByte) == 0); |
7061 // Make sure that FunctionKind and byte 2 are in sync: | 7021 // Make sure that FunctionKind and byte 2 are in sync: |
7062 #define ASSERT_FUNCTION_KIND_ORDER(functionKind, compilerFunctionKind) \ | 7022 #define ASSERT_FUNCTION_KIND_ORDER(functionKind, compilerFunctionKind) \ |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7096 SharedFunctionInfo::kCompilerHintsSize * kBitsPerByte); | 7056 SharedFunctionInfo::kCompilerHintsSize * kBitsPerByte); |
7097 | 7057 |
7098 public: | 7058 public: |
7099 // Constants for optimizing codegen for strict mode function and | 7059 // Constants for optimizing codegen for strict mode function and |
7100 // native tests when using integer-width instructions. | 7060 // native tests when using integer-width instructions. |
7101 static const int kStrictModeBit = | 7061 static const int kStrictModeBit = |
7102 kStrictModeFunction + kCompilerHintsSmiTagSize; | 7062 kStrictModeFunction + kCompilerHintsSmiTagSize; |
7103 static const int kStrongModeBit = | 7063 static const int kStrongModeBit = |
7104 kStrongModeFunction + kCompilerHintsSmiTagSize; | 7064 kStrongModeFunction + kCompilerHintsSmiTagSize; |
7105 static const int kNativeBit = kNative + kCompilerHintsSmiTagSize; | 7065 static const int kNativeBit = kNative + kCompilerHintsSmiTagSize; |
7106 static const int kBoundBit = kBoundFunction + kCompilerHintsSmiTagSize; | |
7107 | 7066 |
7108 static const int kClassConstructorBits = | 7067 static const int kClassConstructorBits = |
7109 FunctionKind::kClassConstructor | 7068 FunctionKind::kClassConstructor |
7110 << (kFunctionKind + kCompilerHintsSmiTagSize); | 7069 << (kFunctionKind + kCompilerHintsSmiTagSize); |
7111 | 7070 |
7112 // Constants for optimizing codegen for strict mode function and | 7071 // Constants for optimizing codegen for strict mode function and |
7113 // native tests. | 7072 // native tests. |
7114 // Allows to use byte-width instructions. | 7073 // Allows to use byte-width instructions. |
7115 static const int kStrictModeBitWithinByte = kStrictModeBit % kBitsPerByte; | 7074 static const int kStrictModeBitWithinByte = kStrictModeBit % kBitsPerByte; |
7116 static const int kStrongModeBitWithinByte = kStrongModeBit % kBitsPerByte; | 7075 static const int kStrongModeBitWithinByte = kStrongModeBit % kBitsPerByte; |
7117 static const int kNativeBitWithinByte = kNativeBit % kBitsPerByte; | 7076 static const int kNativeBitWithinByte = kNativeBit % kBitsPerByte; |
7118 static const int kBoundBitWithinByte = kBoundBit % kBitsPerByte; | |
7119 | 7077 |
7120 static const int kClassConstructorBitsWithinByte = | 7078 static const int kClassConstructorBitsWithinByte = |
7121 FunctionKind::kClassConstructor << kCompilerHintsSmiTagSize; | 7079 FunctionKind::kClassConstructor << kCompilerHintsSmiTagSize; |
7122 STATIC_ASSERT(kClassConstructorBitsWithinByte < (1 << kBitsPerByte)); | 7080 STATIC_ASSERT(kClassConstructorBitsWithinByte < (1 << kBitsPerByte)); |
7123 | 7081 |
7124 #if defined(V8_TARGET_LITTLE_ENDIAN) | 7082 #if defined(V8_TARGET_LITTLE_ENDIAN) |
7125 #define BYTE_OFFSET(compiler_hint) \ | 7083 #define BYTE_OFFSET(compiler_hint) \ |
7126 kCompilerHintsOffset + \ | 7084 kCompilerHintsOffset + \ |
7127 (compiler_hint + kCompilerHintsSmiTagSize) / kBitsPerByte | 7085 (compiler_hint + kCompilerHintsSmiTagSize) / kBitsPerByte |
7128 #elif defined(V8_TARGET_BIG_ENDIAN) | 7086 #elif defined(V8_TARGET_BIG_ENDIAN) |
7129 #define BYTE_OFFSET(compiler_hint) \ | 7087 #define BYTE_OFFSET(compiler_hint) \ |
7130 kCompilerHintsOffset + (kCompilerHintsSize - 1) - \ | 7088 kCompilerHintsOffset + (kCompilerHintsSize - 1) - \ |
7131 ((compiler_hint + kCompilerHintsSmiTagSize) / kBitsPerByte) | 7089 ((compiler_hint + kCompilerHintsSmiTagSize) / kBitsPerByte) |
7132 #else | 7090 #else |
7133 #error Unknown byte ordering | 7091 #error Unknown byte ordering |
7134 #endif | 7092 #endif |
7135 static const int kStrictModeByteOffset = BYTE_OFFSET(kStrictModeFunction); | 7093 static const int kStrictModeByteOffset = BYTE_OFFSET(kStrictModeFunction); |
7136 static const int kStrongModeByteOffset = BYTE_OFFSET(kStrongModeFunction); | 7094 static const int kStrongModeByteOffset = BYTE_OFFSET(kStrongModeFunction); |
7137 static const int kNativeByteOffset = BYTE_OFFSET(kNative); | 7095 static const int kNativeByteOffset = BYTE_OFFSET(kNative); |
7138 static const int kBoundByteOffset = BYTE_OFFSET(kBoundFunction); | |
7139 static const int kFunctionKindByteOffset = BYTE_OFFSET(kFunctionKind); | 7096 static const int kFunctionKindByteOffset = BYTE_OFFSET(kFunctionKind); |
7140 #undef BYTE_OFFSET | 7097 #undef BYTE_OFFSET |
7141 | 7098 |
7142 private: | 7099 private: |
7143 // Returns entry from optimized code map for specified context and OSR entry. | 7100 // Returns entry from optimized code map for specified context and OSR entry. |
7144 // The result is either kNotFound, kSharedCodeIndex for context-independent | 7101 // The result is either kNotFound, kSharedCodeIndex for context-independent |
7145 // entry or a start index of the context-dependent entry. | 7102 // entry or a start index of the context-dependent entry. |
7146 int SearchOptimizedCodeMapEntry(Context* native_context, | 7103 int SearchOptimizedCodeMapEntry(Context* native_context, |
7147 BailoutId osr_ast_id); | 7104 BailoutId osr_ast_id); |
7148 | 7105 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7238 // Layout description. | 7195 // Layout description. |
7239 static const int kContextOffset = JSObject::kHeaderSize; | 7196 static const int kContextOffset = JSObject::kHeaderSize; |
7240 static const int kScopeInfoOffset = kContextOffset + kPointerSize; | 7197 static const int kScopeInfoOffset = kContextOffset + kPointerSize; |
7241 static const int kSize = kScopeInfoOffset + kPointerSize; | 7198 static const int kSize = kScopeInfoOffset + kPointerSize; |
7242 | 7199 |
7243 private: | 7200 private: |
7244 DISALLOW_IMPLICIT_CONSTRUCTORS(JSModule); | 7201 DISALLOW_IMPLICIT_CONSTRUCTORS(JSModule); |
7245 }; | 7202 }; |
7246 | 7203 |
7247 | 7204 |
| 7205 // JSBoundFunction describes a bound function exotic object. |
| 7206 class JSBoundFunction : public JSObject { |
| 7207 public: |
| 7208 // [length]: The bound function "length" property. |
| 7209 DECL_ACCESSORS(length, Object) |
| 7210 |
| 7211 // [name]: The bound function "name" property. |
| 7212 DECL_ACCESSORS(name, Object) |
| 7213 |
| 7214 // [bound_target_function]: The wrapped function object. |
| 7215 DECL_ACCESSORS(bound_target_function, JSReceiver) |
| 7216 |
| 7217 // [bound_this]: The value that is always passed as the this value when |
| 7218 // calling the wrapped function. |
| 7219 DECL_ACCESSORS(bound_this, Object) |
| 7220 |
| 7221 // [bound_arguments]: A list of values whose elements are used as the first |
| 7222 // arguments to any call to the wrapped function. |
| 7223 DECL_ACCESSORS(bound_arguments, FixedArray) |
| 7224 |
| 7225 // [creation_context]: The native context in which the function was bound. |
| 7226 // TODO(bmeurer, verwaest): Can we (mis)use (unused) constructor field in |
| 7227 // the Map instead of putting this into the object? Only required for |
| 7228 // JSReceiver::GetCreationContext() anyway. |
| 7229 DECL_ACCESSORS(creation_context, Context) |
| 7230 |
| 7231 static MaybeHandle<Context> GetFunctionRealm( |
| 7232 Handle<JSBoundFunction> function); |
| 7233 |
| 7234 DECLARE_CAST(JSBoundFunction) |
| 7235 |
| 7236 // Dispatched behavior. |
| 7237 DECLARE_PRINTER(JSBoundFunction) |
| 7238 DECLARE_VERIFIER(JSBoundFunction) |
| 7239 |
| 7240 // The bound function's string representation implemented according |
| 7241 // to ES6 section 19.2.3.5 Function.prototype.toString ( ). |
| 7242 static Handle<String> ToString(Handle<JSBoundFunction> function); |
| 7243 |
| 7244 // Layout description. |
| 7245 static const int kBoundTargetFunctionOffset = JSObject::kHeaderSize; |
| 7246 static const int kBoundThisOffset = kBoundTargetFunctionOffset + kPointerSize; |
| 7247 static const int kBoundArgumentsOffset = kBoundThisOffset + kPointerSize; |
| 7248 static const int kCreationContextOffset = |
| 7249 kBoundArgumentsOffset + kPointerSize; |
| 7250 static const int kLengthOffset = kCreationContextOffset + kPointerSize; |
| 7251 static const int kNameOffset = kLengthOffset + kPointerSize; |
| 7252 static const int kSize = kNameOffset + kPointerSize; |
| 7253 |
| 7254 // Indices of in-object properties. |
| 7255 static const int kLengthIndex = 0; |
| 7256 static const int kNameIndex = 1; |
| 7257 |
| 7258 private: |
| 7259 DISALLOW_IMPLICIT_CONSTRUCTORS(JSBoundFunction); |
| 7260 }; |
| 7261 |
| 7262 |
7248 // JSFunction describes JavaScript functions. | 7263 // JSFunction describes JavaScript functions. |
7249 class JSFunction: public JSObject { | 7264 class JSFunction: public JSObject { |
7250 public: | 7265 public: |
7251 // [prototype_or_initial_map]: | 7266 // [prototype_or_initial_map]: |
7252 DECL_ACCESSORS(prototype_or_initial_map, Object) | 7267 DECL_ACCESSORS(prototype_or_initial_map, Object) |
7253 | 7268 |
7254 // [shared]: The information about the function that | 7269 // [shared]: The information about the function that |
7255 // can be shared by instances. | 7270 // can be shared by instances. |
7256 DECL_ACCESSORS(shared, SharedFunctionInfo) | 7271 DECL_ACCESSORS(shared, SharedFunctionInfo) |
7257 | 7272 |
(...skipping 29 matching lines...) Expand all Loading... |
7287 // recompilation. | 7302 // recompilation. |
7288 inline bool IsMarkedForOptimization(); | 7303 inline bool IsMarkedForOptimization(); |
7289 inline bool IsMarkedForConcurrentOptimization(); | 7304 inline bool IsMarkedForConcurrentOptimization(); |
7290 | 7305 |
7291 // Tells whether or not the function is on the concurrent recompilation queue. | 7306 // Tells whether or not the function is on the concurrent recompilation queue. |
7292 inline bool IsInOptimizationQueue(); | 7307 inline bool IsInOptimizationQueue(); |
7293 | 7308 |
7294 // Completes inobject slack tracking on initial map if it is active. | 7309 // Completes inobject slack tracking on initial map if it is active. |
7295 inline void CompleteInobjectSlackTrackingIfActive(); | 7310 inline void CompleteInobjectSlackTrackingIfActive(); |
7296 | 7311 |
7297 // [literals_or_bindings]: Fixed array holding either | 7312 // [literals]: Fixed array holding the materialized literals. |
7298 // the materialized literals or the bindings of a bound function. | |
7299 // | 7313 // |
7300 // If the function contains object, regexp or array literals, the | 7314 // If the function contains object, regexp or array literals, the |
7301 // literals array prefix contains the object, regexp, and array | 7315 // literals array prefix contains the object, regexp, and array |
7302 // function to be used when creating these literals. This is | 7316 // function to be used when creating these literals. This is |
7303 // necessary so that we do not dynamically lookup the object, regexp | 7317 // necessary so that we do not dynamically lookup the object, regexp |
7304 // or array functions. Performing a dynamic lookup, we might end up | 7318 // or array functions. Performing a dynamic lookup, we might end up |
7305 // using the functions from a new context that we should not have | 7319 // using the functions from a new context that we should not have |
7306 // access to. | 7320 // access to. |
7307 // | 7321 DECL_ACCESSORS(literals, LiteralsArray) |
7308 // On bound functions, the array is a (copy-on-write) fixed-array containing | |
7309 // the function that was bound, bound this-value and any bound | |
7310 // arguments. Bound functions never contain literals. | |
7311 DECL_ACCESSORS(literals_or_bindings, FixedArray) | |
7312 | |
7313 inline LiteralsArray* literals(); | |
7314 inline void set_literals(LiteralsArray* literals); | |
7315 | |
7316 inline BindingsArray* function_bindings(); | |
7317 inline void set_function_bindings(BindingsArray* bindings); | |
7318 | 7322 |
7319 // The initial map for an object created by this constructor. | 7323 // The initial map for an object created by this constructor. |
7320 inline Map* initial_map(); | 7324 inline Map* initial_map(); |
7321 static void SetInitialMap(Handle<JSFunction> function, Handle<Map> map, | 7325 static void SetInitialMap(Handle<JSFunction> function, Handle<Map> map, |
7322 Handle<Object> prototype); | 7326 Handle<Object> prototype); |
7323 inline bool has_initial_map(); | 7327 inline bool has_initial_map(); |
7324 static void EnsureHasInitialMap(Handle<JSFunction> function); | 7328 static void EnsureHasInitialMap(Handle<JSFunction> function); |
7325 | 7329 |
7326 // Creates a map that matches the constructor's initial map, but with | 7330 // Creates a map that matches the constructor's initial map, but with |
7327 // [[prototype]] being new.target.prototype. Because new.target can be a | 7331 // [[prototype]] being new.target.prototype. Because new.target can be a |
(...skipping 3388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10716 } | 10720 } |
10717 return value; | 10721 return value; |
10718 } | 10722 } |
10719 }; | 10723 }; |
10720 | 10724 |
10721 | 10725 |
10722 } // NOLINT, false-positive due to second-order macros. | 10726 } // NOLINT, false-positive due to second-order macros. |
10723 } // NOLINT, false-positive due to second-order macros. | 10727 } // NOLINT, false-positive due to second-order macros. |
10724 | 10728 |
10725 #endif // V8_OBJECTS_H_ | 10729 #endif // V8_OBJECTS_H_ |
OLD | NEW |