OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // Review notes: | 5 // Review notes: |
6 // | 6 // |
7 // - The use of macros in these inline functions may seem superfluous | 7 // - The use of macros in these inline functions may seem superfluous |
8 // but it is absolutely needed to make sure gcc generates optimal | 8 // but it is absolutely needed to make sure gcc generates optimal |
9 // code. gcc is not happy when attempting to inline too deep. | 9 // code. gcc is not happy when attempting to inline too deep. |
10 // | 10 // |
(...skipping 3268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3279 return Max(capacity, kMinCapacity); | 3279 return Max(capacity, kMinCapacity); |
3280 } | 3280 } |
3281 | 3281 |
3282 | 3282 |
3283 template <typename Derived, typename Shape, typename Key> | 3283 template <typename Derived, typename Shape, typename Key> |
3284 int HashTable<Derived, Shape, Key>::FindEntry(Key key) { | 3284 int HashTable<Derived, Shape, Key>::FindEntry(Key key) { |
3285 return FindEntry(GetIsolate(), key); | 3285 return FindEntry(GetIsolate(), key); |
3286 } | 3286 } |
3287 | 3287 |
3288 | 3288 |
| 3289 template<typename Derived, typename Shape, typename Key> |
| 3290 int HashTable<Derived, Shape, Key>::FindEntry(Isolate* isolate, Key key) { |
| 3291 return FindEntry(isolate, key, HashTable::Hash(key)); |
| 3292 } |
| 3293 |
| 3294 |
3289 // Find entry for key otherwise return kNotFound. | 3295 // Find entry for key otherwise return kNotFound. |
3290 template<typename Derived, typename Shape, typename Key> | 3296 template <typename Derived, typename Shape, typename Key> |
3291 int HashTable<Derived, Shape, Key>::FindEntry(Isolate* isolate, Key key) { | 3297 int HashTable<Derived, Shape, Key>::FindEntry(Isolate* isolate, Key key, |
| 3298 int32_t hash) { |
3292 uint32_t capacity = Capacity(); | 3299 uint32_t capacity = Capacity(); |
3293 uint32_t entry = FirstProbe(HashTable::Hash(key), capacity); | 3300 uint32_t entry = FirstProbe(hash, capacity); |
3294 uint32_t count = 1; | 3301 uint32_t count = 1; |
3295 // EnsureCapacity will guarantee the hash table is never full. | 3302 // EnsureCapacity will guarantee the hash table is never full. |
3296 while (true) { | 3303 while (true) { |
3297 Object* element = KeyAt(entry); | 3304 Object* element = KeyAt(entry); |
3298 // Empty entry. Uses raw unchecked accessors because it is called by the | 3305 // Empty entry. Uses raw unchecked accessors because it is called by the |
3299 // string table during bootstrapping. | 3306 // string table during bootstrapping. |
3300 if (element == isolate->heap()->raw_unchecked_undefined_value()) break; | 3307 if (element == isolate->heap()->raw_unchecked_undefined_value()) break; |
3301 if (element != isolate->heap()->raw_unchecked_the_hole_value() && | 3308 if (element != isolate->heap()->raw_unchecked_the_hole_value() && |
3302 Shape::IsMatch(key, element)) return entry; | 3309 Shape::IsMatch(key, element)) return entry; |
3303 entry = NextProbe(entry, count++, capacity); | 3310 entry = NextProbe(entry, count++, capacity); |
(...skipping 4329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7633 #undef READ_SHORT_FIELD | 7640 #undef READ_SHORT_FIELD |
7634 #undef WRITE_SHORT_FIELD | 7641 #undef WRITE_SHORT_FIELD |
7635 #undef READ_BYTE_FIELD | 7642 #undef READ_BYTE_FIELD |
7636 #undef WRITE_BYTE_FIELD | 7643 #undef WRITE_BYTE_FIELD |
7637 #undef NOBARRIER_READ_BYTE_FIELD | 7644 #undef NOBARRIER_READ_BYTE_FIELD |
7638 #undef NOBARRIER_WRITE_BYTE_FIELD | 7645 #undef NOBARRIER_WRITE_BYTE_FIELD |
7639 | 7646 |
7640 } } // namespace v8::internal | 7647 } } // namespace v8::internal |
7641 | 7648 |
7642 #endif // V8_OBJECTS_INL_H_ | 7649 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |