23 */
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/handles.inline.hpp"
39 #include "runtime/interfaceSupport.inline.hpp"
40 #include "runtime/mutexLocker.hpp"
41 #include "runtime/os.hpp"
42 #include "runtime/safepoint.hpp"
43 #include "runtime/thread.inline.hpp"
44 #include "runtime/vmThread.hpp"
45 #include "runtime/vmOperations.hpp"
46 #include "services/runtimeService.hpp"
47 #include "utilities/dtrace.hpp"
48 #include "utilities/events.hpp"
49 #include "utilities/vmError.hpp"
50 #include "utilities/xmlstream.hpp"
51
52 VMOperationQueue::VMOperationQueue() {
53 // The queue is a circular doubled-linked list, which always contains
54 // one element (i.e., one element means empty).
55 for(int i = 0; i < nof_priorities; i++) {
56 _queue_length[i] = 0;
57 _queue_counter = 0;
58 _queue[i] = new VM_None("QueueHead");
59 _queue[i]->set_next(_queue[i]);
60 _queue[i]->set_prev(_queue[i]);
61 }
62 _drain_list = NULL;
297 int prio = (VMThreadPriority == -1)
298 ? os::java_to_os_priority[NearMaxPriority]
299 : VMThreadPriority;
300 // Note that I cannot call os::set_priority because it expects Java
301 // priorities and I am *explicitly* using OS priorities so that it's
302 // possible to set the VM thread priority higher than any Java thread.
303 os::set_native_priority( this, prio );
304
305 // Wait for VM_Operations until termination
306 this->loop();
307
308 // Note the intention to exit before safepointing.
309 // 6295565 This has the effect of waiting for any large tty
310 // outputs to finish.
311 if (xtty != NULL) {
312 ttyLocker ttyl;
313 xtty->begin_elem("destroy_vm");
314 xtty->stamp();
315 xtty->end_elem();
316 assert(should_terminate(), "termination flag must be set");
317 }
318
319 // 4526887 let VM thread exit at Safepoint
320 _cur_vm_operation = &halt_op;
321 SafepointSynchronize::begin();
322
323 if (VerifyBeforeExit) {
324 HandleMark hm(VMThread::vm_thread());
325 // Among other things, this ensures that Eden top is correct.
326 Universe::heap()->prepare_for_verify();
327 // Silent verification so as not to pollute normal output,
328 // unless we really asked for it.
329 Universe::verify();
330 }
331
332 CompileBroker::set_should_block();
333
334 // wait for threads (compiler threads or daemon threads) in the
335 // _thread_in_native state to block.
336 VM_Exit::wait_for_threads_in_native_to_block();
|
23 */
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/handles.inline.hpp"
39 #include "runtime/interfaceSupport.inline.hpp"
40 #include "runtime/mutexLocker.hpp"
41 #include "runtime/os.hpp"
42 #include "runtime/safepoint.hpp"
43 #include "runtime/synchronizer.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 VMOperationQueue::VMOperationQueue() {
54 // The queue is a circular doubled-linked list, which always contains
55 // one element (i.e., one element means empty).
56 for(int i = 0; i < nof_priorities; i++) {
57 _queue_length[i] = 0;
58 _queue_counter = 0;
59 _queue[i] = new VM_None("QueueHead");
60 _queue[i]->set_next(_queue[i]);
61 _queue[i]->set_prev(_queue[i]);
62 }
63 _drain_list = NULL;
298 int prio = (VMThreadPriority == -1)
299 ? os::java_to_os_priority[NearMaxPriority]
300 : VMThreadPriority;
301 // Note that I cannot call os::set_priority because it expects Java
302 // priorities and I am *explicitly* using OS priorities so that it's
303 // possible to set the VM thread priority higher than any Java thread.
304 os::set_native_priority( this, prio );
305
306 // Wait for VM_Operations until termination
307 this->loop();
308
309 // Note the intention to exit before safepointing.
310 // 6295565 This has the effect of waiting for any large tty
311 // outputs to finish.
312 if (xtty != NULL) {
313 ttyLocker ttyl;
314 xtty->begin_elem("destroy_vm");
315 xtty->stamp();
316 xtty->end_elem();
317 assert(should_terminate(), "termination flag must be set");
318 }
319
320 if (AsyncDeflateIdleMonitors) {
321 // AsyncDeflateIdleMonitors does a special deflation at the final
322 // safepoint in order to reduce the in-use monitor population that
323 // is reported ObjectSynchronizer::log_in_use_monitor_details() at
324 // VM exit.
325 ObjectSynchronizer::set_is_special_deflation_requested(true);
326 }
327
328 // 4526887 let VM thread exit at Safepoint
329 _cur_vm_operation = &halt_op;
330 SafepointSynchronize::begin();
331
332 if (VerifyBeforeExit) {
333 HandleMark hm(VMThread::vm_thread());
334 // Among other things, this ensures that Eden top is correct.
335 Universe::heap()->prepare_for_verify();
336 // Silent verification so as not to pollute normal output,
337 // unless we really asked for it.
338 Universe::verify();
339 }
340
341 CompileBroker::set_should_block();
342
343 // wait for threads (compiler threads or daemon threads) in the
344 // _thread_in_native state to block.
345 VM_Exit::wait_for_threads_in_native_to_block();
|