OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 | 868 |
869 #define DECLARE_CAST(type) \ | 869 #define DECLARE_CAST(type) \ |
870 INLINE(static type* cast(Object* object)); \ | 870 INLINE(static type* cast(Object* object)); \ |
871 INLINE(static const type* cast(const Object* object)); | 871 INLINE(static const type* cast(const Object* object)); |
872 | 872 |
873 | 873 |
874 class AccessorPair; | 874 class AccessorPair; |
875 class AllocationSite; | 875 class AllocationSite; |
876 class AllocationSiteCreationContext; | 876 class AllocationSiteCreationContext; |
877 class AllocationSiteUsageContext; | 877 class AllocationSiteUsageContext; |
| 878 class Cell; |
878 class ConsString; | 879 class ConsString; |
879 class DictionaryElementsAccessor; | 880 class DictionaryElementsAccessor; |
880 class ElementsAccessor; | 881 class ElementsAccessor; |
881 class FixedArrayBase; | 882 class FixedArrayBase; |
882 class FunctionLiteral; | 883 class FunctionLiteral; |
883 class GlobalObject; | 884 class GlobalObject; |
| 885 class JSBuiltinsObject; |
884 class LayoutDescriptor; | 886 class LayoutDescriptor; |
885 class LookupIterator; | 887 class LookupIterator; |
| 888 class ObjectHashTable; |
886 class ObjectVisitor; | 889 class ObjectVisitor; |
| 890 class PropertyCell; |
| 891 class SafepointEntry; |
| 892 class SharedFunctionInfo; |
887 class StringStream; | 893 class StringStream; |
| 894 class TypeFeedbackInfo; |
888 class TypeFeedbackVector; | 895 class TypeFeedbackVector; |
889 class WeakCell; | 896 class WeakCell; |
890 | 897 |
891 // We cannot just say "class HeapType;" if it is created from a template... =8-? | 898 // We cannot just say "class HeapType;" if it is created from a template... =8-? |
892 template<class> class TypeImpl; | 899 template<class> class TypeImpl; |
893 struct HeapTypeConfig; | 900 struct HeapTypeConfig; |
894 typedef TypeImpl<HeapTypeConfig> HeapType; | 901 typedef TypeImpl<HeapTypeConfig> HeapType; |
895 | 902 |
896 | 903 |
897 // A template-ized version of the IsXXX functions. | 904 // A template-ized version of the IsXXX functions. |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1726 // Computes the enumerable keys for a JSObject. Used for implementing | 1733 // Computes the enumerable keys for a JSObject. Used for implementing |
1727 // "for (n in object) { }". | 1734 // "for (n in object) { }". |
1728 MUST_USE_RESULT static MaybeHandle<FixedArray> GetKeys( | 1735 MUST_USE_RESULT static MaybeHandle<FixedArray> GetKeys( |
1729 Handle<JSReceiver> object, | 1736 Handle<JSReceiver> object, |
1730 KeyCollectionType type); | 1737 KeyCollectionType type); |
1731 | 1738 |
1732 private: | 1739 private: |
1733 DISALLOW_IMPLICIT_CONSTRUCTORS(JSReceiver); | 1740 DISALLOW_IMPLICIT_CONSTRUCTORS(JSReceiver); |
1734 }; | 1741 }; |
1735 | 1742 |
1736 // Forward declaration for JSObject::GetOrCreateHiddenPropertiesHashTable. | |
1737 class ObjectHashTable; | |
1738 | |
1739 | 1743 |
1740 // The JSObject describes real heap allocated JavaScript objects with | 1744 // The JSObject describes real heap allocated JavaScript objects with |
1741 // properties. | 1745 // properties. |
1742 // Note that the map of JSObject changes during execution to enable inline | 1746 // Note that the map of JSObject changes during execution to enable inline |
1743 // caching. | 1747 // caching. |
1744 class JSObject: public JSReceiver { | 1748 class JSObject: public JSReceiver { |
1745 public: | 1749 public: |
1746 // [properties]: Backing storage for properties. | 1750 // [properties]: Backing storage for properties. |
1747 // properties is a FixedArray in the fast case and a Dictionary in the | 1751 // properties is a FixedArray in the fast case and a Dictionary in the |
1748 // slow case. | 1752 // slow case. |
(...skipping 3078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4827 static const int kReturnOffsetIndex = 0; | 4831 static const int kReturnOffsetIndex = 0; |
4828 static const int kReturnHandlerIndex = 1; | 4832 static const int kReturnHandlerIndex = 1; |
4829 static const int kReturnEntrySize = 2; | 4833 static const int kReturnEntrySize = 2; |
4830 | 4834 |
4831 // Encoding of the {handler} field. | 4835 // Encoding of the {handler} field. |
4832 class HandlerPredictionField : public BitField<CatchPrediction, 0, 1> {}; | 4836 class HandlerPredictionField : public BitField<CatchPrediction, 0, 1> {}; |
4833 class HandlerOffsetField : public BitField<int, 1, 30> {}; | 4837 class HandlerOffsetField : public BitField<int, 1, 30> {}; |
4834 }; | 4838 }; |
4835 | 4839 |
4836 | 4840 |
4837 // Forward declaration. | |
4838 class Cell; | |
4839 class PropertyCell; | |
4840 class SafepointEntry; | |
4841 class TypeFeedbackInfo; | |
4842 | |
4843 // Code describes objects with on-the-fly generated machine code. | 4841 // Code describes objects with on-the-fly generated machine code. |
4844 class Code: public HeapObject { | 4842 class Code: public HeapObject { |
4845 public: | 4843 public: |
4846 // Opaque data type for encapsulating code flags like kind, inline | 4844 // Opaque data type for encapsulating code flags like kind, inline |
4847 // cache state, and arguments count. | 4845 // cache state, and arguments count. |
4848 typedef uint32_t Flags; | 4846 typedef uint32_t Flags; |
4849 | 4847 |
4850 #define NON_IC_KIND_LIST(V) \ | 4848 #define NON_IC_KIND_LIST(V) \ |
4851 V(FUNCTION) \ | 4849 V(FUNCTION) \ |
4852 V(OPTIMIZED_FUNCTION) \ | 4850 V(OPTIMIZED_FUNCTION) \ |
(...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6396 DECL_ACCESSORS(line_ends, Object) | 6394 DECL_ACCESSORS(line_ends, Object) |
6397 | 6395 |
6398 // [eval_from_shared]: for eval scripts the shared funcion info for the | 6396 // [eval_from_shared]: for eval scripts the shared funcion info for the |
6399 // function from which eval was called. | 6397 // function from which eval was called. |
6400 DECL_ACCESSORS(eval_from_shared, Object) | 6398 DECL_ACCESSORS(eval_from_shared, Object) |
6401 | 6399 |
6402 // [eval_from_instructions_offset]: the instruction offset in the code for the | 6400 // [eval_from_instructions_offset]: the instruction offset in the code for the |
6403 // function from which eval was called where eval was called. | 6401 // function from which eval was called where eval was called. |
6404 DECL_ACCESSORS(eval_from_instructions_offset, Smi) | 6402 DECL_ACCESSORS(eval_from_instructions_offset, Smi) |
6405 | 6403 |
| 6404 // [shared_function_infos]: weak fixed array containing all shared |
| 6405 // function infos created from this script. |
| 6406 DECL_ACCESSORS(shared_function_infos, Object) |
| 6407 |
6406 // [flags]: Holds an exciting bitfield. | 6408 // [flags]: Holds an exciting bitfield. |
6407 DECL_ACCESSORS(flags, Smi) | 6409 DECL_ACCESSORS(flags, Smi) |
6408 | 6410 |
6409 // [source_url]: sourceURL from magic comment | 6411 // [source_url]: sourceURL from magic comment |
6410 DECL_ACCESSORS(source_url, Object) | 6412 DECL_ACCESSORS(source_url, Object) |
6411 | 6413 |
6412 // [source_url]: sourceMappingURL magic comment | 6414 // [source_url]: sourceMappingURL magic comment |
6413 DECL_ACCESSORS(source_mapping_url, Object) | 6415 DECL_ACCESSORS(source_mapping_url, Object) |
6414 | 6416 |
6415 // [compilation_type]: how the the script was compiled. Encoded in the | 6417 // [compilation_type]: how the the script was compiled. Encoded in the |
(...skipping 27 matching lines...) Expand all Loading... |
6443 int GetLineNumber(int code_pos); | 6445 int GetLineNumber(int code_pos); |
6444 | 6446 |
6445 static Handle<Object> GetNameOrSourceURL(Handle<Script> script); | 6447 static Handle<Object> GetNameOrSourceURL(Handle<Script> script); |
6446 | 6448 |
6447 // Init line_ends array with code positions of line ends inside script source. | 6449 // Init line_ends array with code positions of line ends inside script source. |
6448 static void InitLineEnds(Handle<Script> script); | 6450 static void InitLineEnds(Handle<Script> script); |
6449 | 6451 |
6450 // Get the JS object wrapping the given script; create it if none exists. | 6452 // Get the JS object wrapping the given script; create it if none exists. |
6451 static Handle<JSObject> GetWrapper(Handle<Script> script); | 6453 static Handle<JSObject> GetWrapper(Handle<Script> script); |
6452 | 6454 |
| 6455 // Look through the list of existing shared function infos to find one |
| 6456 // that matches the function literal. Return empty handle if not found. |
| 6457 MaybeHandle<SharedFunctionInfo> FindSharedFunctionInfo(FunctionLiteral* fun); |
| 6458 |
6453 // Dispatched behavior. | 6459 // Dispatched behavior. |
6454 DECLARE_PRINTER(Script) | 6460 DECLARE_PRINTER(Script) |
6455 DECLARE_VERIFIER(Script) | 6461 DECLARE_VERIFIER(Script) |
6456 | 6462 |
6457 static const int kSourceOffset = HeapObject::kHeaderSize; | 6463 static const int kSourceOffset = HeapObject::kHeaderSize; |
6458 static const int kNameOffset = kSourceOffset + kPointerSize; | 6464 static const int kNameOffset = kSourceOffset + kPointerSize; |
6459 static const int kLineOffsetOffset = kNameOffset + kPointerSize; | 6465 static const int kLineOffsetOffset = kNameOffset + kPointerSize; |
6460 static const int kColumnOffsetOffset = kLineOffsetOffset + kPointerSize; | 6466 static const int kColumnOffsetOffset = kLineOffsetOffset + kPointerSize; |
6461 static const int kContextOffset = kColumnOffsetOffset + kPointerSize; | 6467 static const int kContextOffset = kColumnOffsetOffset + kPointerSize; |
6462 static const int kWrapperOffset = kContextOffset + kPointerSize; | 6468 static const int kWrapperOffset = kContextOffset + kPointerSize; |
6463 static const int kTypeOffset = kWrapperOffset + kPointerSize; | 6469 static const int kTypeOffset = kWrapperOffset + kPointerSize; |
6464 static const int kLineEndsOffset = kTypeOffset + kPointerSize; | 6470 static const int kLineEndsOffset = kTypeOffset + kPointerSize; |
6465 static const int kIdOffset = kLineEndsOffset + kPointerSize; | 6471 static const int kIdOffset = kLineEndsOffset + kPointerSize; |
6466 static const int kEvalFromSharedOffset = kIdOffset + kPointerSize; | 6472 static const int kEvalFromSharedOffset = kIdOffset + kPointerSize; |
6467 static const int kEvalFrominstructionsOffsetOffset = | 6473 static const int kEvalFrominstructionsOffsetOffset = |
6468 kEvalFromSharedOffset + kPointerSize; | 6474 kEvalFromSharedOffset + kPointerSize; |
6469 static const int kFlagsOffset = | 6475 static const int kSharedFunctionInfosOffset = |
6470 kEvalFrominstructionsOffsetOffset + kPointerSize; | 6476 kEvalFrominstructionsOffsetOffset + kPointerSize; |
| 6477 static const int kFlagsOffset = kSharedFunctionInfosOffset + kPointerSize; |
6471 static const int kSourceUrlOffset = kFlagsOffset + kPointerSize; | 6478 static const int kSourceUrlOffset = kFlagsOffset + kPointerSize; |
6472 static const int kSourceMappingUrlOffset = kSourceUrlOffset + kPointerSize; | 6479 static const int kSourceMappingUrlOffset = kSourceUrlOffset + kPointerSize; |
6473 static const int kSize = kSourceMappingUrlOffset + kPointerSize; | 6480 static const int kSize = kSourceMappingUrlOffset + kPointerSize; |
6474 | 6481 |
6475 private: | 6482 private: |
6476 int GetLineNumberWithArray(int code_pos); | 6483 int GetLineNumberWithArray(int code_pos); |
6477 | 6484 |
6478 // Bit positions in the flags field. | 6485 // Bit positions in the flags field. |
6479 static const int kCompilationTypeBit = 0; | 6486 static const int kCompilationTypeBit = 0; |
6480 static const int kCompilationStateBit = 1; | 6487 static const int kCompilationStateBit = 1; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6593 static void InitFromFunctionLiteral(Handle<SharedFunctionInfo> shared_info, | 6600 static void InitFromFunctionLiteral(Handle<SharedFunctionInfo> shared_info, |
6594 FunctionLiteral* lit); | 6601 FunctionLiteral* lit); |
6595 | 6602 |
6596 // Add a new entry to the optimized code map. | 6603 // Add a new entry to the optimized code map. |
6597 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, | 6604 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, |
6598 Handle<Context> native_context, | 6605 Handle<Context> native_context, |
6599 Handle<Code> code, | 6606 Handle<Code> code, |
6600 Handle<FixedArray> literals, | 6607 Handle<FixedArray> literals, |
6601 BailoutId osr_ast_id); | 6608 BailoutId osr_ast_id); |
6602 | 6609 |
| 6610 // Set up the link between shared function info and the script. The shared |
| 6611 // function info is added to the list on the script. |
| 6612 static void SetScript(Handle<SharedFunctionInfo> shared, |
| 6613 Handle<Object> script_object); |
| 6614 |
6603 // Layout description of the optimized code map. | 6615 // Layout description of the optimized code map. |
6604 static const int kNextMapIndex = 0; | 6616 static const int kNextMapIndex = 0; |
6605 static const int kEntriesStart = 1; | 6617 static const int kEntriesStart = 1; |
6606 static const int kContextOffset = 0; | 6618 static const int kContextOffset = 0; |
6607 static const int kCachedCodeOffset = 1; | 6619 static const int kCachedCodeOffset = 1; |
6608 static const int kLiteralsOffset = 2; | 6620 static const int kLiteralsOffset = 2; |
6609 static const int kOsrAstIdOffset = 3; | 6621 static const int kOsrAstIdOffset = 3; |
6610 static const int kEntryLength = 4; | 6622 static const int kEntryLength = 4; |
6611 static const int kInitialLength = kEntriesStart + kEntryLength; | 6623 static const int kInitialLength = kEntriesStart + kEntryLength; |
6612 | 6624 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6806 | 6818 |
6807 // Indicates that this function is a default constructor. | 6819 // Indicates that this function is a default constructor. |
6808 DECL_BOOLEAN_ACCESSORS(is_default_constructor) | 6820 DECL_BOOLEAN_ACCESSORS(is_default_constructor) |
6809 | 6821 |
6810 // Indicates that this function is an asm function. | 6822 // Indicates that this function is an asm function. |
6811 DECL_BOOLEAN_ACCESSORS(asm_function) | 6823 DECL_BOOLEAN_ACCESSORS(asm_function) |
6812 | 6824 |
6813 // Indicates that the the shared function info is deserialized from cache. | 6825 // Indicates that the the shared function info is deserialized from cache. |
6814 DECL_BOOLEAN_ACCESSORS(deserialized) | 6826 DECL_BOOLEAN_ACCESSORS(deserialized) |
6815 | 6827 |
| 6828 // Indicates that the the shared function info has never been compiled before. |
| 6829 DECL_BOOLEAN_ACCESSORS(never_compiled) |
| 6830 |
6816 inline FunctionKind kind(); | 6831 inline FunctionKind kind(); |
6817 inline void set_kind(FunctionKind kind); | 6832 inline void set_kind(FunctionKind kind); |
6818 | 6833 |
6819 // Indicates whether or not the code in the shared function support | 6834 // Indicates whether or not the code in the shared function support |
6820 // deoptimization. | 6835 // deoptimization. |
6821 inline bool has_deoptimization_support(); | 6836 inline bool has_deoptimization_support(); |
6822 | 6837 |
6823 // Enable deoptimization support through recompiled code. | 6838 // Enable deoptimization support through recompiled code. |
6824 void EnableDeoptimizationSupport(Code* recompiled); | 6839 void EnableDeoptimizationSupport(Code* recompiled); |
6825 | 6840 |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7055 kIsArrow, | 7070 kIsArrow, |
7056 kIsGenerator, | 7071 kIsGenerator, |
7057 kIsConciseMethod, | 7072 kIsConciseMethod, |
7058 kIsAccessorFunction, | 7073 kIsAccessorFunction, |
7059 kIsDefaultConstructor, | 7074 kIsDefaultConstructor, |
7060 kIsSubclassConstructor, | 7075 kIsSubclassConstructor, |
7061 kIsBaseConstructor, | 7076 kIsBaseConstructor, |
7062 kInClassLiteral, | 7077 kInClassLiteral, |
7063 kIsAsmFunction, | 7078 kIsAsmFunction, |
7064 kDeserialized, | 7079 kDeserialized, |
| 7080 kNeverCompiled, |
7065 kCompilerHintsCount // Pseudo entry | 7081 kCompilerHintsCount // Pseudo entry |
7066 }; | 7082 }; |
7067 // Add hints for other modes when they're added. | 7083 // Add hints for other modes when they're added. |
7068 STATIC_ASSERT(LANGUAGE_END == 3); | 7084 STATIC_ASSERT(LANGUAGE_END == 3); |
7069 | 7085 |
7070 class FunctionKindBits : public BitField<FunctionKind, kIsArrow, 8> {}; | 7086 class FunctionKindBits : public BitField<FunctionKind, kIsArrow, 8> {}; |
7071 | 7087 |
7072 class DeoptCountBits : public BitField<int, 0, 4> {}; | 7088 class DeoptCountBits : public BitField<int, 0, 4> {}; |
7073 class OptReenableTriesBits : public BitField<int, 4, 18> {}; | 7089 class OptReenableTriesBits : public BitField<int, 4, 18> {}; |
7074 class ICAgeBits : public BitField<int, 22, 8> {}; | 7090 class ICAgeBits : public BitField<int, 22, 8> {}; |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7472 // Layout description. | 7488 // Layout description. |
7473 static const int kNativeContextOffset = JSObject::kHeaderSize; | 7489 static const int kNativeContextOffset = JSObject::kHeaderSize; |
7474 static const int kHashOffset = kNativeContextOffset + kPointerSize; | 7490 static const int kHashOffset = kNativeContextOffset + kPointerSize; |
7475 static const int kSize = kHashOffset + kPointerSize; | 7491 static const int kSize = kHashOffset + kPointerSize; |
7476 | 7492 |
7477 private: | 7493 private: |
7478 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalProxy); | 7494 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalProxy); |
7479 }; | 7495 }; |
7480 | 7496 |
7481 | 7497 |
7482 // Forward declaration. | |
7483 class JSBuiltinsObject; | |
7484 | |
7485 // Common super class for JavaScript global objects and the special | 7498 // Common super class for JavaScript global objects and the special |
7486 // builtins global objects. | 7499 // builtins global objects. |
7487 class GlobalObject: public JSObject { | 7500 class GlobalObject: public JSObject { |
7488 public: | 7501 public: |
7489 // [builtins]: the object holding the runtime routines written in JS. | 7502 // [builtins]: the object holding the runtime routines written in JS. |
7490 DECL_ACCESSORS(builtins, JSBuiltinsObject) | 7503 DECL_ACCESSORS(builtins, JSBuiltinsObject) |
7491 | 7504 |
7492 // [native context]: the natives corresponding to this global object. | 7505 // [native context]: the natives corresponding to this global object. |
7493 DECL_ACCESSORS(native_context, Context) | 7506 DECL_ACCESSORS(native_context, Context) |
7494 | 7507 |
(...skipping 3301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10796 } else { | 10809 } else { |
10797 value &= ~(1 << bit_position); | 10810 value &= ~(1 << bit_position); |
10798 } | 10811 } |
10799 return value; | 10812 return value; |
10800 } | 10813 } |
10801 }; | 10814 }; |
10802 | 10815 |
10803 } } // namespace v8::internal | 10816 } } // namespace v8::internal |
10804 | 10817 |
10805 #endif // V8_OBJECTS_H_ | 10818 #endif // V8_OBJECTS_H_ |
OLD | NEW |