use of com.oracle.truffle.api.TruffleRuntime in project graal by oracle.
the class TruffleRuntimeTest method testRuntimeIsGraalRuntime.
@Test
public void testRuntimeIsGraalRuntime() {
TruffleRuntime runtime = Truffle.getRuntime();
assertTrue(runtime.getClass() != DefaultTruffleRuntime.class);
}
use of com.oracle.truffle.api.TruffleRuntime in project graal by oracle.
the class TruffleRuntimeTest method testGetLayoutFactory.
@Test
public void testGetLayoutFactory() {
TruffleRuntime runtime = Truffle.getRuntime();
LayoutFactory layoutFactory = runtime.getCapability(LayoutFactory.class);
assertNotNull("LayoutFactory not found", layoutFactory);
boolean java8OrEarlier = System.getProperty("java.specification.version").compareTo("1.9") < 0;
ClassLoader layoutFactoryCL = layoutFactory.getClass().getClassLoader();
if (java8OrEarlier) {
// Bootstrap class loader or JVMCI class loader
assertTrue(layoutFactoryCL == null || layoutFactoryCL == runtime.getClass().getClassLoader());
} else {
// Rely on modules to only load trusted service providers
}
}
use of com.oracle.truffle.api.TruffleRuntime in project graal by oracle.
the class TruffleRuntimeTest method testGetTVMCI.
@Test
public void testGetTVMCI() {
TruffleRuntime runtime = Truffle.getRuntime();
TVMCI tvmci = runtime.getCapability(TVMCI.class);
assertNotNull("Truffle Virtual Machine Compiler Interface not found", tvmci);
assertEquals("GraalTVMCI", tvmci.getClass().getSimpleName());
abstract class TVMCISubclass extends TVMCI {
}
TVMCISubclass subclass = runtime.getCapability(TVMCISubclass.class);
assertNull("Expected null return value for TVMCI subclass", subclass);
}
use of com.oracle.truffle.api.TruffleRuntime 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());
}
use of com.oracle.truffle.api.TruffleRuntime in project graal by oracle.
the class RootNodeTest method test.
@Test
public void test() {
TruffleRuntime runtime = Truffle.getRuntime();
TestRootNode rootNode = new TestRootNode();
CallTarget target = runtime.createCallTarget(rootNode);
Object result = target.call();
Assert.assertEquals(42, result);
}
Aggregations