Mercurial > hg > graal-jvmci-8
changeset 18395:1cd104505b61
ConditionalElimination: use GuardingNode interface where possible
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 12 Nov 2014 10:53:37 +0100 |
parents | 973c6551dfd8 |
children | 05fde207f06c |
files | graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java |
diffstat | 1 files changed, 26 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java Mon Sep 22 10:27:52 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java Wed Nov 12 10:53:37 2014 +0100 @@ -104,8 +104,8 @@ private Map<ValueNode, ResolvedJavaType> knownTypes; private Set<ValueNode> knownNonNull; private Set<ValueNode> knownNull; - private Map<LogicNode, ValueNode> trueConditions; - private Map<LogicNode, ValueNode> falseConditions; + private Map<LogicNode, GuardingNode> trueConditions; + private Map<LogicNode, GuardingNode> falseConditions; private Map<ValueNode, GuardedStamp> valueConstraints; public State() { @@ -129,8 +129,8 @@ @Override public boolean merge(MergeNode merge, List<State> withStates) { Map<ValueNode, ResolvedJavaType> newKnownTypes = Node.newIdentityMap(); - Map<LogicNode, ValueNode> newTrueConditions = Node.newIdentityMap(); - Map<LogicNode, ValueNode> newFalseConditions = Node.newIdentityMap(); + Map<LogicNode, GuardingNode> newTrueConditions = Node.newIdentityMap(); + Map<LogicNode, GuardingNode> newFalseConditions = Node.newIdentityMap(); Map<ValueNode, GuardedStamp> newValueConstraints = Node.newIdentityMap(); Set<ValueNode> newKnownNull = Node.newSet(knownNull); @@ -156,12 +156,12 @@ } } - for (Map.Entry<LogicNode, ValueNode> entry : trueConditions.entrySet()) { + for (Map.Entry<LogicNode, GuardingNode> entry : trueConditions.entrySet()) { LogicNode check = entry.getKey(); - ValueNode guard = entry.getValue(); + GuardingNode guard = entry.getValue(); for (State other : withStates) { - ValueNode otherGuard = other.trueConditions.get(check); + GuardingNode otherGuard = other.trueConditions.get(check); if (otherGuard == null) { guard = null; break; @@ -174,12 +174,12 @@ newTrueConditions.put(check, guard); } } - for (Map.Entry<LogicNode, ValueNode> entry : falseConditions.entrySet()) { + for (Map.Entry<LogicNode, GuardingNode> entry : falseConditions.entrySet()) { LogicNode check = entry.getKey(); - ValueNode guard = entry.getValue(); + GuardingNode guard = entry.getValue(); for (State other : withStates) { - ValueNode otherGuard = other.falseConditions.get(check); + GuardingNode otherGuard = other.falseConditions.get(check); if (otherGuard == null) { guard = null; break; @@ -254,7 +254,7 @@ * Adds information about a condition. If isTrue is true then the condition is known to * hold, otherwise the condition is known not to hold. */ - public void addCondition(boolean isTrue, LogicNode condition, ValueNode anchor) { + public void addCondition(boolean isTrue, LogicNode condition, GuardingNode anchor) { if (isTrue) { if (!trueConditions.containsKey(condition)) { trueConditions.put(condition, anchor); @@ -352,7 +352,7 @@ super.finished(); } - private void registerCondition(boolean isTrue, LogicNode condition, ValueNode anchor) { + private void registerCondition(boolean isTrue, LogicNode condition, GuardingNode anchor) { if (!isTrue && condition instanceof ShortCircuitOrNode) { /* * We can only do this for fixed nodes, because floating guards will be registered @@ -476,7 +476,7 @@ if (testExistingGuard(guard)) { return true; } else { - ValueNode anchor = state.trueConditions.get(condition); + GuardingNode anchor = state.trueConditions.get(condition); if (anchor != null) { if (!guard.negated()) { eliminateGuard(guard, anchor); @@ -503,8 +503,8 @@ * @param guard The guard to eliminate. * @param anchor Node to replace the guard. */ - private void eliminateGuard(GuardNode guard, ValueNode anchor) { - guard.replaceAtUsages(anchor); + private void eliminateGuard(GuardNode guard, GuardingNode anchor) { + guard.replaceAtUsages(anchor.asNode()); metricGuardsRemoved.increment(); GraphUtil.killWithUnusedFloatingInputs(guard); } @@ -574,7 +574,7 @@ } private boolean testExistingGuard(GuardNode guard) { - ValueNode existingGuard = guard.negated() ? state.falseConditions.get(guard.condition()) : state.trueConditions.get(guard.condition()); + GuardingNode existingGuard = guard.negated() ? state.falseConditions.get(guard.condition()) : state.trueConditions.get(guard.condition()); if (existingGuard != null && existingGuard != guard) { eliminateGuard(guard, existingGuard); return true; @@ -694,9 +694,9 @@ } } else if (node instanceof FixedGuardNode) { FixedGuardNode guard = (FixedGuardNode) node; - ValueNode existingGuard = guard.isNegated() ? state.falseConditions.get(guard.condition()) : state.trueConditions.get(guard.condition()); + GuardingNode existingGuard = guard.isNegated() ? state.falseConditions.get(guard.condition()) : state.trueConditions.get(guard.condition()); if (existingGuard != null && existingGuard instanceof FixedGuardNode) { - guard.replaceAtUsages(existingGuard); + guard.replaceAtUsages(existingGuard.asNode()); guard.graph().removeFixed(guard); } else { registerCondition(!guard.isNegated(), guard.condition(), guard); @@ -729,7 +729,7 @@ } else if (node instanceof ConditionAnchorNode) { ConditionAnchorNode conditionAnchorNode = (ConditionAnchorNode) node; LogicNode condition = conditionAnchorNode.condition(); - ValueNode replacementAnchor = null; + GuardingNode replacementAnchor = null; if (conditionAnchorNode.isNegated()) { if (state.falseConditions.containsKey(condition)) { replacementAnchor = state.falseConditions.get(condition); @@ -740,7 +740,7 @@ } } if (replacementAnchor != null) { - conditionAnchorNode.replaceAtUsages(replacementAnchor); + conditionAnchorNode.replaceAtUsages(replacementAnchor.asNode()); conditionAnchorNode.graph().removeFixed(conditionAnchorNode); } } else if (node instanceof IfNode) { @@ -748,7 +748,7 @@ LogicNode compare = ifNode.condition(); LogicNode replacement = null; - ValueNode replacementAnchor = null; + GuardingNode replacementAnchor = null; BeginNode survivingSuccessor = null; if (state.trueConditions.containsKey(compare)) { replacement = trueConstant; @@ -772,7 +772,7 @@ if (replacement != null) { if (replacementAnchor != null && !(replacementAnchor instanceof BeginNode)) { - ValueAnchorNode anchor = graph.add(ValueAnchorNode.create(replacementAnchor)); + ValueAnchorNode anchor = graph.add(ValueAnchorNode.create(replacementAnchor.asNode())); graph.addBeforeFixed(ifNode, anchor); } for (Node n : survivingSuccessor.usages().snapshot()) { @@ -784,7 +784,7 @@ return; } // Rewire to the replacement anchor. - n.replaceFirstInput(survivingSuccessor, replacementAnchor); + n.replaceFirstInput(survivingSuccessor, replacementAnchor.asNode()); } } @@ -838,9 +838,9 @@ if (n instanceof InstanceOfNode) { InstanceOfNode instanceOfNode = (InstanceOfNode) n; if (instanceOfNode.type().equals(type) && state.trueConditions.containsKey(instanceOfNode)) { - ValueNode v = state.trueConditions.get(instanceOfNode); - if (v instanceof GuardingNode) { - return (GuardingNode) v; + GuardingNode v = state.trueConditions.get(instanceOfNode); + if (v != null) { + return v; } } }