| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 V(Foreign, prototype_accessors, PrototypeAccessors) \ | 153 V(Foreign, prototype_accessors, PrototypeAccessors) \ |
| 154 V(UnseededNumberDictionary, code_stubs, CodeStubs) \ | 154 V(UnseededNumberDictionary, code_stubs, CodeStubs) \ |
| 155 V(UnseededNumberDictionary, non_monomorphic_cache, NonMonomorphicCache) \ | 155 V(UnseededNumberDictionary, non_monomorphic_cache, NonMonomorphicCache) \ |
| 156 V(PolymorphicCodeCache, polymorphic_code_cache, PolymorphicCodeCache) \ | 156 V(PolymorphicCodeCache, polymorphic_code_cache, PolymorphicCodeCache) \ |
| 157 V(Code, js_entry_code, JsEntryCode) \ | 157 V(Code, js_entry_code, JsEntryCode) \ |
| 158 V(Code, js_construct_entry_code, JsConstructEntryCode) \ | 158 V(Code, js_construct_entry_code, JsConstructEntryCode) \ |
| 159 V(FixedArray, natives_source_cache, NativesSourceCache) \ | 159 V(FixedArray, natives_source_cache, NativesSourceCache) \ |
| 160 V(Object, last_script_id, LastScriptId) \ | 160 V(Object, last_script_id, LastScriptId) \ |
| 161 V(Script, empty_script, EmptyScript) \ | 161 V(Script, empty_script, EmptyScript) \ |
| 162 V(Smi, real_stack_limit, RealStackLimit) \ | 162 V(Smi, real_stack_limit, RealStackLimit) \ |
| 163 V(StringDictionary, intrinsic_function_names, IntrinsicFunctionNames) \ | 163 V(NameDictionary, intrinsic_function_names, IntrinsicFunctionNames) \ |
| 164 V(Smi, arguments_adaptor_deopt_pc_offset, ArgumentsAdaptorDeoptPCOffset) \ | 164 V(Smi, arguments_adaptor_deopt_pc_offset, ArgumentsAdaptorDeoptPCOffset) \ |
| 165 V(Smi, construct_stub_deopt_pc_offset, ConstructStubDeoptPCOffset) \ | 165 V(Smi, construct_stub_deopt_pc_offset, ConstructStubDeoptPCOffset) \ |
| 166 V(Smi, getter_stub_deopt_pc_offset, GetterStubDeoptPCOffset) \ | 166 V(Smi, getter_stub_deopt_pc_offset, GetterStubDeoptPCOffset) \ |
| 167 V(Smi, setter_stub_deopt_pc_offset, SetterStubDeoptPCOffset) \ | 167 V(Smi, setter_stub_deopt_pc_offset, SetterStubDeoptPCOffset) \ |
| 168 V(JSObject, observation_state, ObservationState) \ | 168 V(JSObject, observation_state, ObservationState) \ |
| 169 V(Map, external_map, ExternalMap) | 169 V(Map, external_map, ExternalMap) |
| 170 | 170 |
| 171 #define ROOT_LIST(V) \ | 171 #define ROOT_LIST(V) \ |
| 172 STRONG_ROOT_LIST(V) \ | 172 STRONG_ROOT_LIST(V) \ |
| 173 V(StringTable, string_table, StringTable) | 173 V(StringTable, string_table, StringTable) |
| (...skipping 2278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2452 // Object iterator for the space currently being iterated. | 2452 // Object iterator for the space currently being iterated. |
| 2453 ObjectIterator* object_iterator_; | 2453 ObjectIterator* object_iterator_; |
| 2454 }; | 2454 }; |
| 2455 | 2455 |
| 2456 | 2456 |
| 2457 // Cache for mapping (map, property name) into field offset. | 2457 // Cache for mapping (map, property name) into field offset. |
| 2458 // Cleared at startup and prior to mark sweep collection. | 2458 // Cleared at startup and prior to mark sweep collection. |
| 2459 class KeyedLookupCache { | 2459 class KeyedLookupCache { |
| 2460 public: | 2460 public: |
| 2461 // Lookup field offset for (map, name). If absent, -1 is returned. | 2461 // Lookup field offset for (map, name). If absent, -1 is returned. |
| 2462 int Lookup(Map* map, String* name); | 2462 int Lookup(Map* map, Name* name); |
| 2463 | 2463 |
| 2464 // Update an element in the cache. | 2464 // Update an element in the cache. |
| 2465 void Update(Map* map, String* name, int field_offset); | 2465 void Update(Map* map, Name* name, int field_offset); |
| 2466 | 2466 |
| 2467 // Clear the cache. | 2467 // Clear the cache. |
| 2468 void Clear(); | 2468 void Clear(); |
| 2469 | 2469 |
| 2470 static const int kLength = 256; | 2470 static const int kLength = 256; |
| 2471 static const int kCapacityMask = kLength - 1; | 2471 static const int kCapacityMask = kLength - 1; |
| 2472 static const int kMapHashShift = 5; | 2472 static const int kMapHashShift = 5; |
| 2473 static const int kHashMask = -4; // Zero the last two bits. | 2473 static const int kHashMask = -4; // Zero the last two bits. |
| 2474 static const int kEntriesPerBucket = 4; | 2474 static const int kEntriesPerBucket = 4; |
| 2475 static const int kNotFound = -1; | 2475 static const int kNotFound = -1; |
| 2476 | 2476 |
| 2477 // kEntriesPerBucket should be a power of 2. | 2477 // kEntriesPerBucket should be a power of 2. |
| 2478 STATIC_ASSERT((kEntriesPerBucket & (kEntriesPerBucket - 1)) == 0); | 2478 STATIC_ASSERT((kEntriesPerBucket & (kEntriesPerBucket - 1)) == 0); |
| 2479 STATIC_ASSERT(kEntriesPerBucket == -kHashMask); | 2479 STATIC_ASSERT(kEntriesPerBucket == -kHashMask); |
| 2480 | 2480 |
| 2481 private: | 2481 private: |
| 2482 KeyedLookupCache() { | 2482 KeyedLookupCache() { |
| 2483 for (int i = 0; i < kLength; ++i) { | 2483 for (int i = 0; i < kLength; ++i) { |
| 2484 keys_[i].map = NULL; | 2484 keys_[i].map = NULL; |
| 2485 keys_[i].name = NULL; | 2485 keys_[i].name = NULL; |
| 2486 field_offsets_[i] = kNotFound; | 2486 field_offsets_[i] = kNotFound; |
| 2487 } | 2487 } |
| 2488 } | 2488 } |
| 2489 | 2489 |
| 2490 static inline int Hash(Map* map, String* name); | 2490 static inline int Hash(Map* map, Name* name); |
| 2491 | 2491 |
| 2492 // Get the address of the keys and field_offsets arrays. Used in | 2492 // Get the address of the keys and field_offsets arrays. Used in |
| 2493 // generated code to perform cache lookups. | 2493 // generated code to perform cache lookups. |
| 2494 Address keys_address() { | 2494 Address keys_address() { |
| 2495 return reinterpret_cast<Address>(&keys_); | 2495 return reinterpret_cast<Address>(&keys_); |
| 2496 } | 2496 } |
| 2497 | 2497 |
| 2498 Address field_offsets_address() { | 2498 Address field_offsets_address() { |
| 2499 return reinterpret_cast<Address>(&field_offsets_); | 2499 return reinterpret_cast<Address>(&field_offsets_); |
| 2500 } | 2500 } |
| 2501 | 2501 |
| 2502 struct Key { | 2502 struct Key { |
| 2503 Map* map; | 2503 Map* map; |
| 2504 String* name; | 2504 Name* name; |
| 2505 }; | 2505 }; |
| 2506 | 2506 |
| 2507 Key keys_[kLength]; | 2507 Key keys_[kLength]; |
| 2508 int field_offsets_[kLength]; | 2508 int field_offsets_[kLength]; |
| 2509 | 2509 |
| 2510 friend class ExternalReference; | 2510 friend class ExternalReference; |
| 2511 friend class Isolate; | 2511 friend class Isolate; |
| 2512 DISALLOW_COPY_AND_ASSIGN(KeyedLookupCache); | 2512 DISALLOW_COPY_AND_ASSIGN(KeyedLookupCache); |
| 2513 }; | 2513 }; |
| 2514 | 2514 |
| 2515 | 2515 |
| 2516 // Cache for mapping (map, property name) into descriptor index. | 2516 // Cache for mapping (map, property name) into descriptor index. |
| 2517 // The cache contains both positive and negative results. | 2517 // The cache contains both positive and negative results. |
| 2518 // Descriptor index equals kNotFound means the property is absent. | 2518 // Descriptor index equals kNotFound means the property is absent. |
| 2519 // Cleared at startup and prior to any gc. | 2519 // Cleared at startup and prior to any gc. |
| 2520 class DescriptorLookupCache { | 2520 class DescriptorLookupCache { |
| 2521 public: | 2521 public: |
| 2522 // Lookup descriptor index for (map, name). | 2522 // Lookup descriptor index for (map, name). |
| 2523 // If absent, kAbsent is returned. | 2523 // If absent, kAbsent is returned. |
| 2524 int Lookup(Map* source, String* name) { | 2524 int Lookup(Map* source, Name* name) { |
| 2525 if (!StringShape(name).IsInternalized()) return kAbsent; | 2525 if (!name->IsUniqueName()) return kAbsent; |
| 2526 int index = Hash(source, name); | 2526 int index = Hash(source, name); |
| 2527 Key& key = keys_[index]; | 2527 Key& key = keys_[index]; |
| 2528 if ((key.source == source) && (key.name == name)) return results_[index]; | 2528 if ((key.source == source) && (key.name == name)) return results_[index]; |
| 2529 return kAbsent; | 2529 return kAbsent; |
| 2530 } | 2530 } |
| 2531 | 2531 |
| 2532 // Update an element in the cache. | 2532 // Update an element in the cache. |
| 2533 void Update(Map* source, String* name, int result) { | 2533 void Update(Map* source, Name* name, int result) { |
| 2534 ASSERT(result != kAbsent); | 2534 ASSERT(result != kAbsent); |
| 2535 if (StringShape(name).IsInternalized()) { | 2535 if (name->IsUniqueName()) { |
| 2536 int index = Hash(source, name); | 2536 int index = Hash(source, name); |
| 2537 Key& key = keys_[index]; | 2537 Key& key = keys_[index]; |
| 2538 key.source = source; | 2538 key.source = source; |
| 2539 key.name = name; | 2539 key.name = name; |
| 2540 results_[index] = result; | 2540 results_[index] = result; |
| 2541 } | 2541 } |
| 2542 } | 2542 } |
| 2543 | 2543 |
| 2544 // Clear the cache. | 2544 // Clear the cache. |
| 2545 void Clear(); | 2545 void Clear(); |
| 2546 | 2546 |
| 2547 static const int kAbsent = -2; | 2547 static const int kAbsent = -2; |
| 2548 | 2548 |
| 2549 private: | 2549 private: |
| 2550 DescriptorLookupCache() { | 2550 DescriptorLookupCache() { |
| 2551 for (int i = 0; i < kLength; ++i) { | 2551 for (int i = 0; i < kLength; ++i) { |
| 2552 keys_[i].source = NULL; | 2552 keys_[i].source = NULL; |
| 2553 keys_[i].name = NULL; | 2553 keys_[i].name = NULL; |
| 2554 results_[i] = kAbsent; | 2554 results_[i] = kAbsent; |
| 2555 } | 2555 } |
| 2556 } | 2556 } |
| 2557 | 2557 |
| 2558 static int Hash(Object* source, String* name) { | 2558 static int Hash(Object* source, Name* name) { |
| 2559 // Uses only lower 32 bits if pointers are larger. | 2559 // Uses only lower 32 bits if pointers are larger. |
| 2560 uint32_t source_hash = | 2560 uint32_t source_hash = |
| 2561 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(source)) | 2561 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(source)) |
| 2562 >> kPointerSizeLog2; | 2562 >> kPointerSizeLog2; |
| 2563 uint32_t name_hash = | 2563 uint32_t name_hash = |
| 2564 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name)) | 2564 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name)) |
| 2565 >> kPointerSizeLog2; | 2565 >> kPointerSizeLog2; |
| 2566 return (source_hash ^ name_hash) % kLength; | 2566 return (source_hash ^ name_hash) % kLength; |
| 2567 } | 2567 } |
| 2568 | 2568 |
| 2569 static const int kLength = 64; | 2569 static const int kLength = 64; |
| 2570 struct Key { | 2570 struct Key { |
| 2571 Map* source; | 2571 Map* source; |
| 2572 String* name; | 2572 Name* name; |
| 2573 }; | 2573 }; |
| 2574 | 2574 |
| 2575 Key keys_[kLength]; | 2575 Key keys_[kLength]; |
| 2576 int results_[kLength]; | 2576 int results_[kLength]; |
| 2577 | 2577 |
| 2578 friend class Isolate; | 2578 friend class Isolate; |
| 2579 DISALLOW_COPY_AND_ASSIGN(DescriptorLookupCache); | 2579 DISALLOW_COPY_AND_ASSIGN(DescriptorLookupCache); |
| 2580 }; | 2580 }; |
| 2581 | 2581 |
| 2582 | 2582 |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2958 AssertNoAllocation no_alloc; // i.e. no gc allowed. | 2958 AssertNoAllocation no_alloc; // i.e. no gc allowed. |
| 2959 | 2959 |
| 2960 private: | 2960 private: |
| 2961 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2961 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 2962 }; | 2962 }; |
| 2963 #endif // DEBUG | 2963 #endif // DEBUG |
| 2964 | 2964 |
| 2965 } } // namespace v8::internal | 2965 } } // namespace v8::internal |
| 2966 | 2966 |
| 2967 #endif // V8_HEAP_H_ | 2967 #endif // V8_HEAP_H_ |
| OLD | NEW |