< prev index next >

src/share/vm/runtime/java.cpp

Print this page




 380 #endif
 381   if (PrintBiasedLockingStatistics) {
 382     BiasedLocking::print_counters();
 383   }
 384 
 385   // Native memory tracking data
 386   if (PrintNMTStatistics) {
 387     MemTracker::final_report(tty);
 388   }
 389 
 390   if (LogTouchedMethods && PrintTouchedMethodsAtExit) {
 391     Method::print_touched_methods(tty);
 392   }
 393 }
 394 
 395 #endif
 396 
 397 // Note: before_exit() can be executed only once, if more than one threads
 398 //       are trying to shutdown the VM at the same time, only one thread
 399 //       can run before_exit() and all other threads must wait.
 400 void before_exit(JavaThread * thread) {
 401   #define BEFORE_EXIT_NOT_RUN 0
 402   #define BEFORE_EXIT_RUNNING 1
 403   #define BEFORE_EXIT_DONE    2
 404   static jint volatile _before_exit_status = BEFORE_EXIT_NOT_RUN;
 405 
 406   // Note: don't use a Mutex to guard the entire before_exit(), as
 407   // JVMTI post_thread_end_event and post_vm_death_event will run native code.
 408   // A CAS or OSMutex would work just fine but then we need to manipulate
 409   // thread state for Safepoint. Here we use Monitor wait() and notify_all()
 410   // for synchronization.
 411   { MutexLocker ml(BeforeExit_lock);
 412     switch (_before_exit_status) {
 413     case BEFORE_EXIT_NOT_RUN:
 414       _before_exit_status = BEFORE_EXIT_RUNNING;
 415       break;
 416     case BEFORE_EXIT_RUNNING:
 417       while (_before_exit_status == BEFORE_EXIT_RUNNING) {
 418         BeforeExit_lock->wait();
 419       }
 420       assert(_before_exit_status == BEFORE_EXIT_DONE, "invalid state");
 421       return;
 422     case BEFORE_EXIT_DONE:
 423       return;
 424     }
 425   }
 426 
 427 #if INCLUDE_JVMCI
 428   JVMCIRuntime::shutdown();








 429 #endif
 430 
 431   // Hang forever on exit if we're reporting an error.
 432   if (ShowMessageBoxOnError && is_error_reported()) {
 433     os::infinite_sleep();
 434   }
 435 
 436   // Stop the WatcherThread. We do this before disenrolling various
 437   // PeriodicTasks to reduce the likelihood of races.
 438   if (PeriodicTask::num_tasks() > 0) {
 439     WatcherThread::stop();
 440   }
 441 
 442   // Print statistics gathered (profiling ...)
 443   if (Arguments::has_profile()) {
 444     FlatProfiler::disengage();
 445     FlatProfiler::print(10);
 446   }
 447 
 448   // shut down the StatSampler task


 593       tty->print_cr(": %s", message);
 594     }
 595     else {
 596       tty->cr();
 597     }
 598   }
 599   if (ShowMessageBoxOnError && WizardMode) {
 600     fatal("Error occurred during initialization of VM");
 601   }
 602 }
 603 
 604 void vm_exit_during_initialization(Handle exception) {
 605   tty->print_cr("Error occurred during initialization of VM");
 606   // If there are exceptions on this thread it must be cleared
 607   // first and here. Any future calls to EXCEPTION_MARK requires
 608   // that no pending exceptions exist.
 609   Thread *THREAD = Thread::current();
 610   if (HAS_PENDING_EXCEPTION) {
 611     CLEAR_PENDING_EXCEPTION;
 612   }
 613   java_lang_Throwable::print(exception, tty);
 614   tty->cr();
 615   java_lang_Throwable::print_stack_trace(exception(), tty);
 616   tty->cr();
 617   vm_notify_during_shutdown(NULL, NULL);
 618 
 619   // Failure during initialization, we don't want to dump core
 620   vm_abort(false);
 621 }
 622 
 623 void vm_exit_during_initialization(Symbol* ex, const char* message) {
 624   ResourceMark rm;
 625   vm_notify_during_shutdown(ex->as_C_string(), message);
 626 
 627   // Failure during initialization, we don't want to dump core
 628   vm_abort(false);
 629 }
 630 
 631 void vm_exit_during_initialization(const char* error, const char* message) {
 632   vm_notify_during_shutdown(error, message);
 633 
 634   // Failure during initialization, we don't want to dump core
 635   vm_abort(false);




 380 #endif
 381   if (PrintBiasedLockingStatistics) {
 382     BiasedLocking::print_counters();
 383   }
 384 
 385   // Native memory tracking data
 386   if (PrintNMTStatistics) {
 387     MemTracker::final_report(tty);
 388   }
 389 
 390   if (LogTouchedMethods && PrintTouchedMethodsAtExit) {
 391     Method::print_touched_methods(tty);
 392   }
 393 }
 394 
 395 #endif
 396 
 397 // Note: before_exit() can be executed only once, if more than one threads
 398 //       are trying to shutdown the VM at the same time, only one thread
 399 //       can run before_exit() and all other threads must wait.
 400 void before_exit(JavaThread* thread) {
 401   #define BEFORE_EXIT_NOT_RUN 0
 402   #define BEFORE_EXIT_RUNNING 1
 403   #define BEFORE_EXIT_DONE    2
 404   static jint volatile _before_exit_status = BEFORE_EXIT_NOT_RUN;
 405 
 406   // Note: don't use a Mutex to guard the entire before_exit(), as
 407   // JVMTI post_thread_end_event and post_vm_death_event will run native code.
 408   // A CAS or OSMutex would work just fine but then we need to manipulate
 409   // thread state for Safepoint. Here we use Monitor wait() and notify_all()
 410   // for synchronization.
 411   { MutexLocker ml(BeforeExit_lock);
 412     switch (_before_exit_status) {
 413     case BEFORE_EXIT_NOT_RUN:
 414       _before_exit_status = BEFORE_EXIT_RUNNING;
 415       break;
 416     case BEFORE_EXIT_RUNNING:
 417       while (_before_exit_status == BEFORE_EXIT_RUNNING) {
 418         BeforeExit_lock->wait();
 419       }
 420       assert(_before_exit_status == BEFORE_EXIT_DONE, "invalid state");
 421       return;
 422     case BEFORE_EXIT_DONE:
 423       return;
 424     }
 425   }
 426 
 427 #if INCLUDE_JVMCI
 428   // We are not using CATCH here because we want the exit to continue normally.
 429   Thread* THREAD = thread;
 430   JVMCIRuntime::shutdown(THREAD);
 431   if (HAS_PENDING_EXCEPTION) {
 432     Handle exception(THREAD, PENDING_EXCEPTION);
 433     CLEAR_PENDING_EXCEPTION;
 434     ttyLocker ttyl;
 435     java_lang_Throwable::print_stack_trace(exception, tty);
 436   }
 437 #endif
 438 
 439   // Hang forever on exit if we're reporting an error.
 440   if (ShowMessageBoxOnError && is_error_reported()) {
 441     os::infinite_sleep();
 442   }
 443 
 444   // Stop the WatcherThread. We do this before disenrolling various
 445   // PeriodicTasks to reduce the likelihood of races.
 446   if (PeriodicTask::num_tasks() > 0) {
 447     WatcherThread::stop();
 448   }
 449 
 450   // Print statistics gathered (profiling ...)
 451   if (Arguments::has_profile()) {
 452     FlatProfiler::disengage();
 453     FlatProfiler::print(10);
 454   }
 455 
 456   // shut down the StatSampler task


 601       tty->print_cr(": %s", message);
 602     }
 603     else {
 604       tty->cr();
 605     }
 606   }
 607   if (ShowMessageBoxOnError && WizardMode) {
 608     fatal("Error occurred during initialization of VM");
 609   }
 610 }
 611 
 612 void vm_exit_during_initialization(Handle exception) {
 613   tty->print_cr("Error occurred during initialization of VM");
 614   // If there are exceptions on this thread it must be cleared
 615   // first and here. Any future calls to EXCEPTION_MARK requires
 616   // that no pending exceptions exist.
 617   Thread *THREAD = Thread::current();
 618   if (HAS_PENDING_EXCEPTION) {
 619     CLEAR_PENDING_EXCEPTION;
 620   }
 621   java_lang_Throwable::print_stack_trace(exception, tty);


 622   tty->cr();
 623   vm_notify_during_shutdown(NULL, NULL);
 624 
 625   // Failure during initialization, we don't want to dump core
 626   vm_abort(false);
 627 }
 628 
 629 void vm_exit_during_initialization(Symbol* ex, const char* message) {
 630   ResourceMark rm;
 631   vm_notify_during_shutdown(ex->as_C_string(), message);
 632 
 633   // Failure during initialization, we don't want to dump core
 634   vm_abort(false);
 635 }
 636 
 637 void vm_exit_during_initialization(const char* error, const char* message) {
 638   vm_notify_during_shutdown(error, message);
 639 
 640   // Failure during initialization, we don't want to dump core
 641   vm_abort(false);


< prev index next >