Chromium Code Reviews| Index: runtime/vm/scavenger.cc |
| =================================================================== |
| --- runtime/vm/scavenger.cc (revision 43504) |
| +++ runtime/vm/scavenger.cc (working copy) |
| @@ -475,7 +475,6 @@ |
| void Scavenger::Epilogue(Isolate* isolate, |
| - ScavengerVisitor* visitor, |
| bool invoke_api_callbacks) { |
| // All objects in the to space have been copied from the from space at this |
| // moment. |
| @@ -818,34 +817,39 @@ |
| intptr_t promo_candidate_words = |
| (survivor_end_ - FirstObjectStart()) / kWordSize; |
| Prologue(isolate, invoke_api_callbacks); |
| - const bool prologue_weak_are_strong = !invoke_api_callbacks; |
| + // The API prologue/epilogue may create/destroy zones, so ensure that |
| + // anything allocating from the current zone, such as ScavengerVisitor, is |
| + // destroyed before the epilogue callback. |
| + { |
|
siva
2015/02/05 23:53:06
Ditto comment.
koda
2015/02/06 00:16:07
Done.
|
| + // Setup the visitor and run the scavenge. |
| + ScavengerVisitor visitor(isolate, this); |
| + page_space->AcquireDataLock(); |
| + const bool prologue_weak_are_strong = !invoke_api_callbacks; |
| + IterateRoots(isolate, &visitor, prologue_weak_are_strong); |
| + int64_t start = OS::GetCurrentTimeMicros(); |
| + ProcessToSpace(&visitor); |
| + int64_t middle = OS::GetCurrentTimeMicros(); |
| + IterateWeakReferences(isolate, &visitor); |
| + ScavengerWeakVisitor weak_visitor(this, prologue_weak_are_strong); |
| + // Include the prologue weak handles, since we must process any promotion. |
| + const bool visit_prologue_weak_handles = true; |
| + IterateWeakRoots(isolate, &weak_visitor, visit_prologue_weak_handles); |
| + visitor.Finalize(); |
| + ProcessWeakTables(); |
| + page_space->ReleaseDataLock(); |
| - // Setup the visitor and run the scavenge. |
| - ScavengerVisitor visitor(isolate, this); |
| - page_space->AcquireDataLock(); |
| - IterateRoots(isolate, &visitor, prologue_weak_are_strong); |
| - int64_t start = OS::GetCurrentTimeMicros(); |
| - ProcessToSpace(&visitor); |
| - int64_t middle = OS::GetCurrentTimeMicros(); |
| - IterateWeakReferences(isolate, &visitor); |
| - ScavengerWeakVisitor weak_visitor(this, prologue_weak_are_strong); |
| - // Include the prologue weak handles, since we must process any promotion. |
| - const bool visit_prologue_weak_handles = true; |
| - IterateWeakRoots(isolate, &weak_visitor, visit_prologue_weak_handles); |
| - visitor.Finalize(); |
| - ProcessWeakTables(); |
| - page_space->ReleaseDataLock(); |
| + // Scavenge finished. Run accounting. |
| + int64_t end = OS::GetCurrentTimeMicros(); |
| + heap_->RecordTime(kProcessToSpace, middle - start); |
| + heap_->RecordTime(kIterateWeaks, end - middle); |
| + stats_history_.Add( |
| + ScavengeStats(start, end, |
| + usage_before, GetCurrentUsage(), |
| + promo_candidate_words, |
| + visitor.bytes_promoted() >> kWordSizeLog2)); |
| + } |
| + Epilogue(isolate, invoke_api_callbacks); |
| - // Scavenge finished. Run accounting and epilogue. |
| - int64_t end = OS::GetCurrentTimeMicros(); |
| - heap_->RecordTime(kProcessToSpace, middle - start); |
| - heap_->RecordTime(kIterateWeaks, end - middle); |
| - stats_history_.Add(ScavengeStats(start, end, |
| - usage_before, GetCurrentUsage(), |
| - promo_candidate_words, |
| - visitor.bytes_promoted() >> kWordSizeLog2)); |
| - Epilogue(isolate, &visitor, invoke_api_callbacks); |
| - |
| // TODO(koda): Make verification more compatible with concurrent sweep. |
| if (FLAG_verify_after_gc && !FLAG_concurrent_sweep) { |
| OS::PrintErr("Verifying after Scavenge..."); |