Search in sources :

Example 36 with Assumption

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

the class UnionAssumptionTest method testBothInvalidateCheck.

@Test(expected = InvalidAssumptionException.class)
public void testBothInvalidateCheck() throws InvalidAssumptionException {
    final Assumption first = Truffle.getRuntime().createAssumption("first");
    final Assumption second = Truffle.getRuntime().createAssumption("second");
    final UnionAssumption union = new UnionAssumption(first, second);
    first.invalidate();
    second.invalidate();
    union.check();
}
Also used : UnionAssumption(com.oracle.truffle.api.utilities.UnionAssumption) Assumption(com.oracle.truffle.api.Assumption) UnionAssumption(com.oracle.truffle.api.utilities.UnionAssumption) Test(org.junit.Test)

Example 37 with Assumption

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

the class UnionAssumptionTest method testBothInvalidateIsValid.

@Test
public void testBothInvalidateIsValid() {
    final Assumption first = Truffle.getRuntime().createAssumption("first");
    final Assumption second = Truffle.getRuntime().createAssumption("second");
    final UnionAssumption union = new UnionAssumption(first, second);
    first.invalidate();
    second.invalidate();
    assertFalse(union.isValid());
}
Also used : UnionAssumption(com.oracle.truffle.api.utilities.UnionAssumption) Assumption(com.oracle.truffle.api.Assumption) UnionAssumption(com.oracle.truffle.api.utilities.UnionAssumption) Test(org.junit.Test)

Example 38 with Assumption

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

the class AssumedValue method set.

/**
 * Set a new value, which will be picked up the next time {@link #get} is called.
 *
 * @since 0.8 or earlier
 */
public void set(T newValue) {
    CompilerDirectives.transferToInterpreter();
    value = newValue;
    Assumption newAssumption = Truffle.getRuntime().createAssumption(name);
    Assumption oldAssumption = ASSUMPTION_UPDATER.getAndSet(this, newAssumption);
    oldAssumption.invalidate();
}
Also used : Assumption(com.oracle.truffle.api.Assumption)

Example 39 with Assumption

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

the class CyclicAssumptionSnippets method invalidate.

/**
 * @since 0.33
 */
@TruffleBoundary
public void invalidate(String message) {
    Assumption newAssumption = Truffle.getRuntime().createAssumption(name);
    Assumption oldAssumption = ASSUMPTION_UPDATER.getAndSet(this, newAssumption);
    oldAssumption.invalidate(message);
}
Also used : Assumption(com.oracle.truffle.api.Assumption) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 40 with Assumption

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

the class FlatNodeGenFactory method createIsValid.

private Element createIsValid(TypeMirror assumptionType) {
    CodeExecutableElement isValid = new CodeExecutableElement(modifiers(PRIVATE, STATIC), getType(boolean.class), "isValid_");
    CodeTreeBuilder builder = isValid.createBuilder();
    if (assumptionType.getKind() == TypeKind.ARRAY) {
        isValid.addAnnotationMirror(new CodeAnnotationMirror(context.getDeclaredType(ExplodeLoop.class)));
        isValid.addParameter(new CodeVariableElement(getType(Assumption[].class), "assumptions"));
        builder.startIf().string("assumptions == null").end().startBlock().returnFalse().end();
        builder.startFor().startGroup().type(((ArrayType) assumptionType).getComponentType()).string(" assumption : assumptions").end().end();
        builder.startBlock();
        builder.startIf().string("assumption == null || !assumption.isValid()").end();
        builder.startBlock();
        builder.returnFalse();
        builder.end();
        builder.end();
        builder.returnTrue();
    } else {
        isValid.addParameter(new CodeVariableElement(getType(Assumption.class), "assumption"));
        builder.startReturn().string("assumption != null && assumption.isValid()").end();
    }
    return isValid;
}
Also used : CodeAnnotationMirror(com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror) ArrayType(javax.lang.model.type.ArrayType) CodeExecutableElement(com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement) CodeVariableElement(com.oracle.truffle.dsl.processor.java.model.CodeVariableElement) CodeTreeBuilder(com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder) Assumption(com.oracle.truffle.api.Assumption)

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