| 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 #include "src/heap/mark-compact.h" | 5 #include "src/heap/mark-compact.h" |
| 6 | 6 |
| 7 #include "src/base/atomicops.h" | 7 #include "src/base/atomicops.h" |
| 8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
| 9 #include "src/base/sys-info.h" | 9 #include "src/base/sys-info.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 3466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3477 Page* p = evacuation_candidates_[i]; | 3477 Page* p = evacuation_candidates_[i]; |
| 3478 DCHECK(p->IsEvacuationCandidate() || | 3478 DCHECK(p->IsEvacuationCandidate() || |
| 3479 p->IsFlagSet(Page::RESCAN_ON_EVACUATION)); | 3479 p->IsFlagSet(Page::RESCAN_ON_EVACUATION)); |
| 3480 if (p->IsEvacuationCandidate()) { | 3480 if (p->IsEvacuationCandidate()) { |
| 3481 SlotsBuffer::RemoveObjectSlots(heap_, p->slots_buffer(), start_slot, | 3481 SlotsBuffer::RemoveObjectSlots(heap_, p->slots_buffer(), start_slot, |
| 3482 end_slot); | 3482 end_slot); |
| 3483 } | 3483 } |
| 3484 } | 3484 } |
| 3485 } | 3485 } |
| 3486 | 3486 |
| 3487 |
| 3487 #ifdef VERIFY_HEAP | 3488 #ifdef VERIFY_HEAP |
| 3488 static void VerifyAllBlackObjects(MemoryChunk* page) { | 3489 static void VerifyAllBlackObjects(MemoryChunk* page) { |
| 3489 LiveObjectIterator<kAllLiveObjects> it(page); | 3490 LiveObjectIterator<kAllLiveObjects> it(page); |
| 3490 HeapObject* object = NULL; | 3491 HeapObject* object = NULL; |
| 3491 while ((object = it.Next()) != NULL) { | 3492 while ((object = it.Next()) != NULL) { |
| 3492 CHECK(Marking::IsBlack(Marking::MarkBitFrom(object))); | 3493 CHECK(Marking::IsBlack(Marking::MarkBitFrom(object))); |
| 3493 } | 3494 } |
| 3494 } | 3495 } |
| 3495 #endif // VERIFY_HEAP | 3496 #endif // VERIFY_HEAP |
| 3496 | 3497 |
| 3498 |
| 3497 bool MarkCompactCollector::VisitLiveObjects(MemoryChunk* page, | 3499 bool MarkCompactCollector::VisitLiveObjects(MemoryChunk* page, |
| 3498 HeapObjectVisitor* visitor, | 3500 HeapObjectVisitor* visitor, |
| 3499 IterationMode mode) { | 3501 IterationMode mode) { |
| 3500 #ifdef VERIFY_HEAP | 3502 #ifdef VERIFY_HEAP |
| 3501 VerifyAllBlackObjects(page); | 3503 VerifyAllBlackObjects(page); |
| 3502 #endif // VERIFY_HEAP | 3504 #endif // VERIFY_HEAP |
| 3503 | 3505 |
| 3504 LiveObjectIterator<kBlackObjects> it(page); | 3506 LiveObjectIterator<kBlackObjects> it(page); |
| 3505 HeapObject* object = NULL; | 3507 HeapObject* object = nullptr; |
| 3506 while ((object = it.Next()) != NULL) { | 3508 while ((object = it.Next()) != nullptr) { |
| 3507 DCHECK(Marking::IsBlack(Marking::MarkBitFrom(object))); | 3509 DCHECK(Marking::IsBlack(Marking::MarkBitFrom(object))); |
| 3508 if (!visitor->Visit(object)) { | 3510 if (!visitor->Visit(object)) { |
| 3509 if (mode == kClearMarkbits) { | 3511 if (mode == kClearMarkbits) { |
| 3510 page->markbits()->ClearRange( | 3512 page->markbits()->ClearRange( |
| 3511 page->AddressToMarkbitIndex(page->area_start()), | 3513 page->AddressToMarkbitIndex(page->area_start()), |
| 3512 page->AddressToMarkbitIndex(object->address())); | 3514 page->AddressToMarkbitIndex(object->address())); |
| 3515 RecomputeLiveBytes(page); |
| 3513 } | 3516 } |
| 3514 return false; | 3517 return false; |
| 3515 } | 3518 } |
| 3516 } | 3519 } |
| 3517 if (mode == kClearMarkbits) { | 3520 if (mode == kClearMarkbits) { |
| 3518 Bitmap::Clear(page); | 3521 Bitmap::Clear(page); |
| 3519 } | 3522 } |
| 3520 return true; | 3523 return true; |
| 3521 } | 3524 } |
| 3522 | 3525 |
| 3523 | 3526 |
| 3527 void MarkCompactCollector::RecomputeLiveBytes(MemoryChunk* page) { |
| 3528 LiveObjectIterator<kBlackObjects> it(page); |
| 3529 int new_live_size = 0; |
| 3530 HeapObject* object = nullptr; |
| 3531 while ((object = it.Next()) != nullptr) { |
| 3532 new_live_size += object->Size(); |
| 3533 } |
| 3534 page->SetLiveBytes(new_live_size); |
| 3535 } |
| 3536 |
| 3537 |
| 3524 void MarkCompactCollector::VisitLiveObjectsBody(Page* page, | 3538 void MarkCompactCollector::VisitLiveObjectsBody(Page* page, |
| 3525 ObjectVisitor* visitor) { | 3539 ObjectVisitor* visitor) { |
| 3526 #ifdef VERIFY_HEAP | 3540 #ifdef VERIFY_HEAP |
| 3527 VerifyAllBlackObjects(page); | 3541 VerifyAllBlackObjects(page); |
| 3528 #endif // VERIFY_HEAP | 3542 #endif // VERIFY_HEAP |
| 3529 | 3543 |
| 3530 LiveObjectIterator<kBlackObjects> it(page); | 3544 LiveObjectIterator<kBlackObjects> it(page); |
| 3531 HeapObject* object = NULL; | 3545 HeapObject* object = NULL; |
| 3532 while ((object = it.Next()) != NULL) { | 3546 while ((object = it.Next()) != NULL) { |
| 3533 DCHECK(Marking::IsBlack(Marking::MarkBitFrom(object))); | 3547 DCHECK(Marking::IsBlack(Marking::MarkBitFrom(object))); |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4054 MarkBit mark_bit = Marking::MarkBitFrom(host); | 4068 MarkBit mark_bit = Marking::MarkBitFrom(host); |
| 4055 if (Marking::IsBlack(mark_bit)) { | 4069 if (Marking::IsBlack(mark_bit)) { |
| 4056 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); | 4070 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); |
| 4057 RecordRelocSlot(&rinfo, target); | 4071 RecordRelocSlot(&rinfo, target); |
| 4058 } | 4072 } |
| 4059 } | 4073 } |
| 4060 } | 4074 } |
| 4061 | 4075 |
| 4062 } // namespace internal | 4076 } // namespace internal |
| 4063 } // namespace v8 | 4077 } // namespace v8 |
| OLD | NEW |