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 #ifndef V8_HEAP_HEAP_H_ | 5 #ifndef V8_HEAP_HEAP_H_ |
6 #define V8_HEAP_HEAP_H_ | 6 #define V8_HEAP_HEAP_H_ |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 2462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2473 | 2473 |
2474 private: | 2474 private: |
2475 DescriptorLookupCache() { | 2475 DescriptorLookupCache() { |
2476 for (int i = 0; i < kLength; ++i) { | 2476 for (int i = 0; i < kLength; ++i) { |
2477 keys_[i].source = NULL; | 2477 keys_[i].source = NULL; |
2478 keys_[i].name = NULL; | 2478 keys_[i].name = NULL; |
2479 results_[i] = kAbsent; | 2479 results_[i] = kAbsent; |
2480 } | 2480 } |
2481 } | 2481 } |
2482 | 2482 |
2483 static int Hash(Object* source, Name* name) { | 2483 static inline int Hash(Object* source, Name* name); |
2484 // Uses only lower 32 bits if pointers are larger. | |
2485 uint32_t source_hash = | |
2486 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(source)) >> | |
2487 kPointerSizeLog2; | |
2488 uint32_t name_hash = | |
2489 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name)) >> | |
2490 kPointerSizeLog2; | |
2491 return (source_hash ^ name_hash) % kLength; | |
2492 } | |
2493 | 2484 |
2494 static const int kLength = 64; | 2485 static const int kLength = 64; |
2495 struct Key { | 2486 struct Key { |
2496 Map* source; | 2487 Map* source; |
2497 Name* name; | 2488 Name* name; |
2498 }; | 2489 }; |
2499 | 2490 |
2500 Key keys_[kLength]; | 2491 Key keys_[kLength]; |
2501 int results_[kLength]; | 2492 int results_[kLength]; |
2502 | 2493 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2626 friend class LargeObjectSpace; | 2617 friend class LargeObjectSpace; |
2627 friend class NewSpace; | 2618 friend class NewSpace; |
2628 friend class PagedSpace; | 2619 friend class PagedSpace; |
2629 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); | 2620 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); |
2630 }; | 2621 }; |
2631 | 2622 |
2632 } // namespace internal | 2623 } // namespace internal |
2633 } // namespace v8 | 2624 } // namespace v8 |
2634 | 2625 |
2635 #endif // V8_HEAP_HEAP_H_ | 2626 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |