Search in sources :

Example 1 with UnsupportedSpecializationException

use of com.oracle.truffle.api.dsl.UnsupportedSpecializationException in project graal by oracle.

the class AssumptionsTest method testStaticField.

@Test
public void testStaticField() {
    CallTarget root = createCallTarget(StaticFieldTestFactory.getInstance());
    assertEquals(42, root.call(42));
    assertEquals(42, root.call(42));
    StaticFieldTest.FIELD.invalidate();
    try {
        root.call(45);
        fail();
    } catch (UnsupportedSpecializationException e) {
    }
}
Also used : TestHelper.createCallTarget(com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) UnsupportedSpecializationException(com.oracle.truffle.api.dsl.UnsupportedSpecializationException) Test(org.junit.Test)

Example 2 with UnsupportedSpecializationException

use of com.oracle.truffle.api.dsl.UnsupportedSpecializationException in project graal by oracle.

the class AssumptionsTest method testField.

@Test
public void testField() {
    CallTarget root = createCallTarget(FieldTestFactory.getInstance());
    FieldTest node = getNode(root);
    assertEquals(42, root.call(42));
    assertEquals(42, root.call(42));
    node.field.invalidate();
    try {
        root.call(45);
        fail();
    } catch (UnsupportedSpecializationException e) {
    }
}
Also used : TestHelper.createCallTarget(com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) UnsupportedSpecializationException(com.oracle.truffle.api.dsl.UnsupportedSpecializationException) Test(org.junit.Test)

Example 3 with UnsupportedSpecializationException

use of com.oracle.truffle.api.dsl.UnsupportedSpecializationException in project graal by oracle.

the class CachedTest method testBoundCache.

@Test
public void testBoundCache() {
    CallTarget root = createCallTarget(BoundCacheFactory.getInstance());
    assertEquals(42, root.call(42));
    assertEquals(43, root.call(43));
    assertEquals(44, root.call(44));
    try {
        root.call(45);
        fail();
    } catch (UnsupportedSpecializationException e) {
    }
}
Also used : TestHelper.createCallTarget(com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) UnsupportedSpecializationException(com.oracle.truffle.api.dsl.UnsupportedSpecializationException) Test(org.junit.Test)

Example 4 with UnsupportedSpecializationException

use of com.oracle.truffle.api.dsl.UnsupportedSpecializationException in project graal by oracle.

the class IntrospectionTest method testReflection1.

@Test
public void testReflection1() {
    Introspection1Node node = Introspection1NodeGen.create();
    SpecializationInfo specialization = Introspection.getSpecialization(node, "doInt");
    assertSpecializationEquals(specialization, Introspection.getSpecializations(node).get(0));
    assertEquals("doInt", specialization.getMethodName());
    assertFalse(specialization.isActive());
    assertFalse(specialization.isExcluded());
    assertEquals(0, specialization.getInstances());
    try {
        assertEquals(0, specialization.getCachedData(0));
        fail();
    } catch (IllegalArgumentException e) {
    }
    specialization = Introspection.getSpecialization(node, "doGeneric");
    assertSpecializationEquals(specialization, Introspection.getSpecializations(node).get(1));
    assertEquals("doGeneric", specialization.getMethodName());
    assertFalse(specialization.isActive());
    assertFalse(specialization.isExcluded());
    assertEquals(0, specialization.getInstances());
    try {
        node.execute("");
        fail();
    } catch (UnsupportedSpecializationException e) {
    }
    node.execute(1);
    specialization = Introspection.getSpecialization(node, "doInt");
    assertSpecializationEquals(specialization, Introspection.getSpecializations(node).get(0));
    assertEquals("doInt", specialization.getMethodName());
    assertTrue(specialization.isActive());
    assertFalse(specialization.isExcluded());
    assertEquals(1, specialization.getInstances());
    assertEquals(1, specialization.getCachedData(0).get(0));
    specialization = Introspection.getSpecialization(node, "doGeneric");
    assertSpecializationEquals(specialization, Introspection.getSpecializations(node).get(1));
    assertEquals("doGeneric", specialization.getMethodName());
    assertFalse(specialization.isActive());
    assertFalse(specialization.isExcluded());
    assertEquals(0, specialization.getInstances());
    node.execute(1);
    specialization = Introspection.getSpecialization(node, "doInt");
    assertSpecializationEquals(specialization, Introspection.getSpecializations(node).get(0));
    assertEquals("doInt", specialization.getMethodName());
    assertTrue(specialization.isActive());
    assertFalse(specialization.isExcluded());
    assertEquals(1, specialization.getInstances());
    assertEquals(1, specialization.getCachedData(0).get(0));
    specialization = Introspection.getSpecialization(node, "doGeneric");
    assertSpecializationEquals(specialization, Introspection.getSpecializations(node).get(1));
    assertEquals("doGeneric", specialization.getMethodName());
    assertFalse(specialization.isActive());
    assertFalse(specialization.isExcluded());
    assertEquals(0, specialization.getInstances());
    node.execute(2);
    specialization = Introspection.getSpecialization(node, "doInt");
    assertSpecializationEquals(specialization, Introspection.getSpecializations(node).get(0));
    assertEquals("doInt", specialization.getMethodName());
    assertTrue(specialization.isActive());
    assertFalse(specialization.isExcluded());
    assertEquals(2, specialization.getInstances());
    assertEquals(2, specialization.getCachedData(0).get(0));
    assertEquals(1, specialization.getCachedData(1).get(0));
    specialization = Introspection.getSpecialization(node, "doGeneric");
    assertSpecializationEquals(specialization, Introspection.getSpecializations(node).get(1));
    assertEquals("doGeneric", specialization.getMethodName());
    assertFalse(specialization.isActive());
    assertFalse(specialization.isExcluded());
    assertEquals(0, specialization.getInstances());
    node.execute(3);
    specialization = Introspection.getSpecialization(node, "doInt");
    assertSpecializationEquals(specialization, Introspection.getSpecializations(node).get(0));
    assertEquals("doInt", specialization.getMethodName());
    assertTrue(specialization.isActive());
    assertFalse(specialization.isExcluded());
    assertEquals(3, specialization.getInstances());
    assertEquals(3, specialization.getCachedData(0).get(0));
    assertEquals(2, specialization.getCachedData(1).get(0));
    assertEquals(1, specialization.getCachedData(2).get(0));
    specialization = Introspection.getSpecialization(node, "doGeneric");
    assertSpecializationEquals(specialization, Introspection.getSpecializations(node).get(1));
    assertEquals("doGeneric", specialization.getMethodName());
    assertFalse(specialization.isActive());
    assertFalse(specialization.isExcluded());
    assertEquals(0, specialization.getInstances());
    node.execute(4);
    specialization = Introspection.getSpecialization(node, "doInt");
    assertSpecializationEquals(specialization, Introspection.getSpecializations(node).get(0));
    assertEquals("doInt", specialization.getMethodName());
    assertFalse(specialization.isActive());
    assertTrue(specialization.isExcluded());
    assertEquals(0, specialization.getInstances());
    specialization = Introspection.getSpecialization(node, "doGeneric");
    assertSpecializationEquals(specialization, Introspection.getSpecializations(node).get(1));
    assertEquals("doGeneric", specialization.getMethodName());
    assertTrue(specialization.isActive());
    assertFalse(specialization.isExcluded());
    assertEquals(1, specialization.getInstances());
    assertEquals(0, specialization.getCachedData(0).size());
}
Also used : SpecializationInfo(com.oracle.truffle.api.dsl.Introspection.SpecializationInfo) UnsupportedSpecializationException(com.oracle.truffle.api.dsl.UnsupportedSpecializationException) Test(org.junit.Test)

Example 5 with UnsupportedSpecializationException

use of com.oracle.truffle.api.dsl.UnsupportedSpecializationException in project graal by oracle.

the class LimitTest method testDefaultLimit3.

@Test
public void testDefaultLimit3() {
    CallTarget root = TestHelper.createCallTarget(DefaultLimit3TestFactory.getInstance());
    assertEquals(42, root.call(42));
    assertEquals(43, root.call(43));
    assertEquals(44, root.call(44));
    try {
        root.call(45);
        fail();
    } catch (UnsupportedSpecializationException e) {
    }
}
Also used : CallTarget(com.oracle.truffle.api.CallTarget) UnsupportedSpecializationException(com.oracle.truffle.api.dsl.UnsupportedSpecializationException) Test(org.junit.Test)

Aggregations

UnsupportedSpecializationException (com.oracle.truffle.api.dsl.UnsupportedSpecializationException)10 Test (org.junit.Test)10 CallTarget (com.oracle.truffle.api.CallTarget)9 TestHelper.createCallTarget (com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget)5 Assumption (com.oracle.truffle.api.Assumption)1 SpecializationInfo (com.oracle.truffle.api.dsl.Introspection.SpecializationInfo)1