Search in sources :

Example 26 with NoInline

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

the class VM method writeField.

@NoInline
public static /* don't waste code space inlining these --dave */
void writeField(int fieldWidth, String s) {
    write(s);
    int len = getStringLength(s);
    while (fieldWidth > len++) write(" ");
}
Also used : Entrypoint(org.vmmagic.pragma.Entrypoint) NoInline(org.vmmagic.pragma.NoInline)

Example 27 with NoInline

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

the class ThinLock method lock.

@NoInline
@NoNullCheck
@Unpreemptible
public static void lock(Object o, Offset lockOffset) {
    if (STATS)
        fastLocks++;
    Word threadId = Word.fromIntZeroExtend(RVMThread.getCurrentThread().getLockingId());
    for (int cnt = 0; ; cnt++) {
        Word old = Magic.getWordAtOffset(o, lockOffset);
        Word stat = old.and(TL_STAT_MASK);
        boolean tryToInflate = false;
        if (stat.EQ(TL_STAT_BIASABLE)) {
            Word id = old.and(TL_THREAD_ID_MASK);
            if (id.isZero()) {
                if (ENABLE_BIASED_LOCKING) {
                    // lock is unbiased, bias it in our favor and grab it
                    if (Synchronization.tryCompareAndSwap(o, lockOffset, old, old.or(threadId).plus(TL_LOCK_COUNT_UNIT))) {
                        if (!VM.MagicAttemptImpliesStoreLoadBarrier)
                            Magic.fence();
                        return;
                    }
                } else {
                    // a thin lock
                    if (Synchronization.tryCompareAndSwap(o, lockOffset, old, old.or(threadId).or(TL_STAT_THIN))) {
                        if (!VM.MagicAttemptImpliesStoreLoadBarrier)
                            Magic.fence();
                        return;
                    }
                }
            } else if (id.EQ(threadId)) {
                // lock is biased in our favor
                Word changed = old.plus(TL_LOCK_COUNT_UNIT);
                if (!changed.and(TL_LOCK_COUNT_MASK).isZero()) {
                    setDedicatedU16(o, lockOffset, changed);
                    Magic.combinedLoadBarrier();
                    return;
                } else {
                    tryToInflate = true;
                }
            } else {
                if (casFromBiased(o, lockOffset, old, biasBitsToThinBits(old), cnt)) {
                    // don't spin, since it's thin now
                    continue;
                }
            }
        } else if (stat.EQ(TL_STAT_THIN)) {
            Word id = old.and(TL_THREAD_ID_MASK);
            if (id.isZero()) {
                if (Synchronization.tryCompareAndSwap(o, lockOffset, old, old.or(threadId))) {
                    if (!VM.MagicAttemptImpliesStoreLoadBarrier)
                        Magic.fence();
                    return;
                }
            } else if (id.EQ(threadId)) {
                Word changed = old.plus(TL_LOCK_COUNT_UNIT);
                if (changed.and(TL_LOCK_COUNT_MASK).isZero()) {
                    tryToInflate = true;
                } else if (Synchronization.tryCompareAndSwap(o, lockOffset, old, changed)) {
                    if (!VM.MagicAttemptImpliesStoreLoadBarrier)
                        Magic.fence();
                    return;
                }
            } else if (cnt > retryLimit) {
                tryToInflate = true;
            }
        } else {
            if (VM.VerifyAssertions)
                VM._assert(stat.EQ(TL_STAT_FAT));
            // lock is fat.  contend on it.
            if (Lock.getLock(getLockIndex(old)).lockHeavy(o)) {
                return;
            }
        }
        if (tryToInflate) {
            if (STATS)
                slowLocks++;
            // Right Thing if the lock is biased to someone else.
            if (inflateAndLock(o, lockOffset)) {
                return;
            }
        } else {
            Magic.combinedLoadBarrier();
            RVMThread.yieldNoHandshake();
        }
    }
}
Also used : Word(org.vmmagic.unboxed.Word) Entrypoint(org.vmmagic.pragma.Entrypoint) Unpreemptible(org.vmmagic.pragma.Unpreemptible) NoNullCheck(org.vmmagic.pragma.NoNullCheck) NoInline(org.vmmagic.pragma.NoInline)

Example 28 with NoInline

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

the class ThinLock method unlock.

@NoInline
@NoNullCheck
@Unpreemptible
public static void unlock(Object o, Offset lockOffset) {
    Word threadId = Word.fromIntZeroExtend(RVMThread.getCurrentThread().getLockingId());
    for (int cnt = 0; ; cnt++) {
        Word old = Magic.getWordAtOffset(o, lockOffset);
        Word stat = old.and(TL_STAT_MASK);
        if (stat.EQ(TL_STAT_BIASABLE)) {
            Word id = old.and(TL_THREAD_ID_MASK);
            if (id.EQ(threadId)) {
                if (old.and(TL_LOCK_COUNT_MASK).isZero()) {
                    RVMThread.raiseIllegalMonitorStateException("biased unlocking: we own this object but the count is already zero", o);
                }
                setDedicatedU16(o, lockOffset, old.minus(TL_LOCK_COUNT_UNIT));
                Magic.fence();
                return;
            } else {
                RVMThread.raiseIllegalMonitorStateException("biased unlocking: we don't own this object", o);
            }
        } else if (stat.EQ(TL_STAT_THIN)) {
            Word id = old.and(TL_THREAD_ID_MASK);
            if (id.EQ(threadId)) {
                Word changed;
                if (old.and(TL_LOCK_COUNT_MASK).isZero()) {
                    changed = old.and(TL_UNLOCK_MASK).or(TL_STAT_THIN);
                } else {
                    changed = old.minus(TL_LOCK_COUNT_UNIT);
                }
                Magic.combinedLoadBarrier();
                if (Synchronization.tryCompareAndSwap(o, lockOffset, old, changed)) {
                    if (!VM.MagicAttemptImpliesStoreLoadBarrier)
                        Magic.fence();
                    return;
                }
            } else {
                if (false) {
                    VM.sysWriteln("threadId = ", threadId);
                    VM.sysWriteln("id = ", id);
                }
                RVMThread.raiseIllegalMonitorStateException("thin unlocking: we don't own this object", o);
            }
        } else {
            if (VM.VerifyAssertions)
                VM._assert(stat.EQ(TL_STAT_FAT));
            // fat unlock
            Lock.getLock(getLockIndex(old)).unlockHeavy(o);
            return;
        }
    }
}
Also used : Word(org.vmmagic.unboxed.Word) Entrypoint(org.vmmagic.pragma.Entrypoint) Unpreemptible(org.vmmagic.pragma.Unpreemptible) NoNullCheck(org.vmmagic.pragma.NoNullCheck) NoInline(org.vmmagic.pragma.NoInline)

Example 29 with NoInline

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

the class ThinLock method casFromBiased.

@NoInline
@Unpreemptible
public static boolean casFromBiased(Object o, Offset lockOffset, Word oldLockWord, Word changed, int cnt) {
    RVMThread me = RVMThread.getCurrentThread();
    Word id = oldLockWord.and(TL_THREAD_ID_MASK);
    if (id.isZero()) {
        if (false)
            VM.sysWriteln("id is zero - easy case.");
        return Synchronization.tryCompareAndSwap(o, lockOffset, oldLockWord, changed);
    } else {
        if (false)
            VM.sysWriteln("id = ", id);
        int slot = id.toInt() >> TL_THREAD_ID_SHIFT;
        if (false)
            VM.sysWriteln("slot = ", slot);
        RVMThread owner = RVMThread.threadBySlot[slot];
        if (owner == me || /* I own it, so I can unbias it trivially.  This occurs
                       when we are inflating due to, for example, wait() */
        owner == null) /* the thread that owned it is dead, so it's safe to
                         unbias. */
        {
            // be unbiasing.
            return Synchronization.tryCompareAndSwap(o, lockOffset, oldLockWord, changed);
        } else {
            boolean result = false;
            // goofy.
            if (false)
                VM.sysWriteln("entering pair handshake");
            owner.beginPairHandshake();
            if (false)
                VM.sysWriteln("done with that");
            Word newLockWord = Magic.getWordAtOffset(o, lockOffset);
            result = Synchronization.tryCompareAndSwap(o, lockOffset, oldLockWord, changed);
            owner.endPairHandshake();
            if (false)
                VM.sysWriteln("that worked.");
            return result;
        }
    }
}
Also used : Word(org.vmmagic.unboxed.Word) Entrypoint(org.vmmagic.pragma.Entrypoint) Unpreemptible(org.vmmagic.pragma.Unpreemptible) NoInline(org.vmmagic.pragma.NoInline)

Example 30 with NoInline

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

the class RVMThread method yieldpointFromPrologue.

/*
   * Support for yieldpoints
   */
/**
 * Yieldpoint taken in prologue.
 */
@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 yieldpointFromPrologue() {
    Address fp = Magic.getFramePointer();
    yieldpoint(PROLOGUE, 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)

Aggregations

NoInline (org.vmmagic.pragma.NoInline)46 Entrypoint (org.vmmagic.pragma.Entrypoint)23 Address (org.vmmagic.unboxed.Address)22 Unpreemptible (org.vmmagic.pragma.Unpreemptible)10 TIB (org.jikesrvm.objectmodel.TIB)9 Interruptible (org.vmmagic.pragma.Interruptible)9 RVMArray (org.jikesrvm.classloader.RVMArray)8 Word (org.vmmagic.unboxed.Word)6 NoOptCompile (org.vmmagic.pragma.NoOptCompile)5 Offset (org.vmmagic.unboxed.Offset)5 MethodReference (org.jikesrvm.classloader.MethodReference)4 CodeArray (org.jikesrvm.compilers.common.CodeArray)4 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)4 AbstractRegisters (org.jikesrvm.architecture.AbstractRegisters)3 RVMMethod (org.jikesrvm.classloader.RVMMethod)3 BaselineCompiledMethod (org.jikesrvm.compilers.baseline.BaselineCompiledMethod)3 OptCompiledMethod (org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)3 BaselineSaveLSRegisters (org.vmmagic.pragma.BaselineSaveLSRegisters)3 RVMType (org.jikesrvm.classloader.RVMType)2 RVMThread (org.jikesrvm.scheduler.RVMThread)2