# HG changeset patch # User Thomas Wuerthinger # Date 1376672830 -7200 # Node ID e4a1593cc6e4001c400a0930d6c7546750976b2a # Parent 07814c3b5dba81f0f755894b35a9bf266348de33 Search through tree of proxies for replacement anchor in ConditionalEliminationPhase. diff -r 07814c3b5dba -r e4a1593cc6e4 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java Fri Aug 16 19:05:04 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java Fri Aug 16 19:07:10 2013 +0200 @@ -34,6 +34,7 @@ import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.java.*; import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind; +import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; import com.oracle.graal.nodes.util.*; import com.oracle.graal.phases.*; @@ -489,15 +490,7 @@ boolean nonNull = state.isNonNull(object); GuardingNode replacementAnchor = null; if (nonNull) { - // Search for valid instanceof anchor. - for (InstanceOfNode instanceOfNode : object.usages().filter(InstanceOfNode.class)) { - if (instanceOfNode.type() == checkCast.type() && state.trueConditions.containsKey(instanceOfNode)) { - ValueNode v = state.trueConditions.get(instanceOfNode); - if (v instanceof GuardingNode) { - replacementAnchor = (GuardingNode) v; - } - } - } + replacementAnchor = searchAnchor(GraphUtil.unproxify(object), type); } ValueAnchorNode anchor = null; if (replacementAnchor == null) { @@ -608,5 +601,34 @@ } } + + private GuardingNode searchAnchor(ValueNode value, ResolvedJavaType type) { + for (Node n : value.usages()) { + if (n instanceof InstanceOfNode) { + InstanceOfNode instanceOfNode = (InstanceOfNode) n; + if (instanceOfNode.type() == type && state.trueConditions.containsKey(instanceOfNode)) { + ValueNode v = state.trueConditions.get(instanceOfNode); + if (v instanceof GuardingNode) { + return (GuardingNode) v; + } + } + } + } + + for (Node n : value.usages()) { + if (n instanceof ValueProxy) { + ValueProxy proxyNode = (ValueProxy) n; + if (proxyNode.getOriginalValue() == value) { + GuardingNode result = searchAnchor((ValueNode) n, type); + if (result != null) { + return result; + } + } + + } + } + + return null; + } } }