diff options
| author | Ben Murdoch <benm@google.com> | 2012-01-20 14:57:15 +0000 |
|---|---|---|
| committer | Ben Murdoch <benm@google.com> | 2012-01-20 14:57:15 +0000 |
| commit | 2b4ba1175df6a5a6b9b5cda034189197bf6565ec (patch) | |
| tree | 6a4c479deebb22e68c5d7b915609593adee56a92 /src/objects.h | |
| parent | 35e02d4f35686cd3d202dab09aa0fdf24651afed (diff) | |
| download | android_external_v8-2b4ba1175df6a5a6b9b5cda034189197bf6565ec.tar.gz android_external_v8-2b4ba1175df6a5a6b9b5cda034189197bf6565ec.tar.bz2 android_external_v8-2b4ba1175df6a5a6b9b5cda034189197bf6565ec.zip | |
Merge V8 at r10446: Roll to 3.6.6.19
Bug: 5688872
Change-Id: Ie6be41e043db4e38abeb6b8d92761d7cc2c294bf
Diffstat (limited to 'src/objects.h')
| -rw-r--r-- | src/objects.h | 107 |
1 files changed, 88 insertions, 19 deletions
diff --git a/src/objects.h b/src/objects.h index d4ee9643..1245ed0c 100644 --- a/src/objects.h +++ b/src/objects.h @@ -1541,7 +1541,7 @@ class JSObject: public JSReceiver { bool HasFastArgumentsElements(); bool HasDictionaryArgumentsElements(); inline bool AllowsSetElementsLength(); - inline NumberDictionary* element_dictionary(); // Gets slow elements. + inline SeededNumberDictionary* element_dictionary(); // Gets slow elements. // Requires: HasFastElements(). MUST_USE_RESULT inline MaybeObject* EnsureWritableFastElements(); @@ -1902,8 +1902,6 @@ class JSObject: public JSReceiver { PropertyNormalizationMode mode, int expected_additional_properties); - // Convert and update the elements backing store to be a NumberDictionary - // dictionary. Returns the backing after conversion. MUST_USE_RESULT MaybeObject* NormalizeElements(); MUST_USE_RESULT MaybeObject* UpdateMapCodeCache(String* name, Code* code); @@ -2221,7 +2219,7 @@ class FixedDoubleArray: public FixedArrayBase { public: inline void Initialize(FixedArray* from); inline void Initialize(FixedDoubleArray* from); - inline void Initialize(NumberDictionary* from); + inline void Initialize(SeededNumberDictionary* from); // Setter and getter for elements. inline double get_scalar(int index); @@ -2514,9 +2512,42 @@ class DescriptorArray: public FixedArray { // beginning of the backing storage that can be used for non-element // information by subclasses. +template<typename Key> +class BaseShape { + public: + static const bool UsesSeed = false; + static uint32_t Hash(Key key) { return 0; } + static uint32_t SeededHash(Key key, uint32_t seed) { + ASSERT(UsesSeed); + return Hash(key); + } + static uint32_t HashForObject(Key key, Object* object) { return 0; } + static uint32_t SeededHashForObject(Key key, uint32_t seed, Object* object) { + // Won't be called if UsesSeed isn't overridden by child class. + return HashForObject(key, object); + } +}; + template<typename Shape, typename Key> class HashTable: public FixedArray { public: + // Wrapper methods + inline uint32_t Hash(Key key) { + if (Shape::UsesSeed) { + return Shape::SeededHash(key, GetHeap()->HashSeed()); + } else { + return Shape::Hash(key); + } + } + + inline uint32_t HashForObject(Key key, Object* object) { + if (Shape::UsesSeed) { + return Shape::SeededHashForObject(key, GetHeap()->HashSeed(), object); + } else { + return Shape::HashForObject(key, object); + } + } + // Returns the number of elements in the hash table. int NumberOfElements() { return Smi::cast(get(kNumberOfElementsIndex))->value(); @@ -2658,7 +2689,6 @@ class HashTable: public FixedArray { }; - // HashTableKey is an abstract superclass for virtual key behavior. class HashTableKey { public: @@ -2675,7 +2705,8 @@ class HashTableKey { virtual ~HashTableKey() {} }; -class SymbolTableShape { + +class SymbolTableShape : public BaseShape<HashTableKey*> { public: static inline bool IsMatch(HashTableKey* key, Object* value) { return key->IsMatch(value); @@ -2734,7 +2765,7 @@ class SymbolTable: public HashTable<SymbolTableShape, HashTableKey*> { }; -class MapCacheShape { +class MapCacheShape : public BaseShape<HashTableKey*> { public: static inline bool IsMatch(HashTableKey* key, Object* value) { return key->IsMatch(value); @@ -2890,7 +2921,7 @@ class Dictionary: public HashTable<Shape, Key> { }; -class StringDictionaryShape { +class StringDictionaryShape : public BaseShape<String*> { public: static inline bool IsMatch(String* key, Object* other); static inline uint32_t Hash(String* key); @@ -2923,23 +2954,42 @@ class StringDictionary: public Dictionary<StringDictionaryShape, String*> { }; -class NumberDictionaryShape { +class NumberDictionaryShape : public BaseShape<uint32_t> { public: static inline bool IsMatch(uint32_t key, Object* other); - static inline uint32_t Hash(uint32_t key); - static inline uint32_t HashForObject(uint32_t key, Object* object); MUST_USE_RESULT static inline MaybeObject* AsObject(uint32_t key); - static const int kPrefixSize = 2; static const int kEntrySize = 3; static const bool kIsEnumerable = false; }; -class NumberDictionary: public Dictionary<NumberDictionaryShape, uint32_t> { +class SeededNumberDictionaryShape : public NumberDictionaryShape { public: - static NumberDictionary* cast(Object* obj) { + static const bool UsesSeed = true; + static const int kPrefixSize = 2; + + static inline uint32_t SeededHash(uint32_t key, uint32_t seed); + static inline uint32_t SeededHashForObject(uint32_t key, + uint32_t seed, + Object* object); +}; + + +class UnseededNumberDictionaryShape : public NumberDictionaryShape { + public: + static const int kPrefixSize = 0; + + static inline uint32_t Hash(uint32_t key); + static inline uint32_t HashForObject(uint32_t key, Object* object); +}; + + +class SeededNumberDictionary + : public Dictionary<SeededNumberDictionaryShape, uint32_t> { + public: + static SeededNumberDictionary* cast(Object* obj) { ASSERT(obj->IsDictionary()); - return reinterpret_cast<NumberDictionary*>(obj); + return reinterpret_cast<SeededNumberDictionary*>(obj); } // Type specific at put (default NONE attributes is used when adding). @@ -2978,7 +3028,24 @@ class NumberDictionary: public Dictionary<NumberDictionaryShape, uint32_t> { }; -class ObjectHashTableShape { +class UnseededNumberDictionary + : public Dictionary<UnseededNumberDictionaryShape, uint32_t> { + public: + static UnseededNumberDictionary* cast(Object* obj) { + ASSERT(obj->IsDictionary()); + return reinterpret_cast<UnseededNumberDictionary*>(obj); + } + + // Type specific at put (default NONE attributes is used when adding). + MUST_USE_RESULT MaybeObject* AtNumberPut(uint32_t key, Object* value); + MUST_USE_RESULT MaybeObject* AddNumberEntry(uint32_t key, Object* value); + + // Set an existing entry or add a new one if needed. + MUST_USE_RESULT MaybeObject* Set(uint32_t key, Object* value); +}; + + +class ObjectHashTableShape : public BaseShape<Object*> { public: static inline bool IsMatch(JSObject* key, Object* other); static inline uint32_t Hash(JSObject* key); @@ -3468,7 +3535,8 @@ class DeoptimizationInputData: public FixedArray { static const int kAstIdOffset = 0; static const int kTranslationIndexOffset = 1; static const int kArgumentsStackHeightOffset = 2; - static const int kDeoptEntrySize = 3; + static const int kPcOffset = 3; + static const int kDeoptEntrySize = 4; // Simple element accessors. #define DEFINE_ELEMENT_ACCESSORS(name, type) \ @@ -3504,6 +3572,7 @@ class DeoptimizationInputData: public FixedArray { DEFINE_ENTRY_ACCESSORS(AstId, Smi) DEFINE_ENTRY_ACCESSORS(TranslationIndex, Smi) DEFINE_ENTRY_ACCESSORS(ArgumentsStackHeight, Smi) + DEFINE_ENTRY_ACCESSORS(Pc, Smi) #undef DEFINE_ENTRY_ACCESSORS @@ -5543,7 +5612,7 @@ class JSRegExp: public JSObject { }; -class CompilationCacheShape { +class CompilationCacheShape : public BaseShape<HashTableKey*> { public: static inline bool IsMatch(HashTableKey* key, Object* value) { return key->IsMatch(value); @@ -5643,7 +5712,7 @@ class CodeCache: public Struct { }; -class CodeCacheHashTableShape { +class CodeCacheHashTableShape : public BaseShape<HashTableKey*> { public: static inline bool IsMatch(HashTableKey* key, Object* value) { return key->IsMatch(value); |
