Search in sources :

Example 6 with NoCheckStore

use of org.vmmagic.pragma.NoCheckStore in project JikesRVM by JikesRVM.

the class RVMThread method hardHandshakeSuspend.

@Unpreemptible
@NoCheckStore
public static void hardHandshakeSuspend(BlockAdapter ba, HardHandshakeVisitor hhv) {
    long before = sysCall.sysNanoTime();
    RVMThread current = getCurrentThread();
    handshakeLock.lockWithHandshake();
    int numLockedLocks = 0;
    for (int i = 0; i < nextSlot; ++i) {
        Monitor l = communicationLockBySlot[i];
        if (l != null) {
            l.lockWithHandshake();
            numLockedLocks++;
        }
    }
    // while we're waiting.  that is unlikely but possible.
    for (; ; ) {
        acctLock.lockNoHandshake();
        int numToHandshake = 0;
        for (int i = 0; i < numThreads; ++i) {
            RVMThread t = threads[i];
            if (t != current && !t.ignoreHandshakesAndGC() && hhv.includeThread(t)) {
                handshakeThreads[numToHandshake++] = t;
            }
        }
        acctLock.unlock();
        for (int i = 0; i < numToHandshake; ++i) {
            RVMThread t = handshakeThreads[i];
            t.monitor().lockNoHandshake();
            if (t.blockedFor(ba) || notRunning(t.asyncBlock(ba))) {
                // already blocked or not running, remove
                handshakeThreads[i--] = handshakeThreads[--numToHandshake];
                // help GC
                handshakeThreads[numToHandshake] = null;
            }
            t.monitor().unlock();
        }
        // terminating).
        if (numToHandshake == 0)
            break;
        for (int i = 0; i < numToHandshake; ++i) {
            RVMThread t = handshakeThreads[i];
            observeExecStatusAtSTW(t.block(ba));
            // help GC
            handshakeThreads[i] = null;
        }
    }
    processAboutToTerminate();
    /*
                                * ensure that any threads that died while
                                * we were stopping the world notify us
                                * that they had stopped.
                                */
    int numUnlockedLocks = 0;
    for (int i = 0; i < nextSlot; ++i) {
        Monitor l = communicationLockBySlot[i];
        if (l != null) {
            l.unlock();
            numUnlockedLocks++;
        }
    }
    if (VM.VerifyAssertions)
        VM._assert(numLockedLocks == numUnlockedLocks);
    handshakeLock.unlock();
    if (false) {
        long after = sysCall.sysNanoTime();
        totalSuspendTime += after - before;
        VM.sysWriteln("Stopping the world took ", (after - before), " ns (", totalSuspendTime, " ns total)");
    }
}
Also used : Entrypoint(org.vmmagic.pragma.Entrypoint) Unpreemptible(org.vmmagic.pragma.Unpreemptible) NoCheckStore(org.vmmagic.pragma.NoCheckStore)

Example 7 with NoCheckStore

use of org.vmmagic.pragma.NoCheckStore in project JikesRVM by JikesRVM.

the class RVMThread method hardHandshakeResume.

@NoCheckStore
@Unpreemptible
public static void hardHandshakeResume(BlockAdapter ba, HardHandshakeVisitor hhv) {
    long before = sysCall.sysNanoTime();
    handshakeLock.lockWithHandshake();
    RVMThread current = getCurrentThread();
    acctLock.lockNoHandshake();
    int numToHandshake = 0;
    for (int i = 0; i < numThreads; ++i) {
        RVMThread t = threads[i];
        if (t != current && !t.ignoreHandshakesAndGC() && hhv.includeThread(t)) {
            handshakeThreads[numToHandshake++] = t;
        }
    }
    acctLock.unlock();
    for (int i = 0; i < numToHandshake; ++i) {
        handshakeThreads[i].unblock(ba);
        // help GC
        handshakeThreads[i] = null;
    }
    handshakeLock.unlock();
    if (false) {
        long after = sysCall.sysNanoTime();
        totalResumeTime += after - before;
        VM.sysWriteln("Resuming the world took ", (after - before), " ns (", totalResumeTime, " ns total)");
    }
}
Also used : Entrypoint(org.vmmagic.pragma.Entrypoint) Unpreemptible(org.vmmagic.pragma.Unpreemptible) NoCheckStore(org.vmmagic.pragma.NoCheckStore)

Aggregations

Entrypoint (org.vmmagic.pragma.Entrypoint)7 NoCheckStore (org.vmmagic.pragma.NoCheckStore)7 Unpreemptible (org.vmmagic.pragma.Unpreemptible)5