diff options
Diffstat (limited to 'compiler/optimizing')
| -rw-r--r-- | compiler/optimizing/inliner.cc | 40 | ||||
| -rw-r--r-- | compiler/optimizing/inliner.h | 4 |
2 files changed, 28 insertions, 16 deletions
diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc index 30b47ef65b..fcd899ed1c 100644 --- a/compiler/optimizing/inliner.cc +++ b/compiler/optimizing/inliner.cc @@ -204,6 +204,13 @@ bool HInliner::Run() { } } + if (run_extra_type_propagation_) { + ReferenceTypePropagation rtp_fixup(graph_, + outer_compilation_unit_.GetDexCache(), + /* is_first_run= */ false); + rtp_fixup.Run(); + } + // We return true if we either inlined at least one method, or we marked one of our methods as // always throwing. // To check if we added an always throwing method we can either: @@ -477,6 +484,17 @@ bool HInliner::TryInline(HInvoke* invoke_instruction) { receiver = receiver->InputAt(0); } receiver_info = receiver->GetReferenceTypeInfo(); + if (!receiver_info.IsValid()) { + // We have to run the extra type propagation now as we are requiring the RTI. + DCHECK(run_extra_type_propagation_); + run_extra_type_propagation_ = false; + ReferenceTypePropagation rtp_fixup(graph_, + outer_compilation_unit_.GetDexCache(), + /* is_first_run= */ false); + rtp_fixup.Run(); + receiver_info = receiver->GetReferenceTypeInfo(); + } + DCHECK(receiver_info.IsValid()) << "Invalid RTI for " << receiver->DebugName(); if (invoke_instruction->IsInvokeStaticOrDirect()) { actual_method = invoke_instruction->GetResolvedMethod(); @@ -879,12 +897,9 @@ bool HInliner::TryInlineMonomorphicCall( invoke_instruction, /* with_deoptimization= */ true); - // Run type propagation to get the guard typed, and eventually propagate the + // Lazily run type propagation to get the guard typed, and eventually propagate the // type of the receiver. - ReferenceTypePropagation rtp_fixup(graph_, - outer_compilation_unit_.GetDexCache(), - /* is_first_run= */ false); - rtp_fixup.Run(); + run_extra_type_propagation_ = true; MaybeRecordStat(stats_, MethodCompilationStat::kInlinedMonomorphicCall); return true; @@ -1102,11 +1117,8 @@ bool HInliner::TryInlinePolymorphicCall( MaybeRecordStat(stats_, MethodCompilationStat::kInlinedPolymorphicCall); - // Run type propagation to get the guards typed. - ReferenceTypePropagation rtp_fixup(graph_, - outer_compilation_unit_.GetDexCache(), - /* is_first_run= */ false); - rtp_fixup.Run(); + // Lazily run type propagation to get the guards typed. + run_extra_type_propagation_ = true; return true; } @@ -1295,12 +1307,8 @@ bool HInliner::TryInlinePolymorphicCallToSameTarget( deoptimize->SetReferenceTypeInfo(receiver->GetReferenceTypeInfo()); } - // Run type propagation to get the guard typed. - ReferenceTypePropagation rtp_fixup(graph_, - outer_compilation_unit_.GetDexCache(), - /* is_first_run= */ false); - rtp_fixup.Run(); - + // Lazily run type propagation to get the guard typed. + run_extra_type_propagation_ = true; MaybeRecordStat(stats_, MethodCompilationStat::kInlinedPolymorphicCall); LOG_SUCCESS() << "Inlined same polymorphic target " << actual_method->PrettyMethod(); diff --git a/compiler/optimizing/inliner.h b/compiler/optimizing/inliner.h index a001404268..48600543c6 100644 --- a/compiler/optimizing/inliner.h +++ b/compiler/optimizing/inliner.h @@ -59,6 +59,7 @@ class HInliner : public HOptimization { depth_(depth), inlining_budget_(0), try_catch_inlining_allowed_(try_catch_inlining_allowed), + run_extra_type_propagation_(false), inline_stats_(nullptr) {} bool Run() override; @@ -341,6 +342,9 @@ class HInliner : public HOptimization { // States if we are allowing try catch inlining to occur at this particular instance of inlining. bool try_catch_inlining_allowed_; + // True if we need to run type propagation to type guards we inserted. + bool run_extra_type_propagation_; + // Used to record stats about optimizations on the inlined graph. // If the inlining is successful, these stats are merged to the caller graph's stats. OptimizingCompilerStats* inline_stats_; |