487 _cont_fastpath_thread_state(1),
488 _held_monitor_count(0),
489 _jni_monitor_count(0),
490
491 _handshake(this),
492
493 _popframe_preserved_args(nullptr),
494 _popframe_preserved_args_size(0),
495
496 _jvmti_thread_state(nullptr),
497 _interp_only_mode(0),
498 _should_post_on_exceptions_flag(JNI_FALSE),
499 _thread_stat(new ThreadStatistics()),
500
501 _parker(),
502
503 _class_to_be_initialized(nullptr),
504
505 _SleepEvent(ParkEvent::Allocate(this)),
506
507 _lock_stack(this) {
508 set_jni_functions(jni_functions());
509
510 #if INCLUDE_JVMCI
511 assert(_jvmci._implicit_exception_pc == nullptr, "must be");
512 if (JVMCICounterSize > 0) {
513 resize_counters(0, (int) JVMCICounterSize);
514 }
515 #endif // INCLUDE_JVMCI
516
517 // Setup safepoint state info for this thread
518 ThreadSafepointState::create(this);
519
520 SafepointMechanism::initialize_header(this);
521
522 set_requires_cross_modify_fence(false);
523
524 pd_initialize();
525 assert(deferred_card_mark().is_empty(), "Default MemRegion ctor");
526 }
527
788 lock.notify_all(thread);
789 // Ignore pending exception, since we are exiting anyway
790 thread->clear_pending_exception();
791 }
792
793 static bool is_daemon(oop threadObj) {
794 return (threadObj != nullptr && java_lang_Thread::is_daemon(threadObj));
795 }
796
797 // For any new cleanup additions, please check to see if they need to be applied to
798 // cleanup_failed_attach_current_thread as well.
799 void JavaThread::exit(bool destroy_vm, ExitType exit_type) {
800 assert(this == JavaThread::current(), "thread consistency check");
801 assert(!is_exiting(), "should not be exiting or terminated already");
802
803 elapsedTimer _timer_exit_phase1;
804 elapsedTimer _timer_exit_phase2;
805 elapsedTimer _timer_exit_phase3;
806 elapsedTimer _timer_exit_phase4;
807
808 if (log_is_enabled(Debug, os, thread, timer)) {
809 _timer_exit_phase1.start();
810 }
811
812 HandleMark hm(this);
813 Handle uncaught_exception(this, this->pending_exception());
814 this->clear_pending_exception();
815 Handle threadObj(this, this->threadObj());
816 assert(threadObj.not_null(), "Java thread object should be created");
817
818 if (!destroy_vm) {
819 if (uncaught_exception.not_null()) {
820 EXCEPTION_MARK;
821 // Call method Thread.dispatchUncaughtException().
822 Klass* thread_klass = vmClasses::Thread_klass();
823 JavaValue result(T_VOID);
824 JavaCalls::call_virtual(&result,
825 threadObj, thread_klass,
826 vmSymbols::dispatchUncaughtException_name(),
827 vmSymbols::throwable_void_signature(),
|
487 _cont_fastpath_thread_state(1),
488 _held_monitor_count(0),
489 _jni_monitor_count(0),
490
491 _handshake(this),
492
493 _popframe_preserved_args(nullptr),
494 _popframe_preserved_args_size(0),
495
496 _jvmti_thread_state(nullptr),
497 _interp_only_mode(0),
498 _should_post_on_exceptions_flag(JNI_FALSE),
499 _thread_stat(new ThreadStatistics()),
500
501 _parker(),
502
503 _class_to_be_initialized(nullptr),
504
505 _SleepEvent(ParkEvent::Allocate(this)),
506
507 _lock_stack(this),
508 _om_cache(this) {
509 set_jni_functions(jni_functions());
510
511 #if INCLUDE_JVMCI
512 assert(_jvmci._implicit_exception_pc == nullptr, "must be");
513 if (JVMCICounterSize > 0) {
514 resize_counters(0, (int) JVMCICounterSize);
515 }
516 #endif // INCLUDE_JVMCI
517
518 // Setup safepoint state info for this thread
519 ThreadSafepointState::create(this);
520
521 SafepointMechanism::initialize_header(this);
522
523 set_requires_cross_modify_fence(false);
524
525 pd_initialize();
526 assert(deferred_card_mark().is_empty(), "Default MemRegion ctor");
527 }
528
789 lock.notify_all(thread);
790 // Ignore pending exception, since we are exiting anyway
791 thread->clear_pending_exception();
792 }
793
794 static bool is_daemon(oop threadObj) {
795 return (threadObj != nullptr && java_lang_Thread::is_daemon(threadObj));
796 }
797
798 // For any new cleanup additions, please check to see if they need to be applied to
799 // cleanup_failed_attach_current_thread as well.
800 void JavaThread::exit(bool destroy_vm, ExitType exit_type) {
801 assert(this == JavaThread::current(), "thread consistency check");
802 assert(!is_exiting(), "should not be exiting or terminated already");
803
804 elapsedTimer _timer_exit_phase1;
805 elapsedTimer _timer_exit_phase2;
806 elapsedTimer _timer_exit_phase3;
807 elapsedTimer _timer_exit_phase4;
808
809 om_clear_monitor_cache();
810
811 if (log_is_enabled(Debug, os, thread, timer)) {
812 _timer_exit_phase1.start();
813 }
814
815 HandleMark hm(this);
816 Handle uncaught_exception(this, this->pending_exception());
817 this->clear_pending_exception();
818 Handle threadObj(this, this->threadObj());
819 assert(threadObj.not_null(), "Java thread object should be created");
820
821 if (!destroy_vm) {
822 if (uncaught_exception.not_null()) {
823 EXCEPTION_MARK;
824 // Call method Thread.dispatchUncaughtException().
825 Klass* thread_klass = vmClasses::Thread_klass();
826 JavaValue result(T_VOID);
827 JavaCalls::call_virtual(&result,
828 threadObj, thread_klass,
829 vmSymbols::dispatchUncaughtException_name(),
830 vmSymbols::throwable_void_signature(),
|