use of org.vmmagic.unboxed.ObjectReference in project JikesRVM by JikesRVM.
the class ScanThread method checkReference.
/**
* Check that a reference encountered during scanning is valid. If
* the reference is invalid, dump stack and die.
*
* @param refaddr The address of the reference in question.
*/
private static void checkReference(Address refaddr) {
ObjectReference ref = refaddr.loadObjectReference();
if (!MemoryManager.validRef(ref)) {
Log.writeln();
Log.writeln("Invalid ref reported while scanning stack");
Log.write(refaddr);
Log.write(":");
Log.flush();
MemoryManager.dumpRef(ref);
Log.writeln();
Log.writeln("Dumping stack:");
RVMThread.dumpStack();
VM.sysFail("\n\nScanStack: Detected bad GC map; exiting RVM with fatal error");
}
}
use of org.vmmagic.unboxed.ObjectReference in project JikesRVM by JikesRVM.
the class FinalizableProcessor method scan.
/**
* {@inheritDoc} Calls ReferenceProcessor's
* processReference method for each reference and builds a new
* list of those references still active.
* <p>
* Depending on the value of <code>nursery</code>, we will either
* scan all references, or just those created since the last scan.
* <p>
* TODO parallelise this code
*
* @param nursery Scan only the newly created references
*/
@Override
@UninterruptibleNoWarn
public void scan(TraceLocal trace, boolean nursery) {
int toIndex = nursery ? nurseryIndex : 0;
for (int fromIndex = toIndex; fromIndex < maxIndex; fromIndex++) {
ObjectReference ref = table.get(fromIndex).toObjectReference();
/* Determine liveness (and forward if necessary) */
if (trace.isLive(ref)) {
table.set(toIndex++, trace.getForwardedFinalizable(ref).toAddress());
continue;
}
/* Make ready for finalize */
ref = trace.retainForFinalize(ref);
/* Add to object table */
Offset offset = Word.fromIntZeroExtend(lastReadyIndex).lsh(LOG_BYTES_IN_ADDRESS).toOffset();
Selected.Plan.get().storeObjectReference(Magic.objectAsAddress(readyForFinalize).plus(offset), ref);
lastReadyIndex = (lastReadyIndex + 1) % readyForFinalize.length;
}
nurseryIndex = maxIndex = toIndex;
/* Possible schedule finalizers to run */
Collection.scheduleFinalizerThread();
}
use of org.vmmagic.unboxed.ObjectReference in project JikesRVM by JikesRVM.
the class Mutator method loadReferenceField.
/**
* Load and return the value of a reference field of an object.
*
* @param object The object to load the field of.
* @param index The field index.
* @return The object reference
*/
public ObjectReference loadReferenceField(ObjectReference object, int index) {
Clock.stop();
if (object.isNull())
fail(("Object can not be null in object " + ObjectModel.getString(object)));
Sanity.assertValid(object);
int limit = ObjectModel.getRefs(object);
if (!(index >= 0))
fail(("Index must be non-negative in object " + ObjectModel.getString(object)));
if (!(index < limit))
fail(("Index " + index + " out of bounds " + limit + " in object " + ObjectModel.getString(object)));
Address referenceSlot = ObjectModel.getRefSlot(object, index);
ObjectReference result;
Clock.start();
if (ActivePlan.constraints.needsObjectReferenceReadBarrier()) {
result = context.objectReferenceRead(object, referenceSlot, referenceSlot.toWord(), null, INSTANCE_FIELD);
} else {
result = referenceSlot.loadObjectReference();
}
Clock.stop();
Sanity.assertValid(object);
if (Trace.isEnabled(Item.LOAD) || ObjectModel.isWatched(object)) {
Trace.printf(Item.LOAD, "[%s].object[%d] returned [%s]%n", ObjectModel.getString(object), index, result.toString());
}
Clock.start();
return result;
}
use of org.vmmagic.unboxed.ObjectReference in project JikesRVM by JikesRVM.
the class Mutator method getReferenceStackSlot.
public ObjectReference getReferenceStackSlot(Address slot) {
ObjectReference ref = slot.loadObjectReference();
Clock.stop();
Sanity.assertValid(ref);
Clock.start();
return ref;
}
use of org.vmmagic.unboxed.ObjectReference in project JikesRVM by JikesRVM.
the class Mutator method dumpHeap.
/**
* Print the thread roots and add them to a stack for processing.
*/
public static void dumpHeap() {
int width = 80;
Deque<ObjectReference> workStack = new ArrayDeque<ObjectReference>();
Set<ObjectReference> dumped = new HashSet<ObjectReference>();
for (Mutator m : Mutators.getAll()) {
System.err.println("Mutator " + m.context.getId());
workStack.addAll(m.dumpThreadRoots(width));
}
System.err.println("Heap (Depth First)");
while (!workStack.isEmpty()) {
ObjectReference object = workStack.pop();
if (!dumped.contains(object)) {
dumped.add(object);
workStack.addAll(ObjectModel.dumpLogicalObject(width, object));
}
}
}
Aggregations