Search in sources :

Example 46 with ObjectReference

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");
    }
}
Also used : ObjectReference(org.vmmagic.unboxed.ObjectReference)

Example 47 with ObjectReference

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();
}
Also used : ObjectReference(org.vmmagic.unboxed.ObjectReference) Offset(org.vmmagic.unboxed.Offset) UninterruptibleNoWarn(org.vmmagic.pragma.UninterruptibleNoWarn)

Example 48 with ObjectReference

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;
}
Also used : Address(org.vmmagic.unboxed.Address) ObjectReference(org.vmmagic.unboxed.ObjectReference)

Example 49 with ObjectReference

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;
}
Also used : ObjectReference(org.vmmagic.unboxed.ObjectReference)

Example 50 with ObjectReference

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));
        }
    }
}
Also used : ObjectReference(org.vmmagic.unboxed.ObjectReference) ArrayDeque(java.util.ArrayDeque) HashSet(java.util.HashSet)

Aggregations

ObjectReference (org.vmmagic.unboxed.ObjectReference)74 Inline (org.vmmagic.pragma.Inline)35 Entrypoint (org.vmmagic.pragma.Entrypoint)33 Offset (org.vmmagic.unboxed.Offset)21 Address (org.vmmagic.unboxed.Address)12 StackFrame (org.mmtk.harness.lang.runtime.StackFrame)5 RVMType (org.jikesrvm.classloader.RVMType)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 OutOfMemory (org.mmtk.harness.exception.OutOfMemory)2 ObjectValue (org.mmtk.harness.lang.runtime.ObjectValue)2 CollectorContext (org.mmtk.plan.CollectorContext)2 Uninterruptible (org.vmmagic.pragma.Uninterruptible)2 ArrayDeque (java.util.ArrayDeque)1 HashSet (java.util.HashSet)1 AbstractRegisters (org.jikesrvm.architecture.AbstractRegisters)1 RVMMethod (org.jikesrvm.classloader.RVMMethod)1 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)1 TIB (org.jikesrvm.objectmodel.TIB)1 NoInline (org.vmmagic.pragma.NoInline)1