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.
diff --git a/runtime/gc/collector/mark_sweep.h b/runtime/gc/collector/mark_sweep.h
index 8f8a0f0..29fafd6 100644
--- a/runtime/gc/collector/mark_sweep.h
+++ b/runtime/gc/collector/mark_sweep.h
@@ -334,6 +334,10 @@
   void ClearWhiteReferences(mirror::Object** list)
       SHARED_LOCKS_REQUIRED(Locks::heap_bitmap_lock_, Locks::mutator_lock_);
 
+  // Used to get around thread safety annotations. The call is from MarkingPhase and is guarded by
+  // IsExclusiveHeld.
+  void RevokeAllThreadLocalAllocationStacks(Thread* self) NO_THREAD_SAFETY_ANALYSIS;
+
   // Whether or not we count how many of each type of object were scanned.
   static const bool kCountScannedTypes = false;