VM_RuntimeMeasurements.takeTimerSample(whereFrom);
if (VM.BuildForAdaptiveSystem) { VM_RuntimeMeasurements.takeTimerSample(whereFrom); }
  public static void yieldpoint(int whereFrom) {     boolean threadSwitch = false;    int takeYieldpointVal = VM_Processor.getCurrentProcessor().takeYieldpoint;    VM_Processor.getCurrentProcessor().takeYieldpoint = 0;        //-#if RVM_FOR_POWERPC    // Process request for code-patch memory sync operation    if (VM_Processor.getCurrentProcessor().codePatchSyncRequested) {      VM_Processor.getCurrentProcessor().codePatchSyncRequested = false;      // TODO: Is this sufficient? Ask Steve why we don't need to sync icache/dcache. --dave      // make sure not get stale data      VM_Magic.isync();      VM_Synchronization.fetchAndDecrement(VM_Magic.getJTOC(), VM_Entrypoints.toSyncProcessorsField.getOffset(), 1);    }    //-#endif    // If thread is in critical section we can't switch right now, defer until later    if (!VM_Processor.getCurrentProcessor().threadSwitchingEnabled()) {       if (VM_Processor.getCurrentProcessor().threadSwitchPending != 1) {        VM_Processor.getCurrentProcessor().threadSwitchPending = takeYieldpointVal;      }      return;    }    // Process timer interrupt event    if (VM_Processor.getCurrentProcessor().timeSliceExpired != 0) {      VM_Processor.getCurrentProcessor().timeSliceExpired = 0;            if (VM.CBSCallSamplesPerTick > 0) {        VM_Processor.getCurrentProcessor().yieldForCBSCall = true;        VM_Processor.getCurrentProcessor().takeYieldpoint = -1;        VM_Processor.getCurrentProcessor().firstCBSCallSample = (++VM_Processor.getCurrentProcessor().firstCBSCallSample) % VM.CBSCallSampleStride;        VM_Processor.getCurrentProcessor().countdownCBSCall = VM_Processor.getCurrentProcessor().firstCBSCallSample;        VM_Processor.getCurrentProcessor().numCBSCallSamples = VM.CBSCallSamplesPerTick;      }            if (VM.CBSMethodSamplesPerTick > 0) {        VM_Processor.getCurrentProcessor().yieldForCBSMethod = true;        VM_Processor.getCurrentProcessor().takeYieldpoint = -1;        VM_Processor.getCurrentProcessor().firstCBSMethodSample = (++VM_Processor.getCurrentProcessor().firstCBSMethodSample) % VM.CBSMethodSampleStride;        VM_Processor.getCurrentProcessor().countdownCBSMethod = VM_Processor.getCurrentProcessor().firstCBSMethodSample;        VM_Processor.getCurrentProcessor().numCBSMethodSamples = VM.CBSMethodSamplesPerTick;      }            if (++VM_Processor.getCurrentProcessor().interruptQuantumCounter >= VM.schedulingMultiplier) {        threadSwitch = true;        VM_Processor.getCurrentProcessor().interruptQuantumCounter = 0;        // Check various scheduling requests/queues that need to be polled periodically        if (VM_Scheduler.debugRequested && VM_Scheduler.allProcessorsInitialized) {           // service "debug request" generated by external signal          VM_Scheduler.debuggerMutex.lock();          if (VM_Scheduler.debuggerQueue.isEmpty()) {             // debugger already running            VM_Scheduler.debuggerMutex.unlock();          } else { // awaken debugger            VM_Thread t = VM_Scheduler.debuggerQueue.dequeue();            VM_Scheduler.debuggerMutex.unlock();            t.schedule();          }        }        if (VM_Scheduler.wakeupQueue.isReady()) {          VM_Scheduler.wakeupMutex.lock();          VM_Thread t = VM_Scheduler.wakeupQueue.dequeue();          VM_Scheduler.wakeupMutex.unlock();          if (t != null) {            t.schedule();          }        }      }      //-#if RVM_WITH_ADAPTIVE_SYSTEM      VM_RuntimeMeasurements.takeTimerSample(whereFrom);      //-#endif      if (threadSwitch && (VM_Processor.getCurrentProcessor().yieldForCBSMethod ||			   VM_Processor.getCurrentProcessor().yieldForCBSCall)) {        // want to sample the current thread, not the next one to be scheduled        // So, defer actual threadswitch until we take all of our samples        VM_Processor.getCurrentProcessor().threadSwitchWhenCBSComplete = true;        threadSwitch = false;      }      //-#if RVM_WITH_ADAPTIVE_SYSTEM      threadSwitch |= OSR_Listener.checkForOSRPromotion(whereFrom);      //-#endif      if (threadSwitch) {        VM_Processor.getCurrentProcessor().yieldForCBSMethod = false;        VM_Processor.getCurrentProcessor().yieldForCBSCall = false;         VM_Processor.getCurrentProcessor().threadSwitchWhenCBSComplete = false;      }            }    if (VM_Processor.getCurrentProcessor().yieldForCBSCall) {      if (!(whereFrom == BACKEDGE || whereFrom == OSROPT)) {        if (--VM_Processor.getCurrentProcessor().countdownCBSCall <= 0) {          // take CBS sample          //-#if RVM_WITH_ADAPTIVE_SYSTEM          VM_RuntimeMeasurements.takeCBSCallSample(whereFrom);          //-#endif          VM_Processor.getCurrentProcessor().countdownCBSCall = VM.CBSCallSampleStride;          VM_Processor.getCurrentProcessor().numCBSCallSamples--;          if (VM_Processor.getCurrentProcessor().numCBSCallSamples <= 0) {            VM_Processor.getCurrentProcessor().yieldForCBSCall = false;            if (!VM_Processor.getCurrentProcessor().yieldForCBSMethod) {              VM_Processor.getCurrentProcessor().threadSwitchWhenCBSComplete = false;              threadSwitch = true;            }                    }        }      }      if (VM_Processor.getCurrentProcessor().yieldForCBSCall) {        VM_Processor.getCurrentProcessor().takeYieldpoint = -1;      }    }        if (VM_Processor.getCurrentProcessor().yieldForCBSMethod) {      if (--VM_Processor.getCurrentProcessor().countdownCBSMethod <= 0) {        // take CBS sample        //-#if RVM_WITH_ADAPTIVE_SYSTEM        VM_RuntimeMeasurements.takeCBSMethodSample(whereFrom);        //-#endif        VM_Processor.getCurrentProcessor().countdownCBSMethod = VM.CBSMethodSampleStride;        VM_Processor.getCurrentProcessor().numCBSMethodSamples--;        if (VM_Processor.getCurrentProcessor().numCBSMethodSamples <= 0) {          VM_Processor.getCurrentProcessor().yieldForCBSMethod = false;          if (!VM_Processor.getCurrentProcessor().yieldForCBSCall) {            VM_Processor.getCurrentProcessor().threadSwitchWhenCBSComplete = false;            threadSwitch = true;          }        }      }      if (VM_Processor.getCurrentProcessor().yieldForCBSMethod) {        VM_Processor.getCurrentProcessor().takeYieldpoint = 1;      }    }        // Process request to initiate GC by forcing a thread switch.    if (VM_Processor.getCurrentProcessor().yieldToGCRequested) {      VM_Processor.getCurrentProcessor().yieldToGCRequested = false;      VM_Processor.getCurrentProcessor().yieldForCBSCall = false;      VM_Processor.getCurrentProcessor().yieldForCBSMethod = false;      VM_Processor.getCurrentProcessor().threadSwitchWhenCBSComplete = false;      VM_Processor.getCurrentProcessor().takeYieldpoint = 0;      threadSwitch = true;    }        if (VM_Processor.getCurrentProcessor().yieldToOSRRequested) {      VM_Processor.getCurrentProcessor().yieldToOSRRequested = false;      //-#if RVM_WITH_ADAPTIVE_SYSTEM      OSR_Listener.handleOSRFromOpt();      //-#endif      threadSwitch = true;    }    if (threadSwitch) {      timerTickYield(whereFrom);    }    VM_Thread myThread = getCurrentThread();    if (myThread.isWaitingForOsr) {      OSR_PostThreadSwitch.postProcess(myThread);    }  }