Search in sources :

Example 1 with InvalidAssumptionException

use of com.oracle.truffle.api.nodes.InvalidAssumptionException in project graal by oracle.

the class AssumptionPartialEvaluationTest method constantValue.

@Test
public void constantValue() {
    Assumption assumption = Truffle.getRuntime().createAssumption();
    AbstractTestNode result = new ConstantWithAssumptionTestNode(assumption, 42);
    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) {
        Assert.fail("Assumption must not have been invalidated.");
    }
    assumption.invalidate();
    try {
        assumption.check();
        Assert.fail("Assumption must have been invalidated.");
    } catch (InvalidAssumptionException e) {
    }
    Assert.assertFalse(callTarget.isValid());
    assertDeepEquals(43, callTarget.call());
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) ConstantWithAssumptionTestNode(org.graalvm.compiler.truffle.test.nodes.ConstantWithAssumptionTestNode) AbstractTestNode(org.graalvm.compiler.truffle.test.nodes.AbstractTestNode) InvalidAssumptionException(com.oracle.truffle.api.nodes.InvalidAssumptionException) OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) RootTestNode(org.graalvm.compiler.truffle.test.nodes.RootTestNode) Assumption(com.oracle.truffle.api.Assumption) OptimizedAssumption(org.graalvm.compiler.truffle.runtime.OptimizedAssumption) Test(org.junit.Test)

Example 2 with InvalidAssumptionException

use of com.oracle.truffle.api.nodes.InvalidAssumptionException in project graal by oracle.

the class NeverValidAssumptionTest method testCheck.

@Test
public void testCheck() {
    final NeverValidAssumption assumption = NeverValidAssumption.INSTANCE;
    try {
        assumption.check();
        fail();
    } catch (InvalidAssumptionException e) {
    } catch (Exception e) {
        fail();
    }
}
Also used : NeverValidAssumption(com.oracle.truffle.api.utilities.NeverValidAssumption) InvalidAssumptionException(com.oracle.truffle.api.nodes.InvalidAssumptionException) InvalidAssumptionException(com.oracle.truffle.api.nodes.InvalidAssumptionException) Test(org.junit.Test)

Aggregations

InvalidAssumptionException (com.oracle.truffle.api.nodes.InvalidAssumptionException)2 Test (org.junit.Test)2 Assumption (com.oracle.truffle.api.Assumption)1 FrameDescriptor (com.oracle.truffle.api.frame.FrameDescriptor)1 NeverValidAssumption (com.oracle.truffle.api.utilities.NeverValidAssumption)1 OptimizedAssumption (org.graalvm.compiler.truffle.runtime.OptimizedAssumption)1 OptimizedCallTarget (org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)1 AbstractTestNode (org.graalvm.compiler.truffle.test.nodes.AbstractTestNode)1 ConstantWithAssumptionTestNode (org.graalvm.compiler.truffle.test.nodes.ConstantWithAssumptionTestNode)1 RootTestNode (org.graalvm.compiler.truffle.test.nodes.RootTestNode)1