Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 494 | 494 |
| 495 Counters::objs_since_last_full.Set(0); | 495 Counters::objs_since_last_full.Set(0); |
| 496 context_disposed_pending_ = false; | 496 context_disposed_pending_ = false; |
| 497 } | 497 } |
| 498 | 498 |
| 499 | 499 |
| 500 void Heap::MarkCompactPrologue(bool is_compacting) { | 500 void Heap::MarkCompactPrologue(bool is_compacting) { |
| 501 // At any old GC clear the keyed lookup cache to enable collection of unused | 501 // At any old GC clear the keyed lookup cache to enable collection of unused |
| 502 // maps. | 502 // maps. |
| 503 KeyedLookupCache::Clear(); | 503 KeyedLookupCache::Clear(); |
| 504 ContextSlotCache::Clear(); | |
| 504 | 505 |
| 505 CompilationCache::MarkCompactPrologue(); | 506 CompilationCache::MarkCompactPrologue(); |
| 506 | 507 |
| 507 Top::MarkCompactPrologue(is_compacting); | 508 Top::MarkCompactPrologue(is_compacting); |
| 508 ThreadManager::MarkCompactPrologue(is_compacting); | 509 ThreadManager::MarkCompactPrologue(is_compacting); |
| 509 } | 510 } |
| 510 | 511 |
| 511 | 512 |
| 512 void Heap::MarkCompactEpilogue(bool is_compacting) { | 513 void Heap::MarkCompactEpilogue(bool is_compacting) { |
| 513 Top::MarkCompactEpilogue(is_compacting); | 514 Top::MarkCompactEpilogue(is_compacting); |
| (...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1381 obj = AllocateFixedArray(Natives::GetBuiltinsCount()); | 1382 obj = AllocateFixedArray(Natives::GetBuiltinsCount()); |
| 1382 if (obj->IsFailure()) return false; | 1383 if (obj->IsFailure()) return false; |
| 1383 natives_source_cache_ = FixedArray::cast(obj); | 1384 natives_source_cache_ = FixedArray::cast(obj); |
| 1384 | 1385 |
| 1385 // Handling of script id generation is in Factory::NewScript. | 1386 // Handling of script id generation is in Factory::NewScript. |
| 1386 last_script_id_ = undefined_value(); | 1387 last_script_id_ = undefined_value(); |
| 1387 | 1388 |
| 1388 // Initialize keyed lookup cache. | 1389 // Initialize keyed lookup cache. |
| 1389 KeyedLookupCache::Clear(); | 1390 KeyedLookupCache::Clear(); |
| 1390 | 1391 |
| 1392 // Initialize context slot cache. | |
| 1393 ContextSlotCache::Clear(); | |
| 1394 | |
| 1391 // Initialize compilation cache. | 1395 // Initialize compilation cache. |
| 1392 CompilationCache::Clear(); | 1396 CompilationCache::Clear(); |
| 1393 | 1397 |
| 1394 return true; | 1398 return true; |
| 1395 } | 1399 } |
| 1396 | 1400 |
| 1397 | 1401 |
| 1398 static inline int double_get_hash(double d) { | 1402 static inline int double_get_hash(double d) { |
| 1399 DoubleRepresentation rep(d); | 1403 DoubleRepresentation rep(d); |
| 1400 return ((static_cast<int>(rep.bits) ^ static_cast<int>(rep.bits >> 32)) & | 1404 return ((static_cast<int>(rep.bits) ^ static_cast<int>(rep.bits >> 32)) & |
| (...skipping 2106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3507 case SCAVENGER: | 3511 case SCAVENGER: |
| 3508 return "Scavenge"; | 3512 return "Scavenge"; |
| 3509 case MARK_COMPACTOR: | 3513 case MARK_COMPACTOR: |
| 3510 return MarkCompactCollector::HasCompacted() ? "Mark-compact" | 3514 return MarkCompactCollector::HasCompacted() ? "Mark-compact" |
| 3511 : "Mark-sweep"; | 3515 : "Mark-sweep"; |
| 3512 } | 3516 } |
| 3513 return "Unknown GC"; | 3517 return "Unknown GC"; |
| 3514 } | 3518 } |
| 3515 | 3519 |
| 3516 | 3520 |
| 3521 // ------ KeyedLookupCache ------ | |
|
Mads Ager (chromium)
2009/06/22 08:00:18
We do not have separators like this in the rest of
| |
| 3522 | |
| 3517 int KeyedLookupCache::Hash(Map* map, String* name) { | 3523 int KeyedLookupCache::Hash(Map* map, String* name) { |
| 3518 // Uses only lower 32 bits if pointers are larger. | 3524 // Uses only lower 32 bits if pointers are larger. |
| 3519 uintptr_t addr_hash = | 3525 uintptr_t addr_hash = |
| 3520 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(map)) >> 2; | 3526 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(map)) >> 2; |
| 3521 return (addr_hash ^ name->Hash()) % kLength; | 3527 return (addr_hash ^ name->Hash()) % kLength; |
| 3522 } | 3528 } |
| 3523 | 3529 |
| 3524 | 3530 |
| 3525 int KeyedLookupCache::Lookup(Map* map, String* name) { | 3531 int KeyedLookupCache::Lookup(Map* map, String* name) { |
| 3526 int index = Hash(map, name); | 3532 int index = Hash(map, name); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 3541 key.name = symbol; | 3547 key.name = symbol; |
| 3542 field_offsets_[index] = field_offset; | 3548 field_offsets_[index] = field_offset; |
| 3543 } | 3549 } |
| 3544 } | 3550 } |
| 3545 | 3551 |
| 3546 | 3552 |
| 3547 void KeyedLookupCache::Clear() { | 3553 void KeyedLookupCache::Clear() { |
| 3548 for (int index = 0; index < kLength; index++) keys_[index].map = NULL; | 3554 for (int index = 0; index < kLength; index++) keys_[index].map = NULL; |
| 3549 } | 3555 } |
| 3550 | 3556 |
| 3557 | |
| 3551 KeyedLookupCache::Key KeyedLookupCache::keys_[KeyedLookupCache::kLength]; | 3558 KeyedLookupCache::Key KeyedLookupCache::keys_[KeyedLookupCache::kLength]; |
| 3552 | 3559 |
| 3560 | |
| 3553 int KeyedLookupCache::field_offsets_[KeyedLookupCache::kLength]; | 3561 int KeyedLookupCache::field_offsets_[KeyedLookupCache::kLength]; |
| 3554 | 3562 |
| 3555 | 3563 |
| 3556 #ifdef DEBUG | 3564 #ifdef DEBUG |
| 3557 bool Heap::GarbageCollectionGreedyCheck() { | 3565 bool Heap::GarbageCollectionGreedyCheck() { |
| 3558 ASSERT(FLAG_gc_greedy); | 3566 ASSERT(FLAG_gc_greedy); |
| 3559 if (Bootstrapper::IsActive()) return true; | 3567 if (Bootstrapper::IsActive()) return true; |
| 3560 if (disallow_allocation_failure()) return true; | 3568 if (disallow_allocation_failure()) return true; |
| 3561 return CollectGarbage(0, NEW_SPACE); | 3569 return CollectGarbage(0, NEW_SPACE); |
| 3562 } | 3570 } |
| 3563 #endif | 3571 #endif |
| 3564 | 3572 |
| 3565 } } // namespace v8::internal | 3573 } } // namespace v8::internal |
| OLD | NEW |