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 3504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3515 void MarkCompactCollector::RecomputeLiveBytes(MemoryChunk* page) { | 3515 void MarkCompactCollector::RecomputeLiveBytes(MemoryChunk* page) { |
3516 LiveObjectIterator<kBlackObjects> it(page); | 3516 LiveObjectIterator<kBlackObjects> it(page); |
3517 int new_live_size = 0; | 3517 int new_live_size = 0; |
3518 HeapObject* object = nullptr; | 3518 HeapObject* object = nullptr; |
3519 while ((object = it.Next()) != nullptr) { | 3519 while ((object = it.Next()) != nullptr) { |
3520 new_live_size += object->Size(); | 3520 new_live_size += object->Size(); |
3521 } | 3521 } |
3522 page->SetLiveBytes(new_live_size); | 3522 page->SetLiveBytes(new_live_size); |
3523 } | 3523 } |
3524 | 3524 |
3525 | |
3526 void MarkCompactCollector::VisitLiveObjectsBody(Page* page, | |
3527 ObjectVisitor* visitor) { | |
3528 #ifdef VERIFY_HEAP | |
3529 VerifyAllBlackObjects(page); | |
3530 #endif // VERIFY_HEAP | |
3531 | |
3532 LiveObjectIterator<kBlackObjects> it(page); | |
3533 HeapObject* object = NULL; | |
3534 while ((object = it.Next()) != NULL) { | |
3535 DCHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(object))); | |
3536 Map* map = object->synchronized_map(); | |
3537 int size = object->SizeFromMap(map); | |
3538 object->IterateBody(map->instance_type(), size, visitor); | |
3539 } | |
3540 } | |
3541 | |
3542 void MarkCompactCollector::Sweeper::AddSweptPageSafe(PagedSpace* space, | 3525 void MarkCompactCollector::Sweeper::AddSweptPageSafe(PagedSpace* space, |
3543 Page* page) { | 3526 Page* page) { |
3544 base::LockGuard<base::Mutex> guard(&mutex_); | 3527 base::LockGuard<base::Mutex> guard(&mutex_); |
3545 swept_list_[space->identity()].Add(page); | 3528 swept_list_[space->identity()].Add(page); |
3546 } | 3529 } |
3547 | 3530 |
3548 void MarkCompactCollector::EvacuateNewSpaceAndCandidates() { | 3531 void MarkCompactCollector::EvacuateNewSpaceAndCandidates() { |
3549 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_EVACUATE); | 3532 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_EVACUATE); |
3550 Heap::RelocationLock relocation_lock(heap()); | 3533 Heap::RelocationLock relocation_lock(heap()); |
3551 | 3534 |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4038 // The target is always in old space, we don't have to record the slot in | 4021 // The target is always in old space, we don't have to record the slot in |
4039 // the old-to-new remembered set. | 4022 // the old-to-new remembered set. |
4040 DCHECK(!heap()->InNewSpace(target)); | 4023 DCHECK(!heap()->InNewSpace(target)); |
4041 RecordRelocSlot(host, &rinfo, target); | 4024 RecordRelocSlot(host, &rinfo, target); |
4042 } | 4025 } |
4043 } | 4026 } |
4044 } | 4027 } |
4045 | 4028 |
4046 } // namespace internal | 4029 } // namespace internal |
4047 } // namespace v8 | 4030 } // namespace v8 |
OLD | NEW |