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; | |
879 class ConsString; | 878 class ConsString; |
880 class DictionaryElementsAccessor; | 879 class DictionaryElementsAccessor; |
881 class ElementsAccessor; | 880 class ElementsAccessor; |
882 class FixedArrayBase; | 881 class FixedArrayBase; |
883 class FunctionLiteral; | 882 class FunctionLiteral; |
884 class GlobalObject; | 883 class GlobalObject; |
885 class JSBuiltinsObject; | |
886 class LayoutDescriptor; | 884 class LayoutDescriptor; |
887 class LookupIterator; | 885 class LookupIterator; |
888 class ObjectHashTable; | |
889 class ObjectVisitor; | 886 class ObjectVisitor; |
890 class PropertyCell; | |
891 class SafepointEntry; | |
892 class SharedFunctionInfo; | |
893 class StringStream; | 887 class StringStream; |
894 class TypeFeedbackInfo; | |
895 class TypeFeedbackVector; | 888 class TypeFeedbackVector; |
896 class WeakCell; | 889 class WeakCell; |
897 | 890 |
898 // We cannot just say "class HeapType;" if it is created from a template... =8-? | 891 // We cannot just say "class HeapType;" if it is created from a template... =8-? |
899 template<class> class TypeImpl; | 892 template<class> class TypeImpl; |
900 struct HeapTypeConfig; | 893 struct HeapTypeConfig; |
901 typedef TypeImpl<HeapTypeConfig> HeapType; | 894 typedef TypeImpl<HeapTypeConfig> HeapType; |
902 | 895 |
903 | 896 |
904 // A template-ized version of the IsXXX functions. | 897 // A template-ized version of the IsXXX functions. |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1733 // Computes the enumerable keys for a JSObject. Used for implementing | 1726 // Computes the enumerable keys for a JSObject. Used for implementing |
1734 // "for (n in object) { }". | 1727 // "for (n in object) { }". |
1735 MUST_USE_RESULT static MaybeHandle<FixedArray> GetKeys( | 1728 MUST_USE_RESULT static MaybeHandle<FixedArray> GetKeys( |
1736 Handle<JSReceiver> object, | 1729 Handle<JSReceiver> object, |
1737 KeyCollectionType type); | 1730 KeyCollectionType type); |
1738 | 1731 |
1739 private: | 1732 private: |
1740 DISALLOW_IMPLICIT_CONSTRUCTORS(JSReceiver); | 1733 DISALLOW_IMPLICIT_CONSTRUCTORS(JSReceiver); |
1741 }; | 1734 }; |
1742 | 1735 |
| 1736 // Forward declaration for JSObject::GetOrCreateHiddenPropertiesHashTable. |
| 1737 class ObjectHashTable; |
| 1738 |
1743 | 1739 |
1744 // The JSObject describes real heap allocated JavaScript objects with | 1740 // The JSObject describes real heap allocated JavaScript objects with |
1745 // properties. | 1741 // properties. |
1746 // Note that the map of JSObject changes during execution to enable inline | 1742 // Note that the map of JSObject changes during execution to enable inline |
1747 // caching. | 1743 // caching. |
1748 class JSObject: public JSReceiver { | 1744 class JSObject: public JSReceiver { |
1749 public: | 1745 public: |
1750 // [properties]: Backing storage for properties. | 1746 // [properties]: Backing storage for properties. |
1751 // properties is a FixedArray in the fast case and a Dictionary in the | 1747 // properties is a FixedArray in the fast case and a Dictionary in the |
1752 // slow case. | 1748 // slow case. |
(...skipping 3090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4843 static const int kReturnOffsetIndex = 0; | 4839 static const int kReturnOffsetIndex = 0; |
4844 static const int kReturnHandlerIndex = 1; | 4840 static const int kReturnHandlerIndex = 1; |
4845 static const int kReturnEntrySize = 2; | 4841 static const int kReturnEntrySize = 2; |
4846 | 4842 |
4847 // Encoding of the {handler} field. | 4843 // Encoding of the {handler} field. |
4848 class HandlerPredictionField : public BitField<CatchPrediction, 0, 1> {}; | 4844 class HandlerPredictionField : public BitField<CatchPrediction, 0, 1> {}; |
4849 class HandlerOffsetField : public BitField<int, 1, 30> {}; | 4845 class HandlerOffsetField : public BitField<int, 1, 30> {}; |
4850 }; | 4846 }; |
4851 | 4847 |
4852 | 4848 |
| 4849 // Forward declaration. |
| 4850 class Cell; |
| 4851 class PropertyCell; |
| 4852 class SafepointEntry; |
| 4853 class TypeFeedbackInfo; |
| 4854 |
4853 // Code describes objects with on-the-fly generated machine code. | 4855 // Code describes objects with on-the-fly generated machine code. |
4854 class Code: public HeapObject { | 4856 class Code: public HeapObject { |
4855 public: | 4857 public: |
4856 // Opaque data type for encapsulating code flags like kind, inline | 4858 // Opaque data type for encapsulating code flags like kind, inline |
4857 // cache state, and arguments count. | 4859 // cache state, and arguments count. |
4858 typedef uint32_t Flags; | 4860 typedef uint32_t Flags; |
4859 | 4861 |
4860 #define NON_IC_KIND_LIST(V) \ | 4862 #define NON_IC_KIND_LIST(V) \ |
4861 V(FUNCTION) \ | 4863 V(FUNCTION) \ |
4862 V(OPTIMIZED_FUNCTION) \ | 4864 V(OPTIMIZED_FUNCTION) \ |
(...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6406 DECL_ACCESSORS(line_ends, Object) | 6408 DECL_ACCESSORS(line_ends, Object) |
6407 | 6409 |
6408 // [eval_from_shared]: for eval scripts the shared funcion info for the | 6410 // [eval_from_shared]: for eval scripts the shared funcion info for the |
6409 // function from which eval was called. | 6411 // function from which eval was called. |
6410 DECL_ACCESSORS(eval_from_shared, Object) | 6412 DECL_ACCESSORS(eval_from_shared, Object) |
6411 | 6413 |
6412 // [eval_from_instructions_offset]: the instruction offset in the code for the | 6414 // [eval_from_instructions_offset]: the instruction offset in the code for the |
6413 // function from which eval was called where eval was called. | 6415 // function from which eval was called where eval was called. |
6414 DECL_ACCESSORS(eval_from_instructions_offset, Smi) | 6416 DECL_ACCESSORS(eval_from_instructions_offset, Smi) |
6415 | 6417 |
6416 // [shared_function_infos]: weak fixed array containing all shared | |
6417 // function infos created from this script. | |
6418 DECL_ACCESSORS(shared_function_infos, Object) | |
6419 | |
6420 // [flags]: Holds an exciting bitfield. | 6418 // [flags]: Holds an exciting bitfield. |
6421 DECL_ACCESSORS(flags, Smi) | 6419 DECL_ACCESSORS(flags, Smi) |
6422 | 6420 |
6423 // [source_url]: sourceURL from magic comment | 6421 // [source_url]: sourceURL from magic comment |
6424 DECL_ACCESSORS(source_url, Object) | 6422 DECL_ACCESSORS(source_url, Object) |
6425 | 6423 |
6426 // [source_url]: sourceMappingURL magic comment | 6424 // [source_url]: sourceMappingURL magic comment |
6427 DECL_ACCESSORS(source_mapping_url, Object) | 6425 DECL_ACCESSORS(source_mapping_url, Object) |
6428 | 6426 |
6429 // [compilation_type]: how the the script was compiled. Encoded in the | 6427 // [compilation_type]: how the the script was compiled. Encoded in the |
(...skipping 27 matching lines...) Expand all Loading... |
6457 int GetLineNumber(int code_pos); | 6455 int GetLineNumber(int code_pos); |
6458 | 6456 |
6459 static Handle<Object> GetNameOrSourceURL(Handle<Script> script); | 6457 static Handle<Object> GetNameOrSourceURL(Handle<Script> script); |
6460 | 6458 |
6461 // Init line_ends array with code positions of line ends inside script source. | 6459 // Init line_ends array with code positions of line ends inside script source. |
6462 static void InitLineEnds(Handle<Script> script); | 6460 static void InitLineEnds(Handle<Script> script); |
6463 | 6461 |
6464 // Get the JS object wrapping the given script; create it if none exists. | 6462 // Get the JS object wrapping the given script; create it if none exists. |
6465 static Handle<JSObject> GetWrapper(Handle<Script> script); | 6463 static Handle<JSObject> GetWrapper(Handle<Script> script); |
6466 | 6464 |
6467 // Look through the list of existing shared function infos to find one | |
6468 // that matches the function literal. Return empty handle if not found. | |
6469 MaybeHandle<SharedFunctionInfo> FindSharedFunctionInfo(FunctionLiteral* fun); | |
6470 | |
6471 // Dispatched behavior. | 6465 // Dispatched behavior. |
6472 DECLARE_PRINTER(Script) | 6466 DECLARE_PRINTER(Script) |
6473 DECLARE_VERIFIER(Script) | 6467 DECLARE_VERIFIER(Script) |
6474 | 6468 |
6475 static const int kSourceOffset = HeapObject::kHeaderSize; | 6469 static const int kSourceOffset = HeapObject::kHeaderSize; |
6476 static const int kNameOffset = kSourceOffset + kPointerSize; | 6470 static const int kNameOffset = kSourceOffset + kPointerSize; |
6477 static const int kLineOffsetOffset = kNameOffset + kPointerSize; | 6471 static const int kLineOffsetOffset = kNameOffset + kPointerSize; |
6478 static const int kColumnOffsetOffset = kLineOffsetOffset + kPointerSize; | 6472 static const int kColumnOffsetOffset = kLineOffsetOffset + kPointerSize; |
6479 static const int kContextOffset = kColumnOffsetOffset + kPointerSize; | 6473 static const int kContextOffset = kColumnOffsetOffset + kPointerSize; |
6480 static const int kWrapperOffset = kContextOffset + kPointerSize; | 6474 static const int kWrapperOffset = kContextOffset + kPointerSize; |
6481 static const int kTypeOffset = kWrapperOffset + kPointerSize; | 6475 static const int kTypeOffset = kWrapperOffset + kPointerSize; |
6482 static const int kLineEndsOffset = kTypeOffset + kPointerSize; | 6476 static const int kLineEndsOffset = kTypeOffset + kPointerSize; |
6483 static const int kIdOffset = kLineEndsOffset + kPointerSize; | 6477 static const int kIdOffset = kLineEndsOffset + kPointerSize; |
6484 static const int kEvalFromSharedOffset = kIdOffset + kPointerSize; | 6478 static const int kEvalFromSharedOffset = kIdOffset + kPointerSize; |
6485 static const int kEvalFrominstructionsOffsetOffset = | 6479 static const int kEvalFrominstructionsOffsetOffset = |
6486 kEvalFromSharedOffset + kPointerSize; | 6480 kEvalFromSharedOffset + kPointerSize; |
6487 static const int kSharedFunctionInfosOffset = | 6481 static const int kFlagsOffset = |
6488 kEvalFrominstructionsOffsetOffset + kPointerSize; | 6482 kEvalFrominstructionsOffsetOffset + kPointerSize; |
6489 static const int kFlagsOffset = kSharedFunctionInfosOffset + kPointerSize; | |
6490 static const int kSourceUrlOffset = kFlagsOffset + kPointerSize; | 6483 static const int kSourceUrlOffset = kFlagsOffset + kPointerSize; |
6491 static const int kSourceMappingUrlOffset = kSourceUrlOffset + kPointerSize; | 6484 static const int kSourceMappingUrlOffset = kSourceUrlOffset + kPointerSize; |
6492 static const int kSize = kSourceMappingUrlOffset + kPointerSize; | 6485 static const int kSize = kSourceMappingUrlOffset + kPointerSize; |
6493 | 6486 |
6494 private: | 6487 private: |
6495 int GetLineNumberWithArray(int code_pos); | 6488 int GetLineNumberWithArray(int code_pos); |
6496 | 6489 |
6497 // Bit positions in the flags field. | 6490 // Bit positions in the flags field. |
6498 static const int kCompilationTypeBit = 0; | 6491 static const int kCompilationTypeBit = 0; |
6499 static const int kCompilationStateBit = 1; | 6492 static const int kCompilationStateBit = 1; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6610 static void InitFromFunctionLiteral(Handle<SharedFunctionInfo> shared_info, | 6603 static void InitFromFunctionLiteral(Handle<SharedFunctionInfo> shared_info, |
6611 FunctionLiteral* lit); | 6604 FunctionLiteral* lit); |
6612 | 6605 |
6613 // Add a new entry to the optimized code map. | 6606 // Add a new entry to the optimized code map. |
6614 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, | 6607 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, |
6615 Handle<Context> native_context, | 6608 Handle<Context> native_context, |
6616 Handle<Code> code, | 6609 Handle<Code> code, |
6617 Handle<FixedArray> literals, | 6610 Handle<FixedArray> literals, |
6618 BailoutId osr_ast_id); | 6611 BailoutId osr_ast_id); |
6619 | 6612 |
6620 // Set up the link between shared function info and the script. The shared | |
6621 // function info is added to the list on the script. | |
6622 static void SetScript(Handle<SharedFunctionInfo> shared, | |
6623 Handle<Object> script_object); | |
6624 | |
6625 // Layout description of the optimized code map. | 6613 // Layout description of the optimized code map. |
6626 static const int kNextMapIndex = 0; | 6614 static const int kNextMapIndex = 0; |
6627 static const int kEntriesStart = 1; | 6615 static const int kEntriesStart = 1; |
6628 static const int kContextOffset = 0; | 6616 static const int kContextOffset = 0; |
6629 static const int kCachedCodeOffset = 1; | 6617 static const int kCachedCodeOffset = 1; |
6630 static const int kLiteralsOffset = 2; | 6618 static const int kLiteralsOffset = 2; |
6631 static const int kOsrAstIdOffset = 3; | 6619 static const int kOsrAstIdOffset = 3; |
6632 static const int kEntryLength = 4; | 6620 static const int kEntryLength = 4; |
6633 static const int kInitialLength = kEntriesStart + kEntryLength; | 6621 static const int kInitialLength = kEntriesStart + kEntryLength; |
6634 | 6622 |
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7494 // Layout description. | 7482 // Layout description. |
7495 static const int kNativeContextOffset = JSObject::kHeaderSize; | 7483 static const int kNativeContextOffset = JSObject::kHeaderSize; |
7496 static const int kHashOffset = kNativeContextOffset + kPointerSize; | 7484 static const int kHashOffset = kNativeContextOffset + kPointerSize; |
7497 static const int kSize = kHashOffset + kPointerSize; | 7485 static const int kSize = kHashOffset + kPointerSize; |
7498 | 7486 |
7499 private: | 7487 private: |
7500 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalProxy); | 7488 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalProxy); |
7501 }; | 7489 }; |
7502 | 7490 |
7503 | 7491 |
| 7492 // Forward declaration. |
| 7493 class JSBuiltinsObject; |
| 7494 |
7504 // Common super class for JavaScript global objects and the special | 7495 // Common super class for JavaScript global objects and the special |
7505 // builtins global objects. | 7496 // builtins global objects. |
7506 class GlobalObject: public JSObject { | 7497 class GlobalObject: public JSObject { |
7507 public: | 7498 public: |
7508 // [builtins]: the object holding the runtime routines written in JS. | 7499 // [builtins]: the object holding the runtime routines written in JS. |
7509 DECL_ACCESSORS(builtins, JSBuiltinsObject) | 7500 DECL_ACCESSORS(builtins, JSBuiltinsObject) |
7510 | 7501 |
7511 // [native context]: the natives corresponding to this global object. | 7502 // [native context]: the natives corresponding to this global object. |
7512 DECL_ACCESSORS(native_context, Context) | 7503 DECL_ACCESSORS(native_context, Context) |
7513 | 7504 |
(...skipping 3297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10811 } else { | 10802 } else { |
10812 value &= ~(1 << bit_position); | 10803 value &= ~(1 << bit_position); |
10813 } | 10804 } |
10814 return value; | 10805 return value; |
10815 } | 10806 } |
10816 }; | 10807 }; |
10817 | 10808 |
10818 } } // namespace v8::internal | 10809 } } // namespace v8::internal |
10819 | 10810 |
10820 #endif // V8_OBJECTS_H_ | 10811 #endif // V8_OBJECTS_H_ |
OLD | NEW |