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