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

Unified Diff: runtime/vm/scavenger.cc

Issue 2995693002: Puts TLABs back into the build and fixes assert failure. (Closed)
Patch Set: Created 3 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/scavenger.h ('k') | runtime/vm/thread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/scavenger.cc
diff --git a/runtime/vm/scavenger.cc b/runtime/vm/scavenger.cc
index 6e34bd0fa65fabbc9fa9afaffb19fbf255f12812..a605d713c8cebd08336391252f2da46c63b09aa6 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,13 +403,10 @@ 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
- if (isolate->IsMutatorThreadScheduled()) {
- Thread* thread = isolate->mutator_thread();
- thread->set_top(top_);
- thread->set_end(end_);
- }
+ // Ensure the mutator thread will fail the next allocation. This will force
+ // mutator to allocate a new TLAB
+ 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) {
@@ -722,18 +712,21 @@ void Scavenger::ProcessWeakReferences() {
}
}
-void Scavenger::FlushTLS() const {
+void Scavenger::MakeNewSpaceIterable() const {
ASSERT(heap_ != NULL);
- if (heap_->isolate()->IsMutatorThreadScheduled()) {
- Thread* mutator_thread = heap_->isolate()->mutator_thread();
- mutator_thread->heap()->new_space()->set_top(mutator_thread->top());
+ Thread* mutator_thread = heap_->isolate()->mutator_thread();
+ if (mutator_thread != NULL && !scavenging_) {
+ if (mutator_thread->HasActiveTLAB()) {
+ ASSERT(mutator_thread->top() <= top_);
+ heap_->FillRemainingTLAB(mutator_thread);
+ }
}
}
void Scavenger::VisitObjectPointers(ObjectPointerVisitor* visitor) const {
ASSERT(Thread::Current()->IsAtSafepoint() ||
(Thread::Current()->task_kind() == Thread::kMarkerTask));
- FlushTLS();
+ MakeNewSpaceIterable();
uword cur = FirstObjectStart();
while (cur < top_) {
RawObject* raw_obj = RawObject::FromAddr(cur);
@@ -744,7 +737,7 @@ void Scavenger::VisitObjectPointers(ObjectPointerVisitor* visitor) const {
void Scavenger::VisitObjects(ObjectVisitor* visitor) const {
ASSERT(Thread::Current()->IsAtSafepoint() ||
(Thread::Current()->task_kind() == Thread::kMarkerTask));
- FlushTLS();
+ MakeNewSpaceIterable();
uword cur = FirstObjectStart();
while (cur < top_) {
RawObject* raw_obj = RawObject::FromAddr(cur);
@@ -759,7 +752,7 @@ void Scavenger::AddRegionsToObjectSet(ObjectSet* set) const {
RawObject* Scavenger::FindObject(FindObjectVisitor* visitor) const {
ASSERT(!scavenging_);
- FlushTLS();
+ MakeNewSpaceIterable();
uword cur = FirstObjectStart();
if (visitor->VisitRange(cur, top_)) {
while (cur < top_) {
@@ -806,6 +799,11 @@ void Scavenger::Scavenge(bool invoke_api_callbacks) {
int64_t post_safe_point = OS::GetCurrentMonotonicMicros();
heap_->RecordTime(kSafePoint, post_safe_point - pre_safe_point);
+ 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.
if (FLAG_verify_before_gc && !FLAG_concurrent_sweep) {
OS::PrintErr("Verifying before Scavenge...");
@@ -917,11 +915,6 @@ void Scavenger::Evacuate() {
// Forces the next scavenge to promote all the objects in the new space.
survivor_end_ = top_;
- if (heap_->isolate()->IsMutatorThreadScheduled()) {
- Thread* mutator_thread = heap_->isolate()->mutator_thread();
- survivor_end_ = mutator_thread->top();
- }
-
Scavenge();
// It is possible for objects to stay in the new space
@@ -929,4 +922,17 @@ void Scavenger::Evacuate() {
ASSERT((UsedInWords() == 0) || failed_to_promote_);
}
+int64_t Scavenger::UsedInWords() const {
+ 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
« no previous file with comments | « runtime/vm/scavenger.h ('k') | runtime/vm/thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698