Search in sources :

Example 31 with Assumption

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

the class AssumptionsTest method testAssumptionInvalidateTest2.

@Test
public void testAssumptionInvalidateTest2() {
    AssumptionInvalidateTest2 node = AssumptionInvalidateTest2NodeGen.create();
    node.execute(0);
    node.execute(1);
    node.execute(2);
    for (int i = 0; i < 100; i++) {
        int removeIndex = i % 3;
        Assumption a = node.assumptions[removeIndex];
        a.invalidate();
        node.execute(removeIndex);
        assertNotSame(a, node.assumptions[removeIndex]);
    }
}
Also used : Assumption(com.oracle.truffle.api.Assumption) Test(org.junit.Test)

Example 32 with Assumption

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

the class AssumptionsTest method testAssumptionInvalidateTest3.

@Test
public void testAssumptionInvalidateTest3() {
    AssumptionInvalidateTest3 node = AssumptionInvalidateTest3NodeGen.create();
    node.execute(0);
    for (int i = 0; i < 100; i++) {
        int removeIndex = 0;
        Assumption a = node.assumptions[removeIndex];
        a.invalidate();
        node.execute(removeIndex);
        assertNotSame(a, node.assumptions[removeIndex]);
    }
}
Also used : Assumption(com.oracle.truffle.api.Assumption) Test(org.junit.Test)

Example 33 with Assumption

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

the class AssumptionsTest method testAssumptionArraysCheckUseExplodeLoop.

@Test
public void testAssumptionArraysCheckUseExplodeLoop() throws SecurityException, IllegalArgumentException, NoSuchMethodException {
    AssumptionArraysAreCompilationFinalCached node = TestHelper.createNode(AssumptionArraysAreCompilationFinalCachedFactory.getInstance(), false);
    Method isValidMethod = node.getClass().getDeclaredMethod("isValid_", Assumption[].class);
    assertNotNull(isValidMethod.getAnnotation(ExplodeLoop.class));
}
Also used : ExplodeLoop(com.oracle.truffle.api.nodes.ExplodeLoop) Method(java.lang.reflect.Method) Assumption(com.oracle.truffle.api.Assumption) Test(org.junit.Test)

Example 34 with Assumption

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

the class AssumptionsTest method testAssumptionArraysAreCompilationFinal.

@Test
public void testAssumptionArraysAreCompilationFinal() throws NoSuchFieldException, SecurityException {
    AssumptionArraysAreCompilationFinal node = TestHelper.createNode(AssumptionArraysAreCompilationFinalFactory.getInstance(), false);
    Field field = node.getClass().getDeclaredField("do1_assumption0_");
    field.setAccessible(true);
    assertEquals(Assumption[].class, field.getType());
    CompilationFinal compilationFinal = field.getAnnotation(CompilationFinal.class);
    assertEquals(1, compilationFinal.dimensions());
}
Also used : NodeField(com.oracle.truffle.api.dsl.NodeField) Field(java.lang.reflect.Field) CompilationFinal(com.oracle.truffle.api.CompilerDirectives.CompilationFinal) Assumption(com.oracle.truffle.api.Assumption) Test(org.junit.Test)

Example 35 with Assumption

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

the class AssumptionsTest method testNodeField.

@Test
public void testNodeField() {
    Assumption assumption = Truffle.getRuntime().createAssumption();
    CallTarget root = createCallTarget(NodeFieldTest2Factory.getInstance(), assumption);
    assertEquals(42, root.call(42));
    assertEquals(42, root.call(42));
    assumption.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) Assumption(com.oracle.truffle.api.Assumption) Test(org.junit.Test)

Aggregations

Assumption (com.oracle.truffle.api.Assumption)42 Test (org.junit.Test)25 UnionAssumption (com.oracle.truffle.api.utilities.UnionAssumption)8 CallTarget (com.oracle.truffle.api.CallTarget)5 FrameDescriptor (com.oracle.truffle.api.frame.FrameDescriptor)5 TestHelper.createCallTarget (com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget)3 Field (java.lang.reflect.Field)3 OptimizedCallTarget (org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)3 RootTestNode (org.graalvm.compiler.truffle.test.nodes.RootTestNode)3 CompilationFinal (com.oracle.truffle.api.CompilerDirectives.CompilationFinal)2 NodeField (com.oracle.truffle.api.dsl.NodeField)2 ExplodeLoop (com.oracle.truffle.api.nodes.ExplodeLoop)2 Node (com.oracle.truffle.api.nodes.Node)2 CodeExecutableElement (com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement)2 CodeVariableElement (com.oracle.truffle.dsl.processor.java.model.CodeVariableElement)2 CompilerDirectives (com.oracle.truffle.api.CompilerDirectives)1 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)1 Truffle (com.oracle.truffle.api.Truffle)1 TruffleRuntime (com.oracle.truffle.api.TruffleRuntime)1 Cached (com.oracle.truffle.api.dsl.Cached)1