# HG changeset patch # User Lukas Stadler # Date 1427979016 -7200 # Node ID 33be8eb8cbd53a2d360434a49e02638559113b56 # Parent 6a84da35bc84780e39cf1d34aeedd1cd43775bef test for PEA canonicalization diff -r 6a84da35bc84 -r 33be8eb8cbd5 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EATestBase.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EATestBase.java Thu Apr 02 14:33:43 2015 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EATestBase.java Thu Apr 02 14:50:16 2015 +0200 @@ -132,7 +132,7 @@ * @param iterativeEscapeAnalysis true if escape analysis should be run for more than one * iteration */ - protected void testEscapeAnalysis(String snippet, final JavaConstant expectedConstantResult, final boolean iterativeEscapeAnalysis) { + protected void testEscapeAnalysis(String snippet, JavaConstant expectedConstantResult, boolean iterativeEscapeAnalysis) { prepareGraph(snippet, iterativeEscapeAnalysis); if (expectedConstantResult != null) { for (ReturnNode returnNode : returnNodes) { @@ -145,7 +145,7 @@ Assert.assertEquals(0, newInstanceCount); } - protected void prepareGraph(String snippet, final boolean iterativeEscapeAnalysis) { + protected void prepareGraph(String snippet, boolean iterativeEscapeAnalysis) { ResolvedJavaMethod method = getResolvedJavaMethod(snippet); try (Scope s = Debug.scope(getClass(), method, getCodeCache())) { graph = parseEager(method, AllowAssumptions.YES); diff -r 6a84da35bc84 -r 33be8eb8cbd5 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 Thu Apr 02 14:33:43 2015 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PartialEscapeAnalysisTest.java Thu Apr 02 14:50:16 2015 +0200 @@ -172,8 +172,27 @@ assertDeepEquals(1, graph.getNodes().filter(NewInstanceNode.class).count()); } + public static int testCanonicalizeSnippet(int v) { + CacheKey key = new CacheKey(v, null); + + CacheKey key2; + if (key.idx == v) { + key2 = new CacheKey(v, null); + } else { + key2 = null; + } + return key2.idx; + } + + @Test + public void testCanonicalize() { + prepareGraph("testCanonicalizeSnippet", false); + assertTrue(graph.getNodes().filter(ReturnNode.class).count() == 1); + assertTrue(graph.getNodes().filter(ReturnNode.class).first().result() == graph.getParameter(0)); + } + @SafeVarargs - protected final void testPartialEscapeAnalysis(final String snippet, double expectedProbability, int expectedCount, Class... invalidNodeClasses) { + protected final void testPartialEscapeAnalysis(String snippet, double expectedProbability, int expectedCount, Class... invalidNodeClasses) { prepareGraph(snippet, false); for (AbstractMergeNode merge : graph.getNodes(AbstractMergeNode.TYPE)) { merge.setStateAfter(null);