| 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_H_ | 5 #ifndef V8_HEAP_H_ |
| 6 #define V8_HEAP_H_ | 6 #define V8_HEAP_H_ |
| 7 | 7 |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "allocation.h" | 10 #include "allocation.h" |
| (...skipping 2396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2407 // Object iterator for the space currently being iterated. | 2407 // Object iterator for the space currently being iterated. |
| 2408 ObjectIterator* object_iterator_; | 2408 ObjectIterator* object_iterator_; |
| 2409 }; | 2409 }; |
| 2410 | 2410 |
| 2411 | 2411 |
| 2412 // Cache for mapping (map, property name) into field offset. | 2412 // Cache for mapping (map, property name) into field offset. |
| 2413 // Cleared at startup and prior to mark sweep collection. | 2413 // Cleared at startup and prior to mark sweep collection. |
| 2414 class KeyedLookupCache { | 2414 class KeyedLookupCache { |
| 2415 public: | 2415 public: |
| 2416 // Lookup field offset for (map, name). If absent, -1 is returned. | 2416 // Lookup field offset for (map, name). If absent, -1 is returned. |
| 2417 int Lookup(Map* map, Name* name); | 2417 int Lookup(Handle<Map> map, Handle<Name> name); |
| 2418 | 2418 |
| 2419 // Update an element in the cache. | 2419 // Update an element in the cache. |
| 2420 void Update(Map* map, Name* name, int field_offset); | 2420 void Update(Handle<Map> map, Handle<Name> name, int field_offset); |
| 2421 | 2421 |
| 2422 // Clear the cache. | 2422 // Clear the cache. |
| 2423 void Clear(); | 2423 void Clear(); |
| 2424 | 2424 |
| 2425 static const int kLength = 256; | 2425 static const int kLength = 256; |
| 2426 static const int kCapacityMask = kLength - 1; | 2426 static const int kCapacityMask = kLength - 1; |
| 2427 static const int kMapHashShift = 5; | 2427 static const int kMapHashShift = 5; |
| 2428 static const int kHashMask = -4; // Zero the last two bits. | 2428 static const int kHashMask = -4; // Zero the last two bits. |
| 2429 static const int kEntriesPerBucket = 4; | 2429 static const int kEntriesPerBucket = 4; |
| 2430 static const int kNotFound = -1; | 2430 static const int kNotFound = -1; |
| 2431 | 2431 |
| 2432 // kEntriesPerBucket should be a power of 2. | 2432 // kEntriesPerBucket should be a power of 2. |
| 2433 STATIC_ASSERT((kEntriesPerBucket & (kEntriesPerBucket - 1)) == 0); | 2433 STATIC_ASSERT((kEntriesPerBucket & (kEntriesPerBucket - 1)) == 0); |
| 2434 STATIC_ASSERT(kEntriesPerBucket == -kHashMask); | 2434 STATIC_ASSERT(kEntriesPerBucket == -kHashMask); |
| 2435 | 2435 |
| 2436 private: | 2436 private: |
| 2437 KeyedLookupCache() { | 2437 KeyedLookupCache() { |
| 2438 for (int i = 0; i < kLength; ++i) { | 2438 for (int i = 0; i < kLength; ++i) { |
| 2439 keys_[i].map = NULL; | 2439 keys_[i].map = NULL; |
| 2440 keys_[i].name = NULL; | 2440 keys_[i].name = NULL; |
| 2441 field_offsets_[i] = kNotFound; | 2441 field_offsets_[i] = kNotFound; |
| 2442 } | 2442 } |
| 2443 } | 2443 } |
| 2444 | 2444 |
| 2445 static inline int Hash(Map* map, Name* name); | 2445 static inline int Hash(Handle<Map> map, Handle<Name> name); |
| 2446 | 2446 |
| 2447 // Get the address of the keys and field_offsets arrays. Used in | 2447 // Get the address of the keys and field_offsets arrays. Used in |
| 2448 // generated code to perform cache lookups. | 2448 // generated code to perform cache lookups. |
| 2449 Address keys_address() { | 2449 Address keys_address() { |
| 2450 return reinterpret_cast<Address>(&keys_); | 2450 return reinterpret_cast<Address>(&keys_); |
| 2451 } | 2451 } |
| 2452 | 2452 |
| 2453 Address field_offsets_address() { | 2453 Address field_offsets_address() { |
| 2454 return reinterpret_cast<Address>(&field_offsets_); | 2454 return reinterpret_cast<Address>(&field_offsets_); |
| 2455 } | 2455 } |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2810 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2810 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
| 2811 | 2811 |
| 2812 private: | 2812 private: |
| 2813 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2813 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 2814 }; | 2814 }; |
| 2815 #endif // DEBUG | 2815 #endif // DEBUG |
| 2816 | 2816 |
| 2817 } } // namespace v8::internal | 2817 } } // namespace v8::internal |
| 2818 | 2818 |
| 2819 #endif // V8_HEAP_H_ | 2819 #endif // V8_HEAP_H_ |
| OLD | NEW |