23 */
24
25 #include "precompiled.hpp"
26 #include "compiler/compileBroker.hpp"
27 #include "gc/shared/collectedHeap.hpp"
28 #include "memory/resourceArea.hpp"
29 #include "oops/method.hpp"
30 #include "oops/oop.inline.hpp"
31 #include "oops/verifyOopClosure.hpp"
32 #include "runtime/interfaceSupport.hpp"
33 #include "runtime/mutexLocker.hpp"
34 #include "runtime/os.hpp"
35 #include "runtime/safepoint.hpp"
36 #include "runtime/thread.inline.hpp"
37 #include "runtime/vmThread.hpp"
38 #include "runtime/vm_operations.hpp"
39 #include "services/runtimeService.hpp"
40 #include "trace/tracing.hpp"
41 #include "utilities/dtrace.hpp"
42 #include "utilities/events.hpp"
43 #include "utilities/xmlstream.hpp"
44
45 // Dummy VM operation to act as first element in our circular double-linked list
46 class VM_Dummy: public VM_Operation {
47 VMOp_Type type() const { return VMOp_Dummy; }
48 void doit() {};
49 };
50
51 VMOperationQueue::VMOperationQueue() {
52 // The queue is a circular doubled-linked list, which always contains
53 // one element (i.e., one element means empty).
54 for(int i = 0; i < nof_priorities; i++) {
55 _queue_length[i] = 0;
56 _queue_counter = 0;
57 _queue[i] = new VM_Dummy();
58 _queue[i]->set_next(_queue[i]);
59 _queue[i]->set_prev(_queue[i]);
60 }
61 _drain_list = NULL;
62 }
416
417 // Look for new operation
418 assert(_cur_vm_operation == NULL, "no current one should be executing");
419 _cur_vm_operation = _vm_queue->remove_next();
420
421 // Stall time tracking code
422 if (PrintVMQWaitTime && _cur_vm_operation != NULL &&
423 !_cur_vm_operation->evaluate_concurrently()) {
424 long stall = os::javaTimeMillis() - _cur_vm_operation->timestamp();
425 if (stall > 0)
426 tty->print_cr("%s stall: %ld", _cur_vm_operation->name(), stall);
427 }
428
429 while (!should_terminate() && _cur_vm_operation == NULL) {
430 // wait with a timeout to guarantee safepoints at regular intervals
431 bool timedout =
432 VMOperationQueue_lock->wait(Mutex::_no_safepoint_check_flag,
433 GuaranteedSafepointInterval);
434
435 // Support for self destruction
436 if ((SelfDestructTimer != 0) && !is_error_reported() &&
437 (os::elapsedTime() > (double)SelfDestructTimer * 60.0)) {
438 tty->print_cr("VM self-destructed");
439 exit(-1);
440 }
441
442 if (timedout && VMThread::no_op_safepoint_needed(false)) {
443 MutexUnlockerEx mul(VMOperationQueue_lock,
444 Mutex::_no_safepoint_check_flag);
445 // Force a safepoint since we have not had one for at least
446 // 'GuaranteedSafepointInterval' milliseconds. This will run all
447 // the clean-up processing that needs to be done regularly at a
448 // safepoint
449 SafepointSynchronize::begin();
450 #ifdef ASSERT
451 if (GCALotAtAllSafepoints) InterfaceSupport::check_gc_alot();
452 #endif
453 SafepointSynchronize::end();
454 }
455 _cur_vm_operation = _vm_queue->remove_next();
456
|
23 */
24
25 #include "precompiled.hpp"
26 #include "compiler/compileBroker.hpp"
27 #include "gc/shared/collectedHeap.hpp"
28 #include "memory/resourceArea.hpp"
29 #include "oops/method.hpp"
30 #include "oops/oop.inline.hpp"
31 #include "oops/verifyOopClosure.hpp"
32 #include "runtime/interfaceSupport.hpp"
33 #include "runtime/mutexLocker.hpp"
34 #include "runtime/os.hpp"
35 #include "runtime/safepoint.hpp"
36 #include "runtime/thread.inline.hpp"
37 #include "runtime/vmThread.hpp"
38 #include "runtime/vm_operations.hpp"
39 #include "services/runtimeService.hpp"
40 #include "trace/tracing.hpp"
41 #include "utilities/dtrace.hpp"
42 #include "utilities/events.hpp"
43 #include "utilities/vmError.hpp"
44 #include "utilities/xmlstream.hpp"
45
46 // Dummy VM operation to act as first element in our circular double-linked list
47 class VM_Dummy: public VM_Operation {
48 VMOp_Type type() const { return VMOp_Dummy; }
49 void doit() {};
50 };
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_Dummy();
59 _queue[i]->set_next(_queue[i]);
60 _queue[i]->set_prev(_queue[i]);
61 }
62 _drain_list = NULL;
63 }
417
418 // Look for new operation
419 assert(_cur_vm_operation == NULL, "no current one should be executing");
420 _cur_vm_operation = _vm_queue->remove_next();
421
422 // Stall time tracking code
423 if (PrintVMQWaitTime && _cur_vm_operation != NULL &&
424 !_cur_vm_operation->evaluate_concurrently()) {
425 long stall = os::javaTimeMillis() - _cur_vm_operation->timestamp();
426 if (stall > 0)
427 tty->print_cr("%s stall: %ld", _cur_vm_operation->name(), stall);
428 }
429
430 while (!should_terminate() && _cur_vm_operation == NULL) {
431 // wait with a timeout to guarantee safepoints at regular intervals
432 bool timedout =
433 VMOperationQueue_lock->wait(Mutex::_no_safepoint_check_flag,
434 GuaranteedSafepointInterval);
435
436 // Support for self destruction
437 if ((SelfDestructTimer != 0) && !VMError::is_error_reported() &&
438 (os::elapsedTime() > (double)SelfDestructTimer * 60.0)) {
439 tty->print_cr("VM self-destructed");
440 exit(-1);
441 }
442
443 if (timedout && VMThread::no_op_safepoint_needed(false)) {
444 MutexUnlockerEx mul(VMOperationQueue_lock,
445 Mutex::_no_safepoint_check_flag);
446 // Force a safepoint since we have not had one for at least
447 // 'GuaranteedSafepointInterval' milliseconds. This will run all
448 // the clean-up processing that needs to be done regularly at a
449 // safepoint
450 SafepointSynchronize::begin();
451 #ifdef ASSERT
452 if (GCALotAtAllSafepoints) InterfaceSupport::check_gc_alot();
453 #endif
454 SafepointSynchronize::end();
455 }
456 _cur_vm_operation = _vm_queue->remove_next();
457
|