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