|
24 | 24 |
|
25 | 25 | #include "precompiled.hpp" |
26 | 26 | #include "compiler/compileBroker.hpp" |
27 | | -#include "gc/shared/collectedHeap.hpp" |
28 | 27 | #include "jfr/jfrEvents.hpp" |
29 | 28 | #include "jfr/support/jfrThreadId.hpp" |
30 | 29 | #include "logging/log.hpp" |
31 | 30 | #include "logging/logStream.hpp" |
32 | 31 | #include "logging/logConfiguration.hpp" |
33 | 32 | #include "memory/resourceArea.hpp" |
34 | 33 | #include "memory/universe.hpp" |
35 | | -#include "oops/method.hpp" |
36 | 34 | #include "oops/oop.inline.hpp" |
37 | 35 | #include "oops/verifyOopClosure.hpp" |
38 | 36 | #include "runtime/atomic.hpp" |
|
43 | 41 | #include "runtime/safepoint.hpp" |
44 | 42 | #include "runtime/synchronizer.hpp" |
45 | 43 | #include "runtime/thread.inline.hpp" |
| 44 | +#include "runtime/timerTrace.hpp" |
46 | 45 | #include "runtime/vmThread.hpp" |
47 | 46 | #include "runtime/vmOperations.hpp" |
48 | | -#include "services/runtimeService.hpp" |
49 | 47 | #include "utilities/dtrace.hpp" |
50 | 48 | #include "utilities/events.hpp" |
51 | 49 | #include "utilities/vmError.hpp" |
52 | | -#include "utilities/xmlstream.hpp" |
53 | 50 |
|
54 | 51 |
|
55 | 52 | //------------------------------------------------------------------------------------------------------------------ |
@@ -345,17 +342,27 @@ void VMThread::wait_until_executed(VM_Operation* op) { |
345 | 342 | Thread::current()->is_Java_thread() ? |
346 | 343 | Mutex::_safepoint_check_flag : |
347 | 344 | 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(); |
352 | 355 | } |
353 | | - ml.wait(); |
354 | 356 | } |
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 | + } |
359 | 366 | } |
360 | 367 | } |
361 | 368 |
|
@@ -389,8 +396,6 @@ void VMThread::inner_execute(VM_Operation* op) { |
389 | 396 | HandleMark hm(VMThread::vm_thread()); |
390 | 397 | EventMark em("Executing %s VM operation: %s", prev_vm_operation != NULL ? "nested" : "", op->name()); |
391 | 398 |
|
392 | | - // If we are at a safepoint we will evaluate all the operations that |
393 | | - // follow that also require a safepoint |
394 | 399 | log_debug(vmthread)("Evaluating %s %s VM operation: %s", |
395 | 400 | prev_vm_operation != NULL ? "nested" : "", |
396 | 401 | _cur_vm_operation->evaluate_at_safepoint() ? "safepoint" : "non-safepoint", |
|
0 commit comments