Search in sources :

Example 16 with CallTarget

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

the class CachedTest method testCacheMethod.

@Test
public void testCacheMethod() {
    TestCacheMethod.invocations = 0;
    CallTarget root = createCallTarget(TestCacheMethodFactory.getInstance());
    assertEquals(42, root.call(42));
    assertEquals(42, root.call(43));
    assertEquals(42, root.call(44));
    assertEquals(1, TestCacheMethod.invocations);
}
Also used : TestHelper.createCallTarget(com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) Test(org.junit.Test)

Example 17 with CallTarget

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

the class CachedTest method testCachesOrder.

@Test
public void testCachesOrder() {
    CallTarget root = createCallTarget(TestCachesOrderFactory.getInstance());
    assertEquals(42, root.call(21));
    assertEquals(42, root.call(22));
    assertEquals(42, root.call(23));
}
Also used : TestHelper.createCallTarget(com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) Test(org.junit.Test)

Example 18 with CallTarget

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

the class CachedTest method testCacheNodeWithReplace.

@Test
public void testCacheNodeWithReplace() {
    CallTarget root = createCallTarget(CacheNodeWithReplaceFactory.getInstance());
    assertEquals(42, root.call(41));
    assertEquals(42, root.call(40));
    assertEquals(42, root.call(39));
}
Also used : TestHelper.createCallTarget(com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) Test(org.junit.Test)

Example 19 with CallTarget

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

the class ExecuteEvaluatedTest method testSingleEvaluated.

@Test
public void testSingleEvaluated() {
    ArgumentNode arg0 = new ArgumentNode(0);
    CallTarget callTarget = TestHelper.createCallTarget(UseEvaluatedNodeFactory.create(arg0, EvaluatedNodeFactory.create(null)));
    Assert.assertEquals(43, callTarget.call(new Object[] { 42 }));
    Assert.assertEquals(1, arg0.getInvocationCount());
}
Also used : CallTarget(com.oracle.truffle.api.CallTarget) ArgumentNode(com.oracle.truffle.api.dsl.test.TypeSystemTest.ArgumentNode) Test(org.junit.Test)

Example 20 with CallTarget

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

the class DebugStackFrame method findCurrentRoot.

RootNode findCurrentRoot() {
    SuspendedContext context = getContext();
    if (currentFrame == null) {
        return context.getInstrumentedNode().getRootNode();
    } else {
        Node callNode = currentFrame.getCallNode();
        if (callNode != null) {
            return callNode.getRootNode();
        }
        CallTarget target = currentFrame.getCallTarget();
        if (target instanceof RootCallTarget) {
            return ((RootCallTarget) target).getRootNode();
        }
        return null;
    }
}
Also used : RootCallTarget(com.oracle.truffle.api.RootCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) Node(com.oracle.truffle.api.nodes.Node) RootNode(com.oracle.truffle.api.nodes.RootNode) RootCallTarget(com.oracle.truffle.api.RootCallTarget)

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