summaryrefslogtreecommitdiff
path: root/compiler/optimizing/builder.cc
diff options
context:
space:
mode:
author David Brazdil <dbrazdil@google.com> 2016-01-08 17:37:10 +0000
committer David Brazdil <dbrazdil@google.com> 2016-01-14 16:22:13 +0000
commit6de1938e562b0d06e462512dd806166e754035ea (patch)
treef9df086a73860c20768d17ff7bc5be4139567941 /compiler/optimizing/builder.cc
parentf5b84ee14a3bc578f799a39dca1ae512b49356ea (diff)
ART: Remove incorrect HFakeString optimization
Simplification of HFakeString assumes that it cannot be used until String.<init> is called which is not true and causes different behaviour between the compiler and the interpreter. This patch removes the optimization together with the HFakeString instruction. Instead, HNewInstance is generated and an empty String allocated until it is replaced with the result of the StringFactory call. This is consistent with the behaviour of the interpreter but is too conservative. A follow-up CL will attempt to optimize out the initial allocation when possible. Bug: 26457745 Bug: 26486014 Change-Id: I7139e37ed00a880715bfc234896a930fde670c44
Diffstat (limited to 'compiler/optimizing/builder.cc')
-rw-r--r--compiler/optimizing/builder.cc48
1 files changed, 5 insertions, 43 deletions
diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc
index 1af684683b..37218139fb 100644
--- a/compiler/optimizing/builder.cc
+++ b/compiler/optimizing/builder.cc
@@ -1271,44 +1271,14 @@ bool HGraphBuilder::HandleStringInit(HInvoke* invoke,
// Add move-result for StringFactory method.
uint32_t orig_this_reg = is_range ? register_index : args[0];
- HInstruction* fake_string = LoadLocal(orig_this_reg, Primitive::kPrimNot, invoke->GetDexPc());
- invoke->SetArgumentAt(argument_index, fake_string);
+ HInstruction* new_instance = LoadLocal(orig_this_reg, Primitive::kPrimNot, invoke->GetDexPc());
+ invoke->SetArgumentAt(argument_index, new_instance);
current_block_->AddInstruction(invoke);
- PotentiallySimplifyFakeString(orig_this_reg, invoke->GetDexPc(), invoke);
latest_result_ = invoke;
-
return true;
}
-void HGraphBuilder::PotentiallySimplifyFakeString(uint16_t original_dex_register,
- uint32_t dex_pc,
- HInvoke* actual_string) {
- if (!graph_->IsDebuggable()) {
- // Notify that we cannot compile with baseline. The dex registers aliasing
- // with `original_dex_register` will be handled when we optimize
- // (see HInstructionSimplifer::VisitFakeString).
- can_use_baseline_for_string_init_ = false;
- return;
- }
- const VerifiedMethod* verified_method =
- compiler_driver_->GetVerifiedMethod(dex_file_, dex_compilation_unit_->GetDexMethodIndex());
- if (verified_method != nullptr) {
- UpdateLocal(original_dex_register, actual_string, dex_pc);
- const SafeMap<uint32_t, std::set<uint32_t>>& string_init_map =
- verified_method->GetStringInitPcRegMap();
- auto map_it = string_init_map.find(dex_pc);
- if (map_it != string_init_map.end()) {
- for (uint32_t reg : map_it->second) {
- HInstruction* load_local = LoadLocal(original_dex_register, Primitive::kPrimNot, dex_pc);
- UpdateLocal(reg, load_local, dex_pc);
- }
- }
- } else {
- can_use_baseline_for_string_init_ = false;
- }
-}
-
static Primitive::Type GetFieldAccessType(const DexFile& dex_file, uint16_t field_index) {
const DexFile::FieldId& field_id = dex_file.GetFieldId(field_index);
const char* type = dex_file.GetFieldTypeDescriptor(field_id);
@@ -2698,18 +2668,10 @@ bool HGraphBuilder::AnalyzeDexInstruction(const Instruction& instruction, uint32
}
case Instruction::NEW_INSTANCE: {
- uint16_t type_index = instruction.VRegB_21c();
- if (compiler_driver_->IsStringTypeIndex(type_index, dex_file_)) {
- int32_t register_index = instruction.VRegA();
- HFakeString* fake_string = new (arena_) HFakeString(dex_pc);
- current_block_->AddInstruction(fake_string);
- UpdateLocal(register_index, fake_string, dex_pc);
- } else {
- if (!BuildNewInstance(type_index, dex_pc)) {
- return false;
- }
- UpdateLocal(instruction.VRegA(), current_block_->GetLastInstruction(), dex_pc);
+ if (!BuildNewInstance(instruction.VRegB_21c(), dex_pc)) {
+ return false;
}
+ UpdateLocal(instruction.VRegA(), current_block_->GetLastInstruction(), dex_pc);
break;
}