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 3127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4876 static const int kReturnOffsetIndex = 0; | 4880 static const int kReturnOffsetIndex = 0; |
4877 static const int kReturnHandlerIndex = 1; | 4881 static const int kReturnHandlerIndex = 1; |
4878 static const int kReturnEntrySize = 2; | 4882 static const int kReturnEntrySize = 2; |
4879 | 4883 |
4880 // Encoding of the {handler} field. | 4884 // Encoding of the {handler} field. |
4881 class HandlerPredictionField : public BitField<CatchPrediction, 0, 1> {}; | 4885 class HandlerPredictionField : public BitField<CatchPrediction, 0, 1> {}; |
4882 class HandlerOffsetField : public BitField<int, 1, 30> {}; | 4886 class HandlerOffsetField : public BitField<int, 1, 30> {}; |
4883 }; | 4887 }; |
4884 | 4888 |
4885 | 4889 |
4886 // Forward declaration. | |
4887 class Cell; | |
4888 class PropertyCell; | |
4889 class SafepointEntry; | |
4890 class TypeFeedbackInfo; | |
4891 | |
4892 // Code describes objects with on-the-fly generated machine code. | 4890 // Code describes objects with on-the-fly generated machine code. |
4893 class Code: public HeapObject { | 4891 class Code: public HeapObject { |
4894 public: | 4892 public: |
4895 // Opaque data type for encapsulating code flags like kind, inline | 4893 // Opaque data type for encapsulating code flags like kind, inline |
4896 // cache state, and arguments count. | 4894 // cache state, and arguments count. |
4897 typedef uint32_t Flags; | 4895 typedef uint32_t Flags; |
4898 | 4896 |
4899 #define NON_IC_KIND_LIST(V) \ | 4897 #define NON_IC_KIND_LIST(V) \ |
4900 V(FUNCTION) \ | 4898 V(FUNCTION) \ |
4901 V(OPTIMIZED_FUNCTION) \ | 4899 V(OPTIMIZED_FUNCTION) \ |
(...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6449 DECL_ACCESSORS(line_ends, Object) | 6447 DECL_ACCESSORS(line_ends, Object) |
6450 | 6448 |
6451 // [eval_from_shared]: for eval scripts the shared funcion info for the | 6449 // [eval_from_shared]: for eval scripts the shared funcion info for the |
6452 // function from which eval was called. | 6450 // function from which eval was called. |
6453 DECL_ACCESSORS(eval_from_shared, Object) | 6451 DECL_ACCESSORS(eval_from_shared, Object) |
6454 | 6452 |
6455 // [eval_from_instructions_offset]: the instruction offset in the code for the | 6453 // [eval_from_instructions_offset]: the instruction offset in the code for the |
6456 // function from which eval was called where eval was called. | 6454 // function from which eval was called where eval was called. |
6457 DECL_ACCESSORS(eval_from_instructions_offset, Smi) | 6455 DECL_ACCESSORS(eval_from_instructions_offset, Smi) |
6458 | 6456 |
| 6457 // [shared_function_infos]: weak fixed array containing all shared |
| 6458 // function infos created from this script. |
| 6459 DECL_ACCESSORS(shared_function_infos, Object) |
| 6460 |
6459 // [flags]: Holds an exciting bitfield. | 6461 // [flags]: Holds an exciting bitfield. |
6460 DECL_ACCESSORS(flags, Smi) | 6462 DECL_ACCESSORS(flags, Smi) |
6461 | 6463 |
6462 // [source_url]: sourceURL from magic comment | 6464 // [source_url]: sourceURL from magic comment |
6463 DECL_ACCESSORS(source_url, Object) | 6465 DECL_ACCESSORS(source_url, Object) |
6464 | 6466 |
6465 // [source_url]: sourceMappingURL magic comment | 6467 // [source_url]: sourceMappingURL magic comment |
6466 DECL_ACCESSORS(source_mapping_url, Object) | 6468 DECL_ACCESSORS(source_mapping_url, Object) |
6467 | 6469 |
6468 // [compilation_type]: how the the script was compiled. Encoded in the | 6470 // [compilation_type]: how the the script was compiled. Encoded in the |
(...skipping 27 matching lines...) Expand all Loading... |
6496 int GetLineNumber(int code_pos); | 6498 int GetLineNumber(int code_pos); |
6497 | 6499 |
6498 static Handle<Object> GetNameOrSourceURL(Handle<Script> script); | 6500 static Handle<Object> GetNameOrSourceURL(Handle<Script> script); |
6499 | 6501 |
6500 // Init line_ends array with code positions of line ends inside script source. | 6502 // Init line_ends array with code positions of line ends inside script source. |
6501 static void InitLineEnds(Handle<Script> script); | 6503 static void InitLineEnds(Handle<Script> script); |
6502 | 6504 |
6503 // Get the JS object wrapping the given script; create it if none exists. | 6505 // Get the JS object wrapping the given script; create it if none exists. |
6504 static Handle<JSObject> GetWrapper(Handle<Script> script); | 6506 static Handle<JSObject> GetWrapper(Handle<Script> script); |
6505 | 6507 |
| 6508 // Look through the list of existing shared function infos to find one |
| 6509 // that matches the function literal. Return empty handle if not found. |
| 6510 MaybeHandle<SharedFunctionInfo> FindSharedFunctionInfo(FunctionLiteral* fun); |
| 6511 |
6506 // Dispatched behavior. | 6512 // Dispatched behavior. |
6507 DECLARE_PRINTER(Script) | 6513 DECLARE_PRINTER(Script) |
6508 DECLARE_VERIFIER(Script) | 6514 DECLARE_VERIFIER(Script) |
6509 | 6515 |
6510 static const int kSourceOffset = HeapObject::kHeaderSize; | 6516 static const int kSourceOffset = HeapObject::kHeaderSize; |
6511 static const int kNameOffset = kSourceOffset + kPointerSize; | 6517 static const int kNameOffset = kSourceOffset + kPointerSize; |
6512 static const int kLineOffsetOffset = kNameOffset + kPointerSize; | 6518 static const int kLineOffsetOffset = kNameOffset + kPointerSize; |
6513 static const int kColumnOffsetOffset = kLineOffsetOffset + kPointerSize; | 6519 static const int kColumnOffsetOffset = kLineOffsetOffset + kPointerSize; |
6514 static const int kContextOffset = kColumnOffsetOffset + kPointerSize; | 6520 static const int kContextOffset = kColumnOffsetOffset + kPointerSize; |
6515 static const int kWrapperOffset = kContextOffset + kPointerSize; | 6521 static const int kWrapperOffset = kContextOffset + kPointerSize; |
6516 static const int kTypeOffset = kWrapperOffset + kPointerSize; | 6522 static const int kTypeOffset = kWrapperOffset + kPointerSize; |
6517 static const int kLineEndsOffset = kTypeOffset + kPointerSize; | 6523 static const int kLineEndsOffset = kTypeOffset + kPointerSize; |
6518 static const int kIdOffset = kLineEndsOffset + kPointerSize; | 6524 static const int kIdOffset = kLineEndsOffset + kPointerSize; |
6519 static const int kEvalFromSharedOffset = kIdOffset + kPointerSize; | 6525 static const int kEvalFromSharedOffset = kIdOffset + kPointerSize; |
6520 static const int kEvalFrominstructionsOffsetOffset = | 6526 static const int kEvalFrominstructionsOffsetOffset = |
6521 kEvalFromSharedOffset + kPointerSize; | 6527 kEvalFromSharedOffset + kPointerSize; |
6522 static const int kFlagsOffset = | 6528 static const int kSharedFunctionInfosOffset = |
6523 kEvalFrominstructionsOffsetOffset + kPointerSize; | 6529 kEvalFrominstructionsOffsetOffset + kPointerSize; |
| 6530 static const int kFlagsOffset = kSharedFunctionInfosOffset + kPointerSize; |
6524 static const int kSourceUrlOffset = kFlagsOffset + kPointerSize; | 6531 static const int kSourceUrlOffset = kFlagsOffset + kPointerSize; |
6525 static const int kSourceMappingUrlOffset = kSourceUrlOffset + kPointerSize; | 6532 static const int kSourceMappingUrlOffset = kSourceUrlOffset + kPointerSize; |
6526 static const int kSize = kSourceMappingUrlOffset + kPointerSize; | 6533 static const int kSize = kSourceMappingUrlOffset + kPointerSize; |
6527 | 6534 |
6528 private: | 6535 private: |
6529 int GetLineNumberWithArray(int code_pos); | 6536 int GetLineNumberWithArray(int code_pos); |
6530 | 6537 |
6531 // Bit positions in the flags field. | 6538 // Bit positions in the flags field. |
6532 static const int kCompilationTypeBit = 0; | 6539 static const int kCompilationTypeBit = 0; |
6533 static const int kCompilationStateBit = 1; | 6540 static const int kCompilationStateBit = 1; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6644 static void InitFromFunctionLiteral(Handle<SharedFunctionInfo> shared_info, | 6651 static void InitFromFunctionLiteral(Handle<SharedFunctionInfo> shared_info, |
6645 FunctionLiteral* lit); | 6652 FunctionLiteral* lit); |
6646 | 6653 |
6647 // Add a new entry to the optimized code map. | 6654 // Add a new entry to the optimized code map. |
6648 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, | 6655 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, |
6649 Handle<Context> native_context, | 6656 Handle<Context> native_context, |
6650 Handle<Code> code, | 6657 Handle<Code> code, |
6651 Handle<FixedArray> literals, | 6658 Handle<FixedArray> literals, |
6652 BailoutId osr_ast_id); | 6659 BailoutId osr_ast_id); |
6653 | 6660 |
| 6661 // Set up the link between shared function info and the script. The shared |
| 6662 // function info is added to the list on the script. |
| 6663 static void SetScript(Handle<SharedFunctionInfo> shared, |
| 6664 Handle<Object> script_object); |
| 6665 |
6654 // Layout description of the optimized code map. | 6666 // Layout description of the optimized code map. |
6655 static const int kNextMapIndex = 0; | 6667 static const int kNextMapIndex = 0; |
6656 static const int kEntriesStart = 1; | 6668 static const int kEntriesStart = 1; |
6657 static const int kContextOffset = 0; | 6669 static const int kContextOffset = 0; |
6658 static const int kCachedCodeOffset = 1; | 6670 static const int kCachedCodeOffset = 1; |
6659 static const int kLiteralsOffset = 2; | 6671 static const int kLiteralsOffset = 2; |
6660 static const int kOsrAstIdOffset = 3; | 6672 static const int kOsrAstIdOffset = 3; |
6661 static const int kEntryLength = 4; | 6673 static const int kEntryLength = 4; |
6662 static const int kInitialLength = kEntriesStart + kEntryLength; | 6674 static const int kInitialLength = kEntriesStart + kEntryLength; |
6663 | 6675 |
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7527 // Layout description. | 7539 // Layout description. |
7528 static const int kNativeContextOffset = JSObject::kHeaderSize; | 7540 static const int kNativeContextOffset = JSObject::kHeaderSize; |
7529 static const int kHashOffset = kNativeContextOffset + kPointerSize; | 7541 static const int kHashOffset = kNativeContextOffset + kPointerSize; |
7530 static const int kSize = kHashOffset + kPointerSize; | 7542 static const int kSize = kHashOffset + kPointerSize; |
7531 | 7543 |
7532 private: | 7544 private: |
7533 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalProxy); | 7545 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalProxy); |
7534 }; | 7546 }; |
7535 | 7547 |
7536 | 7548 |
7537 // Forward declaration. | |
7538 class JSBuiltinsObject; | |
7539 | |
7540 // Common super class for JavaScript global objects and the special | 7549 // Common super class for JavaScript global objects and the special |
7541 // builtins global objects. | 7550 // builtins global objects. |
7542 class GlobalObject: public JSObject { | 7551 class GlobalObject: public JSObject { |
7543 public: | 7552 public: |
7544 // [builtins]: the object holding the runtime routines written in JS. | 7553 // [builtins]: the object holding the runtime routines written in JS. |
7545 DECL_ACCESSORS(builtins, JSBuiltinsObject) | 7554 DECL_ACCESSORS(builtins, JSBuiltinsObject) |
7546 | 7555 |
7547 // [native context]: the natives corresponding to this global object. | 7556 // [native context]: the natives corresponding to this global object. |
7548 DECL_ACCESSORS(native_context, Context) | 7557 DECL_ACCESSORS(native_context, Context) |
7549 | 7558 |
(...skipping 3311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10861 } else { | 10870 } else { |
10862 value &= ~(1 << bit_position); | 10871 value &= ~(1 << bit_position); |
10863 } | 10872 } |
10864 return value; | 10873 return value; |
10865 } | 10874 } |
10866 }; | 10875 }; |
10867 | 10876 |
10868 } } // namespace v8::internal | 10877 } } // namespace v8::internal |
10869 | 10878 |
10870 #endif // V8_OBJECTS_H_ | 10879 #endif // V8_OBJECTS_H_ |
OLD | NEW |