Mercurial > hg > graal-compiler
diff graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/IterativeConditionalEliminationPhase.java @ 16241:c6ebc1997a55
added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 26 Jun 2014 13:42:29 +0200 |
parents | 769fc3629f59 |
children | d9de8f5197e1 |
line wrap: on
line diff
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/IterativeConditionalEliminationPhase.java Thu Jun 26 10:50:28 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/IterativeConditionalEliminationPhase.java Thu Jun 26 13:42:29 2014 +0200 @@ -24,6 +24,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.graph.*; +import com.oracle.graal.graph.Graph.*; import com.oracle.graal.graph.spi.*; import com.oracle.graal.nodes.*; import com.oracle.graal.phases.*; @@ -43,24 +44,22 @@ @Override protected void run(StructuredGraph graph, PhaseContext context) { ConditionalEliminationPhase eliminate = new ConditionalEliminationPhase(context.getMetaAccess()); - HashSetNodeChangeListener listener = new HashSetNodeChangeListener(); + HashSetNodeEventListener listener = new HashSetNodeEventListener.ExceptForAddedNodes(); int count = 0; while (true) { - graph.trackInputChange(listener); - graph.trackUsagesDroppedZero(listener); - eliminate.apply(graph); - graph.stopTrackingInputChange(); - graph.stopTrackingUsagesDroppedZero(); - if (listener.getChangedNodes().isEmpty()) { + try (NodeEventScope nes = graph.trackNodeEvents(listener)) { + eliminate.apply(graph); + } + if (listener.getNodes().isEmpty()) { break; } for (Node node : graph.getNodes()) { if (node instanceof Simplifiable) { - listener.getChangedNodes().add(node); + listener.getNodes().add(node); } } - canonicalizer.applyIncremental(graph, context, listener.getChangedNodes()); - listener.getChangedNodes().clear(); + canonicalizer.applyIncremental(graph, context, listener.getNodes()); + listener.getNodes().clear(); if (++count > MAX_ITERATIONS) { throw new BailoutException("Number of iterations in ConditionalEliminationPhase phase exceeds " + MAX_ITERATIONS); }