use of com.oracle.truffle.api.CallTarget in project graal by oracle.
the class CachedTest method testGuardWithJustCachedParameter.
@Test
public void testGuardWithJustCachedParameter() {
TestGuardWithJustCachedParameter.invocations = 0;
CallTarget root = createCallTarget(TestGuardWithJustCachedParameterFactory.getInstance());
assertEquals(42, root.call(42));
assertEquals(42, root.call(43));
assertEquals(42, root.call(44));
if (assertionsEnabled()) {
Assert.assertTrue(TestGuardWithJustCachedParameter.invocations >= 3);
} else {
assertEquals(1, TestGuardWithJustCachedParameter.invocations);
}
}
use of com.oracle.truffle.api.CallTarget in project graal by oracle.
the class CachedTest method testMultipleCaches.
@Test
public void testMultipleCaches() {
CallTarget root = createCallTarget(TestMultipleCachesFactory.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 testBoundCacheOverflow.
@Test
public void testBoundCacheOverflow() {
CallTarget root = createCallTarget(BoundCacheOverflowFactory.getInstance());
assertEquals(42, root.call(42));
assertEquals(43, root.call(43));
assertEquals(-1, root.call(44));
assertEquals(42, root.call(42));
assertEquals(43, root.call(43));
assertEquals(-1, root.call(44));
}
use of com.oracle.truffle.api.CallTarget in project graal by oracle.
the class CachedTest method testGuardWithCachedAndDynamicParameter.
@Test
public void testGuardWithCachedAndDynamicParameter() {
TestGuardWithCachedAndDynamicParameter.cachedMethodInvocations = 0;
TestGuardWithCachedAndDynamicParameter.dynamicMethodInvocations = 0;
CallTarget root = createCallTarget(TestGuardWithCachedAndDynamicParameterFactory.getInstance());
assertEquals(42, root.call(42));
assertEquals(42, root.call(43));
assertEquals(42, root.call(44));
// guards with just cached parameters are just invoked on the slow path
if (assertionsEnabled()) {
Assert.assertTrue(TestGuardWithCachedAndDynamicParameter.cachedMethodInvocations >= 3);
} else {
assertEquals(1, TestGuardWithCachedAndDynamicParameter.cachedMethodInvocations);
}
Assert.assertTrue(TestGuardWithCachedAndDynamicParameter.dynamicMethodInvocations >= 3);
}
use of com.oracle.truffle.api.CallTarget in project graal by oracle.
the class CachedTest method testCacheNodeField.
@Test
public void testCacheNodeField() {
CallTarget root = createCallTarget(TestCacheNodeFieldFactory.getInstance(), 21);
assertEquals(21, root.call(42));
assertEquals(21, root.call(43));
}
Aggregations