Chromium Code Reviews| Index: src/objects.h |
| diff --git a/src/objects.h b/src/objects.h |
| index 698efbc2e50e2926edd4accf2b13ded72bd3ca89..b3ad17b1e71f0214ff8a10d10bf7d41faae4cf2b 100644 |
| --- a/src/objects.h |
| +++ b/src/objects.h |
| @@ -1430,11 +1430,21 @@ class JSReceiver: public HeapObject { |
| MUST_USE_RESULT MaybeObject* SetPrototype(Object* value, |
| bool skip_hidden_prototypes); |
| + // Indicates whether a (hidden) property should be created upon lookup. |
| + enum CreationFlag { ALLOW_CREATION, OMIT_CREATION }; |
|
Michael Starzinger
2011/09/09 09:40:00
The use of this flag is ambiguous, it is used to i
rossberg
2011/09/12 10:50:08
As discussed offline, moved the enum type out of J
|
| + |
| + // Retrieves a permanent object identity hash code. The undefined value might |
| + // be returned in case no has been created yet and OMIT_CREATION was used. |
| + inline MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag); |
| + |
| // Lookup a property. If found, the result is valid and has |
| // detailed information. |
| void LocalLookup(String* name, LookupResult* result); |
| void Lookup(String* name, LookupResult* result); |
| + protected: |
| + Smi* GenerateIdentityHash(); |
| + |
| private: |
| PropertyAttributes GetPropertyAttribute(JSReceiver* receiver, |
| LookupResult* result, |
| @@ -1666,22 +1676,14 @@ class JSObject: public JSReceiver { |
| MUST_USE_RESULT inline MaybeObject* SetHiddenPropertiesObject( |
| Object* hidden_obj); |
| - // Indicates whether the hidden properties object should be created. |
| - enum HiddenPropertiesFlag { ALLOW_CREATION, OMIT_CREATION }; |
| - |
| // Retrieves the hidden properties object. |
| // |
| // The undefined value might be returned in case no hidden properties object |
| // is present and creation was omitted. |
| inline bool HasHiddenProperties(); |
| - MUST_USE_RESULT MaybeObject* GetHiddenProperties(HiddenPropertiesFlag flag); |
| + MUST_USE_RESULT MaybeObject* GetHiddenProperties(CreationFlag flag); |
| - // Retrieves a permanent object identity hash code. |
| - // |
| - // The identity hash is stored as a hidden property. The undefined value might |
| - // be returned in case no hidden properties object is present and creation was |
| - // omitted. |
| - MUST_USE_RESULT MaybeObject* GetIdentityHash(HiddenPropertiesFlag flag); |
| + MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag); |
| MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode); |
| MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode); |
| @@ -2965,10 +2967,10 @@ class NumberDictionary: public Dictionary<NumberDictionaryShape, uint32_t> { |
| class ObjectHashTableShape { |
| public: |
| - static inline bool IsMatch(JSObject* key, Object* other); |
| - static inline uint32_t Hash(JSObject* key); |
| - static inline uint32_t HashForObject(JSObject* key, Object* object); |
| - MUST_USE_RESULT static inline MaybeObject* AsObject(JSObject* key); |
| + static inline bool IsMatch(JSReceiver* key, Object* other); |
| + static inline uint32_t Hash(JSReceiver* key); |
| + static inline uint32_t HashForObject(JSReceiver* key, Object* object); |
| + MUST_USE_RESULT static inline MaybeObject* AsObject(JSReceiver* key); |
| static const int kPrefixSize = 0; |
| static const int kEntrySize = 2; |
| }; |
| @@ -2976,7 +2978,7 @@ class ObjectHashTableShape { |
| // ObjectHashTable maps keys that are JavaScript objects to object values by |
| // using the identity hash of the key for hashing purposes. |
| -class ObjectHashTable: public HashTable<ObjectHashTableShape, JSObject*> { |
| +class ObjectHashTable: public HashTable<ObjectHashTableShape, JSReceiver*> { |
| public: |
| static inline ObjectHashTable* cast(Object* obj) { |
| ASSERT(obj->IsHashTable()); |
| @@ -2985,16 +2987,16 @@ class ObjectHashTable: public HashTable<ObjectHashTableShape, JSObject*> { |
| // Looks up the value associated with the given key. The undefined value is |
| // returned in case the key is not present. |
| - Object* Lookup(JSObject* key); |
| + Object* Lookup(JSReceiver* key); |
| // Adds (or overwrites) the value associated with the given key. Mapping a |
| // key to the undefined value causes removal of the whole entry. |
| - MUST_USE_RESULT MaybeObject* Put(JSObject* key, Object* value); |
| + MUST_USE_RESULT MaybeObject* Put(JSReceiver* key, Object* value); |
| private: |
| friend class MarkCompactCollector; |
| - void AddEntry(int entry, JSObject* key, Object* value); |
| + void AddEntry(int entry, JSReceiver* key, Object* value); |
| void RemoveEntry(int entry, Heap* heap); |
| inline void RemoveEntry(int entry); |
| @@ -6598,6 +6600,9 @@ class JSProxy: public JSReceiver { |
| // [handler]: The handler property. |
| DECL_ACCESSORS(handler, Object) |
| + // [hash]: The hash code property (undefined if not initialized yet). |
| + DECL_ACCESSORS(hash, Object) |
| + |
| // Casting. |
| static inline JSProxy* cast(Object* obj); |
| @@ -6642,6 +6647,8 @@ class JSProxy: public JSReceiver { |
| JSReceiver* receiver, |
| uint32_t index); |
| + MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag); |
| + |
| // Turn this into an (empty) JSObject. |
| void Fix(); |
| @@ -6670,7 +6677,8 @@ class JSProxy: public JSReceiver { |
| // size as a virgin JSObject. This is essential for becoming a JSObject |
| // upon freeze. |
| static const int kHandlerOffset = HeapObject::kHeaderSize; |
| - static const int kPaddingOffset = kHandlerOffset + kPointerSize; |
| + static const int kHashOffset = kHandlerOffset + kPointerSize; |
| + static const int kPaddingOffset = kHashOffset + kPointerSize; |
| static const int kSize = JSObject::kHeaderSize; |
| static const int kHeaderSize = kPaddingOffset; |
| static const int kPaddingSize = kSize - kPaddingOffset; |
| @@ -6678,7 +6686,7 @@ class JSProxy: public JSReceiver { |
| STATIC_CHECK(kPaddingSize >= 0); |
| typedef FixedBodyDescriptor<kHandlerOffset, |
| - kHandlerOffset + kPointerSize, |
| + kPaddingOffset, |
| kSize> BodyDescriptor; |
| private: |
| @@ -6709,7 +6717,7 @@ class JSFunctionProxy: public JSProxy { |
| #endif |
| // Layout description. |
| - static const int kCallTrapOffset = kHandlerOffset + kPointerSize; |
| + static const int kCallTrapOffset = JSProxy::kPaddingOffset; |
| static const int kConstructTrapOffset = kCallTrapOffset + kPointerSize; |
| static const int kPaddingOffset = kConstructTrapOffset + kPointerSize; |
| static const int kSize = JSFunction::kSize; |