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 3569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3580 heap, heap->isolate()->cancelable_task_manager()); | 3580 heap, heap->isolate()->cancelable_task_manager()); |
3581 RememberedSet<direction>::IterateMemoryChunks( | 3581 RememberedSet<direction>::IterateMemoryChunks( |
3582 heap, [job](MemoryChunk* chunk) { job->AddPage(chunk, 0); }); | 3582 heap, [job](MemoryChunk* chunk) { job->AddPage(chunk, 0); }); |
3583 PointersUpdatingVisitor visitor(heap); | 3583 PointersUpdatingVisitor visitor(heap); |
3584 int num_pages = job->NumberOfPages(); | 3584 int num_pages = job->NumberOfPages(); |
3585 int num_tasks = NumberOfPointerUpdateTasks(num_pages); | 3585 int num_tasks = NumberOfPointerUpdateTasks(num_pages); |
3586 job->Run(num_tasks, [&visitor](int i) { return &visitor; }); | 3586 job->Run(num_tasks, [&visitor](int i) { return &visitor; }); |
3587 delete job; | 3587 delete job; |
3588 } | 3588 } |
3589 | 3589 |
| 3590 class ToSpacePointerUpdateJobTraits { |
| 3591 public: |
| 3592 typedef std::pair<Address, Address> PerPageData; |
| 3593 typedef PointersUpdatingVisitor* PerTaskData; |
| 3594 |
| 3595 static bool ProcessPageInParallel(Heap* heap, PerTaskData visitor, |
| 3596 MemoryChunk* chunk, PerPageData limits) { |
| 3597 for (Address cur = limits.first; cur < limits.second;) { |
| 3598 HeapObject* object = HeapObject::FromAddress(cur); |
| 3599 Map* map = object->map(); |
| 3600 int size = object->SizeFromMap(map); |
| 3601 object->IterateBody(map->instance_type(), size, visitor); |
| 3602 cur += size; |
| 3603 } |
| 3604 return true; |
| 3605 } |
| 3606 static const bool NeedSequentialFinalization = false; |
| 3607 static void FinalizePageSequentially(Heap*, MemoryChunk*, bool, PerPageData) { |
| 3608 } |
| 3609 }; |
| 3610 |
| 3611 void UpdateToSpacePointersInParallel(Heap* heap) { |
| 3612 PageParallelJob<ToSpacePointerUpdateJobTraits> job( |
| 3613 heap, heap->isolate()->cancelable_task_manager()); |
| 3614 Address space_start = heap->new_space()->bottom(); |
| 3615 Address space_end = heap->new_space()->top(); |
| 3616 NewSpacePageIterator it(space_start, space_end); |
| 3617 while (it.has_next()) { |
| 3618 NewSpacePage* page = it.next(); |
| 3619 Address start = |
| 3620 page->Contains(space_start) ? space_start : page->area_start(); |
| 3621 Address end = page->Contains(space_end) ? space_end : page->area_end(); |
| 3622 job.AddPage(page, std::make_pair(start, end)); |
| 3623 } |
| 3624 PointersUpdatingVisitor visitor(heap); |
| 3625 int num_tasks = FLAG_parallel_pointer_update ? job.NumberOfPages() : 1; |
| 3626 job.Run(num_tasks, [&visitor](int i) { return &visitor; }); |
| 3627 } |
| 3628 |
3590 void MarkCompactCollector::UpdatePointersAfterEvacuation() { | 3629 void MarkCompactCollector::UpdatePointersAfterEvacuation() { |
3591 GCTracer::Scope gc_scope(heap()->tracer(), | 3630 GCTracer::Scope gc_scope(heap()->tracer(), |
3592 GCTracer::Scope::MC_EVACUATE_UPDATE_POINTERS); | 3631 GCTracer::Scope::MC_EVACUATE_UPDATE_POINTERS); |
3593 | 3632 |
3594 PointersUpdatingVisitor updating_visitor(heap()); | 3633 PointersUpdatingVisitor updating_visitor(heap()); |
3595 | 3634 |
3596 { | 3635 { |
3597 GCTracer::Scope gc_scope( | 3636 GCTracer::Scope gc_scope( |
3598 heap()->tracer(), GCTracer::Scope::MC_EVACUATE_UPDATE_POINTERS_TO_NEW); | 3637 heap()->tracer(), GCTracer::Scope::MC_EVACUATE_UPDATE_POINTERS_TO_NEW); |
3599 // Update pointers in to space. | 3638 UpdateToSpacePointersInParallel(heap_); |
3600 SemiSpaceIterator to_it(heap()->new_space()); | |
3601 for (HeapObject* object = to_it.Next(); object != NULL; | |
3602 object = to_it.Next()) { | |
3603 Map* map = object->map(); | |
3604 object->IterateBody(map->instance_type(), object->SizeFromMap(map), | |
3605 &updating_visitor); | |
3606 } | |
3607 // Update roots. | 3639 // Update roots. |
3608 heap_->IterateRoots(&updating_visitor, VISIT_ALL_IN_SWEEP_NEWSPACE); | 3640 heap_->IterateRoots(&updating_visitor, VISIT_ALL_IN_SWEEP_NEWSPACE); |
3609 | |
3610 UpdatePointersInParallel<OLD_TO_NEW>(heap_); | 3641 UpdatePointersInParallel<OLD_TO_NEW>(heap_); |
3611 } | 3642 } |
3612 | 3643 |
3613 { | 3644 { |
3614 Heap* heap = this->heap(); | 3645 Heap* heap = this->heap(); |
3615 GCTracer::Scope gc_scope( | 3646 GCTracer::Scope gc_scope( |
3616 heap->tracer(), | 3647 heap->tracer(), |
3617 GCTracer::Scope::MC_EVACUATE_UPDATE_POINTERS_TO_EVACUATED); | 3648 GCTracer::Scope::MC_EVACUATE_UPDATE_POINTERS_TO_EVACUATED); |
3618 UpdatePointersInParallel<OLD_TO_OLD>(heap_); | 3649 UpdatePointersInParallel<OLD_TO_OLD>(heap_); |
3619 } | 3650 } |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3863 MarkBit mark_bit = Marking::MarkBitFrom(host); | 3894 MarkBit mark_bit = Marking::MarkBitFrom(host); |
3864 if (Marking::IsBlack(mark_bit)) { | 3895 if (Marking::IsBlack(mark_bit)) { |
3865 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); | 3896 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); |
3866 RecordRelocSlot(host, &rinfo, target); | 3897 RecordRelocSlot(host, &rinfo, target); |
3867 } | 3898 } |
3868 } | 3899 } |
3869 } | 3900 } |
3870 | 3901 |
3871 } // namespace internal | 3902 } // namespace internal |
3872 } // namespace v8 | 3903 } // namespace v8 |
OLD | NEW |