ART: Consider clinit elimination for inlining
Currently inliner rejects inlining method if class initialization is needed.
However, if it has been proven already that it was done, then inlining
can safely proceed.
Change-Id: Iaf1638fcfffff1bcf66010dc39090c77e009a1bb
Signed-off-by: Razvan A Lupusoru <razvan.a.lupusoru@intel.com>
diff --git a/compiler/dex/mir_optimization.cc b/compiler/dex/mir_optimization.cc
index 7ac878f..fdabc3e 100644
--- a/compiler/dex/mir_optimization.cc
+++ b/compiler/dex/mir_optimization.cc
@@ -1360,11 +1360,20 @@
if (!method_info.FastPath()) {
continue;
}
+
InvokeType sharp_type = method_info.GetSharpType();
- if ((sharp_type != kDirect) &&
- (sharp_type != kStatic || method_info.NeedsClassInitialization())) {
+ if ((sharp_type != kDirect) && (sharp_type != kStatic)) {
continue;
}
+
+ if (sharp_type == kStatic) {
+ bool needs_clinit = method_info.NeedsClassInitialization() &&
+ ((mir->optimization_flags & MIR_IGNORE_CLINIT_CHECK) == 0);
+ if (needs_clinit) {
+ continue;
+ }
+ }
+
DCHECK(cu_->compiler_driver->GetMethodInlinerMap() != nullptr);
MethodReference target = method_info.GetTargetMethod();
if (cu_->compiler_driver->GetMethodInlinerMap()->GetMethodInliner(target.dex_file)