Mercurial > hg > graal-compiler
changeset 20156:33be8eb8cbd5
test for PEA canonicalization
author | Lukas Stadler <lukas.stadler@oracle.com> |
---|---|
date | Thu, 02 Apr 2015 14:50:16 +0200 |
parents | 6a84da35bc84 |
children | 8ff9e165002b |
files | graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EATestBase.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PartialEscapeAnalysisTest.java |
diffstat | 2 files changed, 22 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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);
--- 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<? extends Node>... invalidNodeClasses) { + protected final void testPartialEscapeAnalysis(String snippet, double expectedProbability, int expectedCount, Class<? extends Node>... invalidNodeClasses) { prepareGraph(snippet, false); for (AbstractMergeNode merge : graph.getNodes(AbstractMergeNode.TYPE)) { merge.setStateAfter(null);