}  if (VM_CompiledMethods.getCompiledMethod(callerCMID) == null) { VM.sysWrite("VM_EdgeListener:update: Found a caller cmid ("); VM.sysWrite(calleeCMID, false); VM.sysWrite(") with a null compiled method, exiting"); VM_Processor.getCurrentProcessor().enableThreadSwitching(); VM.sysFail("Exiting VM");
  public final void update(VM_Address sfp, int whereFrom) {    if (DEBUG) {      VM.sysWrite("VM_EdgeListener.update("+sfp.toInt()+","+whereFrom+		  "): enter "+samplesTaken+"\n");         }    calledUpdate++;    // don't take a sample for back edge yield points    if (whereFrom == VM_Thread.BACKEDGE) return;     if (buffer == null) {      VM.sysWrite("***Error: VM_EdgeListener.update() called "+		  "before setBuffer() is called!\n");      VM.sysExit(-1);    }    int calleeCMID    = 0;    int callerCMID    = 0;    VM_Address returnAddress = VM_Address.zero();    // While GC is disabled, don't do string concatenation!    VM_Processor.getCurrentProcessor().disableThreadSwitching();         if (VM_Magic.getMemoryWord(sfp) == STACKFRAME_SENTINAL_FP) {      if (DEBUG) VM.sysWrite(" Walking off end of stack!\n");	      VM_Processor.getCurrentProcessor().enableThreadSwitching();      return;    }    calleeCMID = VM_Magic.getCompiledMethodID(sfp);    if (calleeCMID == INVISIBLE_METHOD_ID) {      if (DEBUG){	VM.sysWrite(" INVISIBLE_METHOD_ID  (assembler code) ");	VM.sysWrite(calleeCMID); VM.sysWrite("\n");             }       VM_Processor.getCurrentProcessor().enableThreadSwitching();      return;    }    if (VM_CompiledMethods.getCompiledMethod(calleeCMID) == null) {      VM.sysWrite("VM_EdgeListener:update: Found a callee cmid (");      VM.sysWrite(calleeCMID, false);      VM.sysWrite(") with a null compiled method. ");      VM_Processor.getCurrentProcessor().enableThreadSwitching();      VM.sysFail("Exiting VM");    }    returnAddress = VM_Magic.getReturnAddress(sfp); // return address in caller    sfp = VM_Magic.getCallerFramePointer(sfp);      // caller's frame pointer    if(VM_Magic.getMemoryWord(sfp) == STACKFRAME_SENTINAL_FP) {      if (DEBUG) VM.sysWrite(" Walking off end of stack\n");	      VM_Processor.getCurrentProcessor().enableThreadSwitching();      return;    }    callerCMID = VM_Magic.getCompiledMethodID(sfp);    if (callerCMID == INVISIBLE_METHOD_ID) {      if (DEBUG) { 	VM.sysWrite(" INVISIBLE_METHOD_ID  (assembler code) ");	VM.sysWrite(callerCMID); VM.sysWrite("\n");       }	      VM_Processor.getCurrentProcessor().enableThreadSwitching();      return;    }    if (VM_CompiledMethods.getCompiledMethod(callerCMID) == null) {      VM.sysWrite("VM_EdgeListener:update: Found a caller cmid (");      VM.sysWrite(calleeCMID, false);      VM.sysWrite(") with a null compiled method, exiting");      VM_Processor.getCurrentProcessor().enableThreadSwitching();      VM.sysFail("Exiting VM");    }    // store the offset of the return address from the beginning of the     // instruction    VM_CompiledMethod callerCM = VM_CompiledMethods.getCompiledMethod(callerCMID);    VM_Address beginningOfMachineCode = VM_Magic.objectAsAddress(callerCM.getInstructions());    int callSite = returnAddress.diff(beginningOfMachineCode);    if (DEBUG){       VM.sysWrite("  <");VM.sysWrite(calleeCMID);VM.sysWrite(",");      VM.sysWrite(callerCMID);VM.sysWrite(",");VM.sysWrite(returnAddress);      VM.sysWrite(">\n");    }    if (DEBUG) {       VM_Address fp = VM_Magic.getCallerFramePointer(VM_Magic.getFramePointer());      int compiledMethodID = 0;      for(int i=1; i<6; i++) {	if (VM_Magic.getMemoryWord(fp) == STACKFRAME_SENTINAL_FP) {	  VM.sysWrite(" Walking off end of stack\n"); break;	}	compiledMethodID = VM_Magic.getCompiledMethodID(fp);	if (compiledMethodID == INVISIBLE_METHOD_ID) {	  VM.sysWrite(" INVISIBLE_METHOD_ID  (assembler code) ");	  VM.sysWrite(compiledMethodID); VM.sysWrite("\n");     continue;	}	VM.sysWrite("   Stack frame ");VM.sysWrite(i);VM.sysWrite(": ");	VM.sysWrite(compiledMethodID);	if (true) {	  VM_CompiledMethod compiledMethod = null;	  compiledMethod = VM_CompiledMethods.getCompiledMethod(compiledMethodID);	  VM_Method  method = compiledMethod.getMethod();	  VM.sysWrite(method);	}	VM.sysWrite("\n");	fp = VM_Magic.getCallerFramePointer(fp);      }    }    // done with stack inspection, re-enable GC    VM_Processor.getCurrentProcessor().enableThreadSwitching();    // Try to get 3 buffer slots and update nextIndex appropriately    int idx = VM_Synchronization.fetchAndAdd(this, 					     VM_Entrypoints.edgeListenerNextIndexField.getOffset(),					     3);    // If we got buffer slots that are beyond the end of the buffer, that means    // that we're actually not supposed to take the sample at all (the system    // is in the process of activating our organizer and processing the buffer).    if (idx < buffer.length) {      buffer[idx+0] = calleeCMID;      buffer[idx+1] = callerCMID;      buffer[idx+2] = callSite;      // Determine which sample we just completed.      // fetchAndAdd returns the value before the increment, add one to      // determine which sample we were      int sampleNumber = 	VM_Synchronization.fetchAndAdd(this, 				       VM_Entrypoints.edgeListenerSamplesTakenField.getOffset(),				       1) + 1;      // If we are the last sample, we need to activate the organizer.      if (sampleNumber == desiredSamples) {	activateOrganizer();      }     }   }