Search in sources :

Example 41 with Word

use of org.vmmagic.unboxed.Word in project JikesRVM by JikesRVM.

the class RCHeader method remainRC.

/**
 * Retain 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 retained.
 * @return <code>INC_OLD</code> if the object is not new,
 * <code>INC_NEW</code> if the object is new.
 */
@Inline
public static int remainRC(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;
        if (RCBase.BUILD_FOR_GENRC) {
            return INC_OLD;
        } else {
            if (isHeaderNew(oldValue)) {
                newValue = newValue.or(NEW_BIT_MASK);
                rtn = INC_NEW;
            } else {
                return INC_OLD;
            }
        }
    } while (!VM.objectModel.attemptAvailableBits(object, oldValue, newValue));
    return rtn;
}
Also used : Word(org.vmmagic.unboxed.Word) Inline(org.vmmagic.pragma.Inline)

Example 42 with Word

use of org.vmmagic.unboxed.Word in project JikesRVM by JikesRVM.

the class RCHeader method clearMarked.

/**
 * Clears the mark status for the given object.
 * @param object the object whose status will be cleared
 */
@Inline
public static void clearMarked(ObjectReference object) {
    Word oldValue, newValue;
    do {
        oldValue = VM.objectModel.prepareAvailableBits(object);
        if (VM.VERIFY_ASSERTIONS)
            VM.assertions._assert(isHeaderMarked(oldValue));
        newValue = oldValue.and(MARK_BIT_MASK.not());
    } while (!VM.objectModel.attemptAvailableBits(object, oldValue, newValue));
}
Also used : Word(org.vmmagic.unboxed.Word) Inline(org.vmmagic.pragma.Inline)

Example 43 with Word

use of org.vmmagic.unboxed.Word in project JikesRVM by JikesRVM.

the class RCHeader method incRC.

/**
 * Increment 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 incremented.
 * @return <code>INC_OLD</code> if the object is not new,
 * <code>INC_NEW</code> if the object is new.
 */
@Inline
public static int incRC(ObjectReference object) {
    Word oldValue, newValue;
    int rtn;
    if (VM.VERIFY_ASSERTIONS)
        VM.assertions._assert(RCBase.isRCObject(object));
    do {
        oldValue = VM.objectModel.prepareAvailableBits(object);
        if (isStuck(oldValue))
            return INC_OLD;
        if (RCBase.BUILD_FOR_GENRC) {
            newValue = oldValue.plus(INCREMENT);
            rtn = INC_OLD;
        } else {
            if (isHeaderNew(oldValue)) {
                newValue = oldValue.plus(DOUBLE_INCREMENT);
                newValue = newValue.or(NEW_BIT_MASK);
                rtn = INC_NEW;
            } else {
                newValue = oldValue.plus(INCREMENT);
                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 Word

use of org.vmmagic.unboxed.Word in project JikesRVM by JikesRVM.

the class FragmentedMmapper method hash.

/**
 * Hash an address down to a slab table index.  First cut: mask off the intra-slab
 * bits, divide the high order bits into LOG_SLAB_TABLE_SIZE pieces and XOR them
 * together.
 * @param addr Address to hash
 * @return A hash code in the range 0..2^LOG_SLAB_TABLE_SIZE
 */
static int hash(Address addr) {
    Word initial = addr.toWord().and(MMAP_SLAB_MASK.not()).rshl(LOG_MMAP_SLAB_BYTES);
    Word hash = Word.zero();
    while (!initial.isZero()) {
        hash = hash.xor(initial.and(HASH_MASK));
        initial = initial.rshl(LOG_SLAB_TABLE_SIZE);
    }
    return hash.toInt();
}
Also used : Word(org.vmmagic.unboxed.Word)

Example 45 with Word

use of org.vmmagic.unboxed.Word in project JikesRVM by JikesRVM.

the class BaselineGCMapIteratorTest method getNextReferenceAddressReturnsCorrectReferenceIfReferencesArePresent.

@Test
public void getNextReferenceAddressReturnsCorrectReferenceIfReferencesArePresent() throws Exception {
    NormalMethod nm = TestingTools.getNormalMethod(MethodsForTests.class, "emptyStaticMethodWithObjectParam", Object.class);
    CompiledMethod cm = nm.getCurrentCompiledMethod();
    // Fake a stack frame
    int stackWords = 5;
    WordArray wa = createNonMovableWordArray(stackWords);
    for (int i = 0; i < wa.length(); i++) {
        wa.set(i, Word.fromIntSignExtend(5 * i));
    }
    int targetSlot = wa.length() - 1;
    Address fp = Magic.objectAsAddress(wa).plus(targetSlot * BYTES_IN_WORD);
    // local 0 is reference.
    // +/- 0 words: FP
    // - 1 words: CMID
    // - 2 words: saved GPRs (EDI)
    // - 3 words: saved GPRs (EBX)
    // - 4 words: local0 == reference
    Address targetAddress = fp.minus(4 * BYTES_IN_STACKSLOT);
    Word targetContents = targetAddress.loadWord();
    gcMapIter.setupIterator(cm, Offset.fromIntZeroExtend(cm.getEntryCodeArray().length()), fp);
    Address referenceAddr = gcMapIter.getNextReferenceAddress();
    assertEquals(targetAddress, referenceAddr);
    assertEquals(targetContents, referenceAddr.loadWord());
}
Also used : Word(org.vmmagic.unboxed.Word) Address(org.vmmagic.unboxed.Address) NormalMethod(org.jikesrvm.classloader.NormalMethod) WordArray(org.vmmagic.unboxed.WordArray) TestingTools.createNonMovableWordArray(org.jikesrvm.tests.util.TestingTools.createNonMovableWordArray) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) Test(org.junit.Test)

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