int numSamples = listener.getNumSamples(); int[] samples = listener.getSamples();
int numSamples = ((VM_MethodListener)listener).getNumSamples(); int[] samples = ((VM_MethodListener)listener).getSamples();
  void thresholdReached() {    if (VM.LogAOSEvents) VM_AOSLogging.organizerThresholdReached();    int numSamples = listener.getNumSamples();    int[] samples = listener.getSamples();    // (1) Update the global (cumulative) sample data    VM_Controller.methodSamples.update(samples, numSamples);        // (2) Remove duplicates from samples buffer.    //     NOTE: This is a dirty trick and may be ill-advised.    //     Rather than copying the unique samples into a different buffer    //     we treat samples as if it was a scratch buffer.    //     NOTE: This is worse case O(numSamples^2) but we expect a     //     significant number of duplicates, so it's probably better than    //     the other obvious alternative (sorting samples).    int uniqueIdx = 1;  outer:    for (int i=1; i<numSamples; i++) {      int cur = samples[i];      for (int j=0; j<uniqueIdx; j++) {	if (cur == samples[j]) continue outer;      }      samples[uniqueIdx++] = cur;    }    // (3) For all samples in 0...uniqueIdx, if the method represented by    //     the sample is compiled at an opt level below filterOptLevel    //     and the total (cumulative) number of samples attributed to the    //     method is above our absolute minimum, then report it to the    //     controller. We have an absolute minimum value to avoid    //     considering methods that haven't been sampled enough times to    //     give us at least some reason to think that the fact that they    //     were sampled wasn't just random bad luck.    //     NOTE: this minimum is since the beginning of time, not    //           just the current window.    for (int i=0; i<uniqueIdx; i++) {      int cmid = samples[i];      double ns = VM_Controller.methodSamples.getData(cmid);      VM_CompiledMethod cm = VM_CompiledMethods.getCompiledMethod(cmid);      if (cm != null) {		// not already obsoleted	int compilerType = cm.getCompilerType();	// Enqueue it unless it's either a trap method or already opt	// compiled at filterOptLevel or higher.	if (!(compilerType == VM_CompiledMethod.TRAP ||	      (compilerType == VM_CompiledMethod.OPT && 	       (((VM_OptCompiledMethod)cm).getOptLevel() >= filterOptLevel)))) {	  VM_HotMethodRecompilationEvent event = 	    new VM_HotMethodRecompilationEvent(cm, ns);	  if (VM_Controller.controllerInputQueue.prioritizedInsert(ns, event)){	    if (VM.LogAOSEvents) VM_AOSLogging.controllerNotifiedForHotness(cm, ns);	  } else {	    if (VM.LogAOSEvents) VM_AOSLogging.controllerInputQueueFull(event);	  }	}      }    }        // (4) Get the listener ready to go and activate it for the next     //     sampling window.    listener.reset();    listener.activate();  }