int ipIndex   = rowIP.diff(instr_beg).toInt() >> LG_INSTRUCTION_WIDTH;
Offset ipOffset = rowIP.diff(instr_beg);
  public OSR_ExecutionState extractState(VM_Thread thread,                                  Offset osrFPoff,                                  Offset methFPoff,                                   int cmid) {  /* performs architecture and compiler dependent operations here   *    * When a thread is hung called from baseline compiled code,   * the hierarchy of calls on stack looks like follows   * ( starting from FP in the FP register ):   *                *           morph   *           yield   *           threadSwitch   *           threadSwitchFrom[Prologue|Backedge|Epilong]   *           foo ( real method ).   *    * The returned OSR_ExecutionState should have following   *        *     current thread   *     compiled method ID of "foo"   *     fp of foo's stack frame   *     bytecode index of foo's next instruction   *     the list of variable,value of foo at that point   *     which method (foo)     */    if (VM.TraceOnStackReplacement) {      VM.sysWriteln("BASE execStateExtractor starting ...");        }    VM_Registers contextRegisters = thread.contextRegisters;    byte[] stack = thread.stack;    if (VM.VerifyAssertions) {      int fooCmid  = VM_Magic.getIntAtOffset(stack,                                              methFPoff.add(STACKFRAME_METHOD_ID_OFFSET));      if (VM.TraceOnStackReplacement) {        VM.sysWriteln("fooCmid = " + fooCmid);        VM.sysWriteln("   cmid = " + cmid);      }      VM._assert(fooCmid == cmid);    }    VM_BaselineCompiledMethod fooCM =       (VM_BaselineCompiledMethod)VM_CompiledMethods.getCompiledMethod(cmid);    VM_NormalMethod fooM = (VM_NormalMethod)fooCM.getMethod();    // get the next bc index     VM_CodeArray instructions = fooCM.getInstructions();    VM.disableGC();    Address instr_beg = VM_Magic.objectAsAddress(instructions);    Address rowIP     = VM_Magic.objectAsAddress(stack).loadAddress(osrFPoff.add(STACKFRAME_RETURN_ADDRESS_OFFSET));     VM.enableGC();    int ipIndex   = rowIP.diff(instr_beg).toInt() >> LG_INSTRUCTION_WIDTH;        // CAUTION: IP Offset should point to next instruction    int bcIndex = fooCM.findBytecodeIndexForInstruction(ipIndex + 1);    // assertions    if (VM.VerifyAssertions) {      if (bcIndex == -1) {              VM.sysWriteln("osrFPoff = ", osrFPoff);        VM.sysWriteln("instr_beg = " + instr_beg);        for (int i=(osrFPoff.toInt())-10; i<(osrFPoff.toInt())+10; i++)          VM.sysWriteln("  stack["+i+"] = "+stack[i]);        VM.sysWriteln("ipIndex : " + ipIndex);        VM.sysWriteln("bcIndex : " + bcIndex);      }      VM._assert(bcIndex != -1);    }    // create execution state object    OSR_ExecutionState state = new OSR_ExecutionState(thread,                                                      methFPoff,                                                      cmid,                                                      bcIndex,                                                      osrFPoff);    /* extract values for local and stack, but first of all     * we need to get type information for current PC.     */        OSR_BytecodeTraverser typer = new OSR_BytecodeTraverser();        typer.computeLocalStackTypes(fooM, bcIndex);    byte[] localTypes = typer.getLocalTypes();    byte[] stackTypes = typer.getStackTypes();    if (VM.TraceOnStackReplacement) {      VM.sysWrite("BC Index : "+bcIndex+"\n");      VM.sysWrite("Local Types :");      for (int i=0; i<localTypes.length; i++) {        VM.sysWrite(" "+(char)localTypes[i]);      }      VM.sysWrite("\nStack Types :");      for (int i=0; i<stackTypes.length; i++) {        VM.sysWrite(" "+(char)stackTypes[i]);      }      VM.sysWrite("\n");    }        // consult GC reference map again since the type matcher does not complete    // the flow analysis, it can not distinguish reference or non-reference     // type. We should remove non-reference type    for (int i=0, n=localTypes.length; i<n; i++) {      // if typer reports a local is reference type, but the GC map says no      // then set the localType to uninitialized, see VM spec, bytecode verifier      if (localTypes[i] == ClassTypeCode) {        if (!fooCM.referenceMaps.isLocalRefType(fooM, ipIndex+ 1, i)) {          localTypes[i] = VoidTypeCode;          if (VM.TraceOnStackReplacement) {            VM.sysWriteln("GC maps disagrees with type matcher at "+i+"th local\n");          }        }      }    }    // go through the stack frame and extract values    // In the variable value list, we keep the order as follows:    // L0, L1, ..., S0, S1, ....        // adjust local offset and stack offset    // NOTE: donot call VM_Compiler.getFirstLocalOffset(method)         Offset startLocalOffset = methFPoff.add(fooCM.getStartLocalOffset());    Offset stackOffset = methFPoff.add(fooCM.getEmptyStackOffset());    // for locals    getVariableValue(stack,                      startLocalOffset,                      localTypes,                     fooCM,                     instructions,                     LOCAL,                     state);    // for stacks    getVariableValue(stack,                     stackOffset,                     stackTypes,                     fooCM,                     instructions,                     STACK,                     state);    if (VM.TraceOnStackReplacement) {      state.printState();    }                     if (VM.TraceOnStackReplacement) {      VM.sysWriteln("BASE executionStateExtractor done ");        }    return state;  }