if (VM.VerifyAssertions) VM.assert(t.beingDispatched == false || t == VM_Thread.getCurrentThread());
if (VM.VerifyAssertions) VM._assert(t.beingDispatched == false || t == VM_Thread.getCurrentThread());
  private VM_Thread getRunnableThread() throws VM_PragmaInline {    int loopcheck = 0;    for (int i=transferQueue.length(); 0<i; i--) {      transferMutex.lock();      VM_Thread t = transferQueue.dequeue();      transferMutex.unlock();      if (t.isGCThread){        if (trace) VM_Scheduler.trace("VM_Processor", "getRunnableThread: collector thread", t.getIndex());        return t;      } else 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());        transferMutex.lock();        transferQueue.enqueue(t);        transferMutex.unlock();        if (processorMode == NATIVE) {          // increase loop counter so this thread will be looked at           // again - isbeingdispatched goes off when dispatcher stops          // running on the RVM processor, using this thread's stack.          // RARE CASE: the stuck thread has returned from this native          // processor, but being dispatched in the nativeidlethread has not          // yet gone off because its stack is still being used by dispatcher          // on the RVM	          i++;          if (loopcheck++ >= 1000000) break;          if (VM.VerifyAssertions) VM.assert (t.isNativeIdleThread);        }      } else {        if (trace) VM_Scheduler.trace("VM_Processor", "getRunnableThread: transfer to readyQueue", t.getIndex());        readyQueue.enqueue(t);      }    }    if ((epoch % VM_Scheduler.numProcessors) + 1 == id) {      // it's my turn to check the io queue early to avoid starvation      // of threads in io wait.      // We round robin this among the virtual processors to avoid serializing      // thread switching in the call to select.      if (ioQueue.isReady()) {        VM_Thread t = ioQueue.dequeue();        if (trace) VM_Scheduler.trace("VM_Processor", "getRunnableThread: ioQueue (early)", t.getIndex());        if (VM.VerifyAssertions) VM.assert(t.beingDispatched == false || t == VM_Thread.getCurrentThread()); // local queue: no other dispatcher should be running on thread's stack        return t;      }    }    if (!readyQueue.isEmpty()) {      VM_Thread t = readyQueue.dequeue();      if (trace) VM_Scheduler.trace("VM_Processor", "getRunnableThread: readyQueue", t.getIndex());      if (VM.VerifyAssertions) VM.assert(t.beingDispatched == false || t == VM_Thread.getCurrentThread()); // local queue: no other dispatcher should be running on thread's stack      return t;    }    if (ioQueue.isReady()) {      VM_Thread t = ioQueue.dequeue();      if (trace) VM_Scheduler.trace("VM_Processor", "getRunnableThread: ioQueue", t.getIndex());      if (VM.VerifyAssertions) VM.assert(t.beingDispatched == false || t == VM_Thread.getCurrentThread()); // local queue: no other dispatcher should be running on thread's stack      return t;    }    if (!idleQueue.isEmpty()) {      VM_Thread t = idleQueue.dequeue();      if (trace) VM_Scheduler.trace("VM_Processor", "getRunnableThread: idleQueue", t.getIndex());      if (VM.VerifyAssertions) VM.assert(t.beingDispatched == false || t == VM_Thread.getCurrentThread()); // local queue: no other dispatcher should be running on thread's stack      return t;    }    VM.assert(VM.NOT_REACHED); // should never get here (the idle thread should always be: running, on the idleQueue, or (maybe) on the transferQueue)    return null;  }  //-----------------//  //  Load Balancing //  //-----------------//  /**   * Add a thread to this processor's transfer queue.   */   private void transferThread (VM_Thread t) {    if (this != getCurrentProcessor() || t.isGCThread || (t.beingDispatched && t != VM_Thread.getCurrentThread())) {      transferMutex.lock();      transferQueue.enqueue(t);      transferMutex.unlock();    } else if (t.isIdleThread) {