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;
}
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));
}
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;
}
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();
}
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());
}
Aggregations