asm.emitLAddr (T2, VM_Entrypoints.the_boot_recordField.getOffset(), JTOC); asm.emitLAddr (JTOC, VM_Entrypoints.sysTOCField.getOffset(), T2); asm.emitLAddr (T1,   VM_Entrypoints.sysVirtualProcessorYieldIPField.getOffset(), T2);
asm.emitLAddr (T2, VM_Entrypoints.the_boot_recordField.getOffsetAsInt(), JTOC); asm.emitLAddr (JTOC, VM_Entrypoints.sysTOCField.getOffsetAsInt(), T2); asm.emitLAddr (T1,   VM_Entrypoints.sysVirtualProcessorYieldIPField.getOffsetAsInt(), T2);
  private static VM_CodeArray generateInvokeNativeFunctionInstructions() {    VM_Assembler asm = new VM_Assembler(0);    // move native code address to CTR reg;    // do this early so that S1 will be available as a scratch.    asm.emitMTCTR (S1);     //    // store the return address to the Java to C glue prolog, which is now in LR    // into transition frame. If GC occurs, the JNIGCMapIterator will cause    // this ip address to be relocated if the generated glue code is moved.    //    asm.emitLAddr (S1, 0, FP);    asm.emitMFLR  (T0);    //-#if RVM_WITH_SVR4_ABI || RVM_WITH_MACH_O_ABI    // save return address of JNI method in mini frame (2)    asm.emitSTAddr(T0, STACKFRAME_NEXT_INSTRUCTION_OFFSET, S1);    //-#endif    //-#if RVM_WITH_POWEROPEN_ABI    // save return address in stack frame    asm.emitSTAddr(T0, -JNI_PROLOG_RETURN_ADDRESS_OFFSET, S1);    //-#endif    //    // Load required JNI function ptr into first parameter reg (GPR3/T0)    // This pointer is an interior pointer to the VM_JNIEnvironment which is    // currently in S0.    //    asm.emitADDI (T0, VM_Entrypoints.JNIExternalFunctionsField.getOffset(), S0);    //    // change the vpstatus of the VP to IN_NATIVE    //    asm.emitLAddr(PROCESSOR_REGISTER, VM_Entrypoints.JNIEnvSavedPRField.getOffset(), S0);       asm.emitLVAL (S0,  VM_Processor.IN_NATIVE);    asm.emitSTW  (S0,  VM_Entrypoints.vpStatusField.getOffset(), PROCESSOR_REGISTER);     //     // CALL NATIVE METHOD    //     asm.emitBCCTRL();    // save the return value in R3-R4 in the glue frame spill area since they may be overwritten    // if we have to call sysVirtualProcessorYield because we are locked in native.    if (VM.BuildFor64Addr) {      asm.emitSTD   (T0, NATIVE_FRAME_HEADER_SIZE, FP);    } else {      asm.emitSTW   (T0, NATIVE_FRAME_HEADER_SIZE, FP);      asm.emitSTW   (T1, NATIVE_FRAME_HEADER_SIZE+BYTES_IN_ADDRESS, FP);    }    //    // try to return virtual processor to vpStatus IN_JAVA    //    int label1 = asm.getMachineCodeIndex();    asm.emitLAddr (S0, 0, FP);                            // get previous frame    //-#if RVM_WITH_SVR4_ABI || RVM_WITH_MACH_O_ABI    // mimi (1) FP -> mimi(2) FP -> java caller    asm.emitLAddr (S0, 0, S0);    //-#endif    asm.emitLAddr (PROCESSOR_REGISTER, - JNI_ENV_OFFSET, S0);   // load VM_JNIEnvironment    asm.emitLAddr (JTOC, VM_Entrypoints.JNIEnvSavedJTOCField.getOffset(), PROCESSOR_REGISTER);      // load JTOC    asm.emitLAddr (PROCESSOR_REGISTER, VM_Entrypoints.JNIEnvSavedPRField.getOffset(), PROCESSOR_REGISTER); // load PR    asm.emitLVAL  (S1, VM_Entrypoints.vpStatusField.getOffset());    asm.emitLWARX (S0, S1, PROCESSOR_REGISTER);                 // get status for processor    asm.emitCMPI  (S0, VM_Processor.BLOCKED_IN_NATIVE);         // are we blocked in native code?    VM_ForwardReference fr = asm.emitForwardBC(NE);    //    // if blocked in native, call C routine to do pthread_yield    //    asm.emitLAddr (T2, VM_Entrypoints.the_boot_recordField.getOffset(), JTOC);  // T2 gets boot record address    asm.emitLAddr (JTOC, VM_Entrypoints.sysTOCField.getOffset(), T2);           // load TOC for syscalls from bootrecord    asm.emitLAddr (T1,   VM_Entrypoints.sysVirtualProcessorYieldIPField.getOffset(), T2);  // load addr of function    asm.emitMTLR  (T1);    asm.emitBCLRL ();                                          // call sysVirtualProcessorYield in sys.C    asm.emitB     (label1);                                    // retest the attempt to change status to IN_JAVAE    //    //  br to here -not blocked in native    //    fr.resolve(asm);    asm.emitLVAL  (S0,  VM_Processor.IN_JAVA);               // S0  <- new state value    asm.emitSTWCXr(S0,  S1, PROCESSOR_REGISTER);             // attempt to change state to java    asm.emitBC    (NE, label1);                              // br if failure -retry lwarx    //    // return to caller    //    asm.emitLAddr  (S0, 0 , FP);                                // get previous frame    //-#if RVM_WITH_SVR4_ABI || RVM_WITH_MACH_O_ABI    asm.emitLAddr(S0, STACKFRAME_NEXT_INSTRUCTION_OFFSET, S0);    //-#endif    //-#if RVM_WITH_POWEROPEN_ABI    asm.emitLAddr(S0, -JNI_PROLOG_RETURN_ADDRESS_OFFSET, S0); // get return address from stack frame    //-#endif    asm.emitMTLR  (S0);    asm.emitBCLR   ();    return asm.makeMachineCode().getInstructions();  }