Remove started runtime check in RevokeAllThreadLocalAllocationStacks
This check occasionally caused some thread local allocation stacks
to incorrectly not get revoked when multiple threads were allocating
without a started runtime. This showed up in image_test with
compaction enabled when we were initializing classes in the compiler
driver.
Change-Id: I7f28d072feea333c2503e35265ba25c51a6308fe
diff --git a/runtime/gc/collector/mark_sweep.cc b/runtime/gc/collector/mark_sweep.cc
index 9ab2d2e..cc34689 100644
--- a/runtime/gc/collector/mark_sweep.cc
+++ b/runtime/gc/collector/mark_sweep.cc
@@ -210,7 +210,7 @@
// Since SweepArray() above resets the (active) allocation
// stack. Need to revoke the thread-local allocation stacks that
// point into it.
- GetHeap()->RevokeAllThreadLocalAllocationStacks(self);
+ RevokeAllThreadLocalAllocationStacks(self);
}
timings_.StartSplit("PreSweepingGcVerification");
@@ -252,6 +252,13 @@
}
}
+void MarkSweep::RevokeAllThreadLocalAllocationStacks(Thread* self) {
+ if (kUseThreadLocalAllocationStack) {
+ Locks::mutator_lock_->AssertExclusiveHeld(self);
+ heap_->RevokeAllThreadLocalAllocationStacks(self);
+ }
+}
+
void MarkSweep::MarkingPhase() {
TimingLogger::ScopedSplit split("MarkingPhase", &timings_);
Thread* self = Thread::Current();
@@ -271,9 +278,7 @@
if (Locks::mutator_lock_->IsExclusiveHeld(self)) {
// If we exclusively hold the mutator lock, all threads must be suspended.
MarkRoots();
- if (kUseThreadLocalAllocationStack) {
- heap_->RevokeAllThreadLocalAllocationStacks(self);
- }
+ RevokeAllThreadLocalAllocationStacks(self);
} else {
MarkThreadRoots(self);
// At this point the live stack should no longer have any mutators which push into it.