Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: src/objects.h

Issue 768633002: Add infrastructure to keep track of references to prototypes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/lookup.cc ('k') | src/objects.cc » ('j') | src/objects.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
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 inline Object* get(int index) const;
2600
2601 static bool StoreAnywhere(Handle<WeakFixedArray> array,
Toon Verwaest 2014/12/01 15:23:54 What about combining StoreAnywhere with GrowAndSto
Jakob Kummerow 2014/12/02 12:32:15 Done.
2602 Handle<HeapObject> value,
2603 bool may_be_duplicate = false);
2604
2605 static Handle<WeakFixedArray> GrowAndStore(Handle<WeakFixedArray> original,
2606 Handle<HeapObject> value);
2607 void Delete(Handle<HeapObject> value);
Toon Verwaest 2014/12/01 15:23:54 And then rename to Remove to match Add.
Jakob Kummerow 2014/12/02 12:32:15 Done.
2608
2609 DECLARE_CAST(WeakFixedArray)
2610
2611 private:
2612 static const int kLastUsedIndexIndex = 0;
2613 static const int kReservedFieldCount = 1;
2614
2615 static void Set(Handle<WeakFixedArray> array, int index,
2616 Handle<HeapObject> value);
2617 inline void clear(int index);
2618 inline int length() const;
2619 inline bool IsEmptySlot(int index) const;
2620
2621 inline int last_used_index() const;
2622 inline void set_last_used_index(int index);
2623
2624 static void CopyFrom(Handle<WeakFixedArray> target,
2625 Handle<WeakFixedArray> source);
2626
2627 friend class Factory; // For kReservedFieldCount.
Toon Verwaest 2014/12/01 15:23:54 Just move the method onto WeakFixedArray rather th
Jakob Kummerow 2014/12/02 12:32:15 Done. I've merged CopyFrom into it, to avoid redun
2628
2629 // Disallow inherited setters.
2630 void set(int index, Smi* value);
2631 void set(int index, Object* value);
2632 void set(int index, Object* value, WriteBarrierMode mode);
2633 DISALLOW_IMPLICIT_CONSTRUCTORS(WeakFixedArray);
2634 };
2635
2636
2591 // ConstantPoolArray describes a fixed-sized array containing constant pool 2637 // ConstantPoolArray describes a fixed-sized array containing constant pool
2592 // entries. 2638 // entries.
2593 // 2639 //
2594 // A ConstantPoolArray can be structured in two different ways depending upon 2640 // 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 2641 // whether it is extended or small. The is_extended_layout() method can be used
2596 // to discover which layout the constant pool has. 2642 // to discover which layout the constant pool has.
2597 // 2643 //
2598 // The format of a small constant pool is: 2644 // The format of a small constant pool is:
2599 // [kSmallLayout1Offset] : Small section layout bitmap 1 2645 // [kSmallLayout1Offset] : Small section layout bitmap 1
2600 // [kSmallLayout2Offset] : Small section layout bitmap 2 2646 // [kSmallLayout2Offset] : Small section layout bitmap 2
(...skipping 3275 matching lines...) Expand 10 before | Expand all | Expand 10 after
5876 // Tells whether the instance needs security checks when accessing its 5922 // Tells whether the instance needs security checks when accessing its
5877 // properties. 5923 // properties.
5878 inline void set_is_access_check_needed(bool access_check_needed); 5924 inline void set_is_access_check_needed(bool access_check_needed);
5879 inline bool is_access_check_needed(); 5925 inline bool is_access_check_needed();
5880 5926
5881 // Returns true if map has a non-empty stub code cache. 5927 // Returns true if map has a non-empty stub code cache.
5882 inline bool has_code_cache(); 5928 inline bool has_code_cache();
5883 5929
5884 // [prototype]: implicit prototype object. 5930 // [prototype]: implicit prototype object.
5885 DECL_ACCESSORS(prototype, Object) 5931 DECL_ACCESSORS(prototype, Object)
5932 // TODO(jkummerow): make set_prototype private.
5933 void SetPrototype(Handle<Object> prototype,
5934 PrototypeOptimizationMode proto_mode = FAST_PROTOTYPE);
5935 bool ShouldRegisterAsPrototypeUser(Handle<JSObject> prototype);
5936 bool CanUseOptimizationsBasedOnPrototypeRegistry();
5886 5937
5887 // [constructor]: points back to the function responsible for this map. 5938 // [constructor]: points back to the function responsible for this map.
5888 DECL_ACCESSORS(constructor, Object) 5939 DECL_ACCESSORS(constructor, Object)
5889 5940
5890 // [instance descriptors]: describes the object. 5941 // [instance descriptors]: describes the object.
5891 DECL_ACCESSORS(instance_descriptors, DescriptorArray) 5942 DECL_ACCESSORS(instance_descriptors, DescriptorArray)
5892 5943
5893 // [layout descriptor]: describes the object layout. 5944 // [layout descriptor]: describes the object layout.
5894 DECL_ACCESSORS(layout_descriptor, LayoutDescriptor) 5945 DECL_ACCESSORS(layout_descriptor, LayoutDescriptor)
5895 // |layout descriptor| accessor which can be used from GC. 5946 // |layout descriptor| accessor which can be used from GC.
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
6205 typedef void (*TraverseCallback)(Map* map, void* data); 6256 typedef void (*TraverseCallback)(Map* map, void* data);
6206 6257
6207 void TraverseTransitionTree(TraverseCallback callback, void* data); 6258 void TraverseTransitionTree(TraverseCallback callback, void* data);
6208 6259
6209 // When you set the prototype of an object using the __proto__ accessor you 6260 // 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 6261 // 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 6262 // 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 6263 // 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 6264 // 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 6265 // 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. 6266 // and the values are the maps they transition to.
6216 static const int kMaxCachedPrototypeTransitions = 256; 6267 static const int kMaxCachedPrototypeTransitions = 256;
6217 static Handle<Map> TransitionToPrototype(Handle<Map> map, 6268 static Handle<Map> TransitionToPrototype(Handle<Map> map,
6218 Handle<Object> prototype); 6269 Handle<Object> prototype,
6270 PrototypeOptimizationMode mode);
6219 6271
6220 static const int kMaxPreAllocatedPropertyFields = 255; 6272 static const int kMaxPreAllocatedPropertyFields = 255;
6221 6273
6222 // Layout description. 6274 // Layout description.
6223 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; 6275 static const int kInstanceSizesOffset = HeapObject::kHeaderSize;
6224 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; 6276 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize;
6225 static const int kBitField3Offset = kInstanceAttributesOffset + kIntSize; 6277 static const int kBitField3Offset = kInstanceAttributesOffset + kIntSize;
6226 static const int kPrototypeOffset = kBitField3Offset + kPointerSize; 6278 static const int kPrototypeOffset = kBitField3Offset + kPointerSize;
6227 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; 6279 static const int kConstructorOffset = kPrototypeOffset + kPointerSize;
6228 // Storage for the transition array is overloaded to directly contain a back 6280 // Storage for the transition array is overloaded to directly contain a back
(...skipping 4764 matching lines...) Expand 10 before | Expand all | Expand 10 after
10993 } else { 11045 } else {
10994 value &= ~(1 << bit_position); 11046 value &= ~(1 << bit_position);
10995 } 11047 }
10996 return value; 11048 return value;
10997 } 11049 }
10998 }; 11050 };
10999 11051
11000 } } // namespace v8::internal 11052 } } // namespace v8::internal
11001 11053
11002 #endif // V8_OBJECTS_H_ 11054 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/lookup.cc ('k') | src/objects.cc » ('j') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698