Search in sources :

Example 21 with Assumption

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

the class UnionAssumptionTest method testIsValid.

@Test
public void testIsValid() {
    final Assumption first = Truffle.getRuntime().createAssumption("first");
    final Assumption second = Truffle.getRuntime().createAssumption("second");
    final UnionAssumption union = new UnionAssumption(first, second);
    assertTrue(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 22 with Assumption

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

the class DispatchOutputStream method outListChanged.

private void outListChanged() {
    Assumption changed = outListUnchanged;
    outListUnchanged = Truffle.getRuntime().createAssumption("Unchanged list");
    changed.invalidate();
}
Also used : Assumption(com.oracle.truffle.api.Assumption)

Example 23 with Assumption

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

the class ContextObject method addListener.

void addListener(AllocationListener l) {
    CompilerAsserts.neverPartOfCompilation();
    boolean hadListeners;
    synchronized (this) {
        if (listeners == null) {
            listeners = new AllocationListener[] { l };
            hadListeners = false;
        } else {
            int index = listeners.length;
            AllocationListener[] newListeners = Arrays.copyOf(listeners, index + 1);
            newListeners[index] = l;
            listeners = newListeners;
            hadListeners = true;
        }
        Assumption assumption = listenersNotChangedAssumption;
        listenersNotChangedAssumption = Truffle.getRuntime().createAssumption();
        assumption.invalidate();
    }
    if (!hadListeners) {
        propSupport.firePropertyChange(PROPERTY_ACTIVE, false, true);
    }
}
Also used : Assumption(com.oracle.truffle.api.Assumption)

Example 24 with Assumption

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

the class ProbeNode method lazyUpdatedImpl.

private EventChainNode lazyUpdatedImpl(VirtualFrame frame) {
    EventChainNode oldChain;
    EventChainNode nextChain;
    Lock lock = getLock();
    lock.lock();
    try {
        Assumption localVersion = this.version;
        if (localVersion != null && localVersion.isValid()) {
            return this.chain;
        }
        nextChain = handler.createBindings(frame, ProbeNode.this);
        if (nextChain == null) {
            // chain is null -> remove wrapper;
            // Note: never set child nodes to null, can cause races
            InstrumentationHandler.removeWrapper(ProbeNode.this);
            return null;
        }
        oldChain = this.chain;
        this.chain = insert(nextChain);
        this.version = Truffle.getRuntime().createAssumption("Instruments unchanged");
    } finally {
        lock.unlock();
    }
    if (oldChain != null) {
        oldChain.onDispose(context, frame);
    }
    return nextChain;
}
Also used : Lock(java.util.concurrent.locks.Lock) Assumption(com.oracle.truffle.api.Assumption)

Example 25 with Assumption

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

the class ShapeImpl method getLeafAssumption.

/**
 * @since 0.17 or earlier
 */
@Override
public final Assumption getLeafAssumption() {
    Assumption assumption = leafAssumption;
    if (assumption != null) {
        return assumption;
    } else {
        CompilerDirectives.transferToInterpreterAndInvalidate();
        Assumption prev;
        Assumption next;
        do {
            prev = LEAF_ASSUMPTION_UPDATER.get(this);
            if (prev != null) {
                return prev;
            } else {
                boolean isLeafShape = transitionMap == null;
                next = isLeafShape ? createLeafAssumption() : NeverValidAssumption.INSTANCE;
            }
        } while (!LEAF_ASSUMPTION_UPDATER.compareAndSet(this, prev, next));
        return next;
    }
}
Also used : NeverValidAssumption(com.oracle.truffle.api.utilities.NeverValidAssumption) 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