diff options
| -rw-r--r-- | runtime/art_method.h | 13 | ||||
| -rw-r--r-- | runtime/jit/jit_code_cache.cc | 6 |
2 files changed, 14 insertions, 5 deletions
diff --git a/runtime/art_method.h b/runtime/art_method.h index 3c6f230d15..bd9b64df36 100644 --- a/runtime/art_method.h +++ b/runtime/art_method.h @@ -177,8 +177,9 @@ class ArtMethod FINAL { return (GetAccessFlags<kReadBarrierOption>() & kAccFinal) != 0; } + template <ReadBarrierOption kReadBarrierOption = kWithReadBarrier> bool IsIntrinsic() { - return (GetAccessFlags() & kAccIntrinsic) != 0; + return (GetAccessFlags<kReadBarrierOption>() & kAccIntrinsic) != 0; } ALWAYS_INLINE void SetIntrinsic(uint32_t intrinsic) REQUIRES_SHARED(Locks::mutator_lock_); @@ -318,12 +319,13 @@ class ArtMethod FINAL { return (GetAccessFlags() & kAccPreviouslyWarm) != 0; } + template <ReadBarrierOption kReadBarrierOption = kWithReadBarrier> void SetPreviouslyWarm() { - if (IsIntrinsic()) { + if (IsIntrinsic<kReadBarrierOption>()) { // kAccPreviouslyWarm overlaps with kAccIntrinsicBits. return; } - AddAccessFlags(kAccPreviouslyWarm); + AddAccessFlags<kReadBarrierOption>(kAccPreviouslyWarm); } // Should this method be run in the interpreter and count locks (e.g., failed structured- @@ -846,8 +848,11 @@ class ArtMethod FINAL { } // This setter guarantees atomicity. + template <ReadBarrierOption kReadBarrierOption = kWithReadBarrier> void AddAccessFlags(uint32_t flag) { - DCHECK(!IsIntrinsic() || !OverlapsIntrinsicBits(flag) || IsValidIntrinsicUpdate(flag)); + DCHECK(!IsIntrinsic<kReadBarrierOption>() || + !OverlapsIntrinsicBits(flag) || + IsValidIntrinsicUpdate(flag)); uint32_t old_access_flags; uint32_t new_access_flags; do { diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc index 51a63ddf8a..f0f0df4f5e 100644 --- a/runtime/jit/jit_code_cache.cc +++ b/runtime/jit/jit_code_cache.cc @@ -684,7 +684,11 @@ void JitCodeCache::CopyInlineCacheInto(const InlineCache& ic, static void ClearMethodCounter(ArtMethod* method, bool was_warm) { if (was_warm) { - method->SetPreviouslyWarm(); + // Don't do any read barrier, as the declaring class of `method` may + // be in the process of being GC'ed (reading the declaring class is done + // when DCHECKing the declaring class is resolved, which we know it is + // at this point). + method->SetPreviouslyWarm<kWithoutReadBarrier>(); } // We reset the counter to 1 so that the profile knows that the method was executed at least once. // This is required for layout purposes. |