Search in sources :

Example 66 with FrameDescriptor

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

the class SLNodeFactory method startFunction.

public void startFunction(Token nameToken, int bodyStartPos) {
    assert functionStartPos == 0;
    assert functionName == null;
    assert functionBodyStartPos == 0;
    assert parameterCount == 0;
    assert frameDescriptor == null;
    assert lexicalScope == null;
    functionStartPos = nameToken.charPos;
    functionName = nameToken.val;
    functionBodyStartPos = bodyStartPos;
    frameDescriptor = new FrameDescriptor();
    methodNodes = new ArrayList<>();
    startBlock();
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor)

Example 67 with FrameDescriptor

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

Example 68 with FrameDescriptor

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

the class DebuggerSessionSnippets method clearFrame.

private static void clearFrame(MaterializedFrame frame) {
    FrameDescriptor descriptor = frame.getFrameDescriptor();
    Object value = descriptor.getDefaultValue();
    for (FrameSlot slot : descriptor.getSlots()) {
        frame.setObject(slot, value);
    }
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) FrameSlot(com.oracle.truffle.api.frame.FrameSlot)

Example 69 with FrameDescriptor

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

the class ImplicitCastTest method testExecuteChildWithImplicitCast1.

@Test
public void testExecuteChildWithImplicitCast1() throws UnexpectedResultException {
    ExecuteChildWithImplicitCast1Node node = ExecuteChildWithImplicitCast1NodeGen.create(createArguments(1));
    /*
         * if executeLong is used for the initial execution of the node and the uninitialized case
         * is not checked then this executeLong method might return 0L instead of 2L. This test
         * verifies that this particular case does not happen.
         */
    Assert.assertEquals(2L, node.executeLong(Truffle.getRuntime().createVirtualFrame(new Object[] { 2L }, new FrameDescriptor())));
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) Test(org.junit.Test)

Example 70 with FrameDescriptor

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

the class ReturnTypeSpecializationTest method test.

@Test
public void test() {
    TruffleRuntime runtime = Truffle.getRuntime();
    FrameDescriptor frameDescriptor = new FrameDescriptor();
    FrameSlot slot = frameDescriptor.addFrameSlot("localVar", FrameSlotKind.Int);
    TestRootNode rootNode = new TestRootNode(frameDescriptor, new IntAssignLocal(slot, new StringTestChildNode()), new IntReadLocal(slot));
    CallTarget target = runtime.createCallTarget(rootNode);
    Assert.assertEquals(FrameSlotKind.Int, slot.getKind());
    Object result = target.call();
    Assert.assertEquals("42", result);
    Assert.assertEquals(FrameSlotKind.Object, slot.getKind());
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) FrameSlot(com.oracle.truffle.api.frame.FrameSlot) CallTarget(com.oracle.truffle.api.CallTarget) TruffleRuntime(com.oracle.truffle.api.TruffleRuntime) 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