< prev index next >

src/hotspot/share/runtime/javaThread.cpp

Print this page

  81 #include "runtime/serviceThread.hpp"
  82 #include "runtime/stackFrameStream.inline.hpp"
  83 #include "runtime/stackWatermarkSet.hpp"
  84 #include "runtime/synchronizer.hpp"
  85 #include "runtime/threadCritical.hpp"
  86 #include "runtime/threadSMR.inline.hpp"
  87 #include "runtime/threadStatisticalInfo.hpp"
  88 #include "runtime/threadWXSetters.inline.hpp"
  89 #include "runtime/timer.hpp"
  90 #include "runtime/timerTrace.hpp"
  91 #include "runtime/vframe.inline.hpp"
  92 #include "runtime/vframeArray.hpp"
  93 #include "runtime/vframe_hp.hpp"
  94 #include "runtime/vmThread.hpp"
  95 #include "runtime/vmOperations.hpp"
  96 #include "services/threadService.hpp"
  97 #include "utilities/copy.hpp"
  98 #include "utilities/defaultStream.hpp"
  99 #include "utilities/dtrace.hpp"
 100 #include "utilities/events.hpp"

 101 #include "utilities/macros.hpp"
 102 #include "utilities/preserveException.hpp"
 103 #include "utilities/spinYield.hpp"
 104 #include "utilities/vmError.hpp"
 105 #if INCLUDE_JVMCI
 106 #include "jvmci/jvmci.hpp"
 107 #include "jvmci/jvmciEnv.hpp"
 108 #endif
 109 #if INCLUDE_JFR
 110 #include "jfr/jfr.hpp"
 111 #endif
 112 
 113 // Set by os layer.
 114 size_t      JavaThread::_stack_size_at_create = 0;
 115 
 116 #ifdef DTRACE_ENABLED
 117 
 118 // Only bother with this argument setup if dtrace is available
 119 
 120   #define HOTSPOT_THREAD_PROBE_start HOTSPOT_THREAD_START

 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(),

  81 #include "runtime/serviceThread.hpp"
  82 #include "runtime/stackFrameStream.inline.hpp"
  83 #include "runtime/stackWatermarkSet.hpp"
  84 #include "runtime/synchronizer.hpp"
  85 #include "runtime/threadCritical.hpp"
  86 #include "runtime/threadSMR.inline.hpp"
  87 #include "runtime/threadStatisticalInfo.hpp"
  88 #include "runtime/threadWXSetters.inline.hpp"
  89 #include "runtime/timer.hpp"
  90 #include "runtime/timerTrace.hpp"
  91 #include "runtime/vframe.inline.hpp"
  92 #include "runtime/vframeArray.hpp"
  93 #include "runtime/vframe_hp.hpp"
  94 #include "runtime/vmThread.hpp"
  95 #include "runtime/vmOperations.hpp"
  96 #include "services/threadService.hpp"
  97 #include "utilities/copy.hpp"
  98 #include "utilities/defaultStream.hpp"
  99 #include "utilities/dtrace.hpp"
 100 #include "utilities/events.hpp"
 101 #include "utilities/globalDefinitions.hpp"
 102 #include "utilities/macros.hpp"
 103 #include "utilities/preserveException.hpp"
 104 #include "utilities/spinYield.hpp"
 105 #include "utilities/vmError.hpp"
 106 #if INCLUDE_JVMCI
 107 #include "jvmci/jvmci.hpp"
 108 #include "jvmci/jvmciEnv.hpp"
 109 #endif
 110 #if INCLUDE_JFR
 111 #include "jfr/jfr.hpp"
 112 #endif
 113 
 114 // Set by os layer.
 115 size_t      JavaThread::_stack_size_at_create = 0;
 116 
 117 #ifdef DTRACE_ENABLED
 118 
 119 // Only bother with this argument setup if dtrace is available
 120 
 121   #define HOTSPOT_THREAD_PROBE_start HOTSPOT_THREAD_START

 488   _cont_fastpath_thread_state(1),
 489   _held_monitor_count(0),
 490   _jni_monitor_count(0),
 491 
 492   _handshake(this),
 493 
 494   _popframe_preserved_args(nullptr),
 495   _popframe_preserved_args_size(0),
 496 
 497   _jvmti_thread_state(nullptr),
 498   _interp_only_mode(0),
 499   _should_post_on_exceptions_flag(JNI_FALSE),
 500   _thread_stat(new ThreadStatistics()),
 501 
 502   _parker(),
 503 
 504   _class_to_be_initialized(nullptr),
 505 
 506   _SleepEvent(ParkEvent::Allocate(this)),
 507 
 508   _lock_stack(this),
 509   _om_cache(this) {
 510   set_jni_functions(jni_functions());
 511 
 512 #if INCLUDE_JVMCI
 513   assert(_jvmci._implicit_exception_pc == nullptr, "must be");
 514   if (JVMCICounterSize > 0) {
 515     resize_counters(0, (int) JVMCICounterSize);
 516   }
 517 #endif // INCLUDE_JVMCI
 518 
 519   // Setup safepoint state info for this thread
 520   ThreadSafepointState::create(this);
 521 
 522   SafepointMechanism::initialize_header(this);
 523 
 524   set_requires_cross_modify_fence(false);
 525 
 526   pd_initialize();
 527   assert(deferred_card_mark().is_empty(), "Default MemRegion ctor");
 528 }
 529 

 790   lock.notify_all(thread);
 791   // Ignore pending exception, since we are exiting anyway
 792   thread->clear_pending_exception();
 793 }
 794 
 795 static bool is_daemon(oop threadObj) {
 796   return (threadObj != nullptr && java_lang_Thread::is_daemon(threadObj));
 797 }
 798 
 799 // For any new cleanup additions, please check to see if they need to be applied to
 800 // cleanup_failed_attach_current_thread as well.
 801 void JavaThread::exit(bool destroy_vm, ExitType exit_type) {
 802   assert(this == JavaThread::current(), "thread consistency check");
 803   assert(!is_exiting(), "should not be exiting or terminated already");
 804 
 805   elapsedTimer _timer_exit_phase1;
 806   elapsedTimer _timer_exit_phase2;
 807   elapsedTimer _timer_exit_phase3;
 808   elapsedTimer _timer_exit_phase4;
 809 
 810   om_clear_monitor_cache();
 811 
 812   if (log_is_enabled(Debug, os, thread, timer)) {
 813     _timer_exit_phase1.start();
 814   }
 815 
 816   HandleMark hm(this);
 817   Handle uncaught_exception(this, this->pending_exception());
 818   this->clear_pending_exception();
 819   Handle threadObj(this, this->threadObj());
 820   assert(threadObj.not_null(), "Java thread object should be created");
 821 
 822   if (!destroy_vm) {
 823     if (uncaught_exception.not_null()) {
 824       EXCEPTION_MARK;
 825       // Call method Thread.dispatchUncaughtException().
 826       Klass* thread_klass = vmClasses::Thread_klass();
 827       JavaValue result(T_VOID);
 828       JavaCalls::call_virtual(&result,
 829                               threadObj, thread_klass,
 830                               vmSymbols::dispatchUncaughtException_name(),
 831                               vmSymbols::throwable_void_signature(),
< prev index next >