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 1888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1899 PropertyAttributes attributes); | 1899 PropertyAttributes attributes); |
1900 static void SetDictionaryArgumentsElement(Handle<JSObject> object, | 1900 static void SetDictionaryArgumentsElement(Handle<JSObject> object, |
1901 uint32_t index, | 1901 uint32_t index, |
1902 Handle<Object> value, | 1902 Handle<Object> value, |
1903 PropertyAttributes attributes); | 1903 PropertyAttributes attributes); |
1904 | 1904 |
1905 static void OptimizeAsPrototype(Handle<JSObject> object, | 1905 static void OptimizeAsPrototype(Handle<JSObject> object, |
1906 PrototypeOptimizationMode mode); | 1906 PrototypeOptimizationMode mode); |
1907 static void ReoptimizeIfPrototype(Handle<JSObject> object); | 1907 static void ReoptimizeIfPrototype(Handle<JSObject> object); |
1908 static void LazyRegisterPrototypeUser(Handle<Map> user, Isolate* isolate); | 1908 static void LazyRegisterPrototypeUser(Handle<Map> user, Isolate* isolate); |
1909 static bool RegisterPrototypeUserIfNotRegistered(Handle<JSObject> prototype, | 1909 static bool UnregisterPrototypeUser(Handle<Map> user, Isolate* isolate); |
1910 Handle<HeapObject> user, | |
1911 Isolate* isolate); | |
1912 static bool UnregisterPrototypeUser(Handle<JSObject> prototype, | |
1913 Handle<HeapObject> user); | |
1914 static void InvalidatePrototypeChains(Map* map); | 1910 static void InvalidatePrototypeChains(Map* map); |
1915 | 1911 |
| 1912 // Alternative implementation of WeakFixedArray::NullCallback. |
| 1913 class PrototypeRegistryCompactionCallback { |
| 1914 public: |
| 1915 static void Callback(Object* value, int old_index, int new_index); |
| 1916 }; |
| 1917 |
1916 // Retrieve interceptors. | 1918 // Retrieve interceptors. |
1917 InterceptorInfo* GetNamedInterceptor(); | 1919 InterceptorInfo* GetNamedInterceptor(); |
1918 InterceptorInfo* GetIndexedInterceptor(); | 1920 InterceptorInfo* GetIndexedInterceptor(); |
1919 | 1921 |
1920 // Used from JSReceiver. | 1922 // Used from JSReceiver. |
1921 MUST_USE_RESULT static Maybe<PropertyAttributes> | 1923 MUST_USE_RESULT static Maybe<PropertyAttributes> |
1922 GetPropertyAttributesWithInterceptor(LookupIterator* it); | 1924 GetPropertyAttributesWithInterceptor(LookupIterator* it); |
1923 MUST_USE_RESULT static Maybe<PropertyAttributes> | 1925 MUST_USE_RESULT static Maybe<PropertyAttributes> |
1924 GetPropertyAttributesWithFailedAccessCheck(LookupIterator* it); | 1926 GetPropertyAttributesWithFailedAccessCheck(LookupIterator* it); |
1925 | 1927 |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2524 DECLARE_PRINTER(FixedDoubleArray) | 2526 DECLARE_PRINTER(FixedDoubleArray) |
2525 DECLARE_VERIFIER(FixedDoubleArray) | 2527 DECLARE_VERIFIER(FixedDoubleArray) |
2526 | 2528 |
2527 private: | 2529 private: |
2528 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedDoubleArray); | 2530 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedDoubleArray); |
2529 }; | 2531 }; |
2530 | 2532 |
2531 | 2533 |
2532 class WeakFixedArray : public FixedArray { | 2534 class WeakFixedArray : public FixedArray { |
2533 public: | 2535 public: |
2534 enum SearchForDuplicates { kAlwaysAdd, kAddIfNotFound }; | |
2535 | |
2536 // If |maybe_array| is not a WeakFixedArray, a fresh one will be allocated. | 2536 // If |maybe_array| is not a WeakFixedArray, a fresh one will be allocated. |
2537 static Handle<WeakFixedArray> Add( | 2537 // This function does not check if the value exists already, callers must |
2538 Handle<Object> maybe_array, Handle<HeapObject> value, | 2538 // ensure this themselves if necessary. |
2539 SearchForDuplicates search_for_duplicates = kAlwaysAdd, | 2539 static Handle<WeakFixedArray> Add(Handle<Object> maybe_array, |
2540 bool* was_present = NULL); | 2540 Handle<HeapObject> value, |
| 2541 int* assigned_index = NULL); |
2541 | 2542 |
2542 // Returns true if an entry was found and removed. | 2543 // Returns true if an entry was found and removed. |
2543 bool Remove(Handle<HeapObject> value); | 2544 bool Remove(Handle<HeapObject> value); |
2544 | 2545 |
| 2546 class NullCallback { |
| 2547 public: |
| 2548 static void Callback(Object* value, int old_index, int new_index) {} |
| 2549 }; |
| 2550 |
| 2551 template <class CompactionCallback> |
2545 void Compact(); | 2552 void Compact(); |
2546 | 2553 |
2547 inline Object* Get(int index) const; | 2554 inline Object* Get(int index) const; |
2548 inline void Clear(int index); | 2555 inline void Clear(int index); |
2549 inline int Length() const; | 2556 inline int Length() const; |
2550 | 2557 |
2551 inline bool IsEmptySlot(int index) const; | 2558 inline bool IsEmptySlot(int index) const; |
2552 static Object* Empty() { return Smi::FromInt(0); } | 2559 static Object* Empty() { return Smi::FromInt(0); } |
2553 | 2560 |
2554 DECLARE_CAST(WeakFixedArray) | 2561 DECLARE_CAST(WeakFixedArray) |
(...skipping 2906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5461 // Don't call set_raw_transitions() directly to overwrite transitions, use | 5468 // Don't call set_raw_transitions() directly to overwrite transitions, use |
5462 // the TransitionArray::ReplaceTransitions() wrapper instead! | 5469 // the TransitionArray::ReplaceTransitions() wrapper instead! |
5463 DECL_ACCESSORS(raw_transitions, Object) | 5470 DECL_ACCESSORS(raw_transitions, Object) |
5464 // [prototype_info]: Per-prototype metadata. Aliased with transitions | 5471 // [prototype_info]: Per-prototype metadata. Aliased with transitions |
5465 // (which prototype maps don't have). | 5472 // (which prototype maps don't have). |
5466 DECL_ACCESSORS(prototype_info, Object) | 5473 DECL_ACCESSORS(prototype_info, Object) |
5467 // PrototypeInfo is created lazily using this helper (which installs it on | 5474 // PrototypeInfo is created lazily using this helper (which installs it on |
5468 // the given prototype's map). | 5475 // the given prototype's map). |
5469 static Handle<PrototypeInfo> GetOrCreatePrototypeInfo( | 5476 static Handle<PrototypeInfo> GetOrCreatePrototypeInfo( |
5470 Handle<JSObject> prototype, Isolate* isolate); | 5477 Handle<JSObject> prototype, Isolate* isolate); |
| 5478 static Handle<PrototypeInfo> GetOrCreatePrototypeInfo( |
| 5479 Handle<Map> prototype_map, Isolate* isolate); |
5471 | 5480 |
5472 // [prototype chain validity cell]: Associated with a prototype object, | 5481 // [prototype chain validity cell]: Associated with a prototype object, |
5473 // stored in that object's map's PrototypeInfo, indicates that prototype | 5482 // stored in that object's map's PrototypeInfo, indicates that prototype |
5474 // chains through this object are currently valid. The cell will be | 5483 // chains through this object are currently valid. The cell will be |
5475 // invalidated and replaced when the prototype chain changes. | 5484 // invalidated and replaced when the prototype chain changes. |
5476 static Handle<Cell> GetOrCreatePrototypeChainValidityCell(Handle<Map> map, | 5485 static Handle<Cell> GetOrCreatePrototypeChainValidityCell(Handle<Map> map, |
5477 Isolate* isolate); | 5486 Isolate* isolate); |
5478 static const int kPrototypeChainValid = 0; | 5487 static const int kPrototypeChainValid = 0; |
5479 static const int kPrototypeChainInvalid = 1; | 5488 static const int kPrototypeChainInvalid = 1; |
5480 | 5489 |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6030 static const int kSize = kValueOffset + kPointerSize; | 6039 static const int kSize = kValueOffset + kPointerSize; |
6031 | 6040 |
6032 private: | 6041 private: |
6033 DISALLOW_IMPLICIT_CONSTRUCTORS(Box); | 6042 DISALLOW_IMPLICIT_CONSTRUCTORS(Box); |
6034 }; | 6043 }; |
6035 | 6044 |
6036 | 6045 |
6037 // Container for metadata stored on each prototype map. | 6046 // Container for metadata stored on each prototype map. |
6038 class PrototypeInfo : public Struct { | 6047 class PrototypeInfo : public Struct { |
6039 public: | 6048 public: |
| 6049 static const int UNREGISTERED = -1; |
| 6050 |
6040 // [prototype_users]: WeakFixedArray containing maps using this prototype, | 6051 // [prototype_users]: WeakFixedArray containing maps using this prototype, |
6041 // or Smi(0) if uninitialized. | 6052 // or Smi(0) if uninitialized. |
6042 DECL_ACCESSORS(prototype_users, Object) | 6053 DECL_ACCESSORS(prototype_users, Object) |
| 6054 // [registry_slot]: Slot in prototype's user registry where this user |
| 6055 // is stored. Returns UNREGISTERED if this prototype has not been registered. |
| 6056 inline int registry_slot() const; |
| 6057 inline void set_registry_slot(int slot); |
6043 // [validity_cell]: Cell containing the validity bit for prototype chains | 6058 // [validity_cell]: Cell containing the validity bit for prototype chains |
6044 // going through this object, or Smi(0) if uninitialized. | 6059 // going through this object, or Smi(0) if uninitialized. |
6045 DECL_ACCESSORS(validity_cell, Object) | 6060 DECL_ACCESSORS(validity_cell, Object) |
6046 // [constructor_name]: User-friendly name of the original constructor. | 6061 // [constructor_name]: User-friendly name of the original constructor. |
6047 DECL_ACCESSORS(constructor_name, Object) | 6062 DECL_ACCESSORS(constructor_name, Object) |
6048 | 6063 |
6049 DECLARE_CAST(PrototypeInfo) | 6064 DECLARE_CAST(PrototypeInfo) |
6050 | 6065 |
6051 // Dispatched behavior. | 6066 // Dispatched behavior. |
6052 DECLARE_PRINTER(PrototypeInfo) | 6067 DECLARE_PRINTER(PrototypeInfo) |
6053 DECLARE_VERIFIER(PrototypeInfo) | 6068 DECLARE_VERIFIER(PrototypeInfo) |
6054 | 6069 |
6055 static const int kPrototypeUsersOffset = HeapObject::kHeaderSize; | 6070 static const int kPrototypeUsersOffset = HeapObject::kHeaderSize; |
6056 static const int kValidityCellOffset = kPrototypeUsersOffset + kPointerSize; | 6071 static const int kRegistrySlotOffset = kPrototypeUsersOffset + kPointerSize; |
| 6072 static const int kValidityCellOffset = kRegistrySlotOffset + kPointerSize; |
6057 static const int kConstructorNameOffset = kValidityCellOffset + kPointerSize; | 6073 static const int kConstructorNameOffset = kValidityCellOffset + kPointerSize; |
6058 static const int kSize = kConstructorNameOffset + kPointerSize; | 6074 static const int kSize = kConstructorNameOffset + kPointerSize; |
6059 | 6075 |
6060 private: | 6076 private: |
6061 DISALLOW_IMPLICIT_CONSTRUCTORS(PrototypeInfo); | 6077 DISALLOW_IMPLICIT_CONSTRUCTORS(PrototypeInfo); |
6062 }; | 6078 }; |
6063 | 6079 |
6064 | 6080 |
6065 // Script describes a script which has been added to the VM. | 6081 // Script describes a script which has been added to the VM. |
6066 class Script: public Struct { | 6082 class Script: public Struct { |
(...skipping 4478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10545 } else { | 10561 } else { |
10546 value &= ~(1 << bit_position); | 10562 value &= ~(1 << bit_position); |
10547 } | 10563 } |
10548 return value; | 10564 return value; |
10549 } | 10565 } |
10550 }; | 10566 }; |
10551 | 10567 |
10552 } } // namespace v8::internal | 10568 } } // namespace v8::internal |
10553 | 10569 |
10554 #endif // V8_OBJECTS_H_ | 10570 #endif // V8_OBJECTS_H_ |
OLD | NEW |