Changes calculation of Scavenger's UsedInWords

Once again fixes https://github.com/dart-lang/sdk/issues/30311

The previous commit for this issue (044f818f01) was reverted to
fix a bug. This CL avoids writing to the TLAB to measure the
usage.

R=asiva@google.com, rmacnak@google.com

Review-Url: https://codereview.chromium.org/2993203002 .
This commit is contained in:
Diogenes Nunez
2017-08-07 15:17:42 -07:00
parent 8c08aaa812
commit 91470e7211
+10 -2
View File
@@ -924,8 +924,16 @@ void Scavenger::Evacuate() {
}
int64_t Scavenger::UsedInWords() const {
int64_t used_in_words = (top_ - FirstObjectStart()) >> kWordSizeLog2;
return used_in_words;
int64_t free_space_in_tlab = 0;
if (heap_->isolate()->IsMutatorThreadScheduled()) {
Thread* mutator_thread = heap_->isolate()->mutator_thread();
if (mutator_thread->HasActiveTLAB()) {
free_space_in_tlab =
(mutator_thread->end() - mutator_thread->top()) >> kWordSizeLog2;
}
}
int64_t max_space_used = (top_ - FirstObjectStart()) >> kWordSizeLog2;
return max_space_used - free_space_in_tlab;
}
} // namespace dart