use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.
the class BaselineExceptionDeliverer method unwindStackFrame.
/**
* Unwind a stackframe.
*/
@Override
@Unpreemptible("Unwind stack possibly from unpreemptible code")
public void unwindStackFrame(CompiledMethod compiledMethod, AbstractRegisters registers) {
NormalMethod method = (NormalMethod) compiledMethod.getMethod();
Address fp = registers.getInnermostFramePointer();
if (method.isSynchronized()) {
// release the lock, if it is being held
Address ip = registers.getInnermostInstructionAddress();
Offset instr = compiledMethod.getInstructionOffset(ip);
Offset lockOffset = ((ArchBaselineCompiledMethod) compiledMethod).getLockAcquisitionOffset();
if (instr.sGT(lockOffset)) {
// we actually have the lock, so must unlock it.
Object lock;
if (method.isStatic()) {
lock = method.getDeclaringClass().getResolvedClassForType();
} else {
lock = Magic.addressAsObject(fp.plus(BaselineCompilerImpl.locationToOffset(((ArchBaselineCompiledMethod) compiledMethod).getGeneralLocalLocation(0)) - BYTES_IN_ADDRESS).loadAddress());
}
if (ObjectModel.holdsLock(lock, RVMThread.getCurrentThread())) {
ObjectModel.genericUnlock(lock);
}
}
}
// Restore nonvolatile registers used by the baseline compiler.
if (VM.VerifyAssertions)
VM._assert(SAVED_GPRS == 2);
registers.getGPRs().set(EDI.value(), fp.plus(EDI_SAVE_OFFSET).loadWord());
registers.getGPRs().set(EBX.value(), fp.plus(EBX_SAVE_OFFSET).loadWord());
if (method.hasBaselineSaveLSRegistersAnnotation()) {
registers.getGPRs().set(EBP.value(), fp.plus(EBP_SAVE_OFFSET).toWord());
}
registers.unwindStackFrame();
}
use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.
the class BaselineGCMapIterator method setupIterator.
/*
* Interface
*/
/**
* Set the iterator to scan the map at the machine instruction offset
* provided. The iterator is positioned to the beginning of the map. NOTE: An
* iterator may be reused to scan a different method and map.
*
* @param compiledMethod
* identifies the method and class
* @param instructionOffset
* identifies the map to be scanned.
* @param fp
* identifies a specific occurrence of this method and allows for
* processing instance specific information i.e JSR return address
* values
*/
@Override
public void setupIterator(CompiledMethod compiledMethod, Offset instructionOffset, Address fp) {
currentCompiledMethod = (ArchBaselineCompiledMethod) compiledMethod;
currentMethod = (NormalMethod) currentCompiledMethod.getMethod();
currentNumLocals = currentMethod.getLocalWords();
// setup superclass
//
framePtr = fp;
// setup stackframe mapping
//
mapReader.setMethod(currentMethod, compiledMethod);
mapReader.locateGCPoint(instructionOffset);
if (mapReader.currentMapIsForJSR()) {
mapReader.acquireLockForJSRProcessing();
int JSRindex = mapReader.setupJSRSubroutineMap();
while (JSRindex != 0) {
Address nextCallerAddress = framePtr.plus(convertIndexToOffset(JSRindex)).loadAddress();
Offset nextMachineCodeOffset = compiledMethod.getInstructionOffset(nextCallerAddress);
if (VM.TraceStkMaps) {
traceSetupJSRsubroutineMap(JSRindex, nextCallerAddress, nextMachineCodeOffset);
}
JSRindex = mapReader.getNextJSRAddressIndex(nextMachineCodeOffset);
}
}
if (VM.TraceStkMaps || TRACE_ALL) {
VM.sysWrite("BaselineGCMapIterator setupIterator mapId = ");
VM.sysWrite(mapReader.getMapId());
VM.sysWrite(" for ");
VM.sysWrite(compiledMethod.getMethod());
VM.sysWriteln(".");
}
bridgeData.setupDynamicBridgeMapping(currentMethod, fp);
reset();
}
use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.
the class ArchBridgeDataExtractor method setupArchitectureSpecificDynamicBridgeMapping.
@Override
protected void setupArchitectureSpecificDynamicBridgeMapping(Address fp) {
fp = Magic.getCallerFramePointer(fp);
Address ip = Magic.getNextInstructionAddress(fp);
int callingCompiledMethodId = Magic.getCompiledMethodID(fp);
CompiledMethod callingCompiledMethod = CompiledMethods.getCompiledMethod(callingCompiledMethodId);
Offset callingInstructionOffset = callingCompiledMethod.getInstructionOffset(ip);
updateWithInfoForDynamicLink(callingCompiledMethod, callingInstructionOffset);
}
use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.
the class OptGenericGCMapIterator method checkRegistersForMissedReferences.
/**
* This method inspects the registers from firstReg to lastReg (inclusive)
* for values that look like pointers.
* @param firstReg first reg to check
* @param lastReg last reg to check
*/
final void checkRegistersForMissedReferences(int firstReg, int lastReg) {
for (int i = firstReg; i <= lastReg; i++) {
Address regLocation = registerLocations.get(i);
Address regValue = regLocation.loadAddress();
if (MemoryManager.addressInVM(regValue)) {
VM.sysWrite(" reg#", getCurrentRegister());
VM.sysWrite(", location ==>", regLocation);
VM.sysWriteln(", suspicious value ==>", regValue);
}
}
}
use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.
the class OptGenericGCMapIterator method setupIterator.
/**
* Initialize the iterator for another stack frame scan
* @param cm The compiled method we are interested in
* @param instructionOffset The place in the method where we currently are
* @param framePtr The current frame pointer
*/
@Override
public final void setupIterator(CompiledMethod cm, Offset instructionOffset, Address framePtr) {
if (DEBUG) {
VM.sysWriteln();
VM.sysWrite("\t ==========================");
VM.sysWriteln();
VM.sysWrite("Reference map request made");
VM.sysWrite(" for machine code offset: ");
VM.sysWrite(instructionOffset);
VM.sysWriteln();
VM.sysWrite("\tframePtr: ");
VM.sysWrite(framePtr);
VM.sysWriteln();
}
reset();
// retrieve and save the corresponding OptMachineCodeMap for
// this method and instructionOffset
compiledMethod = (OptCompiledMethod) cm;
map = compiledMethod.getMCMap();
mapIndex = map.findGCMapIndex(instructionOffset);
if (mapIndex == OptGCMap.ERROR) {
if (instructionOffset.sLT(Offset.zero())) {
VM.sysWriteln("OptGenericGCMapIterator.setupIterator called with negative instructionOffset", instructionOffset);
} else {
Offset possibleLen = Offset.fromIntZeroExtend(cm.numberOfInstructions() << ArchConstants.getLogInstructionWidth());
if (possibleLen.sLT(instructionOffset)) {
VM.sysWriteln("OptGenericGCMapIterator.setupIterator called with too big of an instructionOffset");
VM.sysWriteln("offset is", instructionOffset);
VM.sysWriteln(" bytes of machine code for method ", possibleLen);
} else {
VM.sysWriteln("OptGenericGCMapIterator.setupIterator called with apparently valid offset, but no GC map found!");
VM.sysWrite("Method: ");
VM.sysWrite(compiledMethod.getMethod());
VM.sysWrite(", Machine Code (MC) Offset: ");
VM.sysWriteln(instructionOffset);
VM.sysFail("OptGenericMapIterator: findGCMapIndex failed\n");
}
}
VM.sysWrite("Supposed method: ");
VM.sysWrite(compiledMethod.getMethod());
VM.sysWriteln();
VM.sysWriteln("Base of its code array", Magic.objectAsAddress(cm.getEntryCodeArray()));
Address ra = cm.getInstructionAddress(instructionOffset);
VM.sysWriteln("Calculated actual return address is ", ra);
CompiledMethod realCM = CompiledMethods.findMethodForInstruction(ra);
if (realCM == null) {
VM.sysWriteln("Unable to find compiled method corresponding to this return address");
} else {
VM.sysWrite("Found compiled method ");
VM.sysWrite(realCM.getMethod());
VM.sysWriteln(" whose code contains this return address");
}
VM.sysFail("OptGenericMapIterator: setupIterator failed\n");
}
// save the frame pointer
this.framePtr = framePtr;
if (DEBUG) {
VM.sysWrite("\tMethod: ");
VM.sysWrite(compiledMethod.getMethod());
VM.sysWriteln();
if (mapIndex == OptGCMap.NO_MAP_ENTRY) {
VM.sysWriteln("... empty map found");
} else {
VM.sysWriteln("... found a map");
}
if (lookForMissedReferencesInSpills) {
VM.sysWrite("FramePtr: ");
VM.sysWrite(framePtr);
VM.sysWrite("\tFirst Spill: ");
VM.sysWrite(getFirstSpillLoc());
VM.sysWrite("\tLast Spill: ");
VM.sysWrite(getLastSpillLoc());
VM.sysWriteln();
}
}
}
Aggregations