ART: Add flag for ArtMethod class state checks
The checks, especially in GetAccessFlags, is expensive. To help
with running a debug build on devices, add a flag to be able to
turn the checks off.
Bug: 35644369
Test: m
Change-Id: I2a3db1a56986df8f4a8b2dc5bcb26e1bcaea0a24
diff --git a/runtime/art_method-inl.h b/runtime/art_method-inl.h
index 473d9cf..685e26c 100644
--- a/runtime/art_method-inl.h
+++ b/runtime/art_method-inl.h
@@ -55,8 +55,10 @@
if (kIsDebugBuild) {
if (!IsRuntimeMethod()) {
CHECK(result != nullptr) << this;
- CHECK(result->IsIdxLoaded() || result->IsErroneous())
- << result->GetStatus() << " " << result->PrettyClass();
+ if (kCheckDeclaringClassState) {
+ CHECK(result->IsIdxLoaded() || result->IsErroneous())
+ << result->GetStatus() << " " << result->PrettyClass();
+ }
} else {
CHECK(result == nullptr) << this;
}
@@ -89,7 +91,7 @@
template <ReadBarrierOption kReadBarrierOption>
inline uint32_t ArtMethod::GetAccessFlags() {
- if (kIsDebugBuild) {
+ if (kCheckDeclaringClassState) {
Thread* self = Thread::Current();
if (!Locks::mutator_lock_->IsSharedHeld(self)) {
if (self->IsThreadSuspensionAllowable()) {
@@ -118,8 +120,10 @@
}
inline uint32_t ArtMethod::GetDexMethodIndex() {
- DCHECK(IsRuntimeMethod() || GetDeclaringClass()->IsIdxLoaded() ||
- GetDeclaringClass()->IsErroneous());
+ if (kCheckDeclaringClassState) {
+ CHECK(IsRuntimeMethod() || GetDeclaringClass()->IsIdxLoaded() ||
+ GetDeclaringClass()->IsErroneous());
+ }
return GetDexMethodIndexUnchecked();
}
diff --git a/runtime/art_method.h b/runtime/art_method.h
index 99d7a49..cd1950c 100644
--- a/runtime/art_method.h
+++ b/runtime/art_method.h
@@ -53,6 +53,8 @@
class ArtMethod FINAL {
public:
+ static constexpr bool kCheckDeclaringClassState = kIsDebugBuild;
+
ArtMethod() : access_flags_(0), dex_code_item_offset_(0), dex_method_index_(0),
method_index_(0), hotness_count_(0) { }