Search in sources :

Example 11 with Unpreemptible

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

the class ThinLock method inlineLock.

@Inline
@NoNullCheck
@Unpreemptible
@Entrypoint
public static void inlineLock(Object o, Offset lockOffset) {
    // FIXME: bad for PPC?
    Word old = Magic.prepareWord(o, lockOffset);
    Word id = old.and(TL_THREAD_ID_MASK.or(TL_STAT_MASK));
    Word tid = Word.fromIntSignExtend(RVMThread.getCurrentThread().getLockingId());
    if (id.EQ(tid)) {
        Word changed = old.plus(TL_LOCK_COUNT_UNIT);
        if (!changed.and(TL_LOCK_COUNT_MASK).isZero()) {
            setDedicatedU16(o, lockOffset, changed);
            Magic.combinedLoadBarrier();
            return;
        }
    } else if (id.EQ(TL_STAT_THIN)) {
        // lock is thin and not held by anyone
        if (Magic.attemptWord(o, lockOffset, old, old.or(tid))) {
            if (!VM.MagicAttemptImpliesStoreLoadBarrier)
                Magic.fence();
            return;
        }
    }
    lock(o, lockOffset);
}
Also used : Word(org.vmmagic.unboxed.Word) Unpreemptible(org.vmmagic.pragma.Unpreemptible) Entrypoint(org.vmmagic.pragma.Entrypoint) NoNullCheck(org.vmmagic.pragma.NoNullCheck) Inline(org.vmmagic.pragma.Inline) NoInline(org.vmmagic.pragma.NoInline)

Example 12 with Unpreemptible

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

the class RVMThread method yieldpointFromEpilogue.

/**
 * Yieldpoint taken in epilogue.
 */
@BaselineSaveLSRegisters
// Save all non-volatile registers in prologue
@NoOptCompile
@NoInline
// TODO fix this -- related to SaveVolatile
@Entrypoint
@Unpreemptible("Becoming another thread interrupts the current thread, avoid preemption in the process")
public static void yieldpointFromEpilogue() {
    Address fp = Magic.getFramePointer();
    yieldpoint(EPILOGUE, fp);
}
Also used : Address(org.vmmagic.unboxed.Address) Unpreemptible(org.vmmagic.pragma.Unpreemptible) Entrypoint(org.vmmagic.pragma.Entrypoint) BaselineSaveLSRegisters(org.vmmagic.pragma.BaselineSaveLSRegisters) NoInline(org.vmmagic.pragma.NoInline) NoOptCompile(org.vmmagic.pragma.NoOptCompile)

Example 13 with Unpreemptible

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

the class RVMThread method unblockAllMutatorsForGC.

/**
 * Unblock all mutators blocked for GC.
 */
@NoCheckStore
@Unpreemptible
public static void unblockAllMutatorsForGC() {
    RVMThread.handshakeLock.lockNoHandshake();
    RVMThread.acctLock.lockNoHandshake();
    int numToHandshake = 0;
    for (int i = 0; i < RVMThread.numThreads; i++) {
        RVMThread t = RVMThread.threads[i];
        if (!t.isCollectorThread() && !t.ignoreHandshakesAndGC()) {
            RVMThread.handshakeThreads[numToHandshake++] = t;
        }
    }
    RVMThread.acctLock.unlock();
    for (int i = 0; i < numToHandshake; i++) {
        RVMThread.handshakeThreads[i].unblock(RVMThread.gcBlockAdapter);
        // Help GC
        RVMThread.handshakeThreads[i] = null;
    }
    RVMThread.handshakeLock.unlock();
}
Also used : Entrypoint(org.vmmagic.pragma.Entrypoint) Unpreemptible(org.vmmagic.pragma.Unpreemptible) NoCheckStore(org.vmmagic.pragma.NoCheckStore)

Example 14 with Unpreemptible

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

the class Lock method unlockHeavy.

/**
 * Releases this heavy-weight lock on the indicated object.
 *
 * @param o the object to be unlocked
 */
@Unpreemptible
public void unlockHeavy(Object o) {
    boolean deflated = false;
    // Note: thread switching is not allowed while mutex is held.
    mutex.lock();
    RVMThread me = RVMThread.getCurrentThread();
    if (ownerId != me.getLockingId()) {
        // thread-switching benign
        mutex.unlock();
        raiseIllegalMonitorStateException("heavy unlocking", o);
    }
    recursionCount--;
    if (0 < recursionCount) {
        // thread-switching benign
        mutex.unlock();
        return;
    }
    if (STATS)
        unlockOperations++;
    ownerId = 0;
    RVMThread toAwaken = entering.dequeue();
    if (toAwaken == null && entering.isEmpty() && waiting.isEmpty()) {
        // heavy lock can be deflated
        // Possible project: decide on a heuristic to control when lock should be deflated
        Offset lockOffset = Magic.getObjectType(o).getThinLockOffset();
        if (!lockOffset.isMax()) {
            // deflate heavy lock
            deflate(o, lockOffset);
            deflated = true;
        }
    }
    // does a Magic.sync();  (thread-switching benign)
    mutex.unlock();
    if (toAwaken != null) {
        toAwaken.monitor().lockedBroadcastNoHandshake();
    }
}
Also used : Offset(org.vmmagic.unboxed.Offset) Unpreemptible(org.vmmagic.pragma.Unpreemptible)

Example 15 with Unpreemptible

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

the class OnStackReplacementTrigger method trigger.

@NoInline
@Unpreemptible
public static void trigger(int ypTakenInCMID, Offset tsFromFPoff, Offset ypTakenFPoff, int whereFrom) {
    RVMThread thread = RVMThread.getCurrentThread();
    CompiledMethod ypTakenInCM = CompiledMethods.getCompiledMethod(ypTakenInCMID);
    RVMMethod ypTakenInMethod = ypTakenInCM.getMethod();
    boolean isInBootImage = ypTakenInMethod.getDeclaringClass().isInBootImage();
    if (isInBootImage)
        return;
    OnStackReplacementEvent event = (OnStackReplacementEvent) thread.onStackReplacementEvent;
    event.suspendedThread = thread;
    event.whereFrom = whereFrom;
    event.CMID = ypTakenInCMID;
    event.tsFromFPoff = tsFromFPoff;
    event.ypTakenFPoff = ypTakenFPoff;
    thread.monitor().lockNoHandshake();
    thread.requesting_osr = true;
    thread.monitor().unlock();
    Controller.osrOrganizer.activate();
    // PNT: Assumes that OSR doesn't need access to our context regs
    thread.monitor().lockNoHandshake();
    while (!thread.osr_done) {
        thread.monitor().waitWithHandshake();
    }
    thread.osr_done = false;
    thread.monitor().unlock();
}
Also used : RVMMethod(org.jikesrvm.classloader.RVMMethod) RVMThread(org.jikesrvm.scheduler.RVMThread) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) Unpreemptible(org.vmmagic.pragma.Unpreemptible) NoInline(org.vmmagic.pragma.NoInline)

Aggregations

Unpreemptible (org.vmmagic.pragma.Unpreemptible)34 Entrypoint (org.vmmagic.pragma.Entrypoint)23 NoInline (org.vmmagic.pragma.NoInline)14 Address (org.vmmagic.unboxed.Address)12 RVMThread (org.jikesrvm.scheduler.RVMThread)7 Offset (org.vmmagic.unboxed.Offset)6 Word (org.vmmagic.unboxed.Word)6 NoCheckStore (org.vmmagic.pragma.NoCheckStore)5 NoNullCheck (org.vmmagic.pragma.NoNullCheck)5 OptCompiledMethod (org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)4 Inline (org.vmmagic.pragma.Inline)4 BaselineSaveLSRegisters (org.vmmagic.pragma.BaselineSaveLSRegisters)3 NoOptCompile (org.vmmagic.pragma.NoOptCompile)3 NormalMethod (org.jikesrvm.classloader.NormalMethod)2 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)2 GPR (org.jikesrvm.ia32.RegisterConstants.GPR)2 AbstractRegisters (org.jikesrvm.architecture.AbstractRegisters)1 RVMArray (org.jikesrvm.classloader.RVMArray)1 RVMMethod (org.jikesrvm.classloader.RVMMethod)1 RVMType (org.jikesrvm.classloader.RVMType)1