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 3862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3873 // Required. | 3873 // Required. |
3874 virtual ~HashTableKey() {} | 3874 virtual ~HashTableKey() {} |
3875 }; | 3875 }; |
3876 | 3876 |
3877 | 3877 |
3878 class StringTableShape : public BaseShape<HashTableKey*> { | 3878 class StringTableShape : public BaseShape<HashTableKey*> { |
3879 public: | 3879 public: |
3880 static inline bool IsMatch(HashTableKey* key, Object* value) { | 3880 static inline bool IsMatch(HashTableKey* key, Object* value) { |
3881 return key->IsMatch(value); | 3881 return key->IsMatch(value); |
3882 } | 3882 } |
| 3883 |
3883 static inline uint32_t Hash(HashTableKey* key) { | 3884 static inline uint32_t Hash(HashTableKey* key) { |
3884 return key->Hash(); | 3885 return key->Hash(); |
3885 } | 3886 } |
| 3887 |
3886 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { | 3888 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { |
3887 return key->HashForObject(object); | 3889 return key->HashForObject(object); |
3888 } | 3890 } |
3889 MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap, | 3891 |
3890 HashTableKey* key) { | 3892 static inline Handle<Object> AsHandle(Isolate* isolate, HashTableKey* key); |
3891 return key->AsObject(heap); | |
3892 } | |
3893 | 3893 |
3894 static const int kPrefixSize = 0; | 3894 static const int kPrefixSize = 0; |
3895 static const int kEntrySize = 1; | 3895 static const int kEntrySize = 1; |
3896 }; | 3896 }; |
3897 | 3897 |
3898 class SeqOneByteString; | 3898 class SeqOneByteString; |
3899 | 3899 |
3900 // StringTable. | 3900 // StringTable. |
3901 // | 3901 // |
3902 // No special elements in the prefix and the element size is 1 | 3902 // No special elements in the prefix and the element size is 1 |
(...skipping 23 matching lines...) Expand all Loading... |
3926 | 3926 |
3927 DISALLOW_IMPLICIT_CONSTRUCTORS(StringTable); | 3927 DISALLOW_IMPLICIT_CONSTRUCTORS(StringTable); |
3928 }; | 3928 }; |
3929 | 3929 |
3930 | 3930 |
3931 class MapCacheShape : public BaseShape<HashTableKey*> { | 3931 class MapCacheShape : public BaseShape<HashTableKey*> { |
3932 public: | 3932 public: |
3933 static inline bool IsMatch(HashTableKey* key, Object* value) { | 3933 static inline bool IsMatch(HashTableKey* key, Object* value) { |
3934 return key->IsMatch(value); | 3934 return key->IsMatch(value); |
3935 } | 3935 } |
| 3936 |
3936 static inline uint32_t Hash(HashTableKey* key) { | 3937 static inline uint32_t Hash(HashTableKey* key) { |
3937 return key->Hash(); | 3938 return key->Hash(); |
3938 } | 3939 } |
3939 | 3940 |
3940 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { | 3941 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { |
3941 return key->HashForObject(object); | 3942 return key->HashForObject(object); |
3942 } | 3943 } |
3943 | 3944 |
3944 MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap, | 3945 static inline Handle<Object> AsHandle(Isolate* isolate, HashTableKey* key); |
3945 HashTableKey* key) { | |
3946 return key->AsObject(heap); | |
3947 } | |
3948 | 3946 |
3949 static const int kPrefixSize = 0; | 3947 static const int kPrefixSize = 0; |
3950 static const int kEntrySize = 2; | 3948 static const int kEntrySize = 2; |
3951 }; | 3949 }; |
3952 | 3950 |
3953 | 3951 |
3954 // MapCache. | 3952 // MapCache. |
3955 // | 3953 // |
3956 // Maps keys that are a fixed array of unique names to a map. | 3954 // Maps keys that are a fixed array of unique names to a map. |
3957 // Used for canonicalize maps for object literals. | 3955 // Used for canonicalize maps for object literals. |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4103 MinimumCapacity capacity_option, | 4101 MinimumCapacity capacity_option, |
4104 PretenureFlag pretenure); | 4102 PretenureFlag pretenure); |
4105 }; | 4103 }; |
4106 | 4104 |
4107 | 4105 |
4108 class NameDictionaryShape : public BaseShape<Handle<Name> > { | 4106 class NameDictionaryShape : public BaseShape<Handle<Name> > { |
4109 public: | 4107 public: |
4110 static inline bool IsMatch(Handle<Name> key, Object* other); | 4108 static inline bool IsMatch(Handle<Name> key, Object* other); |
4111 static inline uint32_t Hash(Handle<Name> key); | 4109 static inline uint32_t Hash(Handle<Name> key); |
4112 static inline uint32_t HashForObject(Handle<Name> key, Object* object); | 4110 static inline uint32_t HashForObject(Handle<Name> key, Object* object); |
4113 MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap, | |
4114 Handle<Name> key); | |
4115 static inline Handle<Object> AsHandle(Isolate* isolate, Handle<Name> key); | 4111 static inline Handle<Object> AsHandle(Isolate* isolate, Handle<Name> key); |
4116 static const int kPrefixSize = 2; | 4112 static const int kPrefixSize = 2; |
4117 static const int kEntrySize = 3; | 4113 static const int kEntrySize = 3; |
4118 static const bool kIsEnumerable = true; | 4114 static const bool kIsEnumerable = true; |
4119 }; | 4115 }; |
4120 | 4116 |
4121 | 4117 |
4122 class NameDictionary: public Dictionary<NameDictionary, | 4118 class NameDictionary: public Dictionary<NameDictionary, |
4123 NameDictionaryShape, | 4119 NameDictionaryShape, |
4124 Handle<Name> > { | 4120 Handle<Name> > { |
(...skipping 16 matching lines...) Expand all Loading... |
4141 int FindEntry(Handle<Name> key); | 4137 int FindEntry(Handle<Name> key); |
4142 | 4138 |
4143 // TODO(ishell): Remove this when all the callers are handlified. | 4139 // TODO(ishell): Remove this when all the callers are handlified. |
4144 int FindEntry(Name* key); | 4140 int FindEntry(Name* key); |
4145 }; | 4141 }; |
4146 | 4142 |
4147 | 4143 |
4148 class NumberDictionaryShape : public BaseShape<uint32_t> { | 4144 class NumberDictionaryShape : public BaseShape<uint32_t> { |
4149 public: | 4145 public: |
4150 static inline bool IsMatch(uint32_t key, Object* other); | 4146 static inline bool IsMatch(uint32_t key, Object* other); |
4151 // TODO(ishell): This should be eventually replaced with AsHandle(). | |
4152 MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap, | |
4153 uint32_t key); | |
4154 static inline Handle<Object> AsHandle(Isolate* isolate, uint32_t key); | 4147 static inline Handle<Object> AsHandle(Isolate* isolate, uint32_t key); |
4155 static const int kEntrySize = 3; | 4148 static const int kEntrySize = 3; |
4156 static const bool kIsEnumerable = false; | 4149 static const bool kIsEnumerable = false; |
4157 }; | 4150 }; |
4158 | 4151 |
4159 | 4152 |
4160 class SeededNumberDictionaryShape : public NumberDictionaryShape { | 4153 class SeededNumberDictionaryShape : public NumberDictionaryShape { |
4161 public: | 4154 public: |
4162 static const bool UsesSeed = true; | 4155 static const bool UsesSeed = true; |
4163 static const int kPrefixSize = 2; | 4156 static const int kPrefixSize = 2; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4256 uint32_t key, | 4249 uint32_t key, |
4257 Handle<Object> value); | 4250 Handle<Object> value); |
4258 }; | 4251 }; |
4259 | 4252 |
4260 | 4253 |
4261 class ObjectHashTableShape : public BaseShape<Handle<Object> > { | 4254 class ObjectHashTableShape : public BaseShape<Handle<Object> > { |
4262 public: | 4255 public: |
4263 static inline bool IsMatch(Handle<Object> key, Object* other); | 4256 static inline bool IsMatch(Handle<Object> key, Object* other); |
4264 static inline uint32_t Hash(Handle<Object> key); | 4257 static inline uint32_t Hash(Handle<Object> key); |
4265 static inline uint32_t HashForObject(Handle<Object> key, Object* object); | 4258 static inline uint32_t HashForObject(Handle<Object> key, Object* object); |
4266 MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap, | |
4267 Handle<Object> key); | |
4268 static inline Handle<Object> AsHandle(Isolate* isolate, Handle<Object> key); | 4259 static inline Handle<Object> AsHandle(Isolate* isolate, Handle<Object> key); |
4269 static const int kPrefixSize = 0; | 4260 static const int kPrefixSize = 0; |
4270 static const int kEntrySize = 2; | 4261 static const int kEntrySize = 2; |
4271 }; | 4262 }; |
4272 | 4263 |
4273 | 4264 |
4274 // ObjectHashTable maps keys that are arbitrary objects to object values by | 4265 // ObjectHashTable maps keys that are arbitrary objects to object values by |
4275 // using the identity hash of the key for hashing purposes. | 4266 // using the identity hash of the key for hashing purposes. |
4276 class ObjectHashTable: public HashTable<ObjectHashTable, | 4267 class ObjectHashTable: public HashTable<ObjectHashTable, |
4277 ObjectHashTableShape, | 4268 ObjectHashTableShape, |
(...skipping 4018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8296 } | 8287 } |
8297 | 8288 |
8298 static inline uint32_t Hash(HashTableKey* key) { | 8289 static inline uint32_t Hash(HashTableKey* key) { |
8299 return key->Hash(); | 8290 return key->Hash(); |
8300 } | 8291 } |
8301 | 8292 |
8302 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { | 8293 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { |
8303 return key->HashForObject(object); | 8294 return key->HashForObject(object); |
8304 } | 8295 } |
8305 | 8296 |
8306 MUST_USE_RESULT static MaybeObject* AsObject(Heap* heap, | 8297 static inline Handle<Object> AsHandle(Isolate* isolate, HashTableKey* key); |
8307 HashTableKey* key) { | |
8308 return key->AsObject(heap); | |
8309 } | |
8310 | 8298 |
8311 static const int kPrefixSize = 0; | 8299 static const int kPrefixSize = 0; |
8312 static const int kEntrySize = 2; | 8300 static const int kEntrySize = 2; |
8313 }; | 8301 }; |
8314 | 8302 |
8315 | 8303 |
8316 class CompilationCacheTable: public HashTable<CompilationCacheTable, | 8304 class CompilationCacheTable: public HashTable<CompilationCacheTable, |
8317 CompilationCacheShape, | 8305 CompilationCacheShape, |
8318 HashTableKey*> { | 8306 HashTableKey*> { |
8319 public: | 8307 public: |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8399 } | 8387 } |
8400 | 8388 |
8401 static inline uint32_t Hash(HashTableKey* key) { | 8389 static inline uint32_t Hash(HashTableKey* key) { |
8402 return key->Hash(); | 8390 return key->Hash(); |
8403 } | 8391 } |
8404 | 8392 |
8405 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { | 8393 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { |
8406 return key->HashForObject(object); | 8394 return key->HashForObject(object); |
8407 } | 8395 } |
8408 | 8396 |
8409 MUST_USE_RESULT static MaybeObject* AsObject(Heap* heap, | 8397 static inline Handle<Object> AsHandle(Isolate* isolate, HashTableKey* key); |
8410 HashTableKey* key) { | |
8411 return key->AsObject(heap); | |
8412 } | |
8413 | 8398 |
8414 static const int kPrefixSize = 0; | 8399 static const int kPrefixSize = 0; |
8415 static const int kEntrySize = 2; | 8400 static const int kEntrySize = 2; |
8416 }; | 8401 }; |
8417 | 8402 |
8418 | 8403 |
8419 class CodeCacheHashTable: public HashTable<CodeCacheHashTable, | 8404 class CodeCacheHashTable: public HashTable<CodeCacheHashTable, |
8420 CodeCacheHashTableShape, | 8405 CodeCacheHashTableShape, |
8421 HashTableKey*> { | 8406 HashTableKey*> { |
8422 public: | 8407 public: |
(...skipping 2866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11289 } else { | 11274 } else { |
11290 value &= ~(1 << bit_position); | 11275 value &= ~(1 << bit_position); |
11291 } | 11276 } |
11292 return value; | 11277 return value; |
11293 } | 11278 } |
11294 }; | 11279 }; |
11295 | 11280 |
11296 } } // namespace v8::internal | 11281 } } // namespace v8::internal |
11297 | 11282 |
11298 #endif // V8_OBJECTS_H_ | 11283 #endif // V8_OBJECTS_H_ |
OLD | NEW |