Search in sources :

Example 11 with RootTestNode

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

Example 12 with RootTestNode

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

the class SimplePartialEvaluationTest method longSequenceConstants.

@Test
public void longSequenceConstants() {
    FrameDescriptor fd = new FrameDescriptor();
    int length = 40;
    AbstractTestNode[] children = new AbstractTestNode[length];
    for (int i = 0; i < children.length; ++i) {
        children[i] = new ConstantTestNode(42);
    }
    AbstractTestNode result = new BlockTestNode(children);
    assertPartialEvalEquals("constant42", new RootTestNode(fd, "longSequenceConstants", result));
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) BlockTestNode(org.graalvm.compiler.truffle.test.nodes.BlockTestNode) AbstractTestNode(org.graalvm.compiler.truffle.test.nodes.AbstractTestNode) ConstantTestNode(org.graalvm.compiler.truffle.test.nodes.ConstantTestNode) RootTestNode(org.graalvm.compiler.truffle.test.nodes.RootTestNode) Test(org.junit.Test)

Example 13 with RootTestNode

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

the class SimplePartialEvaluationTest method intrinsicStringHashCodeNonFinal.

@Test
public void intrinsicStringHashCodeNonFinal() {
    /*
         * The intrinsic for String.hashcode() does not trigger on non-constant strings, so the
         * method String.hashCode() must be inlined during partial evaluation (so there must not be
         * an invoke after partial evaluation).
         */
    FrameDescriptor fd = new FrameDescriptor();
    AbstractTestNode result = new StringHashCodeNonFinalNode("*");
    assertPartialEvalNoInvokes(new RootTestNode(fd, "intrinsicStringHashCodeNonFinal", result));
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) AbstractTestNode(org.graalvm.compiler.truffle.test.nodes.AbstractTestNode) StringHashCodeNonFinalNode(org.graalvm.compiler.truffle.test.nodes.StringHashCodeNonFinalNode) RootTestNode(org.graalvm.compiler.truffle.test.nodes.RootTestNode) Test(org.junit.Test)

Example 14 with RootTestNode

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

the class SimplePartialEvaluationTest method explodeLoopUntilReturnWithThrow.

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

Example 15 with RootTestNode

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

the class SimplePartialEvaluationTest method intrinsicStringHashCodeFinal.

@Test
public void intrinsicStringHashCodeFinal() {
    /* The intrinsic for String.hashcode() triggers on constant strings. */
    FrameDescriptor fd = new FrameDescriptor();
    AbstractTestNode result = new StringHashCodeFinalNode("*");
    /* The hash code of "*" is 42. */
    assertPartialEvalEquals("constant42", new RootTestNode(fd, "intrinsicStringHashCodeFinal", result));
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) AbstractTestNode(org.graalvm.compiler.truffle.test.nodes.AbstractTestNode) StringHashCodeFinalNode(org.graalvm.compiler.truffle.test.nodes.StringHashCodeFinalNode) RootTestNode(org.graalvm.compiler.truffle.test.nodes.RootTestNode) 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