if ( ! VM_Thread.getCurrentThread().isNativeIdleThread ) { while(t.beingDispatched && t != VM_Thread.getCurrentThread()){ VM_Magic.isync(); } return t; } else transferQueue.enqueue(t);
  private VM_Thread getRunnableThread() {    VM_Magic.pragmaInline();    if (!transferQueue.isEmpty()) {      transferMutex.lock();      VM_Thread t = transferQueue.dequeue();      if (t.beingDispatched && t != VM_Thread.getCurrentThread()) {         // thread's stack in use by some OTHER dispatcher	if (trace)           VM_Scheduler.trace("VM_Processor",                              "getRunnableThread: stack in use", t.getIndex());	///	transferQueue.enqueue(t);	transferMutex.unlock();	// for default jni implementation - if running is stack         // of a native idle thread, do not spinwait here,	// instead proceed on to other threads, the idle thread if         // necessary, to free	// up the native idle thread so it can be dispatched on its         // native processor	// confused? ask steve & dick.	if ( ! VM_Thread.getCurrentThread().isNativeIdleThread ) {	  while(t.beingDispatched && t != VM_Thread.getCurrentThread()){	    VM_Magic.isync();	  }	  return t;	}	else 	  transferQueue.enqueue(t);      } else {	if (trace)           VM_Scheduler.trace("VM_Processor",                              "getRunnableThread: transferQueue", t.getIndex());	transferMutex.unlock();	return t;      }    }    if (!readyQueue.isEmpty()) {      VM_Thread t = readyQueue.dequeue();      if (trace)         VM_Scheduler.trace("VM_Processor",                            "getRunnableThread: readyQueue", t.getIndex());      if (VM.VerifyAssertions)         // local queue: no other dispatcher should be running on thread's stack        VM_Scheduler.assert(t.beingDispatched == false ||                             t == VM_Thread.getCurrentThread());       return t;    }    if (ioQueue.isReady()) {      VM_Thread t = ioQueue.dequeue();      if (trace)         VM_Scheduler.trace("VM_Processor",                            "getRunnableThread: ioQueue", t.getIndex());      if (VM.VerifyAssertions)         // local queue: no other dispatcher should be running on thread's stack        VM_Scheduler.assert(t.beingDispatched == false ||                             t == VM_Thread.getCurrentThread());       return t;    }    if ( ! VM_Thread.getCurrentThread().isNativeIdleThread ) {      // recheck the transfer queue- if entry "being dispatch" spin      //      if(!transferQueue.isEmpty()){	transferMutex.lock();	VM_Thread t = transferQueue.dequeue();	transferMutex.unlock();	while(t.beingDispatched && t != VM_Thread.getCurrentThread()){	  VM_Magic.isync();	}        return t;        }    }    if (!idleQueue.isEmpty()) {      VM_Thread t = idleQueue.dequeue();      if (trace)         VM_Scheduler.trace("VM_Processor",                            "getRunnableThread: idleQueue", t.getIndex());      if (VM.VerifyAssertions)         // local queue: no other dispatcher should be running on thread's stack        VM_Scheduler.assert(t.beingDispatched == false ||                             t == VM_Thread.getCurrentThread());       return t;    }    // if the idle thread isn't on the idle queue,     // it must be on the transfer queue    if (!transferQueue.isEmpty()) {      transferMutex.lock();      VM_Thread t = transferQueue.dequeue();      while (t.beingDispatched && t != VM_Thread.getCurrentThread()) {         // thread's stack in use by some OTHER dispatcher        if (trace) VM_Scheduler.trace("VM_Processor",                                       "getRunnableThread: stack in use",                                       t.getIndex());	transferQueue.enqueue(t);	t = transferQueue.dequeue();      }       if (trace) VM_Scheduler.trace("VM_Processor",                                     "getRunnableThread: transferQueue",                                     t.getIndex());      transferMutex.unlock();      return t;    }    debugGetRunnableThread(); // should not get here    VM_Scheduler.assert(VM.NOT_REACHED);    return null;  }