if (op instanceof OPT_RegisterOperand) { op = ((OPT_RegisterOperand)op).copyU2U();
if (op.isRegister()) { op = op.asRegister().copyU2U();
  private void renovateOsrPoints(LinkedList osrs, OPT_IR ir) {    for (int osrIdx=0, osrSize=osrs.size(); osrIdx<osrSize; osrIdx++) {      OPT_Instruction osr = (OPT_Instruction)osrs.get(osrIdx);            LinkedList barriers = new LinkedList();      // Step 1: collect barriers put before inlined method      //         in the order of from inner to outer      {        OPT_Instruction bar = (OPT_Instruction)osr.scratchObject;        if (osr.position == null) osr.position = bar.position;        adjustBCIndex(osr);        while (bar != null) {          barriers.add(bar);          // verify each barrier is clean          if (VM.VerifyAssertions) {            if (!isBarrierClean(bar)) {              VM.sysWriteln("Barrier "+bar+" is not clean!");            }            VM._assert(isBarrierClean(bar));          }          OPT_Instruction callsite = bar.position.getCallSite();          if (callsite != null) {            bar = (OPT_Instruction)callsite.scratchObject;                if (bar == null) {                  VM.sysWrite("call site :"+callsite);                  VM._assert(false);                }                            adjustBCIndex(bar);          } else {            bar = null;          }         }      }      int inlineDepth = barriers.size();      if (VM.VerifyAssertions) {        if (inlineDepth == 0) {          VM.sysWriteln("Inlining depth for "+osr+" is 0!");        }        VM._assert(inlineDepth != 0); }      // Step 2: make a new InlinedOsrTypeOperand from barriers      int methodids[] = new int[inlineDepth];      int bcindexes[] = new int[inlineDepth];      byte localTypeCodes[][] = new byte[inlineDepth][];      byte stackTypeCodes[][] = new byte[inlineDepth][];            int totalOperands = 0;      // first iteration, count the size of total locals and stack sizes      for (int barIdx=0, barSize=barriers.size(); barIdx<barSize; barIdx++) {        OPT_Instruction bar = (OPT_Instruction)barriers.get(barIdx);        methodids[barIdx] = bar.position.method.getId();        bcindexes[barIdx] = bar.bcIndex;        OPT_OsrTypeInfoOperand typeInfo = OsrBarrier.getTypeInfo(bar);        localTypeCodes[barIdx] = typeInfo.localTypeCodes;        stackTypeCodes[barIdx] = typeInfo.stackTypeCodes;        // count the number of operand, but ignore VoidTypeCode        totalOperands += OsrBarrier.getNumberOfElements(bar);        /*        if (VM.TraceOnStackReplacement) {          VM.sysWriteln("OsrBarrier : "+bar.bcIndex                        +"@"+bar.position.method                        +" "+typeInfo);        }        */      }      // new make InlinedOsrTypeInfoOperand      OPT_InlinedOsrTypeInfoOperand typeInfo =        new OPT_InlinedOsrTypeInfoOperand(methodids, bcindexes,                                          localTypeCodes,                                          stackTypeCodes);            OsrPoint.mutate(osr, osr.operator(),                      typeInfo,                       totalOperands);      // Step 3: second iteration, copy operands      int opIndex = 0;      for (int barIdx=0, barSize=barriers.size(); barIdx<barSize; barIdx++) {        OPT_Instruction bar = (OPT_Instruction)barriers.get(barIdx);        for (int elmIdx=0, elmSize=OsrBarrier.getNumberOfElements(bar);              elmIdx<elmSize;              elmIdx++) {          OPT_Operand op = OsrBarrier.getElement(bar, elmIdx);              if (VM.VerifyAssertions) {            if (op == null) {              VM.sysWriteln(elmIdx+"th Operand of "+bar+" is null!");               }            VM._assert(op != null);          }           if (op instanceof OPT_RegisterOperand) {            op = ((OPT_RegisterOperand)op).copyU2U();          }          OsrPoint.setElement(osr, opIndex, op);          opIndex ++;        }      }/*      if (VM.TraceOnStackReplacement) {        VM.sysWriteln("renovated OsrPoint instruction "+osr);        VM.sysWriteln("  position "+osr.bcIndex+"@"+osr.position.method);      }*/      // the last OsrBarrier should in the current method      if (VM.VerifyAssertions) {        OPT_Instruction lastBar = (OPT_Instruction)barriers.getLast();        if (ir.method != lastBar.position.method) {          VM.sysWriteln("The last barrier is not in the same method as osr:");          VM.sysWriteln(lastBar+"@"+lastBar.position.method);          VM.sysWriteln("current method @"+ir.method);        }        VM._assert(ir.method == lastBar.position.method);        if (opIndex != totalOperands) {          VM.sysWriteln("opIndex and totalOperands do not match:");          VM.sysWriteln("opIndex = "+opIndex);          VM.sysWriteln("totalOperands = "+totalOperands);        }        VM._assert(opIndex == totalOperands);      } // end of assertion    } // end of for loop  }