diff options
author | 2018-05-16 11:37:41 +0100 | |
---|---|---|
committer | 2018-05-16 13:50:29 +0100 | |
commit | d147e2fb824a92acb9cd86bd92d3f1c137d488c5 (patch) | |
tree | ff228859971532ed6cc8f49baf387fa957fa923f /compiler/optimizing | |
parent | 4972754f2327dc9c443f2c0c70e5a6528973c435 (diff) |
Don't compile methods with irreducible loops and String.<init>.
The current code doesn't work when dex register aliases.
bug: 78493232
Test: m
Change-Id: I1c296f6dc914388844ae5eb7d84f3bd7d81e1f87
Diffstat (limited to 'compiler/optimizing')
-rw-r--r-- | compiler/optimizing/instruction_builder.cc | 10 | ||||
-rw-r--r-- | compiler/optimizing/optimizing_compiler_stats.h | 1 |
2 files changed, 9 insertions, 2 deletions
diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc index 9647dd5d41..a36e80379d 100644 --- a/compiler/optimizing/instruction_builder.cc +++ b/compiler/optimizing/instruction_builder.cc @@ -1360,9 +1360,15 @@ bool HInstructionBuilder::HandleStringInit(HInvoke* invoke, if (arg_this->IsNewInstance()) { ssa_builder_->AddUninitializedString(arg_this->AsNewInstance()); } else { + // The only reason a HPhi can flow in a String.<init> is when there is an + // irreducible loop, which will create HPhi for all dex registers at loop entry. DCHECK(arg_this->IsPhi()); - // NewInstance is not the direct input of the StringFactory call. It might - // be redundant but optimizing this case is not worth the effort. + DCHECK(graph_->HasIrreducibleLoops()); + // Don't bother compiling a method in that situation. While we could look at all + // phis related to the HNewInstance, it's not worth the trouble. + MaybeRecordStat(compilation_stats_, + MethodCompilationStat::kNotCompiledIrreducibleAndStringInit); + return false; } // Walk over all vregs and replace any occurrence of `arg_this` with `invoke`. diff --git a/compiler/optimizing/optimizing_compiler_stats.h b/compiler/optimizing/optimizing_compiler_stats.h index 9a26f2f6c4..f246228074 100644 --- a/compiler/optimizing/optimizing_compiler_stats.h +++ b/compiler/optimizing/optimizing_compiler_stats.h @@ -50,6 +50,7 @@ enum class MethodCompilationStat { kNotCompiledThrowCatchLoop, kNotCompiledAmbiguousArrayOp, kNotCompiledHugeMethod, + kNotCompiledIrreducibleAndStringInit, kNotCompiledLargeMethodNoBranches, kNotCompiledMalformedOpcode, kNotCompiledNoCodegen, |