< prev index next >

src/hotspot/share/runtime/thread.cpp

Print this page

 100 #include "runtime/serviceThread.hpp"
 101 #include "runtime/sharedRuntime.hpp"
 102 #include "runtime/stackFrameStream.inline.hpp"
 103 #include "runtime/stackWatermarkSet.hpp"
 104 #include "runtime/statSampler.hpp"
 105 #include "runtime/task.hpp"
 106 #include "runtime/thread.inline.hpp"
 107 #include "runtime/threadCritical.hpp"
 108 #include "runtime/threadSMR.inline.hpp"
 109 #include "runtime/threadStatisticalInfo.hpp"
 110 #include "runtime/threadWXSetters.inline.hpp"
 111 #include "runtime/timer.hpp"
 112 #include "runtime/timerTrace.hpp"
 113 #include "runtime/vframe.inline.hpp"
 114 #include "runtime/vframeArray.hpp"
 115 #include "runtime/vframe_hp.hpp"
 116 #include "runtime/vmThread.hpp"
 117 #include "runtime/vmOperations.hpp"
 118 #include "runtime/vm_version.hpp"
 119 #include "services/attachListener.hpp"

 120 #include "services/management.hpp"
 121 #include "services/memTracker.hpp"
 122 #include "services/threadService.hpp"
 123 #include "utilities/align.hpp"
 124 #include "utilities/copy.hpp"
 125 #include "utilities/defaultStream.hpp"
 126 #include "utilities/dtrace.hpp"
 127 #include "utilities/events.hpp"
 128 #include "utilities/macros.hpp"
 129 #include "utilities/preserveException.hpp"
 130 #include "utilities/spinYield.hpp"
 131 #include "utilities/vmError.hpp"
 132 #if INCLUDE_JVMCI
 133 #include "jvmci/jvmci.hpp"
 134 #include "jvmci/jvmciEnv.hpp"
 135 #endif
 136 #ifdef COMPILER1
 137 #include "c1/c1_Compiler.hpp"
 138 #endif
 139 #ifdef COMPILER2

2852     }
2853   }
2854 
2855   // Launch -Xrun agents
2856   // Must be done in the JVMTI live phase so that for backward compatibility the JDWP
2857   // back-end can launch with -Xdebug -Xrunjdwp.
2858   if (!EagerXrunInit && Arguments::init_libraries_at_startup()) {
2859     create_vm_init_libraries();
2860   }
2861 
2862   Chunk::start_chunk_pool_cleaner_task();
2863 
2864   // Start the service thread
2865   // The service thread enqueues JVMTI deferred events and does various hashtable
2866   // and other cleanups.  Needs to start before the compilers start posting events.
2867   ServiceThread::initialize();
2868 
2869   // Start the monitor deflation thread:
2870   MonitorDeflationThread::initialize();
2871 



2872   // initialize compiler(s)
2873 #if defined(COMPILER1) || COMPILER2_OR_JVMCI
2874 #if INCLUDE_JVMCI
2875   bool force_JVMCI_intialization = false;
2876   if (EnableJVMCI) {
2877     // Initialize JVMCI eagerly when it is explicitly requested.
2878     // Or when JVMCILibDumpJNIConfig or JVMCIPrintProperties is enabled.
2879     force_JVMCI_intialization = EagerJVMCI || JVMCIPrintProperties || JVMCILibDumpJNIConfig;
2880 
2881     if (!force_JVMCI_intialization) {
2882       // 8145270: Force initialization of JVMCI runtime otherwise requests for blocking
2883       // compilations via JVMCI will not actually block until JVMCI is initialized.
2884       force_JVMCI_intialization = UseJVMCICompiler && (!UseInterpreter || !BackgroundCompilation);
2885     }
2886   }
2887 #endif
2888   CompileBroker::compilation_init_phase1(CHECK_JNI_ERR);
2889   // Postpone completion of compiler initialization to after JVMCI
2890   // is initialized to avoid timeouts of blocking compilations.
2891   if (JVMCI_ONLY(!force_JVMCI_intialization) NOT_JVMCI(true)) {

3302   }
3303   os::wait_for_keypress_at_exit();
3304 
3305   // run Java level shutdown hooks
3306   thread->invoke_shutdown_hooks();
3307 
3308   before_exit(thread);
3309 
3310   thread->exit(true);
3311 
3312   // We are no longer on the main thread list but could still be in a
3313   // secondary list where another thread may try to interact with us.
3314   // So wait until all such interactions are complete before we bring
3315   // the VM to the termination safepoint. Normally this would be done
3316   // using thread->smr_delete() below where we delete the thread, but
3317   // we can't call that after the termination safepoint is active as
3318   // we will deadlock on the Threads_lock. Once all interactions are
3319   // complete it is safe to directly delete the thread at any time.
3320   ThreadsSMRSupport::wait_until_not_protected(thread);
3321 


3322   // Stop VM thread.
3323   {
3324     // 4945125 The vm thread comes to a safepoint during exit.
3325     // GC vm_operations can get caught at the safepoint, and the
3326     // heap is unparseable if they are caught. Grab the Heap_lock
3327     // to prevent this. The GC vm_operations will not be able to
3328     // queue until after the vm thread is dead. After this point,
3329     // we'll never emerge out of the safepoint before the VM exits.
3330     // Assert that the thread is terminated so that acquiring the
3331     // Heap_lock doesn't cause the terminated thread to participate in
3332     // the safepoint protocol.
3333 
3334     assert(thread->is_terminated(), "must be terminated here");
3335     MutexLocker ml(Heap_lock);
3336 
3337     VMThread::wait_for_vm_thread_exit();
3338     assert(SafepointSynchronize::is_at_safepoint(), "VM thread should exit at Safepoint");
3339     VMThread::destroy();
3340   }
3341 

 100 #include "runtime/serviceThread.hpp"
 101 #include "runtime/sharedRuntime.hpp"
 102 #include "runtime/stackFrameStream.inline.hpp"
 103 #include "runtime/stackWatermarkSet.hpp"
 104 #include "runtime/statSampler.hpp"
 105 #include "runtime/task.hpp"
 106 #include "runtime/thread.inline.hpp"
 107 #include "runtime/threadCritical.hpp"
 108 #include "runtime/threadSMR.inline.hpp"
 109 #include "runtime/threadStatisticalInfo.hpp"
 110 #include "runtime/threadWXSetters.inline.hpp"
 111 #include "runtime/timer.hpp"
 112 #include "runtime/timerTrace.hpp"
 113 #include "runtime/vframe.inline.hpp"
 114 #include "runtime/vframeArray.hpp"
 115 #include "runtime/vframe_hp.hpp"
 116 #include "runtime/vmThread.hpp"
 117 #include "runtime/vmOperations.hpp"
 118 #include "runtime/vm_version.hpp"
 119 #include "services/attachListener.hpp"
 120 #include "services/heapObjectStatistics.hpp"
 121 #include "services/management.hpp"
 122 #include "services/memTracker.hpp"
 123 #include "services/threadService.hpp"
 124 #include "utilities/align.hpp"
 125 #include "utilities/copy.hpp"
 126 #include "utilities/defaultStream.hpp"
 127 #include "utilities/dtrace.hpp"
 128 #include "utilities/events.hpp"
 129 #include "utilities/macros.hpp"
 130 #include "utilities/preserveException.hpp"
 131 #include "utilities/spinYield.hpp"
 132 #include "utilities/vmError.hpp"
 133 #if INCLUDE_JVMCI
 134 #include "jvmci/jvmci.hpp"
 135 #include "jvmci/jvmciEnv.hpp"
 136 #endif
 137 #ifdef COMPILER1
 138 #include "c1/c1_Compiler.hpp"
 139 #endif
 140 #ifdef COMPILER2

2853     }
2854   }
2855 
2856   // Launch -Xrun agents
2857   // Must be done in the JVMTI live phase so that for backward compatibility the JDWP
2858   // back-end can launch with -Xdebug -Xrunjdwp.
2859   if (!EagerXrunInit && Arguments::init_libraries_at_startup()) {
2860     create_vm_init_libraries();
2861   }
2862 
2863   Chunk::start_chunk_pool_cleaner_task();
2864 
2865   // Start the service thread
2866   // The service thread enqueues JVMTI deferred events and does various hashtable
2867   // and other cleanups.  Needs to start before the compilers start posting events.
2868   ServiceThread::initialize();
2869 
2870   // Start the monitor deflation thread:
2871   MonitorDeflationThread::initialize();
2872 
2873   // Start heap object statistics sampling
2874   HeapObjectStatistics::initialize();
2875 
2876   // initialize compiler(s)
2877 #if defined(COMPILER1) || COMPILER2_OR_JVMCI
2878 #if INCLUDE_JVMCI
2879   bool force_JVMCI_intialization = false;
2880   if (EnableJVMCI) {
2881     // Initialize JVMCI eagerly when it is explicitly requested.
2882     // Or when JVMCILibDumpJNIConfig or JVMCIPrintProperties is enabled.
2883     force_JVMCI_intialization = EagerJVMCI || JVMCIPrintProperties || JVMCILibDumpJNIConfig;
2884 
2885     if (!force_JVMCI_intialization) {
2886       // 8145270: Force initialization of JVMCI runtime otherwise requests for blocking
2887       // compilations via JVMCI will not actually block until JVMCI is initialized.
2888       force_JVMCI_intialization = UseJVMCICompiler && (!UseInterpreter || !BackgroundCompilation);
2889     }
2890   }
2891 #endif
2892   CompileBroker::compilation_init_phase1(CHECK_JNI_ERR);
2893   // Postpone completion of compiler initialization to after JVMCI
2894   // is initialized to avoid timeouts of blocking compilations.
2895   if (JVMCI_ONLY(!force_JVMCI_intialization) NOT_JVMCI(true)) {

3306   }
3307   os::wait_for_keypress_at_exit();
3308 
3309   // run Java level shutdown hooks
3310   thread->invoke_shutdown_hooks();
3311 
3312   before_exit(thread);
3313 
3314   thread->exit(true);
3315 
3316   // We are no longer on the main thread list but could still be in a
3317   // secondary list where another thread may try to interact with us.
3318   // So wait until all such interactions are complete before we bring
3319   // the VM to the termination safepoint. Normally this would be done
3320   // using thread->smr_delete() below where we delete the thread, but
3321   // we can't call that after the termination safepoint is active as
3322   // we will deadlock on the Threads_lock. Once all interactions are
3323   // complete it is safe to directly delete the thread at any time.
3324   ThreadsSMRSupport::wait_until_not_protected(thread);
3325 
3326   HeapObjectStatistics::shutdown();
3327 
3328   // Stop VM thread.
3329   {
3330     // 4945125 The vm thread comes to a safepoint during exit.
3331     // GC vm_operations can get caught at the safepoint, and the
3332     // heap is unparseable if they are caught. Grab the Heap_lock
3333     // to prevent this. The GC vm_operations will not be able to
3334     // queue until after the vm thread is dead. After this point,
3335     // we'll never emerge out of the safepoint before the VM exits.
3336     // Assert that the thread is terminated so that acquiring the
3337     // Heap_lock doesn't cause the terminated thread to participate in
3338     // the safepoint protocol.
3339 
3340     assert(thread->is_terminated(), "must be terminated here");
3341     MutexLocker ml(Heap_lock);
3342 
3343     VMThread::wait_for_vm_thread_exit();
3344     assert(SafepointSynchronize::is_at_safepoint(), "VM thread should exit at Safepoint");
3345     VMThread::destroy();
3346   }
3347 
< prev index next >