Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: src/heap/mark-compact.cc

Issue 1807923004: [heap] More evacuation tracing (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap/gc-tracer.cc ('k') | tools/eval_gc_time.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3035 matching lines...) Expand 10 before | Expand all | Expand 10 after
3046 MemoryChunk* p, HeapObjectVisitor* visitor) { 3046 MemoryChunk* p, HeapObjectVisitor* visitor) {
3047 bool success = false; 3047 bool success = false;
3048 DCHECK(p->IsEvacuationCandidate() || p->InNewSpace()); 3048 DCHECK(p->IsEvacuationCandidate() || p->InNewSpace());
3049 int saved_live_bytes = p->LiveBytes(); 3049 int saved_live_bytes = p->LiveBytes();
3050 double evacuation_time; 3050 double evacuation_time;
3051 { 3051 {
3052 AlwaysAllocateScope always_allocate(heap()->isolate()); 3052 AlwaysAllocateScope always_allocate(heap()->isolate());
3053 TimedScope timed_scope(&evacuation_time); 3053 TimedScope timed_scope(&evacuation_time);
3054 success = collector_->VisitLiveObjects(p, visitor, kClearMarkbits); 3054 success = collector_->VisitLiveObjects(p, visitor, kClearMarkbits);
3055 } 3055 }
3056 if (FLAG_trace_evacuation) {
3057 PrintIsolate(heap()->isolate(),
3058 "evacuation[%p]: page=%p new_space=%d executable=%d "
3059 "live_bytes=%d time=%f\n",
3060 this, p, p->InNewSpace(),
3061 p->IsFlagSet(MemoryChunk::IS_EXECUTABLE), saved_live_bytes,
3062 evacuation_time);
3063 }
3056 if (success) { 3064 if (success) {
3057 ReportCompactionProgress(evacuation_time, saved_live_bytes); 3065 ReportCompactionProgress(evacuation_time, saved_live_bytes);
3058 } 3066 }
3059 return success; 3067 return success;
3060 } 3068 }
3061 3069
3062 bool MarkCompactCollector::Evacuator::EvacuatePage(MemoryChunk* chunk) { 3070 bool MarkCompactCollector::Evacuator::EvacuatePage(MemoryChunk* chunk) {
3063 bool success = false; 3071 bool success = false;
3064 if (chunk->InNewSpace()) { 3072 if (chunk->InNewSpace()) {
3065 DCHECK_EQ(chunk->concurrent_sweeping_state().Value(), 3073 DCHECK_EQ(chunk->concurrent_sweeping_state().Value(),
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
3188 job.AddPage(page, &abandoned_pages); 3196 job.AddPage(page, &abandoned_pages);
3189 } 3197 }
3190 for (NewSpacePage* page : newspace_evacuation_candidates_) { 3198 for (NewSpacePage* page : newspace_evacuation_candidates_) {
3191 live_bytes += page->LiveBytes(); 3199 live_bytes += page->LiveBytes();
3192 job.AddPage(page, &abandoned_pages); 3200 job.AddPage(page, &abandoned_pages);
3193 } 3201 }
3194 DCHECK_GE(job.NumberOfPages(), 1); 3202 DCHECK_GE(job.NumberOfPages(), 1);
3195 3203
3196 // Used for trace summary. 3204 // Used for trace summary.
3197 intptr_t compaction_speed = 0; 3205 intptr_t compaction_speed = 0;
3198 if (FLAG_trace_fragmentation) { 3206 if (FLAG_trace_evacuation) {
3199 compaction_speed = heap()->tracer()->CompactionSpeedInBytesPerMillisecond(); 3207 compaction_speed = heap()->tracer()->CompactionSpeedInBytesPerMillisecond();
3200 } 3208 }
3201 3209
3202 const int wanted_num_tasks = 3210 const int wanted_num_tasks =
3203 NumberOfParallelCompactionTasks(job.NumberOfPages(), live_bytes); 3211 NumberOfParallelCompactionTasks(job.NumberOfPages(), live_bytes);
3204 Evacuator** evacuators = new Evacuator*[wanted_num_tasks]; 3212 Evacuator** evacuators = new Evacuator*[wanted_num_tasks];
3205 for (int i = 0; i < wanted_num_tasks; i++) { 3213 for (int i = 0; i < wanted_num_tasks; i++) {
3206 evacuators[i] = new Evacuator(this); 3214 evacuators[i] = new Evacuator(this);
3207 } 3215 }
3208 job.Run(wanted_num_tasks, [evacuators](int i) { return evacuators[i]; }); 3216 job.Run(wanted_num_tasks, [evacuators](int i) { return evacuators[i]; });
3209 for (int i = 0; i < wanted_num_tasks; i++) { 3217 for (int i = 0; i < wanted_num_tasks; i++) {
3210 evacuators[i]->Finalize(); 3218 evacuators[i]->Finalize();
3211 delete evacuators[i]; 3219 delete evacuators[i];
3212 } 3220 }
3213 delete[] evacuators; 3221 delete[] evacuators;
3214 3222
3215 if (FLAG_trace_fragmentation) { 3223 if (FLAG_trace_evacuation) {
3216 PrintIsolate(isolate(), 3224 PrintIsolate(
3217 "%8.0f ms: compaction: parallel=%d pages=%d aborted=%d " 3225 isolate(),
3218 "wanted_tasks=%d tasks=%d cores=%d live_bytes=%" V8_PTR_PREFIX 3226 "%8.0f ms: evacuation-summary: parallel=%s pages=%d aborted=%d "
3219 "d compaction_speed=%" V8_PTR_PREFIX "d\n", 3227 "wanted_tasks=%d tasks=%d cores=%d live_bytes=%" V8_PTR_PREFIX
3220 isolate()->time_millis_since_init(), FLAG_parallel_compaction, 3228 "d compaction_speed=%" V8_PTR_PREFIX "d\n",
3221 job.NumberOfPages(), abandoned_pages, wanted_num_tasks, 3229 isolate()->time_millis_since_init(),
3222 job.NumberOfTasks(), 3230 FLAG_parallel_compaction ? "yes" : "no", job.NumberOfPages(),
3223 V8::GetCurrentPlatform()->NumberOfAvailableBackgroundThreads(), 3231 abandoned_pages, wanted_num_tasks, job.NumberOfTasks(),
3224 live_bytes, compaction_speed); 3232 V8::GetCurrentPlatform()->NumberOfAvailableBackgroundThreads(),
3233 live_bytes, compaction_speed);
3225 } 3234 }
3226 } 3235 }
3227 3236
3228 class EvacuationWeakObjectRetainer : public WeakObjectRetainer { 3237 class EvacuationWeakObjectRetainer : public WeakObjectRetainer {
3229 public: 3238 public:
3230 virtual Object* RetainAs(Object* object) { 3239 virtual Object* RetainAs(Object* object) {
3231 if (object->IsHeapObject()) { 3240 if (object->IsHeapObject()) {
3232 HeapObject* heap_object = HeapObject::cast(object); 3241 HeapObject* heap_object = HeapObject::cast(object);
3233 MapWord map_word = heap_object->map_word(); 3242 MapWord map_word = heap_object->map_word();
3234 if (map_word.IsForwardingAddress()) { 3243 if (map_word.IsForwardingAddress()) {
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
3453 } 3462 }
3454 } 3463 }
3455 3464
3456 3465
3457 void MarkCompactCollector::EvacuateNewSpaceAndCandidates() { 3466 void MarkCompactCollector::EvacuateNewSpaceAndCandidates() {
3458 GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_EVACUATE); 3467 GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_EVACUATE);
3459 Heap::RelocationLock relocation_lock(heap()); 3468 Heap::RelocationLock relocation_lock(heap());
3460 3469
3461 { 3470 {
3462 GCTracer::Scope gc_scope(heap()->tracer(), 3471 GCTracer::Scope gc_scope(heap()->tracer(),
3463 GCTracer::Scope::MC_EVACUATE_NEW_SPACE); 3472 GCTracer::Scope::MC_EVACUATE_COPY);
3464 EvacuationScope evacuation_scope(this); 3473 EvacuationScope evacuation_scope(this);
3465 3474
3466 EvacuateNewSpacePrologue(); 3475 EvacuateNewSpacePrologue();
3467 EvacuatePagesInParallel(); 3476 EvacuatePagesInParallel();
3468 EvacuateNewSpaceEpilogue(); 3477 EvacuateNewSpaceEpilogue();
3469 heap()->new_space()->set_age_mark(heap()->new_space()->top()); 3478 heap()->new_space()->set_age_mark(heap()->new_space()->top());
3470 } 3479 }
3471 3480
3472 UpdatePointersAfterEvacuation(); 3481 UpdatePointersAfterEvacuation();
3473 3482
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
3854 MarkBit mark_bit = Marking::MarkBitFrom(host); 3863 MarkBit mark_bit = Marking::MarkBitFrom(host);
3855 if (Marking::IsBlack(mark_bit)) { 3864 if (Marking::IsBlack(mark_bit)) {
3856 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); 3865 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host);
3857 RecordRelocSlot(host, &rinfo, target); 3866 RecordRelocSlot(host, &rinfo, target);
3858 } 3867 }
3859 } 3868 }
3860 } 3869 }
3861 3870
3862 } // namespace internal 3871 } // namespace internal
3863 } // namespace v8 3872 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/gc-tracer.cc ('k') | tools/eval_gc_time.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698