Search in sources :

Example 1 with MethodVariables

use of org.jikesrvm.osr.MethodVariables 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);
}
Also used : InlinedOsrTypeInfoOperand(org.jikesrvm.compilers.opt.ir.operand.InlinedOsrTypeInfoOperand) BasicBlockOperand(org.jikesrvm.compilers.opt.ir.operand.BasicBlockOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) InlinedOsrTypeInfoOperand(org.jikesrvm.compilers.opt.ir.operand.InlinedOsrTypeInfoOperand) LocalRegPair(org.jikesrvm.osr.LocalRegPair) MethodVariables(org.jikesrvm.osr.MethodVariables) LinkedList(java.util.LinkedList) OsrPoint(org.jikesrvm.compilers.opt.ir.OsrPoint)

Example 2 with MethodVariables

use of org.jikesrvm.osr.MethodVariables 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

Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)2 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)2 LocalRegPair (org.jikesrvm.osr.LocalRegPair)2 MethodVariables (org.jikesrvm.osr.MethodVariables)2 LinkedList (java.util.LinkedList)1 OptimizingCompilerException (org.jikesrvm.compilers.opt.OptimizingCompilerException)1 OsrPoint (org.jikesrvm.compilers.opt.ir.OsrPoint)1 Register (org.jikesrvm.compilers.opt.ir.Register)1 AddressConstantOperand (org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand)1 BasicBlockOperand (org.jikesrvm.compilers.opt.ir.operand.BasicBlockOperand)1 InlinedOsrTypeInfoOperand (org.jikesrvm.compilers.opt.ir.operand.InlinedOsrTypeInfoOperand)1 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)1 LongConstantOperand (org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand)1 VariableMapElement (org.jikesrvm.osr.VariableMapElement)1