24
25 #include "precompiled.hpp"
26 #include "compiler/compileBroker.hpp"
27 #include "gc/shared/collectedHeap.hpp"
28 #include "jfr/jfrEvents.hpp"
29 #include "jfr/support/jfrThreadId.hpp"
30 #include "logging/log.hpp"
31 #include "logging/logStream.hpp"
32 #include "logging/logConfiguration.hpp"
33 #include "memory/resourceArea.hpp"
34 #include "memory/universe.hpp"
35 #include "oops/method.hpp"
36 #include "oops/oop.inline.hpp"
37 #include "oops/verifyOopClosure.hpp"
38 #include "runtime/atomic.hpp"
39 #include "runtime/handles.inline.hpp"
40 #include "runtime/interfaceSupport.inline.hpp"
41 #include "runtime/mutexLocker.hpp"
42 #include "runtime/os.hpp"
43 #include "runtime/safepoint.hpp"
44 #include "runtime/thread.inline.hpp"
45 #include "runtime/vmThread.hpp"
46 #include "runtime/vmOperations.hpp"
47 #include "services/runtimeService.hpp"
48 #include "utilities/dtrace.hpp"
49 #include "utilities/events.hpp"
50 #include "utilities/vmError.hpp"
51 #include "utilities/xmlstream.hpp"
52
53 VM_QueueHead VMOperationQueue::_queue_head[VMOperationQueue::nof_priorities];
54
55 VMOperationQueue::VMOperationQueue() {
56 // The queue is a circular doubled-linked list, which always contains
57 // one element (i.e., one element means empty).
58 for(int i = 0; i < nof_priorities; i++) {
59 _queue_length[i] = 0;
60 _queue_counter = 0;
61 _queue[i] = &_queue_head[i];
62 _queue[i]->set_next(_queue[i]);
63 _queue[i]->set_prev(_queue[i]);
266 : VMThreadPriority;
267 // Note that I cannot call os::set_priority because it expects Java
268 // priorities and I am *explicitly* using OS priorities so that it's
269 // possible to set the VM thread priority higher than any Java thread.
270 os::set_native_priority( this, prio );
271
272 // Wait for VM_Operations until termination
273 this->loop();
274
275 // Note the intention to exit before safepointing.
276 // 6295565 This has the effect of waiting for any large tty
277 // outputs to finish.
278 if (xtty != NULL) {
279 ttyLocker ttyl;
280 xtty->begin_elem("destroy_vm");
281 xtty->stamp();
282 xtty->end_elem();
283 assert(should_terminate(), "termination flag must be set");
284 }
285
286 // 4526887 let VM thread exit at Safepoint
287 _cur_vm_operation = &halt_op;
288 SafepointSynchronize::begin();
289
290 if (VerifyBeforeExit) {
291 HandleMark hm(VMThread::vm_thread());
292 // Among other things, this ensures that Eden top is correct.
293 Universe::heap()->prepare_for_verify();
294 // Silent verification so as not to pollute normal output,
295 // unless we really asked for it.
296 Universe::verify();
297 }
298
299 CompileBroker::set_should_block();
300
301 // wait for threads (compiler threads or daemon threads) in the
302 // _thread_in_native state to block.
303 VM_Exit::wait_for_threads_in_native_to_block();
304
305 // signal other threads that VM process is gone
|
24
25 #include "precompiled.hpp"
26 #include "compiler/compileBroker.hpp"
27 #include "gc/shared/collectedHeap.hpp"
28 #include "jfr/jfrEvents.hpp"
29 #include "jfr/support/jfrThreadId.hpp"
30 #include "logging/log.hpp"
31 #include "logging/logStream.hpp"
32 #include "logging/logConfiguration.hpp"
33 #include "memory/resourceArea.hpp"
34 #include "memory/universe.hpp"
35 #include "oops/method.hpp"
36 #include "oops/oop.inline.hpp"
37 #include "oops/verifyOopClosure.hpp"
38 #include "runtime/atomic.hpp"
39 #include "runtime/handles.inline.hpp"
40 #include "runtime/interfaceSupport.inline.hpp"
41 #include "runtime/mutexLocker.hpp"
42 #include "runtime/os.hpp"
43 #include "runtime/safepoint.hpp"
44 #include "runtime/synchronizer.hpp"
45 #include "runtime/thread.inline.hpp"
46 #include "runtime/vmThread.hpp"
47 #include "runtime/vmOperations.hpp"
48 #include "services/runtimeService.hpp"
49 #include "utilities/dtrace.hpp"
50 #include "utilities/events.hpp"
51 #include "utilities/vmError.hpp"
52 #include "utilities/xmlstream.hpp"
53
54 VM_QueueHead VMOperationQueue::_queue_head[VMOperationQueue::nof_priorities];
55
56 VMOperationQueue::VMOperationQueue() {
57 // The queue is a circular doubled-linked list, which always contains
58 // one element (i.e., one element means empty).
59 for(int i = 0; i < nof_priorities; i++) {
60 _queue_length[i] = 0;
61 _queue_counter = 0;
62 _queue[i] = &_queue_head[i];
63 _queue[i]->set_next(_queue[i]);
64 _queue[i]->set_prev(_queue[i]);
267 : VMThreadPriority;
268 // Note that I cannot call os::set_priority because it expects Java
269 // priorities and I am *explicitly* using OS priorities so that it's
270 // possible to set the VM thread priority higher than any Java thread.
271 os::set_native_priority( this, prio );
272
273 // Wait for VM_Operations until termination
274 this->loop();
275
276 // Note the intention to exit before safepointing.
277 // 6295565 This has the effect of waiting for any large tty
278 // outputs to finish.
279 if (xtty != NULL) {
280 ttyLocker ttyl;
281 xtty->begin_elem("destroy_vm");
282 xtty->stamp();
283 xtty->end_elem();
284 assert(should_terminate(), "termination flag must be set");
285 }
286
287 if (AsyncDeflateIdleMonitors && log_is_enabled(Info, monitorinflation)) {
288 // AsyncDeflateIdleMonitors does a special deflation at the final
289 // safepoint in order to reduce the in-use monitor population that
290 // is reported by ObjectSynchronizer::log_in_use_monitor_details()
291 // at VM exit.
292 ObjectSynchronizer::set_is_special_deflation_requested(true);
293 }
294
295 // 4526887 let VM thread exit at Safepoint
296 _cur_vm_operation = &halt_op;
297 SafepointSynchronize::begin();
298
299 if (VerifyBeforeExit) {
300 HandleMark hm(VMThread::vm_thread());
301 // Among other things, this ensures that Eden top is correct.
302 Universe::heap()->prepare_for_verify();
303 // Silent verification so as not to pollute normal output,
304 // unless we really asked for it.
305 Universe::verify();
306 }
307
308 CompileBroker::set_should_block();
309
310 // wait for threads (compiler threads or daemon threads) in the
311 // _thread_in_native state to block.
312 VM_Exit::wait_for_threads_in_native_to_block();
313
314 // signal other threads that VM process is gone
|