pushInt(T0); } return true; }  if (methodName == VM_MagicNames.loadShort) {  if (types.length == 0) { popAddr(T0); asm.emitLHA(T0, 0, T0); pushInt(T0); } else { popInt(T1); popAddr(T0); asm.emitLHAX(T0, T1, T0);
  private boolean generateInlineCode(VM_MethodReference methodToBeCalled) {    VM_Atom methodName = methodToBeCalled.getName();          if (methodToBeCalled.getType() == VM_TypeReference.SysCall) {      VM_TypeReference[] args = methodToBeCalled.getParameterTypes();      // (1) Set up arguments according to OS calling convention, excluding the first      // which is not an argument to the native function but the address of the function to call      int paramWords = methodToBeCalled.getParameterWords();      int gp = FIRST_OS_PARAMETER_GPR;      int fp = FIRST_OS_PARAMETER_FPR;      int stackIndex = paramWords - 1;      int paramBytes = ((VM.BuildFor64Addr? args.length : paramWords) - 1)* BYTES_IN_STACKSLOT;      int callee_param_index = - BYTES_IN_STACKSLOT - paramBytes;            for (int i=1; i<args.length; i++) {        VM_TypeReference t = args[i];        if (t.isLongType()) {          stackIndex -= 2;          callee_param_index += BYTES_IN_LONG;          if (VM.BuildFor64Addr) {            if (gp <= LAST_OS_PARAMETER_GPR) {               peekLong(gp, gp, stackIndex);              gp++;              } else {              peekLong(S0,S0, stackIndex);              asm.emitSTD(S0, callee_param_index - BYTES_IN_LONG, FP);            }          } else {          //-#if RVM_FOR_LINUX          /* NOTE: following adjustment is not stated in SVR4 ABI, but            * was implemented in GCC.           */            gp += (gp + 1) & 0x01; // if gpr is even, gpr += 1          //-#endif            if (gp <= LAST_OS_PARAMETER_GPR){               peekInt(gp++, stackIndex);               }   // lo register := lo mem (== hi order word)            if (gp <= LAST_OS_PARAMETER_GPR){                peekInt(gp++, stackIndex+1);    // hi register := hi mem (== lo order word)            } else {              peekLong(S0, S1, stackIndex);              asm.emitSTW(S0, callee_param_index - BYTES_IN_LONG, FP);              asm.emitSTW(S1, callee_param_index - BYTES_IN_INT, FP);            }          }        } else if (t.isFloatType()) {          stackIndex -= 1;          callee_param_index += BYTES_IN_STACKSLOT;          if (fp <= LAST_OS_PARAMETER_FPR) {             peekFloat(fp++, stackIndex);          } else {              peekFloat(FIRST_SCRATCH_FPR, stackIndex);              asm.emitSTFS(FIRST_SCRATCH_FPR, callee_param_index - BYTES_IN_FLOAT, FP);          }        } else if (t.isDoubleType()) {          stackIndex -= 2;          callee_param_index += BYTES_IN_DOUBLE;          if (fp <= LAST_OS_PARAMETER_FPR) {             peekDouble(fp++, stackIndex);          } else {            peekDouble( FIRST_SCRATCH_FPR, stackIndex);            asm.emitSTFD(FIRST_SCRATCH_FPR, callee_param_index - BYTES_IN_DOUBLE, FP);          }        } else if (t.isIntLikeType()) {          stackIndex -= 1;          callee_param_index += BYTES_IN_STACKSLOT;          if (gp <= LAST_OS_PARAMETER_GPR)  {            peekInt(gp++, stackIndex);          } else {            peekInt(S0, stackIndex);            asm.emitSTAddr(S0, callee_param_index - BYTES_IN_ADDRESS, FP);// save int zero-extended to be sure          }        } else { // t is object          stackIndex -= 1;          callee_param_index += BYTES_IN_STACKSLOT;          if (gp <= LAST_OS_PARAMETER_GPR){              peekAddr(gp++, stackIndex);          } else {            peekAddr(S0, stackIndex);            asm.emitSTAddr(S0, callee_param_index - BYTES_IN_ADDRESS, FP);          }        }      }      if (VM.VerifyAssertions) {        VM._assert(stackIndex == 0);      }      // (2) Call it      peekAddr(S0, paramWords - 1); // Load addres of function into S0      generateSysCall(paramBytes); // make the call      // (3) Pop Java expression stack      discardSlots(paramWords);      // (4) Push return value (if any)      VM_TypeReference rtype = methodToBeCalled.getReturnType();      if (rtype.isIntLikeType()) {        pushInt(T0);      } else if (rtype.isWordType() || rtype.isReferenceType()) {        pushAddr(T0);       } else if (rtype.isDoubleType()) {        pushDouble(FIRST_OS_PARAMETER_FPR);      } else if (rtype.isFloatType()) {        pushFloat(FIRST_OS_PARAMETER_FPR);      } else if (rtype.isLongType()) {        pushLong(T0, VM.BuildFor64Addr?T0:T1);      }      return true;    }    if (methodToBeCalled.getType() == VM_TypeReference.Address) {      // Address.xyz magic      VM_TypeReference[] types = methodToBeCalled.getParameterTypes();      // Loads all take the form:      // ..., Address, [Offset] -> ..., Value      if (methodName == VM_MagicNames.loadAddress ||          methodName == VM_MagicNames.loadObjectReference ||          methodName == VM_MagicNames.loadWord) {        if (types.length == 0) {          popAddr(T0);                  // pop base           asm.emitLAddr(T0,  0, T0);    // *(base)          pushAddr(T0);                 // push *(base)        } else {          popInt(T1);                   // pop offset          popAddr(T0);                  // pop base           asm.emitLAddrX(T0, T1, T0);   // *(base+offset)          pushAddr(T0);                 // push *(base+offset)        }        return true;      }      if (methodName == VM_MagicNames.loadChar ||          methodName == VM_MagicNames.loadShort) {        if (types.length == 0) {          popAddr(T0);                  // pop base          asm.emitLHZ(T0, 0, T0);       // load with zero extension.          pushInt(T0);                  // push *(base)         } else {          popInt(T1);                   // pop offset          popAddr(T0);                  // pop base          asm.emitLHZX(T0, T1, T0);     // load with zero extension.          pushInt(T0);                  // push *(base+offset)         }        return true;      }      if (methodName == VM_MagicNames.loadByte) {        if (types.length == 0) {          popAddr(T0);                  // pop base          asm.emitLBZ(T0, 0, T0);       // load with zero extension.          pushInt(T0);                  // push *(base)         } else {          popInt(T1);                   // pop offset          popAddr(T0);                  // pop base          asm.emitLBZX(T0, T1, T0);     // load with zero extension.          pushInt(T0);                  // push *(base+offset)         }        return true;      }      if (methodName == VM_MagicNames.loadInt ||          methodName == VM_MagicNames.loadFloat) {        if (types.length == 0) {          popAddr(T0);                  // pop base           asm.emitLInt(T0,  0, T0);     // *(base)          pushInt(T0);                  // push *(base)        } else {          popInt(T1);                   // pop offset          popAddr(T0);                  // pop base           asm.emitLIntX(T0, T1, T0);    // *(base+offset)          pushInt(T0);                  // push *(base+offset)        }        return true;      }      if (methodName == VM_MagicNames.loadDouble ||          methodName == VM_MagicNames.loadLong) {        if (types.length == 0) {          popAddr(T1);                  // pop base           asm.emitLFD (F0, 0, T1);      // *(base)          pushDouble(F0);               // push double        } else {                 popInt(T2);                   // pop offset           popAddr(T1);                  // pop base           asm.emitLFDX (F0, T1, T2);    // *(base+offset)          pushDouble(F0);               // push *(base+offset)        }        return true;      }            // Prepares all take the form:      // ..., Address, [Offset] -> ..., Value      if (methodName == VM_MagicNames.prepareInt) {        if (types.length == 0) {          popAddr(T0);                             // pop base           asm.emitLWARX(T0, 0, T0);                // *(base), setting reservation address          // this Integer is not sign extended !!          pushInt(T0);                             // push *(base+offset)        } else {          popInt(T1);                              // pop offset          popAddr(T0);                             // pop base           asm.emitLWARX(T0,  T1, T0);              // *(base+offset), setting reservation address          // this Integer is not sign extended !!          pushInt(T0);                             // push *(base+offset)        }        return true;      }      if (methodName == VM_MagicNames.prepareWord ||           methodName == VM_MagicNames.prepareObjectReference ||          methodName == VM_MagicNames.prepareAddress) {        if (types.length == 0) {          popAddr(T0);                             // pop base          if (VM.BuildFor32Addr) {            asm.emitLWARX(T0, 0, T0);            // *(base+offset), setting           } else {                               // reservation address            asm.emitLDARX(T0, 0, T0);          }          pushAddr(T0);                            // push *(base+offset)        } else {          popInt(T1);                              // pop offset          popAddr(T0);                             // pop base          if (VM.BuildFor32Addr) {            asm.emitLWARX(T0,  T1, T0);          // *(base+offset), setting           } else {                               // reservation address            asm.emitLDARX(T0, T1, T0);          }          pushAddr(T0);                            // push *(base+offset)        }        return true;        }       // Attempts all take the form:      // ..., Address, OldVal, NewVal, [Offset] -> ..., Success?      if (methodName == VM_MagicNames.attempt &&           types[0] == VM_TypeReference.Int) {        if (types.length == 2) {           popInt(T2);                            // pop newValue                           discardSlot();                         // ignore oldValue                      popAddr(T0);                           // pop base           asm.emitSTWCXr(T2,  0, T0);            // store new value and set CR0          asm.emitLVAL(T0,  0);                  // T0 := false          VM_ForwardReference fr = asm.emitForwardBC(NE);             // skip, if store failed          asm.emitLVAL(T0,  1);                  // T0 := true          fr.resolve(asm);          pushInt(T0);                           // push success of store        } else {          popInt(T1);                            // pop offset          popInt(T2);                            // pop newValue                           discardSlot();                         // ignore oldValue                      popAddr(T0);                           // pop base           asm.emitSTWCXr(T2,  T1, T0);           // store new value and set CR0          asm.emitLVAL(T0,  0);                  // T0 := false          VM_ForwardReference fr = asm.emitForwardBC(NE);             // skip, if store failed          asm.emitLVAL(T0,  1);                  // T0 := true          fr.resolve(asm);          pushInt(T0);                           // push success of store        }        return true;      }      if (methodName == VM_MagicNames.attempt &&          (types[0] == VM_TypeReference.Address ||           types[0] == VM_TypeReference.Word)) {        if (types.length == 2) {          popAddr(T2);                             // pop newValue          discardSlot();                           // ignore oldValue          popAddr(T0);                             // pop base           if (VM.BuildFor32Addr) {            asm.emitSTWCXr(T2,  0, T0);          // store new value and set CR0          } else {             asm.emitSTDCXr(T2,  0, T0);          // store new value and set CR0          }          asm.emitLVAL(T0, 0);                   // T0 := false          VM_ForwardReference fr = asm.emitForwardBC(NE);  // skip, if store failed          asm.emitLVAL(T0, 1);                   // T0 := true          fr.resolve(asm);            pushInt(T0);                           // push success of store        } else {          popInt(T1);                              // pop offset          popAddr(T2);                             // pop newValue          discardSlot();                           // ignore oldValue          popAddr(T0);                             // pop base           if (VM.BuildFor32Addr) {            asm.emitSTWCXr(T2,  T1, T0);         // store new value and set CR0          } else {            asm.emitSTDCXr(T2,  T1, T0);         // store new value and set CR0          }          asm.emitLVAL(T0, 0);                   // T0 := false          VM_ForwardReference fr = asm.emitForwardBC(NE);             // skip, if store failed          asm.emitLVAL(T0, 1);                   // T0 := true          fr.resolve(asm);            pushInt(T0);                           // push success of store        }        return true;      }      // Stores all take the form:      // ..., Address, Value, [Offset] -> ...      if (methodName == VM_MagicNames.store) {        if(types[0] == VM_TypeReference.Word ||           types[0] == VM_TypeReference.ObjectReference ||           types[0] == VM_TypeReference.Address) {          if (types.length == 1) {            popAddr(T1);                 // pop newvalue            popAddr(T0);                 // pop base             asm.emitSTAddrX(T1, 0, T0);   // *(base) = newvalue          } else {            popInt(T1);                  // pop offset            popAddr(T2);                 // pop newvalue            popAddr(T0);                 // pop base             asm.emitSTAddrX(T2, T1, T0); // *(base+offset) = newvalue          }          return true;        }        if(types[0] == VM_TypeReference.Byte) {          if (types.length == 1) {            popInt(T1);                  // pop newvalue            popAddr(T0);                 // pop base             asm.emitSTBX(T1, 0, T0);      // *(base) = newvalue          } else {            popInt(T1);                  // pop offset            popInt(T2);                  // pop newvalue            popAddr(T0);                 // pop base             asm.emitSTBX(T2, T1, T0);    // *(base+offset) = newvalue          }          return true;        }        if(types[0] == VM_TypeReference.Int ||           types[0] == VM_TypeReference.Float) {          if (types.length == 1) {            popInt(T1);                  // pop newvalue            popAddr(T0);                 // pop base             asm.emitSTWX(T1, 0, T0);      // *(base+offset) = newvalue          } else {            popInt(T1);                  // pop offset            popInt(T2);                  // pop newvalue            popAddr(T0);                 // pop base             asm.emitSTWX(T2, T1, T0);    // *(base+offset) = newvalue          }          return true;        }        if(types[0] == VM_TypeReference.Short ||           types[0] == VM_TypeReference.Char) {          if (types.length == 1) {            popInt(T1);                  // pop newvalue            popAddr(T0);                 // pop base             asm.emitSTHX(T1, 0, T0);      // *(base) = newvalue          } else {            popInt(T1);                  // pop offset            popInt(T2);                  // pop newvalue            popAddr(T0);                 // pop base             asm.emitSTHX(T2, T1, T0);    // *(base+offset) = newvalue          }          return true;        }        if(types[0] == VM_TypeReference.Double ||          types[0] == VM_TypeReference.Long) {          if (types.length == 1) {            popLong(T2, T1);                      // pop newvalue low and high            popAddr(T0);                          // pop base             if (VM.BuildFor32Addr) {              asm.emitSTWX(T2, 0, T0);             // *(base) = newvalue low              asm.emitSTWX(T1, BYTES_IN_INT, T0);  // *(base+4) = newvalue high            } else {              asm.emitSTDX(T1, 0, T0);           // *(base) = newvalue             }          } else {            popInt(T1);                           // pop offset            popLong(T3, T2);                      // pop newvalue low and high            popAddr(T0);                          // pop base             if (VM.BuildFor32Addr) {              asm.emitSTWX(T3, T1, T0);           // *(base+offset) = newvalue low              asm.emitADDI(T1, BYTES_IN_INT, T1); // offset += 4              asm.emitSTWX(T2, T1, T0);           // *(base+offset) = newvalue high            } else {              asm.emitSTDX(T2, T1, T0);           // *(base+offset) = newvalue             }          }          return true;        }      }    }    if (methodName == VM_MagicNames.getFramePointer) {      pushAddr(FP);     } else if (methodName == VM_MagicNames.getCallerFramePointer) {      popAddr(T0);                               // pop  frame pointer of callee frame      asm.emitLAddr(T1, STACKFRAME_FRAME_POINTER_OFFSET, T0); // load frame pointer of caller frame      pushAddr(T1);                               // push frame pointer of caller frame    } else if (methodName == VM_MagicNames.setCallerFramePointer) {      popAddr(T1); // value      popAddr(T0); // fp      asm.emitSTAddr(T1,  STACKFRAME_FRAME_POINTER_OFFSET, T0); // *(address+SFPO) := value    } else if (methodName == VM_MagicNames.getCompiledMethodID) {      popAddr(T0);                           // pop  frame pointer of callee frame      asm.emitLInt (T1, STACKFRAME_METHOD_ID_OFFSET, T0); // load compiled method id      pushInt(T1);                           // push method ID     } else if (methodName == VM_MagicNames.setCompiledMethodID) {      popInt(T1); // value      popAddr(T0); // fp      asm.emitSTW(T1,  STACKFRAME_METHOD_ID_OFFSET, T0); // *(address+SNIO) := value    } else if (methodName == VM_MagicNames.getNextInstructionAddress) {      popAddr(T0);                                  // pop  frame pointer of callee frame      asm.emitLAddr(T1, STACKFRAME_NEXT_INSTRUCTION_OFFSET, T0); // load frame pointer of caller frame      pushAddr(T1);                                  // push frame pointer of caller frame    } else if (methodName == VM_MagicNames.setNextInstructionAddress) {      popAddr(T1); // value      popAddr(T0); // fp      asm.emitSTAddr(T1,  STACKFRAME_NEXT_INSTRUCTION_OFFSET, T0); // *(address+SNIO) := value    } else if (methodName == VM_MagicNames.getReturnAddressLocation) {      popAddr(T0);                                  // pop  frame pointer of callee frame      asm.emitLAddr(T1, STACKFRAME_FRAME_POINTER_OFFSET, T0);    // load frame pointer of caller frame      asm.emitADDI (T2, STACKFRAME_NEXT_INSTRUCTION_OFFSET, T1); // get location containing ret addr      pushAddr(T2);                                  // push frame pointer of caller frame    } else if (methodName == VM_MagicNames.getTocPointer ||               methodName == VM_MagicNames.getJTOC) {      pushAddr(JTOC);     } else if (methodName == VM_MagicNames.getProcessorRegister) {      pushAddr(PROCESSOR_REGISTER);    } else if (methodName == VM_MagicNames.setProcessorRegister) {      popAddr(PROCESSOR_REGISTER);    } else if (methodName == VM_MagicNames.getTimeBase) {      if (VM.BuildFor64Addr) {        asm.emitMFTB (T1);      // T1 := time base      } else {        int label = asm.getMachineCodeIndex();        asm.emitMFTBU(T0);                      // T0 := time base, upper        asm.emitMFTB (T1);                      // T1 := time base, lower        asm.emitMFTBU(T2);                      // T2 := time base, upper        asm.emitCMP  (T0, T2);                  // T0 == T2?        asm.emitBC   (NE, label);               // lower rolled over, try again      }      pushLong(T0,T1);                  } else if (methodName == VM_MagicNames.invokeMain) {      popAddr(T0); // t0 := ip      asm.emitMTCTR(T0);      peekAddr(T0,0); // t0 := parameter      asm.emitBCCTRL();          // call      discardSlot(); // pop parameter    } else if (methodName == VM_MagicNames.invokeClassInitializer) {      popAddr(T0); // t0 := address to be called      asm.emitMTCTR(T0);      asm.emitBCCTRL();          // call    } else if (methodName == VM_MagicNames.invokeMethodReturningVoid) {      generateMethodInvocation(); // call method    } else if (methodName == VM_MagicNames.invokeMethodReturningInt) {      generateMethodInvocation(); // call method      pushInt(T0);       // push result    } else if (methodName == VM_MagicNames.invokeMethodReturningLong) {      generateMethodInvocation(); // call method      pushLong(T0, VM.BuildFor64Addr?T0:T1);       // push result    } else if (methodName == VM_MagicNames.invokeMethodReturningFloat) {      generateMethodInvocation(); // call method      pushFloat(F0);     // push result    } else if (methodName == VM_MagicNames.invokeMethodReturningDouble) {      generateMethodInvocation(); // call method      pushDouble(F0);     // push result    } else if (methodName == VM_MagicNames.invokeMethodReturningObject) {      generateMethodInvocation(); // call method      pushAddr(T0);       // push result    } else if (methodName == VM_MagicNames.addressArrayCreate) {      VM_Array type = methodToBeCalled.getType().resolve().asArray();      emit_resolved_newarray(type);    } else if (methodName == VM_MagicNames.addressArrayLength) {      emit_arraylength();    } else if (methodName == VM_MagicNames.addressArrayGet) {      if (VM.BuildFor32Addr || methodToBeCalled.getType() == VM_TypeReference.CodeArray) {        emit_iaload();      } else {        genBoundsCheck();        asm.emitSLDI (T1, T1,  LOG_BYTES_IN_ADDRESS);  // convert index to offset        asm.emitLAddrX(T2, T0, T1);  // load desired array element        pushAddr(T2);      }    } else if (methodName == VM_MagicNames.addressArraySet) {      if (VM.BuildFor32Addr || methodToBeCalled.getType() == VM_TypeReference.CodeArray) {        emit_iastore();        } else {        popAddr(T2);                                   // T2 is value to store        genBoundsCheck();        asm.emitSLDI (T1, T1,  LOG_BYTES_IN_ADDRESS);  // convert index to offset        asm.emitSTAddrX (T2, T0, T1);                  // store value in array      }    } else if (methodName == VM_MagicNames.getIntAtOffset) {       popInt(T1); // pop offset      popAddr(T0); // pop object      asm.emitLIntX (T0, T1, T0); // *(object+offset)      pushInt(T0); // push *(object+offset)    } else if (methodName == VM_MagicNames.getObjectAtOffset ||               methodName == VM_MagicNames.getWordAtOffset ||                methodName == VM_MagicNames.getObjectArrayAtOffset) {      popInt(T1); // pop offset      popAddr(T0); // pop object      asm.emitLAddrX(T0, T1, T0); // *(object+offset)      pushAddr(T0); // push *(object+offset)    } else if (methodName == VM_MagicNames.getByteAtOffset) {      popInt(T1);   // pop offset      popAddr(T0);   // pop object      asm.emitLBZX(T0, T1, T0);   // load byte with zero extension.      pushInt(T0);    // push *(object+offset)     } else if (methodName == VM_MagicNames.getCharAtOffset) {      popInt(T1);   // pop offset      popAddr(T0);   // pop object      asm.emitLHZX(T0, T1, T0);   // load char with zero extension.      pushInt(T0);    // push *(object+offset)     } else if (methodName == VM_MagicNames.setIntAtOffset){      popInt(T2); // pop newvalue      popInt(T1); // pop offset      popAddr(T0); // pop object      asm.emitSTWX(T2, T1, T0); // *(object+offset) = newvalue    } else if (methodName == VM_MagicNames.setObjectAtOffset ||               methodName == VM_MagicNames.setWordAtOffset) {      if (methodToBeCalled.getParameterTypes().length == 4) {        discardSlot(); // discard locationMetadata parameter      }      popAddr(T2); // pop newvalue      popInt(T1); // pop offset      popAddr(T0); // pop object      asm.emitSTAddrX(T2, T1, T0); // *(object+offset) = newvalue    } else if (methodName == VM_MagicNames.setByteAtOffset) {      popInt(T2); // pop newvalue      popInt(T1); // pop offset      popAddr(T0); // pop object      asm.emitSTBX(T2, T1, T0); // *(object+offset) = newvalue    } else if (methodName == VM_MagicNames.setCharAtOffset) {      popInt(T2); // pop newvalue      popInt(T1); // pop offset      popAddr(T0); // pop object      asm.emitSTHX(T2, T1, T0); // *(object+offset) = newvalue    } else if (methodName == VM_MagicNames.getLongAtOffset ||               methodName == VM_MagicNames.getDoubleAtOffset) {      popInt(T2); // pop offset      popAddr(T1); // pop object      asm.emitLFDX (F0, T1, T2);       pushDouble(F0);    } else if ((methodName == VM_MagicNames.setLongAtOffset)                || (methodName == VM_MagicNames.setDoubleAtOffset)) {      popLong(T3, T2);        popInt(T1); // pop offset      popAddr(T0); // pop object      if (VM.BuildFor32Addr) {        asm.emitSTWX(T3, T1, T0); // *(object+offset) = newvalue low        asm.emitADDI(T1, BYTES_IN_INT, T1); // offset += 4        asm.emitSTWX(T2, T1, T0); // *(object+offset) = newvalue high      } else {        asm.emitSTDX(T2, T1, T0); // *(object+offset) = newvalue       }     } else if (methodName == VM_MagicNames.getMemoryInt){      popAddr(T0); // address      asm.emitLInt (T0,  0, T0); // *address      pushInt(T0); // *sp := *address    } else if (methodName == VM_MagicNames.getMemoryWord ||               methodName == VM_MagicNames.getMemoryAddress) {      popAddr(T0); // address      asm.emitLAddr(T0,  0, T0); // *address      pushAddr(T0); // *sp := *address    } else if (methodName == VM_MagicNames.setMemoryInt ){      popInt(T1); // value      popAddr(T0); // address      asm.emitSTW(T1,  0, T0); // *address := value    } else if (methodName == VM_MagicNames.setMemoryWord ||               methodName == VM_MagicNames.setMemoryAddress) {      if (methodToBeCalled.getParameterTypes().length == 3) {        discardSlot(); // discard locationMetadata parameter      }      popAddr(T1); // value      popAddr(T0); // address      asm.emitSTAddr(T1,  0, T0); // *address := value    } else if (methodName == VM_MagicNames.prepareInt){      popInt(T1); // pop offset      popAddr(T0); // pop object      asm.emitLWARX(T0,  T1, T0); // *(object+offset), setting processor's reservation address      // this Integer is not sign extended !!      pushInt(T0); // push *(object+offset)    } else if (methodName == VM_MagicNames.prepareObject ||               methodName == VM_MagicNames.prepareAddress ||               methodName == VM_MagicNames.prepareWord) {      popInt(T1); // pop offset      popAddr(T0); // pop object      if (VM.BuildFor32Addr) {        asm.emitLWARX(T0,  T1, T0); // *(object+offset), setting processor's reservation address      } else {        asm.emitLDARX(T0, T1, T0);      }      pushAddr(T0); // push *(object+offset)    } else if (methodName == VM_MagicNames.attemptInt){      popInt(T2);  // pop newValue      discardSlot(); // ignore oldValue      popInt(T1);  // pop offset      popAddr(T0);  // pop object      asm.emitSTWCXr(T2,  T1, T0); // store new value and set CR0      asm.emitLVAL(T0,  0);  // T0 := false      VM_ForwardReference fr = asm.emitForwardBC(NE); // skip, if store failed      asm.emitLVAL(T0,  1);   // T0 := true      fr.resolve(asm);      pushInt(T0);  // push success of conditional store    } else if (methodName == VM_MagicNames.attemptObject ||               methodName == VM_MagicNames.attemptAddress ||               methodName == VM_MagicNames.attemptObjectReference ||                methodName == VM_MagicNames.attemptWord) {      popAddr(T2);  // pop newValue      discardSlot(); // ignore oldValue      popInt(T1);  // pop offset      popAddr(T0);  // pop object      if (VM.BuildFor32Addr) {        asm.emitSTWCXr(T2,  T1, T0); // store new value and set CR0      } else {        asm.emitSTDCXr(T2,  T1, T0); // store new value and set CR0      }      asm.emitLVAL(T0, 0);  // T0 := false      VM_ForwardReference fr = asm.emitForwardBC(NE); // skip, if store failed      asm.emitLVAL(T0, 1);   // T0 := true      fr.resolve(asm);      pushInt(T0);  // push success of conditional store    } else if (methodName == VM_MagicNames.saveThreadState) {      peekAddr(T0, 0); // T0 := address of VM_Registers object      asm.emitLAddrToc(S0, VM_Entrypoints.saveThreadStateInstructionsField.getOffset());      asm.emitMTCTR(S0);      asm.emitBCCTRL(); // call out of line machine code      discardSlot();  // pop arg    } else if (methodName == VM_MagicNames.threadSwitch) {      peekAddr(T1, 0); // T1 := address of VM_Registers of new thread      peekAddr(T0, 1); // T0 := address of previous VM_Thread object      asm.emitLAddrToc(S0, VM_Entrypoints.threadSwitchInstructionsField.getOffset());      asm.emitMTCTR(S0);      asm.emitBCCTRL();      discardSlots(2);  // pop two args    } else if (methodName == VM_MagicNames.restoreHardwareExceptionState) {      peekAddr(T0, 0); // T0 := address of VM_Registers object      asm.emitLAddrToc(S0, VM_Entrypoints.restoreHardwareExceptionStateInstructionsField.getOffset());      asm.emitMTLR(S0);      asm.emitBCLR(); // branch to out of line machine code (does not return)    } else if (methodName == VM_MagicNames.returnToNewStack) {      peekAddr(FP, 0);                                  // FP := new stackframe      asm.emitLAddr(S0, STACKFRAME_NEXT_INSTRUCTION_OFFSET, FP); // fetch...      asm.emitMTLR(S0);                                         // ...return address      asm.emitBCLR ();                                           // return to caller    } else if (methodName == VM_MagicNames.dynamicBridgeTo) {      if (VM.VerifyAssertions) VM._assert(klass.isDynamicBridge());               // fetch parameter (address to branch to) into CT register      //      peekAddr(T0, 0);      asm.emitMTCTR(T0);      // restore volatile and non-volatile registers      // (note that these are only saved for "dynamic bridge" methods)      //      int offset = frameSize;      // restore non-volatile and volatile fprs      for (int i = LAST_NONVOLATILE_FPR; i >= FIRST_VOLATILE_FPR; --i)        asm.emitLFD(i, offset -= BYTES_IN_DOUBLE, FP);            // restore non-volatile gprs      for (int i = LAST_NONVOLATILE_GPR; i >= FIRST_NONVOLATILE_GPR; --i)        asm.emitLAddr(i, offset -= BYTES_IN_ADDRESS, FP);                  // skip saved thread-id, processor, and scratch registers      offset -= (FIRST_NONVOLATILE_GPR - LAST_VOLATILE_GPR - 1) * BYTES_IN_ADDRESS;               // restore volatile gprs      for (int i = LAST_VOLATILE_GPR; i >= FIRST_VOLATILE_GPR; --i)        asm.emitLAddr(i, offset -= BYTES_IN_ADDRESS, FP);                // pop stackframe      asm.emitLAddr(FP, 0, FP);               // restore link register      asm.emitLAddr(S0, STACKFRAME_NEXT_INSTRUCTION_OFFSET, FP);      asm.emitMTLR(S0);      asm.emitBCCTR(); // branch always, through count register    } else if (methodName == VM_MagicNames.objectAsAddress         ||               methodName == VM_MagicNames.addressAsByteArray      ||               methodName == VM_MagicNames.addressAsIntArray       ||               methodName == VM_MagicNames.addressAsObject         ||               methodName == VM_MagicNames.addressAsObjectArray    ||               methodName == VM_MagicNames.addressAsType           ||               methodName == VM_MagicNames.objectAsType            ||               methodName == VM_MagicNames.objectAsByteArray       ||               methodName == VM_MagicNames.objectAsShortArray      ||               methodName == VM_MagicNames.objectAsIntArray        ||               methodName == VM_MagicNames.addressAsThread         ||               methodName == VM_MagicNames.objectAsThread          ||               methodName == VM_MagicNames.objectAsProcessor       ||               methodName == VM_MagicNames.threadAsCollectorThread ||               methodName == VM_MagicNames.addressAsRegisters      ||               methodName == VM_MagicNames.addressAsStack          ||               methodName == VM_MagicNames.floatAsIntBits          ||               methodName == VM_MagicNames.intBitsAsFloat          ||               methodName == VM_MagicNames.doubleAsLongBits        ||               methodName == VM_MagicNames.longBitsAsDouble) {      // no-op (a type change, not a representation change)    } else if (methodName == VM_MagicNames.getObjectType) {      popAddr(T0);                   // get object pointer      VM_ObjectModel.baselineEmitLoadTIB(asm,T0,T0);      asm.emitLAddr(T0,  TIB_TYPE_INDEX << LOG_BYTES_IN_ADDRESS, T0); // get "type" field from type information block      pushAddr(T0);                   // *sp := type    } else if (methodName == VM_MagicNames.getArrayLength) {      popAddr(T0);                   // get object pointer      asm.emitLIntOffset(T0, T0, VM_ObjectModel.getArrayLengthOffset()); // get array length field      pushInt(T0);                   // *sp := length    } else if (methodName == VM_MagicNames.sync) {      asm.emitSYNC();    } else if (methodName == VM_MagicNames.isync) {      asm.emitISYNC();    } else if (methodName == VM_MagicNames.dcbst) {      popAddr(T0);    // address      asm.emitDCBST(0, T0);    } else if (methodName == VM_MagicNames.dcbt) {      popAddr(T0);    // address      asm.emitDCBT(0, T0);    } else if (methodName == VM_MagicNames.dcbtst) {      popAddr(T0);    // address      asm.emitDCBTST(0, T0);    } else if (methodName == VM_MagicNames.dcbz) {      popAddr(T0);    // address      asm.emitDCBZ(0, T0);    } else if (methodName == VM_MagicNames.dcbzl) {      popAddr(T0);    // address      asm.emitDCBZL(0, T0);    } else if (methodName == VM_MagicNames.icbi) {      popAddr(T0);    // address      asm.emitICBI(0, T0);    } else if (methodName == VM_MagicNames.wordToInt ||                methodName == VM_MagicNames.wordToAddress ||               methodName == VM_MagicNames.wordToOffset ||               methodName == VM_MagicNames.wordToObject ||               methodName == VM_MagicNames.wordFromObject ||               methodName == VM_MagicNames.wordToObjectReference ||               methodName == VM_MagicNames.wordToExtent ||               methodName == VM_MagicNames.wordToWord) {      // no-op       } else if (methodName == VM_MagicNames.wordToLong) {      asm.emitLVAL(T0,0);      pushAddr(T0);    } else if (methodName == VM_MagicNames.wordFromInt ||               methodName == VM_MagicNames.wordFromIntSignExtend) {      if (VM.BuildFor64Addr) {        popInt(T0);        pushAddr(T0);      } // else no-op    } else if (methodName == VM_MagicNames.wordFromIntZeroExtend) {      if (VM.BuildFor64Addr) {        asm.emitLWZ(T0, spTopOffset + BYTES_IN_STACKSLOT - BYTES_IN_INT, FP);        pokeAddr(T0,0);      } // else no-op    } else if (methodName == VM_MagicNames.wordFromLong) {      discardSlot();    } else if (methodName == VM_MagicNames.wordPlus) {      if (VM.BuildFor64Addr && (methodToBeCalled.getParameterTypes()[0] == VM_TypeReference.Int)){        popInt(T0);      } else {        popAddr(T0);      }      popAddr(T1);      asm.emitADD (T2, T1, T0);      pushAddr(T2);    } else if (methodName == VM_MagicNames.wordMinus ||               methodName == VM_MagicNames.wordDiff) {      if (VM.BuildFor64Addr && (methodToBeCalled.getParameterTypes()[0] == VM_TypeReference.Int)){        popInt(T0);                } else {        popAddr(T0);                }      popAddr(T1);      asm.emitSUBFC (T2, T0, T1);      pushAddr(T2);    } else if (methodName == VM_MagicNames.wordEQ) {       generateAddrComparison(false, EQ);    } else if (methodName == VM_MagicNames.wordNE) {       generateAddrComparison(false, NE);    } else if (methodName == VM_MagicNames.wordLT) {      generateAddrComparison(false, LT);    } else if (methodName == VM_MagicNames.wordLE) {      generateAddrComparison(false, LE);     } else if (methodName == VM_MagicNames.wordGT) {      generateAddrComparison(false, GT);    } else if (methodName == VM_MagicNames.wordGE) {      generateAddrComparison(false, GE);    } else if (methodName == VM_MagicNames.wordsLT) {      generateAddrComparison(true, LT);    } else if (methodName == VM_MagicNames.wordsLE) {      generateAddrComparison(true, LE);     } else if (methodName == VM_MagicNames.wordsGT) {      generateAddrComparison(true, GT);    } else if (methodName == VM_MagicNames.wordsGE) {      generateAddrComparison(true, GE);    } else if (methodName == VM_MagicNames.wordIsZero ||               methodName == VM_MagicNames.wordIsNull) {      // unsigned comparison generating a boolean      asm.emitLVAL(T0,  0);      pushAddr(T0);      generateAddrComparison(false, EQ);    } else if (methodName == VM_MagicNames.wordIsMax) {      // unsigned comparison generating a boolean      asm.emitLVAL(T0, -1);      pushAddr(T0);      generateAddrComparison(false, EQ);    } else if (methodName == VM_MagicNames.wordZero ||               methodName == VM_MagicNames.wordNull) {      asm.emitLVAL (T0,  0);      pushAddr(T0);    } else if (methodName == VM_MagicNames.wordOne) {      asm.emitLVAL (T0,  1);      pushAddr(T0);    } else if (methodName == VM_MagicNames.wordMax) {      asm.emitLVAL (T0, -1);      pushAddr(T0);    } else if (methodName == VM_MagicNames.wordAnd) {      popAddr(T0);      popAddr(T1);      asm.emitAND(T2, T1, T0);      pushAddr(T2);    } else if (methodName == VM_MagicNames.wordOr) {      popAddr(T0);      popAddr(T1);      asm.emitOR (T2, T1, T0);      pushAddr(T2);    } else if (methodName == VM_MagicNames.wordNot) {      popAddr(T0);      asm.emitLVAL(T1, -1);      asm.emitXOR(T2, T1, T0);      pushAddr(T2);    } else if (methodName == VM_MagicNames.wordXor) {      popAddr(T0);      popAddr(T1);      asm.emitXOR(T2, T1, T0);      pushAddr(T2);    } else if (methodName == VM_MagicNames.wordLsh) {      popInt(T0);      popAddr(T1);           asm.emitSLAddr (T2, T1, T0);      pushAddr(T2);    } else if (methodName == VM_MagicNames.wordRshl) {      popInt(T0);      popAddr(T1);           asm.emitSRAddr (T2, T1, T0);      pushAddr(T2);    } else if (methodName == VM_MagicNames.wordRsha) {      popInt(T0);      popAddr(T1);           asm.emitSRA_Addr (T2, T1, T0);      pushAddr(T2);    } else {      return false;    }    return true;  }