Cleanup work for @NeverCompile in art
This change is a followup to aosp/1897910. It makes a style change to
the list of parameters provided to MethodIsNeverCompile, and adds a
clause for abstract methods when calling it in the class linker.
Bug: 197753440
Test: Checked that the behavior of @NeverCompile is maintained by
inspecting services.odex after annotating specific methods.
Change-Id: I91969898a635c71656451e59ad22940eb78143f6
diff --git a/dex2oat/driver/compiler_driver.cc b/dex2oat/driver/compiler_driver.cc
index 0f4638d..caf8753 100644
--- a/dex2oat/driver/compiler_driver.cc
+++ b/dex2oat/driver/compiler_driver.cc
@@ -487,7 +487,8 @@
}
} else if ((access_flags & kAccAbstract) != 0) {
// Abstract methods don't have code.
- } else if (annotations::MethodIsNeverCompile(dex_file, dex_file.GetClassDef(class_def_idx),
+ } else if (annotations::MethodIsNeverCompile(dex_file,
+ dex_file.GetClassDef(class_def_idx),
method_idx)) {
// Method is annotated with @NeverCompile and should not be compiled.
} else {
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 3f5b09f..d2ab81e 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -3672,8 +3672,8 @@
// Check if the native method is annotated with @FastNative or @CriticalNative.
access_flags |= annotations::GetNativeMethodAnnotationAccessFlags(
dex_file, dst->GetClassDef(), dex_method_idx);
- }
- if (annotations::MethodIsNeverCompile(dex_file, dst->GetClassDef(), dex_method_idx)) {
+ } else if ((access_flags & kAccAbstract) == 0u &&
+ annotations::MethodIsNeverCompile(dex_file, dst->GetClassDef(), dex_method_idx)) {
access_flags |= kAccCompileDontBother;
}
dst->SetAccessFlags(access_flags);