--- a/src/hotspot/share/runtime/vmThread.cpp Thu Oct 17 20:27:44 2019 +0100
+++ b/src/hotspot/share/runtime/vmThread.cpp Thu Oct 17 20:53:35 2019 +0100
@@ -149,7 +149,7 @@
//-----------------------------------------------------------------
// High-level interface
-bool VMOperationQueue::add(VM_Operation *op) {
+void VMOperationQueue::add(VM_Operation *op) {
HOTSPOT_VMOPS_REQUEST(
(char *) op->name(), strlen(op->name()),
@@ -157,13 +157,7 @@
// Encapsulates VM queue policy. Currently, that
// only involves putting them on the right list
- if (op->evaluate_at_safepoint()) {
- queue_add_back(SafepointPriority, op);
- return true;
- }
-
- queue_add_back(MediumPriority, op);
- return true;
+ queue_add_back(op->evaluate_at_safepoint() ? SafepointPriority : MediumPriority, op);
}
VM_Operation* VMOperationQueue::remove_next() {
@@ -360,9 +354,9 @@
void VMThread::wait_for_vm_thread_exit() {
assert(Thread::current()->is_Java_thread(), "Should be a JavaThread");
assert(((JavaThread*)Thread::current())->is_terminated(), "Should be terminated");
- { MutexLocker mu(VMOperationQueue_lock, Mutex::_no_safepoint_check_flag);
+ { MonitorLocker mu(VMOperationQueue_lock, Mutex::_no_safepoint_check_flag);
_should_terminate = true;
- VMOperationQueue_lock->notify();
+ mu.notify();
}
// Note: VM thread leaves at Safepoint. We are not stopped by Safepoint
@@ -394,7 +388,7 @@
// For concurrent vm operations, the thread id is set to 0 indicating thread is unknown.
// This is because the caller thread could have exited already.
event->set_caller(is_concurrent ? 0 : JFR_THREAD_ID(op->calling_thread()));
- event->set_safepointId(evaluate_at_safepoint ? SafepointSynchronize::safepoint_counter() : 0);
+ event->set_safepointId(evaluate_at_safepoint ? SafepointSynchronize::safepoint_id() : 0);
event->commit();
}
@@ -562,6 +556,7 @@
_cur_vm_operation = safepoint_ops;
if (_cur_vm_operation != NULL) {
do {
+ EventMark em("Executing coalesced safepoint VM operation: %s", _cur_vm_operation->name());
log_debug(vmthread)("Evaluating coalesced safepoint VM operation: %s", _cur_vm_operation->name());
// evaluate_operation deletes the op object so we have
// to grab the next op now
@@ -625,8 +620,8 @@
//
// Notify (potential) waiting Java thread(s)
- { MutexLocker mu(VMOperationRequest_lock, Mutex::_no_safepoint_check_flag);
- VMOperationRequest_lock->notify_all();
+ { MonitorLocker mu(VMOperationRequest_lock, Mutex::_no_safepoint_check_flag);
+ mu.notify_all();
}
// We want to make sure that we get to a safepoint regularly
@@ -674,7 +669,7 @@
bool concurrent = op->evaluate_concurrently();
// only blocking VM operations need to verify the caller's safepoint state:
if (!concurrent) {
- t->check_for_valid_safepoint_state(true);
+ t->check_for_valid_safepoint_state();
}
// New request from Java thread, evaluate prologue
@@ -683,7 +678,7 @@
}
// Setup VM_operations for execution
- op->set_calling_thread(t, Thread::get_priority(t));
+ op->set_calling_thread(t);
// It does not make sense to execute the epilogue, if the VM operation object is getting
// deallocated by the VM thread.
@@ -700,18 +695,11 @@
// VMOperationQueue_lock, so we can block without a safepoint check. This allows vm operation requests
// to be queued up during a safepoint synchronization.
{
- VMOperationQueue_lock->lock_without_safepoint_check();
+ MonitorLocker ml(VMOperationQueue_lock, Mutex::_no_safepoint_check_flag);
log_debug(vmthread)("Adding VM operation: %s", op->name());
- bool ok = _vm_queue->add(op);
+ _vm_queue->add(op);
op->set_timestamp(os::javaTimeMillis());
- VMOperationQueue_lock->notify();
- VMOperationQueue_lock->unlock();
- // VM_Operation got skipped
- if (!ok) {
- assert(concurrent, "can only skip concurrent tasks");
- if (op->is_cheap_allocated()) delete op;
- return;
- }
+ ml.notify();
}
if (!concurrent) {
@@ -738,7 +726,7 @@
fatal("Nested VM operation %s requested by operation %s",
op->name(), vm_operation()->name());
}
- op->set_calling_thread(prev_vm_operation->calling_thread(), prev_vm_operation->priority());
+ op->set_calling_thread(prev_vm_operation->calling_thread());
}
EventMark em("Executing %s VM operation: %s", prev_vm_operation ? "nested" : "", op->name());