# HG changeset patch # User Mick Jordan # Date 1378847205 25200 # Node ID c47153857827c558bc3710201be819ad919aa0a9 # Parent 4dbd3e3adda6444c35de48c8bd9b29afe2cdcd0f# Parent a8132e3fd0d87bc45f16ef7a5ce572c156249b51 Merge - CR1368: add beforeInline callback to snippet instantiation diff -r 4dbd3e3adda6 -r c47153857827 README_GRAAL.txt --- a/README_GRAAL.txt Tue Sep 10 09:30:09 2013 -0700 +++ b/README_GRAAL.txt Tue Sep 10 14:06:45 2013 -0700 @@ -11,11 +11,30 @@ % mx build -This builds the 'product' version of HotSpot with the Graal modifications. -To build the debug or fastdebug versions: +There are a number of VM configurations supported by mx which can +be explicitly specified using the --vm option. However, you'll typically +want one of these VM configurations: - mx --vmbuild debug build - mx --vmbuild fastdebug build +1. The 'server' configuration is a standard HotSpot VM that includes the + runtime support for Graal but uses the existing compilers for normal + compilation (e.g., when the interpreter threshold is hit for a method). + Compilation with Graal is only done by explicit requests to the + Graal API. This is how Truffle uses Graal. + +2. The 'graal' configuration is a VM where all compilation is performed + by Graal and no other compilers are built into the VM binary. This + VM will bootstrap Graal itself at startup unless the -XX:-BootstrapGraal + VM option is given. + +Unless you use the --vm option with the build command, you will be presented +with a dialogue to choose one of the above VM configurations for the build +as well as have the option to make it your default for subsequent commands +that need a VM specified. + +To build the debug or fastdebug builds: + +% mx --vmbuild debug build +% mx --vmbuild fastdebug build Running Graal ------------- @@ -24,47 +43,16 @@ % mx vm ... -To select the fastdebug or debug versions of the VM: +To select the fastdebug or debug builds of the VM: % mx --vmbuild fastdebug vm ... % mx --vmbuild debug vm ... -Graal has an optional bootstrap step where it compiles itself before -compiling any application code. This bootstrap step currently takes about 20 seconds -on a fast x64 machine. It's useful to disable this bootstrap step when running small -programs with the -XX:-BootstrapGraal options. For example: - -% mx vm -XX:-BootstrapGraal ... - - -Other Build Configurations --------------------------- - -By default the build commands above create a HotSpot binary where Graal -is the only compiler. This binary is the Graal VM binary and identifies as -such with the -version option: +Other VM Configurations +----------------------- -% mx vm -XX:-BootstrapGraal -version -java version "1.7.0_25" -Java(TM) SE Runtime Environment (build 1.7.0_25-b15) -OpenJDK 64-Bit Graal VM (build 25.0-b43-internal, mixed mode) - -It's also possible to build and execute the standard HotSpot binaries -using the --vm option: - -% mx --vm server build -% mx --vm server vm -version -java version "1.7.0_25" -Java(TM) SE Runtime Environment (build 1.7.0_25-b15) -OpenJDK 64-Bit Server VM (build 25.0-b43-internal, mixed mode) - -These standard binaries still include the code necessary to support use of the -Graal compiler for explicit compilation requests. However, in this configuration -the Graal compiler will not service VM issued compilation requests (e.g., upon -counter overflow in the interpreter). - -To build and run a HotSpot binary that completely omits all VM support for Graal, -use the following as a guide: +In addition to the VM configurations described above, there are +VM configurations that omit all VM support for Graal: % mx --vm server-nograal build % mx --vm server-nograal vm -version @@ -78,3 +66,5 @@ Java(TM) SE Runtime Environment (build 1.7.0_25-b15) OpenJDK 64-Bit Cleint VM (build 25.0-b43-internal, mixed mode) +These configurations aim to match as closely as possible the +VM(s) included in the OpenJDK binaries one can download. \ No newline at end of file diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java Tue Sep 10 14:06:45 2013 -0700 @@ -112,7 +112,7 @@ int getModifiers(); /** - * Checks whether this type is initialized. If a type is initialized it implies that is was + * Checks whether this type is initialized. If a type is initialized it implies that it was * {@link #isLinked() linked} and that the static initializer has run. * * @return {@code true} if this type is initialized diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/BoxingEliminationTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/BoxingEliminationTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/BoxingEliminationTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -308,8 +308,8 @@ graph = parse(snippet); Assumptions assumptions = new Assumptions(false); HighTierContext context = new HighTierContext(runtime(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); - new InliningPhase().apply(graph, context); - new PartialEscapePhase(false).apply(graph, context); + new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); + new PartialEscapePhase(false, new CanonicalizerPhase(true)).apply(graph, context); } private void compareGraphs(final String snippet, final String referenceSnippet) { @@ -326,19 +326,19 @@ Assumptions assumptions = new Assumptions(false); HighTierContext context = new HighTierContext(runtime(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); CanonicalizerPhase canonicalizer = new CanonicalizerPhase(true); - new InliningPhase().apply(graph, context); + new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); if (loopPeeling) { new LoopTransformHighPhase().apply(graph); } new DeadCodeEliminationPhase().apply(graph); canonicalizer.apply(graph, context); - new PartialEscapePhase(false).apply(graph, context); + new PartialEscapePhase(false, canonicalizer).apply(graph, context); new DeadCodeEliminationPhase().apply(graph); canonicalizer.apply(graph, context); StructuredGraph referenceGraph = parse(referenceSnippet); - new InliningPhase().apply(referenceGraph, context); + new InliningPhase(new CanonicalizerPhase(true)).apply(referenceGraph, context); new DeadCodeEliminationPhase().apply(referenceGraph); new CanonicalizerPhase(true).apply(referenceGraph, context); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CompareCanonicalizerTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CompareCanonicalizerTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CompareCanonicalizerTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -30,12 +30,13 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.phases.common.*; +import com.oracle.graal.phases.tiers.*; public class CompareCanonicalizerTest extends GraalCompilerTest { private StructuredGraph getCanonicalizedGraph(String name) { StructuredGraph graph = parse(name); - new CanonicalizerPhase.Instance(runtime(), null, true).apply(graph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime(), null, replacements)); return graph; } @@ -53,7 +54,7 @@ assertEquals(referenceGraph, graph); } Assumptions assumptions = new Assumptions(false); - new CanonicalizerPhase.Instance(runtime(), assumptions, true).apply(referenceGraph); + new CanonicalizerPhase(true).apply(referenceGraph, new PhaseContext(runtime(), assumptions, replacements)); for (int i = 1; i < 4; i++) { StructuredGraph graph = getCanonicalizedGraph("canonicalCompare" + i); assertEquals(referenceGraph, graph); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionalEliminationTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionalEliminationTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionalEliminationTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -32,6 +32,7 @@ import com.oracle.graal.nodes.java.*; import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind; import com.oracle.graal.phases.common.*; +import com.oracle.graal.phases.tiers.*; /** * Collection of tests for {@link ConditionalEliminationPhase} including those that triggered bugs @@ -141,7 +142,7 @@ StructuredGraph graph = parse("testNullnessSnippet"); new ConditionalEliminationPhase(runtime()).apply(graph); - new CanonicalizerPhase.Instance(runtime(), null, true).apply(graph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime(), null, replacements)); for (ConstantNode constant : graph.getNodes().filter(ConstantNode.class)) { assertTrue("unexpected constant: " + constant, constant.asConstant().isNull() || constant.asConstant().asInt() > 0); } @@ -163,7 +164,7 @@ @Test public void testDisjunction() { StructuredGraph graph = parse("testDisjunctionSnippet"); - new CanonicalizerPhase.Instance(runtime(), null, true).apply(graph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime(), null, replacements)); IfNode ifNode = (IfNode) graph.start().next(); InstanceOfNode instanceOf = (InstanceOfNode) ifNode.condition(); IsNullNode x = graph.unique(new IsNullNode(graph.getLocal(0))); @@ -171,9 +172,9 @@ ShortCircuitOrNode disjunction = graph.unique(new ShortCircuitOrNode(x, false, y, false, NOT_FREQUENT_PROBABILITY)); LogicNegationNode negation = graph.unique(new LogicNegationNode(disjunction)); ifNode.setCondition(negation); - new CanonicalizerPhase.Instance(runtime(), null, true).apply(graph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime(), null, replacements)); new ConditionalEliminationPhase(runtime()).apply(graph); - new CanonicalizerPhase.Instance(runtime(), null, true).apply(graph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime(), null, replacements)); for (ConstantNode constant : graph.getNodes().filter(ConstantNode.class)) { assertTrue("unexpected constant: " + constant, constant.asConstant().isNull() || constant.asConstant().asInt() > 0); } @@ -191,7 +192,7 @@ public void testInvoke() { test("testInvokeSnippet", new Integer(16)); StructuredGraph graph = parse("testInvokeSnippet"); - new CanonicalizerPhase.Instance(runtime(), null, true).apply(graph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime(), null, replacements)); new ConditionalEliminationPhase(runtime()).apply(graph); InvokeNode invoke = graph.getNodes(InvokeNode.class).first(); @@ -221,9 +222,9 @@ @Test public void testTypeMerging() { StructuredGraph graph = parse("testTypeMergingSnippet"); - new CanonicalizerPhase.Instance(runtime(), null, true).apply(graph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime(), null, replacements)); new ConditionalEliminationPhase(runtime()).apply(graph); - new CanonicalizerPhase.Instance(runtime(), null, true).apply(graph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime(), null, replacements)); assertEquals(0, graph.getNodes().filter(StoreFieldNode.class).count()); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/DegeneratedLoopsTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/DegeneratedLoopsTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/DegeneratedLoopsTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -83,7 +83,7 @@ public void run() { StructuredGraph graph = parse(snippet); HighTierContext context = new HighTierContext(runtime(), new Assumptions(false), replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); - new InliningPhase().apply(graph, context); + new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); new CanonicalizerPhase(true).apply(graph, context); Debug.dump(graph, "Graph"); StructuredGraph referenceGraph = parse(REFERENCE_SNIPPET); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/EliminateNestedCheckCastsTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/EliminateNestedCheckCastsTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/EliminateNestedCheckCastsTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -31,6 +31,7 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.java.*; import com.oracle.graal.phases.common.*; +import com.oracle.graal.phases.tiers.*; public class EliminateNestedCheckCastsTest extends GraalCompilerTest { @@ -113,7 +114,7 @@ public StructuredGraph call() throws Exception { Debug.dump(graph, "After parsing: " + snippet); Assert.assertEquals(checkcasts, graph.getNodes().filter(CheckCastNode.class).count()); - new CanonicalizerPhase.Instance(runtime(), new Assumptions(false), true).apply(graph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime(), new Assumptions(false), replacements)); Assert.assertEquals(afterCanon, graph.getNodes(CheckCastNode.class).count()); return graph; } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FinalizableSubclassTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FinalizableSubclassTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FinalizableSubclassTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -69,7 +69,7 @@ GraphBuilderConfiguration conf = GraphBuilderConfiguration.getSnippetDefault(); new GraphBuilderPhase(runtime, conf, OptimisticOptimizations.ALL).apply(graph); HighTierContext context = new HighTierContext(runtime(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); - new InliningPhase().apply(graph, context); + new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); new CanonicalizerPhase(true).apply(graph, context); return graph; } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FloatingReadTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FloatingReadTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FloatingReadTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -29,7 +29,6 @@ import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.extended.*; -import com.oracle.graal.nodes.spi.Lowerable.*; import com.oracle.graal.phases.common.*; import com.oracle.graal.phases.tiers.*; @@ -60,7 +59,7 @@ public void run() { StructuredGraph graph = parse(snippet); PhaseContext context = new PhaseContext(runtime(), new Assumptions(false), replacements); - new LoweringPhase(LoweringType.BEFORE_GUARDS).apply(graph, context); + new LoweringPhase(new CanonicalizerPhase(true)).apply(graph, context); new FloatingReadPhase().apply(graph); ReturnNode returnNode = null; diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/IfCanonicalizerTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/IfCanonicalizerTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/IfCanonicalizerTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -31,6 +31,7 @@ import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; import com.oracle.graal.phases.common.*; +import com.oracle.graal.phases.tiers.*; /** * In the following tests, the usages of local variable "a" are replaced with the integer constant @@ -144,7 +145,7 @@ n.replaceFirstInput(local, constant); } Debug.dump(graph, "Graph"); - new CanonicalizerPhase.Instance(runtime(), new Assumptions(false), true).apply(graph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime(), new Assumptions(false), replacements)); for (FrameState fs : local.usages().filter(FrameState.class).snapshot()) { fs.replaceFirstInput(local, null); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InvokeExceptionTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InvokeExceptionTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InvokeExceptionTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -67,7 +67,7 @@ } Assumptions assumptions = new Assumptions(false); HighTierContext context = new HighTierContext(runtime(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); - new InliningPhase(hints).apply(graph, context); + new InliningPhase(hints, new CanonicalizerPhase(true)).apply(graph, context); new CanonicalizerPhase(true).apply(graph, context); new DeadCodeEliminationPhase().apply(graph); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InvokeHintsTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InvokeHintsTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InvokeHintsTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -78,7 +78,7 @@ Assumptions assumptions = new Assumptions(false); HighTierContext context = new HighTierContext(runtime(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); - new InliningPhase(hints).apply(graph, context); + new InliningPhase(hints, new CanonicalizerPhase(true)).apply(graph, context); new CanonicalizerPhase(true).apply(graph, context); new DeadCodeEliminationPhase().apply(graph); StructuredGraph referenceGraph = parse(REFERENCE_SNIPPET); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/LockEliminationTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/LockEliminationTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/LockEliminationTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -29,7 +29,6 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.java.*; -import com.oracle.graal.nodes.spi.Lowerable.LoweringType; import com.oracle.graal.phases.*; import com.oracle.graal.phases.common.*; import com.oracle.graal.phases.tiers.*; @@ -62,7 +61,7 @@ test("testSynchronizedSnippet", new A(), new A()); StructuredGraph graph = getGraph("testSynchronizedSnippet"); - new CanonicalizerPhase.Instance(runtime(), null, true).apply(graph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime(), null, replacements)); new LockEliminationPhase().apply(graph); assertEquals(1, graph.getNodes().filter(MonitorEnterNode.class).count()); assertEquals(1, graph.getNodes().filter(MonitorExitNode.class).count()); @@ -80,7 +79,7 @@ test("testSynchronizedMethodSnippet", new A()); StructuredGraph graph = getGraph("testSynchronizedMethodSnippet"); - new CanonicalizerPhase.Instance(runtime(), null, true).apply(graph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime(), null, replacements)); new LockEliminationPhase().apply(graph); assertEquals(1, graph.getNodes().filter(MonitorEnterNode.class).count()); assertEquals(1, graph.getNodes().filter(MonitorExitNode.class).count()); @@ -93,10 +92,10 @@ Assumptions assumptions = new Assumptions(true); HighTierContext context = new HighTierContext(runtime(), assumptions, replacements, null, phasePlan, OptimisticOptimizations.ALL); new CanonicalizerPhase(true).apply(graph, context); - new InliningPhase().apply(graph, context); + new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); new CanonicalizerPhase(true).apply(graph, context); new DeadCodeEliminationPhase().apply(graph); - new LoweringPhase(LoweringType.BEFORE_GUARDS).apply(graph, context); + new LoweringPhase(new CanonicalizerPhase(true)).apply(graph, context); new ValueAnchorCleanupPhase().apply(graph); new LockEliminationPhase().apply(graph); return graph; diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/LoopUnswitchTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/LoopUnswitchTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/LoopUnswitchTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -30,6 +30,7 @@ import com.oracle.graal.loop.phases.*; import com.oracle.graal.nodes.*; import com.oracle.graal.phases.common.*; +import com.oracle.graal.phases.tiers.*; public class LoopUnswitchTest extends GraalCompilerTest { @@ -133,8 +134,8 @@ } Assumptions assumptions = new Assumptions(false); - new CanonicalizerPhase.Instance(runtime(), assumptions, true).apply(graph); - new CanonicalizerPhase.Instance(runtime(), assumptions, true).apply(referenceGraph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime(), assumptions, replacements)); + new CanonicalizerPhase(true).apply(referenceGraph, new PhaseContext(runtime(), assumptions, replacements)); Debug.scope("Test", new DebugDumpScope("Test:" + snippet), new Runnable() { @Override diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -36,7 +36,6 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.cfg.*; import com.oracle.graal.nodes.extended.*; -import com.oracle.graal.nodes.spi.Lowerable.LoweringType; import com.oracle.graal.nodes.util.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.common.*; @@ -502,9 +501,9 @@ HighTierContext context = new HighTierContext(runtime(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); new CanonicalizerPhase(true).apply(graph, context); if (mode == TestMode.INLINED_WITHOUT_FRAMESTATES) { - new InliningPhase().apply(graph, context); + new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); } - new LoweringPhase(LoweringType.BEFORE_GUARDS).apply(graph, context); + new LoweringPhase(new CanonicalizerPhase(true)).apply(graph, context); if (mode == TestMode.WITHOUT_FRAMESTATES || mode == TestMode.INLINED_WITHOUT_FRAMESTATES) { for (Node node : graph.getNodes()) { if (node instanceof StateSplit) { @@ -523,8 +522,8 @@ MidTierContext midContext = new MidTierContext(runtime(), assumptions, replacements, runtime().getTarget(), OptimisticOptimizations.ALL); new GuardLoweringPhase().apply(graph, midContext); - new LoweringPhase(LoweringType.AFTER_GUARDS).apply(graph, midContext); - new LoweringPhase(LoweringType.AFTER_FSA).apply(graph, midContext); + new LoweringPhase(new CanonicalizerPhase(true)).apply(graph, midContext); + new LoweringPhase(new CanonicalizerPhase(true)).apply(graph, midContext); SchedulePhase schedule = new SchedulePhase(SchedulingStrategy.LATEST_OUT_OF_LOOPS, memsched); schedule.apply(graph); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MonitorGraphTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MonitorGraphTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MonitorGraphTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -95,7 +95,7 @@ } Assumptions assumptions = new Assumptions(false); HighTierContext context = new HighTierContext(runtime(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); - new InliningPhase(hints).apply(graph, context); + new InliningPhase(hints, new CanonicalizerPhase(true)).apply(graph, context); new CanonicalizerPhase(true).apply(graph, context); new DeadCodeEliminationPhase().apply(graph); return graph; diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PushNodesThroughPiTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PushNodesThroughPiTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PushNodesThroughPiTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -30,7 +30,6 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.extended.*; -import com.oracle.graal.nodes.spi.Lowerable.LoweringType; import com.oracle.graal.nodes.type.*; import com.oracle.graal.phases.common.*; import com.oracle.graal.phases.tiers.*; @@ -94,7 +93,7 @@ StructuredGraph graph = parse(snippet); PhaseContext context = new PhaseContext(runtime(), new Assumptions(false), replacements); CanonicalizerPhase canonicalizer = new CanonicalizerPhase(true); - new LoweringPhase(LoweringType.BEFORE_GUARDS).apply(graph, context); + new LoweringPhase(canonicalizer).apply(graph, context); canonicalizer.apply(graph, context); new PushThroughPiPhase().apply(graph); canonicalizer.apply(graph, context); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReadAfterCheckCastTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReadAfterCheckCastTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReadAfterCheckCastTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -29,7 +29,6 @@ import com.oracle.graal.debug.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.extended.*; -import com.oracle.graal.nodes.spi.Lowerable.*; import com.oracle.graal.phases.common.*; import com.oracle.graal.phases.tiers.*; @@ -85,7 +84,7 @@ public void run() { StructuredGraph graph = parse(snippet); PhaseContext context = new PhaseContext(runtime(), new Assumptions(false), replacements); - new LoweringPhase(LoweringType.BEFORE_GUARDS).apply(graph, context); + new LoweringPhase(new CanonicalizerPhase(true)).apply(graph, context); new FloatingReadPhase().apply(graph); new EliminatePartiallyRedundantGuardsPhase(true, false).apply(graph); new ReadEliminationPhase().apply(graph); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReassociateAndCanonicalTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReassociateAndCanonicalTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReassociateAndCanonicalTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -28,6 +28,7 @@ import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; import com.oracle.graal.phases.common.*; +import com.oracle.graal.phases.tiers.*; public class ReassociateAndCanonicalTest extends GraalCompilerTest { @@ -244,9 +245,9 @@ private void test(String test, String ref) { StructuredGraph testGraph = parse(test); Assumptions assumptions = new Assumptions(false); - new CanonicalizerPhase.Instance(runtime(), assumptions, true).apply(testGraph); + new CanonicalizerPhase(true).apply(testGraph, new PhaseContext(runtime(), assumptions, replacements)); StructuredGraph refGraph = parse(ref); - new CanonicalizerPhase.Instance(runtime(), assumptions, true).apply(refGraph); + new CanonicalizerPhase(true).apply(refGraph, new PhaseContext(runtime(), assumptions, replacements)); assertEquals(testGraph, refGraph); } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ScalarTypeSystemTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ScalarTypeSystemTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ScalarTypeSystemTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -28,6 +28,7 @@ import com.oracle.graal.debug.*; import com.oracle.graal.nodes.*; import com.oracle.graal.phases.common.*; +import com.oracle.graal.phases.tiers.*; /** * In the following tests, the scalar type system of the compiler should be complete enough to see @@ -166,9 +167,9 @@ StructuredGraph graph = parse(snippet); Debug.dump(graph, "Graph"); Assumptions assumptions = new Assumptions(false); - new CanonicalizerPhase.Instance(runtime(), assumptions, true).apply(graph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime(), assumptions, replacements)); new ConditionalEliminationPhase(runtime()).apply(graph); - new CanonicalizerPhase.Instance(runtime(), assumptions, true).apply(graph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime(), assumptions, replacements)); StructuredGraph referenceGraph = parse(referenceSnippet); assertEquals(referenceGraph, graph); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StampCanonicalizerTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StampCanonicalizerTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StampCanonicalizerTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -28,6 +28,7 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.type.*; import com.oracle.graal.phases.common.*; +import com.oracle.graal.phases.tiers.*; /** * This class tests some specific patterns the stamp system should be able to canonicalize away @@ -109,7 +110,7 @@ private void testZeroReturn(String methodName) { StructuredGraph graph = parse(methodName); - new CanonicalizerPhase.Instance(runtime(), new Assumptions(false), true).apply(graph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime(), new Assumptions(false), replacements)); new DeadCodeEliminationPhase().apply(graph); assertConstantReturn(graph, 0); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StraighteningTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StraighteningTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StraighteningTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -28,6 +28,7 @@ import com.oracle.graal.debug.*; import com.oracle.graal.nodes.*; import com.oracle.graal.phases.common.*; +import com.oracle.graal.phases.tiers.*; public class StraighteningTest extends GraalCompilerTest { @@ -89,7 +90,7 @@ // No debug scope to reduce console noise for @Test(expected = ...) tests StructuredGraph graph = parse(snippet); Debug.dump(graph, "Graph"); - new CanonicalizerPhase.Instance(runtime(), new Assumptions(false), true).apply(graph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime(), new Assumptions(false), replacements)); StructuredGraph referenceGraph = parse(REFERENCE_SNIPPET); assertEquals(referenceGraph, graph); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/TypeSystemTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/TypeSystemTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/TypeSystemTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -35,6 +35,7 @@ import com.oracle.graal.nodes.java.*; import com.oracle.graal.phases.common.*; import com.oracle.graal.phases.schedule.*; +import com.oracle.graal.phases.tiers.*; /** * In the following tests, the scalar type system of the compiler should be complete enough to see @@ -184,13 +185,13 @@ StructuredGraph graph = parse(snippet); Debug.dump(graph, "Graph"); Assumptions assumptions = new Assumptions(false); - new CanonicalizerPhase.Instance(runtime(), assumptions, true).apply(graph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime(), assumptions, replacements)); new ConditionalEliminationPhase(runtime()).apply(graph); - new CanonicalizerPhase.Instance(runtime(), assumptions, true).apply(graph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime(), assumptions, replacements)); // a second canonicalizer is needed to process nested MaterializeNodes - new CanonicalizerPhase.Instance(runtime(), assumptions, true).apply(graph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime(), assumptions, replacements)); StructuredGraph referenceGraph = parse(referenceSnippet); - new CanonicalizerPhase.Instance(runtime(), assumptions, true).apply(referenceGraph); + new CanonicalizerPhase(true).apply(referenceGraph, new PhaseContext(runtime(), assumptions, replacements)); assertEquals(referenceGraph, graph); } @@ -240,9 +241,9 @@ StructuredGraph graph = parse(snippet); Debug.dump(graph, "Graph"); Assumptions assumptions = new Assumptions(false); - new CanonicalizerPhase.Instance(runtime(), assumptions, true).apply(graph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime(), assumptions, replacements)); new ConditionalEliminationPhase(runtime()).apply(graph); - new CanonicalizerPhase.Instance(runtime(), assumptions, true).apply(graph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime(), assumptions, replacements)); Debug.dump(graph, "Graph"); Assert.assertFalse("shouldn't have nodes of type " + clazz, graph.getNodes(clazz).iterator().hasNext()); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/deopt/CompiledMethodTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/deopt/CompiledMethodTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/deopt/CompiledMethodTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -32,6 +32,7 @@ import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; import com.oracle.graal.phases.common.*; +import com.oracle.graal.phases.tiers.*; import com.oracle.graal.test.*; /** @@ -55,7 +56,7 @@ public void test1() { Method method = getMethod("testMethod"); final StructuredGraph graph = parse(method); - new CanonicalizerPhase.Instance(runtime(), new Assumptions(false), true).apply(graph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime(), new Assumptions(false), replacements)); new DeadCodeEliminationPhase().apply(graph); for (Node node : graph.getNodes()) { diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EarlyReadEliminationTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EarlyReadEliminationTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EarlyReadEliminationTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -42,7 +42,7 @@ graph = parse(snippet); Assumptions assumptions = new Assumptions(false); HighTierContext context = new HighTierContext(runtime(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); - new InliningPhase().apply(graph, context); - new EarlyReadEliminationPhase().apply(graph, context); + new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); + new EarlyReadEliminationPhase(new CanonicalizerPhase(true)).apply(graph, context); } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EscapeAnalysisTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EscapeAnalysisTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EscapeAnalysisTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -234,10 +234,10 @@ Assumptions assumptions = new Assumptions(false); HighTierContext context = new HighTierContext(runtime(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); - new InliningPhase().apply(graph, context); + new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); new DeadCodeEliminationPhase().apply(graph); new CanonicalizerPhase(true).apply(graph, context); - new PartialEscapePhase(iterativeEscapeAnalysis).apply(graph, context); + new PartialEscapePhase(iterativeEscapeAnalysis, new CanonicalizerPhase(true)).apply(graph, context); Assert.assertEquals(1, graph.getNodes(ReturnNode.class).count()); ReturnNode returnNode = graph.getNodes(ReturnNode.class).first(); if (expectedConstantResult != null) { diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PEAReadEliminationTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PEAReadEliminationTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PEAReadEliminationTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -244,7 +244,7 @@ graph = parse(snippet); Assumptions assumptions = new Assumptions(false); HighTierContext context = new HighTierContext(runtime(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); - new InliningPhase().apply(graph, context); - new PartialEscapePhase(false, true).apply(graph, context); + new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); + new PartialEscapePhase(false, true, new CanonicalizerPhase(true)).apply(graph, context); } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PartialEscapeAnalysisTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PartialEscapeAnalysisTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PartialEscapeAnalysisTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -199,10 +199,10 @@ Assumptions assumptions = new Assumptions(false); HighTierContext context = new HighTierContext(runtime(), assumptions, replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); - new InliningPhase().apply(graph, context); + new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); new DeadCodeEliminationPhase().apply(graph); new CanonicalizerPhase(true).apply(graph, context); - new PartialEscapePhase(false).apply(graph, context); + new PartialEscapePhase(false, new CanonicalizerPhase(true)).apply(graph, context); for (MergeNode merge : graph.getNodes(MergeNode.class)) { merge.setStateAfter(null); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/inlining/InliningTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/inlining/InliningTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/inlining/InliningTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -240,7 +240,7 @@ HighTierContext context = new HighTierContext(runtime(), assumptions, replacements, null, phasePlan, OptimisticOptimizations.ALL); Debug.dump(graph, "Graph"); new CanonicalizerPhase(true).apply(graph, context); - new InliningPhase().apply(graph, context); + new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); Debug.dump(graph, "Graph"); new CanonicalizerPhase(true).apply(graph, context); new DeadCodeEliminationPhase().apply(graph); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/HighTier.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/HighTier.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/HighTier.java Tue Sep 10 14:06:45 2013 -0700 @@ -22,12 +22,12 @@ */ package com.oracle.graal.compiler.phases; +import static com.oracle.graal.compiler.phases.HighTier.Options.*; import static com.oracle.graal.phases.GraalOptions.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.loop.phases.*; -import com.oracle.graal.nodes.spi.Lowerable.LoweringType; import com.oracle.graal.options.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.common.*; @@ -37,12 +37,15 @@ public class HighTier extends PhaseSuite { - // @formatter:off - @Option(help = "") - public static final OptionValue VerifyUsageWithEquals = new OptionValue<>(true); - @Option(help = "Enable inlining") - public static final OptionValue Inline = new OptionValue<>(true); - // @formatter:on + static class Options { + + // @formatter:off + @Option(help = "") + public static final OptionValue VerifyUsageWithEquals = new OptionValue<>(true); + @Option(help = "Enable inlining") + public static final OptionValue Inline = new OptionValue<>(true); + // @formatter:on + } public HighTier() { CanonicalizerPhase canonicalizer = new CanonicalizerPhase(!AOTCompilation.getValue()); @@ -60,12 +63,12 @@ if (IterativeInlining.getValue()) { appendPhase(new IterativeInliningPhase(canonicalizer)); } else { - appendPhase(new InliningPhase()); + appendPhase(new InliningPhase(canonicalizer)); appendPhase(new DeadCodeEliminationPhase()); if (ConditionalElimination.getValue() && OptCanonicalizer.getValue()) { appendPhase(canonicalizer); - appendPhase(new IterativeConditionalEliminationPhase()); + appendPhase(new IterativeConditionalEliminationPhase(canonicalizer)); } } } @@ -73,15 +76,15 @@ appendPhase(new CleanTypeProfileProxyPhase()); if (FullUnroll.getValue()) { - appendPhase(new LoopFullUnrollPhase(!AOTCompilation.getValue())); + appendPhase(new LoopFullUnrollPhase(canonicalizer)); } if (OptTailDuplication.getValue()) { - appendPhase(new TailDuplicationPhase()); + appendPhase(new TailDuplicationPhase(canonicalizer)); } if (PartialEscapeAnalysis.getValue()) { - appendPhase(new PartialEscapePhase(true)); + appendPhase(new PartialEscapePhase(true, canonicalizer)); } if (OptConvertDeoptsToGuards.getValue()) { @@ -98,6 +101,6 @@ appendPhase(canonicalizer); } - appendPhase(new LoweringPhase(LoweringType.BEFORE_GUARDS)); + appendPhase(new LoweringPhase(canonicalizer)); } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LowTier.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LowTier.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LowTier.java Tue Sep 10 14:06:45 2013 -0700 @@ -22,7 +22,8 @@ */ package com.oracle.graal.compiler.phases; -import com.oracle.graal.nodes.spi.Lowerable.LoweringType; +import static com.oracle.graal.phases.GraalOptions.*; + import com.oracle.graal.phases.*; import com.oracle.graal.phases.common.*; import com.oracle.graal.phases.tiers.*; @@ -30,7 +31,9 @@ public class LowTier extends PhaseSuite { public LowTier() { - appendPhase(new LoweringPhase(LoweringType.AFTER_FSA)); + CanonicalizerPhase canonicalizer = new CanonicalizerPhase(!AOTCompilation.getValue()); + + appendPhase(new LoweringPhase(canonicalizer)); appendPhase(new ExpandLogicPhase()); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/MidTier.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/MidTier.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/MidTier.java Tue Sep 10 14:06:45 2013 -0700 @@ -25,7 +25,6 @@ import static com.oracle.graal.phases.GraalOptions.*; import com.oracle.graal.loop.phases.*; -import com.oracle.graal.nodes.spi.Lowerable.LoweringType; import com.oracle.graal.phases.*; import com.oracle.graal.phases.common.*; import com.oracle.graal.phases.tiers.*; @@ -47,11 +46,11 @@ appendPhase(new LockEliminationPhase()); if (OptReadElimination.getValue()) { - appendPhase(new EarlyReadEliminationPhase()); + appendPhase(new EarlyReadEliminationPhase(canonicalizer)); } if (OptFloatingReads.getValue()) { - IncrementalCanonicalizerPhase incCanonicalizer = new IncrementalCanonicalizerPhase<>(); + IncrementalCanonicalizerPhase incCanonicalizer = new IncrementalCanonicalizerPhase<>(canonicalizer); incCanonicalizer.appendPhase(new FloatingReadPhase()); appendPhase(incCanonicalizer); if (OptReadElimination.getValue()) { @@ -69,7 +68,7 @@ } if (ConditionalElimination.getValue() && OptCanonicalizer.getValue()) { - appendPhase(new IterativeConditionalEliminationPhase()); + appendPhase(new IterativeConditionalEliminationPhase(canonicalizer)); } if (OptEliminatePartiallyRedundantGuards.getValue()) { @@ -86,7 +85,7 @@ appendPhase(new GuardLoweringPhase()); - appendPhase(new LoweringPhase(LoweringType.AFTER_GUARDS)); + appendPhase(new LoweringPhase(canonicalizer)); appendPhase(new FrameStateAssignmentPhase()); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -39,7 +39,6 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.HeapAccess.BarrierType; import com.oracle.graal.nodes.extended.*; -import com.oracle.graal.nodes.spi.Lowerable.LoweringType; import com.oracle.graal.phases.*; import com.oracle.graal.phases.common.*; import com.oracle.graal.phases.tiers.*; @@ -249,10 +248,10 @@ StructuredGraph graph = parse(snippet); HighTierContext highContext = new HighTierContext(runtime(), new Assumptions(false), replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); MidTierContext midContext = new MidTierContext(runtime(), new Assumptions(false), replacements, runtime().getTarget(), OptimisticOptimizations.ALL); - new InliningPhase(new InliningPhase.InlineEverythingPolicy()).apply(graph, highContext); - new LoweringPhase(LoweringType.BEFORE_GUARDS).apply(graph, highContext); + new InliningPhase(new InliningPhase.InlineEverythingPolicy(), new CanonicalizerPhase(true)).apply(graph, highContext); + new LoweringPhase(new CanonicalizerPhase(true)).apply(graph, highContext); new GuardLoweringPhase().apply(graph, midContext); - new LoweringPhase(LoweringType.AFTER_GUARDS).apply(graph, midContext); + new LoweringPhase(new CanonicalizerPhase(true)).apply(graph, midContext); new WriteBarrierAdditionPhase().apply(graph); Debug.dump(graph, "After Write Barrier Addition"); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierVerificationTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierVerificationTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierVerificationTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -36,7 +36,6 @@ import com.oracle.graal.hotspot.phases.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.extended.*; -import com.oracle.graal.nodes.spi.Lowerable.LoweringType; import com.oracle.graal.phases.*; import com.oracle.graal.phases.common.*; import com.oracle.graal.phases.graph.*; @@ -633,14 +632,14 @@ public AssertionError call() { final StructuredGraph graph = parse(snippet); HighTierContext highTierContext = new HighTierContext(runtime(), new Assumptions(false), replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL); - new InliningPhase().apply(graph, highTierContext); + new InliningPhase(new CanonicalizerPhase(true)).apply(graph, highTierContext); MidTierContext midTierContext = new MidTierContext(runtime(), new Assumptions(false), replacements, runtime().getTarget(), OptimisticOptimizations.ALL); - new LoweringPhase(LoweringType.BEFORE_GUARDS).apply(graph, highTierContext); + new LoweringPhase(new CanonicalizerPhase(true)).apply(graph, highTierContext); new GuardLoweringPhase().apply(graph, midTierContext); new SafepointInsertionPhase().apply(graph); - new LoweringPhase(LoweringType.AFTER_GUARDS).apply(graph, highTierContext); + new LoweringPhase(new CanonicalizerPhase(true)).apply(graph, highTierContext); new WriteBarrierAdditionPhase().apply(graph); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java Tue Sep 10 14:06:45 2013 -0700 @@ -24,7 +24,6 @@ package com.oracle.graal.hotspot; import static com.oracle.graal.compiler.GraalDebugConfig.*; -import static com.oracle.graal.hotspot.HotSpotVMConfig.*; import static java.nio.file.Files.*; import java.io.*; @@ -179,9 +178,11 @@ /** * Called from VM code once all Graal command line options have been processed by * {@link #setOption(String)}. + * + * @param ciTime the value of the CITime HotSpot VM option */ - public static void finalizeOptions() { - if (areDebugScopePatternsEnabled() || getVMOption("CITime")) { + public static void finalizeOptions(boolean ciTime) { + if (areDebugScopePatternsEnabled() || ciTime) { Debug.enable(); } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Tue Sep 10 14:06:45 2013 -0700 @@ -85,7 +85,6 @@ 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.spi.Lowerable.LoweringType; import com.oracle.graal.nodes.type.*; import com.oracle.graal.nodes.virtual.*; import com.oracle.graal.phases.tiers.*; @@ -637,11 +636,11 @@ graph.replaceFixedWithFixed(storeIndexed, memoryWrite); } else if (n instanceof UnsafeLoadNode) { - if (tool.getLoweringType().ordinal() > LoweringType.BEFORE_GUARDS.ordinal()) { + if (graph.getGuardsPhase().ordinal() > StructuredGraph.GuardsPhase.FLOATING_GUARDS.ordinal()) { UnsafeLoadNode load = (UnsafeLoadNode) n; assert load.kind() != Kind.Illegal; boolean compressible = (!load.object().isNullConstant() && load.accessKind() == Kind.Object); - if (addReadBarrier(load, tool)) { + if (addReadBarrier(load)) { unsafeLoadSnippets.lower(load, tool); } else { IndexedLocationNode location = IndexedLocationNode.create(ANY_LOCATION, load.accessKind(), load.displacement(), load.offset(), graph, 1); @@ -676,14 +675,8 @@ StoreHubNode storeHub = (StoreHubNode) n; WriteNode hub = createWriteHub(graph, wordKind, storeHub.getObject(), storeHub.getValue()); graph.replaceFixed(storeHub, hub); - } else if (n instanceof FixedGuardNode) { - FixedGuardNode node = (FixedGuardNode) n; - GuardingNode guard = tool.createGuard(node.condition(), node.getReason(), node.getAction(), node.isNegated()); - ValueAnchorNode newAnchor = graph.add(new ValueAnchorNode(guard.asNode())); - node.replaceAtUsages(guard.asNode()); - graph.replaceFixedWithFixed(node, newAnchor); } else if (n instanceof CommitAllocationNode) { - if (tool.getLoweringType() == LoweringType.AFTER_GUARDS) { + if (graph.getGuardsPhase() == StructuredGraph.GuardsPhase.FIXED_DEOPTS) { CommitAllocationNode commit = (CommitAllocationNode) n; ValueNode[] allocations = new ValueNode[commit.getVirtualObjects().size()]; @@ -759,7 +752,7 @@ graph.removeFixed(commit); } } else if (n instanceof OSRStartNode) { - if (tool.getLoweringType() == LoweringType.AFTER_GUARDS) { + if (graph.getGuardsPhase() == StructuredGraph.GuardsPhase.FIXED_DEOPTS) { OSRStartNode osrStart = (OSRStartNode) n; StartNode newStart = graph.add(new StartNode()); LocalNode buffer = graph.unique(new LocalNode(0, StampFactory.forKind(wordKind()))); @@ -788,31 +781,31 @@ } else if (n instanceof CheckCastDynamicNode) { checkcastDynamicSnippets.lower((CheckCastDynamicNode) n); } else if (n instanceof InstanceOfNode) { - if (tool.getLoweringType() == LoweringType.AFTER_GUARDS) { + if (graph.getGuardsPhase() == StructuredGraph.GuardsPhase.FIXED_DEOPTS) { instanceofSnippets.lower((InstanceOfNode) n, tool); } } else if (n instanceof InstanceOfDynamicNode) { - if (tool.getLoweringType() == LoweringType.AFTER_GUARDS) { + if (graph.getGuardsPhase() == StructuredGraph.GuardsPhase.FIXED_DEOPTS) { instanceofSnippets.lower((InstanceOfDynamicNode) n, tool); } } else if (n instanceof NewInstanceNode) { - if (tool.getLoweringType() == LoweringType.AFTER_FSA) { + if (graph.getGuardsPhase() == StructuredGraph.GuardsPhase.AFTER_FSA) { newObjectSnippets.lower((NewInstanceNode) n); } } else if (n instanceof NewArrayNode) { - if (tool.getLoweringType() == LoweringType.AFTER_FSA) { + if (graph.getGuardsPhase() == StructuredGraph.GuardsPhase.AFTER_FSA) { newObjectSnippets.lower((NewArrayNode) n); } } else if (n instanceof DynamicNewArrayNode) { - if (tool.getLoweringType() == LoweringType.AFTER_FSA) { + if (graph.getGuardsPhase() == StructuredGraph.GuardsPhase.AFTER_FSA) { newObjectSnippets.lower((DynamicNewArrayNode) n); } } else if (n instanceof MonitorEnterNode) { - if (tool.getLoweringType() == LoweringType.AFTER_GUARDS) { + if (graph.getGuardsPhase() == StructuredGraph.GuardsPhase.FIXED_DEOPTS) { monitorSnippets.lower((MonitorEnterNode) n, tool); } } else if (n instanceof MonitorExitNode) { - if (tool.getLoweringType() == LoweringType.AFTER_GUARDS) { + if (graph.getGuardsPhase() == StructuredGraph.GuardsPhase.FIXED_DEOPTS) { monitorSnippets.lower((MonitorExitNode) n, tool); } } else if (n instanceof G1PreWriteBarrier) { @@ -830,7 +823,7 @@ } else if (n instanceof G1ArrayRangePostWriteBarrier) { writeBarrierSnippets.lower((G1ArrayRangePostWriteBarrier) n, tool); } else if (n instanceof NewMultiArrayNode) { - if (tool.getLoweringType() == LoweringType.AFTER_FSA) { + if (graph.getGuardsPhase() == StructuredGraph.GuardsPhase.AFTER_FSA) { newObjectSnippets.lower((NewMultiArrayNode) n); } } else if (n instanceof LoadExceptionObjectNode) { @@ -850,8 +843,8 @@ } } - private static boolean addReadBarrier(UnsafeLoadNode load, LoweringTool tool) { - if (useG1GC() && tool.getLoweringType() == LoweringType.AFTER_GUARDS && load.object().kind() == Kind.Object && load.accessKind() == Kind.Object && + private static boolean addReadBarrier(UnsafeLoadNode load) { + if (useG1GC() && load.graph().getGuardsPhase() == StructuredGraph.GuardsPhase.FIXED_DEOPTS && load.object().kind() == Kind.Object && load.accessKind() == Kind.Object && !ObjectStamp.isObjectAlwaysNull(load.object())) { ResolvedJavaType type = ObjectStamp.typeOrNull(load.object()); if (type != null && !type.isArray()) { diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CStringNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CStringNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CStringNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -44,7 +44,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { byte[] formatBytes = string.getBytes(); long cstring = unsafe.allocateMemory(formatBytes.length + 1); for (int i = 0; i < formatBytes.length; i++) { diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/VerifyHotSpotOptionsPhase.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/VerifyHotSpotOptionsPhase.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/VerifyHotSpotOptionsPhase.java Tue Sep 10 14:06:45 2013 -0700 @@ -57,21 +57,25 @@ for (OptionDescriptor desc : opts) { if (HotSpotOptions.isHotSpotOption(desc)) { HotSpotResolvedObjectType holder = (HotSpotResolvedObjectType) runtime.lookupJavaType(desc.getDeclaringClass()); - checkType(runtime, checked, holder); + checkType(holder, desc, runtime, checked); } } } return true; } - private static void checkType(HotSpotRuntime runtime, Set checked, HotSpotResolvedObjectType holder) { - if (!checked.contains(holder)) { - checked.add(holder); - for (ResolvedJavaMethod method : holder.getMethods()) { + private static void checkType(HotSpotResolvedObjectType type, OptionDescriptor option, HotSpotRuntime runtime, Set checked) { + if (!checked.contains(type)) { + checked.add(type); + HotSpotResolvedObjectType superType = type.getSupertype(); + if (superType != null && !MetaUtil.isJavaLangObject(superType)) { + checkType(superType, option, runtime, checked); + } + for (ResolvedJavaMethod method : type.getMethods()) { if (method.isClassInitializer()) { StructuredGraph graph = new StructuredGraph(method); new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph); - new VerifyHotSpotOptionsPhase(holder, runtime).apply(graph); + new VerifyHotSpotOptionsPhase(type, runtime, option).apply(graph); } } } @@ -81,11 +85,13 @@ private final ResolvedJavaType declaringClass; private final ResolvedJavaType optionValueType; private final Set boxingTypes; + private final OptionDescriptor option; - public VerifyHotSpotOptionsPhase(ResolvedJavaType declaringClass, HotSpotRuntime runtime) { + public VerifyHotSpotOptionsPhase(ResolvedJavaType declaringClass, HotSpotRuntime runtime, OptionDescriptor option) { this.runtime = runtime; this.declaringClass = declaringClass; this.optionValueType = runtime.lookupJavaType(OptionValue.class); + this.option = option; this.boxingTypes = new HashSet<>(); for (Class c : new Class[]{Boolean.class, Byte.class, Short.class, Character.class, Integer.class, Float.class, Long.class, Double.class}) { this.boxingTypes.add(runtime.lookupJavaType(c)); @@ -140,7 +146,9 @@ private void error(Node node, String message) { String loc = GraphUtil.approxSourceLocation(node); - throw new GraalInternalError(String.format("HotSpot option declarer %s contains code pattern implying action other than initialization of an option:%n %s%n %s", + throw new GraalInternalError(String.format("The " + option.getName() + " option is declared in " + option.getDeclaringClass() + + " whose class hierarchy contains a class initializer (in %s) with a code pattern at or near %s implying an action other than initialization of an option:%n%n %s%n%n" + + "The recommended solution is to move " + option.getName() + " into a separate class (e.g., " + option.getDeclaringClass().getName() + ".Options).%n", toJavaName(declaringClass), loc, message)); } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -87,7 +87,7 @@ // additions, etc. PhaseContext context = new PhaseContext(tool.getRuntime(), tool.assumptions(), tool.getReplacements()); new CanonicalizerPhase(true).apply(snippetGraph, context); - new LoopFullUnrollPhase(true).apply(snippetGraph, context); + new LoopFullUnrollPhase(new CanonicalizerPhase(true)).apply(snippetGraph, context); new CanonicalizerPhase(true).apply(snippetGraph, context); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CallSiteTargetNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CallSiteTargetNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CallSiteTargetNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -66,7 +66,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { ConstantNode target = getConstantCallTarget(tool.getRuntime(), tool.assumptions()); if (target != null) { diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ReflectionGetCallerClassNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ReflectionGetCallerClassNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ReflectionGetCallerClassNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -47,7 +47,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { ConstantNode callerClassNode = getCallerClassNode(tool.getRuntime()); if (callerClassNode != null) { diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/UnsafeArrayCopyNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/UnsafeArrayCopyNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/UnsafeArrayCopyNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -92,8 +92,8 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { - if (loweringType == LoweringType.AFTER_FSA) { + public void lower(LoweringTool tool) { + if (graph().getGuardsPhase() == StructuredGraph.GuardsPhase.AFTER_FSA) { UnsafeArrayCopySnippets.Templates templates = tool.getReplacements().getSnippetTemplateCache(UnsafeArrayCopySnippets.Templates.class); templates.lower(this); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopTransformations.java --- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopTransformations.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopTransformations.java Tue Sep 10 14:06:45 2013 -0700 @@ -25,13 +25,13 @@ import static com.oracle.graal.phases.GraalOptions.*; import com.oracle.graal.api.code.*; -import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.NodeClass.NodeClassIterator; import com.oracle.graal.graph.NodeClass.Position; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.phases.common.*; +import com.oracle.graal.phases.tiers.*; public abstract class LoopTransformations { @@ -53,7 +53,7 @@ loop.inside().duplicate().insertBefore(loop); } - public static void fullUnroll(LoopEx loop, MetaAccessProvider runtime, Assumptions assumptions, boolean canonicalizeReads) { + public static void fullUnroll(LoopEx loop, PhaseContext context, CanonicalizerPhase canonicalizer) { // assert loop.isCounted(); //TODO (gd) strenghten : counted with known trip count int iterations = 0; LoopBeginNode loopBegin = loop.loopBegin(); @@ -61,7 +61,7 @@ while (!loopBegin.isDeleted()) { int mark = graph.getMark(); peel(loop); - new CanonicalizerPhase.Instance(runtime, assumptions, canonicalizeReads, mark, null).apply(graph); + canonicalizer.applyIncremental(graph, context, mark); if (iterations++ > UNROLL_LIMIT || graph.getNodeCount() > MaximumDesiredSize.getValue() * 3) { throw new BailoutException("FullUnroll : Graph seems to grow out of proportion"); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.loop/src/com/oracle/graal/loop/phases/LoopFullUnrollPhase.java --- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/phases/LoopFullUnrollPhase.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/phases/LoopFullUnrollPhase.java Tue Sep 10 14:06:45 2013 -0700 @@ -26,15 +26,16 @@ import com.oracle.graal.loop.*; import com.oracle.graal.nodes.*; import com.oracle.graal.phases.*; +import com.oracle.graal.phases.common.*; import com.oracle.graal.phases.tiers.*; public class LoopFullUnrollPhase extends BasePhase { private static final DebugMetric FULLY_UNROLLED_LOOPS = Debug.metric("FullUnrolls"); - private final boolean canonicalizeReads; + private final CanonicalizerPhase canonicalizer; - public LoopFullUnrollPhase(boolean canonicalizeReads) { - this.canonicalizeReads = canonicalizeReads; + public LoopFullUnrollPhase(CanonicalizerPhase canonicalizer) { + this.canonicalizer = canonicalizer; } @Override @@ -48,7 +49,7 @@ for (LoopEx loop : dataCounted.countedLoops()) { if (LoopPolicies.shouldFullUnroll(loop)) { Debug.log("FullUnroll %s", loop); - LoopTransformations.fullUnroll(loop, context.getRuntime(), context.getAssumptions(), canonicalizeReads); + LoopTransformations.fullUnroll(loop, context, canonicalizer); FULLY_UNROLLED_LOOPS.increment(); Debug.dump(graph, "After fullUnroll %s", loop); peeled = true; diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/AbstractBeginNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/AbstractBeginNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/AbstractBeginNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -185,9 +185,4 @@ throw new UnsupportedOperationException(); } } - - @Override - public AbstractBeginNode asNode() { - return this; - } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/DeoptimizeNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/DeoptimizeNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/DeoptimizeNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -59,7 +59,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedGuardNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedGuardNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedGuardNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -106,9 +106,12 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { - if (loweringType == LoweringType.BEFORE_GUARDS) { - tool.getRuntime().lower(this, tool); + public void lower(LoweringTool tool) { + if (graph().getGuardsPhase() == StructuredGraph.GuardsPhase.FLOATING_GUARDS) { + GuardingNode guard = tool.createGuard(condition(), getReason(), getAction(), isNegated()); + ValueAnchorNode newAnchor = graph().add(new ValueAnchorNode(guard.asNode())); + this.replaceAtUsages(guard.asNode()); + graph().replaceFixedWithFixed(this, newAnchor); } else { FixedNode next = next(); setNext(null); @@ -130,11 +133,6 @@ } @Override - public FixedGuardNode asNode() { - return this; - } - - @Override public boolean canDeoptimize() { return true; } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -35,4 +35,9 @@ assertTrue(this.successors().isNotEmpty() || this.predecessor() != null, "FixedNode should not float"); return super.verify(); } + + @Override + public FixedNode asNode() { + return this; + } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FloatingGuardedNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FloatingGuardedNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FloatingGuardedNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -49,10 +49,4 @@ updateUsages(this.guard == null ? null : this.guard.asNode(), guard == null ? null : guard.asNode()); this.guard = guard; } - - @Override - public FloatingNode asNode() { - return this; - } - } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardingPiNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardingPiNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardingPiNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -76,8 +76,8 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { - if (loweringType == LoweringType.AFTER_GUARDS) { + public void lower(LoweringTool tool) { + if (graph().getGuardsPhase() == StructuredGraph.GuardsPhase.FIXED_DEOPTS) { throw new GraalInternalError("Cannot create guards in after-guard lowering"); } FixedGuardNode guard = graph().add(new FixedGuardNode(condition, reason, action, negated)); @@ -115,11 +115,6 @@ @ConstantNodeParameter DeoptimizationAction action, @ConstantNodeParameter Stamp stamp); @Override - public ValueNode asNode() { - return this; - } - - @Override public ValueNode getOriginalValue() { return object; } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InvokeNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InvokeNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InvokeNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -108,7 +108,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } @@ -133,11 +133,6 @@ } @Override - public FixedNode asNode() { - return this; - } - - @Override public FrameState stateDuring() { FrameState stateAfter = stateAfter(); if (stateAfter == null) { diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InvokeWithExceptionNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InvokeWithExceptionNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InvokeWithExceptionNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -119,11 +119,6 @@ } @Override - public FixedNode asNode() { - return this; - } - - @Override public void setNext(FixedNode x) { if (x != null) { this.setNext(AbstractBeginNode.begin(x)); @@ -133,7 +128,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LogicNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LogicNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LogicNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -30,4 +30,22 @@ public LogicNode() { super(StampFactory.condition()); } + + public static LogicNode and(LogicNode a, LogicNode b, double shortCircuitProbability) { + return and(a, false, b, false, shortCircuitProbability); + } + + public static LogicNode and(LogicNode a, boolean negateA, LogicNode b, boolean negateB, double shortCircuitProbability) { + StructuredGraph graph = a.graph(); + ShortCircuitOrNode notAorNotB = graph.unique(new ShortCircuitOrNode(a, !negateA, b, !negateB, shortCircuitProbability)); + return graph.unique(new LogicNegationNode(notAorNotB)); + } + + public static LogicNode or(LogicNode a, LogicNode b, double shortCircuitProbability) { + return or(a, false, b, false, shortCircuitProbability); + } + + public static LogicNode or(LogicNode a, boolean negateA, LogicNode b, boolean negateB, double shortCircuitProbability) { + return a.graph().unique(new ShortCircuitOrNode(a, negateA, b, negateB, shortCircuitProbability)); + } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -248,9 +248,4 @@ public boolean isLoopPhi() { return merge() instanceof LoopBeginNode; } - - @Override - public PhiNode asNode() { - return this; - } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ProxyNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ProxyNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ProxyNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -120,8 +120,4 @@ public ValueNode getOriginalValue() { return value; } - - public ValueNode asNode() { - return this; - } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ShortCircuitAndNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ShortCircuitAndNode.java Tue Sep 10 09:30:09 2013 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2013, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.nodes; - -import com.oracle.graal.nodes.spi.*; - -/** - * The short-circuit AND (i.e. {@code &&} in Java) operator. - */ -public class ShortCircuitAndNode extends ShortCircuitBooleanNode implements Canonicalizable { - - public ShortCircuitAndNode(LogicNode x, boolean xNegated, LogicNode y, boolean yNegated, double shortCircuitProbability) { - super(x, xNegated, y, yNegated, shortCircuitProbability); - } - - @Override - public LogicNode canonical(CanonicalizerTool tool) { - ShortCircuitBooleanNode ret = canonicalizeNegation(); - if (ret != null) { - return ret; - } - - LogicNode x = getX(); - LogicNode y = getY(); - if (x == y) { - // @formatter:off - // a && a = a - // a && !a = false - // !a && a = false - // !a && !a = !a - // @formatter:on - if (isXNegated()) { - if (isYNegated()) { - // !a && !a = !a - return graph().unique(new LogicNegationNode(x)); - } else { - // !a && a = false - return LogicConstantNode.contradiction(graph()); - } - } else { - if (isYNegated()) { - // a && !a = false - return LogicConstantNode.contradiction(graph()); - } else { - // a && a = a - return x; - } - } - } - if (x instanceof LogicConstantNode) { - if (((LogicConstantNode) x).getValue() ^ isXNegated()) { - if (isYNegated()) { - return graph().unique(new LogicNegationNode(y)); - } else { - return y; - } - } else { - return LogicConstantNode.contradiction(graph()); - } - } - if (y instanceof LogicConstantNode) { - if (((LogicConstantNode) y).getValue() ^ isYNegated()) { - if (isXNegated()) { - return graph().unique(new LogicNegationNode(x)); - } else { - return x; - } - } else { - return LogicConstantNode.contradiction(graph()); - } - } - return this; - } - - @Override - protected ShortCircuitBooleanNode createCopy(LogicNode xCond, boolean xNeg, LogicNode yCond, boolean yNeg, double probability) { - return new ShortCircuitAndNode(xCond, xNeg, yCond, yNeg, probability); - } -} diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ShortCircuitBooleanNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ShortCircuitBooleanNode.java Tue Sep 10 09:30:09 2013 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2013, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.nodes; - -import com.oracle.graal.graph.*; - -/** - * Base class for the short-circuit boolean operators. - */ -public abstract class ShortCircuitBooleanNode extends LogicNode implements Node.IterableNodeType { - - @Input private LogicNode x; - @Input private LogicNode y; - private boolean xNegated; - private boolean yNegated; - private double shortCircuitProbability; - - public ShortCircuitBooleanNode(LogicNode x, boolean xNegated, LogicNode y, boolean yNegated, double shortCircuitProbability) { - this.x = x; - this.xNegated = xNegated; - this.y = y; - this.yNegated = yNegated; - this.shortCircuitProbability = shortCircuitProbability; - } - - public LogicNode getX() { - return x; - } - - public LogicNode getY() { - return y; - } - - public boolean isXNegated() { - return xNegated; - } - - public boolean isYNegated() { - return yNegated; - } - - /** - * Gets the probability that the {@link #getY() y} part of this binary node is not - * evaluated. This is the probability that this operator will short-circuit its execution. - */ - public double getShortCircuitProbability() { - return shortCircuitProbability; - } - - protected abstract ShortCircuitBooleanNode createCopy(LogicNode xCond, boolean xNeg, LogicNode yCond, boolean yNeg, double probability); - - protected ShortCircuitBooleanNode canonicalizeNegation() { - LogicNode xCond = x; - boolean xNeg = xNegated; - while (xCond instanceof LogicNegationNode) { - xCond = ((LogicNegationNode) xCond).getInput(); - xNeg = !xNeg; - } - - LogicNode yCond = y; - boolean yNeg = yNegated; - while (yCond instanceof LogicNegationNode) { - yCond = ((LogicNegationNode) yCond).getInput(); - yNeg = !yNeg; - } - - if (xCond != x || yCond != y) { - return graph().unique(createCopy(xCond, xNeg, yCond, yNeg, shortCircuitProbability)); - } else { - return null; - } - } -} diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ShortCircuitOrNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ShortCircuitOrNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ShortCircuitOrNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -22,27 +22,79 @@ */ package com.oracle.graal.nodes; +import com.oracle.graal.graph.*; import com.oracle.graal.nodes.spi.*; -/** - * The short-circuit OR (i.e. {@code ||} in Java) operator. - */ -public class ShortCircuitOrNode extends ShortCircuitBooleanNode implements Canonicalizable { +public class ShortCircuitOrNode extends LogicNode implements Node.IterableNodeType, Canonicalizable { + + @Input private LogicNode x; + @Input private LogicNode y; + private boolean xNegated; + private boolean yNegated; + private double shortCircuitProbability; public ShortCircuitOrNode(LogicNode x, boolean xNegated, LogicNode y, boolean yNegated, double shortCircuitProbability) { - super(x, xNegated, y, yNegated, shortCircuitProbability); + this.x = x; + this.xNegated = xNegated; + this.y = y; + this.yNegated = yNegated; + this.shortCircuitProbability = shortCircuitProbability; + } + + public LogicNode getX() { + return x; + } + + public LogicNode getY() { + return y; + } + + public boolean isXNegated() { + return xNegated; + } + + public boolean isYNegated() { + return yNegated; + } + + /** + * Gets the probability that the {@link #getY() y} part of this binary node is not + * evaluated. This is the probability that this operator will short-circuit its execution. + */ + public double getShortCircuitProbability() { + return shortCircuitProbability; + } + + protected ShortCircuitOrNode canonicalizeNegation() { + LogicNode xCond = x; + boolean xNeg = xNegated; + while (xCond instanceof LogicNegationNode) { + xCond = ((LogicNegationNode) xCond).getInput(); + xNeg = !xNeg; + } + + LogicNode yCond = y; + boolean yNeg = yNegated; + while (yCond instanceof LogicNegationNode) { + yCond = ((LogicNegationNode) yCond).getInput(); + yNeg = !yNeg; + } + + if (xCond != x || yCond != y) { + return graph().unique(new ShortCircuitOrNode(xCond, xNeg, yCond, yNeg, shortCircuitProbability)); + } else { + return null; + } } @Override public LogicNode canonical(CanonicalizerTool tool) { - ShortCircuitBooleanNode ret = canonicalizeNegation(); + ShortCircuitOrNode ret = canonicalizeNegation(); if (ret != null) { return ret; } - LogicNode x = getX(); - LogicNode y = getY(); - if (x == y) { + if (getX() == getY()) { // @formatter:off // a || a = a // a || !a = true @@ -52,7 +104,7 @@ if (isXNegated()) { if (isYNegated()) { // !a || !a = !a - return graph().unique(new LogicNegationNode(x)); + return graph().unique(new LogicNegationNode(getX())); } else { // !a || a = true return LogicConstantNode.tautology(graph()); @@ -63,37 +115,32 @@ return LogicConstantNode.tautology(graph()); } else { // a || a = a - return x; + return getX(); } } } - if (x instanceof LogicConstantNode) { - if (((LogicConstantNode) x).getValue() ^ isXNegated()) { + if (getX() instanceof LogicConstantNode) { + if (((LogicConstantNode) getX()).getValue() ^ isXNegated()) { return LogicConstantNode.tautology(graph()); } else { if (isYNegated()) { - return graph().unique(new LogicNegationNode(y)); + return graph().unique(new LogicNegationNode(getY())); } else { - return y; + return getY(); } } } - if (y instanceof LogicConstantNode) { - if (((LogicConstantNode) y).getValue() ^ isYNegated()) { + if (getY() instanceof LogicConstantNode) { + if (((LogicConstantNode) getY()).getValue() ^ isYNegated()) { return LogicConstantNode.tautology(graph()); } else { if (isXNegated()) { - return graph().unique(new LogicNegationNode(x)); + return graph().unique(new LogicNegationNode(getX())); } else { - return x; + return getX(); } } } return this; } - - @Override - protected ShortCircuitBooleanNode createCopy(LogicNode xCond, boolean xNeg, LogicNode yCond, boolean yNeg, double probability) { - return new ShortCircuitOrNode(xCond, xNeg, yCond, yNeg, probability); - } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java Tue Sep 10 14:06:45 2013 -0700 @@ -37,6 +37,10 @@ */ public class StructuredGraph extends Graph { + public static enum GuardsPhase { + FLOATING_GUARDS, FIXED_DEOPTS, AFTER_FSA + } + public static final int INVOCATION_ENTRY_BCI = -1; public static final long INVALID_GRAPH_ID = -1; @@ -48,6 +52,7 @@ private final ResolvedJavaMethod method; private final long graphId; private final int entryBCI; + private GuardsPhase guardsPhase = GuardsPhase.FLOATING_GUARDS; /** * Creates a new Graph containing a single {@link AbstractBeginNode} as the {@link #start() @@ -386,4 +391,13 @@ singleEnd.replaceAndDelete(sux); } } + + public GuardsPhase getGuardsPhase() { + return guardsPhase; + } + + public void setGuardsPhase(GuardsPhase guardsPhase) { + assert guardsPhase.ordinal() >= this.guardsPhase.ordinal(); + this.guardsPhase = guardsPhase; + } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/UnwindNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/UnwindNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/UnwindNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -50,7 +50,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -140,4 +140,8 @@ assertTrue(kind() == kind().getStackKind(), "Should have a stack kind : %s", kind()); return super.verify(); } + + public ValueNode asNode() { + return this; + } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/WriteBarrier.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/WriteBarrier.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/WriteBarrier.java Tue Sep 10 14:06:45 2013 -0700 @@ -53,8 +53,8 @@ } @Override - public void lower(LoweringTool generator, LoweringType loweringType) { - assert loweringType == LoweringType.AFTER_FSA; + public void lower(LoweringTool generator) { + assert graph().getGuardsPhase() == StructuredGraph.GuardsPhase.AFTER_FSA; generator.getRuntime().lower(this, generator); } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/BinaryNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/BinaryNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/BinaryNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -150,14 +150,22 @@ return null; } + //@formatter:off /* * In reassociate, complexity comes from the handling of IntegerSub (non commutative) which can - * be mixed with IntegerAdd. if first tries to find m1, m2 which match the criterion : (a o m2) - * o m1 (m2 o a) o m1 m1 o (a o m2) m1 o (m2 o a) It then produces 4 boolean for the -/+ case - * invertA : should the final expression be like *-a (rather than a+*) aSub : should the final - * expression be like a-* (rather than a+*) invertM1 : should the final expression contain -m1 + * be mixed with IntegerAdd. It first tries to find m1, m2 which match the criterion : + * (a o m2) o m1 + * (m2 o a) o m1 + * m1 o (a o m2) + * m1 o (m2 o a) + * It then produces 4 boolean for the -/+ cases: + * invertA : should the final expression be like *-a (rather than a+*) + * aSub : should the final expression be like a-* (rather than a+*) + * invertM1 : should the final expression contain -m1 * invertM2 : should the final expression contain -m2 + * */ + //@formatter:on /** * Tries to re-associate values which satisfy the criterion. For example with a constantness * criterion : (a + 2) + 1 => a + (1 + 2)
diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConvertNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConvertNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConvertNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -235,7 +235,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerDivNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerDivNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerDivNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -110,7 +110,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerRemNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerRemNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerRemNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -61,7 +61,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/NormalizeCompareNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/NormalizeCompareNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/NormalizeCompareNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -48,7 +48,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { LogicNode equalComp; LogicNode lessComp; if (x().kind() == Kind.Double || x().kind() == Kind.Float) { diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnsignedDivNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnsignedDivNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnsignedDivNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -62,7 +62,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnsignedRemNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnsignedRemNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnsignedRemNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -61,7 +61,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/debug/DynamicCounterNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/debug/DynamicCounterNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/debug/DynamicCounterNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -166,7 +166,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { if (!enabled) { throw new GraalInternalError("counter nodes shouldn't exist when not enabled"); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/AccessNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/AccessNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/AccessNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -78,11 +78,6 @@ } @Override - public AccessNode asNode() { - return this; - } - - @Override public boolean canDeoptimize() { return nullCheck; } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BoxNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BoxNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BoxNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -53,7 +53,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BranchProbabilityNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BranchProbabilityNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BranchProbabilityNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -123,7 +123,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { throw new GraalInternalError("Branch probability could not be injected, because the probability value did not reduce to a constant value."); } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FloatingAccessNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FloatingAccessNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FloatingAccessNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -70,11 +70,6 @@ } @Override - public FloatingAccessNode asNode() { - return this; - } - - @Override public boolean canDeoptimize() { return nullCheck; } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -58,8 +58,8 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { - if (loweringType == LoweringType.AFTER_GUARDS) { + public void lower(LoweringTool tool) { + if (graph().getGuardsPhase() == StructuredGraph.GuardsPhase.FIXED_DEOPTS) { tool.getRuntime().lower(this, tool); } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadMethodNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadMethodNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadMethodNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -51,7 +51,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/NullCheckNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/NullCheckNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/NullCheckNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -54,9 +54,4 @@ public DeoptimizationReason getDeoptimizationReason() { return DeoptimizationReason.NullCheckException; } - - @Override - public ValueNode asNode() { - return this; - } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/OSRStartNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/OSRStartNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/OSRStartNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -29,7 +29,7 @@ public class OSRStartNode extends StartNode implements Lowerable { @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/StoreHubNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/StoreHubNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/StoreHubNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -46,7 +46,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnboxNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnboxNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnboxNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -48,7 +48,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeLoadNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeLoadNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeLoadNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -49,7 +49,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeStoreNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeStoreNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeStoreNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -68,7 +68,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ValueAnchorNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ValueAnchorNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ValueAnchorNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -114,9 +114,4 @@ } tool.delete(); } - - @Override - public ValueNode asNode() { - return this; - } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AbstractNewArrayNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AbstractNewArrayNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AbstractNewArrayNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -88,7 +88,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AccessFieldNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AccessFieldNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AccessFieldNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -83,7 +83,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AccessIndexedNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AccessIndexedNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AccessIndexedNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -64,7 +64,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ArrayLengthNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ArrayLengthNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ArrayLengthNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -62,7 +62,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastDynamicNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastDynamicNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastDynamicNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -59,7 +59,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -96,7 +96,7 @@ * {@code LoweringPhase.checkUsagesAreScheduled()}. */ @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { InstanceOfNode typeTest = graph().add(new InstanceOfNode(type, object, profile)); Stamp stamp = StampFactory.declared(type); if (stamp() instanceof ObjectStamp && object().stamp() instanceof ObjectStamp) { @@ -118,7 +118,7 @@ } else { // TODO (ds) replace with probability of null-seen when available double shortCircuitProbability = NOT_FREQUENT_PROBABILITY; - condition = graph().unique(new ShortCircuitOrNode(graph().unique(new IsNullNode(object)), false, typeTest, false, shortCircuitProbability)); + condition = LogicNode.or(graph().unique(new IsNullNode(object)), typeTest, shortCircuitProbability); } } GuardingPiNode checkedObject = graph().add(new GuardingPiNode(object, condition, false, forStoreCheck ? ArrayStoreException : ClassCastException, InvalidateReprofile, stamp)); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CompareAndSwapNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CompareAndSwapNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CompareAndSwapNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -78,7 +78,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ExceptionObjectNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ExceptionObjectNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ExceptionObjectNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -64,7 +64,7 @@ * runtime/interpreter would not have a valid location for the exception object to be rethrown. */ @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { if (isLowered()) { return; } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfDynamicNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfDynamicNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfDynamicNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -50,7 +50,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -51,7 +51,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoadExceptionObjectNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoadExceptionObjectNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoadExceptionObjectNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -44,7 +44,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MonitorEnterNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MonitorEnterNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MonitorEnterNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -50,7 +50,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MonitorExitNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MonitorExitNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MonitorExitNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -51,7 +51,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewInstanceNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewInstanceNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewInstanceNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -77,7 +77,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewMultiArrayNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewMultiArrayNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewMultiArrayNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -62,7 +62,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/SelfReplacingMethodCallTargetNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/SelfReplacingMethodCallTargetNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/SelfReplacingMethodCallTargetNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -28,7 +28,7 @@ import com.oracle.graal.api.meta.ResolvedJavaMethod; import com.oracle.graal.graph.GraalInternalError; import com.oracle.graal.graph.NodeInputList; -import com.oracle.graal.nodes.ValueNode; +import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.LIRGeneratorTool; import com.oracle.graal.nodes.spi.Lowerable; import com.oracle.graal.nodes.spi.LoweringTool; @@ -68,7 +68,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { InvokeKind invokeKind = Modifier.isStatic(replacementTargetMethod.getModifiers()) ? InvokeKind.Static : InvokeKind.Special; MethodCallTargetNode replacement = graph().add( new MethodCallTargetNode(invokeKind, replacementTargetMethod, replacementArguments.toArray(new ValueNode[replacementArguments.size()]), replacementReturnType)); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/Lowerable.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/Lowerable.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/Lowerable.java Tue Sep 10 14:06:45 2013 -0700 @@ -22,11 +22,11 @@ */ package com.oracle.graal.nodes.spi; +import com.oracle.graal.nodes.*; + public interface Lowerable { - public enum LoweringType { - BEFORE_GUARDS, AFTER_GUARDS, AFTER_FSA - } + void lower(LoweringTool tool); - void lower(LoweringTool tool, LoweringType loweringType); + ValueNode asNode(); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LoweringTool.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LoweringTool.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LoweringTool.java Tue Sep 10 14:06:45 2013 -0700 @@ -28,14 +28,11 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.cfg.*; import com.oracle.graal.nodes.extended.*; -import com.oracle.graal.nodes.spi.Lowerable.LoweringType; public interface LoweringTool { GraalCodeCacheProvider getRuntime(); - LoweringType getLoweringType(); - Replacements getReplacements(); GuardingNode createNullCheckGuard(GuardedNode guardedNode, ValueNode object); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/CommitAllocationNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/CommitAllocationNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/CommitAllocationNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -65,7 +65,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java Tue Sep 10 14:06:45 2013 -0700 @@ -31,24 +31,25 @@ import com.oracle.graal.graph.Graph.NodeChangedListener; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; -import com.oracle.graal.nodes.extended.*; -import com.oracle.graal.nodes.java.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.util.*; import com.oracle.graal.phases.*; +import com.oracle.graal.phases.PhasePlan.PhasePosition; import com.oracle.graal.phases.tiers.*; public class CanonicalizerPhase extends BasePhase { private static final int MAX_ITERATION_PER_NODE = 10; private static final DebugMetric METRIC_CANONICALIZED_NODES = Debug.metric("CanonicalizedNodes"); + private static final DebugMetric METRIC_PROCESSED_NODES = Debug.metric("ProcessedNodes"); private static final DebugMetric METRIC_CANONICALIZATION_CONSIDERED_NODES = Debug.metric("CanonicalizationConsideredNodes"); private static final DebugMetric METRIC_INFER_STAMP_CALLED = Debug.metric("InferStampCalled"); private static final DebugMetric METRIC_STAMP_CHANGED = Debug.metric("StampChanged"); private static final DebugMetric METRIC_SIMPLIFICATION_CONSIDERED_NODES = Debug.metric("SimplificationConsideredNodes"); - public static final DebugMetric METRIC_GLOBAL_VALUE_NUMBERING_HITS = Debug.metric("GlobalValueNumberingHits"); + private static final DebugMetric METRIC_GLOBAL_VALUE_NUMBERING_HITS = Debug.metric("GlobalValueNumberingHits"); private final boolean canonicalizeReads; + private final CustomCanonicalizer customCanonicalizer; public interface CustomCanonicalizer { @@ -56,15 +57,57 @@ } public CanonicalizerPhase(boolean canonicalizeReads) { + this(canonicalizeReads, null); + } + + public CanonicalizerPhase(boolean canonicalizeReads, CustomCanonicalizer customCanonicalizer) { this.canonicalizeReads = canonicalizeReads; + this.customCanonicalizer = customCanonicalizer; } @Override protected void run(StructuredGraph graph, PhaseContext context) { - new Instance(context.getRuntime(), context.getAssumptions(), canonicalizeReads).run(graph); + new Instance(context.getRuntime(), context.getAssumptions(), canonicalizeReads, customCanonicalizer).run(graph); + } + + /** + * @param newNodesMark only the {@linkplain Graph#getNewNodes(int) new nodes} specified by this + * mark are processed + */ + public void applyIncremental(StructuredGraph graph, PhaseContext context, int newNodesMark) { + applyIncremental(graph, context, newNodesMark, true); + } + + public void applyIncremental(StructuredGraph graph, PhaseContext context, int newNodesMark, boolean dumpGraph) { + new Instance(context.getRuntime(), context.getAssumptions(), canonicalizeReads, newNodesMark, customCanonicalizer).apply(graph, dumpGraph); } - public static class Instance extends Phase { + /** + * @param workingSet the initial working set of nodes on which the canonicalizer works, should + * be an auto-grow node bitmap + */ + public void applyIncremental(StructuredGraph graph, PhaseContext context, Iterable workingSet) { + applyIncremental(graph, context, workingSet, true); + } + + public void applyIncremental(StructuredGraph graph, PhaseContext context, Iterable workingSet, boolean dumpGraph) { + new Instance(context.getRuntime(), context.getAssumptions(), canonicalizeReads, workingSet, customCanonicalizer).apply(graph, dumpGraph); + } + + public void applyIncremental(StructuredGraph graph, PhaseContext context, Iterable workingSet, int newNodesMark) { + applyIncremental(graph, context, workingSet, newNodesMark, true); + } + + public void applyIncremental(StructuredGraph graph, PhaseContext context, Iterable workingSet, int newNodesMark, boolean dumpGraph) { + new Instance(context.getRuntime(), context.getAssumptions(), canonicalizeReads, workingSet, newNodesMark, customCanonicalizer).apply(graph, dumpGraph); + } + + @Deprecated + public void addToPhasePlan(PhasePlan plan, PhaseContext context) { + plan.addPhase(PhasePosition.AFTER_PARSING, new Instance(context.getRuntime(), context.getAssumptions(), canonicalizeReads, customCanonicalizer)); + } + + private static final class Instance extends Phase { private final int newNodesMark; private final Assumptions assumptions; @@ -76,34 +119,19 @@ private NodeWorkList workList; private Tool tool; - public Instance(MetaAccessProvider runtime, Assumptions assumptions, boolean canonicalizeReads) { - this(runtime, assumptions, canonicalizeReads, null, 0, null); + private Instance(MetaAccessProvider runtime, Assumptions assumptions, boolean canonicalizeReads, CustomCanonicalizer customCanonicalizer) { + this(runtime, assumptions, canonicalizeReads, null, 0, customCanonicalizer); } - /** - * @param runtime - * @param assumptions - * @param workingSet the initial working set of nodes on which the canonicalizer works, - * should be an auto-grow node bitmap - * @param customCanonicalizer - * @param canonicalizeReads flag to indicate if - * {@link LoadFieldNode#canonical(CanonicalizerTool)} and - * {@link ReadNode#canonical(CanonicalizerTool)} should canonicalize reads of - * constant fields. - */ - public Instance(MetaAccessProvider runtime, Assumptions assumptions, boolean canonicalizeReads, Iterable workingSet, CustomCanonicalizer customCanonicalizer) { + private Instance(MetaAccessProvider runtime, Assumptions assumptions, boolean canonicalizeReads, Iterable workingSet, CustomCanonicalizer customCanonicalizer) { this(runtime, assumptions, canonicalizeReads, workingSet, 0, customCanonicalizer); } - /** - * @param newNodesMark only the {@linkplain Graph#getNewNodes(int) new nodes} specified by - * this mark are processed otherwise all nodes in the graph are processed - */ - public Instance(MetaAccessProvider runtime, Assumptions assumptions, boolean canonicalizeReads, int newNodesMark, CustomCanonicalizer customCanonicalizer) { + private Instance(MetaAccessProvider runtime, Assumptions assumptions, boolean canonicalizeReads, int newNodesMark, CustomCanonicalizer customCanonicalizer) { this(runtime, assumptions, canonicalizeReads, null, newNodesMark, customCanonicalizer); } - public Instance(MetaAccessProvider runtime, Assumptions assumptions, boolean canonicalizeReads, Iterable workingSet, int newNodesMark, CustomCanonicalizer customCanonicalizer) { + private Instance(MetaAccessProvider runtime, Assumptions assumptions, boolean canonicalizeReads, Iterable workingSet, int newNodesMark, CustomCanonicalizer customCanonicalizer) { super("Canonicalizer"); this.newNodesMark = newNodesMark; this.assumptions = assumptions; @@ -160,14 +188,13 @@ if (!tryCanonicalize(node)) { if (node instanceof ValueNode) { ValueNode valueNode = (ValueNode) node; - if (tryInferStamp(valueNode)) { - Constant constant = valueNode.stamp().asConstant(); - if (constant != null) { - performReplacement(valueNode, ConstantNode.forConstant(constant, runtime, valueNode.graph())); - } else { - // the improved stamp may enable additional canonicalization - tryCanonicalize(valueNode); - } + boolean improvedStamp = tryInferStamp(valueNode); + Constant constant = valueNode.stamp().asConstant(); + if (constant != null && !(node instanceof ConstantNode)) { + performReplacement(valueNode, ConstantNode.forConstant(constant, runtime, valueNode.graph())); + } else if (improvedStamp) { + // the improved stamp may enable additional canonicalization + tryCanonicalize(valueNode); } } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ExpandLogicPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ExpandLogicPhase.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ExpandLogicPhase.java Tue Sep 10 14:06:45 2013 -0700 @@ -31,33 +31,21 @@ @Override protected void run(StructuredGraph graph) { - for (ShortCircuitBooleanNode logic : graph.getNodes(ShortCircuitBooleanNode.class)) { + for (ShortCircuitOrNode logic : graph.getNodes(ShortCircuitOrNode.class)) { processBinary(logic); } - assert graph.getNodes(ShortCircuitBooleanNode.class).isEmpty(); + assert graph.getNodes(ShortCircuitOrNode.class).isEmpty(); } - private static void processBinary(ShortCircuitBooleanNode binary) { + private static void processBinary(ShortCircuitOrNode binary) { while (binary.usages().isNotEmpty()) { Node usage = binary.usages().first(); - if (usage instanceof ShortCircuitBooleanNode) { - processBinary((ShortCircuitBooleanNode) usage); + if (usage instanceof ShortCircuitOrNode) { + processBinary((ShortCircuitOrNode) usage); } else if (usage instanceof IfNode) { - if (binary instanceof ShortCircuitAndNode) { - processIf(binary.getX(), binary.isXNegated(), binary.getY(), binary.isYNegated(), (IfNode) usage, false, binary.getShortCircuitProbability()); - } else if (binary instanceof ShortCircuitOrNode) { - processIf(binary.getX(), !binary.isXNegated(), binary.getY(), !binary.isYNegated(), (IfNode) usage, true, binary.getShortCircuitProbability()); - } else { - throw GraalInternalError.shouldNotReachHere(); - } + processIf(binary.getX(), binary.isXNegated(), binary.getY(), binary.isYNegated(), (IfNode) usage, binary.getShortCircuitProbability()); } else if (usage instanceof ConditionalNode) { - if (binary instanceof ShortCircuitOrNode) { - processConditional(binary.getX(), binary.isXNegated(), binary.getY(), binary.isYNegated(), (ConditionalNode) usage, false); - } else if (binary instanceof ShortCircuitOrNode) { - processConditional(binary.getX(), !binary.isXNegated(), binary.getY(), !binary.isYNegated(), (ConditionalNode) usage, true); - } else { - throw GraalInternalError.shouldNotReachHere(); - } + processConditional(binary.getX(), binary.isXNegated(), binary.getY(), binary.isYNegated(), (ConditionalNode) usage); } else { throw GraalInternalError.shouldNotReachHere(); } @@ -65,33 +53,44 @@ binary.safeDelete(); } - private static void processIf(LogicNode x, boolean xNegated, LogicNode y, boolean yNegated, IfNode ifNode, boolean negateTargets, double shortCircuitProbability) { - AbstractBeginNode trueTarget = negateTargets ? ifNode.falseSuccessor() : ifNode.trueSuccessor(); - AbstractBeginNode falseTarget = negateTargets ? ifNode.trueSuccessor() : ifNode.falseSuccessor(); + private static void processIf(LogicNode x, boolean xNegated, LogicNode y, boolean yNegated, IfNode ifNode, double shortCircuitProbability) { + AbstractBeginNode trueTarget = ifNode.trueSuccessor(); + AbstractBeginNode falseTarget = ifNode.falseSuccessor(); double firstIfProbability = shortCircuitProbability; - double secondIfProbability = 1 - ifNode.probability(trueTarget); + /* + * P(Y | not(X)) = P(Y inter not(X)) / P(not(X)) = (P(X union Y) - P(X)) / (1 - P(X)) + * + * P(X) = shortCircuitProbability + * + * P(X union Y) = ifNode.probability(trueTarget) + */ + double secondIfProbability = (ifNode.probability(trueTarget) - shortCircuitProbability) / (1 - shortCircuitProbability); + secondIfProbability = Math.min(1.0, Math.max(0.0, secondIfProbability)); + if (Double.isNaN(secondIfProbability)) { + secondIfProbability = 0.5; + } ifNode.clearSuccessors(); Graph graph = ifNode.graph(); - MergeNode falseTargetMerge = graph.add(new MergeNode()); - falseTargetMerge.setNext(falseTarget); - EndNode firstFalseEnd = graph.add(new EndNode()); - EndNode secondFalseEnd = graph.add(new EndNode()); - falseTargetMerge.addForwardEnd(firstFalseEnd); - falseTargetMerge.addForwardEnd(secondFalseEnd); - AbstractBeginNode firstFalseTarget = AbstractBeginNode.begin(firstFalseEnd); - AbstractBeginNode secondFalseTarget = AbstractBeginNode.begin(secondFalseEnd); - AbstractBeginNode secondIf = AbstractBeginNode.begin(graph.add(new IfNode(y, yNegated ? firstFalseTarget : trueTarget, yNegated ? trueTarget : firstFalseTarget, secondIfProbability))); - IfNode firstIf = graph.add(new IfNode(x, xNegated ? secondFalseTarget : secondIf, xNegated ? secondIf : secondFalseTarget, firstIfProbability)); + MergeNode trueTargetMerge = graph.add(new MergeNode()); + trueTargetMerge.setNext(trueTarget); + EndNode firstTrueEnd = graph.add(new EndNode()); + EndNode secondTrueEnd = graph.add(new EndNode()); + trueTargetMerge.addForwardEnd(firstTrueEnd); + trueTargetMerge.addForwardEnd(secondTrueEnd); + AbstractBeginNode firstTrueTarget = AbstractBeginNode.begin(firstTrueEnd); + AbstractBeginNode secondTrueTarget = AbstractBeginNode.begin(secondTrueEnd); + AbstractBeginNode secondIf = AbstractBeginNode.begin(graph.add(new IfNode(y, yNegated ? falseTarget : secondTrueTarget, yNegated ? secondTrueTarget : falseTarget, secondIfProbability))); + IfNode firstIf = graph.add(new IfNode(x, xNegated ? secondIf : firstTrueTarget, xNegated ? firstTrueTarget : secondIf, firstIfProbability)); ifNode.replaceAtPredecessor(firstIf); ifNode.safeDelete(); } - private static void processConditional(LogicNode x, boolean xNegated, LogicNode y, boolean yNegated, ConditionalNode conditional, boolean negateTargets) { - ValueNode trueTarget = negateTargets ? conditional.falseValue() : conditional.trueValue(); - ValueNode falseTarget = negateTargets ? conditional.trueValue() : conditional.falseValue(); + private static void processConditional(LogicNode x, boolean xNegated, LogicNode y, boolean yNegated, ConditionalNode conditional) { + ValueNode trueTarget = conditional.trueValue(); + ValueNode falseTarget = conditional.falseValue(); Graph graph = conditional.graph(); ConditionalNode secondConditional = graph.unique(new ConditionalNode(y, yNegated ? falseTarget : trueTarget, yNegated ? trueTarget : falseTarget)); - ConditionalNode firstConditional = graph.unique(new ConditionalNode(x, xNegated ? falseTarget : secondConditional, xNegated ? secondConditional : falseTarget)); + ConditionalNode firstConditional = graph.unique(new ConditionalNode(x, xNegated ? secondConditional : trueTarget, xNegated ? trueTarget : secondConditional)); conditional.replaceAndDelete(firstConditional); } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FrameStateAssignmentPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FrameStateAssignmentPhase.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FrameStateAssignmentPhase.java Tue Sep 10 14:06:45 2013 -0700 @@ -27,6 +27,7 @@ import com.oracle.graal.graph.*; import com.oracle.graal.graph.iterators.*; import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.StructuredGraph.GuardsPhase; import com.oracle.graal.nodes.util.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.graph.*; @@ -77,6 +78,8 @@ protected void run(StructuredGraph graph) { assert checkFixedDeopts(graph); ReentrantNodeIterator.apply(new FrameStateAssignmentClosure(), graph.start(), null, null); + + graph.setGuardsPhase(GuardsPhase.AFTER_FSA); } private static boolean checkFixedDeopts(StructuredGraph graph) { diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java Tue Sep 10 14:06:45 2013 -0700 @@ -29,6 +29,7 @@ import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.StructuredGraph.GuardsPhase; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.cfg.*; import com.oracle.graal.nodes.extended.*; @@ -187,6 +188,8 @@ for (Block block : schedule.getCFG().getBlocks()) { processBlock(block, schedule, context.getTarget().implicitNullCheckLimit); } + + graph.setGuardsPhase(GuardsPhase.FIXED_DEOPTS); } private static void processBlock(Block block, SchedulePhase schedule, int implicitNullCheckLimit) { diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/IncrementalCanonicalizerPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/IncrementalCanonicalizerPhase.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/IncrementalCanonicalizerPhase.java Tue Sep 10 14:06:45 2013 -0700 @@ -22,29 +22,42 @@ */ package com.oracle.graal.phases.common; -import static com.oracle.graal.phases.GraalOptions.*; +import java.util.*; +import com.oracle.graal.graph.Graph.NodeChangedListener; +import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; import com.oracle.graal.phases.*; -import com.oracle.graal.phases.common.CanonicalizerPhase.CustomCanonicalizer; import com.oracle.graal.phases.tiers.*; public class IncrementalCanonicalizerPhase extends PhaseSuite { - private final CustomCanonicalizer customCanonicalizer; + private final CanonicalizerPhase canonicalizer; - public IncrementalCanonicalizerPhase() { - this(null); - } - - public IncrementalCanonicalizerPhase(CustomCanonicalizer customCanonicalizer) { - this.customCanonicalizer = customCanonicalizer; + public IncrementalCanonicalizerPhase(CanonicalizerPhase canonicalizer) { + this.canonicalizer = canonicalizer; } @Override protected void run(StructuredGraph graph, C context) { - int mark = graph.getMark(); + int newNodesMark = graph.getMark(); + final Set changedNodes = new HashSet<>(); + + NodeChangedListener listener = new NodeChangedListener() { + + @Override + public void nodeChanged(Node node) { + changedNodes.add(node); + } + }; + graph.trackInputChange(listener); + graph.trackUsagesDroppedZero(listener); + super.run(graph, context); - new CanonicalizerPhase.Instance(context.getRuntime(), context.getAssumptions(), !AOTCompilation.getValue(), mark, customCanonicalizer).apply(graph); + + graph.stopTrackingInputChange(); + graph.stopTrackingUsagesDroppedZero(); + + canonicalizer.applyIncremental(graph, context, changedNodes, newNodesMark, false); } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java Tue Sep 10 14:06:45 2013 -0700 @@ -39,7 +39,6 @@ import com.oracle.graal.nodes.util.*; import com.oracle.graal.options.*; import com.oracle.graal.phases.PhasePlan.PhasePosition; -import com.oracle.graal.phases.common.CanonicalizerPhase.CustomCanonicalizer; import com.oracle.graal.phases.common.InliningUtil.InlineInfo; import com.oracle.graal.phases.common.InliningUtil.Inlineable; import com.oracle.graal.phases.common.InliningUtil.InlineableGraph; @@ -59,7 +58,7 @@ } private final InliningPolicy inliningPolicy; - private final CustomCanonicalizer customCanonicalizer; + private final CanonicalizerPhase canonicalizer; private int inliningCount; private int maxMethodPerInlining = Integer.MAX_VALUE; @@ -70,25 +69,17 @@ private static final DebugMetric metricInliningStoppedByMaxDesiredSize = Debug.metric("InliningStoppedByMaxDesiredSize"); private static final DebugMetric metricInliningRuns = Debug.metric("Runs"); - public InliningPhase() { - this(new GreedyInliningPolicy(null), null); - } - - public InliningPhase(CustomCanonicalizer canonicalizer) { + public InliningPhase(CanonicalizerPhase canonicalizer) { this(new GreedyInliningPolicy(null), canonicalizer); } - public InliningPhase(Map hints) { - this(new GreedyInliningPolicy(hints), null); + public InliningPhase(Map hints, CanonicalizerPhase canonicalizer) { + this(new GreedyInliningPolicy(hints), canonicalizer); } - public InliningPhase(InliningPolicy policy) { - this(policy, null); - } - - private InliningPhase(InliningPolicy policy, CustomCanonicalizer customCanonicalizer) { + public InliningPhase(InliningPolicy policy, CanonicalizerPhase canonicalizer) { this.inliningPolicy = policy; - this.customCanonicalizer = customCanonicalizer; + this.canonicalizer = canonicalizer; } public void setMaxMethodsPerInlining(int max) { @@ -163,7 +154,7 @@ MethodInvocation calleeInvocation = data.pushInvocation(info, parentAssumptions, invokeProbability, invokeRelevance); for (int i = 0; i < info.numberOfMethods(); i++) { - Inlineable elem = getInlineableElement(info.methodAt(i), info.invoke(), calleeInvocation.assumptions(), context); + Inlineable elem = getInlineableElement(info.methodAt(i), info.invoke(), context.replaceAssumptions(calleeInvocation.assumptions())); info.setInlinableElement(i, elem); if (elem instanceof InlineableGraph) { data.pushGraph(((InlineableGraph) elem).getGraph(), invokeProbability * info.probabilityAt(i), invokeRelevance * info.relevanceAt(i)); @@ -200,7 +191,7 @@ if (OptCanonicalizer.getValue()) { int markBeforeCanonicalization = callerGraph.getMark(); - new CanonicalizerPhase.Instance(context.getRuntime(), callerAssumptions, !AOTCompilation.getValue(), invokeUsages, markBeforeInlining, customCanonicalizer).apply(callerGraph); + canonicalizer.applyIncremental(callerGraph, context, invokeUsages, markBeforeInlining); // process invokes that are possibly created during canonicalization for (Node newNode : callerGraph.getNewNodes(markBeforeCanonicalization)) { @@ -223,16 +214,16 @@ } } - private static Inlineable getInlineableElement(final ResolvedJavaMethod method, Invoke invoke, Assumptions assumptions, HighTierContext context) { + private Inlineable getInlineableElement(final ResolvedJavaMethod method, Invoke invoke, HighTierContext context) { Class macroNodeClass = InliningUtil.getMacroNodeClass(context.getReplacements(), method); if (macroNodeClass != null) { return new InlineableMacroNode(macroNodeClass); } else { - return new InlineableGraph(buildGraph(method, invoke, assumptions, context)); + return new InlineableGraph(buildGraph(method, invoke, context)); } } - private static StructuredGraph buildGraph(final ResolvedJavaMethod method, final Invoke invoke, final Assumptions assumptions, final HighTierContext context) { + private StructuredGraph buildGraph(final ResolvedJavaMethod method, final Invoke invoke, final HighTierContext context) { final StructuredGraph newGraph; final boolean parseBytecodes; @@ -258,7 +249,7 @@ @Override public StructuredGraph call() throws Exception { if (parseBytecodes) { - parseBytecodes(newGraph, assumptions, context); + parseBytecodes(newGraph, context); } boolean callerHasMoreInformationAboutArguments = false; @@ -285,7 +276,7 @@ } if (OptCanonicalizer.getValue()) { - new CanonicalizerPhase.Instance(context.getRuntime(), assumptions, !AOTCompilation.getValue()).apply(newGraph); + canonicalizer.apply(newGraph, context); } return newGraph; @@ -303,7 +294,7 @@ return null; } - private static StructuredGraph parseBytecodes(StructuredGraph newGraph, Assumptions assumptions, HighTierContext context) { + private StructuredGraph parseBytecodes(StructuredGraph newGraph, HighTierContext context) { boolean hasMatureProfilingInfo = newGraph.method().getProfilingInfo().isMature(); if (context.getPhasePlan() != null) { @@ -314,7 +305,7 @@ new DeadCodeEliminationPhase().apply(newGraph); if (OptCanonicalizer.getValue()) { - new CanonicalizerPhase.Instance(context.getRuntime(), assumptions, !AOTCompilation.getValue()).apply(newGraph); + canonicalizer.apply(newGraph, context); } if (CacheGraphs.getValue() && context.getGraphCache() != null) { diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java Tue Sep 10 14:06:45 2013 -0700 @@ -38,7 +38,7 @@ import com.oracle.graal.api.meta.ResolvedJavaType.Representation; import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; -import com.oracle.graal.graph.Node.*; +import com.oracle.graal.graph.Node.Verbosity; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.extended.*; @@ -707,7 +707,8 @@ if (opportunities > 0) { metricInliningTailDuplication.increment(); Debug.log("MultiTypeGuardInlineInfo starting tail duplication (%d opportunities)", opportunities); - TailDuplicationPhase.tailDuplicate(returnMerge, TailDuplicationPhase.TRUE_DECISION, replacementNodes, new PhaseContext(runtime, assumptions, replacements)); + TailDuplicationPhase.tailDuplicate(returnMerge, TailDuplicationPhase.TRUE_DECISION, replacementNodes, new PhaseContext(runtime, assumptions, replacements), new CanonicalizerPhase( + !AOTCompilation.getValue())); } } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/IterativeConditionalEliminationPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/IterativeConditionalEliminationPhase.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/IterativeConditionalEliminationPhase.java Tue Sep 10 14:06:45 2013 -0700 @@ -22,8 +22,6 @@ */ package com.oracle.graal.phases.common; -import static com.oracle.graal.phases.GraalOptions.*; - import com.oracle.graal.api.code.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; @@ -36,6 +34,12 @@ private static final int MAX_ITERATIONS = 256; + private final CanonicalizerPhase canonicalizer; + + public IterativeConditionalEliminationPhase(CanonicalizerPhase canonicalizer) { + this.canonicalizer = canonicalizer; + } + @Override protected void run(StructuredGraph graph, PhaseContext context) { ConditionalEliminationPhase eliminate = new ConditionalEliminationPhase(context.getRuntime()); @@ -55,7 +59,7 @@ listener.getChangedNodes().add(node); } } - new CanonicalizerPhase.Instance(context.getRuntime(), context.getAssumptions(), !AOTCompilation.getValue(), listener.getChangedNodes(), null).apply(graph); + canonicalizer.applyIncremental(graph, context, listener.getChangedNodes()); listener.getChangedNodes().clear(); if (++count > MAX_ITERATIONS) { throw new BailoutException("Number of iterations in conditional elimination phase exceeds " + MAX_ITERATIONS); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java Tue Sep 10 14:06:45 2013 -0700 @@ -35,7 +35,6 @@ import com.oracle.graal.nodes.cfg.*; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; -import com.oracle.graal.nodes.spi.Lowerable.LoweringType; import com.oracle.graal.nodes.type.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.schedule.*; @@ -73,11 +72,6 @@ } @Override - public LoweringType getLoweringType() { - return loweringType; - } - - @Override public GuardingNode createNullCheckGuard(GuardedNode guardedNode, ValueNode object) { if (ObjectStamp.isObjectNonNull(object)) { // Short cut creation of null check guard if the object is known to be non-null. @@ -101,8 +95,8 @@ @Override public GuardingNode createGuard(LogicNode condition, DeoptimizationReason deoptReason, DeoptimizationAction action, boolean negated) { - if (loweringType != LoweringType.BEFORE_GUARDS) { - throw new GraalInternalError("Cannot create guards in after-guard lowering"); + if (condition.graph().getGuardsPhase().ordinal() > StructuredGraph.GuardsPhase.FLOATING_GUARDS.ordinal()) { + throw new GraalInternalError("Cannot create guards after guard lowering"); } if (OptEliminateGuards.getValue()) { for (Node usage : condition.usages()) { @@ -134,11 +128,10 @@ } } - private final LoweringType loweringType; + private final CanonicalizerPhase canonicalizer; - public LoweringPhase(LoweringType loweringType) { - super("Lowering (" + loweringType.name() + ")"); - this.loweringType = loweringType; + public LoweringPhase(CanonicalizerPhase canonicalizer) { + this.canonicalizer = canonicalizer; } private static boolean containsLowerable(NodeIterable nodes) { @@ -154,12 +147,11 @@ protected void run(final StructuredGraph graph, PhaseContext context) { int i = 0; while (true) { - Round round = new Round(i++, context); int mark = graph.getMark(); - IncrementalCanonicalizerPhase canonicalizer = new IncrementalCanonicalizerPhase<>(); - canonicalizer.appendPhase(round); - canonicalizer.apply(graph, context); + IncrementalCanonicalizerPhase incrementalCanonicalizer = new IncrementalCanonicalizerPhase<>(canonicalizer); + incrementalCanonicalizer.appendPhase(new Round(i++, context)); + incrementalCanonicalizer.apply(graph, context); if (!containsLowerable(graph.getNewNodes(mark))) { // No new lowerable nodes - done! @@ -239,7 +231,7 @@ if (node instanceof Lowerable) { assert checkUsagesAreScheduled(node); - ((Lowerable) node).lower(loweringTool, loweringType); + ((Lowerable) node).lower(loweringTool); } if (!nextNode.isAlive()) { diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java Tue Sep 10 14:06:45 2013 -0700 @@ -42,8 +42,8 @@ /** * This class is a phase that looks for opportunities for tail duplication. The static method - * {@link #tailDuplicate(MergeNode, TailDuplicationDecision, List, PhaseContext)} can also be used - * to drive tail duplication from other places, e.g., inlining. + * {@link #tailDuplicate(MergeNode, TailDuplicationDecision, List, PhaseContext, CanonicalizerPhase)} + * can also be used to drive tail duplication from other places, e.g., inlining. */ public class TailDuplicationPhase extends BasePhase { @@ -53,6 +53,8 @@ private static final DebugMetric metricDuplicationConsidered = Debug.metric("DuplicationConsidered"); private static final DebugMetric metricDuplicationPerformed = Debug.metric("DuplicationPerformed"); + private final CanonicalizerPhase canonicalizer; + /** * This interface is used by tail duplication to let clients decide if tail duplication should * be performed. @@ -129,6 +131,10 @@ } }; + public TailDuplicationPhase(CanonicalizerPhase canonicalizer) { + this.canonicalizer = canonicalizer; + } + @Override protected void run(StructuredGraph graph, PhaseContext phaseContext) { NodesToDoubles nodeProbabilities = new ComputeProbabilityClosure(graph).apply(); @@ -137,7 +143,7 @@ // duplication. for (MergeNode merge : graph.getNodes(MergeNode.class).snapshot()) { if (!(merge instanceof LoopBeginNode) && nodeProbabilities.get(merge) >= TailDuplicationProbability.getValue()) { - tailDuplicate(merge, DEFAULT_DECISION, null, phaseContext); + tailDuplicate(merge, DEFAULT_DECISION, null, phaseContext, canonicalizer); } } } @@ -159,7 +165,7 @@ * {@link PiNode} in the duplicated branch that corresponds to the entry. * @param phaseContext */ - public static boolean tailDuplicate(MergeNode merge, TailDuplicationDecision decision, List replacements, PhaseContext phaseContext) { + public static boolean tailDuplicate(MergeNode merge, TailDuplicationDecision decision, List replacements, PhaseContext phaseContext, CanonicalizerPhase canonicalizer) { assert !(merge instanceof LoopBeginNode); assert replacements == null || replacements.size() == merge.forwardEndCount(); FixedNode fixed = merge; @@ -172,7 +178,7 @@ metricDuplicationConsidered.increment(); if (decision.doTransform(merge, fixedCount)) { metricDuplicationPerformed.increment(); - new DuplicationOperation(merge, replacements).duplicate(phaseContext); + new DuplicationOperation(merge, replacements, canonicalizer).duplicate(phaseContext); return true; } } @@ -190,6 +196,8 @@ private final HashMap bottomPhis = new HashMap<>(); private final List replacements; + private final CanonicalizerPhase canonicalizer; + /** * Initializes the tail duplication operation without actually performing any work. * @@ -197,10 +205,11 @@ * @param replacements A list of replacement {@link PiNode}s, or null. If this is non-null, * then the size of the list needs to match the number of end nodes at the merge. */ - public DuplicationOperation(MergeNode merge, List replacements) { + public DuplicationOperation(MergeNode merge, List replacements, CanonicalizerPhase canonicalizer) { this.merge = merge; this.replacements = replacements; this.graph = merge.graph(); + this.canonicalizer = canonicalizer; } /** @@ -289,7 +298,7 @@ phi.setMerge(mergeAfter); } } - new CanonicalizerPhase.Instance(phaseContext.getRuntime(), phaseContext.getAssumptions(), !AOTCompilation.getValue(), graph.getNewNodes(startMark), null).apply(graph); + canonicalizer.applyIncremental(graph, phaseContext, startMark); Debug.dump(graph, "After tail duplication at %s", merge); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/BasePhase.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/BasePhase.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/BasePhase.java Tue Sep 10 14:06:45 2013 -0700 @@ -33,8 +33,8 @@ public abstract class BasePhase { private String name; + private static final DebugMetric metricPhaseRuns = Debug.metric("Runs"); - protected static final DebugMetric METRIC_PROCESSED_NODES = Debug.metric("ProcessedNodes"); protected BasePhase() { this.name = this.getClass().getSimpleName(); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/HighTierContext.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/HighTierContext.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/HighTierContext.java Tue Sep 10 14:06:45 2013 -0700 @@ -52,4 +52,8 @@ public OptimisticOptimizations getOptimisticOptimizations() { return optimisticOpts; } + + public HighTierContext replaceAssumptions(Assumptions newAssumptions) { + return new HighTierContext(getRuntime(), newAssumptions, getReplacements(), getGraphCache(), getPhasePlan(), getOptimisticOptimizations()); + } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/MethodSubstitutionTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/MethodSubstitutionTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/MethodSubstitutionTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -53,7 +53,7 @@ Assumptions assumptions = new Assumptions(true); HighTierContext context = new HighTierContext(runtime(), assumptions, replacements, null, phasePlan, OptimisticOptimizations.ALL); Debug.dump(graph, "Graph"); - new InliningPhase().apply(graph, context); + new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); Debug.dump(graph, "Graph"); new CanonicalizerPhase(true).apply(graph, context); new DeadCodeEliminationPhase().apply(graph); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InstanceOfSnippetsTemplates.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InstanceOfSnippetsTemplates.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InstanceOfSnippetsTemplates.java Tue Sep 10 14:06:45 2013 -0700 @@ -93,7 +93,7 @@ */ protected InstanceOfUsageReplacer createReplacer(FloatingNode instanceOf, Instantiation instantiation, Node usage, final StructuredGraph graph) { InstanceOfUsageReplacer replacer; - if (usage instanceof IfNode || usage instanceof FixedGuardNode || usage instanceof ShortCircuitBooleanNode || usage instanceof GuardingPiNode) { + if (usage instanceof IfNode || usage instanceof FixedGuardNode || usage instanceof ShortCircuitOrNode || usage instanceof GuardingPiNode) { replacer = new NonMaterializationUsageReplacer(instantiation, ConstantNode.forInt(1, graph), ConstantNode.forInt(0, graph), instanceOf, usage); } else { assert usage instanceof ConditionalNode : "unexpected usage of " + instanceOf + ": " + usage; diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Tue Sep 10 14:06:45 2013 -0700 @@ -44,6 +44,7 @@ import com.oracle.graal.nodes.spi.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.common.*; +import com.oracle.graal.phases.tiers.*; import com.oracle.graal.replacements.Snippet.DefaultSnippetInliningPolicy; import com.oracle.graal.replacements.Snippet.SnippetInliningPolicy; import com.oracle.graal.word.phases.*; @@ -331,7 +332,7 @@ new WordTypeVerificationPhase(runtime, target.wordKind).apply(graph); if (OptCanonicalizer.getValue()) { new WordTypeRewriterPhase(runtime, target.wordKind).apply(graph); - new CanonicalizerPhase.Instance(runtime, assumptions, true).apply(graph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime, assumptions, ReplacementsImpl.this)); } } }); @@ -352,7 +353,7 @@ protected void afterInline(StructuredGraph caller, StructuredGraph callee, Object beforeInlineData) { if (OptCanonicalizer.getValue()) { new WordTypeRewriterPhase(runtime, target.wordKind).apply(caller); - new CanonicalizerPhase.Instance(runtime, assumptions, true).apply(caller); + new CanonicalizerPhase(true).apply(caller, new PhaseContext(runtime, assumptions, ReplacementsImpl.this)); } } @@ -366,7 +367,7 @@ new DeadCodeEliminationPhase().apply(graph); if (OptCanonicalizer.getValue()) { - new CanonicalizerPhase.Instance(runtime, assumptions, true).apply(graph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime, assumptions, ReplacementsImpl.this)); } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Tue Sep 10 14:06:45 2013 -0700 @@ -41,6 +41,7 @@ import com.oracle.graal.nodes.type.*; import com.oracle.graal.nodes.util.*; import com.oracle.graal.phases.common.*; +import com.oracle.graal.phases.tiers.*; import com.oracle.graal.replacements.Snippet.ConstantParameter; import com.oracle.graal.replacements.Snippet.VarargsParameter; import com.oracle.graal.replacements.nodes.*; @@ -388,6 +389,8 @@ ResolvedJavaMethod method = snippetGraph.method(); Signature signature = method.getSignature(); + PhaseContext context = new PhaseContext(runtime, replacements.getAssumptions(), replacements); + // Copy snippet graph, replacing constant parameters with given arguments StructuredGraph snippetCopy = new StructuredGraph(snippetGraph.name, snippetGraph.method()); IdentityHashMap nodeReplacements = new IdentityHashMap<>(); @@ -425,7 +428,7 @@ new NodeIntrinsificationPhase(runtime).apply(snippetCopy); new WordTypeRewriterPhase(runtime, target.wordKind).apply(snippetCopy); - new CanonicalizerPhase.Instance(runtime, replacements.getAssumptions(), true, 0, null).apply(snippetCopy); + new CanonicalizerPhase(true).apply(snippetCopy, context); } NodeIntrinsificationVerificationPhase.verify(snippetCopy); @@ -481,8 +484,8 @@ if (loopBegin != null) { LoopEx loop = new LoopsData(snippetCopy).loop(loopBegin); int mark = snippetCopy.getMark(); - LoopTransformations.fullUnroll(loop, runtime, replacements.getAssumptions(), true); - new CanonicalizerPhase.Instance(runtime, replacements.getAssumptions(), true, mark, null).apply(snippetCopy); + LoopTransformations.fullUnroll(loop, context, new CanonicalizerPhase(true)); + new CanonicalizerPhase(true).applyIncremental(snippetCopy, context, mark); } FixedNode explodeLoopNext = explodeLoop.next(); explodeLoop.clearSuccessors(); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/DirectObjectStoreNode.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/DirectObjectStoreNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/DirectObjectStoreNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -64,7 +64,7 @@ public static native void storeInt(Object obj, @ConstantNodeParameter int displacement, long offset, int value); @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { IndexedLocationNode location = IndexedLocationNode.create(ANY_LOCATION, value.kind(), displacement, offset, graph(), 1); WriteNode write = graph().add(new WriteNode(object, value, location, BarrierType.NONE, value.kind() == Kind.Object)); graph().replaceFixedWithFixed(this, write); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -79,7 +79,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { boolean nullCheck = false; StructuredGraph replacementGraph = getSnippetGraph(tool); if (replacementGraph == null) { diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/PartialEvaluationTest.java --- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/PartialEvaluationTest.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/PartialEvaluationTest.java Tue Sep 10 14:06:45 2013 -0700 @@ -36,7 +36,6 @@ import com.oracle.graal.loop.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.java.*; -import com.oracle.graal.nodes.spi.Lowerable.LoweringType; import com.oracle.graal.phases.*; import com.oracle.graal.phases.PhasePlan.PhasePosition; import com.oracle.graal.phases.common.*; @@ -118,7 +117,7 @@ if (ex.counted().isConstantMaxTripCount()) { long constant = ex.counted().constantMaxTripCount(); if (constant <= UNROLL_LIMIT) { - LoopTransformations.fullUnroll(ex, runtime, assumptions, canonicalizeReads); + LoopTransformations.fullUnroll(ex, context, canonicalizer); Debug.dump(resultGraph, "After loop unrolling %d times", constant); canonicalizer.apply(resultGraph, context); @@ -131,7 +130,7 @@ } new DeadCodeEliminationPhase().apply(resultGraph); - new PartialEscapePhase(true).apply(resultGraph, context); + new PartialEscapePhase(true, canonicalizer).apply(resultGraph, context); if (TruffleInlinePrinter.getValue()) { InlinePrinterProcessor.printTree(); @@ -161,7 +160,7 @@ frameState.replaceAtUsages(null); frameState.safeDelete(); } - new CanonicalizerPhase.Instance(runtime, new Assumptions(false), true).apply(graph); + new CanonicalizerPhase(true).apply(graph, new PhaseContext(runtime, new Assumptions(false), replacements)); new DeadCodeEliminationPhase().apply(graph); } @@ -169,34 +168,36 @@ StructuredGraph graphResult = Debug.scope("Truffle", new DebugDumpScope("Comparison: " + methodName), new Callable() { + @SuppressWarnings("deprecation") public StructuredGraph call() { Assumptions assumptions = new Assumptions(false); StructuredGraph graph = parse(methodName); - CanonicalizerPhase.Instance canonicalizerPhase = new CanonicalizerPhase.Instance(runtime, assumptions, true); - canonicalizerPhase.apply(graph); + PhaseContext context = new PhaseContext(runtime, assumptions, replacements); + CanonicalizerPhase canonicalizer = new CanonicalizerPhase(true); + canonicalizer.apply(graph, context); // Additional inlining. final PhasePlan plan = new PhasePlan(); GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getEagerDefault(), TruffleCompilerImpl.Optimizations); plan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); - plan.addPhase(PhasePosition.AFTER_PARSING, canonicalizerPhase); + canonicalizer.addToPhasePlan(plan, context); plan.addPhase(PhasePosition.AFTER_PARSING, new DeadCodeEliminationPhase()); new ConvertDeoptimizeToGuardPhase().apply(graph); - canonicalizerPhase.apply(graph); + canonicalizer.apply(graph, context); new DeadCodeEliminationPhase().apply(graph); - HighTierContext context = new HighTierContext(runtime, assumptions, replacements, null, plan, OptimisticOptimizations.NONE); - InliningPhase inliningPhase = new InliningPhase(); - inliningPhase.apply(graph, context); + HighTierContext highTierContext = new HighTierContext(runtime, assumptions, replacements, null, plan, OptimisticOptimizations.NONE); + InliningPhase inliningPhase = new InliningPhase(canonicalizer); + inliningPhase.apply(graph, highTierContext); removeFrameStates(graph); new ConvertDeoptimizeToGuardPhase().apply(graph); - canonicalizerPhase.apply(graph); + canonicalizer.apply(graph, context); new DeadCodeEliminationPhase().apply(graph); - new LoweringPhase(LoweringType.BEFORE_GUARDS).apply(graph, context); - canonicalizerPhase.apply(graph); + new LoweringPhase(new CanonicalizerPhase(true)).apply(graph, context); + canonicalizer.apply(graph, context); new DeadCodeEliminationPhase().apply(graph); return graph; } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java Tue Sep 10 14:06:45 2013 -0700 @@ -68,7 +68,7 @@ private final MetaAccessProvider metaAccessProvider; private final ResolvedJavaType nodeClass; private final ResolvedJavaMethod executeHelperMethod; - private final CustomCanonicalizer customCanonicalizer; + private final CanonicalizerPhase canonicalizer; private final ResolvedJavaType[] skippedExceptionTypes; private final Replacements replacements; private Set constantReceivers; @@ -78,7 +78,8 @@ public PartialEvaluator(MetaAccessProvider metaAccessProvider, Replacements replacements, TruffleCache truffleCache) { this.metaAccessProvider = metaAccessProvider; this.nodeClass = metaAccessProvider.lookupJavaType(com.oracle.truffle.api.nodes.Node.class); - this.customCanonicalizer = new PartialEvaluatorCanonicalizer(metaAccessProvider, nodeClass); + CustomCanonicalizer customCanonicalizer = new PartialEvaluatorCanonicalizer(metaAccessProvider, nodeClass); + this.canonicalizer = new CanonicalizerPhase(!AOTCompilation.getValue(), customCanonicalizer); this.skippedExceptionTypes = TruffleCompilerImpl.getSkippedExceptionTypes(metaAccessProvider); this.replacements = replacements; this.cache = HotSpotGraalRuntime.graalRuntime().getCache(); @@ -114,6 +115,7 @@ Debug.scope("createGraph", graph, new Runnable() { + @SuppressWarnings("deprecation") @Override public void run() { new GraphBuilderPhase(metaAccessProvider, config, TruffleCompilerImpl.Optimizations).apply(graph); @@ -123,8 +125,8 @@ thisNode.replaceAndDelete(ConstantNode.forObject(node, metaAccessProvider, graph)); // Canonicalize / constant propagate. - CanonicalizerPhase.Instance canonicalizerPhase = new CanonicalizerPhase.Instance(metaAccessProvider, assumptions, !AOTCompilation.getValue(), null, customCanonicalizer); - canonicalizerPhase.apply(graph); + PhaseContext baseContext = new PhaseContext(metaAccessProvider, assumptions, replacements); + canonicalizer.apply(graph, baseContext); // Intrinsify methods. new ReplaceIntrinsicsPhase(replacements).apply(graph); @@ -156,22 +158,22 @@ final PhasePlan plan = new PhasePlan(); GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(metaAccessProvider, config, TruffleCompilerImpl.Optimizations); plan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); - plan.addPhase(PhasePosition.AFTER_PARSING, canonicalizerPhase); + canonicalizer.addToPhasePlan(plan, baseContext); plan.addPhase(PhasePosition.AFTER_PARSING, new ReplaceIntrinsicsPhase(replacements)); new ConvertDeoptimizeToGuardPhase().apply(graph); - canonicalizerPhase.apply(graph); + canonicalizer.apply(graph, baseContext); new DeadCodeEliminationPhase().apply(graph); HighTierContext context = new HighTierContext(metaAccessProvider, assumptions, replacements, cache, plan, OptimisticOptimizations.NONE); - InliningPhase inliningPhase = new InliningPhase(customCanonicalizer); + InliningPhase inliningPhase = new InliningPhase(canonicalizer); inliningPhase.apply(graph, context); // Convert deopt to guards. new ConvertDeoptimizeToGuardPhase().apply(graph); // Canonicalize / constant propagate. - canonicalizerPhase.apply(graph); + canonicalizer.apply(graph, context); for (NeverPartOfCompilationNode neverPartOfCompilationNode : graph.getNodes(NeverPartOfCompilationNode.class)) { Throwable exception = new VerificationError(neverPartOfCompilationNode.getMessage()); @@ -180,7 +182,7 @@ // EA frame and clean up. new VerifyFrameDoesNotEscapePhase().apply(graph, false); - new PartialEscapePhase(false).apply(graph, context); + new PartialEscapePhase(false, canonicalizer).apply(graph, context); new VerifyNoIntrinsicsLeftPhase().apply(graph, false); for (MaterializeFrameNode materializeNode : graph.getNodes(MaterializeFrameNode.class).snapshot()) { materializeNode.replaceAtUsages(materializeNode.getFrame()); @@ -203,7 +205,7 @@ new ConvertDeoptimizeToGuardPhase().apply(graph); // Canonicalize / constant propagate. - canonicalizerPhase.apply(graph); + canonicalizer.apply(graph, context); } }); @@ -229,7 +231,7 @@ StructuredGraph inlineGraph = replacements.getMethodSubstitution(methodCallTargetNode.targetMethod()); NewFrameNode otherNewFrame = null; if (inlineGraph == null) { - inlineGraph = parseGraph(methodCallTargetNode.targetMethod(), methodCallTargetNode.arguments(), assumptions, !AOTCompilation.getValue()); + inlineGraph = parseGraph(methodCallTargetNode.targetMethod(), methodCallTargetNode.arguments(), assumptions); otherNewFrame = inlineGraph.getNodes(NewFrameNode.class).first(); } @@ -257,7 +259,7 @@ } while (changed && newFrameNode.isAlive() && newFrameNode.usages().isNotEmpty()); } - private StructuredGraph parseGraph(final ResolvedJavaMethod targetMethod, final NodeInputList arguments, final Assumptions assumptions, final boolean canonicalizeReads) { + private StructuredGraph parseGraph(final ResolvedJavaMethod targetMethod, final NodeInputList arguments, final Assumptions assumptions) { final StructuredGraph graph = truffleCache.lookup(targetMethod, arguments, assumptions); Debug.scope("parseGraph", targetMethod, new Runnable() { @@ -266,13 +268,14 @@ public void run() { // Canonicalize / constant propagate. - new CanonicalizerPhase.Instance(metaAccessProvider, assumptions, canonicalizeReads, null, customCanonicalizer).apply(graph); + PhaseContext context = new PhaseContext(metaAccessProvider, assumptions, replacements); + canonicalizer.apply(graph, context); // Intrinsify methods. new ReplaceIntrinsicsPhase(replacements).apply(graph); // Inline trivial getter methods - new InlineTrivialGettersPhase(metaAccessProvider, assumptions, customCanonicalizer).apply(graph); + new InlineTrivialGettersPhase(metaAccessProvider, canonicalizer).apply(graph, context); // Convert deopt to guards. new ConvertDeoptimizeToGuardPhase().apply(graph); @@ -287,9 +290,9 @@ if (ex.counted().isConstantMaxTripCount()) { long constant = ex.counted().constantMaxTripCount(); if (constant <= TruffleConstantUnrollLimit.getValue() || targetMethod.getAnnotation(ExplodeLoop.class) != null) { - LoopTransformations.fullUnroll(ex, metaAccessProvider, assumptions, canonicalizeReads); + LoopTransformations.fullUnroll(ex, context, canonicalizer); Debug.dump(graph, "After loop unrolling %d times", constant); - new CanonicalizerPhase.Instance(metaAccessProvider, assumptions, canonicalizeReads, null, customCanonicalizer).apply(graph); + canonicalizer.apply(graph, context); unrolled = true; break; } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCache.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCache.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCache.java Tue Sep 10 14:06:45 2013 -0700 @@ -112,7 +112,7 @@ optimizeGraph(newGraph, tmpAssumptions); PhaseContext context = new PhaseContext(metaAccessProvider, tmpAssumptions, replacements); - PartialEscapePhase partialEscapePhase = new PartialEscapePhase(false); + PartialEscapePhase partialEscapePhase = new PartialEscapePhase(false, new CanonicalizerPhase(!AOTCompilation.getValue())); partialEscapePhase.apply(newGraph, context); cache.put(method, newGraph); @@ -153,7 +153,7 @@ ConditionalEliminationPhase conditionalEliminationPhase = new ConditionalEliminationPhase(metaAccessProvider); ConvertDeoptimizeToGuardPhase convertDeoptimizeToGuardPhase = new ConvertDeoptimizeToGuardPhase(); CanonicalizerPhase canonicalizerPhase = new CanonicalizerPhase(!AOTCompilation.getValue()); - EarlyReadEliminationPhase readEliminationPhase = new EarlyReadEliminationPhase(); + EarlyReadEliminationPhase readEliminationPhase = new EarlyReadEliminationPhase(canonicalizerPhase); int maxNodes = TruffleCompilerOptions.TruffleOperationCacheMaxNodes.getValue(); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerAddExactNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerAddExactNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerAddExactNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -77,7 +77,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { IntegerExactArithmeticSplitNode.lower(tool, this); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerExactArithmeticSplitNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerExactArithmeticSplitNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerExactArithmeticSplitNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -29,7 +29,6 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.spi.*; -import com.oracle.graal.nodes.spi.Lowerable.*; import com.oracle.graal.nodes.type.*; public abstract class IntegerExactArithmeticSplitNode extends ControlSplitNode implements LIRGenLowerable { @@ -82,7 +81,7 @@ protected abstract Value generateArithmetic(LIRGeneratorTool generator); static void lower(LoweringTool tool, IntegerExactArithmeticNode node) { - if (tool.getLoweringType() == LoweringType.AFTER_GUARDS) { + if (node.asNode().graph().getGuardsPhase() == StructuredGraph.GuardsPhase.FIXED_DEOPTS) { FloatingNode floatingNode = (FloatingNode) node; FixedWithNextNode previous = tool.lastFixedNode(); FixedNode next = previous.next(); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerMulExactNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerMulExactNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerMulExactNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -73,7 +73,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { IntegerExactArithmeticSplitNode.lower(tool, this); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerSubExactNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerSubExactNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerSubExactNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -77,7 +77,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { IntegerExactArithmeticSplitNode.lower(tool, this); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/asserts/NeverInlineMacroNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/asserts/NeverInlineMacroNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/asserts/NeverInlineMacroNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -33,7 +33,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { InvokeNode invoke = createInvoke(); graph().replaceFixedWithFixed(this, invoke); invoke.setUseForInlining(false); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/FrameGetNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/FrameGetNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/FrameGetNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -70,7 +70,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { assert !(getFrame() instanceof NewFrameNode); StructuredGraph structuredGraph = graph(); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/FrameSetNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/FrameSetNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/FrameSetNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -70,7 +70,7 @@ } @Override - public void lower(LoweringTool tool, LoweringType loweringType) { + public void lower(LoweringTool tool) { assert !(getFrame() instanceof NewFrameNode); StructuredGraph structuredGraph = graph(); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomTypeCheckNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomTypeCheckNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomTypeCheckNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -50,8 +50,8 @@ return customType; } - public void lower(LoweringTool tool, LoweringType loweringType) { - if (loweringType == LoweringType.BEFORE_GUARDS) { + public void lower(LoweringTool tool) { + if (graph().getGuardsPhase() == StructuredGraph.GuardsPhase.FLOATING_GUARDS) { this.replaceAtUsages(graph().unique(new IntegerEqualsNode(condition, ConstantNode.forInt(1, graph())))); this.safeDelete(); } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/TypeCastNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/TypeCastNode.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/TypeCastNode.java Tue Sep 10 14:06:45 2013 -0700 @@ -59,8 +59,8 @@ return customType; } - public void lower(LoweringTool tool, LoweringType loweringType) { - if (loweringType == LoweringType.BEFORE_GUARDS) { + public void lower(LoweringTool tool) { + if (graph().getGuardsPhase() == StructuredGraph.GuardsPhase.FLOATING_GUARDS) { ValueAnchorNode valueAnchorNode = graph().add(new ValueAnchorNode()); UnsafeCastNode unsafeCast = graph().unique(new UnsafeCastNode(object, this.stamp(), (GuardingNode) valueAnchorNode)); this.replaceAtUsages(unsafeCast); diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/phases/InlineTrivialGettersPhase.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/phases/InlineTrivialGettersPhase.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/phases/InlineTrivialGettersPhase.java Tue Sep 10 14:06:45 2013 -0700 @@ -22,9 +22,6 @@ */ package com.oracle.graal.truffle.phases; -import static com.oracle.graal.phases.GraalOptions.*; - -import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.debug.*; import com.oracle.graal.java.*; @@ -33,27 +30,25 @@ import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind; import com.oracle.graal.phases.*; import com.oracle.graal.phases.common.*; -import com.oracle.graal.phases.common.CanonicalizerPhase.CustomCanonicalizer; +import com.oracle.graal.phases.tiers.*; import com.oracle.graal.truffle.*; /** * Inline all trivial getters (i.e. simple field loads). */ -public class InlineTrivialGettersPhase extends Phase { +public class InlineTrivialGettersPhase extends BasePhase { private static final int TRIVIAL_GETTER_SIZE = 5; private final MetaAccessProvider metaAccessProvider; - private final Assumptions assumptions; - private final CustomCanonicalizer customCanonicalizer; + private final CanonicalizerPhase canonicalizer; - public InlineTrivialGettersPhase(MetaAccessProvider metaAccessProvider, Assumptions assumptions, CustomCanonicalizer customCanonicalizer) { + public InlineTrivialGettersPhase(MetaAccessProvider metaAccessProvider, CanonicalizerPhase canonicalizer) { this.metaAccessProvider = metaAccessProvider; - this.assumptions = assumptions; - this.customCanonicalizer = customCanonicalizer; + this.canonicalizer = canonicalizer; } @Override - protected void run(StructuredGraph graph) { + protected void run(StructuredGraph graph, PhaseContext context) { for (MethodCallTargetNode methodCallTarget : graph.getNodes(MethodCallTargetNode.class)) { if (methodCallTarget.isAlive()) { InvokeKind invokeKind = methodCallTarget.invokeKind(); @@ -66,7 +61,7 @@ int mark = graph.getMark(); InliningUtil.inline(methodCallTarget.invoke(), inlineGraph, false); Debug.dump(graph, "After inlining trivial getter %s", targetMethod.toString()); - new CanonicalizerPhase.Instance(metaAccessProvider, assumptions, !AOTCompilation.getValue(), mark, customCanonicalizer).apply(graph); + canonicalizer.applyIncremental(graph, context, mark); } } } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EarlyReadEliminationPhase.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EarlyReadEliminationPhase.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EarlyReadEliminationPhase.java Tue Sep 10 14:06:45 2013 -0700 @@ -25,13 +25,14 @@ import static com.oracle.graal.phases.GraalOptions.*; import com.oracle.graal.nodes.*; +import com.oracle.graal.phases.common.*; import com.oracle.graal.phases.schedule.*; import com.oracle.graal.phases.tiers.*; public class EarlyReadEliminationPhase extends EffectsPhase { - public EarlyReadEliminationPhase() { - super(1); + public EarlyReadEliminationPhase(CanonicalizerPhase canonicalizer) { + super(1, canonicalizer); } @Override diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsPhase.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsPhase.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsPhase.java Tue Sep 10 14:06:45 2013 -0700 @@ -22,8 +22,6 @@ */ package com.oracle.graal.virtual.phases.ea; -import static com.oracle.graal.phases.GraalOptions.*; - import java.util.concurrent.*; import com.oracle.graal.debug.*; @@ -47,9 +45,11 @@ } private final int maxIterations; + private final CanonicalizerPhase canonicalizer; - public EffectsPhase(int maxIterations) { + public EffectsPhase(int maxIterations, CanonicalizerPhase canonicalizer) { this.maxIterations = maxIterations; + this.canonicalizer = canonicalizer; } @Override @@ -90,7 +90,7 @@ listener.getChangedNodes().add(node); } } - new CanonicalizerPhase.Instance(context.getRuntime(), context.getAssumptions(), !AOTCompilation.getValue(), listener.getChangedNodes(), null).apply(graph); + canonicalizer.applyIncremental(graph, context, listener.getChangedNodes()); return true; } diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/IterativeInliningPhase.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/IterativeInliningPhase.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/IterativeInliningPhase.java Tue Sep 10 14:06:45 2013 -0700 @@ -60,13 +60,13 @@ @Override public Boolean call() { boolean progress = false; - PartialEscapePhase ea = new PartialEscapePhase(false); + PartialEscapePhase ea = new PartialEscapePhase(false, canonicalizer); boolean eaResult = ea.runAnalysis(graph, context); progress |= eaResult; Map hints = PEAInliningHints.getValue() ? PartialEscapePhase.getHints(graph) : null; - InliningPhase inlining = new InliningPhase(hints); + InliningPhase inlining = new InliningPhase(hints, new CanonicalizerPhase(true)); inlining.setMaxMethodsPerInlining(simple ? 1 : Integer.MAX_VALUE); inlining.apply(graph, context); progress |= inlining.getInliningCount() > 0; @@ -75,7 +75,7 @@ if (ConditionalElimination.getValue() && OptCanonicalizer.getValue()) { canonicalizer.apply(graph, context); - new IterativeConditionalEliminationPhase().apply(graph, context); + new IterativeConditionalEliminationPhase(canonicalizer).apply(graph, context); } return progress; diff -r 4dbd3e3adda6 -r c47153857827 graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapePhase.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapePhase.java Tue Sep 10 09:30:09 2013 -0700 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapePhase.java Tue Sep 10 14:06:45 2013 -0700 @@ -23,6 +23,7 @@ package com.oracle.graal.virtual.phases.ea; import static com.oracle.graal.phases.GraalOptions.*; +import static com.oracle.graal.virtual.phases.ea.PartialEscapePhase.Options.*; import java.util.*; @@ -33,25 +34,29 @@ import com.oracle.graal.nodes.util.*; import com.oracle.graal.nodes.virtual.*; import com.oracle.graal.options.*; +import com.oracle.graal.phases.common.*; import com.oracle.graal.phases.graph.*; import com.oracle.graal.phases.schedule.*; import com.oracle.graal.phases.tiers.*; public class PartialEscapePhase extends EffectsPhase { - //@formatter:off - @Option(help = "") - public static final OptionValue OptEarlyReadElimination = new OptionValue<>(true); - //@formatter:on + static class Options { + + //@formatter:off + @Option(help = "") + public static final OptionValue OptEarlyReadElimination = new OptionValue<>(true); + //@formatter:on + } private final boolean readElimination; - public PartialEscapePhase(boolean iterative) { - this(iterative, OptEarlyReadElimination.getValue()); + public PartialEscapePhase(boolean iterative, CanonicalizerPhase canonicalizer) { + this(iterative, OptEarlyReadElimination.getValue(), canonicalizer); } - public PartialEscapePhase(boolean iterative, boolean readElimination) { - super(iterative ? EscapeAnalysisIterations.getValue() : 1); + public PartialEscapePhase(boolean iterative, boolean readElimination, CanonicalizerPhase canonicalizer) { + super(iterative ? EscapeAnalysisIterations.getValue() : 1, canonicalizer); this.readElimination = readElimination; } diff -r 4dbd3e3adda6 -r c47153857827 src/share/vm/graal/graalCompiler.cpp --- a/src/share/vm/graal/graalCompiler.cpp Tue Sep 10 09:30:09 2013 -0700 +++ b/src/share/vm/graal/graalCompiler.cpp Tue Sep 10 14:06:45 2013 -0700 @@ -95,7 +95,7 @@ vm_abort(false); } } - VMToCompiler::finalizeOptions(); + VMToCompiler::finalizeOptions(CITime); if (UseCompiler) { VMToCompiler::startCompiler(BootstrapGraal); diff -r 4dbd3e3adda6 -r c47153857827 src/share/vm/graal/graalVMToCompiler.cpp --- a/src/share/vm/graal/graalVMToCompiler.cpp Tue Sep 10 09:30:09 2013 -0700 +++ b/src/share/vm/graal/graalVMToCompiler.cpp Tue Sep 10 14:06:45 2013 -0700 @@ -107,11 +107,13 @@ return result.get_jboolean(); } -void VMToCompiler::finalizeOptions() { +void VMToCompiler::finalizeOptions(jboolean ciTime) { KlassHandle optionsKlass = loadClass(vmSymbols::com_oracle_graal_hotspot_HotSpotOptions()); Thread* THREAD = Thread::current(); JavaValue result(T_VOID); - JavaCalls::call_static(&result, optionsKlass, vmSymbols::finalizeOptions_name(), vmSymbols::void_method_signature(), THREAD); + JavaCallArguments args; + args.push_int(ciTime); + JavaCalls::call_static(&result, optionsKlass, vmSymbols::finalizeOptions_name(), vmSymbols::bool_void_signature(), &args, THREAD); check_pending_exception("Error while calling finalizeOptions"); } diff -r 4dbd3e3adda6 -r c47153857827 src/share/vm/graal/graalVMToCompiler.hpp --- a/src/share/vm/graal/graalVMToCompiler.hpp Tue Sep 10 09:30:09 2013 -0700 +++ b/src/share/vm/graal/graalVMToCompiler.hpp Tue Sep 10 14:06:45 2013 -0700 @@ -57,8 +57,8 @@ // public static boolean HotSpotOptions.setOption(String option); static jboolean setOption(Handle option); - // public static void HotSpotOptions.finalizeOptions(); - static void finalizeOptions(); + // public static void HotSpotOptions.finalizeOptions(boolean ciTime); + static void finalizeOptions(jboolean ciTime); // public abstract boolean compileMethod(long vmId, String name, int entry_bci, boolean blocking); static void compileMethod(Method* method, Handle holder, int entry_bci, jboolean blocking);