use of org.vmmagic.unboxed.ObjectReference in project JikesRVM by JikesRVM.
the class MemoryManager method modifyCheck.
/**
*********************************************************************
*
* Write barriers
*/
/**
* Checks that if a garbage collection is in progress then the given
* object is not movable. If it is movable error messages are
* logged and the system exits.
*
* @param object the object to check
*/
@Entrypoint
public static void modifyCheck(Object object) {
/* Make sure that during GC, we don't update on a possibly moving object.
Such updates are dangerous because they can be lost.
*/
if (Plan.gcInProgressProper()) {
ObjectReference ref = ObjectReference.fromObject(object);
if (Space.isMovable(ref)) {
VM.sysWriteln("GC modifying a potentially moving object via Java (i.e. not magic)");
VM.sysWriteln(" obj = ", ref);
RVMType t = Magic.getObjectType(object);
VM.sysWrite(" type = ");
VM.sysWriteln(t.getDescriptor());
VM.sysFail("GC modifying a potentially moving object via Java (i.e. not magic)");
}
}
}
use of org.vmmagic.unboxed.ObjectReference in project JikesRVM by JikesRVM.
the class SpecializedScanMethod method fallback.
public static void fallback(Object object, TransitiveClosure trace) {
ObjectReference objectRef = ObjectReference.fromObject(object);
RVMType type = ObjectModel.getObjectType(objectRef.toObject());
int[] offsets = type.getReferenceOffsets();
if (offsets != REFARRAY_OFFSET_ARRAY) {
if (VM.VerifyAssertions)
VM._assert(type.isClassType() || (type.isArrayType() && !type.asArray().getElementType().isReferenceType()));
for (int i = 0; i < offsets.length; i++) {
trace.processEdge(objectRef, objectRef.toAddress().plus(offsets[i]));
}
} else {
if (VM.VerifyAssertions)
VM._assert(type.isArrayType() && type.asArray().getElementType().isReferenceType());
for (int i = 0; i < ObjectModel.getArrayLength(objectRef.toObject()); i++) {
trace.processEdge(objectRef, objectRef.toAddress().plus(i << LOG_BYTES_IN_ADDRESS));
}
}
}
use of org.vmmagic.unboxed.ObjectReference in project JikesRVM by JikesRVM.
the class RCBaseCollector method collectionPhase.
@Override
public void collectionPhase(short phaseId, boolean primary) {
if (phaseId == RCBase.PREPARE) {
getRootTrace().prepare();
if (RCBase.CC_BACKUP_TRACE && RCBase.performCycleCollection)
backupTrace.prepare();
return;
}
if (phaseId == RCBase.ROOTS) {
VM.scanning.computeGlobalRoots(getCurrentTrace());
VM.scanning.computeStaticRoots(getCurrentTrace());
if (Plan.SCAN_BOOT_IMAGE && RCBase.CC_BACKUP_TRACE && RCBase.performCycleCollection) {
VM.scanning.computeBootImageRoots(getCurrentTrace());
}
return;
}
if (phaseId == RCBase.CLOSURE) {
getRootTrace().completeTrace();
newRootBuffer.flushLocal();
return;
}
if (phaseId == RCBase.BT_CLOSURE) {
if (RCBase.CC_BACKUP_TRACE && RCBase.performCycleCollection) {
backupTrace.completeTrace();
}
return;
}
if (phaseId == RCBase.PROCESS_OLDROOTBUFFER) {
if (RCBase.CC_BACKUP_TRACE && RCBase.performCycleCollection)
return;
ObjectReference current;
while ((!(current = oldRootBuffer.pop()).isNull())) {
decBuffer.push(current);
}
return;
}
if (phaseId == RCBase.PROCESS_NEWROOTBUFFER) {
ObjectReference current;
if (RCBase.CC_BACKUP_TRACE && RCBase.performCycleCollection) {
while (!(current = newRootBuffer.pop()).isNull()) {
if (RCHeader.testAndMark(current)) {
if (RCBase.BUILD_FOR_GENRC) {
RCHeader.initRC(current);
} else {
if (RCHeader.initRC(current) == RCHeader.INC_NEW) {
modBuffer.push(current);
}
}
backupTrace.processNode(current);
} else {
if (RCBase.BUILD_FOR_GENRC) {
RCHeader.incRC(current);
} else {
if (RCHeader.incRC(current) == RCHeader.INC_NEW) {
modBuffer.push(current);
}
}
}
}
if (!RCBase.BUILD_FOR_GENRC)
modBuffer.flushLocal();
return;
}
while (!(current = newRootBuffer.pop()).isNull()) {
if (RCBase.BUILD_FOR_GENRC) {
RCHeader.incRC(current);
} else {
if (RCHeader.incRC(current) == RCHeader.INC_NEW) {
modBuffer.push(current);
}
}
oldRootBuffer.push(current);
}
oldRootBuffer.flushLocal();
if (!RCBase.BUILD_FOR_GENRC)
modBuffer.flushLocal();
return;
}
if (phaseId == RCBase.PROCESS_MODBUFFER) {
ObjectReference current;
while (!(current = modBuffer.pop()).isNull()) {
RCHeader.makeUnlogged(current);
if (!RCBase.BUILD_FOR_GENRC) {
if (Space.isInSpace(RCBase.REF_COUNT, current)) {
ExplicitFreeListSpace.testAndSetLiveBit(current);
}
}
VM.scanning.scanObject(getModifiedProcessor(), current);
}
return;
}
if (phaseId == RCBase.PROCESS_DECBUFFER) {
ObjectReference current;
if (RCBase.CC_BACKUP_TRACE && RCBase.performCycleCollection) {
if (!RCBase.BUILD_FOR_GENRC) {
while (!(current = decBuffer.pop()).isNull()) {
if (RCHeader.isNew(current)) {
if (Space.isInSpace(RCBase.REF_COUNT, current)) {
RCBase.rcSpace.free(current);
} else if (Space.isInSpace(RCBase.REF_COUNT_LOS, current)) {
RCBase.rcloSpace.free(current);
} else if (Space.isInSpace(RCBase.IMMORTAL, current)) {
VM.scanning.scanObject(zero, current);
}
}
}
}
return;
}
while (!(current = decBuffer.pop()).isNull()) {
if (RCBase.BUILD_FOR_GENRC) {
if (RCHeader.decRC(current) == RCHeader.DEC_KILL) {
decBuffer.processChildren(current);
if (Space.isInSpace(RCBase.REF_COUNT, current)) {
RCBase.rcSpace.free(current);
} else if (Space.isInSpace(RCBase.REF_COUNT_LOS, current)) {
RCBase.rcloSpace.free(current);
} else if (Space.isInSpace(RCBase.IMMORTAL, current)) {
VM.scanning.scanObject(zero, current);
}
}
} else {
if (RCHeader.isNew(current)) {
if (Space.isInSpace(RCBase.REF_COUNT, current)) {
RCBase.rcSpace.free(current);
} else if (Space.isInSpace(RCBase.REF_COUNT_LOS, current)) {
RCBase.rcloSpace.free(current);
} else if (Space.isInSpace(RCBase.IMMORTAL, current)) {
VM.scanning.scanObject(zero, current);
}
} else {
if (RCHeader.decRC(current) == RCHeader.DEC_KILL) {
decBuffer.processChildren(current);
if (Space.isInSpace(RCBase.REF_COUNT, current)) {
RCBase.rcSpace.free(current);
} else if (Space.isInSpace(RCBase.REF_COUNT_LOS, current)) {
RCBase.rcloSpace.free(current);
} else if (Space.isInSpace(RCBase.IMMORTAL, current)) {
VM.scanning.scanObject(zero, current);
}
}
}
}
}
return;
}
if (phaseId == RCBase.RELEASE) {
if (RCBase.CC_BACKUP_TRACE && RCBase.performCycleCollection) {
backupTrace.release();
global().oldRootPool.clearDeque(1);
if (RCBase.BUILD_FOR_GENRC)
global().decPool.clearDeque(1);
}
getRootTrace().release();
if (VM.VERIFY_ASSERTIONS) {
VM.assertions._assert(newRootBuffer.isEmpty());
VM.assertions._assert(modBuffer.isEmpty());
VM.assertions._assert(decBuffer.isEmpty());
}
return;
}
super.collectionPhase(phaseId, primary);
}
use of org.vmmagic.unboxed.ObjectReference in project JikesRVM by JikesRVM.
the class ForwardingWord method forwardObject.
public static ObjectReference forwardObject(ObjectReference object, int allocator) {
ObjectReference newObject = VM.objectModel.copy(object, allocator);
VM.objectModel.writeAvailableBitsWord(object, newObject.toAddress().toWord().or(Word.fromIntZeroExtend(FORWARDED)));
return newObject;
}
use of org.vmmagic.unboxed.ObjectReference in project JikesRVM by JikesRVM.
the class MarkCompactCollector method compact.
/**
* Perform the compacting phase of the collection.
*/
public void compact() {
if (regions.isZero())
return;
toCursor.init(regions);
fromCursor.init(regions);
/* Loop through active regions or until the last region */
while (fromCursor.isValid()) {
if (VERBOSE) {
Log.write("Compacting from region ", fromCursor.getRegion());
Log.writeln(" to region ", toCursor.getRegion());
}
/* Loop through the objects in the region */
while (fromCursor.hasMoreObjects()) {
ObjectReference current = fromCursor.advanceToObject();
fromCursor.advanceToObjectEnd(current);
ObjectReference copyTo = MarkCompactSpace.getForwardingPointer(current);
if (VM.VERIFY_ASSERTIONS)
VM.assertions._assert(!copyTo.toAddress().EQ(Address.fromIntZeroExtend(VM.ALIGNMENT_VALUE)));
if (!copyTo.isNull() && Space.isInSpace(MC.MARK_COMPACT, copyTo)) {
if (VM.VERIFY_ASSERTIONS) {
if (MarkCompactSpace.isMarked(current)) {
Log.write("Object ", current);
Log.writeln(" is marked during the compact phase");
VM.objectModel.dumpObject(current);
}
VM.assertions._assert(!MarkCompactSpace.isMarked(current));
}
if (!toCursor.isInRegion(copyTo)) {
// Update metadata and move on
toCursor.finishAndAdvanceToNextRegion();
}
if (VM.VERIFY_ASSERTIONS)
VM.assertions._assert(toCursor.isInRegion(copyTo));
toCursor.copy(current, copyTo);
if (VM.VERIFY_ASSERTIONS)
VM.assertions._assert(toCursor.isInRegion(copyTo));
MarkCompactSpace.setForwardingPointer(copyTo, ObjectReference.nullReference());
}
}
fromCursor.advanceToNextRegion();
}
/* Fix up the last object pointer etc */
toCursor.finish();
/*
* Return unused pages to the global page resource
*/
Address region = toCursor.snip();
while (!region.isZero()) {
Address nextRegion = MarkCompactLocal.getNextRegion(region);
space.release(region);
region = nextRegion;
}
}
Aggregations