Skip to content

Commit f590c6c

Browse files
committed
Update after Coleen and David
1 parent e49178a commit f590c6c

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

src/hotspot/share/runtime/vmThread.cpp

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,13 @@
2424

2525
#include "precompiled.hpp"
2626
#include "compiler/compileBroker.hpp"
27-
#include "gc/shared/collectedHeap.hpp"
2827
#include "jfr/jfrEvents.hpp"
2928
#include "jfr/support/jfrThreadId.hpp"
3029
#include "logging/log.hpp"
3130
#include "logging/logStream.hpp"
3231
#include "logging/logConfiguration.hpp"
3332
#include "memory/resourceArea.hpp"
3433
#include "memory/universe.hpp"
35-
#include "oops/method.hpp"
3634
#include "oops/oop.inline.hpp"
3735
#include "oops/verifyOopClosure.hpp"
3836
#include "runtime/atomic.hpp"
@@ -43,13 +41,12 @@
4341
#include "runtime/safepoint.hpp"
4442
#include "runtime/synchronizer.hpp"
4543
#include "runtime/thread.inline.hpp"
44+
#include "runtime/timerTrace.hpp"
4645
#include "runtime/vmThread.hpp"
4746
#include "runtime/vmOperations.hpp"
48-
#include "services/runtimeService.hpp"
4947
#include "utilities/dtrace.hpp"
5048
#include "utilities/events.hpp"
5149
#include "utilities/vmError.hpp"
52-
#include "utilities/xmlstream.hpp"
5350

5451

5552
//------------------------------------------------------------------------------------------------------------------
@@ -345,17 +342,27 @@ void VMThread::wait_until_executed(VM_Operation* op) {
345342
Thread::current()->is_Java_thread() ?
346343
Mutex::_safepoint_check_flag :
347344
Mutex::_no_safepoint_check_flag);
348-
while (true) {
349-
if (VMThread::vm_thread()->set_next_operation(op)) {
350-
ml.notify_all();
351-
break;
345+
{
346+
TraceTime timer("Installing VM operation", TRACETIME_LOG(Trace, vmthread));
347+
while (true) {
348+
if (VMThread::vm_thread()->set_next_operation(op)) {
349+
ml.notify_all();
350+
break;
351+
}
352+
// Wait to install this operation as the next operation in the VM Thread
353+
log_trace(vmthread)("A VM operation already set, waiting");
354+
ml.wait();
352355
}
353-
ml.wait();
354356
}
355-
// _next_vm_operation is cleared holding VMOperation_lock
356-
// after it have been executed.
357-
while (_next_vm_operation == op) {
358-
ml.wait();
357+
{
358+
// Wait until the operation has been processed
359+
TraceTime timer("Waiting for VM operation to be completed", TRACETIME_LOG(Trace, vmthread));
360+
// _next_vm_operation is cleared holding VMOperation_lock after it have been
361+
// executed. We wait until _next_vm_operation not our op.
362+
while (_next_vm_operation == op) {
363+
// VM Thread can process it once we unlocks the mutex on wait.
364+
ml.wait();
365+
}
359366
}
360367
}
361368

@@ -389,8 +396,6 @@ void VMThread::inner_execute(VM_Operation* op) {
389396
HandleMark hm(VMThread::vm_thread());
390397
EventMark em("Executing %s VM operation: %s", prev_vm_operation != NULL ? "nested" : "", op->name());
391398

392-
// If we are at a safepoint we will evaluate all the operations that
393-
// follow that also require a safepoint
394399
log_debug(vmthread)("Evaluating %s %s VM operation: %s",
395400
prev_vm_operation != NULL ? "nested" : "",
396401
_cur_vm_operation->evaluate_at_safepoint() ? "safepoint" : "non-safepoint",

0 commit comments

Comments
 (0)