use of org.jikesrvm.compilers.common.assembler.ForwardReference in project JikesRVM by JikesRVM.
the class BaselineCompilerImpl method emit_f2i.
@Override
protected void emit_f2i() {
popFloat(F0);
asm.emitFCMPU(F0, F0);
ForwardReference fr1 = asm.emitForwardBC(NE);
// Normal case: F0 == F0 therefore not a NaN
asm.emitFCTIWZ(F0, F0);
if (VM.BuildFor64Addr) {
pushLowDoubleAsInt(F0);
} else {
asm.emitSTFDoffset(F0, THREAD_REGISTER, Entrypoints.scratchStorageField.getOffset());
asm.emitLIntOffset(T0, THREAD_REGISTER, Entrypoints.scratchStorageField.getOffset().plus(4));
pushInt(T0);
}
ForwardReference fr2 = asm.emitForwardB();
fr1.resolve(asm);
// A NaN => 0
asm.emitLVAL(T0, 0);
pushInt(T0);
fr2.resolve(asm);
}
use of org.jikesrvm.compilers.common.assembler.ForwardReference in project JikesRVM by JikesRVM.
the class BaselineCompilerImpl method emit_lshr.
@Override
protected void emit_lshr() {
// T0 is n
popInt(T0);
popLong(T2, T1);
if (VM.BuildFor64Addr) {
asm.emitANDI(T0, T0, 0x3F);
asm.emitSRAD(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.emitSRAW(T3, T2, T0);
ForwardReference fr1 = asm.emitForwardBC(EQ);
// propogate a full work of sign bit
asm.emitSRAWI(T0, T3, 0x1F);
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_instanceof_resolvedInterface.
@Override
protected void emit_instanceof_resolvedInterface(RVMClass type) {
int interfaceIndex = type.getDoesImplementIndex();
int interfaceMask = type.getDoesImplementBitMask();
// load object from stack and check for null
popAddr(T0);
asm.emitCMPAddrI(T0, 0);
ForwardReference isNull = asm.emitForwardBC(EQ);
// get implements bit vector from object's TIB
asm.baselineEmitLoadTIB(T0, T0);
asm.emitLAddr(T0, TIB_DOES_IMPLEMENT_INDEX << LOG_BYTES_IN_ADDRESS, T0);
ForwardReference outOfBounds = null;
if (DynamicTypeCheck.MIN_DOES_IMPLEMENT_SIZE <= interfaceIndex) {
// must do arraybounds check of implements bit vector
// T1 gets array length
asm.emitLIntOffset(T1, T0, ObjectModel.getArrayLengthOffset());
asm.emitLVAL(T2, interfaceIndex);
asm.emitCMPL(T1, T2);
outOfBounds = asm.emitForwardBC(LE);
}
// Test the appropriate bit and if set, set T0 to true (1)
asm.emitLInt(T1, interfaceIndex << LOG_BYTES_IN_INT, T0);
if ((interfaceMask & 0xffff) == interfaceMask) {
asm.emitANDI(S0, T1, interfaceMask);
} else {
if (VM.VerifyAssertions)
VM._assert((interfaceMask & 0xffff0000) == interfaceMask);
asm.emitANDIS(S0, T1, interfaceMask);
}
ForwardReference notMatched = asm.emitForwardBC(EQ);
asm.emitLVAL(T0, 1);
ForwardReference done = asm.emitForwardB();
// set T1 to 0 (false)
isNull.resolve(asm);
if (outOfBounds != null)
outOfBounds.resolve(asm);
notMatched.resolve(asm);
asm.emitLVAL(T0, 0);
// push T0, containing the result of the instanceof comparision, to the stack.
done.resolve(asm);
pushInt(T0);
}
use of org.jikesrvm.compilers.common.assembler.ForwardReference in project JikesRVM by JikesRVM.
the class BaselineCompilerImpl method emit_lshl.
@Override
protected void emit_lshl() {
// T0 is n
popInt(T0);
popLong(T2, T1);
if (VM.BuildFor64Addr) {
asm.emitANDI(T0, T0, 0x3F);
asm.emitSLD(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);
// low bits of l shifted n or n-32 bits
asm.emitSLW(T3, T1, T0);
// if shift less than 32, goto
ForwardReference fr1 = asm.emitForwardBC(EQ);
// low bits are zero
asm.emitLVAL(T0, 0);
pushLong(T3, T0);
ForwardReference fr2 = asm.emitForwardB();
fr1.resolve(asm);
// high bits of l shifted n bits left
asm.emitSLW(T2, T2, T0);
// T0 := 32 - T0;
asm.emitSUBFIC(T0, T0, 0x20);
// T1 is middle bits of result
asm.emitSRW(T1, T1, T0);
// T2 is high bits of result
asm.emitOR(T2, T2, T1);
pushLong(T2, T3);
fr2.resolve(asm);
}
}
use of org.jikesrvm.compilers.common.assembler.ForwardReference in project JikesRVM by JikesRVM.
the class BaselineCompilerImpl method emitDynamicLinkingSequence.
private void emitDynamicLinkingSequence(GPR reg, MemberReference ref, boolean couldBeZero) {
int memberId = ref.getId();
Offset memberOffset = Offset.fromIntZeroExtend(memberId << LOG_BYTES_IN_INT);
Offset tableOffset = Entrypoints.memberOffsetsField.getOffset();
if (couldBeZero) {
Offset resolverOffset = Entrypoints.resolveMemberMethod.getOffset();
int label = asm.getMachineCodeIndex();
// load offset table
asm.emitLAddrToc(reg, tableOffset);
asm.emitLIntOffset(reg, reg, memberOffset);
// test for non-zero offset and branch around call to resolver
// reg ?= NEEDS_DYNAMIC_LINK, is field's class loaded?
asm.emitCMPI(reg, NEEDS_DYNAMIC_LINK);
ForwardReference fr1 = asm.emitForwardBC(NE);
asm.emitLAddrToc(T0, resolverOffset);
asm.emitMTCTR(T0);
// id of member we are resolving
asm.emitLVAL(T0, memberId);
// link; will throw exception if link error
asm.emitBCCTRL();
// go back and try again
asm.emitB(label);
fr1.resolve(asm);
} else {
// load offset table
asm.emitLAddrToc(reg, tableOffset);
asm.emitLIntOffset(reg, reg, memberOffset);
}
}
Aggregations