Search in sources :

Example 36 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.
 * @param verbosity The level of verbosity to be used when
 * performing the scan.
 */
private void checkReference(Address refaddr, int verbosity) {
    ObjectReference ref = refaddr.loadObjectReference();
    if (!MemoryManager.validRef(ref)) {
        Log.writeln();
        Log.writeln("Invalid ref reported while scanning stack");
        printMethodHeader();
        Log.write(refaddr);
        Log.write(":");
        Log.flush();
        MemoryManager.dumpRef(ref);
        dumpStackFrame(verbosity);
        Log.writeln();
        Log.writeln("Dumping stack starting at frame with bad ref:");
        RVMThread.dumpStack(ip, fp);
        /* dump stack starting at top */
        Address top_ip = thread.getContextRegisters().getInnermostInstructionAddress();
        Address top_fp = thread.getContextRegisters().getInnermostFramePointer();
        RVMThread.dumpStack(top_ip, top_fp);
        Log.writeln("Failing iterators:");
        Offset offset = compiledMethod.getInstructionOffset(ip);
        iterator = iteratorGroup.selectIterator(compiledMethod);
        iterator.setupIterator(compiledMethod, offset, fp);
        int i = 0;
        for (Address addr = iterator.getNextReferenceAddress(); !addr.isZero(); addr = iterator.getNextReferenceAddress()) {
            ObjectReference ref2 = addr.loadObjectReference();
            Log.write("Iterator ");
            Log.write(i++);
            Log.write(": ");
            Log.write(addr);
            Log.write(": ");
            Log.flush();
            MemoryManager.dumpRef(ref2);
        }
        VM.sysFail("\n\nScanStack: Detected bad GC map; exiting RVM with fatal error");
    }
}
Also used : Address(org.vmmagic.unboxed.Address) ObjectReference(org.vmmagic.unboxed.ObjectReference) Offset(org.vmmagic.unboxed.Offset)

Example 37 with ObjectReference

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

the class ScanThread method getHWExceptionRegisters.

/**
 * When an exception occurs, registers are saved temporarily.  If
 * the stack being scanned is in this state, we need to scan those
 * registers for code pointers.  If the codeLocations deque is null,
 * then scanning for code pointers is not required, so we don't need
 * to do anything. (SB: Why only code pointers?).
 * <p>
 * Dave G:  The contents of the GPRs of the exceptionRegisters
 * are handled during normal stack scanning
 * (@see org.jikesrvm.runtime.compilers.common.HardwareTrapCompiledMethod.
 * It looks to me like the main goal of this method is to ensure that the
 * method in which the trap happened isn't treated as dead code and collected
 * (if it's been marked as obsolete, we are setting its activeOnStackFlag below).
 */
private void getHWExceptionRegisters() {
    AbstractRegisters exReg = thread.getExceptionRegisters();
    if (processCodeLocations && exReg.getInUse()) {
        Address ip = exReg.getIP();
        CompiledMethod compiledMethod = CompiledMethods.findMethodForInstruction(ip);
        if (VM.VerifyAssertions) {
            VM._assert(compiledMethod != null);
            VM._assert(compiledMethod.containsReturnAddress(ip));
        }
        compiledMethod.setActiveOnStack();
        ObjectReference code = ObjectReference.fromObject(compiledMethod.getEntryCodeArray());
        Address ipLoc = exReg.getIPLocation();
        if (VM.VerifyAssertions)
            VM._assert(ip.EQ(ipLoc.loadAddress()));
        processCodeLocation(code, ipLoc);
    }
}
Also used : Address(org.vmmagic.unboxed.Address) ObjectReference(org.vmmagic.unboxed.ObjectReference) AbstractRegisters(org.jikesrvm.architecture.AbstractRegisters) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod)

Example 38 with ObjectReference

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

the class Mutator method alloc.

/**
 * Allocate an object and return a reference to it.
 *
 * @param refCount The number of reference fields.
 * @param dataCount The number of data fields.
 * @param doubleAlign Is this an 8 byte aligned object?
 * @param allocSite Allocation site
 * @return The object reference.
 */
public ObjectReference alloc(int refCount, int dataCount, boolean doubleAlign, int allocSite) {
    if (!(refCount >= 0))
        fail("Non-negative reference field count required");
    if (!(refCount <= ObjectModel.MAX_REF_FIELDS))
        fail(("Maximum of " + ObjectModel.MAX_REF_FIELDS + " reference fields per object"));
    if (!(dataCount >= 0))
        fail("Non-negative data field count required");
    if (!(dataCount <= ObjectModel.MAX_DATA_FIELDS))
        fail(("Maximum of " + ObjectModel.MAX_DATA_FIELDS + " data fields per object"));
    ObjectReference result = ObjectModel.allocateObject(context, refCount, dataCount, doubleAlign, allocSite);
    if (Trace.isEnabled(Item.ALLOC) || ObjectModel.isWatched(result)) {
        Clock.stop();
        Trace.printf(Item.ALLOC, "alloc(%d,%d,%b) -> [%s]%n", refCount, dataCount, doubleAlign, ObjectModel.getString(result));
        Clock.start();
    }
    if (result == null || result.isNull())
        fail("Allocation returned null");
    return result;
}
Also used : ObjectReference(org.vmmagic.unboxed.ObjectReference)

Example 39 with ObjectReference

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

the class FinalizableProcessor method forward.

/**
 * {@inheritDoc}.
 * <p>
 * Currently ignores the nursery hint.
 * <p>
 * TODO parallelise this code?
 *
 * @param trace The trace
 * @param nursery Is this a nursery collection ?
 */
@Override
public void forward(TraceLocal trace, boolean nursery) {
    for (int i = 0; i < maxIndex; i++) {
        ObjectReference ref = table.get(i).toObjectReference();
        table.set(i, trace.getForwardedFinalizable(ref).toAddress());
    }
}
Also used : ObjectReference(org.vmmagic.unboxed.ObjectReference)

Example 40 with ObjectReference

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

the class AllocUserOp method exec.

@Override
public void exec(Env env) {
    StackFrame frame = env.top();
    ObjectReference object;
    try {
        object = env.alloc(refCount, dataCount, getDoubleAlign(frame), site);
    } catch (OutOfMemory e) {
        throw e;
    } catch (Exception e) {
        throw new RuntimeException("Error allocating object id:" + ObjectModel.lastObjectId() + " refs:" + refCount + " ints: " + dataCount + " align:" + getDoubleAlign(frame) + " site:" + site, e);
    }
    setResult(frame, new ObjectValue(object));
    if (Harness.gcEveryAlloc()) {
        env.gc();
    }
}
Also used : OutOfMemory(org.mmtk.harness.exception.OutOfMemory) ObjectValue(org.mmtk.harness.lang.runtime.ObjectValue) ObjectReference(org.vmmagic.unboxed.ObjectReference) StackFrame(org.mmtk.harness.lang.runtime.StackFrame)

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