diff options
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/optimizing/graph_checker.cc | 24 | ||||
-rw-r--r-- | compiler/optimizing/graph_checker.h | 4 | ||||
-rw-r--r-- | compiler/optimizing/reference_type_propagation.cc | 9 |
3 files changed, 37 insertions, 0 deletions
diff --git a/compiler/optimizing/graph_checker.cc b/compiler/optimizing/graph_checker.cc index fd28f0b..44c4101 100644 --- a/compiler/optimizing/graph_checker.cc +++ b/compiler/optimizing/graph_checker.cc @@ -253,6 +253,30 @@ void GraphChecker::VisitInvokeStaticOrDirect(HInvokeStaticOrDirect* invoke) { } } +void GraphChecker::VisitCheckCast(HCheckCast* check) { + VisitInstruction(check); + HInstruction* input = check->InputAt(1); + if (!input->IsLoadClass()) { + AddError(StringPrintf("%s:%d expects a HLoadClass as second input, not %s:%d.", + check->DebugName(), + check->GetId(), + input->DebugName(), + input->GetId())); + } +} + +void GraphChecker::VisitInstanceOf(HInstanceOf* instruction) { + VisitInstruction(instruction); + HInstruction* input = instruction->InputAt(1); + if (!input->IsLoadClass()) { + AddError(StringPrintf("%s:%d expects a HLoadClass as second input, not %s:%d.", + instruction->DebugName(), + instruction->GetId(), + input->DebugName(), + input->GetId())); + } +} + void SSAChecker::VisitBasicBlock(HBasicBlock* block) { super_type::VisitBasicBlock(block); diff --git a/compiler/optimizing/graph_checker.h b/compiler/optimizing/graph_checker.h index b4314da..9284bb7 100644 --- a/compiler/optimizing/graph_checker.h +++ b/compiler/optimizing/graph_checker.h @@ -48,6 +48,10 @@ class GraphChecker : public HGraphDelegateVisitor { // Check that the HasBoundsChecks() flag is set for bounds checks. void VisitBoundsCheck(HBoundsCheck* check) OVERRIDE; + // Check that HCheckCast and HInstanceOf have HLoadClass as second input. + void VisitCheckCast(HCheckCast* check) OVERRIDE; + void VisitInstanceOf(HInstanceOf* check) OVERRIDE; + // Was the last visit of the graph valid? bool IsValid() const { return errors_.empty(); diff --git a/compiler/optimizing/reference_type_propagation.cc b/compiler/optimizing/reference_type_propagation.cc index e93e061..302366e 100644 --- a/compiler/optimizing/reference_type_propagation.cc +++ b/compiler/optimizing/reference_type_propagation.cc @@ -130,6 +130,15 @@ void ReferenceTypePropagation::BoundTypeForIfInstanceOf(HBasicBlock* block) { HBoundType* bound_type = nullptr; HInstruction* obj = instanceOf->InputAt(0); + if (obj->GetReferenceTypeInfo().IsExact() && !obj->IsPhi()) { + // This method is being called while doing a fixed-point calculation + // over phis. Non-phis instruction whose type is already known do + // not need to be bound to another type. + // Not that this also prevents replacing `HLoadClass` with a `HBoundType`. + // `HCheckCast` and `HInstanceOf` expect a `HLoadClass` as a second + // input. + return; + } for (HUseIterator<HInstruction*> it(obj->GetUses()); !it.Done(); it.Advance()) { HInstruction* user = it.Current()->GetUser(); if (instanceOfTrueBlock->Dominates(user->GetBlock())) { |