Search in sources :

Example 71 with CallTarget

use of com.oracle.truffle.api.CallTarget in project sulong by graalvm.

the class NFIAPITest method loadLibrary.

private static TruffleObject loadLibrary(String lib, String filename, String mimetype) {
    File file = new File(TEST_DIR.toFile(), lib + "/" + filename);
    String loadLib = "load '" + file.getAbsolutePath() + "'";
    Source source = Source.newBuilder(loadLib).name("loadLibrary").mimeType(mimetype).build();
    CallTarget target = runWithPolyglot.getTruffleTestEnv().parse(source);
    return (TruffleObject) target.call();
}
Also used : CallTarget(com.oracle.truffle.api.CallTarget) File(java.io.File) Source(com.oracle.truffle.api.source.Source) TruffleObject(com.oracle.truffle.api.interop.TruffleObject)

Example 72 with CallTarget

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

the class OptimizedOSRLoopNodeTest method testStackTraceDoesNotShowOSR.

/*
     * OSR stack frames should not show up.
     */
@Theory
public void testStackTraceDoesNotShowOSR(OSRLoopFactory factory) {
    TestRootNode rootNode = new TestRootNode(factory, new TestOSRStackTrace());
    CallTarget target = runtime.createCallTarget(rootNode);
    target.call(1);
    rootNode.forceOSR();
    assertCompiled(rootNode.getOSRTarget());
    target.call(1);
    assertCompiled(rootNode.getOSRTarget());
}
Also used : RootCallTarget(com.oracle.truffle.api.RootCallTarget) OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) Theory(org.junit.experimental.theories.Theory)

Example 73 with CallTarget

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

the class OptimizedOSRLoopNodeTest method testOSRSingleInvocation.

/*
     * Test that we achieve compilation on the first execution with a loop invoked
     */
@Theory
public void testOSRSingleInvocation(OSRLoopFactory factory) {
    TestRootNode rootNode = new TestRootNode(factory, new TestRepeatingNode());
    CallTarget target = runtime.createCallTarget(rootNode);
    target.call(OSR_THRESHOLD + 1);
    assertCompiled(rootNode.getOSRTarget());
    target.call(2);
    assertCompiled(rootNode.getOSRTarget());
    Assert.assertTrue(rootNode.wasRepeatingCalledCompiled());
}
Also used : RootCallTarget(com.oracle.truffle.api.RootCallTarget) OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) Theory(org.junit.experimental.theories.Theory)

Example 74 with CallTarget

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

the class OptimizedOSRLoopNodeTest method testTwoLoopsParentChild1.

/*
     * Test that two loops in a parent child relationship are propagating loop counts.
     */
@Theory
public void testTwoLoopsParentChild1(OSRLoopFactory factory) {
    ChildLoopRepeatingNode childLoop = new ChildLoopRepeatingNode(factory, new TestRepeatingNode(), loop -> {
        assertNotCompiled(loop.getOSRTarget());
        return null;
    });
    TestRootNode rootNode = new TestRootNode(factory, childLoop);
    CallTarget target = runtime.createCallTarget(rootNode);
    target.call(1, OSR_THRESHOLD);
    assertCompiled(rootNode.getOSRTarget());
    assertNotCompiled(childLoop.getOSRTarget());
}
Also used : RootCallTarget(com.oracle.truffle.api.RootCallTarget) OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) Theory(org.junit.experimental.theories.Theory)

Example 75 with CallTarget

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

the class OptimizedOSRLoopNodeTest method testTwoLoopsParentChild2.

@Theory
public void testTwoLoopsParentChild2(OSRLoopFactory factory) {
    ChildLoopRepeatingNode childLoop = new ChildLoopRepeatingNode(factory, new TestRepeatingNode(), loop -> {
        assertCompiled(loop.getOSRTarget());
        return null;
    });
    TestRootNode rootNode = new TestRootNode(factory, childLoop);
    CallTarget target = runtime.createCallTarget(rootNode);
    target.call(1, OSR_THRESHOLD + 1);
    assertCompiled(rootNode.getOSRTarget());
    assertCompiled(childLoop.getOSRTarget());
}
Also used : RootCallTarget(com.oracle.truffle.api.RootCallTarget) OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) Theory(org.junit.experimental.theories.Theory)

Aggregations

CallTarget (com.oracle.truffle.api.CallTarget)128 Test (org.junit.Test)102 TestHelper.createCallTarget (com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget)50 RootCallTarget (com.oracle.truffle.api.RootCallTarget)26 RootNode (com.oracle.truffle.api.nodes.RootNode)17 TruffleRuntime (com.oracle.truffle.api.TruffleRuntime)15 VirtualFrame (com.oracle.truffle.api.frame.VirtualFrame)10 UnsupportedSpecializationException (com.oracle.truffle.api.dsl.UnsupportedSpecializationException)9 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)9 Node (com.oracle.truffle.api.nodes.Node)9 OptimizedCallTarget (org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)9 TruffleContext (com.oracle.truffle.api.TruffleContext)6 LanguageContext (com.oracle.truffle.api.test.polyglot.LanguageSPITestLanguage.LanguageContext)6 Context (org.graalvm.polyglot.Context)6 Theory (org.junit.experimental.theories.Theory)6 TruffleException (com.oracle.truffle.api.TruffleException)5 UnknownIdentifierException (com.oracle.truffle.api.interop.UnknownIdentifierException)5 UnsupportedMessageException (com.oracle.truffle.api.interop.UnsupportedMessageException)5 UnsupportedTypeException (com.oracle.truffle.api.interop.UnsupportedTypeException)5 Source (com.oracle.truffle.api.source.Source)5