diff options
-rw-r--r-- | runtime/art_method-inl.h | 10 | ||||
-rw-r--r-- | runtime/gc/heap.cc | 3 | ||||
-rw-r--r-- | runtime/thread-inl.h | 12 | ||||
-rw-r--r-- | runtime/thread.h | 3 |
4 files changed, 24 insertions, 4 deletions
diff --git a/runtime/art_method-inl.h b/runtime/art_method-inl.h index 32425d89a0..70a907f11d 100644 --- a/runtime/art_method-inl.h +++ b/runtime/art_method-inl.h @@ -90,10 +90,12 @@ inline uint32_t ArtMethod::GetAccessFlags() { if (kIsDebugBuild) { Thread* self = Thread::Current(); if (!Locks::mutator_lock_->IsSharedHeld(self)) { - ScopedObjectAccess soa(self); - CHECK(IsRuntimeMethod() || - GetDeclaringClass<kReadBarrierOption>()->IsIdxLoaded() || - GetDeclaringClass<kReadBarrierOption>()->IsErroneous()); + if (self->IsThreadSuspensionAllowable()) { + ScopedObjectAccess soa(self); + CHECK(IsRuntimeMethod() || + GetDeclaringClass<kReadBarrierOption>()->IsIdxLoaded() || + GetDeclaringClass<kReadBarrierOption>()->IsErroneous()); + } } else { // We cannot use SOA in this case. We might be holding the lock, but may not be in the // runnable state (e.g., during GC). diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index 6f4767e391..74e6c3cf31 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -2546,6 +2546,9 @@ void Heap::PreZygoteFork() { // Set all the cards in the mod-union table since we don't know which objects contain references // to large objects. mod_union_table->SetCards(); + // Filter out cards that do not to be dirty. This is mostly for CC collector so that it does + // not gray the objects on all the cards in the zygote space. + mod_union_table->FilterCards(); AddModUnionTable(mod_union_table); large_object_space_->SetAllLargeObjectsAsZygoteObjects(self); if (collector::SemiSpace::kUseRememberedSet) { diff --git a/runtime/thread-inl.h b/runtime/thread-inl.h index 3fd66a7bcb..3aa1fc256d 100644 --- a/runtime/thread-inl.h +++ b/runtime/thread-inl.h @@ -93,6 +93,18 @@ inline ThreadState Thread::SetState(ThreadState new_state) { return static_cast<ThreadState>(old_state_and_flags.as_struct.state); } +inline bool Thread::IsThreadSuspensionAllowable() const { + if (tls32_.no_thread_suspension != 0) { + return false; + } + for (int i = kLockLevelCount - 1; i >= 0; --i) { + if (i != kMutatorLock && GetHeldMutex(static_cast<LockLevel>(i)) != nullptr) { + return false; + } + } + return true; +} + inline void Thread::AssertThreadSuspensionIsAllowable(bool check_locks) const { if (kIsDebugBuild) { if (gAborting == 0) { diff --git a/runtime/thread.h b/runtime/thread.h index a3a4005347..9a4eb97243 100644 --- a/runtime/thread.h +++ b/runtime/thread.h @@ -287,6 +287,9 @@ class Thread { void AssertThreadSuspensionIsAllowable(bool check_locks = true) const; + // Return true if thread suspension is allowable. + bool IsThreadSuspensionAllowable() const; + bool IsDaemon() const { return tls32_.daemon; } |