| Index: src/objects.h
|
| ===================================================================
|
| --- src/objects.h (revision 10379)
|
| +++ src/objects.h (working copy)
|
| @@ -2514,9 +2514,44 @@
|
| // 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 +2693,6 @@
|
| };
|
|
|
|
|
| -
|
| // HashTableKey is an abstract superclass for virtual key behavior.
|
| class HashTableKey {
|
| public:
|
| @@ -2675,7 +2709,8 @@
|
| virtual ~HashTableKey() {}
|
| };
|
|
|
| -class SymbolTableShape {
|
| +
|
| +class SymbolTableShape : public BaseShape<HashTableKey*> {
|
| public:
|
| static inline bool IsMatch(HashTableKey* key, Object* value) {
|
| return key->IsMatch(value);
|
| @@ -2734,7 +2769,7 @@
|
| };
|
|
|
|
|
| -class MapCacheShape {
|
| +class MapCacheShape : public BaseShape<HashTableKey*> {
|
| public:
|
| static inline bool IsMatch(HashTableKey* key, Object* value) {
|
| return key->IsMatch(value);
|
| @@ -2890,7 +2925,7 @@
|
| };
|
|
|
|
|
| -class StringDictionaryShape {
|
| +class StringDictionaryShape : public BaseShape<String*> {
|
| public:
|
| static inline bool IsMatch(String* key, Object* other);
|
| static inline uint32_t Hash(String* key);
|
| @@ -2923,11 +2958,17 @@
|
| };
|
|
|
|
|
| -class NumberDictionaryShape {
|
| +class NumberDictionaryShape : public BaseShape<uint32_t> {
|
| public:
|
| + static const bool UsesSeed = true;
|
| +
|
| static inline bool IsMatch(uint32_t key, Object* other);
|
| static inline uint32_t Hash(uint32_t key);
|
| + static inline uint32_t SeededHash(uint32_t key, uint32_t seed);
|
| static inline uint32_t HashForObject(uint32_t key, Object* object);
|
| + static inline uint32_t SeededHashForObject(uint32_t key,
|
| + uint32_t seed,
|
| + Object* object);
|
| MUST_USE_RESULT static inline MaybeObject* AsObject(uint32_t key);
|
| static const int kPrefixSize = 2;
|
| static const int kEntrySize = 3;
|
| @@ -2978,7 +3019,7 @@
|
| };
|
|
|
|
|
| -class ObjectHashTableShape {
|
| +class ObjectHashTableShape : public BaseShape<Object*> {
|
| public:
|
| static inline bool IsMatch(JSObject* key, Object* other);
|
| static inline uint32_t Hash(JSObject* key);
|
| @@ -5543,7 +5584,7 @@
|
| };
|
|
|
|
|
| -class CompilationCacheShape {
|
| +class CompilationCacheShape : public BaseShape<HashTableKey*> {
|
| public:
|
| static inline bool IsMatch(HashTableKey* key, Object* value) {
|
| return key->IsMatch(value);
|
| @@ -5643,7 +5684,7 @@
|
| };
|
|
|
|
|
| -class CodeCacheHashTableShape {
|
| +class CodeCacheHashTableShape : public BaseShape<HashTableKey*> {
|
| public:
|
| static inline bool IsMatch(HashTableKey* key, Object* value) {
|
| return key->IsMatch(value);
|
|
|