477 _exception_oop(oop()),
478 _exception_pc(nullptr),
479 _exception_handler_pc(nullptr),
480 _is_method_handle_return(0),
481
482 _jni_active_critical(0),
483 _pending_jni_exception_check_fn(nullptr),
484 _depth_first_number(0),
485
486 // JVMTI PopFrame support
487 _popframe_condition(popframe_inactive),
488 _frames_to_pop_failed_realloc(0),
489
490 _cont_entry(nullptr),
491 _cont_fastpath(nullptr),
492 _cont_fastpath_thread_state(1),
493 _held_monitor_count(0),
494 _jni_monitor_count(0),
495 _unlocked_inflated_monitor(nullptr),
496
497 _preempt_alternate_return(nullptr),
498 _preemption_cancelled(false),
499 _pending_interrupted_exception(false),
500
501 _handshake(this),
502
503 _popframe_preserved_args(nullptr),
504 _popframe_preserved_args_size(0),
505
506 _jvmti_thread_state(nullptr),
507 _interp_only_mode(0),
508 _should_post_on_exceptions_flag(JNI_FALSE),
509 _thread_stat(new ThreadStatistics()),
510
511 _parker(),
512
513 _class_to_be_initialized(nullptr),
514 _class_being_initialized(nullptr),
515
516 _SleepEvent(ParkEvent::Allocate(this)),
962 if (free_handle_block() != nullptr) {
963 JNIHandleBlock* block = free_handle_block();
964 set_free_handle_block(nullptr);
965 JNIHandleBlock::release_block(block);
966 }
967
968 // These have to be removed while this is still a valid thread.
969 _stack_overflow_state.remove_stack_guard_pages();
970
971 if (UseTLAB) {
972 tlab().retire();
973 }
974
975 if (JvmtiEnv::environments_might_exist()) {
976 JvmtiExport::cleanup_thread(this);
977 }
978
979 // We need to cache the thread name for logging purposes below as once
980 // we have called on_thread_detach this thread must not access any oops.
981 char* thread_name = nullptr;
982 if (log_is_enabled(Debug, os, thread, timer)) {
983 ResourceMark rm(this);
984 thread_name = os::strdup(name());
985 }
986
987 if (log_is_enabled(Info, os, thread)) {
988 ResourceMark rm(this);
989 log_info(os, thread)("JavaThread %s (name: \"%s\", tid: %zu).",
990 exit_type == JavaThread::normal_exit ? "exiting" : "detaching",
991 name(), os::current_thread_id());
992 }
993
994 if (log_is_enabled(Debug, os, thread, timer)) {
995 _timer_exit_phase3.stop();
996 _timer_exit_phase4.start();
997 }
998
999 #if INCLUDE_JVMCI
1000 if (JVMCICounterSize > 0) {
1001 if (jvmci_counters_include(this)) {
1002 for (int i = 0; i < JVMCICounterSize; i++) {
1003 _jvmci_old_thread_counters[i] += _jvmci_counters[i];
1004 }
1005 }
1006 }
1007 #endif // INCLUDE_JVMCI
1008
1009 // Remove from list of active threads list, and notify VM thread if we are the last non-daemon thread.
1010 // We call BarrierSet::barrier_set()->on_thread_detach() here so no touching of oops after this point.
1011 Threads::remove(this, daemon);
1012
1013 if (log_is_enabled(Debug, os, thread, timer)) {
1014 _timer_exit_phase4.stop();
1015 log_debug(os, thread, timer)("name='%s'"
1016 ", exit-phase1=" JLONG_FORMAT
1017 ", exit-phase2=" JLONG_FORMAT
1018 ", exit-phase3=" JLONG_FORMAT
1019 ", exit-phase4=" JLONG_FORMAT,
1020 thread_name,
1021 _timer_exit_phase1.milliseconds(),
1022 _timer_exit_phase2.milliseconds(),
1023 _timer_exit_phase3.milliseconds(),
1024 _timer_exit_phase4.milliseconds());
1025 os::free(thread_name);
1026 }
1027 }
1028
|
477 _exception_oop(oop()),
478 _exception_pc(nullptr),
479 _exception_handler_pc(nullptr),
480 _is_method_handle_return(0),
481
482 _jni_active_critical(0),
483 _pending_jni_exception_check_fn(nullptr),
484 _depth_first_number(0),
485
486 // JVMTI PopFrame support
487 _popframe_condition(popframe_inactive),
488 _frames_to_pop_failed_realloc(0),
489
490 _cont_entry(nullptr),
491 _cont_fastpath(nullptr),
492 _cont_fastpath_thread_state(1),
493 _held_monitor_count(0),
494 _jni_monitor_count(0),
495 _unlocked_inflated_monitor(nullptr),
496
497 _can_call_java(true),
498
499 _preempt_alternate_return(nullptr),
500 _preemption_cancelled(false),
501 _pending_interrupted_exception(false),
502
503 _handshake(this),
504
505 _popframe_preserved_args(nullptr),
506 _popframe_preserved_args_size(0),
507
508 _jvmti_thread_state(nullptr),
509 _interp_only_mode(0),
510 _should_post_on_exceptions_flag(JNI_FALSE),
511 _thread_stat(new ThreadStatistics()),
512
513 _parker(),
514
515 _class_to_be_initialized(nullptr),
516 _class_being_initialized(nullptr),
517
518 _SleepEvent(ParkEvent::Allocate(this)),
964 if (free_handle_block() != nullptr) {
965 JNIHandleBlock* block = free_handle_block();
966 set_free_handle_block(nullptr);
967 JNIHandleBlock::release_block(block);
968 }
969
970 // These have to be removed while this is still a valid thread.
971 _stack_overflow_state.remove_stack_guard_pages();
972
973 if (UseTLAB) {
974 tlab().retire();
975 }
976
977 if (JvmtiEnv::environments_might_exist()) {
978 JvmtiExport::cleanup_thread(this);
979 }
980
981 // We need to cache the thread name for logging purposes below as once
982 // we have called on_thread_detach this thread must not access any oops.
983 char* thread_name = nullptr;
984 if (log_is_enabled(Debug, os, thread, timer) || (CountBytecodesPerThread && log_is_enabled(Info, init))) {
985 ResourceMark rm(this);
986 thread_name = os::strdup(name());
987 }
988
989 if (log_is_enabled(Info, os, thread)) {
990 ResourceMark rm(this);
991 log_info(os, thread)("JavaThread %s (name: \"%s\", tid: %zu).",
992 exit_type == JavaThread::normal_exit ? "exiting" : "detaching",
993 name(), os::current_thread_id());
994 }
995
996 if (log_is_enabled(Debug, os, thread, timer)) {
997 _timer_exit_phase3.stop();
998 _timer_exit_phase4.start();
999 }
1000
1001 #if INCLUDE_JVMCI
1002 if (JVMCICounterSize > 0) {
1003 if (jvmci_counters_include(this)) {
1004 for (int i = 0; i < JVMCICounterSize; i++) {
1005 _jvmci_old_thread_counters[i] += _jvmci_counters[i];
1006 }
1007 }
1008 }
1009 #endif // INCLUDE_JVMCI
1010
1011 if (bc_counter_value() > 0) {
1012 log_info(init)("Thread '%s': " JLONG_FORMAT " bytecodes executed (during clinit: " JLONG_FORMAT ")",
1013 thread_name, bc_counter_value(), clinit_bc_counter_value());
1014 }
1015
1016 // Remove from list of active threads list, and notify VM thread if we are the last non-daemon thread.
1017 // We call BarrierSet::barrier_set()->on_thread_detach() here so no touching of oops after this point.
1018 Threads::remove(this, daemon);
1019
1020 if (log_is_enabled(Debug, os, thread, timer)) {
1021 _timer_exit_phase4.stop();
1022 log_debug(os, thread, timer)("name='%s'"
1023 ", exit-phase1=" JLONG_FORMAT
1024 ", exit-phase2=" JLONG_FORMAT
1025 ", exit-phase3=" JLONG_FORMAT
1026 ", exit-phase4=" JLONG_FORMAT,
1027 thread_name,
1028 _timer_exit_phase1.milliseconds(),
1029 _timer_exit_phase2.milliseconds(),
1030 _timer_exit_phase3.milliseconds(),
1031 _timer_exit_phase4.milliseconds());
1032 os::free(thread_name);
1033 }
1034 }
1035
|