stuckEnv.savedPRreg = native_vp; VM_Address topJavaFP = stuckEnv.JNITopJavaFP;
stuckEnv.setSavedPRreg( native_vp ); VM_Address topJavaFP = stuckEnv.topJavaFP();
  void switchPThread (VM_Processor stuck_vp, VM_Processor native_vp) {    if (trace) {      VM_Scheduler.trace("NDT","Entering switchPThread");      VM_Scheduler.trace("NDT","switchPThread - stuck_vp =",stuck_vp.id);      stuck_vp.dumpProcessorState();      VM_Scheduler.trace("NDT","switchPThread - native_vp =",native_vp.id);      native_vp.dumpProcessorState();    }    // give the new (native) processor the status word of the old (stuck) processor    // briefly, both processors have the "BLOCKED_IN_NATIVE" status word, until    // the stuck thread is switched to the new processor.    //    VM_Address tempStatusAddress = native_vp.vpStatusAddress;    int tempStatusIndex   = native_vp.vpStatusIndex;    native_vp.vpStatusAddress = stuck_vp.vpStatusAddress;    native_vp.vpStatusIndex   = stuck_vp.vpStatusIndex;    // sync these changes - before changing processor of stuck thread    // to ensure stuck thread continues to see BLOCKED_IN_NATIVE    //    VM_Magic.sync();    // switch saved Processor refs in stuck threads JNIEnvironment & java to C     // glue stack frame to point to the new (native) processor    //    VM_Thread stuckThread = stuck_vp.activeThread;    VM_JNIEnvironment stuckEnv = stuckThread.getJNIEnv();if (stuckEnv == null) {      VM_Scheduler.trace("NDT","Entering switchPThread");      VM_Scheduler.trace("NDT","switchPThread - stuck_vp =",stuck_vp.id);      stuck_vp.dumpProcessorState();      VM_Scheduler.trace("NDT","switchPThread - native_vp =",native_vp.id);      native_vp.dumpProcessorState();			VM.sysFail("quitting in switchpthread");}    stuckEnv.savedPRreg = native_vp;    VM_Address topJavaFP = stuckEnv.JNITopJavaFP;//-#if RVM_FOR_IA32    VM_Magic.setMemoryAddress(topJavaFP.add(VM_JNICompiler.JNI_PR_OFFSET), VM_Magic.objectAsAddress(native_vp));//-#else     VM_Address callerFP  = VM_Magic.getMemoryAddress(topJavaFP);    VM_Magic.setMemoryAddress(callerFP.sub(JNI_PR_OFFSET), VM_Magic.objectAsAddress(native_vp));//-#endif     // active thread of native vp should be its NativeIdleThread    if (VM.VerifyAssertions) VM._assert( native_vp.activeThread.isNativeIdleThread == true );    // switch active threads on the two processors    VM_NativeIdleThread nativeIdleThread = (VM_NativeIdleThread) native_vp.activeThread;    native_vp.activeThread  = stuckThread;    stuck_vp.activeThread  = nativeIdleThread;/// new line below    stuck_vp.threadSwitchRequested = 0; // reset    int temp = native_vp.pthread_id;    native_vp.pthread_id = stuck_vp.pthread_id;     stuck_vp.pthread_id = temp; //-#if RVM_FOR_IA32    temp = native_vp.threadId;    native_vp.threadId = stuck_vp.threadId;     stuck_vp.threadId = temp; //-#endif     // set return affinity of stuck thread to original (blue/old) processor    stuckThread.returnAffinity = stuck_vp;    // set field in nativeIdleThread to tell it which processor it has migrated to    // it will use this to update its processor reg after being signalled    nativeIdleThread.blockedProcessor = stuck_vp;    // sync again, to ensure stuck thread sees its new processor, before    // switching the old processors status word to that of the native    // processor (with status = IN_SIGWAIT)    VM_Magic.sync();    // now complete the swap of status words    stuck_vp.vpStatusAddress = tempStatusAddress;    stuck_vp.vpStatusIndex   = tempStatusIndex;    if (trace) {      VM_Scheduler.trace("NDT","Leaving switchPThread");      VM_Scheduler.trace("NDT","switchPThread - stuck_vp =",stuck_vp.id);      stuck_vp.dumpProcessorState();      VM_Scheduler.trace("NDT","switchPThread - native_vp =",native_vp.id);      native_vp.dumpProcessorState();    }  }  // switchPThread