Search in sources :

Example 36 with AbstractTestNode

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

the class SimplePartialEvaluationTest method intrinsicStatic.

@Test
public void intrinsicStatic() {
    /*
         * The intrinsic for String.equals() is inlined early during bytecode parsing, because we
         * call equals() on a value that has the static type String.
         */
    FrameDescriptor fd = new FrameDescriptor();
    AbstractTestNode result = new StringEqualsNode("abc", "abf");
    RootNode rootNode = new RootTestNode(fd, "intrinsicStatic", result);
    OptimizedCallTarget compilable = compileHelper("intrinsicStatic", rootNode, new Object[0]);
    Assert.assertEquals(42, compilable.call(new Object[0]));
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) RootNode(com.oracle.truffle.api.nodes.RootNode) AbstractTestNode(org.graalvm.compiler.truffle.test.nodes.AbstractTestNode) OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) RootTestNode(org.graalvm.compiler.truffle.test.nodes.RootTestNode) StringEqualsNode(org.graalvm.compiler.truffle.test.nodes.StringEqualsNode) Test(org.junit.Test)

Example 37 with AbstractTestNode

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

the class TruffleExceptionPartialEvaluationTest method createCallerChain.

private static RootTestNode createCallerChain(int framesAbove, int framesBelow) {
    FrameDescriptor fd = new FrameDescriptor();
    AbstractTestNode calleeNode = new ThrowTruffleExceptionTestNode(-1, true);
    RootTestNode calleeRoot = new RootTestNode(fd, "testTruffleException", calleeNode);
    for (int i = 0; i < framesAbove; i++) {
        AbstractTestNode call = new CallTestNode(Truffle.getRuntime().createCallTarget(calleeRoot));
        calleeRoot = new RootTestNode(fd, "testTruffleException", call);
    }
    AbstractTestNode callerNode = new CallTestNode(Truffle.getRuntime().createCallTarget(calleeRoot));
    AbstractTestNode catchNode = new CatchTruffleExceptionTestNode(callerNode);
    RootTestNode callerRoot = new RootTestNode(fd, "testTruffleException", catchNode);
    for (int i = 0; i < framesBelow; i++) {
        AbstractTestNode call = new CallTestNode(Truffle.getRuntime().createCallTarget(callerRoot));
        callerRoot = new RootTestNode(fd, "testTruffleException", call);
    }
    return callerRoot;
}
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)

Example 38 with AbstractTestNode

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

the class BailoutPartialEvaluationTest method partialEvaluationConstantBailout2.

@Test(expected = BailoutException.class)
public void partialEvaluationConstantBailout2() {
    FrameDescriptor fd = new FrameDescriptor();
    RootTestNode rootNode = new RootTestNode(fd, "partialEvaluationConstantBailout2", new AbstractTestNode() {

        @Override
        public int execute(VirtualFrame frame) {
            CompilerAsserts.partialEvaluationConstant(notConstantInt);
            return 0;
        }
    });
    compileHelper("partialEvaluationConstantBailout2", rootNode, new Object[] {});
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) VirtualFrame(com.oracle.truffle.api.frame.VirtualFrame) AbstractTestNode(org.graalvm.compiler.truffle.test.nodes.AbstractTestNode) RootTestNode(org.graalvm.compiler.truffle.test.nodes.RootTestNode) Test(org.junit.Test)

Example 39 with AbstractTestNode

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

the class CastExactPartialEvaluationTest method byteBufferAccess.

/**
 * Tests that {@link ByteBuffer} accesses do not contain any method calls, e.g. for exceptions.
 */
@Test
public void byteBufferAccess() {
    AbstractTestNode result = new BufferGetPutTestNode(newBuffer().getClass());
    testCommon(result, "byteBufferAccess");
}
Also used : AbstractTestNode(org.graalvm.compiler.truffle.test.nodes.AbstractTestNode) Test(org.junit.Test)

Example 40 with AbstractTestNode

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

the class CastExactPartialEvaluationTest method exactClassProfile.

/**
 * Tests that the profile created by {@link ValueProfile#createClassProfile()} casts the
 * argument to the exact profiled class.
 */
@Test
public void exactClassProfile() {
    AbstractTestNode result = new ExactClassProfileTestNode();
    testCommon(result, "exactClassProfile");
}
Also used : AbstractTestNode(org.graalvm.compiler.truffle.test.nodes.AbstractTestNode) Test(org.junit.Test)

Aggregations

AbstractTestNode (org.graalvm.compiler.truffle.test.nodes.AbstractTestNode)46 Test (org.junit.Test)45 FrameDescriptor (com.oracle.truffle.api.frame.FrameDescriptor)43 RootTestNode (org.graalvm.compiler.truffle.test.nodes.RootTestNode)43 ConstantTestNode (org.graalvm.compiler.truffle.test.nodes.ConstantTestNode)13 OptimizedCallTarget (org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)11 RootNode (com.oracle.truffle.api.nodes.RootNode)9 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 LoadLocalTestNode (org.graalvm.compiler.truffle.test.nodes.LoadLocalTestNode)4 NestedExplodedLoopTestNode (org.graalvm.compiler.truffle.test.nodes.NestedExplodedLoopTestNode)3 StoreLocalTestNode (org.graalvm.compiler.truffle.test.nodes.StoreLocalTestNode)3 Assumption (com.oracle.truffle.api.Assumption)2 CallTarget (com.oracle.truffle.api.CallTarget)2 WeakReference (java.lang.ref.WeakReference)2 IntSupplier (java.util.function.IntSupplier)2 LoopTestNode (org.graalvm.compiler.truffle.test.nodes.LoopTestNode)2 TwoMergesExplodedLoopTestNode (org.graalvm.compiler.truffle.test.nodes.TwoMergesExplodedLoopTestNode)2 Ignore (org.junit.Ignore)2