Chromium Code Reviews| Index: runtime/vm/scavenger.cc |
| diff --git a/runtime/vm/scavenger.cc b/runtime/vm/scavenger.cc |
| index d4a26b1b06234e74525862e582b14e49072c4a57..c5b9faa4cb7dcfa3a7eb6430f4834ffadd7262d7 100644 |
| --- a/runtime/vm/scavenger.cc |
| +++ b/runtime/vm/scavenger.cc |
| @@ -394,13 +394,6 @@ SemiSpace* Scavenger::Prologue(Isolate* isolate, bool invoke_api_callbacks) { |
| resolved_top_ = top_; |
| end_ = to_->end(); |
| - // Throw out the old information about the from space |
| - if (isolate->IsMutatorThreadScheduled()) { |
| - Thread* mutator_thread = isolate->mutator_thread(); |
| - mutator_thread->set_top(top_); |
| - mutator_thread->set_end(end_); |
| - } |
| - |
| return from; |
| } |
| @@ -410,12 +403,12 @@ void Scavenger::Epilogue(Isolate* isolate, |
| // All objects in the to space have been copied from the from space at this |
| // moment. |
| - // Ensure the mutator thread now has the up-to-date top_ and end_ of the |
| - // semispace |
| + // Ensure the mutator thread will fail the next allocation. This will force |
| + // mutator to allocate a new TLAB |
| if (isolate->IsMutatorThreadScheduled()) { |
| Thread* thread = isolate->mutator_thread(); |
| thread->set_top(top_); |
|
rmacnak
2017/07/25 21:02:45
Can this use zeroes?
danunez
2017/07/26 20:19:20
Good call. Found a latent error by changing this t
|
| - thread->set_end(end_); |
| + thread->set_end(top_); |
| } |
| double avg_frac = stats_history_.Get(0).PromoCandidatesSuccessFraction(); |
| @@ -718,31 +711,46 @@ void Scavenger::ProcessWeakReferences() { |
| } |
| } |
| -void Scavenger::FlushTLS() const { |
| +uword Scavenger::FlushTLS() const { |
| ASSERT(heap_ != NULL); |
| - if (heap_->isolate()->IsMutatorThreadScheduled()) { |
| + uword top_bk = top_; |
|
rmacnak
2017/07/25 21:02:45
Throughout this file: saved_top
danunez
2017/07/26 20:19:20
Done.
|
| + if (heap_->isolate()->IsMutatorThreadScheduled() && !scavenging_) { |
| Thread* mutator_thread = heap_->isolate()->mutator_thread(); |
| + top_bk = mutator_thread->heap()->new_space()->top(); |
| + ASSERT(mutator_thread->top() <= mutator_thread->heap()->new_space()->top()); |
| mutator_thread->heap()->new_space()->set_top(mutator_thread->top()); |
| } |
| + return top_bk; |
| +} |
| + |
| +void Scavenger::UnflushTLS(uword value) const { |
| + ASSERT(heap_ != NULL); |
| + if (heap_->isolate()->IsMutatorThreadScheduled() && !scavenging_) { |
| + Thread* mutator_thread = heap_->isolate()->mutator_thread(); |
| + mutator_thread->heap()->new_space()->set_top(value); |
| + ASSERT(mutator_thread->top() <= mutator_thread->heap()->new_space()->top()); |
| + } |
| } |
| void Scavenger::VisitObjectPointers(ObjectPointerVisitor* visitor) const { |
| - FlushTLS(); |
| + uword backup = FlushTLS(); |
| uword cur = FirstObjectStart(); |
| while (cur < top_) { |
| RawObject* raw_obj = RawObject::FromAddr(cur); |
| cur += raw_obj->VisitPointers(visitor); |
| } |
| + UnflushTLS(backup); |
| } |
| void Scavenger::VisitObjects(ObjectVisitor* visitor) const { |
| - FlushTLS(); |
| + uword backup = FlushTLS(); |
| uword cur = FirstObjectStart(); |
| while (cur < top_) { |
| RawObject* raw_obj = RawObject::FromAddr(cur); |
| visitor->VisitObject(raw_obj); |
| cur += raw_obj->Size(); |
| } |
| + UnflushTLS(backup); |
| } |
| void Scavenger::AddRegionsToObjectSet(ObjectSet* set) const { |
| @@ -751,19 +759,21 @@ void Scavenger::AddRegionsToObjectSet(ObjectSet* set) const { |
| RawObject* Scavenger::FindObject(FindObjectVisitor* visitor) const { |
| ASSERT(!scavenging_); |
| - FlushTLS(); |
| + uword backup = FlushTLS(); |
| uword cur = FirstObjectStart(); |
| if (visitor->VisitRange(cur, top_)) { |
| while (cur < top_) { |
| RawObject* raw_obj = RawObject::FromAddr(cur); |
| uword next = cur + raw_obj->Size(); |
| if (visitor->VisitRange(cur, next) && raw_obj->FindObject(visitor)) { |
| + UnflushTLS(backup); |
| return raw_obj; // Found object, return it. |
| } |
| cur = next; |
| } |
| ASSERT(cur == top_); |
| } |
| + UnflushTLS(backup); |
| return Object::null(); |
| } |
| @@ -798,6 +808,10 @@ void Scavenger::Scavenge(bool invoke_api_callbacks) { |
| int64_t post_safe_point = OS::GetCurrentMonotonicMicros(); |
| heap_->RecordTime(kSafePoint, post_safe_point - pre_safe_point); |
| + if (thread->IsMutatorThread() && isolate->IsMutatorThreadScheduled()) { |
| + heap_->MakeTLABIterable(thread->top(), thread->end()); |
| + } |
| + |
| // TODO(koda): Make verification more compatible with concurrent sweep. |
| if (FLAG_verify_before_gc && !FLAG_concurrent_sweep) { |
| OS::PrintErr("Verifying before Scavenge..."); |