use of org.vmmagic.unboxed.Offset in project JikesRVM by JikesRVM.
the class BaselineCompilerImpl method emit_resolved_getstatic.
@Override
protected void emit_resolved_getstatic(FieldReference fieldRef) {
RVMField field = fieldRef.peekResolvedField();
Offset fieldOffset = field.getOffset();
if (NEEDS_OBJECT_GETSTATIC_BARRIER && !fieldRef.getFieldContentsType().isPrimitiveType() && !field.isUntraced()) {
Barriers.compileGetstaticBarrierImm(asm, fieldOffset, fieldRef.getId());
return;
}
if (fieldRef.getSize() <= BYTES_IN_INT) {
// field is one word
if (VM.BuildFor32Addr) {
asm.emitPUSH_Abs(Magic.getTocPointer().plus(fieldOffset));
} else {
asm.generateJTOCloadInt(T0, fieldOffset);
asm.emitPUSH_Reg(T0);
}
} else {
// field is two words (double or long)
if (VM.VerifyAssertions)
VM._assert(fieldRef.getSize() == BYTES_IN_LONG);
if (VM.BuildFor32Addr) {
// JMM: we need to guarantee atomic access for volatile fields
if (field.isVolatile()) {
if (SSE2_BASE) {
asm.emitMOVQ_Reg_Abs(XMM0, Magic.getTocPointer().plus(fieldOffset));
adjustStack(-2 * WORDSIZE, true);
asm.emitMOVQ_RegInd_Reg(SP, XMM0);
} else {
asm.emitFLD_Reg_Abs_Quad(FP0, Magic.getTocPointer().plus(fieldOffset));
adjustStack(-2 * WORDSIZE, true);
asm.emitFSTP_RegInd_Reg_Quad(SP, FP0);
}
} else {
// get high part
asm.emitPUSH_Abs(Magic.getTocPointer().plus(fieldOffset).plus(WORDSIZE));
// get low part
asm.emitPUSH_Abs(Magic.getTocPointer().plus(fieldOffset));
}
} else {
if (fieldRef.getNumberOfStackSlots() != 1) {
adjustStack(-WORDSIZE, true);
}
asm.generateJTOCpush(fieldOffset);
}
}
}
use of org.vmmagic.unboxed.Offset in project JikesRVM by JikesRVM.
the class BaselineCompilerImpl method emit_f2i.
@Override
protected void emit_f2i() {
if (SSE2_BASE) {
// Set up value in XMM0
asm.emitMOVSS_Reg_RegInd(XMM0, SP);
// adjust = 0
asm.emitXOR_Reg_Reg(T1, T1);
// result = 0
asm.emitXOR_Reg_Reg(T0, T0);
// value cmp maxint
asm.generateJTOCcmpFloat(XMM0, Entrypoints.maxintFloatField.getOffset());
// if NaN goto fr1
ForwardReference fr1 = asm.forwardJcc(PE);
// T1 = (value >= maxint) ? 1 : 0;
asm.emitSET_Cond_Reg_Byte(LGE, T1);
// T0 = (int)value, or 0x80000000 if value > maxint
asm.emitCVTTSS2SI_Reg_Reg(T0, XMM0);
// T0 = T0 - T1, ie fix max int case
asm.emitSUB_Reg_Reg(T0, T1);
fr1.resolve(asm);
// push result
asm.emitMOV_RegInd_Reg(SP, T0);
} else {
// TODO: use x87 operations to do this conversion inline taking care of
// the boundary cases that differ between x87 and Java
// (1) save RVM nonvolatiles
int numNonVols = NONVOLATILE_GPRS.length;
Offset off = Offset.fromIntSignExtend(numNonVols * WORDSIZE);
for (int i = 0; i < numNonVols; i++) {
asm.emitPUSH_Reg(NONVOLATILE_GPRS[i]);
}
// (2) Push arg to C function
asm.emitPUSH_RegDisp(SP, off);
// (3) invoke C function through bootrecord
asm.emitMOV_Reg_Abs(S0, Magic.getTocPointer().plus(Entrypoints.the_boot_recordField.getOffset()));
asm.emitCALL_RegDisp(S0, Entrypoints.sysFloatToIntIPField.getOffset());
// (4) pop argument;
asm.emitPOP_Reg(S0);
// (5) restore RVM nonvolatiles
for (int i = numNonVols - 1; i >= 0; i--) {
asm.emitPOP_Reg(NONVOLATILE_GPRS[i]);
}
// (6) put result on expression stack
asm.emitMOV_RegInd_Reg(SP, T0);
}
}
use of org.vmmagic.unboxed.Offset in project JikesRVM by JikesRVM.
the class BaselineCompilerImpl method emit_resolved_invokestatic.
@Override
protected void emit_resolved_invokestatic(MethodReference methodRef) {
Offset methodOffset = methodRef.peekResolvedMethod().getOffset();
genParameterRegisterLoad(methodRef, false);
asm.generateJTOCcall(methodOffset);
genResultRegisterUnload(methodRef);
}
use of org.vmmagic.unboxed.Offset 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.Offset 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();
}
Aggregations