use of org.jikesrvm.compilers.common.assembler.ForwardReference in project JikesRVM by JikesRVM.
the class BaselineCompilerImpl method emit_checkcast_resolvedClass.
@Override
protected void emit_checkcast_resolvedClass(RVMClass type) {
int LHSDepth = type.getTypeDepth();
int LHSId = type.getId();
// load the object being checked
peekAddr(T0, 0);
// check for null
asm.emitCMPAddrI(T0, 0);
ForwardReference isNull = asm.emitForwardBC(EQ);
// TIB of "this" object
asm.baselineEmitLoadTIB(T0, T0);
// superclass display
asm.emitLAddr(T0, TIB_SUPERCLASS_IDS_INDEX << LOG_BYTES_IN_ADDRESS, T0);
if (DynamicTypeCheck.MIN_SUPERCLASS_IDS_SIZE <= LHSDepth) {
// must do arraybounds check of superclass display
// T1 gets array length
asm.emitLIntOffset(T1, T0, ObjectModel.getArrayLengthOffset());
asm.emitLVAL(T2, LHSDepth);
asm.emitCMPL(T2, T1);
// if in bounds, jump around trap. TODO: would like to encode "y" bit that this branch is expected to be takem.
ForwardReference fr1 = asm.emitForwardBC(LT);
// encoding of TRAP_ALWAYS CHECKCAST
asm.emitTWI(31, GPR.R12, CHECKCAST_TRAP);
fr1.resolve(asm);
}
// Load id from display at required depth and compare against target id.
asm.emitLHZ(T0, LHSDepth << LOG_BYTES_IN_CHAR, T0);
if (Assembler.fits(LHSId, 16)) {
asm.emitCMPI(T0, LHSId);
} else {
asm.emitLVAL(T1, LHSId);
asm.emitCMP(T0, T1);
}
// TODO: encode "y" bit that branch is likely taken.
ForwardReference fr2 = asm.emitForwardBC(EQ);
// encoding of TRAP_ALWAYS CHECKCAST
asm.emitTWI(31, GPR.R12, CHECKCAST_TRAP);
fr2.resolve(asm);
isNull.resolve(asm);
}
use of org.jikesrvm.compilers.common.assembler.ForwardReference in project JikesRVM by JikesRVM.
the class BaselineCompilerImpl method emit_jsr.
@Override
protected void emit_jsr(int bTarget) {
ForwardReference fr = asm.emitForwardBL();
// get PC into LR...
fr.resolve(asm);
int start = asm.getMachineCodeIndex();
int delta = 4;
// LR + 0
asm.emitMFLR(T1);
// LR + 4
asm.emitADDI(T1, delta * INSTRUCTION_WIDTH, T1);
// LR + 8
pushAddr(T1);
// LR + 12
asm.emitBL(bytecodeMap[bTarget], bTarget);
int done = asm.getMachineCodeIndex();
if (VM.VerifyAssertions)
VM._assert((done - start) == delta);
}
use of org.jikesrvm.compilers.common.assembler.ForwardReference in project JikesRVM by JikesRVM.
the class BaselineCompilerImpl method emit_lushr.
@Override
protected void emit_lushr() {
// T0 is n
popInt(T0);
popLong(T2, T1);
if (VM.BuildFor64Addr) {
asm.emitANDI(T0, T0, 0x3F);
asm.emitSRD(T1, T1, T0);
pushLong(T1, T1);
} else {
// shift more than 31 bits?
asm.emitANDI(T3, T0, 0x20);
// restrict shift to at most 31 bits
asm.emitXOR(T0, T3, T0);
// high bits of l shifted n or n-32 bits
asm.emitSRW(T3, T2, T0);
ForwardReference fr1 = asm.emitForwardBC(EQ);
// high bits are zero
asm.emitLVAL(T0, 0);
pushLong(T0, T3);
ForwardReference fr2 = asm.emitForwardB();
fr1.resolve(asm);
// low bits of l shifted n bits right
asm.emitSRW(T1, T1, T0);
// T0 := 32 - T0;
asm.emitSUBFIC(T0, T0, 0x20);
// T2 is middle bits of result
asm.emitSLW(T2, T2, T0);
// T1 is low bits of result
asm.emitOR(T1, T1, T2);
pushLong(T3, T1);
fr2.resolve(asm);
}
}
use of org.jikesrvm.compilers.common.assembler.ForwardReference in project JikesRVM by JikesRVM.
the class BaselineCompilerImpl method emit_i2d.
@Override
protected void emit_i2d() {
if (VM.BuildFor64Addr) {
// TO is X (an int)
popInt(T0);
pushLong(T0, T0);
// load long
popDouble(F0);
// convert it
asm.emitFCFID(F0, F0);
// store the float
pushDouble(F0);
} else {
// T0 is X (an int)
popInt(T0);
// F0 is MAGIC
asm.emitLFDtoc(F0, Entrypoints.IEEEmagicField.getOffset(), T1);
// MAGIC on stack
pushDouble(F0);
// if 0 <= X, MAGIC + X
pokeInt(T0, 1);
// is X < 0
asm.emitCMPI(T0, 0);
// ow, handle X < 0
ForwardReference fr = asm.emitForwardBC(GE);
// T0 is top of MAGIC
popInt(T0);
// decrement top of MAGIC
asm.emitADDI(T0, -1, T0);
// MAGIC + X is on stack
pushInt(T0);
fr.resolve(asm);
// F1 is MAGIC + X
popDouble(F1);
// F1 is X
asm.emitFSUB(F1, F1, F0);
// float(X) is on stack
pushDouble(F1);
}
}
use of org.jikesrvm.compilers.common.assembler.ForwardReference in project JikesRVM by JikesRVM.
the class BaselineCompilerImpl method emit_instanceof_final.
@Override
protected void emit_instanceof_final(RVMType type) {
// load object from stack
asm.emitPOP_Reg(ECX);
// test for null
ForwardReference isNull = asm.forwardJECXZ();
// compare TIB of object to desired TIB and push true if equal
asm.baselineEmitLoadTIB(S0, ECX);
asm.generateJTOCcmpWord(S0, type.getTibOffset());
ForwardReference notMatched = asm.forwardJcc(NE);
asm.emitPUSH_Imm(1);
ForwardReference done = asm.forwardJMP();
// push false
isNull.resolve(asm);
notMatched.resolve(asm);
asm.emitPUSH_Imm(0);
done.resolve(asm);
}
Aggregations