VM.sysExit(VM.exitStatusDyingWithUncaughtException);
VM.sysExit(VM.EXIT_STATUS_DYING_WITH_UNCAUGHT_EXCEPTION);
  static void terminate () throws InterruptiblePragma {    boolean terminateSystem = false;    if (trace) VM_Scheduler.trace("VM_Thread", "terminate");    if (traceTermination) {      VM.disableGC();      VM.sysWriteln("[ BEGIN Verbosely dumping stack at time of thread termination");      VM_Scheduler.dumpStack();      VM.sysWriteln("END Verbosely dumping stack at time of creating thread termination ]");      VM.enableGC();    }    //-#if RVM_WITH_HPM    // sample HPM counter values at every interrupt or a thread switch.    if (VM.BuildForHPM && VM_HardwarePerformanceMonitors.safe &&         ! VM_HardwarePerformanceMonitors.thread_group) {      captureCallChainCMIDs(false);      VM_Thread myThread = getCurrentThread();      if (VM_HardwarePerformanceMonitors.verbose>=5) {        VM.sysWriteln("***VM_Thread.startoff() terminate thread "+myThread.getIndex()+"***!");      }      VM_Processor.getCurrentProcessor().hpm.updateHPMcounters(myThread, false, true);    }    //-#endif     //-#if RVM_WITH_ADAPTIVE_SYSTEM    VM_RuntimeMeasurements.monitorThreadExit();    //-#endif    VM_Thread myThread = getCurrentThread();    // allow java.lang.Thread.exit() to remove this thread from ThreadGroup    myThread.exit();     synchronized (myThread) { // release anybody waiting on this thread -         // begin critical section        //        VM_Scheduler.threadCreationMutex.lock();        VM_Processor.getCurrentProcessor().disableThreadSwitching();                // in particular, see java.lang.Thread.join()        myThread.isAlive = false;        myThread.notifyAll();    }            //    // if the thread terminated because of an exception, remove    // the mark from the exception register object, or else the    // garbage collector will attempt to relocate its ip field.    myThread.hardwareExceptionRegisters.inuse = false;        VM_Scheduler.numActiveThreads -= 1;    if (myThread.isDaemon)      VM_Scheduler.numDaemons -= 1;    if (VM_Scheduler.numDaemons == VM_Scheduler.numActiveThreads) {      // no non-daemon thread remains      terminateSystem = true;    }    if (traceTermination) {      VM.sysWriteln("VM_Thread.terminate: myThread.isDaemon = ",                     myThread.isDaemon);      VM.sysWriteln("  VM_Scheduler.numActiveThreads = ",                     VM_Scheduler.numActiveThreads);      VM.sysWriteln("  VM_Scheduler.numDaemons = ",                     VM_Scheduler.numDaemons);      VM.sysWriteln("  terminateSystem = ",                     terminateSystem);    }        // end critical section    //    VM_Processor.getCurrentProcessor().enableThreadSwitching();    VM_Scheduler.threadCreationMutex.unlock();    if (VM.VerifyAssertions)       VM._assert( (!VM.fullyBooted && terminateSystem )                 || VM_Processor.getCurrentProcessor().threadSwitchingEnabled());    if (terminateSystem) {      if (myThread.dyingWithUncaughtException)        VM.sysExit(VM.exitStatusDyingWithUncaughtException);      else if (myThread.thread instanceof MainThread) {        MainThread mt = (MainThread) myThread.thread;        if (! mt.launched) {          VM.sysExit(VM.exitStatusMainThreadCouldNotLaunch);        }      }      VM.sysExit(0);      if (VM.VerifyAssertions) VM._assert(VM.NOT_REACHED);    }        if (myThread.jniEnv != null) {      VM_JNIEnvironment.deallocateEnvironment(myThread.jniEnv);      myThread.jniEnv = null;    }    // become another thread    // begin critical section    //    VM_Scheduler.threadCreationMutex.lock();    myThread.releaseThreadSlot();        myThread.beingDispatched = true;    VM_Scheduler.threadCreationMutex.unlock();    VM_Processor.getCurrentProcessor().dispatch(false);    if (VM.VerifyAssertions) VM._assert(VM.NOT_REACHED);  }