Search in sources :

Example 1 with VariableMapElement

use of org.jikesrvm.osr.VariableMapElement 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
}
Also used : RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) Register(org.jikesrvm.compilers.opt.ir.Register) AddressConstantOperand(org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) LongConstantOperand(org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) AddressConstantOperand(org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand) LocalRegPair(org.jikesrvm.osr.LocalRegPair) VariableMapElement(org.jikesrvm.osr.VariableMapElement) OptimizingCompilerException(org.jikesrvm.compilers.opt.OptimizingCompilerException) MethodVariables(org.jikesrvm.osr.MethodVariables)

Aggregations

OptimizingCompilerException (org.jikesrvm.compilers.opt.OptimizingCompilerException)1 Register (org.jikesrvm.compilers.opt.ir.Register)1 AddressConstantOperand (org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand)1 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)1 LongConstantOperand (org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand)1 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)1 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)1 LocalRegPair (org.jikesrvm.osr.LocalRegPair)1 MethodVariables (org.jikesrvm.osr.MethodVariables)1 VariableMapElement (org.jikesrvm.osr.VariableMapElement)1