< 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

2939     }
2940   }
2941 
2942   // Launch -Xrun agents
2943   // Must be done in the JVMTI live phase so that for backward compatibility the JDWP
2944   // back-end can launch with -Xdebug -Xrunjdwp.
2945   if (!EagerXrunInit && Arguments::init_libraries_at_startup()) {
2946     create_vm_init_libraries();
2947   }
2948 
2949   Chunk::start_chunk_pool_cleaner_task();
2950 
2951   // Start the service thread
2952   // The service thread enqueues JVMTI deferred events and does various hashtable
2953   // and other cleanups.  Needs to start before the compilers start posting events.
2954   ServiceThread::initialize();
2955 
2956   // Start the monitor deflation thread:
2957   MonitorDeflationThread::initialize();
2958 



2959   // initialize compiler(s)
2960 #if defined(COMPILER1) || COMPILER2_OR_JVMCI
2961 #if INCLUDE_JVMCI
2962   bool force_JVMCI_intialization = false;
2963   if (EnableJVMCI) {
2964     // Initialize JVMCI eagerly when it is explicitly requested.
2965     // Or when JVMCILibDumpJNIConfig or JVMCIPrintProperties is enabled.
2966     force_JVMCI_intialization = EagerJVMCI || JVMCIPrintProperties || JVMCILibDumpJNIConfig;
2967 
2968     if (!force_JVMCI_intialization) {
2969       // 8145270: Force initialization of JVMCI runtime otherwise requests for blocking
2970       // compilations via JVMCI will not actually block until JVMCI is initialized.
2971       force_JVMCI_intialization = UseJVMCICompiler && (!UseInterpreter || !BackgroundCompilation);
2972     }
2973   }
2974 #endif
2975   CompileBroker::compilation_init_phase1(CHECK_JNI_ERR);
2976   // Postpone completion of compiler initialization to after JVMCI
2977   // is initialized to avoid timeouts of blocking compilations.
2978   if (JVMCI_ONLY(!force_JVMCI_intialization) NOT_JVMCI(true)) {

3389   }
3390   os::wait_for_keypress_at_exit();
3391 
3392   // run Java level shutdown hooks
3393   thread->invoke_shutdown_hooks();
3394 
3395   before_exit(thread);
3396 
3397   thread->exit(true);
3398 
3399   // We are no longer on the main thread list but could still be in a
3400   // secondary list where another thread may try to interact with us.
3401   // So wait until all such interactions are complete before we bring
3402   // the VM to the termination safepoint. Normally this would be done
3403   // using thread->smr_delete() below where we delete the thread, but
3404   // we can't call that after the termination safepoint is active as
3405   // we will deadlock on the Threads_lock. Once all interactions are
3406   // complete it is safe to directly delete the thread at any time.
3407   ThreadsSMRSupport::wait_until_not_protected(thread);
3408 


3409   // Stop VM thread.
3410   {
3411     // 4945125 The vm thread comes to a safepoint during exit.
3412     // GC vm_operations can get caught at the safepoint, and the
3413     // heap is unparseable if they are caught. Grab the Heap_lock
3414     // to prevent this. The GC vm_operations will not be able to
3415     // queue until after the vm thread is dead. After this point,
3416     // we'll never emerge out of the safepoint before the VM exits.
3417     // Assert that the thread is terminated so that acquiring the
3418     // Heap_lock doesn't cause the terminated thread to participate in
3419     // the safepoint protocol.
3420 
3421     assert(thread->is_terminated(), "must be terminated here");
3422     MutexLocker ml(Heap_lock);
3423 
3424     VMThread::wait_for_vm_thread_exit();
3425     assert(SafepointSynchronize::is_at_safepoint(), "VM thread should exit at Safepoint");
3426     VMThread::destroy();
3427   }
3428 

 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

2940     }
2941   }
2942 
2943   // Launch -Xrun agents
2944   // Must be done in the JVMTI live phase so that for backward compatibility the JDWP
2945   // back-end can launch with -Xdebug -Xrunjdwp.
2946   if (!EagerXrunInit && Arguments::init_libraries_at_startup()) {
2947     create_vm_init_libraries();
2948   }
2949 
2950   Chunk::start_chunk_pool_cleaner_task();
2951 
2952   // Start the service thread
2953   // The service thread enqueues JVMTI deferred events and does various hashtable
2954   // and other cleanups.  Needs to start before the compilers start posting events.
2955   ServiceThread::initialize();
2956 
2957   // Start the monitor deflation thread:
2958   MonitorDeflationThread::initialize();
2959 
2960   // Start heap object statistics sampling
2961   HeapObjectStatistics::initialize();
2962 
2963   // initialize compiler(s)
2964 #if defined(COMPILER1) || COMPILER2_OR_JVMCI
2965 #if INCLUDE_JVMCI
2966   bool force_JVMCI_intialization = false;
2967   if (EnableJVMCI) {
2968     // Initialize JVMCI eagerly when it is explicitly requested.
2969     // Or when JVMCILibDumpJNIConfig or JVMCIPrintProperties is enabled.
2970     force_JVMCI_intialization = EagerJVMCI || JVMCIPrintProperties || JVMCILibDumpJNIConfig;
2971 
2972     if (!force_JVMCI_intialization) {
2973       // 8145270: Force initialization of JVMCI runtime otherwise requests for blocking
2974       // compilations via JVMCI will not actually block until JVMCI is initialized.
2975       force_JVMCI_intialization = UseJVMCICompiler && (!UseInterpreter || !BackgroundCompilation);
2976     }
2977   }
2978 #endif
2979   CompileBroker::compilation_init_phase1(CHECK_JNI_ERR);
2980   // Postpone completion of compiler initialization to after JVMCI
2981   // is initialized to avoid timeouts of blocking compilations.
2982   if (JVMCI_ONLY(!force_JVMCI_intialization) NOT_JVMCI(true)) {

3393   }
3394   os::wait_for_keypress_at_exit();
3395 
3396   // run Java level shutdown hooks
3397   thread->invoke_shutdown_hooks();
3398 
3399   before_exit(thread);
3400 
3401   thread->exit(true);
3402 
3403   // We are no longer on the main thread list but could still be in a
3404   // secondary list where another thread may try to interact with us.
3405   // So wait until all such interactions are complete before we bring
3406   // the VM to the termination safepoint. Normally this would be done
3407   // using thread->smr_delete() below where we delete the thread, but
3408   // we can't call that after the termination safepoint is active as
3409   // we will deadlock on the Threads_lock. Once all interactions are
3410   // complete it is safe to directly delete the thread at any time.
3411   ThreadsSMRSupport::wait_until_not_protected(thread);
3412 
3413   HeapObjectStatistics::shutdown();
3414 
3415   // Stop VM thread.
3416   {
3417     // 4945125 The vm thread comes to a safepoint during exit.
3418     // GC vm_operations can get caught at the safepoint, and the
3419     // heap is unparseable if they are caught. Grab the Heap_lock
3420     // to prevent this. The GC vm_operations will not be able to
3421     // queue until after the vm thread is dead. After this point,
3422     // we'll never emerge out of the safepoint before the VM exits.
3423     // Assert that the thread is terminated so that acquiring the
3424     // Heap_lock doesn't cause the terminated thread to participate in
3425     // the safepoint protocol.
3426 
3427     assert(thread->is_terminated(), "must be terminated here");
3428     MutexLocker ml(Heap_lock);
3429 
3430     VMThread::wait_for_vm_thread_exit();
3431     assert(SafepointSynchronize::is_at_safepoint(), "VM thread should exit at Safepoint");
3432     VMThread::destroy();
3433   }
3434 
< prev index next >