Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2747 MUST_USE_RESULT virtual MaybeObject* AsObject() = 0; | 2747 MUST_USE_RESULT virtual MaybeObject* AsObject() = 0; |
| 2748 // Required. | 2748 // Required. |
| 2749 virtual ~HashTableKey() {} | 2749 virtual ~HashTableKey() {} |
| 2750 }; | 2750 }; |
| 2751 | 2751 |
| 2752 class SymbolTableShape { | 2752 class SymbolTableShape { |
| 2753 public: | 2753 public: |
| 2754 static inline bool IsMatch(HashTableKey* key, Object* value) { | 2754 static inline bool IsMatch(HashTableKey* key, Object* value) { |
| 2755 return key->IsMatch(value); | 2755 return key->IsMatch(value); |
| 2756 } | 2756 } |
| 2757 static inline uint32_t Hash(HashTableKey* key) { | 2757 static inline uint32_t Hash(HashTableKey* key, uint32_t) { |
| 2758 return key->Hash(); | 2758 return key->Hash(); |
| 2759 } | 2759 } |
| 2760 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { | 2760 static inline uint32_t HashForObject(HashTableKey* key, uint32_t, |
|
Erik Corry
2012/01/09 23:52:48
Formatting.
| |
| 2761 Object* object) { | |
| 2761 return key->HashForObject(object); | 2762 return key->HashForObject(object); |
| 2762 } | 2763 } |
| 2763 MUST_USE_RESULT static inline MaybeObject* AsObject(HashTableKey* key) { | 2764 MUST_USE_RESULT static inline MaybeObject* AsObject(HashTableKey* key) { |
| 2764 return key->AsObject(); | 2765 return key->AsObject(); |
| 2765 } | 2766 } |
| 2766 | 2767 |
| 2767 static const int kPrefixSize = 0; | 2768 static const int kPrefixSize = 0; |
| 2768 static const int kEntrySize = 1; | 2769 static const int kEntrySize = 1; |
| 2769 }; | 2770 }; |
| 2770 | 2771 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2806 | 2807 |
| 2807 DISALLOW_IMPLICIT_CONSTRUCTORS(SymbolTable); | 2808 DISALLOW_IMPLICIT_CONSTRUCTORS(SymbolTable); |
| 2808 }; | 2809 }; |
| 2809 | 2810 |
| 2810 | 2811 |
| 2811 class MapCacheShape { | 2812 class MapCacheShape { |
| 2812 public: | 2813 public: |
| 2813 static inline bool IsMatch(HashTableKey* key, Object* value) { | 2814 static inline bool IsMatch(HashTableKey* key, Object* value) { |
| 2814 return key->IsMatch(value); | 2815 return key->IsMatch(value); |
| 2815 } | 2816 } |
| 2816 static inline uint32_t Hash(HashTableKey* key) { | 2817 static inline uint32_t Hash(HashTableKey* key, uint32_t) { |
| 2817 return key->Hash(); | 2818 return key->Hash(); |
| 2818 } | 2819 } |
| 2819 | 2820 |
| 2820 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { | 2821 static inline uint32_t HashForObject(HashTableKey* key, uint32_t, |
|
Erik Corry
2012/01/09 23:52:48
Formatting.
| |
| 2822 Object* object) { | |
| 2821 return key->HashForObject(object); | 2823 return key->HashForObject(object); |
| 2822 } | 2824 } |
| 2823 | 2825 |
| 2824 MUST_USE_RESULT static inline MaybeObject* AsObject(HashTableKey* key) { | 2826 MUST_USE_RESULT static inline MaybeObject* AsObject(HashTableKey* key) { |
| 2825 return key->AsObject(); | 2827 return key->AsObject(); |
| 2826 } | 2828 } |
| 2827 | 2829 |
| 2828 static const int kPrefixSize = 0; | 2830 static const int kPrefixSize = 0; |
| 2829 static const int kEntrySize = 2; | 2831 static const int kEntrySize = 2; |
| 2830 }; | 2832 }; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2960 MUST_USE_RESULT MaybeObject* GenerateNewEnumerationIndices(); | 2962 MUST_USE_RESULT MaybeObject* GenerateNewEnumerationIndices(); |
| 2961 static const int kMaxNumberKeyIndex = | 2963 static const int kMaxNumberKeyIndex = |
| 2962 HashTable<Shape, Key>::kPrefixStartIndex; | 2964 HashTable<Shape, Key>::kPrefixStartIndex; |
| 2963 static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1; | 2965 static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1; |
| 2964 }; | 2966 }; |
| 2965 | 2967 |
| 2966 | 2968 |
| 2967 class StringDictionaryShape { | 2969 class StringDictionaryShape { |
| 2968 public: | 2970 public: |
| 2969 static inline bool IsMatch(String* key, Object* other); | 2971 static inline bool IsMatch(String* key, Object* other); |
| 2970 static inline uint32_t Hash(String* key); | 2972 static inline uint32_t Hash(String* key, uint32_t); |
|
Erik Corry
2012/01/09 23:52:48
Parameter should have a name.
I'm unhappy that we
| |
| 2971 static inline uint32_t HashForObject(String* key, Object* object); | 2973 static inline uint32_t HashForObject(String* key, uint32_t, |
|
Erik Corry
2012/01/09 23:52:48
Formatting, and the parameter should have a name.
| |
| 2974 Object* object); | |
| 2972 MUST_USE_RESULT static inline MaybeObject* AsObject(String* key); | 2975 MUST_USE_RESULT static inline MaybeObject* AsObject(String* key); |
| 2973 static const int kPrefixSize = 2; | 2976 static const int kPrefixSize = 2; |
| 2974 static const int kEntrySize = 3; | 2977 static const int kEntrySize = 3; |
| 2975 static const bool kIsEnumerable = true; | 2978 static const bool kIsEnumerable = true; |
| 2976 }; | 2979 }; |
| 2977 | 2980 |
| 2978 | 2981 |
| 2979 class StringDictionary: public Dictionary<StringDictionaryShape, String*> { | 2982 class StringDictionary: public Dictionary<StringDictionaryShape, String*> { |
| 2980 public: | 2983 public: |
| 2981 static inline StringDictionary* cast(Object* obj) { | 2984 static inline StringDictionary* cast(Object* obj) { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 2993 | 2996 |
| 2994 // Find entry for key, otherwise return kNotFound. Optimized version of | 2997 // Find entry for key, otherwise return kNotFound. Optimized version of |
| 2995 // HashTable::FindEntry. | 2998 // HashTable::FindEntry. |
| 2996 int FindEntry(String* key); | 2999 int FindEntry(String* key); |
| 2997 }; | 3000 }; |
| 2998 | 3001 |
| 2999 | 3002 |
| 3000 class NumberDictionaryShape { | 3003 class NumberDictionaryShape { |
| 3001 public: | 3004 public: |
| 3002 static inline bool IsMatch(uint32_t key, Object* other); | 3005 static inline bool IsMatch(uint32_t key, Object* other); |
| 3003 static inline uint32_t Hash(uint32_t key); | 3006 static inline uint32_t Hash(uint32_t key, uint32_t seed); |
| 3004 static inline uint32_t HashForObject(uint32_t key, Object* object); | 3007 static inline uint32_t HashForObject(uint32_t key, uint32_t seed, |
|
Erik Corry
2012/01/09 23:52:48
Formatting.
| |
| 3008 Object* object); | |
| 3005 MUST_USE_RESULT static inline MaybeObject* AsObject(uint32_t key); | 3009 MUST_USE_RESULT static inline MaybeObject* AsObject(uint32_t key); |
| 3006 static const int kPrefixSize = 2; | 3010 static const int kPrefixSize = 2; |
| 3007 static const int kEntrySize = 3; | 3011 static const int kEntrySize = 3; |
| 3008 static const bool kIsEnumerable = false; | 3012 static const bool kIsEnumerable = false; |
| 3009 }; | 3013 }; |
| 3010 | 3014 |
| 3011 | 3015 |
| 3012 class NumberDictionary: public Dictionary<NumberDictionaryShape, uint32_t> { | 3016 class NumberDictionary: public Dictionary<NumberDictionaryShape, uint32_t> { |
| 3013 public: | 3017 public: |
| 3014 static NumberDictionary* cast(Object* obj) { | 3018 static NumberDictionary* cast(Object* obj) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3053 static const int kRequiresSlowElementsMask = 1; | 3057 static const int kRequiresSlowElementsMask = 1; |
| 3054 static const int kRequiresSlowElementsTagSize = 1; | 3058 static const int kRequiresSlowElementsTagSize = 1; |
| 3055 static const uint32_t kRequiresSlowElementsLimit = (1 << 29) - 1; | 3059 static const uint32_t kRequiresSlowElementsLimit = (1 << 29) - 1; |
| 3056 }; | 3060 }; |
| 3057 | 3061 |
| 3058 | 3062 |
| 3059 template <int entrysize> | 3063 template <int entrysize> |
| 3060 class ObjectHashTableShape { | 3064 class ObjectHashTableShape { |
| 3061 public: | 3065 public: |
| 3062 static inline bool IsMatch(Object* key, Object* other); | 3066 static inline bool IsMatch(Object* key, Object* other); |
| 3063 static inline uint32_t Hash(Object* key); | 3067 static inline uint32_t Hash(Object* key, uint32_t); |
|
Erik Corry
2012/01/09 23:52:48
Names for arguments x2
| |
| 3064 static inline uint32_t HashForObject(Object* key, Object* object); | 3068 static inline uint32_t HashForObject(Object* key, uint32_t, Object* object); |
| 3065 MUST_USE_RESULT static inline MaybeObject* AsObject(Object* key); | 3069 MUST_USE_RESULT static inline MaybeObject* AsObject(Object* key); |
| 3066 static const int kPrefixSize = 0; | 3070 static const int kPrefixSize = 0; |
| 3067 static const int kEntrySize = entrysize; | 3071 static const int kEntrySize = entrysize; |
| 3068 }; | 3072 }; |
| 3069 | 3073 |
| 3070 | 3074 |
| 3071 // ObjectHashSet holds keys that are arbitrary objects by using the identity | 3075 // ObjectHashSet holds keys that are arbitrary objects by using the identity |
| 3072 // hash of the key for hashing purposes. | 3076 // hash of the key for hashing purposes. |
| 3073 class ObjectHashSet: public HashTable<ObjectHashTableShape<1>, Object*> { | 3077 class ObjectHashSet: public HashTable<ObjectHashTableShape<1>, Object*> { |
| 3074 public: | 3078 public: |
| (...skipping 2893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5968 static const int kCodeAgeMask = 0xff; | 5972 static const int kCodeAgeMask = 0xff; |
| 5969 }; | 5973 }; |
| 5970 | 5974 |
| 5971 | 5975 |
| 5972 class CompilationCacheShape { | 5976 class CompilationCacheShape { |
| 5973 public: | 5977 public: |
| 5974 static inline bool IsMatch(HashTableKey* key, Object* value) { | 5978 static inline bool IsMatch(HashTableKey* key, Object* value) { |
| 5975 return key->IsMatch(value); | 5979 return key->IsMatch(value); |
| 5976 } | 5980 } |
| 5977 | 5981 |
| 5978 static inline uint32_t Hash(HashTableKey* key) { | 5982 static inline uint32_t Hash(HashTableKey* key, uint32_t) { |
| 5979 return key->Hash(); | 5983 return key->Hash(); |
| 5980 } | 5984 } |
| 5981 | 5985 |
| 5982 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { | 5986 static inline uint32_t HashForObject(HashTableKey* key, uint32_t, |
| 5987 Object* object) { | |
| 5983 return key->HashForObject(object); | 5988 return key->HashForObject(object); |
| 5984 } | 5989 } |
| 5985 | 5990 |
| 5986 MUST_USE_RESULT static MaybeObject* AsObject(HashTableKey* key) { | 5991 MUST_USE_RESULT static MaybeObject* AsObject(HashTableKey* key) { |
| 5987 return key->AsObject(); | 5992 return key->AsObject(); |
| 5988 } | 5993 } |
| 5989 | 5994 |
| 5990 static const int kPrefixSize = 0; | 5995 static const int kPrefixSize = 0; |
| 5991 static const int kEntrySize = 2; | 5996 static const int kEntrySize = 2; |
| 5992 }; | 5997 }; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6072 DISALLOW_IMPLICIT_CONSTRUCTORS(CodeCache); | 6077 DISALLOW_IMPLICIT_CONSTRUCTORS(CodeCache); |
| 6073 }; | 6078 }; |
| 6074 | 6079 |
| 6075 | 6080 |
| 6076 class CodeCacheHashTableShape { | 6081 class CodeCacheHashTableShape { |
| 6077 public: | 6082 public: |
| 6078 static inline bool IsMatch(HashTableKey* key, Object* value) { | 6083 static inline bool IsMatch(HashTableKey* key, Object* value) { |
| 6079 return key->IsMatch(value); | 6084 return key->IsMatch(value); |
| 6080 } | 6085 } |
| 6081 | 6086 |
| 6082 static inline uint32_t Hash(HashTableKey* key) { | 6087 static inline uint32_t Hash(HashTableKey* key, uint32_t) { |
| 6083 return key->Hash(); | 6088 return key->Hash(); |
| 6084 } | 6089 } |
| 6085 | 6090 |
| 6086 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { | 6091 static inline uint32_t HashForObject(HashTableKey* key, uint32_t, |
| 6092 Object* object) { | |
| 6087 return key->HashForObject(object); | 6093 return key->HashForObject(object); |
| 6088 } | 6094 } |
| 6089 | 6095 |
| 6090 MUST_USE_RESULT static MaybeObject* AsObject(HashTableKey* key) { | 6096 MUST_USE_RESULT static MaybeObject* AsObject(HashTableKey* key) { |
| 6091 return key->AsObject(); | 6097 return key->AsObject(); |
| 6092 } | 6098 } |
| 6093 | 6099 |
| 6094 static const int kPrefixSize = 0; | 6100 static const int kPrefixSize = 0; |
| 6095 static const int kEntrySize = 2; | 6101 static const int kEntrySize = 2; |
| 6096 }; | 6102 }; |
| (...skipping 1975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8072 } else { | 8078 } else { |
| 8073 value &= ~(1 << bit_position); | 8079 value &= ~(1 << bit_position); |
| 8074 } | 8080 } |
| 8075 return value; | 8081 return value; |
| 8076 } | 8082 } |
| 8077 }; | 8083 }; |
| 8078 | 8084 |
| 8079 } } // namespace v8::internal | 8085 } } // namespace v8::internal |
| 8080 | 8086 |
| 8081 #endif // V8_OBJECTS_H_ | 8087 #endif // V8_OBJECTS_H_ |
| OLD | NEW |