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 1823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1834 // Sets the property value in a normalized object given (key, value, details). | 1834 // Sets the property value in a normalized object given (key, value, details). |
1835 // Handles the special representation of JS global objects. | 1835 // Handles the special representation of JS global objects. |
1836 static void SetNormalizedProperty(Handle<JSObject> object, | 1836 static void SetNormalizedProperty(Handle<JSObject> object, |
1837 Handle<Name> key, | 1837 Handle<Name> key, |
1838 Handle<Object> value, | 1838 Handle<Object> value, |
1839 PropertyDetails details); | 1839 PropertyDetails details); |
1840 | 1840 |
1841 static void OptimizeAsPrototype(Handle<JSObject> object, | 1841 static void OptimizeAsPrototype(Handle<JSObject> object, |
1842 PrototypeOptimizationMode mode); | 1842 PrototypeOptimizationMode mode); |
1843 static void ReoptimizeIfPrototype(Handle<JSObject> object); | 1843 static void ReoptimizeIfPrototype(Handle<JSObject> object); |
1844 static void RegisterPrototypeUser(Handle<JSObject> prototype, | 1844 static void LazyRegisterPrototypeUser(Handle<Map> user, Isolate* isolate); |
1845 Handle<HeapObject> user); | 1845 static bool RegisterPrototypeUserIfNotRegistered(Handle<JSObject> prototype, |
1846 static void UnregisterPrototypeUser(Handle<JSObject> prototype, | 1846 Handle<HeapObject> user, |
| 1847 Isolate* isolate); |
| 1848 static bool UnregisterPrototypeUser(Handle<JSObject> prototype, |
1847 Handle<HeapObject> user); | 1849 Handle<HeapObject> user); |
1848 static void InvalidatePrototypeChains(Map* map); | 1850 static void InvalidatePrototypeChains(Map* map); |
1849 | 1851 |
1850 // Retrieve interceptors. | 1852 // Retrieve interceptors. |
1851 InterceptorInfo* GetNamedInterceptor(); | 1853 InterceptorInfo* GetNamedInterceptor(); |
1852 InterceptorInfo* GetIndexedInterceptor(); | 1854 InterceptorInfo* GetIndexedInterceptor(); |
1853 | 1855 |
1854 // Used from JSReceiver. | 1856 // Used from JSReceiver. |
1855 MUST_USE_RESULT static Maybe<PropertyAttributes> | 1857 MUST_USE_RESULT static Maybe<PropertyAttributes> |
1856 GetPropertyAttributesWithInterceptor(Handle<JSObject> holder, | 1858 GetPropertyAttributesWithInterceptor(Handle<JSObject> holder, |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2614 }; | 2616 }; |
2615 | 2617 |
2616 | 2618 |
2617 class WeakFixedArray : public FixedArray { | 2619 class WeakFixedArray : public FixedArray { |
2618 public: | 2620 public: |
2619 enum SearchForDuplicates { kAlwaysAdd, kAddIfNotFound }; | 2621 enum SearchForDuplicates { kAlwaysAdd, kAddIfNotFound }; |
2620 | 2622 |
2621 // If |maybe_array| is not a WeakFixedArray, a fresh one will be allocated. | 2623 // If |maybe_array| is not a WeakFixedArray, a fresh one will be allocated. |
2622 static Handle<WeakFixedArray> Add( | 2624 static Handle<WeakFixedArray> Add( |
2623 Handle<Object> maybe_array, Handle<HeapObject> value, | 2625 Handle<Object> maybe_array, Handle<HeapObject> value, |
2624 SearchForDuplicates search_for_duplicates = kAlwaysAdd); | 2626 SearchForDuplicates search_for_duplicates = kAlwaysAdd, |
| 2627 bool* was_present = NULL); |
2625 | 2628 |
2626 void Remove(Handle<HeapObject> value); | 2629 // Returns true if an entry was found and removed. |
| 2630 bool Remove(Handle<HeapObject> value); |
2627 | 2631 |
2628 void Compact(); | 2632 void Compact(); |
2629 | 2633 |
2630 inline Object* Get(int index) const; | 2634 inline Object* Get(int index) const; |
2631 inline int Length() const; | 2635 inline int Length() const; |
2632 | 2636 |
2633 static Object* Empty() { return Smi::FromInt(0); } | 2637 static Object* Empty() { return Smi::FromInt(0); } |
2634 | 2638 |
2635 DECLARE_CAST(WeakFixedArray) | 2639 DECLARE_CAST(WeakFixedArray) |
2636 | 2640 |
(...skipping 3200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5837 // any cleared weak cell. | 5841 // any cleared weak cell. |
5838 bool Compact(); | 5842 bool Compact(); |
5839 static int Grow(int number_of_entries) { | 5843 static int Grow(int number_of_entries) { |
5840 if (number_of_entries < 5) return number_of_entries + 1; | 5844 if (number_of_entries < 5) return number_of_entries + 1; |
5841 return number_of_entries * 5 / 4; | 5845 return number_of_entries * 5 / 4; |
5842 } | 5846 } |
5843 static const int kCodesStartIndex = kGroupCount; | 5847 static const int kCodesStartIndex = kGroupCount; |
5844 }; | 5848 }; |
5845 | 5849 |
5846 | 5850 |
| 5851 class PrototypeInfo; |
| 5852 |
| 5853 |
5847 // All heap objects have a Map that describes their structure. | 5854 // All heap objects have a Map that describes their structure. |
5848 // A Map contains information about: | 5855 // A Map contains information about: |
5849 // - Size information about the object | 5856 // - Size information about the object |
5850 // - How to iterate over an object (for garbage collection) | 5857 // - How to iterate over an object (for garbage collection) |
5851 class Map: public HeapObject { | 5858 class Map: public HeapObject { |
5852 public: | 5859 public: |
5853 // Instance size. | 5860 // Instance size. |
5854 // Size in bytes or kVariableSizeSentinel if instances do not have | 5861 // Size in bytes or kVariableSizeSentinel if instances do not have |
5855 // a fixed size. | 5862 // a fixed size. |
5856 inline int instance_size(); | 5863 inline int instance_size(); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6044 | 6051 |
6045 inline FixedArrayBase* GetInitialElements(); | 6052 inline FixedArrayBase* GetInitialElements(); |
6046 | 6053 |
6047 // [raw_transitions]: Provides access to the transitions storage field. | 6054 // [raw_transitions]: Provides access to the transitions storage field. |
6048 // Don't call set_raw_transitions() directly to overwrite transitions, use | 6055 // Don't call set_raw_transitions() directly to overwrite transitions, use |
6049 // the TransitionArray::ReplaceTransitions() wrapper instead! | 6056 // the TransitionArray::ReplaceTransitions() wrapper instead! |
6050 DECL_ACCESSORS(raw_transitions, Object) | 6057 DECL_ACCESSORS(raw_transitions, Object) |
6051 // [prototype_info]: Per-prototype metadata. Aliased with transitions | 6058 // [prototype_info]: Per-prototype metadata. Aliased with transitions |
6052 // (which prototype maps don't have). | 6059 // (which prototype maps don't have). |
6053 DECL_ACCESSORS(prototype_info, Object) | 6060 DECL_ACCESSORS(prototype_info, Object) |
| 6061 // PrototypeInfo is created lazily using this helper (which installs it on |
| 6062 // the given prototype's map). |
| 6063 static Handle<PrototypeInfo> GetOrCreatePrototypeInfo( |
| 6064 Handle<JSObject> prototype, Isolate* isolate); |
6054 | 6065 |
6055 // [prototype chain validity cell]: Associated with a prototype object, | 6066 // [prototype chain validity cell]: Associated with a prototype object, |
6056 // stored in that object's map's PrototypeInfo, indicates that prototype | 6067 // stored in that object's map's PrototypeInfo, indicates that prototype |
6057 // chains through this object are currently valid. The cell will be | 6068 // chains through this object are currently valid. The cell will be |
6058 // invalidated and replaced when the prototype chain changes. | 6069 // invalidated and replaced when the prototype chain changes. |
6059 static Handle<Cell> GetOrCreatePrototypeChainValidityCell(Handle<Map> map, | 6070 static Handle<Cell> GetOrCreatePrototypeChainValidityCell(Handle<Map> map, |
6060 Isolate* isolate); | 6071 Isolate* isolate); |
6061 static const int kPrototypeChainValid = 0; | 6072 static const int kPrototypeChainValid = 0; |
6062 static const int kPrototypeChainInvalid = 1; | 6073 static const int kPrototypeChainInvalid = 1; |
6063 | 6074 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6116 | 6127 |
6117 // Returns true if map has a non-empty stub code cache. | 6128 // Returns true if map has a non-empty stub code cache. |
6118 inline bool has_code_cache(); | 6129 inline bool has_code_cache(); |
6119 | 6130 |
6120 // [prototype]: implicit prototype object. | 6131 // [prototype]: implicit prototype object. |
6121 DECL_ACCESSORS(prototype, Object) | 6132 DECL_ACCESSORS(prototype, Object) |
6122 // TODO(jkummerow): make set_prototype private. | 6133 // TODO(jkummerow): make set_prototype private. |
6123 static void SetPrototype( | 6134 static void SetPrototype( |
6124 Handle<Map> map, Handle<Object> prototype, | 6135 Handle<Map> map, Handle<Object> prototype, |
6125 PrototypeOptimizationMode proto_mode = FAST_PROTOTYPE); | 6136 PrototypeOptimizationMode proto_mode = FAST_PROTOTYPE); |
6126 static bool ShouldRegisterAsPrototypeUser(Handle<Map> map, | |
6127 Handle<JSObject> prototype); | |
6128 bool CanUseOptimizationsBasedOnPrototypeRegistry(); | |
6129 | 6137 |
6130 // [constructor]: points back to the function responsible for this map. | 6138 // [constructor]: points back to the function responsible for this map. |
6131 // The field overlaps with the back pointer. All maps in a transition tree | 6139 // The field overlaps with the back pointer. All maps in a transition tree |
6132 // have the same constructor, so maps with back pointers can walk the | 6140 // have the same constructor, so maps with back pointers can walk the |
6133 // back pointer chain until they find the map holding their constructor. | 6141 // back pointer chain until they find the map holding their constructor. |
6134 DECL_ACCESSORS(constructor_or_backpointer, Object) | 6142 DECL_ACCESSORS(constructor_or_backpointer, Object) |
6135 inline Object* GetConstructor() const; | 6143 inline Object* GetConstructor() const; |
6136 inline void SetConstructor(Object* constructor, | 6144 inline void SetConstructor(Object* constructor, |
6137 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | 6145 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
6138 // [back pointer]: points back to the parent map from which a transition | 6146 // [back pointer]: points back to the parent map from which a transition |
(...skipping 4954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11093 } else { | 11101 } else { |
11094 value &= ~(1 << bit_position); | 11102 value &= ~(1 << bit_position); |
11095 } | 11103 } |
11096 return value; | 11104 return value; |
11097 } | 11105 } |
11098 }; | 11106 }; |
11099 | 11107 |
11100 } } // namespace v8::internal | 11108 } } // namespace v8::internal |
11101 | 11109 |
11102 #endif // V8_OBJECTS_H_ | 11110 #endif // V8_OBJECTS_H_ |
OLD | NEW |