use of com.oracle.truffle.api.CallTarget in project graal by oracle.
the class EngineBenchmark method executeCallTarget2.
@Benchmark
public Object executeCallTarget2(CallTargetCallState state) {
CallTarget callTarget = state.callTarget;
int result = 0;
result += (int) callTarget.call(state.internalContext.object, state.intValue);
result += (int) callTarget.call(state.internalContext.object, state.intValue, state.intValue);
result += (int) callTarget.call(state.internalContext.object, state.intValue, state.intValue, state.intValue);
result += (int) callTarget.call(state.internalContext.object, state.intValue, state.intValue, state.intValue, state.intValue);
return result;
}
use of com.oracle.truffle.api.CallTarget in project graal by oracle.
the class AssumptionsTest method testMethod.
@Test
public void testMethod() {
CallTarget root = createCallTarget(MethodTestFactory.getInstance());
MethodTest node = getNode(root);
assertEquals(42, root.call(42));
assertEquals(42, root.call(42));
node.hiddenAssumption.invalidate();
try {
root.call(45);
fail();
} catch (UnsupportedSpecializationException e) {
}
}
use of com.oracle.truffle.api.CallTarget in project graal by oracle.
the class AssumptionsTest method testCacheAssumption.
@Test
public void testCacheAssumption() {
CallTarget root = createCallTarget(CacheAssumptionTestFactory.getInstance());
CacheAssumptionTest node = getNode(root);
assertEquals("do1", root.call(42));
assertEquals("do1", root.call(43));
assertEquals("do1", root.call(44));
node.assumptions.get(42).invalidate();
// clear 42
node.assumptions.put(42, null);
node.assumptions.get(43).invalidate();
node.assumptions.get(44).invalidate();
// recreates 42
assertEquals("do1", root.call(42));
// invalid 43 -> remove -> insert do2
assertEquals("do2", root.call(43));
// here is an unfixed bug in the old dsl layout. the new layout gets rid
// of invalid cached entries earlier, therefore lines are available again.
// 43 got removed, so there is space for 45
assertEquals("do1", root.call(45));
// no more lines can be created.
assertEquals("do2", root.call(46));
}
use of com.oracle.truffle.api.CallTarget in project graal by oracle.
the class AssumptionsTest method testCacheAssumptionLimit.
@Test
public void testCacheAssumptionLimit() {
CallTarget root = createCallTarget(CacheAssumptionTestFactory.getInstance());
assertEquals("do1", root.call(42));
assertEquals("do1", root.call(43));
assertEquals("do1", root.call(44));
assertEquals("do2", root.call(45));
assertEquals("do1", root.call(43));
assertEquals("do1", root.call(44));
}
use of com.oracle.truffle.api.CallTarget in project graal by oracle.
the class AssumptionsTest method testMultipleAssumptions.
@Test
public void testMultipleAssumptions() {
CallTarget root = createCallTarget(MultipleAssumptionsTestFactory.getInstance());
MultipleAssumptionsTest node = getNode(root);
node.assumption1 = Truffle.getRuntime().createAssumption();
node.assumption2 = Truffle.getRuntime().createAssumption();
assertEquals("do1", root.call(42));
node.assumption1.invalidate();
assertEquals("do2", root.call(42));
CallTarget root2 = createCallTarget(MultipleAssumptionsTestFactory.getInstance());
MultipleAssumptionsTest node2 = getNode(root2);
node2.assumption1 = Truffle.getRuntime().createAssumption();
node2.assumption2 = Truffle.getRuntime().createAssumption();
assertEquals("do1", root2.call(42));
node2.assumption2.invalidate();
assertEquals("do2", root2.call(42));
}
Aggregations