summaryrefslogtreecommitdiff
path: root/compiler/optimizing
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/optimizing')
-rw-r--r--compiler/optimizing/builder.cc10
-rw-r--r--compiler/optimizing/graph_visualizer.cc5
-rw-r--r--compiler/optimizing/instruction_simplifier.cc23
-rw-r--r--compiler/optimizing/nodes.h8
-rw-r--r--compiler/optimizing/ssa_builder.cc10
5 files changed, 40 insertions, 16 deletions
diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc
index e19e74f37a..7ae405ab3a 100644
--- a/compiler/optimizing/builder.cc
+++ b/compiler/optimizing/builder.cc
@@ -1693,8 +1693,14 @@ void HGraphBuilder::BuildPackedSwitch(const Instruction& instruction, uint32_t d
} else {
// Chained cmp-and-branch, starting from starting_key.
for (size_t i = 1; i <= num_entries; i++) {
- BuildSwitchCaseHelper(instruction, i, i == num_entries, table, value,
- starting_key + i - 1, table.GetEntryAt(i), dex_pc);
+ BuildSwitchCaseHelper(instruction,
+ i,
+ i == num_entries,
+ table,
+ value,
+ starting_key + i - 1,
+ table.GetEntryAt(i),
+ dex_pc);
}
}
}
diff --git a/compiler/optimizing/graph_visualizer.cc b/compiler/optimizing/graph_visualizer.cc
index d05c514912..2c6c3b726a 100644
--- a/compiler/optimizing/graph_visualizer.cc
+++ b/compiler/optimizing/graph_visualizer.cc
@@ -374,6 +374,11 @@ class HGraphVisualizerPrinter : public HGraphDelegateVisitor {
<< instance_of->MustDoNullCheck() << std::noboolalpha;
}
+ void VisitArraySet(HArraySet* array_set) OVERRIDE {
+ StartAttributeStream("value_can_be_null") << std::boolalpha
+ << array_set->GetValueCanBeNull() << std::noboolalpha;
+ }
+
void VisitInvoke(HInvoke* invoke) OVERRIDE {
StartAttributeStream("dex_file_index") << invoke->GetDexMethodIndex();
StartAttributeStream("method_name") << PrettyMethod(
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc
index 0ac26de674..30dc9b303a 100644
--- a/compiler/optimizing/instruction_simplifier.cc
+++ b/compiler/optimizing/instruction_simplifier.cc
@@ -71,7 +71,8 @@ class InstructionSimplifierVisitor : public HGraphVisitor {
void VisitXor(HXor* instruction) OVERRIDE;
void VisitInstanceOf(HInstanceOf* instruction) OVERRIDE;
void VisitFakeString(HFakeString* fake_string) OVERRIDE;
- bool IsDominatedByInputNullCheck(HInstruction* instr);
+
+ bool CanEnsureNotNullAt(HInstruction* instr, HInstruction* at) const;
OptimizingCompilerStats* stats_;
bool simplification_occurred_ = false;
@@ -187,14 +188,18 @@ void InstructionSimplifierVisitor::VisitNullCheck(HNullCheck* null_check) {
}
}
-bool InstructionSimplifierVisitor::IsDominatedByInputNullCheck(HInstruction* instr) {
- HInstruction* input = instr->InputAt(0);
+bool InstructionSimplifierVisitor::CanEnsureNotNullAt(HInstruction* input, HInstruction* at) const {
+ if (!input->CanBeNull()) {
+ return true;
+ }
+
for (HUseIterator<HInstruction*> it(input->GetUses()); !it.Done(); it.Advance()) {
HInstruction* use = it.Current()->GetUser();
- if (use->IsNullCheck() && use->StrictlyDominates(instr)) {
+ if (use->IsNullCheck() && use->StrictlyDominates(at)) {
return true;
}
}
+
return false;
}
@@ -231,7 +236,7 @@ static bool TypeCheckHasKnownOutcome(HLoadClass* klass, HInstruction* object, bo
void InstructionSimplifierVisitor::VisitCheckCast(HCheckCast* check_cast) {
HInstruction* object = check_cast->InputAt(0);
- if (!object->CanBeNull() || IsDominatedByInputNullCheck(check_cast)) {
+ if (CanEnsureNotNullAt(object, check_cast)) {
check_cast->ClearMustDoNullCheck();
}
@@ -267,7 +272,7 @@ void InstructionSimplifierVisitor::VisitCheckCast(HCheckCast* check_cast) {
void InstructionSimplifierVisitor::VisitInstanceOf(HInstanceOf* instruction) {
HInstruction* object = instruction->InputAt(0);
bool can_be_null = true;
- if (!object->CanBeNull() || IsDominatedByInputNullCheck(instruction)) {
+ if (CanEnsureNotNullAt(object, instruction)) {
can_be_null = false;
instruction->ClearMustDoNullCheck();
}
@@ -305,14 +310,14 @@ void InstructionSimplifierVisitor::VisitInstanceOf(HInstanceOf* instruction) {
void InstructionSimplifierVisitor::VisitInstanceFieldSet(HInstanceFieldSet* instruction) {
if ((instruction->GetValue()->GetType() == Primitive::kPrimNot)
- && !instruction->GetValue()->CanBeNull()) {
+ && CanEnsureNotNullAt(instruction->GetValue(), instruction)) {
instruction->ClearValueCanBeNull();
}
}
void InstructionSimplifierVisitor::VisitStaticFieldSet(HStaticFieldSet* instruction) {
if ((instruction->GetValue()->GetType() == Primitive::kPrimNot)
- && !instruction->GetValue()->CanBeNull()) {
+ && CanEnsureNotNullAt(instruction->GetValue(), instruction)) {
instruction->ClearValueCanBeNull();
}
}
@@ -437,7 +442,7 @@ void InstructionSimplifierVisitor::VisitArraySet(HArraySet* instruction) {
instruction->ClearNeedsTypeCheck();
}
- if (!value->CanBeNull()) {
+ if (CanEnsureNotNullAt(value, instruction)) {
instruction->ClearValueCanBeNull();
}
}
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h
index b19726d3ba..486968cf9e 100644
--- a/compiler/optimizing/nodes.h
+++ b/compiler/optimizing/nodes.h
@@ -2408,7 +2408,9 @@ class HCurrentMethod : public HExpression<0> {
// will be the block containing the next Dex opcode.
class HPackedSwitch : public HTemplateInstruction<1> {
public:
- HPackedSwitch(int32_t start_value, uint32_t num_entries, HInstruction* input,
+ HPackedSwitch(int32_t start_value,
+ uint32_t num_entries,
+ HInstruction* input,
uint32_t dex_pc = kNoDexPc)
: HTemplateInstruction(SideEffects::None(), dex_pc),
start_value_(start_value),
@@ -2429,8 +2431,8 @@ class HPackedSwitch : public HTemplateInstruction<1> {
DECLARE_INSTRUCTION(PackedSwitch);
private:
- int32_t start_value_;
- uint32_t num_entries_;
+ const int32_t start_value_;
+ const uint32_t num_entries_;
DISALLOW_COPY_AND_ASSIGN(HPackedSwitch);
};
diff --git a/compiler/optimizing/ssa_builder.cc b/compiler/optimizing/ssa_builder.cc
index ad8c682b3a..fb11d76320 100644
--- a/compiler/optimizing/ssa_builder.cc
+++ b/compiler/optimizing/ssa_builder.cc
@@ -145,8 +145,14 @@ void DeadPhiHandling::VisitBasicBlock(HBasicBlock* block) {
if (phi->IsDead() && phi->HasEnvironmentUses()) {
phi->SetLive();
if (block->IsLoopHeader()) {
- // Give a type to the loop phi, to guarantee convergence of the algorithm.
- phi->SetType(phi->InputAt(0)->GetType());
+ // Give a type to the loop phi to guarantee convergence of the algorithm.
+ // Note that the dead phi may already have a type if it is an equivalent
+ // generated for a typed LoadLocal. In that case we do not change the
+ // type because it could lead to an unsupported PrimNot/Float/Double ->
+ // PrimInt/Long transition and create same type equivalents.
+ if (phi->GetType() == Primitive::kPrimVoid) {
+ phi->SetType(phi->InputAt(0)->GetType());
+ }
AddToWorklist(phi);
} else {
// Because we are doing a reverse post order visit, all inputs of