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);
}
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());
}
}
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);
}
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());
}
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);
}
Aggregations