| 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 1905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1916 PropertyAttributes attributes); | 1916 PropertyAttributes attributes); |
| 1917 static void SetDictionaryArgumentsElement(Handle<JSObject> object, | 1917 static void SetDictionaryArgumentsElement(Handle<JSObject> object, |
| 1918 uint32_t index, | 1918 uint32_t index, |
| 1919 Handle<Object> value, | 1919 Handle<Object> value, |
| 1920 PropertyAttributes attributes); | 1920 PropertyAttributes attributes); |
| 1921 | 1921 |
| 1922 static void OptimizeAsPrototype(Handle<JSObject> object, | 1922 static void OptimizeAsPrototype(Handle<JSObject> object, |
| 1923 PrototypeOptimizationMode mode); | 1923 PrototypeOptimizationMode mode); |
| 1924 static void ReoptimizeIfPrototype(Handle<JSObject> object); | 1924 static void ReoptimizeIfPrototype(Handle<JSObject> object); |
| 1925 static void LazyRegisterPrototypeUser(Handle<Map> user, Isolate* isolate); | 1925 static void LazyRegisterPrototypeUser(Handle<Map> user, Isolate* isolate); |
| 1926 static bool RegisterPrototypeUserIfNotRegistered(Handle<JSObject> prototype, | 1926 static bool UnregisterPrototypeUser(Handle<Map> user, Isolate* isolate); |
| 1927 Handle<HeapObject> user, | |
| 1928 Isolate* isolate); | |
| 1929 static bool UnregisterPrototypeUser(Handle<JSObject> prototype, | |
| 1930 Handle<HeapObject> user); | |
| 1931 static void InvalidatePrototypeChains(Map* map); | 1927 static void InvalidatePrototypeChains(Map* map); |
| 1932 | 1928 |
| 1929 // Alternative implementation of WeakFixedArray::NullCallback. |
| 1930 class PrototypeRegistryCompactionCallback { |
| 1931 public: |
| 1932 static void Callback(Object* value, int old_index, int new_index); |
| 1933 }; |
| 1934 |
| 1933 // Retrieve interceptors. | 1935 // Retrieve interceptors. |
| 1934 InterceptorInfo* GetNamedInterceptor(); | 1936 InterceptorInfo* GetNamedInterceptor(); |
| 1935 InterceptorInfo* GetIndexedInterceptor(); | 1937 InterceptorInfo* GetIndexedInterceptor(); |
| 1936 | 1938 |
| 1937 // Used from JSReceiver. | 1939 // Used from JSReceiver. |
| 1938 MUST_USE_RESULT static Maybe<PropertyAttributes> | 1940 MUST_USE_RESULT static Maybe<PropertyAttributes> |
| 1939 GetPropertyAttributesWithInterceptor(LookupIterator* it); | 1941 GetPropertyAttributesWithInterceptor(LookupIterator* it); |
| 1940 MUST_USE_RESULT static Maybe<PropertyAttributes> | 1942 MUST_USE_RESULT static Maybe<PropertyAttributes> |
| 1941 GetPropertyAttributesWithFailedAccessCheck(LookupIterator* it); | 1943 GetPropertyAttributesWithFailedAccessCheck(LookupIterator* it); |
| 1942 | 1944 |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2557 DECLARE_PRINTER(FixedDoubleArray) | 2559 DECLARE_PRINTER(FixedDoubleArray) |
| 2558 DECLARE_VERIFIER(FixedDoubleArray) | 2560 DECLARE_VERIFIER(FixedDoubleArray) |
| 2559 | 2561 |
| 2560 private: | 2562 private: |
| 2561 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedDoubleArray); | 2563 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedDoubleArray); |
| 2562 }; | 2564 }; |
| 2563 | 2565 |
| 2564 | 2566 |
| 2565 class WeakFixedArray : public FixedArray { | 2567 class WeakFixedArray : public FixedArray { |
| 2566 public: | 2568 public: |
| 2567 enum SearchForDuplicates { kAlwaysAdd, kAddIfNotFound }; | |
| 2568 | |
| 2569 // If |maybe_array| is not a WeakFixedArray, a fresh one will be allocated. | 2569 // If |maybe_array| is not a WeakFixedArray, a fresh one will be allocated. |
| 2570 static Handle<WeakFixedArray> Add( | 2570 // This function does not check if the value exists already, callers must |
| 2571 Handle<Object> maybe_array, Handle<HeapObject> value, | 2571 // ensure this themselves if necessary. |
| 2572 SearchForDuplicates search_for_duplicates = kAlwaysAdd, | 2572 static Handle<WeakFixedArray> Add(Handle<Object> maybe_array, |
| 2573 bool* was_present = NULL); | 2573 Handle<HeapObject> value, |
| 2574 int* assigned_index = NULL); |
| 2574 | 2575 |
| 2575 // Returns true if an entry was found and removed. | 2576 // Returns true if an entry was found and removed. |
| 2576 bool Remove(Handle<HeapObject> value); | 2577 bool Remove(Handle<HeapObject> value); |
| 2577 | 2578 |
| 2579 class NullCallback { |
| 2580 public: |
| 2581 static void Callback(Object* value, int old_index, int new_index) {} |
| 2582 }; |
| 2583 |
| 2584 template <class CompactionCallback> |
| 2578 void Compact(); | 2585 void Compact(); |
| 2579 | 2586 |
| 2580 inline Object* Get(int index) const; | 2587 inline Object* Get(int index) const; |
| 2581 inline void Clear(int index); | 2588 inline void Clear(int index); |
| 2582 inline int Length() const; | 2589 inline int Length() const; |
| 2583 | 2590 |
| 2584 inline bool IsEmptySlot(int index) const; | 2591 inline bool IsEmptySlot(int index) const; |
| 2585 static Object* Empty() { return Smi::FromInt(0); } | 2592 static Object* Empty() { return Smi::FromInt(0); } |
| 2586 | 2593 |
| 2587 DECLARE_CAST(WeakFixedArray) | 2594 DECLARE_CAST(WeakFixedArray) |
| (...skipping 3156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5744 // Don't call set_raw_transitions() directly to overwrite transitions, use | 5751 // Don't call set_raw_transitions() directly to overwrite transitions, use |
| 5745 // the TransitionArray::ReplaceTransitions() wrapper instead! | 5752 // the TransitionArray::ReplaceTransitions() wrapper instead! |
| 5746 DECL_ACCESSORS(raw_transitions, Object) | 5753 DECL_ACCESSORS(raw_transitions, Object) |
| 5747 // [prototype_info]: Per-prototype metadata. Aliased with transitions | 5754 // [prototype_info]: Per-prototype metadata. Aliased with transitions |
| 5748 // (which prototype maps don't have). | 5755 // (which prototype maps don't have). |
| 5749 DECL_ACCESSORS(prototype_info, Object) | 5756 DECL_ACCESSORS(prototype_info, Object) |
| 5750 // PrototypeInfo is created lazily using this helper (which installs it on | 5757 // PrototypeInfo is created lazily using this helper (which installs it on |
| 5751 // the given prototype's map). | 5758 // the given prototype's map). |
| 5752 static Handle<PrototypeInfo> GetOrCreatePrototypeInfo( | 5759 static Handle<PrototypeInfo> GetOrCreatePrototypeInfo( |
| 5753 Handle<JSObject> prototype, Isolate* isolate); | 5760 Handle<JSObject> prototype, Isolate* isolate); |
| 5761 static Handle<PrototypeInfo> GetOrCreatePrototypeInfo( |
| 5762 Handle<Map> prototype_map, Isolate* isolate); |
| 5754 | 5763 |
| 5755 // [prototype chain validity cell]: Associated with a prototype object, | 5764 // [prototype chain validity cell]: Associated with a prototype object, |
| 5756 // stored in that object's map's PrototypeInfo, indicates that prototype | 5765 // stored in that object's map's PrototypeInfo, indicates that prototype |
| 5757 // chains through this object are currently valid. The cell will be | 5766 // chains through this object are currently valid. The cell will be |
| 5758 // invalidated and replaced when the prototype chain changes. | 5767 // invalidated and replaced when the prototype chain changes. |
| 5759 static Handle<Cell> GetOrCreatePrototypeChainValidityCell(Handle<Map> map, | 5768 static Handle<Cell> GetOrCreatePrototypeChainValidityCell(Handle<Map> map, |
| 5760 Isolate* isolate); | 5769 Isolate* isolate); |
| 5761 static const int kPrototypeChainValid = 0; | 5770 static const int kPrototypeChainValid = 0; |
| 5762 static const int kPrototypeChainInvalid = 1; | 5771 static const int kPrototypeChainInvalid = 1; |
| 5763 | 5772 |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6321 static const int kSize = kValueOffset + kPointerSize; | 6330 static const int kSize = kValueOffset + kPointerSize; |
| 6322 | 6331 |
| 6323 private: | 6332 private: |
| 6324 DISALLOW_IMPLICIT_CONSTRUCTORS(Box); | 6333 DISALLOW_IMPLICIT_CONSTRUCTORS(Box); |
| 6325 }; | 6334 }; |
| 6326 | 6335 |
| 6327 | 6336 |
| 6328 // Container for metadata stored on each prototype map. | 6337 // Container for metadata stored on each prototype map. |
| 6329 class PrototypeInfo : public Struct { | 6338 class PrototypeInfo : public Struct { |
| 6330 public: | 6339 public: |
| 6340 static const int UNREGISTERED = -1; |
| 6341 |
| 6331 // [prototype_users]: WeakFixedArray containing maps using this prototype, | 6342 // [prototype_users]: WeakFixedArray containing maps using this prototype, |
| 6332 // or Smi(0) if uninitialized. | 6343 // or Smi(0) if uninitialized. |
| 6333 DECL_ACCESSORS(prototype_users, Object) | 6344 DECL_ACCESSORS(prototype_users, Object) |
| 6345 // [registry_slot]: Slot in prototype's user registry where this user |
| 6346 // is stored. Returns UNREGISTERED if this prototype has not been registered. |
| 6347 inline int registry_slot() const; |
| 6348 inline void set_registry_slot(int slot); |
| 6334 // [validity_cell]: Cell containing the validity bit for prototype chains | 6349 // [validity_cell]: Cell containing the validity bit for prototype chains |
| 6335 // going through this object, or Smi(0) if uninitialized. | 6350 // going through this object, or Smi(0) if uninitialized. |
| 6336 DECL_ACCESSORS(validity_cell, Object) | 6351 DECL_ACCESSORS(validity_cell, Object) |
| 6337 // [constructor_name]: User-friendly name of the original constructor. | 6352 // [constructor_name]: User-friendly name of the original constructor. |
| 6338 DECL_ACCESSORS(constructor_name, Object) | 6353 DECL_ACCESSORS(constructor_name, Object) |
| 6339 | 6354 |
| 6340 DECLARE_CAST(PrototypeInfo) | 6355 DECLARE_CAST(PrototypeInfo) |
| 6341 | 6356 |
| 6342 // Dispatched behavior. | 6357 // Dispatched behavior. |
| 6343 DECLARE_PRINTER(PrototypeInfo) | 6358 DECLARE_PRINTER(PrototypeInfo) |
| 6344 DECLARE_VERIFIER(PrototypeInfo) | 6359 DECLARE_VERIFIER(PrototypeInfo) |
| 6345 | 6360 |
| 6346 static const int kPrototypeUsersOffset = HeapObject::kHeaderSize; | 6361 static const int kPrototypeUsersOffset = HeapObject::kHeaderSize; |
| 6347 static const int kValidityCellOffset = kPrototypeUsersOffset + kPointerSize; | 6362 static const int kRegistrySlotOffset = kPrototypeUsersOffset + kPointerSize; |
| 6363 static const int kValidityCellOffset = kRegistrySlotOffset + kPointerSize; |
| 6348 static const int kConstructorNameOffset = kValidityCellOffset + kPointerSize; | 6364 static const int kConstructorNameOffset = kValidityCellOffset + kPointerSize; |
| 6349 static const int kSize = kConstructorNameOffset + kPointerSize; | 6365 static const int kSize = kConstructorNameOffset + kPointerSize; |
| 6350 | 6366 |
| 6351 private: | 6367 private: |
| 6352 DISALLOW_IMPLICIT_CONSTRUCTORS(PrototypeInfo); | 6368 DISALLOW_IMPLICIT_CONSTRUCTORS(PrototypeInfo); |
| 6353 }; | 6369 }; |
| 6354 | 6370 |
| 6355 | 6371 |
| 6356 // Script describes a script which has been added to the VM. | 6372 // Script describes a script which has been added to the VM. |
| 6357 class Script: public Struct { | 6373 class Script: public Struct { |
| (...skipping 4474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10832 } else { | 10848 } else { |
| 10833 value &= ~(1 << bit_position); | 10849 value &= ~(1 << bit_position); |
| 10834 } | 10850 } |
| 10835 return value; | 10851 return value; |
| 10836 } | 10852 } |
| 10837 }; | 10853 }; |
| 10838 | 10854 |
| 10839 } } // namespace v8::internal | 10855 } } // namespace v8::internal |
| 10840 | 10856 |
| 10841 #endif // V8_OBJECTS_H_ | 10857 #endif // V8_OBJECTS_H_ |
| OLD | NEW |