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

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: use WeakCellForMap() when appropriate 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') | no next file with comments »
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 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 V(LayoutDescriptor) \ 937 V(LayoutDescriptor) \
937 V(Map) \ 938 V(Map) \
938 V(DescriptorArray) \ 939 V(DescriptorArray) \
939 V(TransitionArray) \ 940 V(TransitionArray) \
940 V(TypeFeedbackVector) \ 941 V(TypeFeedbackVector) \
941 V(DeoptimizationInputData) \ 942 V(DeoptimizationInputData) \
942 V(DeoptimizationOutputData) \ 943 V(DeoptimizationOutputData) \
943 V(DependentCode) \ 944 V(DependentCode) \
944 V(FixedArray) \ 945 V(FixedArray) \
945 V(FixedDoubleArray) \ 946 V(FixedDoubleArray) \
947 V(WeakFixedArray) \
946 V(ConstantPoolArray) \ 948 V(ConstantPoolArray) \
947 V(Context) \ 949 V(Context) \
948 V(ScriptContextTable) \ 950 V(ScriptContextTable) \
949 V(NativeContext) \ 951 V(NativeContext) \
950 V(ScopeInfo) \ 952 V(ScopeInfo) \
951 V(JSFunction) \ 953 V(JSFunction) \
952 V(Code) \ 954 V(Code) \
953 V(Oddball) \ 955 V(Oddball) \
954 V(SharedFunctionInfo) \ 956 V(SharedFunctionInfo) \
955 V(JSValue) \ 957 V(JSValue) \
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after
1814 // Sets the property value in a normalized object given (key, value, details). 1816 // Sets the property value in a normalized object given (key, value, details).
1815 // Handles the special representation of JS global objects. 1817 // Handles the special representation of JS global objects.
1816 static void SetNormalizedProperty(Handle<JSObject> object, 1818 static void SetNormalizedProperty(Handle<JSObject> object,
1817 Handle<Name> key, 1819 Handle<Name> key,
1818 Handle<Object> value, 1820 Handle<Object> value,
1819 PropertyDetails details); 1821 PropertyDetails details);
1820 1822
1821 static void OptimizeAsPrototype(Handle<JSObject> object, 1823 static void OptimizeAsPrototype(Handle<JSObject> object,
1822 PrototypeOptimizationMode mode); 1824 PrototypeOptimizationMode mode);
1823 static void ReoptimizeIfPrototype(Handle<JSObject> object); 1825 static void ReoptimizeIfPrototype(Handle<JSObject> object);
1826 static void RegisterPrototypeUser(Handle<JSObject> prototype,
1827 Handle<HeapObject> user);
1828 static void UnregisterPrototypeUser(Handle<JSObject> prototype,
1829 Handle<HeapObject> user);
1824 1830
1825 // Retrieve interceptors. 1831 // Retrieve interceptors.
1826 InterceptorInfo* GetNamedInterceptor(); 1832 InterceptorInfo* GetNamedInterceptor();
1827 InterceptorInfo* GetIndexedInterceptor(); 1833 InterceptorInfo* GetIndexedInterceptor();
1828 1834
1829 // Used from JSReceiver. 1835 // Used from JSReceiver.
1830 MUST_USE_RESULT static Maybe<PropertyAttributes> 1836 MUST_USE_RESULT static Maybe<PropertyAttributes>
1831 GetPropertyAttributesWithInterceptor(Handle<JSObject> holder, 1837 GetPropertyAttributesWithInterceptor(Handle<JSObject> holder,
1832 Handle<Object> receiver, 1838 Handle<Object> receiver,
1833 Handle<Name> name); 1839 Handle<Name> name);
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
2601 2607
2602 // Dispatched behavior. 2608 // Dispatched behavior.
2603 DECLARE_PRINTER(FixedDoubleArray) 2609 DECLARE_PRINTER(FixedDoubleArray)
2604 DECLARE_VERIFIER(FixedDoubleArray) 2610 DECLARE_VERIFIER(FixedDoubleArray)
2605 2611
2606 private: 2612 private:
2607 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedDoubleArray); 2613 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedDoubleArray);
2608 }; 2614 };
2609 2615
2610 2616
2617 class WeakFixedArray : public FixedArray {
2618 public:
2619 enum SearchForDuplicates { kAlwaysAdd, kAddIfNotFound };
2620
2621 // If |maybe_array| is not a WeakFixedArray, a fresh one will be allocated.
2622 static Handle<WeakFixedArray> Add(
2623 Handle<Object> maybe_array, Handle<HeapObject> value,
2624 SearchForDuplicates search_for_duplicates = kAlwaysAdd);
2625
2626 void Remove(Handle<HeapObject> value);
2627
2628 inline Object* Get(int index) const;
2629 inline int Length() const;
2630
2631 DECLARE_CAST(WeakFixedArray)
2632
2633 private:
2634 static const int kLastUsedIndexIndex = 0;
2635 static const int kFirstIndex = 1;
2636
2637 static Handle<WeakFixedArray> Allocate(
2638 Isolate* isolate, int size, Handle<WeakFixedArray> initialize_from);
2639
2640 static void Set(Handle<WeakFixedArray> array, int index,
2641 Handle<HeapObject> value);
2642 inline void clear(int index);
2643 inline bool IsEmptySlot(int index) const;
2644
2645 inline int last_used_index() const;
2646 inline void set_last_used_index(int index);
2647
2648 // Disallow inherited setters.
2649 void set(int index, Smi* value);
2650 void set(int index, Object* value);
2651 void set(int index, Object* value, WriteBarrierMode mode);
2652 DISALLOW_IMPLICIT_CONSTRUCTORS(WeakFixedArray);
2653 };
2654
2655
2611 // ConstantPoolArray describes a fixed-sized array containing constant pool 2656 // ConstantPoolArray describes a fixed-sized array containing constant pool
2612 // entries. 2657 // entries.
2613 // 2658 //
2614 // A ConstantPoolArray can be structured in two different ways depending upon 2659 // A ConstantPoolArray can be structured in two different ways depending upon
2615 // whether it is extended or small. The is_extended_layout() method can be used 2660 // whether it is extended or small. The is_extended_layout() method can be used
2616 // to discover which layout the constant pool has. 2661 // to discover which layout the constant pool has.
2617 // 2662 //
2618 // The format of a small constant pool is: 2663 // The format of a small constant pool is:
2619 // [kSmallLayout1Offset] : Small section layout bitmap 1 2664 // [kSmallLayout1Offset] : Small section layout bitmap 1
2620 // [kSmallLayout2Offset] : Small section layout bitmap 2 2665 // [kSmallLayout2Offset] : Small section layout bitmap 2
(...skipping 3298 matching lines...) Expand 10 before | Expand all | Expand 10 after
5919 // Tells whether the instance needs security checks when accessing its 5964 // Tells whether the instance needs security checks when accessing its
5920 // properties. 5965 // properties.
5921 inline void set_is_access_check_needed(bool access_check_needed); 5966 inline void set_is_access_check_needed(bool access_check_needed);
5922 inline bool is_access_check_needed(); 5967 inline bool is_access_check_needed();
5923 5968
5924 // Returns true if map has a non-empty stub code cache. 5969 // Returns true if map has a non-empty stub code cache.
5925 inline bool has_code_cache(); 5970 inline bool has_code_cache();
5926 5971
5927 // [prototype]: implicit prototype object. 5972 // [prototype]: implicit prototype object.
5928 DECL_ACCESSORS(prototype, Object) 5973 DECL_ACCESSORS(prototype, Object)
5974 // TODO(jkummerow): make set_prototype private.
5975 void SetPrototype(Handle<Object> prototype,
5976 PrototypeOptimizationMode proto_mode = FAST_PROTOTYPE);
5977 bool ShouldRegisterAsPrototypeUser(Handle<JSObject> prototype);
5978 bool CanUseOptimizationsBasedOnPrototypeRegistry();
5929 5979
5930 // [constructor]: points back to the function responsible for this map. 5980 // [constructor]: points back to the function responsible for this map.
5931 DECL_ACCESSORS(constructor, Object) 5981 DECL_ACCESSORS(constructor, Object)
5932 5982
5933 // [instance descriptors]: describes the object. 5983 // [instance descriptors]: describes the object.
5934 DECL_ACCESSORS(instance_descriptors, DescriptorArray) 5984 DECL_ACCESSORS(instance_descriptors, DescriptorArray)
5935 5985
5936 // [layout descriptor]: describes the object layout. 5986 // [layout descriptor]: describes the object layout.
5937 DECL_ACCESSORS(layout_descriptor, LayoutDescriptor) 5987 DECL_ACCESSORS(layout_descriptor, LayoutDescriptor)
5938 // |layout descriptor| accessor which can be used from GC. 5988 // |layout descriptor| accessor which can be used from GC.
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
6250 typedef void (*TraverseCallback)(Map* map, void* data); 6300 typedef void (*TraverseCallback)(Map* map, void* data);
6251 6301
6252 void TraverseTransitionTree(TraverseCallback callback, void* data); 6302 void TraverseTransitionTree(TraverseCallback callback, void* data);
6253 6303
6254 // When you set the prototype of an object using the __proto__ accessor you 6304 // When you set the prototype of an object using the __proto__ accessor you
6255 // need a new map for the object (the prototype is stored in the map). In 6305 // need a new map for the object (the prototype is stored in the map). In
6256 // order not to multiply maps unnecessarily we store these as transitions in 6306 // order not to multiply maps unnecessarily we store these as transitions in
6257 // the original map. That way we can transition to the same map if the same 6307 // the original map. That way we can transition to the same map if the same
6258 // prototype is set, rather than creating a new map every time. The 6308 // prototype is set, rather than creating a new map every time. The
6259 // transitions are in the form of a map where the keys are prototype objects 6309 // transitions are in the form of a map where the keys are prototype objects
6260 // and the values are the maps the are transitioned to. 6310 // and the values are the maps they transition to.
6261 static const int kMaxCachedPrototypeTransitions = 256; 6311 static const int kMaxCachedPrototypeTransitions = 256;
6262 static Handle<Map> TransitionToPrototype(Handle<Map> map, 6312 static Handle<Map> TransitionToPrototype(Handle<Map> map,
6263 Handle<Object> prototype); 6313 Handle<Object> prototype,
6314 PrototypeOptimizationMode mode);
6264 6315
6265 static const int kMaxPreAllocatedPropertyFields = 255; 6316 static const int kMaxPreAllocatedPropertyFields = 255;
6266 6317
6267 // Layout description. 6318 // Layout description.
6268 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; 6319 static const int kInstanceSizesOffset = HeapObject::kHeaderSize;
6269 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; 6320 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize;
6270 static const int kBitField3Offset = kInstanceAttributesOffset + kIntSize; 6321 static const int kBitField3Offset = kInstanceAttributesOffset + kIntSize;
6271 static const int kPrototypeOffset = kBitField3Offset + kPointerSize; 6322 static const int kPrototypeOffset = kBitField3Offset + kPointerSize;
6272 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; 6323 static const int kConstructorOffset = kPrototypeOffset + kPointerSize;
6273 // Storage for the transition array is overloaded to directly contain a back 6324 // Storage for the transition array is overloaded to directly contain a back
(...skipping 4768 matching lines...) Expand 10 before | Expand all | Expand 10 after
11042 } else { 11093 } else {
11043 value &= ~(1 << bit_position); 11094 value &= ~(1 << bit_position);
11044 } 11095 }
11045 return value; 11096 return value;
11046 } 11097 }
11047 }; 11098 };
11048 11099
11049 } } // namespace v8::internal 11100 } } // namespace v8::internal
11050 11101
11051 #endif // V8_OBJECTS_H_ 11102 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/lookup.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698