Mercurial > hg > graal-compiler
changeset 17434:64325207a1a1
truffle pe: re-enable AssumptionPartialEvaluationTest
author | Bernhard Urban <bernhard.urban@jku.at> |
---|---|
date | Tue, 14 Oct 2014 14:06:42 +0200 |
parents | f503236c022e |
children | 2ea20d64ab5c |
files | graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/AssumptionPartialEvaluationTest.java graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/PartialEvaluationTest.java |
diffstat | 2 files changed, 17 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/AssumptionPartialEvaluationTest.java Tue Oct 14 13:09:36 2014 +0200 +++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/AssumptionPartialEvaluationTest.java Tue Oct 14 14:06:42 2014 +0200 @@ -24,33 +24,26 @@ import org.junit.*; -import com.oracle.graal.api.code.*; +import com.oracle.graal.truffle.*; import com.oracle.graal.truffle.test.nodes.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.nodes.*; -@Ignore("Currently ignored due to problems with code coverage tools.") public class AssumptionPartialEvaluationTest extends PartialEvaluationTest { - public static Object constant42() { return 42; } @Test public void constantValue() { - FrameDescriptor fd = new FrameDescriptor(); Assumption assumption = Truffle.getRuntime().createAssumption(); AbstractTestNode result = new ConstantWithAssumptionTestNode(assumption, 42); - RootTestNode rootNode = new RootTestNode(fd, "constantValue", result); - InstalledCode installedCode = assertPartialEvalEquals("constant42", rootNode); - Assert.assertTrue(installedCode.isValid()); - try { - assertDeepEquals(42, installedCode.executeVarargs(null, null, null)); - } catch (InvalidInstalledCodeException e) { - Assert.fail("Code must not have been invalidated."); - } - Assert.assertTrue(installedCode.isValid()); + RootTestNode rootNode = new RootTestNode(new FrameDescriptor(), "constantValue", result); + OptimizedCallTarget callTarget = assertPartialEvalEquals("constant42", rootNode); + Assert.assertTrue(callTarget.isValid()); + assertDeepEquals(42, callTarget.call()); + Assert.assertTrue(callTarget.isValid()); try { assumption.check(); } catch (InvalidAssumptionException e) { @@ -62,12 +55,7 @@ Assert.fail("Assumption must have been invalidated."); } catch (InvalidAssumptionException e) { } - Assert.assertFalse(installedCode.isValid()); - - try { - installedCode.executeVarargs(null, null, null); - Assert.fail("Code must have been invalidated."); - } catch (InvalidInstalledCodeException e) { - } + Assert.assertFalse(callTarget.isValid()); + assertDeepEquals(43, callTarget.call()); } }
--- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/PartialEvaluationTest.java Tue Oct 14 13:09:36 2014 +0200 +++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/PartialEvaluationTest.java Tue Oct 14 14:06:42 2014 +0200 @@ -48,19 +48,19 @@ DebugEnvironment.initialize(System.out); } - protected InstalledCode assertPartialEvalEquals(String methodName, RootNode root) { + protected OptimizedCallTarget assertPartialEvalEquals(String methodName, RootNode root) { return assertPartialEvalEquals(methodName, root, new Object[0]); } - protected InstalledCode assertPartialEvalEquals(String methodName, RootNode root, Object[] arguments) { + protected OptimizedCallTarget assertPartialEvalEquals(String methodName, RootNode root, Object[] arguments) { Assumptions assumptions = new Assumptions(true); - StructuredGraph actual = partialEval(root, arguments, assumptions); - InstalledCode result = new InstalledCode("Test:" + methodName); - truffleCompiler.compileMethodHelper(actual, assumptions, root.toString(), getSpeculationLog(), result); + final OptimizedCallTarget compilable = (OptimizedCallTarget) Truffle.getRuntime().createCallTarget(root); + StructuredGraph actual = partialEval(compilable, arguments, assumptions); + truffleCompiler.compileMethodHelper(actual, assumptions, methodName, getSpeculationLog(), compilable); removeFrameStates(actual); StructuredGraph expected = parseForComparison(methodName); Assert.assertEquals(getCanonicalGraphString(expected, true, true), getCanonicalGraphString(actual, true, true)); - return result; + return compilable; } protected void assertPartialEvalNoInvokes(RootNode root) { @@ -69,16 +69,15 @@ protected void assertPartialEvalNoInvokes(RootNode root, Object[] arguments) { Assumptions assumptions = new Assumptions(true); - StructuredGraph actual = partialEval(root, arguments, assumptions); + final OptimizedCallTarget compilable = (OptimizedCallTarget) Truffle.getRuntime().createCallTarget(root); + StructuredGraph actual = partialEval(compilable, arguments, assumptions); removeFrameStates(actual); for (MethodCallTargetNode node : actual.getNodes(MethodCallTargetNode.class)) { Assert.fail("Found invalid method call target node: " + node); } } - protected StructuredGraph partialEval(RootNode root, Object[] arguments, final Assumptions assumptions) { - final OptimizedCallTarget compilable = (OptimizedCallTarget) Truffle.getRuntime().createCallTarget(root); - + protected StructuredGraph partialEval(OptimizedCallTarget compilable, Object[] arguments, final Assumptions assumptions) { // Executed AST so that all classes are loaded and initialized. compilable.call(arguments); compilable.call(arguments);