Search in sources :

Example 41 with Inline

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

the class RCHeader method attemptToLog.

/**
 * Attempt to log <code>object</code> for coalescing RC. This is
 * used to handle a race to log the object, and returns
 * <code>true</code> if we are to log the object and
 * <code>false</code> if we lost the race to log the object.
 *
 * <p>If this method returns <code>true</code>, it leaves the object
 * in the <code>BEING_LOGGED</code> state.  It is the responsibility
 * of the caller to change the object to <code>LOGGED</code> once
 * the logging is complete.
 *
 * @see #makeLogged(ObjectReference)
 * @param object The object in question
 * @return <code>true</code> if the race to log
 * <code>object</code>was won.
 */
@Inline
@Uninterruptible
public static boolean attemptToLog(ObjectReference object) {
    Word oldValue;
    do {
        oldValue = VM.objectModel.prepareAvailableBits(object);
        if (oldValue.and(LOGGING_MASK).EQ(LOGGED)) {
            return false;
        }
    } while ((oldValue.and(LOGGING_MASK).EQ(BEING_LOGGED)) || !VM.objectModel.attemptAvailableBits(object, oldValue, oldValue.or(BEING_LOGGED)));
    if (VM.VERIFY_ASSERTIONS) {
        Word value = VM.objectModel.readAvailableBitsWord(object);
        VM.assertions._assert(value.and(LOGGING_MASK).EQ(BEING_LOGGED));
    }
    return true;
}
Also used : Word(org.vmmagic.unboxed.Word) Uninterruptible(org.vmmagic.pragma.Uninterruptible) Inline(org.vmmagic.pragma.Inline)

Example 42 with Inline

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

the class RCHeader method initializeHeader.

/**
 * Perform any required initialization of the GC portion of the header.
 *
 * @param object the object
 * @param initialInc start with a reference count of 1 (0 if <code>false</code>)
 */
@Inline
public static void initializeHeader(ObjectReference object, boolean initialInc) {
    Word existingValue = VM.objectModel.readAvailableBitsWord(object);
    Word initialValue = existingValue.and(WRITE_MASK).or((initialInc) ? INCREMENT : Word.zero());
    VM.objectModel.writeAvailableBitsWord(object, initialValue);
}
Also used : Word(org.vmmagic.unboxed.Word) Inline(org.vmmagic.pragma.Inline)

Example 43 with Inline

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

the class RCHeader method initRC.

/**
 * Initialize the reference count of an object.  Return either
 * <code>INC_OLD</code> if the object is not new,
 * <code>INC_NEW</code> if the object is new.
 *
 * @param object The object whose RC is to be initialized.
 * @return <code>INC_OLD</code> if the object is not new,
 * <code>INC_NEW</code> if the object is new.
 */
@Inline
public static int initRC(ObjectReference object) {
    Word oldValue, newValue;
    int rtn;
    if (VM.VERIFY_ASSERTIONS)
        VM.assertions._assert(RCBase.isRCObject(object));
    do {
        oldValue = VM.objectModel.prepareAvailableBits(object);
        newValue = oldValue.and(WRITE_MASK).or(INCREMENT);
        if (RCBase.BUILD_FOR_GENRC) {
            rtn = INC_OLD;
        } else {
            if (isHeaderNew(oldValue)) {
                newValue = newValue.or(NEW_BIT_MASK);
                rtn = INC_NEW;
            } else {
                rtn = INC_OLD;
            }
        }
    } while (!VM.objectModel.attemptAvailableBits(object, oldValue, newValue));
    return rtn;
}
Also used : Word(org.vmmagic.unboxed.Word) Inline(org.vmmagic.pragma.Inline)

Example 44 with Inline

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

the class RCHeader method makeLogged.

/**
 * Signify completion of logging <code>object</code>.
 *
 * <code>object</code> is left in the <code>LOGGED</code> state.
 *
 * @see #attemptToLog(ObjectReference)
 * @param object The object whose state is to be changed.
 */
@Inline
@Uninterruptible
public static void makeLogged(ObjectReference object) {
    Word value = VM.objectModel.readAvailableBitsWord(object);
    if (VM.VERIFY_ASSERTIONS)
        VM.assertions._assert(value.and(LOGGING_MASK).NE(LOGGED));
    VM.objectModel.writeAvailableBitsWord(object, value.and(LOGGING_MASK.not()));
}
Also used : Word(org.vmmagic.unboxed.Word) Uninterruptible(org.vmmagic.pragma.Uninterruptible) Inline(org.vmmagic.pragma.Inline)

Example 45 with Inline

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

the class RCHeader method decRC.

/**
 * Decrement the reference count of an object.  Return either
 * <code>DEC_KILL</code> if the count went to zero,
 * <code>DEC_ALIVE</code> if the count did not go to zero.
 *
 * @param object The object whose RC is to be decremented.
 * @return <code>DEC_KILL</code> if the count went to zero,
 * <code>DEC_ALIVE</code> if the count did not go to zero.
 */
@Inline
@Uninterruptible
public static int decRC(ObjectReference object) {
    Word oldValue, newValue;
    int rtn;
    if (VM.VERIFY_ASSERTIONS) {
        VM.assertions._assert(RCBase.isRCObject(object));
        VM.assertions._assert(isLiveRC(object));
    }
    do {
        oldValue = VM.objectModel.prepareAvailableBits(object);
        if (isStuck(oldValue))
            return DEC_ALIVE;
        newValue = oldValue.minus(INCREMENT);
        if (newValue.and(READ_MASK).LT(LIVE_THRESHOLD)) {
            rtn = DEC_KILL;
        } else {
            rtn = DEC_ALIVE;
        }
    } while (!VM.objectModel.attemptAvailableBits(object, oldValue, newValue));
    return rtn;
}
Also used : Word(org.vmmagic.unboxed.Word) Uninterruptible(org.vmmagic.pragma.Uninterruptible) Inline(org.vmmagic.pragma.Inline)

Aggregations

Inline (org.vmmagic.pragma.Inline)110 NoInline (org.vmmagic.pragma.NoInline)42 Entrypoint (org.vmmagic.pragma.Entrypoint)40 Offset (org.vmmagic.unboxed.Offset)38 ObjectReference (org.vmmagic.unboxed.ObjectReference)35 Address (org.vmmagic.unboxed.Address)15 Word (org.vmmagic.unboxed.Word)15 TypeReference (org.jikesrvm.classloader.TypeReference)12 Uninterruptible (org.vmmagic.pragma.Uninterruptible)6 RVMType (org.jikesrvm.classloader.RVMType)5 RVMClass (org.jikesrvm.classloader.RVMClass)4 Unpreemptible (org.vmmagic.pragma.Unpreemptible)4 RVMClassLoader (org.jikesrvm.classloader.RVMClassLoader)3 TIB (org.jikesrvm.objectmodel.TIB)3 Extent (org.vmmagic.unboxed.Extent)3 MethodReference (org.jikesrvm.classloader.MethodReference)2 ForwardReference (org.jikesrvm.compilers.common.assembler.ForwardReference)2 RVMThread (org.jikesrvm.scheduler.RVMThread)2 CollectorContext (org.mmtk.plan.CollectorContext)2 NoNullCheck (org.vmmagic.pragma.NoNullCheck)2