summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Santiago Aboy Solanes <solanes@google.com> 2024-11-05 13:57:14 +0000
committer Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-11-08 14:32:49 +0000
commit8cb3e137f7ee567cfb885fcd6345e27e4b99e4a5 (patch)
tree6518a9017a4049b9e77949dd025f7cb3d51c01e9
parent8cbf793d000b2598dbb3be58fb8f3288543cd7a4 (diff)
Check that the API level is set correctly for all intrinsics
Remove the need of kIsDebugBuild for the DCHECK to take place. Bug: 376736704 Test: art/test/testrunner/testrunner.py --host --64 -b --optimizing Change-Id: Ib5ec7d7afca1150a85d5a204c3fd26c5222382cb
-rw-r--r--runtime/art_method.cc73
1 files changed, 34 insertions, 39 deletions
diff --git a/runtime/art_method.cc b/runtime/art_method.cc
index 8c0c7f56cc..d2b378f746 100644
--- a/runtime/art_method.cc
+++ b/runtime/art_method.cc
@@ -723,52 +723,47 @@ void ArtMethod::SetIntrinsic(Intrinsics intrinsic) {
// classes. We don't set kHasSingleImplementation for those methods.
DCHECK(IsStatic() || IsFinal() || GetDeclaringClass()->IsFinal()) <<
"Potential conflict with kAccSingleImplementation";
- static const int kAccFlagsShift = CTZ(kAccIntrinsicBits);
+ static constexpr int kAccFlagsShift = CTZ(kAccIntrinsicBits);
uint32_t intrinsic_u32 = enum_cast<uint32_t>(intrinsic);
DCHECK_LE(intrinsic_u32, kAccIntrinsicBits >> kAccFlagsShift);
uint32_t intrinsic_bits = intrinsic_u32 << kAccFlagsShift;
uint32_t new_value = (GetAccessFlags() & ~kAccIntrinsicBits) | kAccIntrinsic | intrinsic_bits;
- if (kIsDebugBuild) {
- uint32_t java_flags = (GetAccessFlags() & kAccJavaFlagsMask);
- bool is_constructor = IsConstructor();
- bool is_synchronized = IsSynchronized();
- bool skip_access_checks = SkipAccessChecks();
- bool is_fast_native = IsFastNative();
- bool is_critical_native = IsCriticalNative();
- bool is_copied = IsCopied();
- bool is_miranda = IsMiranda();
- bool is_default = IsDefault();
- bool is_default_conflict = IsDefaultConflicting();
- bool is_compilable = IsCompilable();
- bool must_count_locks = MustCountLocks();
- // Recompute flags instead of getting them from the current access flags because
- // access flags may have been changed to deduplicate warning messages (b/129063331).
- uint32_t hiddenapi_flags = hiddenapi::CreateRuntimeFlags(this);
- SetAccessFlags(new_value);
- DCHECK_EQ(java_flags, (GetAccessFlags() & kAccJavaFlagsMask));
- DCHECK_EQ(is_constructor, IsConstructor());
- DCHECK_EQ(is_synchronized, IsSynchronized());
- DCHECK_EQ(skip_access_checks, SkipAccessChecks());
- DCHECK_EQ(is_fast_native, IsFastNative());
- DCHECK_EQ(is_critical_native, IsCriticalNative());
- DCHECK_EQ(is_copied, IsCopied());
- DCHECK_EQ(is_miranda, IsMiranda());
- DCHECK_EQ(is_default, IsDefault());
- DCHECK_EQ(is_default_conflict, IsDefaultConflicting());
- DCHECK_EQ(is_compilable, IsCompilable());
- DCHECK_EQ(must_count_locks, MustCountLocks());
- // Only DCHECK that we have preserved the hidden API access flags if the
- // original method was not in the SDK list. This is because the core image
- // does not have the access flags set (b/77733081).
- if ((hiddenapi_flags & kAccHiddenapiBits) != kAccPublicApi) {
- DCHECK_EQ(hiddenapi_flags, hiddenapi::GetRuntimeFlags(this)) << PrettyMethod();
- }
- } else {
- SetAccessFlags(new_value);
- }
+ // These flags shouldn't be overridden by setting the intrinsic.
+ uint32_t java_flags = (GetAccessFlags() & kAccJavaFlagsMask);
+ bool is_constructor = IsConstructor();
+ bool is_synchronized = IsSynchronized();
+ bool skip_access_checks = SkipAccessChecks();
+ bool is_fast_native = IsFastNative();
+ bool is_critical_native = IsCriticalNative();
+ bool is_copied = IsCopied();
+ bool is_miranda = IsMiranda();
+ bool is_default = IsDefault();
+ bool is_default_conflict = IsDefaultConflicting();
+ bool is_compilable = IsCompilable();
+ bool must_count_locks = MustCountLocks();
+ // Recompute flags instead of getting them from the current access flags because
+ // access flags may have been changed to deduplicate warning messages (b/129063331).
+ uint32_t hiddenapi_flags = hiddenapi::CreateRuntimeFlags(this);
+
+ SetAccessFlags(new_value);
// Intrinsics are considered hot from the first call.
SetHotCounter();
+
+ // DCHECK that the flags weren't overridden.
+ DCHECK_EQ(java_flags, (GetAccessFlags() & kAccJavaFlagsMask));
+ DCHECK_EQ(is_constructor, IsConstructor());
+ DCHECK_EQ(is_synchronized, IsSynchronized());
+ DCHECK_EQ(skip_access_checks, SkipAccessChecks());
+ DCHECK_EQ(is_fast_native, IsFastNative());
+ DCHECK_EQ(is_critical_native, IsCriticalNative());
+ DCHECK_EQ(is_copied, IsCopied());
+ DCHECK_EQ(is_miranda, IsMiranda());
+ DCHECK_EQ(is_default, IsDefault());
+ DCHECK_EQ(is_default_conflict, IsDefaultConflicting());
+ DCHECK_EQ(is_compilable, IsCompilable());
+ DCHECK_EQ(must_count_locks, MustCountLocks());
+ DCHECK_EQ(hiddenapi_flags, hiddenapi::GetRuntimeFlags(this)) << PrettyMethod();
}
void ArtMethod::SetNotIntrinsic() {