Search in sources :

Example 11 with FrameDescriptor

use of com.oracle.truffle.api.frame.FrameDescriptor in project graal by oracle.

the class CompilerAssertsTest method neverPartOfCompilationTest.

@Test
public void neverPartOfCompilationTest() {
    NeverPartOfCompilationTestNode result = new NeverPartOfCompilationTestNode();
    RootTestNode rootNode = new RootTestNode(new FrameDescriptor(), "neverPartOfCompilation", result);
    try {
        compileHelper("neverPartOfCompilation", rootNode, new Object[0]);
        Assert.fail("Expected bailout exception due to never part of compilation");
    } catch (BailoutException e) {
    // Bailout exception expected.
    }
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) BailoutException(jdk.vm.ci.code.BailoutException) RootTestNode(org.graalvm.compiler.truffle.test.nodes.RootTestNode) Test(org.junit.Test)

Example 12 with FrameDescriptor

use of com.oracle.truffle.api.frame.FrameDescriptor in project graal by oracle.

the class ControlFlowExceptionPartialEvaluationTest method catchControlFlowExceptionFromCall.

@Test
public void catchControlFlowExceptionFromCall() {
    Assume.assumeTrue(TruffleCompilerOptions.getValue(TruffleFunctionInlining));
    CallTarget callTarget = Truffle.getRuntime().createCallTarget(new RootTestNode(new FrameDescriptor(), "throwControlFlowException", new ThrowControlFlowExceptionTestNode()));
    AbstractTestNode result = new CatchControlFlowExceptionTestNode(new CallTestNode(callTarget));
    assertPartialEvalEquals("constant42", new RootTestNode(new FrameDescriptor(), "catchControlFlowExceptionFromCall", result));
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) AbstractTestNode(org.graalvm.compiler.truffle.test.nodes.AbstractTestNode) CallTarget(com.oracle.truffle.api.CallTarget) RootTestNode(org.graalvm.compiler.truffle.test.nodes.RootTestNode) Test(org.junit.Test)

Example 13 with FrameDescriptor

use of com.oracle.truffle.api.frame.FrameDescriptor 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 14 with FrameDescriptor

use of com.oracle.truffle.api.frame.FrameDescriptor in project graal by oracle.

the class OptimizedOSRLoopNode method forceOSR.

/**
 * Forces OSR compilation for this loop.
 */
public final void forceOSR() {
    baseLoopCount = getThreshold();
    RootNode rootNode = getRootNode();
    VirtualFrame dummyFrame = Truffle.getRuntime().createVirtualFrame(new Object[0], rootNode != null ? rootNode.getFrameDescriptor() : new FrameDescriptor());
    compileLoop(dummyFrame);
}
Also used : VirtualFrame(com.oracle.truffle.api.frame.VirtualFrame) FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) RootNode(com.oracle.truffle.api.nodes.RootNode)

Example 15 with FrameDescriptor

use of com.oracle.truffle.api.frame.FrameDescriptor in project graal by oracle.

the class FrameTest method testFrameDescriptorAccess1.

@Test
public void testFrameDescriptorAccess1() {
    FrameDescriptorAccess1Node node = FrameDescriptorAccess1NodeGen.create();
    FrameDescriptor descriptor = new FrameDescriptor();
    VirtualFrame frame = Truffle.getRuntime().createVirtualFrame(null, descriptor);
    Assert.assertSame(frame.getFrameDescriptor(), node.execute(frame, 2));
    Assert.assertSame(frame.getFrameDescriptor(), node.execute(frame, 3));
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) VirtualFrame(com.oracle.truffle.api.frame.VirtualFrame) Test(org.junit.Test)

Aggregations

FrameDescriptor (com.oracle.truffle.api.frame.FrameDescriptor)72 Test (org.junit.Test)61 RootTestNode (org.graalvm.compiler.truffle.test.nodes.RootTestNode)50 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)12 VirtualFrame (com.oracle.truffle.api.frame.VirtualFrame)9 FrameSlot (com.oracle.truffle.api.frame.FrameSlot)7 AddTestNode (org.graalvm.compiler.truffle.test.nodes.AddTestNode)7 BlockTestNode (org.graalvm.compiler.truffle.test.nodes.BlockTestNode)6 Assumption (com.oracle.truffle.api.Assumption)5 CallTarget (com.oracle.truffle.api.CallTarget)5 TruffleRuntime (com.oracle.truffle.api.TruffleRuntime)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 RootCallTarget (com.oracle.truffle.api.RootCallTarget)2 WeakReference (java.lang.ref.WeakReference)2 List (java.util.List)2