Search in sources :

Example 16 with TruffleRuntime

use of com.oracle.truffle.api.TruffleRuntime in project graal by oracle.

the class ThreadSafetyTest method test.

@Test
@Ignore("sporadic failures with \"expected:<1000000> but was:<999999>\"")
public void test() throws InterruptedException {
    TruffleRuntime runtime = Truffle.getRuntime();
    TestRootNode rootNode1 = new TestRootNode(new RewritingNode(new RewritingNode(new RewritingNode(new RewritingNode(new RewritingNode(new ConstNode(42)))))));
    final CallTarget target1 = runtime.createCallTarget(rootNode1);
    NodeUtil.verify(rootNode1);
    RecursiveCallNode callNode = new RecursiveCallNode(new ConstNode(42));
    TestRootNode rootNode2 = new TestRootNode(new RewritingNode(new RewritingNode(new RewritingNode(new RewritingNode(new RewritingNode(callNode))))));
    final CallTarget target2 = runtime.createCallTarget(rootNode2);
    callNode.setCallNode(runtime.createDirectCallNode(target2));
    NodeUtil.verify(rootNode2);
    testTarget(target1, 47, 1_000_000);
    testTarget(target2, 72, 1_000_000);
}
Also used : CallTarget(com.oracle.truffle.api.CallTarget) TruffleRuntime(com.oracle.truffle.api.TruffleRuntime) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 17 with TruffleRuntime

use of com.oracle.truffle.api.TruffleRuntime in project graal by oracle.

the class TruffleRuntimeTest method verifyTheRealRuntimeIsUsedOnRealGraal.

// @Test
public void verifyTheRealRuntimeIsUsedOnRealGraal() {
    TruffleRuntime r = Truffle.getRuntime();
    final String name = r.getClass().getName();
    if (name.endsWith("DefaultTruffleRuntime")) {
        fail("Wrong name " + name + " with following System.getProperties:\n" + System.getProperties().toString());
    }
}
Also used : TruffleRuntime(com.oracle.truffle.api.TruffleRuntime)

Example 18 with TruffleRuntime

use of com.oracle.truffle.api.TruffleRuntime in project graal by oracle.

the class ChildrenNodesTest method testMultipleChildrenFields.

@Test
public void testMultipleChildrenFields() {
    TruffleRuntime runtime = Truffle.getRuntime();
    TestChildNode firstChild = new TestChildNode();
    TestChildNode secondChild = new TestChildNode();
    TestChildNode thirdChild = new TestChildNode();
    TestChildNode forthChild = new TestChildNode();
    TestRootNode rootNode = new TestRoot2Node(new TestChildNode[] { firstChild, secondChild }, new TestChildNode[] { thirdChild, forthChild });
    CallTarget target = runtime.createCallTarget(rootNode);
    Assert.assertEquals(rootNode, firstChild.getParent());
    Assert.assertEquals(rootNode, secondChild.getParent());
    Assert.assertEquals(rootNode, thirdChild.getParent());
    Assert.assertEquals(rootNode, forthChild.getParent());
    Iterator<Node> iterator = rootNode.getChildren().iterator();
    Assert.assertEquals(firstChild, iterator.next());
    Assert.assertEquals(secondChild, iterator.next());
    Assert.assertEquals(thirdChild, iterator.next());
    Assert.assertEquals(forthChild, iterator.next());
    Assert.assertFalse(iterator.hasNext());
    Object result = target.call();
    Assert.assertEquals(2 * 42, result);
}
Also used : CallTarget(com.oracle.truffle.api.CallTarget) Node(com.oracle.truffle.api.nodes.Node) RootNode(com.oracle.truffle.api.nodes.RootNode) TruffleRuntime(com.oracle.truffle.api.TruffleRuntime) Test(org.junit.Test)

Example 19 with TruffleRuntime

use of com.oracle.truffle.api.TruffleRuntime in project graal by oracle.

the class FrameSlotTypeSpecializationTest 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)

Example 20 with TruffleRuntime

use of com.oracle.truffle.api.TruffleRuntime in project graal by oracle.

the class FrameTest method test.

@Test
public void test() throws SecurityException, IllegalArgumentException {
    TruffleRuntime runtime = Truffle.getRuntime();
    FrameDescriptor frameDescriptor = new FrameDescriptor();
    String varName = "localVar";
    FrameSlot slot = frameDescriptor.addFrameSlot(varName, FrameSlotKind.Int);
    TestRootNode rootNode = new TestRootNode(frameDescriptor, new AssignLocal(slot), new ReadLocal(slot));
    CallTarget target = runtime.createCallTarget(rootNode);
    Object result = target.call();
    Assert.assertEquals(42, result);
    frameDescriptor.removeFrameSlot(varName);
    boolean slotMissing = false;
    try {
        result = target.call();
    } catch (IllegalArgumentException iae) {
        slotMissing = true;
    }
    Assert.assertTrue(slotMissing);
}
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

TruffleRuntime (com.oracle.truffle.api.TruffleRuntime)23 Test (org.junit.Test)19 CallTarget (com.oracle.truffle.api.CallTarget)15 RootNode (com.oracle.truffle.api.nodes.RootNode)9 DefaultTruffleRuntime (com.oracle.truffle.api.impl.DefaultTruffleRuntime)6 Node (com.oracle.truffle.api.nodes.Node)6 SubstrateTruffleRuntime (com.oracle.svm.truffle.api.SubstrateTruffleRuntime)3 Frame (com.oracle.truffle.api.frame.Frame)3 FrameDescriptor (com.oracle.truffle.api.frame.FrameDescriptor)3 FrameSlot (com.oracle.truffle.api.frame.FrameSlot)3 AnalysisField (com.oracle.graal.pointsto.meta.AnalysisField)2 AnalysisMethod (com.oracle.graal.pointsto.meta.AnalysisMethod)2 HostedProviders (com.oracle.graal.pointsto.meta.HostedProviders)2 Alias (com.oracle.svm.core.annotate.Alias)2 Delete (com.oracle.svm.core.annotate.Delete)2 NeverInline (com.oracle.svm.core.annotate.NeverInline)2 RecomputeFieldValue (com.oracle.svm.core.annotate.RecomputeFieldValue)2 Kind (com.oracle.svm.core.annotate.RecomputeFieldValue.Kind)2 TargetClass (com.oracle.svm.core.annotate.TargetClass)2 Deoptimizer (com.oracle.svm.core.deopt.Deoptimizer)2