if (notifyExit) { if (pickBuffer(4+4)) {  writeNotifyExit(EXIT_FORMAT, notify_exit_value); updateBufferIndex(); n_records++; }  passivate();     notifyExitFound = true;   consumer.notifyExit = true; activateConsumer(); }
  private void tracing(int tid, int global_tid, long startOfWallTime, 		       long endOfWallTime, HPM_counters counters, boolean threadSwitch)   {    //-#if RVM_WITH_HPM    // which buffer to use    if (! processCallbacksFromConsumer()) return;    if (! pickBuffer(VM_HardwarePerformanceMonitors.getRecordSize())) return;    // buffer != null only if active==true    //BEGIN HRM    if (VM_HardwarePerformanceMonitors.verbose>=6) VM.sysWriteln("begin method stuff");    int callee_MID;    int caller_MID;    if (cmidAvailable) {      if (callee_CMID<1 || callee_CMID>=VM_CompiledMethods.numCompiledMethods()) {	callee_MID = CMID_OUT_OF_BOUNDS_MID;	VM.sysWriteln("***VM_HPM.tracing() CALLEE_CMID_OUT_OF_BOUNDS_MID*** ",callee_CMID);	VM.sysExit(-1);      } else {	final VM_CompiledMethod cm1 = VM_CompiledMethods.getCompiledMethod(callee_CMID);	if (cm1==null) {	  callee_MID = CMID_WITHOUT_COMPILED_METHOD_MID;	  VM.sysWriteln("***VM_HPM.tracing() CALLEE_CMID_WITHOUT_COMPILED_METHOD_MID*** ",callee_CMID);	  VM.sysExit(-1);	} else {	  final VM_Method m1 = cm1.getMethod();	  if (m1==null) {	    callee_MID = COMPILED_METHOD_WITHOUT_METHOD_MID;	    VM.sysWriteln("***VM_HPM.tracing() CALLEE_CMID_WITHOUT_METHOD_MID*** ",callee_CMID);	    VM.sysExit(-1);	  } else {	    callee_MID = m1.getId();	    /**	    VM.sysWrite("m1: ["); VM.sysWrite(m1.getId()); VM.sysWrite("] ");	    VM.sysWrite(m1.getDeclaringClass().getDescriptor());	    VM.sysWrite(m1.getName()); VM.sysWrite(m1.getDescriptor()); VM.sysWriteln();	    **/	  }	}      }      if (caller_CMID<1 || caller_CMID>=VM_CompiledMethods.numCompiledMethods()) {	caller_MID = CMID_OUT_OF_BOUNDS_MID;	VM.sysWriteln("***VM_HPM.tracing() CALLER_CMID_OUT_OF_BOUNDS_MID*** ",caller_CMID);	VM.sysExit(-1);      } else {	final VM_CompiledMethod cm2 = VM_CompiledMethods.getCompiledMethod(caller_CMID);	if (cm2==null) {	  caller_MID = CMID_WITHOUT_COMPILED_METHOD_MID;	  VM.sysWriteln("***VM_HPM.tracing() CALLER_CMID_WITHOUT_COMPILED_METHOD_MID*** ",caller_CMID);	  VM.sysExit(-1);	} else {	  final VM_Method m2 = cm2.getMethod();	  if (m2==null) {	    caller_MID = COMPILED_METHOD_WITHOUT_METHOD_MID;	    VM.sysWriteln("***VM_HPM.tracing() CALLER_CMID_WITHOUT_METHOD_MID*** ",caller_CMID);	    VM.sysExit(-1);	  } else {	    caller_MID = m2.getId();	    /**	    VM.sysWrite("m2: ["); VM.sysWrite(m2.getId()); VM.sysWrite("] ");	    VM.sysWrite(m2.getDeclaringClass().getDescriptor());	    VM.sysWrite(m2.getName()); VM.sysWrite(m2.getDescriptor()); VM.sysWriteln();	    **/	  }	}      }      //VM_Thread.dumpCallStack();      cmidAvailableCount++;      cmidAvailable = false;    } else {      cmidUnavailableCount++;      VM.sysWrite("***VM_HPM.tracing() cmidAvailable == false***");      VM.sysWrite("cmidAvailableCount:   ");      VM.sysWriteln(cmidAvailableCount);      VM.sysWrite("cmidUnavailableCount:   ");      VM.sysWriteln(cmidUnavailableCount);      //VM.sysWriteln("cmid NOT available");      VM_Thread.dumpCallStack();      callee_MID = UNAVAILABLE_MID;      caller_MID = UNAVAILABLE_MID;    }    if (VM_HardwarePerformanceMonitors.verbose>=6) VM.sysWriteln("end method stuff");    //END HRM    int thread_switch = (threadSwitch==true?1:0);    int encoding = (tid  << 16) + (buffer_code << 15) + (thread_switch << 14) +                    (vpid <<  4) + TRACE_FORMAT;        if(VM_HardwarePerformanceMonitors.verbose>=5 || VM_HardwarePerformanceMonitors.hpm_trace_verbose == vpid) {      if (threadSwitch) VM.sysWrite(" ");      else              VM.sysWrite("*");      VM.sysWrite(index,": ");      VM.sysWrite(TRACE_FORMAT);      VM.sysWrite(" BC ",buffer_code);      VM.sysWrite(" PID ", vpid);        //      VM.sysWrite(" ("); VM.sysWriteHex(encoding); VM.sysWrite(")");      VM.sysWrite(" GTID ", global_tid);      VM.sysWrite(" TID ", tid);      VM.sysWrite(" SWT ");    VM.sysWriteLong(startOfWallTime);      if(n_counters > 4) VM.sysWrite("\n  ");      VM.sysWrite(" EWT " ); VM.sysWriteLong(endOfWallTime);      //BEGIN HRM      VM.sysWrite(" CALLEE_MID ", callee_MID);      VM.sysWrite(" CALLER_MID ", caller_MID);      //END HRM    }    if (buffer != null) { // write record header      n_records++;      VM_Magic.setIntAtOffset( buffer, index, encoding);	// encoding      index += VM_HardwarePerformanceMonitors.SIZE_OF_INT;      VM_Magic.setIntAtOffset( buffer, index, global_tid);	// globally unique tid        index += VM_HardwarePerformanceMonitors.SIZE_OF_INT;      VM_Magic.setLongAtOffset(buffer, index, startOfWallTime);	// start of global time      index += VM_HardwarePerformanceMonitors.SIZE_OF_LONG;      VM_Magic.setLongAtOffset(buffer, index,   endOfWallTime);	// end   of global time      index += VM_HardwarePerformanceMonitors.SIZE_OF_LONG;      //BEGIN HRM      VM_Magic.setIntAtOffset( buffer, index, callee_MID);	// callee MID      index += VM_HardwarePerformanceMonitors.SIZE_OF_INT;      VM_Magic.setIntAtOffset( buffer, index, caller_MID);	// caller MID      index += VM_HardwarePerformanceMonitors.SIZE_OF_INT;      //END HRM    }    for(int i=1; i<=n_counters; i++) {      long value = counters.counters[i];      if(VM_HardwarePerformanceMonitors.verbose>=5 || VM_HardwarePerformanceMonitors.hpm_trace_verbose == vpid) {	VM.sysWrite(" ",i,": ");VM.sysWriteLong(value);       }      if (buffer != null) { // write HPM counter values	VM_Magic.setLongAtOffset(buffer, index, value);		  	index += VM_HardwarePerformanceMonitors.SIZE_OF_LONG;      }    }    if (VM_HardwarePerformanceMonitors.verbose>=5 || VM_HardwarePerformanceMonitors.hpm_trace_verbose == vpid) {      VM.sysWriteln();    }    updateBufferIndex();    // after thread switch is handled, handle notify exit if occurred    if (notifyExit) {      if (pickBuffer(4+4)) {	// write notify trace record	writeNotifyExit(EXIT_FORMAT, notify_exit_value);	updateBufferIndex();	n_records++;      }      // don't collect any more trace records!      passivate();      // reset state (not really needed as expect notifyExit occurs only once!)      //      notifyExit = false; notify_exit_value = -1;      // Don't collect any more HPM trace records      notifyExitFound = true;      // notify consumer to drain buffer and close file      consumer.notifyExit = true;      activateConsumer();    }    //-#endif  }