sampleNumber++;
  public final void update(int cmid, int callerCmid, int whereFrom) {    if (callerCmid != -1) {      if (VM_ClassLoader.getCompiledMethod(callerCmid) == null) {	VM.sysWrite("MethodListener.update: callerCmid (");	VM.sysWrite(callerCmid, false);	VM.sysWrite(") is null, exiting\n");	VM.sysWrite("nextIndex: ");	VM.sysWrite(nextIndex, false);	VM.sysWrite("\n");	throw new RuntimeException();      }    }    if (VM_ClassLoader.getCompiledMethod(cmid) == null) {      VM.sysWrite("MethodListener.update: cmid (");      VM.sysWrite(cmid, false);      VM.sysWrite(") is null, exiting\n");      VM.sysWrite("numSamples: ");      VM.sysWrite(numSamples, false);      VM.sysWrite("\n");      throw new RuntimeException();    }        int idx;    int sampleNumber=-1; // the sample number of our insertion    if (VM.UseEpilogueYieldPoints) {      // New scheme: Use epilogue yieldpoints.  We increment one sample      // for every yieldpoint.  On a prologue, we count the caller.      // On backedges and epilogues, we count the current method.      if (whereFrom == VM_Thread.PROLOGUE) { 	idx = VM_Synchronization.fetchAndAdd(this, nextIndexOffset, 1);	if (idx < sampleSize && callerCmid != -1) { 	  samples[idx] = callerCmid; 	  sampleNumber = VM_Synchronization.fetchAndAdd(this, 							numSamplesOffset, 1);        }      } else {         // loop backedge or epilogue.   	idx = VM_Synchronization.fetchAndAdd(this, nextIndexOffset, 1);	if (idx < sampleSize) { 	  samples[idx] = cmid; 	  sampleNumber = VM_Synchronization.fetchAndAdd(this, 							numSamplesOffset, 1);        }      }    } else {      // Original scheme: No epilogue yieldpoints.  We increment two samples      // for every yieldpoint.  On a prologue, we count both the caller      // and callee.  On backedges, we count the current method twice.      if (whereFrom == VM_Thread.PROLOGUE) {        // Increment both for this method and the caller 	idx = VM_Synchronization.fetchAndAdd(this, nextIndexOffset, 1);	if (idx < sampleSize) { 	  samples[idx] = cmid; 	  sampleNumber = VM_Synchronization.fetchAndAdd(this, 							numSamplesOffset, 1);	} 	idx = VM_Synchronization.fetchAndAdd(this, nextIndexOffset, 1);	if (idx < sampleSize && callerCmid != -1) { 	  samples[idx] = callerCmid; 	  sampleNumber = VM_Synchronization.fetchAndAdd(this, 							numSamplesOffset, 1);        }      } else {         // loop backedge.  We're only called once, so need to take        // two samples to avoid penalizing methods with loops. 	idx = VM_Synchronization.fetchAndAdd(this, nextIndexOffset, 1);	if (idx < sampleSize) { 	  samples[idx] = cmid; 	  sampleNumber = VM_Synchronization.fetchAndAdd(this, 							numSamplesOffset, 1);	} 	idx = VM_Synchronization.fetchAndAdd(this, nextIndexOffset, 1);         if (idx < sampleSize) { 	  samples[idx] = cmid; 	  sampleNumber = VM_Synchronization.fetchAndAdd(this, 							numSamplesOffset, 1);        }      }    }    if (sampleNumber >= sampleSize) {       passivate();      thresholdReached();    }  }