From: Andreas Gampe Date: Tue, 29 Sep 2015 18:21:43 +0000 (-0700) Subject: ART: Remove unnecessary SHARED_REQUIRES in ArtMethod X-Git-Tag: android-x86-7.1-r1~889^2~272^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=6dd332933a570f5e413dd0d784481607798fbcf5;p=android-x86%2Fart.git ART: Remove unnecessary SHARED_REQUIRES in ArtMethod Move DCHECKs in GetAccessFlags into their own block and let them acquire the mutator lock, if necessary. Then remove the old annotations. Change-Id: I29e24f17b001d0e16dc66c01a0f6450efb64ebc6 --- diff --git a/runtime/art_method-inl.h b/runtime/art_method-inl.h index d6b2b7e04..65bcefa35 100644 --- a/runtime/art_method-inl.h +++ b/runtime/art_method-inl.h @@ -35,6 +35,8 @@ #include "quick/quick_method_frame_info.h" #include "read_barrier-inl.h" #include "runtime-inl.h" +#include "scoped_thread_state_change.h" +#include "thread-inl.h" #include "utils.h" namespace art { @@ -76,8 +78,11 @@ inline bool ArtMethod::CASDeclaringClass(mirror::Class* expected_class, } inline uint32_t ArtMethod::GetAccessFlags() { - DCHECK(IsRuntimeMethod() || GetDeclaringClass()->IsIdxLoaded() || - GetDeclaringClass()->IsErroneous()); + if (kIsDebugBuild) { + ScopedObjectAccess soa(Thread::Current()); + CHECK(IsRuntimeMethod() || GetDeclaringClass()->IsIdxLoaded() || + GetDeclaringClass()->IsErroneous()); + } return access_flags_; } diff --git a/runtime/art_method.h b/runtime/art_method.h index f78c8274b..0315c3a95 100644 --- a/runtime/art_method.h +++ b/runtime/art_method.h @@ -75,7 +75,9 @@ class ArtMethod FINAL { return MemberOffset(OFFSETOF_MEMBER(ArtMethod, declaring_class_)); } - ALWAYS_INLINE uint32_t GetAccessFlags() SHARED_REQUIRES(Locks::mutator_lock_); + // Note: GetAccessFlags acquires the mutator lock in debug mode to check that it is not called for + // a proxy method. + ALWAYS_INLINE uint32_t GetAccessFlags(); void SetAccessFlags(uint32_t new_access_flags) { // Not called within a transaction. @@ -86,77 +88,78 @@ class ArtMethod FINAL { InvokeType GetInvokeType() SHARED_REQUIRES(Locks::mutator_lock_); // Returns true if the method is declared public. - bool IsPublic() SHARED_REQUIRES(Locks::mutator_lock_) { + bool IsPublic() { return (GetAccessFlags() & kAccPublic) != 0; } // Returns true if the method is declared private. - bool IsPrivate() SHARED_REQUIRES(Locks::mutator_lock_) { + bool IsPrivate() { return (GetAccessFlags() & kAccPrivate) != 0; } // Returns true if the method is declared static. - bool IsStatic() SHARED_REQUIRES(Locks::mutator_lock_) { + bool IsStatic() { return (GetAccessFlags() & kAccStatic) != 0; } // Returns true if the method is a constructor. - bool IsConstructor() SHARED_REQUIRES(Locks::mutator_lock_) { + bool IsConstructor() { return (GetAccessFlags() & kAccConstructor) != 0; } // Returns true if the method is a class initializer. - bool IsClassInitializer() SHARED_REQUIRES(Locks::mutator_lock_) { + bool IsClassInitializer() { return IsConstructor() && IsStatic(); } // Returns true if the method is static, private, or a constructor. - bool IsDirect() SHARED_REQUIRES(Locks::mutator_lock_) { + bool IsDirect() { return IsDirect(GetAccessFlags()); } static bool IsDirect(uint32_t access_flags) { - return (access_flags & (kAccStatic | kAccPrivate | kAccConstructor)) != 0; + constexpr uint32_t direct = kAccStatic | kAccPrivate | kAccConstructor; + return (access_flags & direct) != 0; } // Returns true if the method is declared synchronized. - bool IsSynchronized() SHARED_REQUIRES(Locks::mutator_lock_) { - uint32_t synchonized = kAccSynchronized | kAccDeclaredSynchronized; + bool IsSynchronized() { + constexpr uint32_t synchonized = kAccSynchronized | kAccDeclaredSynchronized; return (GetAccessFlags() & synchonized) != 0; } - bool IsFinal() SHARED_REQUIRES(Locks::mutator_lock_) { + bool IsFinal() { return (GetAccessFlags() & kAccFinal) != 0; } - bool IsMiranda() SHARED_REQUIRES(Locks::mutator_lock_) { + bool IsMiranda() { return (GetAccessFlags() & kAccMiranda) != 0; } - bool IsNative() SHARED_REQUIRES(Locks::mutator_lock_) { + bool IsNative() { return (GetAccessFlags() & kAccNative) != 0; } - bool IsFastNative() SHARED_REQUIRES(Locks::mutator_lock_) { - uint32_t mask = kAccFastNative | kAccNative; + bool IsFastNative() { + constexpr uint32_t mask = kAccFastNative | kAccNative; return (GetAccessFlags() & mask) == mask; } - bool IsAbstract() SHARED_REQUIRES(Locks::mutator_lock_) { + bool IsAbstract() { return (GetAccessFlags() & kAccAbstract) != 0; } - bool IsSynthetic() SHARED_REQUIRES(Locks::mutator_lock_) { + bool IsSynthetic() { return (GetAccessFlags() & kAccSynthetic) != 0; } bool IsProxyMethod() SHARED_REQUIRES(Locks::mutator_lock_); - bool IsPreverified() SHARED_REQUIRES(Locks::mutator_lock_) { + bool IsPreverified() { return (GetAccessFlags() & kAccPreverified) != 0; } - void SetPreverified() SHARED_REQUIRES(Locks::mutator_lock_) { + void SetPreverified() { DCHECK(!IsPreverified()); SetAccessFlags(GetAccessFlags() | kAccPreverified); } @@ -404,7 +407,7 @@ class ArtMethod FINAL { return GetNativePointer(EntryPointFromJniOffset(pointer_size), pointer_size); } - void SetEntryPointFromJni(const void* entrypoint) SHARED_REQUIRES(Locks::mutator_lock_) { + void SetEntryPointFromJni(const void* entrypoint) { DCHECK(IsNative()); SetEntryPointFromJniPtrSize(entrypoint, sizeof(void*)); }