| 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 1824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 LazyRegisterPrototypeUser(Handle<Map> user, Isolate* isolate); | 1844 static void LazyRegisterPrototypeUser(Handle<Map> user, Isolate* isolate); |
| 1845 static bool RegisterPrototypeUserIfNotRegistered(Handle<JSObject> prototype, | 1845 static bool UnregisterPrototypeUser(Handle<Map> user, Isolate* isolate); |
| 1846 Handle<HeapObject> user, | |
| 1847 Isolate* isolate); | |
| 1848 static bool UnregisterPrototypeUser(Handle<JSObject> prototype, | |
| 1849 Handle<HeapObject> user); | |
| 1850 static void InvalidatePrototypeChains(Map* map); | 1846 static void InvalidatePrototypeChains(Map* map); |
| 1851 | 1847 |
| 1848 // Alternative implementation of WeakFixedArray::NullCallback. |
| 1849 class PrototypeRegistryCompactionCallback { |
| 1850 public: |
| 1851 static void Callback(Object* value, int old_index, int new_index); |
| 1852 }; |
| 1853 |
| 1852 // Retrieve interceptors. | 1854 // Retrieve interceptors. |
| 1853 InterceptorInfo* GetNamedInterceptor(); | 1855 InterceptorInfo* GetNamedInterceptor(); |
| 1854 InterceptorInfo* GetIndexedInterceptor(); | 1856 InterceptorInfo* GetIndexedInterceptor(); |
| 1855 | 1857 |
| 1856 // Used from JSReceiver. | 1858 // Used from JSReceiver. |
| 1857 MUST_USE_RESULT static Maybe<PropertyAttributes> | 1859 MUST_USE_RESULT static Maybe<PropertyAttributes> |
| 1858 GetPropertyAttributesWithInterceptor(Handle<JSObject> holder, | 1860 GetPropertyAttributesWithInterceptor(Handle<JSObject> holder, |
| 1859 Handle<Object> receiver, | 1861 Handle<Object> receiver, |
| 1860 Handle<Name> name); | 1862 Handle<Name> name); |
| 1861 MUST_USE_RESULT static Maybe<PropertyAttributes> | 1863 MUST_USE_RESULT static Maybe<PropertyAttributes> |
| (...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2619 DECLARE_PRINTER(FixedDoubleArray) | 2621 DECLARE_PRINTER(FixedDoubleArray) |
| 2620 DECLARE_VERIFIER(FixedDoubleArray) | 2622 DECLARE_VERIFIER(FixedDoubleArray) |
| 2621 | 2623 |
| 2622 private: | 2624 private: |
| 2623 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedDoubleArray); | 2625 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedDoubleArray); |
| 2624 }; | 2626 }; |
| 2625 | 2627 |
| 2626 | 2628 |
| 2627 class WeakFixedArray : public FixedArray { | 2629 class WeakFixedArray : public FixedArray { |
| 2628 public: | 2630 public: |
| 2629 enum SearchForDuplicates { kAlwaysAdd, kAddIfNotFound }; | |
| 2630 | |
| 2631 // If |maybe_array| is not a WeakFixedArray, a fresh one will be allocated. | 2631 // If |maybe_array| is not a WeakFixedArray, a fresh one will be allocated. |
| 2632 static Handle<WeakFixedArray> Add( | 2632 // This function does not check if the value exists already, callers must |
| 2633 Handle<Object> maybe_array, Handle<HeapObject> value, | 2633 // ensure this themselves if necessary. |
| 2634 SearchForDuplicates search_for_duplicates = kAlwaysAdd, | 2634 static Handle<WeakFixedArray> Add(Handle<Object> maybe_array, |
| 2635 bool* was_present = NULL); | 2635 Handle<HeapObject> value, |
| 2636 int* assigned_index = NULL); |
| 2636 | 2637 |
| 2637 // Returns true if an entry was found and removed. | 2638 // Returns true if an entry was found and removed. |
| 2638 bool Remove(Handle<HeapObject> value); | 2639 bool Remove(Handle<HeapObject> value); |
| 2639 | 2640 |
| 2641 class NullCallback { |
| 2642 public: |
| 2643 static void Callback(Object* value, int old_index, int new_index) {} |
| 2644 }; |
| 2645 |
| 2646 template <class CompactionCallback> |
| 2640 void Compact(); | 2647 void Compact(); |
| 2641 | 2648 |
| 2642 inline Object* Get(int index) const; | 2649 inline Object* Get(int index) const; |
| 2643 inline void Clear(int index); | 2650 inline void Clear(int index); |
| 2644 inline int Length() const; | 2651 inline int Length() const; |
| 2645 | 2652 |
| 2646 inline bool IsEmptySlot(int index) const; | 2653 inline bool IsEmptySlot(int index) const; |
| 2647 static Object* Empty() { return Smi::FromInt(0); } | 2654 static Object* Empty() { return Smi::FromInt(0); } |
| 2648 | 2655 |
| 2649 DECLARE_CAST(WeakFixedArray) | 2656 DECLARE_CAST(WeakFixedArray) |
| (...skipping 3405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6055 // Don't call set_raw_transitions() directly to overwrite transitions, use | 6062 // Don't call set_raw_transitions() directly to overwrite transitions, use |
| 6056 // the TransitionArray::ReplaceTransitions() wrapper instead! | 6063 // the TransitionArray::ReplaceTransitions() wrapper instead! |
| 6057 DECL_ACCESSORS(raw_transitions, Object) | 6064 DECL_ACCESSORS(raw_transitions, Object) |
| 6058 // [prototype_info]: Per-prototype metadata. Aliased with transitions | 6065 // [prototype_info]: Per-prototype metadata. Aliased with transitions |
| 6059 // (which prototype maps don't have). | 6066 // (which prototype maps don't have). |
| 6060 DECL_ACCESSORS(prototype_info, Object) | 6067 DECL_ACCESSORS(prototype_info, Object) |
| 6061 // PrototypeInfo is created lazily using this helper (which installs it on | 6068 // PrototypeInfo is created lazily using this helper (which installs it on |
| 6062 // the given prototype's map). | 6069 // the given prototype's map). |
| 6063 static Handle<PrototypeInfo> GetOrCreatePrototypeInfo( | 6070 static Handle<PrototypeInfo> GetOrCreatePrototypeInfo( |
| 6064 Handle<JSObject> prototype, Isolate* isolate); | 6071 Handle<JSObject> prototype, Isolate* isolate); |
| 6072 static Handle<PrototypeInfo> GetOrCreatePrototypeInfo( |
| 6073 Handle<Map> prototype_map, Isolate* isolate); |
| 6065 | 6074 |
| 6066 // [prototype chain validity cell]: Associated with a prototype object, | 6075 // [prototype chain validity cell]: Associated with a prototype object, |
| 6067 // stored in that object's map's PrototypeInfo, indicates that prototype | 6076 // stored in that object's map's PrototypeInfo, indicates that prototype |
| 6068 // chains through this object are currently valid. The cell will be | 6077 // chains through this object are currently valid. The cell will be |
| 6069 // invalidated and replaced when the prototype chain changes. | 6078 // invalidated and replaced when the prototype chain changes. |
| 6070 static Handle<Cell> GetOrCreatePrototypeChainValidityCell(Handle<Map> map, | 6079 static Handle<Cell> GetOrCreatePrototypeChainValidityCell(Handle<Map> map, |
| 6071 Isolate* isolate); | 6080 Isolate* isolate); |
| 6072 static const int kPrototypeChainValid = 0; | 6081 static const int kPrototypeChainValid = 0; |
| 6073 static const int kPrototypeChainInvalid = 1; | 6082 static const int kPrototypeChainInvalid = 1; |
| 6074 | 6083 |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6628 static const int kSize = kValueOffset + kPointerSize; | 6637 static const int kSize = kValueOffset + kPointerSize; |
| 6629 | 6638 |
| 6630 private: | 6639 private: |
| 6631 DISALLOW_IMPLICIT_CONSTRUCTORS(Box); | 6640 DISALLOW_IMPLICIT_CONSTRUCTORS(Box); |
| 6632 }; | 6641 }; |
| 6633 | 6642 |
| 6634 | 6643 |
| 6635 // Container for metadata stored on each prototype map. | 6644 // Container for metadata stored on each prototype map. |
| 6636 class PrototypeInfo : public Struct { | 6645 class PrototypeInfo : public Struct { |
| 6637 public: | 6646 public: |
| 6647 static const int UNREGISTERED = -1; |
| 6648 |
| 6638 // [prototype_users]: WeakFixedArray containing maps using this prototype, | 6649 // [prototype_users]: WeakFixedArray containing maps using this prototype, |
| 6639 // or Smi(0) if uninitialized. | 6650 // or Smi(0) if uninitialized. |
| 6640 DECL_ACCESSORS(prototype_users, Object) | 6651 DECL_ACCESSORS(prototype_users, Object) |
| 6652 // [registry_slot]: Slot in prototype's user registry where this user |
| 6653 // is stored. Returns UNREGISTERED if this prototype has not been registered. |
| 6654 inline int registry_slot() const; |
| 6655 inline void set_registry_slot(int slot); |
| 6641 // [validity_cell]: Cell containing the validity bit for prototype chains | 6656 // [validity_cell]: Cell containing the validity bit for prototype chains |
| 6642 // going through this object, or Smi(0) if uninitialized. | 6657 // going through this object, or Smi(0) if uninitialized. |
| 6643 DECL_ACCESSORS(validity_cell, Object) | 6658 DECL_ACCESSORS(validity_cell, Object) |
| 6644 // [constructor_name]: User-friendly name of the original constructor. | 6659 // [constructor_name]: User-friendly name of the original constructor. |
| 6645 DECL_ACCESSORS(constructor_name, Object) | 6660 DECL_ACCESSORS(constructor_name, Object) |
| 6646 | 6661 |
| 6647 DECLARE_CAST(PrototypeInfo) | 6662 DECLARE_CAST(PrototypeInfo) |
| 6648 | 6663 |
| 6649 // Dispatched behavior. | 6664 // Dispatched behavior. |
| 6650 DECLARE_PRINTER(PrototypeInfo) | 6665 DECLARE_PRINTER(PrototypeInfo) |
| 6651 DECLARE_VERIFIER(PrototypeInfo) | 6666 DECLARE_VERIFIER(PrototypeInfo) |
| 6652 | 6667 |
| 6653 static const int kPrototypeUsersOffset = HeapObject::kHeaderSize; | 6668 static const int kPrototypeUsersOffset = HeapObject::kHeaderSize; |
| 6654 static const int kValidityCellOffset = kPrototypeUsersOffset + kPointerSize; | 6669 static const int kRegistrySlotOffset = kPrototypeUsersOffset + kPointerSize; |
| 6670 static const int kValidityCellOffset = kRegistrySlotOffset + kPointerSize; |
| 6655 static const int kConstructorNameOffset = kValidityCellOffset + kPointerSize; | 6671 static const int kConstructorNameOffset = kValidityCellOffset + kPointerSize; |
| 6656 static const int kSize = kConstructorNameOffset + kPointerSize; | 6672 static const int kSize = kConstructorNameOffset + kPointerSize; |
| 6657 | 6673 |
| 6658 private: | 6674 private: |
| 6659 DISALLOW_IMPLICIT_CONSTRUCTORS(PrototypeInfo); | 6675 DISALLOW_IMPLICIT_CONSTRUCTORS(PrototypeInfo); |
| 6660 }; | 6676 }; |
| 6661 | 6677 |
| 6662 | 6678 |
| 6663 // Script describes a script which has been added to the VM. | 6679 // Script describes a script which has been added to the VM. |
| 6664 class Script: public Struct { | 6680 class Script: public Struct { |
| (...skipping 4437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11102 } else { | 11118 } else { |
| 11103 value &= ~(1 << bit_position); | 11119 value &= ~(1 << bit_position); |
| 11104 } | 11120 } |
| 11105 return value; | 11121 return value; |
| 11106 } | 11122 } |
| 11107 }; | 11123 }; |
| 11108 | 11124 |
| 11109 } } // namespace v8::internal | 11125 } } // namespace v8::internal |
| 11110 | 11126 |
| 11111 #endif // V8_OBJECTS_H_ | 11127 #endif // V8_OBJECTS_H_ |
| OLD | NEW |