Search in sources :

Example 46 with RootTestNode

use of org.graalvm.compiler.truffle.test.nodes.RootTestNode in project graal by oracle.

the class CompilerAssertsTest method compilationNonConstantTest.

@Test
public void compilationNonConstantTest() {
    FrameDescriptor descriptor = new FrameDescriptor();
    CompilationConstantTestNode result = new CompilationConstantTestNode(new NonConstantTestNode(5));
    RootTestNode rootNode = new RootTestNode(descriptor, "compilationConstant", result);
    try {
        compileHelper("compilationConstant", rootNode, new Object[0]);
        Assert.fail("Expected bailout exception because expression is not compilation constant");
    } catch (BailoutException e) {
    // Bailout exception expected.
    }
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) NonConstantTestNode(org.graalvm.compiler.truffle.test.nodes.NonConstantTestNode) BailoutException(jdk.vm.ci.code.BailoutException) RootTestNode(org.graalvm.compiler.truffle.test.nodes.RootTestNode) Test(org.junit.Test)

Example 47 with RootTestNode

use of org.graalvm.compiler.truffle.test.nodes.RootTestNode in project graal by oracle.

the class ControlFlowExceptionPartialEvaluationTest method catchControlFlowExceptionWithLoopExplosion.

@Test
public void catchControlFlowExceptionWithLoopExplosion() {
    FrameDescriptor fd = new FrameDescriptor();
    AbstractTestNode result = new CatchControlFlowExceptionTestNode(new BlockTestNode(new ThrowControlFlowExceptionTestNode()));
    assertPartialEvalEquals("constant42", new RootTestNode(fd, "catchControlFlowExceptionWithLoopExplosion", result));
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) AbstractTestNode(org.graalvm.compiler.truffle.test.nodes.AbstractTestNode) RootTestNode(org.graalvm.compiler.truffle.test.nodes.RootTestNode) Test(org.junit.Test)

Example 48 with RootTestNode

use of org.graalvm.compiler.truffle.test.nodes.RootTestNode in project graal by oracle.

the class ControlFlowExceptionPartialEvaluationTest method catchControlFlowException.

@Test
public void catchControlFlowException() {
    FrameDescriptor fd = new FrameDescriptor();
    AbstractTestNode result = new CatchControlFlowExceptionTestNode(new ThrowControlFlowExceptionTestNode());
    assertPartialEvalEquals("constant42", new RootTestNode(fd, "catchControlFlowException", result));
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) AbstractTestNode(org.graalvm.compiler.truffle.test.nodes.AbstractTestNode) RootTestNode(org.graalvm.compiler.truffle.test.nodes.RootTestNode) Test(org.junit.Test)

Example 49 with RootTestNode

use of org.graalvm.compiler.truffle.test.nodes.RootTestNode in project graal by oracle.

the class ControlFlowExceptionPartialEvaluationTest method catchSlowPathAndControlFlowException.

@Test
public void catchSlowPathAndControlFlowException() {
    FrameDescriptor fd = new FrameDescriptor();
    AbstractTestNode result = new CatchSlowPathAndControlFlowExceptionTestNode(new ThrowControlFlowExceptionTestNode());
    assertPartialEvalEquals("constant42", new RootTestNode(fd, "catchSlowPathAndControlFlowException", result));
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) AbstractTestNode(org.graalvm.compiler.truffle.test.nodes.AbstractTestNode) RootTestNode(org.graalvm.compiler.truffle.test.nodes.RootTestNode) Test(org.junit.Test)

Example 50 with RootTestNode

use of org.graalvm.compiler.truffle.test.nodes.RootTestNode 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)

Aggregations

FrameDescriptor (com.oracle.truffle.api.frame.FrameDescriptor)50 RootTestNode (org.graalvm.compiler.truffle.test.nodes.RootTestNode)50 Test (org.junit.Test)48 AbstractTestNode (org.graalvm.compiler.truffle.test.nodes.AbstractTestNode)43 OptimizedCallTarget (org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)14 ConstantTestNode (org.graalvm.compiler.truffle.test.nodes.ConstantTestNode)14 RootNode (com.oracle.truffle.api.nodes.RootNode)10 AddTestNode (org.graalvm.compiler.truffle.test.nodes.AddTestNode)7 BlockTestNode (org.graalvm.compiler.truffle.test.nodes.BlockTestNode)6 VirtualFrame (com.oracle.truffle.api.frame.VirtualFrame)5 Assumption (com.oracle.truffle.api.Assumption)3 LoadLocalTestNode (org.graalvm.compiler.truffle.test.nodes.LoadLocalTestNode)3 NestedExplodedLoopTestNode (org.graalvm.compiler.truffle.test.nodes.NestedExplodedLoopTestNode)3 StoreLocalTestNode (org.graalvm.compiler.truffle.test.nodes.StoreLocalTestNode)3 CallTarget (com.oracle.truffle.api.CallTarget)2 RootCallTarget (com.oracle.truffle.api.RootCallTarget)2 WeakReference (java.lang.ref.WeakReference)2 IntSupplier (java.util.function.IntSupplier)2 BailoutException (jdk.vm.ci.code.BailoutException)2 InstrumentPhase (org.graalvm.compiler.truffle.compiler.phases.InstrumentPhase)2