use of org.jikesrvm.osr.LocalRegPair in project JikesRVM by JikesRVM.
the class LiveAnalysis method collectOsrInfo.
/* collect osr info according to live information */
private void collectOsrInfo(Instruction inst, LiveSet lives) {
// create an entry to the OSRIRMap, order: callee => caller
LinkedList<MethodVariables> mvarList = new LinkedList<MethodVariables>();
// get the type info for locals and stacks
InlinedOsrTypeInfoOperand typeInfo = OsrPoint.getInlinedTypeInfo(inst);
/* iterator over type info and create LocalRegTuple
* for each variable.
* NOTE: we do not process LONG type register operand here,
* which was splitted in BURS.
*/
byte[][] ltypes = typeInfo.localTypeCodes;
byte[][] stypes = typeInfo.stackTypeCodes;
int nummeth = typeInfo.methodids.length;
int elm_idx = 0;
int snd_long_idx = typeInfo.validOps;
for (int midx = 0; midx < nummeth; midx++) {
LinkedList<LocalRegPair> tupleList = new LinkedList<LocalRegPair>();
byte[] ls = ltypes[midx];
byte[] ss = stypes[midx];
/* record maps for local variables, skip dead ones */
for (int i = 0, n = ls.length; i < n; i++) {
if (ls[i] != VoidTypeCode) {
// check liveness
Operand op = OsrPoint.getElement(inst, elm_idx++);
LocalRegPair tuple = new LocalRegPair(LOCAL, i, ls[i], op);
// put it in the list
tupleList.add(tuple);
// get another half of a long type operand
if (VM.BuildFor32Addr && (ls[i] == LongTypeCode)) {
Operand other_op = OsrPoint.getElement(inst, snd_long_idx++);
tuple._otherHalf = new LocalRegPair(LOCAL, i, ls[i], other_op);
}
}
}
/* record maps for stack slots */
for (int i = 0, n = ss.length; i < n; i++) {
if (ss[i] != VoidTypeCode) {
LocalRegPair tuple = new LocalRegPair(STACK, i, ss[i], OsrPoint.getElement(inst, elm_idx++));
tupleList.add(tuple);
if (VM.BuildFor32Addr && (ss[i] == LongTypeCode)) {
tuple._otherHalf = new LocalRegPair(STACK, i, ss[i], OsrPoint.getElement(inst, snd_long_idx++));
}
}
}
// create MethodVariables
MethodVariables mvar = new MethodVariables(typeInfo.methodids[midx], typeInfo.bcindexes[midx], tupleList);
mvarList.add(mvar);
}
// put the method variables for this OSR in the osrMap, encoding later.
osrMap.insertFirst(inst, mvarList);
}
use of org.jikesrvm.osr.LocalRegPair in project JikesRVM by JikesRVM.
the class UpdateOSRMaps method perform.
/**
* Iterate over the IR-based OSR map, and update symbolic registers
* with real reg number or spill locations.
* Verify there are only two types of operands:
* ConstantOperand
* RegisterOperand
* for integer constant, we save the value of the integer
*
* The LONG register has another half part.
*
* CodeSpill replaces any allocated symbolic register by
* physical registers.
*/
@Override
public void perform(IR ir) throws OptimizingCompilerException {
/* for each osr instruction */
for (VariableMapElement elm : ir.MIRInfo.osrVarMap.list) {
// MethodVariables mvar = mvarsList.get(numMvars);
for (MethodVariables mvar : elm.mvars) {
// LocalRegPair tuple = tupleList.get(numTuple);
for (LocalRegPair tuple : mvar.tupleList) {
Operand op = tuple.operand;
if (op.isRegister()) {
Register sym_reg = ((RegisterOperand) op).getRegister();
setRealPosition(ir, tuple, sym_reg);
// get another half part of long register
if (VM.BuildFor32Addr && (tuple.typeCode == LongTypeCode)) {
LocalRegPair other = tuple._otherHalf;
Operand other_op = other.operand;
if (VM.VerifyAssertions)
VM._assert(other_op.isRegister());
Register other_reg = ((RegisterOperand) other_op).getRegister();
setRealPosition(ir, other, other_reg);
}
/* According to ConvertToLowLevelIR, StringConstant, LongConstant,
* NullConstant, FloatConstant, and DoubleConstant are all materialized
* The only thing left is the integer constants which could encode
* non-moveable objects.
* POTENTIAL DRAWBACKS: since any long, float, and double are moved
* to register and treated as use, it may consume more registers and
* add unnecessary MOVEs.
*
* Perhaps, ConvertToLowLevelIR can skip OsrPoint instruction.
*/
} else if (op.isIntConstant()) {
setTupleValue(tuple, ICONST, ((IntConstantOperand) op).value);
if (VM.BuildFor32Addr && (tuple.typeCode == LongTypeCode)) {
LocalRegPair other = tuple._otherHalf;
Operand other_op = other.operand;
if (VM.VerifyAssertions)
VM._assert(other_op.isIntConstant());
setTupleValue(other, ICONST, ((IntConstantOperand) other_op).value);
}
} else if (op.isAddressConstant()) {
setTupleValue(tuple, ACONST, ((AddressConstantOperand) op).value.toWord());
} else if (VM.BuildFor64Addr && op.isLongConstant()) {
setTupleValue(tuple, LCONST, Word.fromLong(((LongConstantOperand) op).value));
} else {
throw new OptimizingCompilerException("LinearScan", "Unexpected operand type at ", op.toString());
}
// for the op type
}
// for each tuple
}
// for each inlined method
}
// for each osr instruction
}
Aggregations