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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 // - MapCache | 81 // - MapCache |
82 // - OrderedHashTable | 82 // - OrderedHashTable |
83 // - OrderedHashSet | 83 // - OrderedHashSet |
84 // - OrderedHashMap | 84 // - OrderedHashMap |
85 // - Context | 85 // - Context |
86 // - TypeFeedbackVector | 86 // - TypeFeedbackVector |
87 // - JSFunctionResultCache | 87 // - JSFunctionResultCache |
88 // - ScopeInfo | 88 // - ScopeInfo |
89 // - TransitionArray | 89 // - TransitionArray |
90 // - ScriptContextTable | 90 // - ScriptContextTable |
91 // - WeakFixedArray | |
91 // - FixedDoubleArray | 92 // - FixedDoubleArray |
92 // - ExternalArray | 93 // - ExternalArray |
93 // - ExternalUint8ClampedArray | 94 // - ExternalUint8ClampedArray |
94 // - ExternalInt8Array | 95 // - ExternalInt8Array |
95 // - ExternalUint8Array | 96 // - ExternalUint8Array |
96 // - ExternalInt16Array | 97 // - ExternalInt16Array |
97 // - ExternalUint16Array | 98 // - ExternalUint16Array |
98 // - ExternalInt32Array | 99 // - ExternalInt32Array |
99 // - ExternalUint32Array | 100 // - ExternalUint32Array |
100 // - ExternalFloat32Array | 101 // - ExternalFloat32Array |
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
935 V(LayoutDescriptor) \ | 936 V(LayoutDescriptor) \ |
936 V(Map) \ | 937 V(Map) \ |
937 V(DescriptorArray) \ | 938 V(DescriptorArray) \ |
938 V(TransitionArray) \ | 939 V(TransitionArray) \ |
939 V(TypeFeedbackVector) \ | 940 V(TypeFeedbackVector) \ |
940 V(DeoptimizationInputData) \ | 941 V(DeoptimizationInputData) \ |
941 V(DeoptimizationOutputData) \ | 942 V(DeoptimizationOutputData) \ |
942 V(DependentCode) \ | 943 V(DependentCode) \ |
943 V(FixedArray) \ | 944 V(FixedArray) \ |
944 V(FixedDoubleArray) \ | 945 V(FixedDoubleArray) \ |
946 V(WeakFixedArray) \ | |
945 V(ConstantPoolArray) \ | 947 V(ConstantPoolArray) \ |
946 V(Context) \ | 948 V(Context) \ |
947 V(ScriptContextTable) \ | 949 V(ScriptContextTable) \ |
948 V(NativeContext) \ | 950 V(NativeContext) \ |
949 V(ScopeInfo) \ | 951 V(ScopeInfo) \ |
950 V(JSFunction) \ | 952 V(JSFunction) \ |
951 V(Code) \ | 953 V(Code) \ |
952 V(Oddball) \ | 954 V(Oddball) \ |
953 V(SharedFunctionInfo) \ | 955 V(SharedFunctionInfo) \ |
954 V(JSValue) \ | 956 V(JSValue) \ |
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1808 // Sets the property value in a normalized object given (key, value, details). | 1810 // Sets the property value in a normalized object given (key, value, details). |
1809 // Handles the special representation of JS global objects. | 1811 // Handles the special representation of JS global objects. |
1810 static void SetNormalizedProperty(Handle<JSObject> object, | 1812 static void SetNormalizedProperty(Handle<JSObject> object, |
1811 Handle<Name> key, | 1813 Handle<Name> key, |
1812 Handle<Object> value, | 1814 Handle<Object> value, |
1813 PropertyDetails details); | 1815 PropertyDetails details); |
1814 | 1816 |
1815 static void OptimizeAsPrototype(Handle<JSObject> object, | 1817 static void OptimizeAsPrototype(Handle<JSObject> object, |
1816 PrototypeOptimizationMode mode); | 1818 PrototypeOptimizationMode mode); |
1817 static void ReoptimizeIfPrototype(Handle<JSObject> object); | 1819 static void ReoptimizeIfPrototype(Handle<JSObject> object); |
1820 static void RegisterPrototypeUser(Handle<JSObject> prototype, | |
1821 Handle<HeapObject> user); | |
1822 static void UnregisterPrototypeUser(Handle<JSObject> prototype, | |
1823 Handle<HeapObject> user); | |
1818 | 1824 |
1819 // Retrieve interceptors. | 1825 // Retrieve interceptors. |
1820 InterceptorInfo* GetNamedInterceptor(); | 1826 InterceptorInfo* GetNamedInterceptor(); |
1821 InterceptorInfo* GetIndexedInterceptor(); | 1827 InterceptorInfo* GetIndexedInterceptor(); |
1822 | 1828 |
1823 // Used from JSReceiver. | 1829 // Used from JSReceiver. |
1824 MUST_USE_RESULT static Maybe<PropertyAttributes> | 1830 MUST_USE_RESULT static Maybe<PropertyAttributes> |
1825 GetPropertyAttributesWithInterceptor(Handle<JSObject> holder, | 1831 GetPropertyAttributesWithInterceptor(Handle<JSObject> holder, |
1826 Handle<Object> receiver, | 1832 Handle<Object> receiver, |
1827 Handle<Name> name); | 1833 Handle<Name> name); |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2581 | 2587 |
2582 // Dispatched behavior. | 2588 // Dispatched behavior. |
2583 DECLARE_PRINTER(FixedDoubleArray) | 2589 DECLARE_PRINTER(FixedDoubleArray) |
2584 DECLARE_VERIFIER(FixedDoubleArray) | 2590 DECLARE_VERIFIER(FixedDoubleArray) |
2585 | 2591 |
2586 private: | 2592 private: |
2587 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedDoubleArray); | 2593 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedDoubleArray); |
2588 }; | 2594 }; |
2589 | 2595 |
2590 | 2596 |
2597 class WeakFixedArray : public FixedArray { | |
2598 public: | |
2599 // If |maybe_array| is not a WeakFixedArray, a fresh one will be allocated. | |
2600 static Handle<WeakFixedArray> Add(Handle<Object> maybe_array, | |
2601 Handle<HeapObject> value, | |
2602 bool may_be_duplicate = false); | |
ulan
2014/12/15 15:40:36
Please use enum with descriptive name instead of b
Jakob Kummerow
2014/12/15 16:18:49
Done.
| |
2603 | |
2604 void Remove(Handle<HeapObject> value); | |
2605 | |
2606 inline Object* get(int index) const; | |
2607 inline int length() const; | |
ulan
2014/12/15 15:40:36
Nit: I personally don't like non-virtual overrides
Jakob Kummerow
2014/12/15 16:18:49
Done. (I don't see the need, but I'm happy to make
| |
2608 | |
2609 DECLARE_CAST(WeakFixedArray) | |
2610 | |
2611 private: | |
2612 static const int kLastUsedIndexIndex = 0; | |
2613 static const int kFirstIndex = 1; | |
2614 | |
2615 static Handle<WeakFixedArray> Allocate( | |
2616 Isolate* isolate, int size, Handle<WeakFixedArray> initialize_from); | |
2617 | |
2618 static void Set(Handle<WeakFixedArray> array, int index, | |
2619 Handle<HeapObject> value); | |
2620 inline void clear(int index); | |
2621 inline bool IsEmptySlot(int index) const; | |
2622 | |
2623 inline int last_used_index() const; | |
2624 inline void set_last_used_index(int index); | |
2625 | |
2626 // Disallow inherited setters. | |
2627 void set(int index, Smi* value); | |
2628 void set(int index, Object* value); | |
2629 void set(int index, Object* value, WriteBarrierMode mode); | |
2630 DISALLOW_IMPLICIT_CONSTRUCTORS(WeakFixedArray); | |
2631 }; | |
2632 | |
2633 | |
2591 // ConstantPoolArray describes a fixed-sized array containing constant pool | 2634 // ConstantPoolArray describes a fixed-sized array containing constant pool |
2592 // entries. | 2635 // entries. |
2593 // | 2636 // |
2594 // A ConstantPoolArray can be structured in two different ways depending upon | 2637 // A ConstantPoolArray can be structured in two different ways depending upon |
2595 // whether it is extended or small. The is_extended_layout() method can be used | 2638 // whether it is extended or small. The is_extended_layout() method can be used |
2596 // to discover which layout the constant pool has. | 2639 // to discover which layout the constant pool has. |
2597 // | 2640 // |
2598 // The format of a small constant pool is: | 2641 // The format of a small constant pool is: |
2599 // [kSmallLayout1Offset] : Small section layout bitmap 1 | 2642 // [kSmallLayout1Offset] : Small section layout bitmap 1 |
2600 // [kSmallLayout2Offset] : Small section layout bitmap 2 | 2643 // [kSmallLayout2Offset] : Small section layout bitmap 2 |
(...skipping 3275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5876 // Tells whether the instance needs security checks when accessing its | 5919 // Tells whether the instance needs security checks when accessing its |
5877 // properties. | 5920 // properties. |
5878 inline void set_is_access_check_needed(bool access_check_needed); | 5921 inline void set_is_access_check_needed(bool access_check_needed); |
5879 inline bool is_access_check_needed(); | 5922 inline bool is_access_check_needed(); |
5880 | 5923 |
5881 // Returns true if map has a non-empty stub code cache. | 5924 // Returns true if map has a non-empty stub code cache. |
5882 inline bool has_code_cache(); | 5925 inline bool has_code_cache(); |
5883 | 5926 |
5884 // [prototype]: implicit prototype object. | 5927 // [prototype]: implicit prototype object. |
5885 DECL_ACCESSORS(prototype, Object) | 5928 DECL_ACCESSORS(prototype, Object) |
5929 // TODO(jkummerow): make set_prototype private. | |
5930 void SetPrototype(Handle<Object> prototype, | |
5931 PrototypeOptimizationMode proto_mode = FAST_PROTOTYPE); | |
5932 bool ShouldRegisterAsPrototypeUser(Handle<JSObject> prototype); | |
5933 bool CanUseOptimizationsBasedOnPrototypeRegistry(); | |
5886 | 5934 |
5887 // [constructor]: points back to the function responsible for this map. | 5935 // [constructor]: points back to the function responsible for this map. |
5888 DECL_ACCESSORS(constructor, Object) | 5936 DECL_ACCESSORS(constructor, Object) |
5889 | 5937 |
5890 // [instance descriptors]: describes the object. | 5938 // [instance descriptors]: describes the object. |
5891 DECL_ACCESSORS(instance_descriptors, DescriptorArray) | 5939 DECL_ACCESSORS(instance_descriptors, DescriptorArray) |
5892 | 5940 |
5893 // [layout descriptor]: describes the object layout. | 5941 // [layout descriptor]: describes the object layout. |
5894 DECL_ACCESSORS(layout_descriptor, LayoutDescriptor) | 5942 DECL_ACCESSORS(layout_descriptor, LayoutDescriptor) |
5895 // |layout descriptor| accessor which can be used from GC. | 5943 // |layout descriptor| accessor which can be used from GC. |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6205 typedef void (*TraverseCallback)(Map* map, void* data); | 6253 typedef void (*TraverseCallback)(Map* map, void* data); |
6206 | 6254 |
6207 void TraverseTransitionTree(TraverseCallback callback, void* data); | 6255 void TraverseTransitionTree(TraverseCallback callback, void* data); |
6208 | 6256 |
6209 // When you set the prototype of an object using the __proto__ accessor you | 6257 // When you set the prototype of an object using the __proto__ accessor you |
6210 // need a new map for the object (the prototype is stored in the map). In | 6258 // need a new map for the object (the prototype is stored in the map). In |
6211 // order not to multiply maps unnecessarily we store these as transitions in | 6259 // order not to multiply maps unnecessarily we store these as transitions in |
6212 // the original map. That way we can transition to the same map if the same | 6260 // the original map. That way we can transition to the same map if the same |
6213 // prototype is set, rather than creating a new map every time. The | 6261 // prototype is set, rather than creating a new map every time. The |
6214 // transitions are in the form of a map where the keys are prototype objects | 6262 // transitions are in the form of a map where the keys are prototype objects |
6215 // and the values are the maps the are transitioned to. | 6263 // and the values are the maps they transition to. |
6216 static const int kMaxCachedPrototypeTransitions = 256; | 6264 static const int kMaxCachedPrototypeTransitions = 256; |
6217 static Handle<Map> TransitionToPrototype(Handle<Map> map, | 6265 static Handle<Map> TransitionToPrototype(Handle<Map> map, |
6218 Handle<Object> prototype); | 6266 Handle<Object> prototype, |
6267 PrototypeOptimizationMode mode); | |
6219 | 6268 |
6220 static const int kMaxPreAllocatedPropertyFields = 255; | 6269 static const int kMaxPreAllocatedPropertyFields = 255; |
6221 | 6270 |
6222 // Layout description. | 6271 // Layout description. |
6223 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; | 6272 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; |
6224 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; | 6273 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; |
6225 static const int kBitField3Offset = kInstanceAttributesOffset + kIntSize; | 6274 static const int kBitField3Offset = kInstanceAttributesOffset + kIntSize; |
6226 static const int kPrototypeOffset = kBitField3Offset + kPointerSize; | 6275 static const int kPrototypeOffset = kBitField3Offset + kPointerSize; |
6227 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; | 6276 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; |
6228 // Storage for the transition array is overloaded to directly contain a back | 6277 // Storage for the transition array is overloaded to directly contain a back |
(...skipping 4764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10993 } else { | 11042 } else { |
10994 value &= ~(1 << bit_position); | 11043 value &= ~(1 << bit_position); |
10995 } | 11044 } |
10996 return value; | 11045 return value; |
10997 } | 11046 } |
10998 }; | 11047 }; |
10999 | 11048 |
11000 } } // namespace v8::internal | 11049 } } // namespace v8::internal |
11001 | 11050 |
11002 #endif // V8_OBJECTS_H_ | 11051 #endif // V8_OBJECTS_H_ |
OLD | NEW |