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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 // - JSValue | 69 // - JSValue |
70 // - JSDate | 70 // - JSDate |
71 // - JSMessageObject | 71 // - JSMessageObject |
72 // - JSProxy | 72 // - JSProxy |
73 // - JSFunctionProxy | 73 // - JSFunctionProxy |
74 // - FixedArrayBase | 74 // - FixedArrayBase |
75 // - ByteArray | 75 // - ByteArray |
76 // - BytecodeArray | 76 // - BytecodeArray |
77 // - FixedArray | 77 // - FixedArray |
78 // - DescriptorArray | 78 // - DescriptorArray |
| 79 // - LiteralsArray |
79 // - HashTable | 80 // - HashTable |
80 // - Dictionary | 81 // - Dictionary |
81 // - StringTable | 82 // - StringTable |
82 // - CompilationCacheTable | 83 // - CompilationCacheTable |
83 // - CodeCacheHashTable | 84 // - CodeCacheHashTable |
84 // - MapCache | 85 // - MapCache |
85 // - OrderedHashTable | 86 // - OrderedHashTable |
86 // - OrderedHashSet | 87 // - OrderedHashSet |
87 // - OrderedHashMap | 88 // - OrderedHashMap |
88 // - Context | 89 // - Context |
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 class AllocationSiteCreationContext; | 846 class AllocationSiteCreationContext; |
846 class AllocationSiteUsageContext; | 847 class AllocationSiteUsageContext; |
847 class Cell; | 848 class Cell; |
848 class ConsString; | 849 class ConsString; |
849 class ElementsAccessor; | 850 class ElementsAccessor; |
850 class FixedArrayBase; | 851 class FixedArrayBase; |
851 class FunctionLiteral; | 852 class FunctionLiteral; |
852 class GlobalObject; | 853 class GlobalObject; |
853 class JSBuiltinsObject; | 854 class JSBuiltinsObject; |
854 class LayoutDescriptor; | 855 class LayoutDescriptor; |
| 856 class LiteralsArray; |
855 class LookupIterator; | 857 class LookupIterator; |
856 class ObjectHashTable; | 858 class ObjectHashTable; |
857 class ObjectVisitor; | 859 class ObjectVisitor; |
858 class PropertyCell; | 860 class PropertyCell; |
859 class SafepointEntry; | 861 class SafepointEntry; |
860 class SharedFunctionInfo; | 862 class SharedFunctionInfo; |
861 class StringStream; | 863 class StringStream; |
862 class TypeFeedbackInfo; | 864 class TypeFeedbackInfo; |
863 class TypeFeedbackVector; | 865 class TypeFeedbackVector; |
864 class WeakCell; | 866 class WeakCell; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 V(FreeSpace) \ | 935 V(FreeSpace) \ |
934 V(JSReceiver) \ | 936 V(JSReceiver) \ |
935 V(JSObject) \ | 937 V(JSObject) \ |
936 V(JSContextExtensionObject) \ | 938 V(JSContextExtensionObject) \ |
937 V(JSGeneratorObject) \ | 939 V(JSGeneratorObject) \ |
938 V(JSModule) \ | 940 V(JSModule) \ |
939 V(LayoutDescriptor) \ | 941 V(LayoutDescriptor) \ |
940 V(Map) \ | 942 V(Map) \ |
941 V(DescriptorArray) \ | 943 V(DescriptorArray) \ |
942 V(TransitionArray) \ | 944 V(TransitionArray) \ |
| 945 V(LiteralsArray) \ |
943 V(TypeFeedbackVector) \ | 946 V(TypeFeedbackVector) \ |
944 V(DeoptimizationInputData) \ | 947 V(DeoptimizationInputData) \ |
945 V(DeoptimizationOutputData) \ | 948 V(DeoptimizationOutputData) \ |
946 V(DependentCode) \ | 949 V(DependentCode) \ |
947 V(HandlerTable) \ | 950 V(HandlerTable) \ |
948 V(FixedArray) \ | 951 V(FixedArray) \ |
949 V(FixedDoubleArray) \ | 952 V(FixedDoubleArray) \ |
950 V(WeakFixedArray) \ | 953 V(WeakFixedArray) \ |
951 V(ArrayList) \ | 954 V(ArrayList) \ |
952 V(Context) \ | 955 V(Context) \ |
(...skipping 3608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4561 PretenureFlag pretenure); | 4564 PretenureFlag pretenure); |
4562 | 4565 |
4563 DECLARE_CAST(DeoptimizationOutputData) | 4566 DECLARE_CAST(DeoptimizationOutputData) |
4564 | 4567 |
4565 #if defined(OBJECT_PRINT) || defined(ENABLE_DISASSEMBLER) | 4568 #if defined(OBJECT_PRINT) || defined(ENABLE_DISASSEMBLER) |
4566 void DeoptimizationOutputDataPrint(std::ostream& os); // NOLINT | 4569 void DeoptimizationOutputDataPrint(std::ostream& os); // NOLINT |
4567 #endif | 4570 #endif |
4568 }; | 4571 }; |
4569 | 4572 |
4570 | 4573 |
| 4574 // A literals array contains the literals for a JSFunction. It also holds |
| 4575 // the type feedback vector. |
| 4576 class LiteralsArray : public FixedArray { |
| 4577 public: |
| 4578 static const int kVectorIndex = 0; |
| 4579 static const int kFirstLiteralIndex = 1; |
| 4580 static const int kOffsetToFirstLiteral = |
| 4581 FixedArray::kHeaderSize + kPointerSize; |
| 4582 |
| 4583 static int OffsetOfLiteralAt(int index) { |
| 4584 return SizeFor(index + kFirstLiteralIndex); |
| 4585 } |
| 4586 |
| 4587 inline TypeFeedbackVector* feedback_vector() const; |
| 4588 inline void set_feedback_vector(TypeFeedbackVector* vector); |
| 4589 inline Object* literal(int literal_index) const; |
| 4590 inline void set_literal(int literal_index, Object* literal); |
| 4591 inline int literals_count() const; |
| 4592 |
| 4593 static Handle<LiteralsArray> New(Isolate* isolate, |
| 4594 Handle<TypeFeedbackVector> vector, |
| 4595 int number_of_literals, |
| 4596 PretenureFlag pretenure); |
| 4597 |
| 4598 DECLARE_CAST(LiteralsArray) |
| 4599 |
| 4600 private: |
| 4601 inline Object* get(int index) const; |
| 4602 inline void set(int index, Object* value); |
| 4603 inline void set(int index, Smi* value); |
| 4604 inline void set(int index, Object* value, WriteBarrierMode mode); |
| 4605 }; |
| 4606 |
| 4607 |
4571 // HandlerTable is a fixed array containing entries for exception handlers in | 4608 // HandlerTable is a fixed array containing entries for exception handlers in |
4572 // the code object it is associated with. The tables comes in two flavors: | 4609 // the code object it is associated with. The tables comes in two flavors: |
4573 // 1) Based on ranges: Used for unoptimized code. Contains one entry per | 4610 // 1) Based on ranges: Used for unoptimized code. Contains one entry per |
4574 // exception handler and a range representing the try-block covered by that | 4611 // exception handler and a range representing the try-block covered by that |
4575 // handler. Layout looks as follows: | 4612 // handler. Layout looks as follows: |
4576 // [ range-start , range-end , handler-offset , stack-depth ] | 4613 // [ range-start , range-end , handler-offset , stack-depth ] |
4577 // 2) Based on return addresses: Used for turbofanned code. Contains one entry | 4614 // 2) Based on return addresses: Used for turbofanned code. Contains one entry |
4578 // per call-site that could throw an exception. Layout looks as follows: | 4615 // per call-site that could throw an exception. Layout looks as follows: |
4579 // [ return-address-offset , handler-offset ] | 4616 // [ return-address-offset , handler-offset ] |
4580 class HandlerTable : public FixedArray { | 4617 class HandlerTable : public FixedArray { |
(...skipping 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6285 // Fake id for a special case of Math.pow. Note, it continues the | 6322 // Fake id for a special case of Math.pow. Note, it continues the |
6286 // list of math functions. | 6323 // list of math functions. |
6287 kMathPowHalf | 6324 kMathPowHalf |
6288 }; | 6325 }; |
6289 | 6326 |
6290 | 6327 |
6291 // Result of searching in an optimized code map of a SharedFunctionInfo. Note | 6328 // Result of searching in an optimized code map of a SharedFunctionInfo. Note |
6292 // that both {code} and {literals} can be NULL to pass search result status. | 6329 // that both {code} and {literals} can be NULL to pass search result status. |
6293 struct CodeAndLiterals { | 6330 struct CodeAndLiterals { |
6294 Code* code; // Cached optimized code. | 6331 Code* code; // Cached optimized code. |
6295 FixedArray* literals; // Cached literals array. | 6332 LiteralsArray* literals; // Cached literals array. |
6296 }; | 6333 }; |
6297 | 6334 |
6298 | 6335 |
6299 // SharedFunctionInfo describes the JSFunction information that can be | 6336 // SharedFunctionInfo describes the JSFunction information that can be |
6300 // shared by multiple instances of the function. | 6337 // shared by multiple instances of the function. |
6301 class SharedFunctionInfo: public HeapObject { | 6338 class SharedFunctionInfo: public HeapObject { |
6302 public: | 6339 public: |
6303 // [name]: Function name. | 6340 // [name]: Function name. |
6304 DECL_ACCESSORS(name, Object) | 6341 DECL_ACCESSORS(name, Object) |
6305 | 6342 |
(...skipping 26 matching lines...) Expand all Loading... |
6332 // Add a new entry to the optimized code map for context-independent code. | 6369 // Add a new entry to the optimized code map for context-independent code. |
6333 static void AddSharedCodeToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, | 6370 static void AddSharedCodeToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, |
6334 Handle<Code> code); | 6371 Handle<Code> code); |
6335 | 6372 |
6336 // Add a new entry to the optimized code map for context-dependent code. | 6373 // Add a new entry to the optimized code map for context-dependent code. |
6337 // |code| is either a code object or an undefined value. In the latter case | 6374 // |code| is either a code object or an undefined value. In the latter case |
6338 // the entry just maps |native_context, osr_ast_id| pair to |literals| array. | 6375 // the entry just maps |native_context, osr_ast_id| pair to |literals| array. |
6339 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, | 6376 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, |
6340 Handle<Context> native_context, | 6377 Handle<Context> native_context, |
6341 Handle<HeapObject> code, | 6378 Handle<HeapObject> code, |
6342 Handle<FixedArray> literals, | 6379 Handle<LiteralsArray> literals, |
6343 BailoutId osr_ast_id); | 6380 BailoutId osr_ast_id); |
6344 | 6381 |
6345 // Set up the link between shared function info and the script. The shared | 6382 // Set up the link between shared function info and the script. The shared |
6346 // function info is added to the list on the script. | 6383 // function info is added to the list on the script. |
6347 static void SetScript(Handle<SharedFunctionInfo> shared, | 6384 static void SetScript(Handle<SharedFunctionInfo> shared, |
6348 Handle<Object> script_object); | 6385 Handle<Object> script_object); |
6349 | 6386 |
6350 // Layout description of the optimized code map. | 6387 // Layout description of the optimized code map. |
6351 static const int kNextMapIndex = 0; | 6388 static const int kNextMapIndex = 0; |
6352 static const int kSharedCodeIndex = 1; | 6389 static const int kSharedCodeIndex = 1; |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7128 // necessary so that we do not dynamically lookup the object, regexp | 7165 // necessary so that we do not dynamically lookup the object, regexp |
7129 // or array functions. Performing a dynamic lookup, we might end up | 7166 // or array functions. Performing a dynamic lookup, we might end up |
7130 // using the functions from a new context that we should not have | 7167 // using the functions from a new context that we should not have |
7131 // access to. | 7168 // access to. |
7132 // | 7169 // |
7133 // On bound functions, the array is a (copy-on-write) fixed-array containing | 7170 // On bound functions, the array is a (copy-on-write) fixed-array containing |
7134 // the function that was bound, bound this-value and any bound | 7171 // the function that was bound, bound this-value and any bound |
7135 // arguments. Bound functions never contain literals. | 7172 // arguments. Bound functions never contain literals. |
7136 DECL_ACCESSORS(literals_or_bindings, FixedArray) | 7173 DECL_ACCESSORS(literals_or_bindings, FixedArray) |
7137 | 7174 |
7138 inline FixedArray* literals(); | 7175 inline LiteralsArray* literals(); |
7139 inline void set_literals(FixedArray* literals); | 7176 inline void set_literals(LiteralsArray* literals); |
7140 | 7177 |
7141 inline FixedArray* function_bindings(); | 7178 inline FixedArray* function_bindings(); |
7142 inline void set_function_bindings(FixedArray* bindings); | 7179 inline void set_function_bindings(FixedArray* bindings); |
7143 | 7180 |
7144 // The initial map for an object created by this constructor. | 7181 // The initial map for an object created by this constructor. |
7145 inline Map* initial_map(); | 7182 inline Map* initial_map(); |
7146 static void SetInitialMap(Handle<JSFunction> function, Handle<Map> map, | 7183 static void SetInitialMap(Handle<JSFunction> function, Handle<Map> map, |
7147 Handle<Object> prototype); | 7184 Handle<Object> prototype); |
7148 inline bool has_initial_map(); | 7185 inline bool has_initial_map(); |
7149 static void EnsureHasInitialMap(Handle<JSFunction> function); | 7186 static void EnsureHasInitialMap(Handle<JSFunction> function); |
(...skipping 3433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10583 | 10620 |
10584 Isolate* isolate_; | 10621 Isolate* isolate_; |
10585 Handle<FixedArray> keys_; | 10622 Handle<FixedArray> keys_; |
10586 Handle<OrderedHashSet> set_; | 10623 Handle<OrderedHashSet> set_; |
10587 int length_; | 10624 int length_; |
10588 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator); | 10625 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator); |
10589 }; | 10626 }; |
10590 } } // namespace v8::internal | 10627 } } // namespace v8::internal |
10591 | 10628 |
10592 #endif // V8_OBJECTS_H_ | 10629 #endif // V8_OBJECTS_H_ |
OLD | NEW |