diff options
author | Nicolas Geoffray <ngeoffray@google.com> | 2015-06-29 13:43:54 +0100 |
---|---|---|
committer | Nicolas Geoffray <ngeoffray@google.com> | 2015-06-29 22:12:48 +0100 |
commit | b7a4790e5a2884e62f6dc85aca1455b145e2a7db (patch) | |
tree | bf0a44cef7f95ceae58cec7835a01ef134867725 /compiler | |
parent | d735c41e95a5d89cc9dad0c78d7d052579d8bd41 (diff) | |
download | art-b7a4790e5a2884e62f6dc85aca1455b145e2a7db.zip art-b7a4790e5a2884e62f6dc85aca1455b145e2a7db.tar.gz art-b7a4790e5a2884e62f6dc85aca1455b145e2a7db.tar.bz2 |
Revert "Revert "Do not update the type of something we already know.""
This reverts commit 63107a804ce17db9789051e1fe310d99d1dae1cb.
bug:22116987
(cherry picked from commit f9a199571417b5a5a62d94d05a064077e14dd2c4)
Change-Id: Ia516f2cbce6d22df37f3a0854abdd0b54d3ea72d
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())) { |