diff options
| -rw-r--r-- | runtime/interpreter/shadow_frame.h | 8 | ||||
| -rw-r--r-- | runtime/read_barrier.h | 8 | ||||
| -rw-r--r-- | runtime/thread.cc | 11 |
3 files changed, 13 insertions, 14 deletions
diff --git a/runtime/interpreter/shadow_frame.h b/runtime/interpreter/shadow_frame.h index 6903af284f..80fdadb0a7 100644 --- a/runtime/interpreter/shadow_frame.h +++ b/runtime/interpreter/shadow_frame.h @@ -188,9 +188,7 @@ class ShadowFrame { const uint32_t* vreg_ptr = &vregs_[i]; ref = reinterpret_cast<const StackReference<mirror::Object>*>(vreg_ptr)->AsMirrorPtr(); } - if (kUseReadBarrier) { - ReadBarrier::AssertToSpaceInvariant(ref); - } + ReadBarrier::MaybeAssertToSpaceInvariant(ref); if (kVerifyFlags & kVerifyReads) { VerifyObject(ref); } @@ -256,9 +254,7 @@ class ShadowFrame { if (kVerifyFlags & kVerifyWrites) { VerifyObject(val); } - if (kUseReadBarrier) { - ReadBarrier::AssertToSpaceInvariant(val); - } + ReadBarrier::MaybeAssertToSpaceInvariant(val); uint32_t* vreg = &vregs_[i]; reinterpret_cast<StackReference<mirror::Object>*>(vreg)->Assign(val); if (HasReferenceArray()) { diff --git a/runtime/read_barrier.h b/runtime/read_barrier.h index 45e78bcc07..00674b2b89 100644 --- a/runtime/read_barrier.h +++ b/runtime/read_barrier.h @@ -89,6 +89,14 @@ class ReadBarrier { static void AssertToSpaceInvariant(GcRootSource* gc_root_source, mirror::Object* ref) REQUIRES_SHARED(Locks::mutator_lock_); + // Without the holder object, and only with the read barrier configuration (no-op otherwise). + static void MaybeAssertToSpaceInvariant(mirror::Object* ref) + REQUIRES_SHARED(Locks::mutator_lock_) { + if (kUseReadBarrier) { + AssertToSpaceInvariant(ref); + } + } + // ALWAYS_INLINE on this caused a performance regression b/26744236. static mirror::Object* Mark(mirror::Object* obj) REQUIRES_SHARED(Locks::mutator_lock_); diff --git a/runtime/thread.cc b/runtime/thread.cc index 24129315b3..b66365a1a9 100644 --- a/runtime/thread.cc +++ b/runtime/thread.cc @@ -3080,9 +3080,7 @@ void Thread::QuickDeliverException() { UNREACHABLE(); } - if (kUseReadBarrier) { - ReadBarrier::AssertToSpaceInvariant(exception.Ptr()); - } + ReadBarrier::MaybeAssertToSpaceInvariant(exception.Ptr()); // This is a real exception: let the instrumentation know about it. instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation(); @@ -3131,11 +3129,8 @@ void Thread::QuickDeliverException() { } else { // Exception was put back with a throw location. DCHECK(IsExceptionPending()); - if (kUseReadBarrier) { - // Check the to-space invariant on the re-installed exception. - ObjPtr<mirror::Throwable> reinstalled_exception = GetException(); - ReadBarrier::AssertToSpaceInvariant(reinstalled_exception.Ptr()); - } + // Check the to-space invariant on the re-installed exception (if applicable). + ReadBarrier::MaybeAssertToSpaceInvariant(GetException()); } exception_handler.DoLongJump(); } |