Revert "Revoke thread-local mark stack for CC in ~Thread"
This reverts commit 129d61b4c45ee2cf14a9ea964ec97bca1441b621.
Bug: 140119552
Reason for revert: Test failures
Change-Id: If31d47973c442bed57415cc55341602274e5851b
diff --git a/runtime/gc/collector/concurrent_copying.cc b/runtime/gc/collector/concurrent_copying.cc
index 4a6869f..a1663c8 100644
--- a/runtime/gc/collector/concurrent_copying.cc
+++ b/runtime/gc/collector/concurrent_copying.cc
@@ -2027,9 +2027,7 @@
CHECK_EQ(self, thread);
accounting::AtomicStack<mirror::Object>* tl_mark_stack = thread->GetThreadLocalMarkStack();
if (tl_mark_stack != nullptr) {
- // With 2-phase CC change, we cannot assert that is_marking_ will always be true
- // as we perform thread stack scan even before enabling the read-barrier.
- CHECK(is_marking_ || (use_generational_cc_ && !young_gen_));
+ CHECK(is_marking_);
MutexLock mu(self, mark_stack_lock_);
revoked_mark_stacks_.push_back(tl_mark_stack);
RemoveThreadMarkStackMapping(thread, tl_mark_stack);
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 36c35f8..59a38e1 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -2439,19 +2439,13 @@
{
ScopedObjectAccess soa(self);
Runtime::Current()->GetHeap()->RevokeThreadLocalBuffers(this);
+ if (kUseReadBarrier) {
+ Runtime::Current()->GetHeap()->ConcurrentCopyingCollector()->RevokeThreadLocalMarkStack(this);
+ }
}
}
Thread::~Thread() {
- if (kUseReadBarrier) {
- // It's a cheap operation so can be done in the destructor (instead of
- // Destroy()).
- // Doing it without mutator_lock mutual exclusion is also necessary as there
- // is a checkpoint in ConcurrentCopying which scans the threads' stacks,
- // thereby assigning a thread-local mark-stack to self, breaking some
- // assumptions about how the GC works (see b/140119552).
- Runtime::Current()->GetHeap()->ConcurrentCopyingCollector()->RevokeThreadLocalMarkStack(this);
- }
CHECK(tlsPtr_.class_loader_override == nullptr);
CHECK(tlsPtr_.jpeer == nullptr);
CHECK(tlsPtr_.opeer == nullptr);