Search in sources :

Example 11 with TruffleRuntime

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);
}
Also used : DefaultTruffleRuntime(com.oracle.truffle.api.impl.DefaultTruffleRuntime) DefaultTruffleRuntime(com.oracle.truffle.api.impl.DefaultTruffleRuntime) TruffleRuntime(com.oracle.truffle.api.TruffleRuntime) Test(org.junit.Test)

Example 12 with TruffleRuntime

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
    }
}
Also used : LayoutFactory(com.oracle.truffle.api.object.LayoutFactory) DefaultTruffleRuntime(com.oracle.truffle.api.impl.DefaultTruffleRuntime) TruffleRuntime(com.oracle.truffle.api.TruffleRuntime) Test(org.junit.Test)

Example 13 with TruffleRuntime

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);
}
Also used : TVMCI(com.oracle.truffle.api.impl.TVMCI) DefaultTruffleRuntime(com.oracle.truffle.api.impl.DefaultTruffleRuntime) TruffleRuntime(com.oracle.truffle.api.TruffleRuntime) Test(org.junit.Test)

Example 14 with TruffleRuntime

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());
}
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 15 with TruffleRuntime

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);
}
Also used : 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