Search in sources :

Example 1 with AssumptionCutsBranchTestNode

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

the class AssumptionPartialEvaluationTest method assumptionBranchCutoff.

/**
 * Tests whether a valid {@link Assumption} cuts off a non-executed branch.
 */
@Test
public void assumptionBranchCutoff() {
    Assumption assumption = Truffle.getRuntime().createAssumption();
    AssumptionCutsBranchTestNode result = new AssumptionCutsBranchTestNode(assumption);
    RootTestNode rootNode = new RootTestNode(new FrameDescriptor(), "cutoffBranch", result);
    OptimizedCallTarget compilable = compileHelper("cutoffBranch", rootNode, new Object[0]);
    for (int i = 0; i < 100000; i++) {
        Assert.assertEquals(0, compilable.call(new Object[0]));
    }
    Assert.assertNull(result.getChildNode());
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) AssumptionCutsBranchTestNode(org.graalvm.compiler.truffle.test.nodes.AssumptionCutsBranchTestNode) 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

Assumption (com.oracle.truffle.api.Assumption)1 FrameDescriptor (com.oracle.truffle.api.frame.FrameDescriptor)1 OptimizedAssumption (org.graalvm.compiler.truffle.runtime.OptimizedAssumption)1 OptimizedCallTarget (org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)1 AssumptionCutsBranchTestNode (org.graalvm.compiler.truffle.test.nodes.AssumptionCutsBranchTestNode)1 RootTestNode (org.graalvm.compiler.truffle.test.nodes.RootTestNode)1 Test (org.junit.Test)1