Search in sources :

Example 11 with Word

use of org.vmmagic.unboxed.Word 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 12 with Word

use of org.vmmagic.unboxed.Word 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 13 with Word

use of org.vmmagic.unboxed.Word 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 14 with Word

use of org.vmmagic.unboxed.Word 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 15 with Word

use of org.vmmagic.unboxed.Word 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

Word (org.vmmagic.unboxed.Word)62 Inline (org.vmmagic.pragma.Inline)15 Address (org.vmmagic.unboxed.Address)14 NoInline (org.vmmagic.pragma.NoInline)11 Offset (org.vmmagic.unboxed.Offset)10 AddressConstantOperand (org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand)8 BranchProfileOperand (org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)8 CodeConstantOperand (org.jikesrvm.compilers.opt.ir.operand.CodeConstantOperand)8 ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ConditionOperand)8 ConstantOperand (org.jikesrvm.compilers.opt.ir.operand.ConstantOperand)8 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)8 LongConstantOperand (org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand)8 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)8 NullConstantOperand (org.jikesrvm.compilers.opt.ir.operand.NullConstantOperand)8 ObjectConstantOperand (org.jikesrvm.compilers.opt.ir.operand.ObjectConstantOperand)8 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)8 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)8 TIBConstantOperand (org.jikesrvm.compilers.opt.ir.operand.TIBConstantOperand)8 TrapCodeOperand (org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand)8 TrueGuardOperand (org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand)8