summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
author Santiago Aboy Solanes <solanes@google.com> 2022-09-29 18:03:13 +0100
committer Santiago Aboy Solanes <solanes@google.com> 2022-10-05 17:18:11 +0000
commit2979d53b8abf6ea4122783b58c35c82aea437000 (patch)
tree9e5fcf8510159c174f3e713295039bdf663ba646 /compiler
parente3a0f6c6239e5aa4544da4bdc90f6e8f999bce69 (diff)
Add compiler support for @NeverInline
This change sets methods as not inlineable if they are annotated with @NeverInline. This is done by adding a new method in dex_file_annotations.h that checks if a method is annotated, similar to @NeverCompile. Bug: 246530973 Change-Id: I5851fd85367f49d7af3201a7a3ef766f669401e9
Diffstat (limited to 'compiler')
-rw-r--r--compiler/optimizing/inliner.cc9
-rw-r--r--compiler/optimizing/optimizing_compiler_stats.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc
index cdd8fb2638..cfde561194 100644
--- a/compiler/optimizing/inliner.cc
+++ b/compiler/optimizing/inliner.cc
@@ -1379,6 +1379,15 @@ bool HInliner::IsInliningAllowed(ArtMethod* method, const CodeItemDataAccessor&
return false;
}
+ if (annotations::MethodIsNeverInline(*method->GetDexFile(),
+ method->GetClassDef(),
+ method->GetDexMethodIndex())) {
+ LOG_FAIL(stats_, MethodCompilationStat::kNotInlinedNeverInlineAnnotation)
+ << "Method " << method->PrettyMethod()
+ << " has the @NeverInline annotation so it won't be inlined";
+ return false;
+ }
+
return true;
}
diff --git a/compiler/optimizing/optimizing_compiler_stats.h b/compiler/optimizing/optimizing_compiler_stats.h
index 5e316ba403..18b3a60546 100644
--- a/compiler/optimizing/optimizing_compiler_stats.h
+++ b/compiler/optimizing/optimizing_compiler_stats.h
@@ -96,6 +96,7 @@ enum class MethodCompilationStat {
kNotInlinedTryCatchCallee,
kNotInlinedRegisterAllocator,
kNotInlinedCannotBuild,
+ kNotInlinedNeverInlineAnnotation,
kNotInlinedNotCompilable,
kNotInlinedNotVerified,
kNotInlinedCodeItem,