Mercurial > hg > graal-jvmci-8
changeset 16344:6f70e0b85e91
Merge.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 01 Jul 2014 15:45:14 +0200 |
parents | a415b3990811 (diff) 2cc0fea0cff6 (current diff) |
children | d0c5f9bc7d98 |
files | |
diffstat | 7 files changed, 60 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/IfCanonicalizerTest.java Tue Jul 01 14:57:53 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/IfCanonicalizerTest.java Tue Jul 01 15:45:14 2014 +0200 @@ -203,6 +203,7 @@ new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), new Assumptions(false))); for (FrameState fs : param.usages().filter(FrameState.class).snapshot()) { fs.replaceFirstInput(param, null); + param.safeDelete(); } StructuredGraph referenceGraph = parse(REFERENCE_SNIPPET); assertEquals(referenceGraph, graph);
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Tue Jul 01 14:57:53 2014 +0200 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Tue Jul 01 15:45:14 2014 +0200 @@ -278,6 +278,14 @@ n.safeDelete(); } } + + // remove dead parameters + for (ParameterNode param : currentGraph.getNodes(ParameterNode.class)) { + if (param.usages().isEmpty()) { + assert param.inputs().isEmpty(); + param.safeDelete(); + } + } } } @@ -308,7 +316,6 @@ protected void handleUnresolvedLoadConstant(JavaType type) { assert !graphBuilderConfig.eagerResolving(); append(new DeoptimizeNode(InvalidateRecompile, Unresolved)); - frameState.push(Kind.Object, appendConstant(Constant.NULL_OBJECT)); } /** @@ -343,7 +350,6 @@ protected void handleUnresolvedNewInstance(JavaType type) { assert !graphBuilderConfig.eagerResolving(); append(new DeoptimizeNode(InvalidateRecompile, Unresolved)); - frameState.apush(appendConstant(Constant.NULL_OBJECT)); } /** @@ -354,7 +360,6 @@ protected void handleUnresolvedNewObjectArray(JavaType type, ValueNode length) { assert !graphBuilderConfig.eagerResolving(); append(new DeoptimizeNode(InvalidateRecompile, Unresolved)); - frameState.apush(appendConstant(Constant.NULL_OBJECT)); } /** @@ -365,7 +370,6 @@ protected void handleUnresolvedNewMultiArray(JavaType type, List<ValueNode> dims) { assert !graphBuilderConfig.eagerResolving(); append(new DeoptimizeNode(InvalidateRecompile, Unresolved)); - frameState.apush(appendConstant(Constant.NULL_OBJECT)); } /** @@ -376,9 +380,7 @@ @Override protected void handleUnresolvedLoadField(JavaField field, ValueNode receiver) { assert !graphBuilderConfig.eagerResolving(); - Kind kind = field.getKind(); append(new DeoptimizeNode(InvalidateRecompile, Unresolved)); - frameState.push(kind.getStackKind(), appendConstant(Constant.defaultForKind(kind))); } /** @@ -403,15 +405,13 @@ append(new DeoptimizeNode(InvalidateRecompile, Unresolved)); } + /** + * @param javaMethod + * @param invokeKind + */ protected void handleUnresolvedInvoke(JavaMethod javaMethod, InvokeKind invokeKind) { assert !graphBuilderConfig.eagerResolving(); - boolean withReceiver = invokeKind != InvokeKind.Static; append(new DeoptimizeNode(InvalidateRecompile, Unresolved)); - frameState.popArguments(javaMethod.getSignature().getParameterSlots(withReceiver), javaMethod.getSignature().getParameterCount(withReceiver)); - Kind kind = javaMethod.getSignature().getReturnKind(); - if (kind != Kind.Void) { - frameState.push(kind.getStackKind(), appendConstant(Constant.defaultForKind(kind))); - } } private DispatchBeginNode handleException(ValueNode exceptionObject, int bci) {
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/BasicInductionVariable.java Tue Jul 01 14:57:53 2014 +0200 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/BasicInductionVariable.java Tue Jul 01 15:45:14 2014 +0200 @@ -153,4 +153,8 @@ public long constantExtremum() { return constantStride() * (loop.counted().constantMaxTripCount() - 1) + constantInit(); } + + @Override + public void deleteUnusedNodes() { + } }
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/DerivedOffsetInductionVariable.java Tue Jul 01 14:57:53 2014 +0200 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/DerivedOffsetInductionVariable.java Tue Jul 01 15:45:14 2014 +0200 @@ -140,4 +140,8 @@ } throw GraalInternalError.shouldNotReachHere(); } + + @Override + public void deleteUnusedNodes() { + } }
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariable.java Tue Jul 01 14:57:53 2014 +0200 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariable.java Tue Jul 01 15:45:14 2014 +0200 @@ -108,6 +108,5 @@ /** * Deletes any nodes created within the scope of this object that have no usages. */ - public void deleteUnusedNodes() { - } + public abstract void deleteUnusedNodes(); }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java Tue Jul 01 14:57:53 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java Tue Jul 01 15:45:14 2014 +0200 @@ -23,14 +23,20 @@ package com.oracle.graal.phases.common; import static com.oracle.graal.api.meta.LocationIdentity.*; +import static com.oracle.graal.graph.Graph.NodeEvent.*; import static com.oracle.graal.graph.util.CollectionsAccess.*; import java.util.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.graph.Graph.NodeEventScope; +import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.extended.*; +import com.oracle.graal.nodes.util.*; import com.oracle.graal.phases.*; +import com.oracle.graal.phases.common.util.*; import com.oracle.graal.phases.graph.*; import com.oracle.graal.phases.graph.ReentrantNodeIterator.LoopInfo; import com.oracle.graal.phases.graph.ReentrantNodeIterator.NodeIteratorClosure; @@ -94,11 +100,42 @@ this.execmode = execmode; } + /** + * Removes nodes from a given set that (transitively) have a usage outside the set. + */ + private static Set<Node> removeExternallyUsedNodes(Set<Node> set) { + boolean change; + do { + change = false; + for (Iterator<Node> iter = set.iterator(); iter.hasNext();) { + Node node = iter.next(); + for (Node usage : node.usages()) { + if (!set.contains(usage)) { + change = true; + iter.remove(); + break; + } + } + } + } while (change); + return set; + } + @Override protected void run(StructuredGraph graph) { Map<LoopBeginNode, Set<LocationIdentity>> modifiedInLoops = newNodeIdentityMap(); ReentrantNodeIterator.apply(new CollectMemoryCheckpointsClosure(modifiedInLoops), graph.start(), new HashSet<LocationIdentity>()); - ReentrantNodeIterator.apply(new FloatingReadClosure(modifiedInLoops, execmode), graph.start(), new MemoryMapImpl(graph.start())); + HashSetNodeEventListener listener = new HashSetNodeEventListener(EnumSet.of(NODE_ADDED, ZERO_USAGES)); + try (NodeEventScope nes = graph.trackNodeEvents(listener)) { + ReentrantNodeIterator.apply(new FloatingReadClosure(modifiedInLoops, execmode), graph.start(), new MemoryMapImpl(graph.start())); + } + + for (Node n : removeExternallyUsedNodes(listener.getNodes())) { + if (n.isAlive() && n instanceof FloatingNode) { + n.replaceAtUsages(null); + GraphUtil.killWithUnusedFloatingInputs(n); + } + } if (execmode == ExecutionMode.CREATE_FLOATING_READS) { assert !graph.isAfterFloatingReadPhase(); graph.setAfterFloatingReadPhase(true);
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/NoDeadCodeVerifyHandler.java Tue Jul 01 14:57:53 2014 +0200 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/NoDeadCodeVerifyHandler.java Tue Jul 01 15:45:14 2014 +0200 @@ -68,8 +68,6 @@ assert after.size() <= before.size(); if (before.size() != after.size()) { if (discovered.put(message, Boolean.TRUE) == null) { - System.out.println("MESSAGE: " + message); - before.removeAll(after); String prefix = message == null ? "" : message + ": "; GraalInternalError error = new GraalInternalError("%sfound dead nodes in %s: %s", prefix, graph, before);