OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1724 // otherwise returns the value set for the key. | 1724 // otherwise returns the value set for the key. |
1725 Object* GetHiddenProperty(String* key); | 1725 Object* GetHiddenProperty(String* key); |
1726 // Deletes a hidden property. Deleting a non-existing property is | 1726 // Deletes a hidden property. Deleting a non-existing property is |
1727 // considered successful. | 1727 // considered successful. |
1728 void DeleteHiddenProperty(String* key); | 1728 void DeleteHiddenProperty(String* key); |
1729 // Returns true if the object has a property with the hidden symbol as name. | 1729 // Returns true if the object has a property with the hidden symbol as name. |
1730 bool HasHiddenProperties(); | 1730 bool HasHiddenProperties(); |
1731 | 1731 |
1732 static int GetIdentityHash(Handle<JSObject> obj); | 1732 static int GetIdentityHash(Handle<JSObject> obj); |
1733 MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag); | 1733 MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag); |
1734 MUST_USE_RESULT MaybeObject* SetIdentityHash(Object* hash, CreationFlag flag); | 1734 MUST_USE_RESULT MaybeObject* SetIdentityHash(Smi* hash, CreationFlag flag); |
1735 | 1735 |
1736 static Handle<Object> DeleteProperty(Handle<JSObject> obj, | 1736 static Handle<Object> DeleteProperty(Handle<JSObject> obj, |
1737 Handle<String> name); | 1737 Handle<String> name); |
1738 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode); | 1738 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode); |
1739 | 1739 |
1740 static Handle<Object> DeleteElement(Handle<JSObject> obj, uint32_t index); | 1740 static Handle<Object> DeleteElement(Handle<JSObject> obj, uint32_t index); |
1741 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode); | 1741 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode); |
1742 | 1742 |
1743 inline void ValidateElements(); | 1743 inline void ValidateElements(); |
1744 | 1744 |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2228 Object* getter, | 2228 Object* getter, |
2229 Object* setter, | 2229 Object* setter, |
2230 PropertyAttributes attributes); | 2230 PropertyAttributes attributes); |
2231 MUST_USE_RESULT MaybeObject* CreateAccessorPairFor(String* name); | 2231 MUST_USE_RESULT MaybeObject* CreateAccessorPairFor(String* name); |
2232 MUST_USE_RESULT MaybeObject* DefinePropertyAccessor( | 2232 MUST_USE_RESULT MaybeObject* DefinePropertyAccessor( |
2233 String* name, | 2233 String* name, |
2234 Object* getter, | 2234 Object* getter, |
2235 Object* setter, | 2235 Object* setter, |
2236 PropertyAttributes attributes); | 2236 PropertyAttributes attributes); |
2237 | 2237 |
2238 // Returns the hidden properties backing store object, currently | 2238 |
2239 // a StringDictionary, stored on this object. | 2239 enum InitializeHiddenProperties { |
2240 // If no hidden properties object has been put on this object, | 2240 CREATE_NEW_IF_ABSENT, |
2241 // return undefined, unless create_if_absent is true, in which case | 2241 ONLY_RETURN_INLINE_VALUE |
2242 // a new dictionary is created, added to this object, and returned. | 2242 }; |
2243 MUST_USE_RESULT MaybeObject* GetHiddenPropertiesDictionary( | 2243 |
2244 bool create_if_absent); | 2244 // If create_if_absent is true, return the hash table backing store |
2245 // Updates the existing hidden properties dictionary. | 2245 // for hidden properties. If there is no backing store, allocate one. |
2246 MUST_USE_RESULT MaybeObject* SetHiddenPropertiesDictionary( | 2246 // If create_if_absent is false, return the hash table backing store |
2247 StringDictionary* dictionary); | 2247 // or the inline stored identity hash, whatever is found. |
| 2248 MUST_USE_RESULT MaybeObject* GetHiddenPropertiesHashTable( |
| 2249 InitializeHiddenProperties init_option); |
| 2250 // Set the hidden property backing store to either a hash table or |
| 2251 // the inline-stored identity hash. |
| 2252 MUST_USE_RESULT MaybeObject* SetHiddenPropertiesHashTable( |
| 2253 Object* value); |
2248 | 2254 |
2249 DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject); | 2255 DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject); |
2250 }; | 2256 }; |
2251 | 2257 |
2252 | 2258 |
2253 // Common superclass for FixedArrays that allow implementations to share | 2259 // Common superclass for FixedArrays that allow implementations to share |
2254 // common accessors and some code paths. | 2260 // common accessors and some code paths. |
2255 class FixedArrayBase: public HeapObject { | 2261 class FixedArrayBase: public HeapObject { |
2256 public: | 2262 public: |
2257 // [length]: length of the array. | 2263 // [length]: length of the array. |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2740 static uint32_t HashForObject(Key key, Object* object) { return 0; } | 2746 static uint32_t HashForObject(Key key, Object* object) { return 0; } |
2741 static uint32_t SeededHashForObject(Key key, uint32_t seed, Object* object) { | 2747 static uint32_t SeededHashForObject(Key key, uint32_t seed, Object* object) { |
2742 ASSERT(UsesSeed); | 2748 ASSERT(UsesSeed); |
2743 return HashForObject(key, object); | 2749 return HashForObject(key, object); |
2744 } | 2750 } |
2745 }; | 2751 }; |
2746 | 2752 |
2747 template<typename Shape, typename Key> | 2753 template<typename Shape, typename Key> |
2748 class HashTable: public FixedArray { | 2754 class HashTable: public FixedArray { |
2749 public: | 2755 public: |
| 2756 enum MinimumCapacity { |
| 2757 USE_DEFAULT_MINIMUM_CAPACITY, |
| 2758 USE_CUSTOM_MINIMUM_CAPACITY |
| 2759 }; |
| 2760 |
2750 // Wrapper methods | 2761 // Wrapper methods |
2751 inline uint32_t Hash(Key key) { | 2762 inline uint32_t Hash(Key key) { |
2752 if (Shape::UsesSeed) { | 2763 if (Shape::UsesSeed) { |
2753 return Shape::SeededHash(key, | 2764 return Shape::SeededHash(key, |
2754 GetHeap()->HashSeed()); | 2765 GetHeap()->HashSeed()); |
2755 } else { | 2766 } else { |
2756 return Shape::Hash(key); | 2767 return Shape::Hash(key); |
2757 } | 2768 } |
2758 } | 2769 } |
2759 | 2770 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2792 SetNumberOfDeletedElements(NumberOfDeletedElements() + 1); | 2803 SetNumberOfDeletedElements(NumberOfDeletedElements() + 1); |
2793 } | 2804 } |
2794 void ElementsRemoved(int n) { | 2805 void ElementsRemoved(int n) { |
2795 SetNumberOfElements(NumberOfElements() - n); | 2806 SetNumberOfElements(NumberOfElements() - n); |
2796 SetNumberOfDeletedElements(NumberOfDeletedElements() + n); | 2807 SetNumberOfDeletedElements(NumberOfDeletedElements() + n); |
2797 } | 2808 } |
2798 | 2809 |
2799 // Returns a new HashTable object. Might return Failure. | 2810 // Returns a new HashTable object. Might return Failure. |
2800 MUST_USE_RESULT static MaybeObject* Allocate( | 2811 MUST_USE_RESULT static MaybeObject* Allocate( |
2801 int at_least_space_for, | 2812 int at_least_space_for, |
| 2813 MinimumCapacity capacity_option = USE_DEFAULT_MINIMUM_CAPACITY, |
2802 PretenureFlag pretenure = NOT_TENURED); | 2814 PretenureFlag pretenure = NOT_TENURED); |
2803 | 2815 |
2804 // Computes the required capacity for a table holding the given | 2816 // Computes the required capacity for a table holding the given |
2805 // number of elements. May be more than HashTable::kMaxCapacity. | 2817 // number of elements. May be more than HashTable::kMaxCapacity. |
2806 static int ComputeCapacity(int at_least_space_for); | 2818 static int ComputeCapacity(int at_least_space_for); |
2807 | 2819 |
2808 // Returns the key at entry. | 2820 // Returns the key at entry. |
2809 Object* KeyAt(int entry) { return get(EntryToIndex(entry)); } | 2821 Object* KeyAt(int entry) { return get(EntryToIndex(entry)); } |
2810 | 2822 |
2811 // Tells whether k is a real key. The hole and undefined are not allowed | 2823 // Tells whether k is a real key. The hole and undefined are not allowed |
(...skipping 6098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8910 } else { | 8922 } else { |
8911 value &= ~(1 << bit_position); | 8923 value &= ~(1 << bit_position); |
8912 } | 8924 } |
8913 return value; | 8925 return value; |
8914 } | 8926 } |
8915 }; | 8927 }; |
8916 | 8928 |
8917 } } // namespace v8::internal | 8929 } } // namespace v8::internal |
8918 | 8930 |
8919 #endif // V8_OBJECTS_H_ | 8931 #endif // V8_OBJECTS_H_ |
OLD | NEW |