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