From 479db734e339060fcdfd98154d5dc39b1285bc66 Mon Sep 17 00:00:00 2001 From: Diogenes Nunez Date: Tue, 8 Aug 2017 10:17:15 -0700 Subject: [PATCH] Fixes the regression caused by 7568e1f18e. The IO tests unscheduled the mutator thread constantly, forcing the isolate to fill new space and cause a GC. Now, the mutator thread keeps its TLAB when unscheduled, taking advantage of the fact the same thread object will always be the mutator thread. R=asiva@google.com, rmacnak@google.com Review-Url: https://codereview.chromium.org/2993863002 . --- runtime/vm/isolate.cc | 12 ------------ runtime/vm/scavenger.cc | 18 +++++++----------- runtime/vm/thread.h | 2 -- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc index edcff0d646d..c32e7e63451 100644 --- a/runtime/vm/isolate.cc +++ b/runtime/vm/isolate.cc @@ -2563,11 +2563,6 @@ Thread* Isolate::ScheduleThread(bool is_mutator, bool bypass_safepoint) { os_thread->set_thread(thread); if (is_mutator) { scheduled_mutator_thread_ = thread; - if ((Dart::vm_isolate() != NULL) && - (heap() != Dart::vm_isolate()->heap())) { - scheduled_mutator_thread_->set_top(0); - scheduled_mutator_thread_->set_end(0); - } } Thread::SetCurrent(thread); os_thread->EnableThreadInterrupts(); @@ -2606,13 +2601,6 @@ void Isolate::UnscheduleThread(Thread* thread, os_thread->set_thread(NULL); OSThread::SetCurrent(os_thread); if (is_mutator) { - if ((Dart::vm_isolate() != NULL) && - (heap() != Dart::vm_isolate()->heap())) { - if (scheduled_mutator_thread_->HasActiveTLAB()) { - heap()->AbandonRemainingTLAB(scheduled_mutator_thread_); - } - } - ASSERT(!scheduled_mutator_thread_->HasActiveTLAB()); scheduled_mutator_thread_ = NULL; } thread->isolate_ = NULL; diff --git a/runtime/vm/scavenger.cc b/runtime/vm/scavenger.cc index 702f115dd9d..3118417cc83 100644 --- a/runtime/vm/scavenger.cc +++ b/runtime/vm/scavenger.cc @@ -405,10 +405,8 @@ void Scavenger::Epilogue(Isolate* isolate, // Ensure the mutator thread will fail the next allocation. This will force // mutator to allocate a new TLAB - if (isolate->IsMutatorThreadScheduled()) { - Thread* mutator_thread = isolate->mutator_thread(); - ASSERT(!mutator_thread->HasActiveTLAB()); - } + Thread* mutator_thread = isolate->mutator_thread(); + ASSERT((mutator_thread == NULL) || (!mutator_thread->HasActiveTLAB())); double avg_frac = stats_history_.Get(0).PromoCandidatesSuccessFraction(); if (stats_history_.Size() >= 2) { @@ -716,8 +714,8 @@ void Scavenger::ProcessWeakReferences() { void Scavenger::MakeNewSpaceIterable() const { ASSERT(heap_ != NULL); - if (heap_->isolate()->IsMutatorThreadScheduled() && !scavenging_) { - Thread* mutator_thread = heap_->isolate()->mutator_thread(); + Thread* mutator_thread = heap_->isolate()->mutator_thread(); + if (mutator_thread != NULL && !scavenging_) { if (mutator_thread->HasActiveTLAB()) { ASSERT(mutator_thread->top() <= mutator_thread->heap()->new_space()->top()); @@ -802,11 +800,9 @@ void Scavenger::Scavenge(bool invoke_api_callbacks) { int64_t post_safe_point = OS::GetCurrentMonotonicMicros(); heap_->RecordTime(kSafePoint, post_safe_point - pre_safe_point); - if (isolate->IsMutatorThreadScheduled()) { - Thread* mutator_thread = isolate->mutator_thread(); - if (mutator_thread->HasActiveTLAB()) { - heap_->AbandonRemainingTLAB(mutator_thread); - } + Thread* mutator_thread = isolate->mutator_thread(); + if ((mutator_thread != NULL) && (mutator_thread->HasActiveTLAB())) { + heap_->AbandonRemainingTLAB(mutator_thread); } // TODO(koda): Make verification more compatible with concurrent sweep. diff --git a/runtime/vm/thread.h b/runtime/vm/thread.h index 6f3100279f9..002b78a5410 100644 --- a/runtime/vm/thread.h +++ b/runtime/vm/thread.h @@ -366,11 +366,9 @@ class Thread : public BaseThread { static intptr_t heap_offset() { return OFFSET_OF(Thread, heap_); } void set_top(uword value) { - ASSERT(heap_ != NULL); top_ = value; } void set_end(uword value) { - ASSERT(heap_ != NULL); end_ = value; }