--- old/src/share/vm/runtime/vmThread.cpp 2019-02-15 19:02:46.598513004 +0300 +++ new/src/share/vm/runtime/vmThread.cpp 2019-02-15 19:02:46.494516635 +0300 @@ -25,6 +25,8 @@ #include "precompiled.hpp" #include "compiler/compileBroker.hpp" #include "gc_interface/collectedHeap.hpp" +#include "jfr/jfrEvents.hpp" +#include "jfr/support/jfrThreadId.hpp" #include "memory/resourceArea.hpp" #include "oops/method.hpp" #include "oops/oop.inline.hpp" @@ -35,7 +37,6 @@ #include "runtime/vmThread.hpp" #include "runtime/vm_operations.hpp" #include "services/runtimeService.hpp" -#include "trace/tracing.hpp" #include "utilities/dtrace.hpp" #include "utilities/events.hpp" #include "utilities/xmlstream.hpp" @@ -358,6 +359,23 @@ st->cr(); } +static void post_vm_operation_event(EventExecuteVMOperation* event, VM_Operation* op) { + assert(event != NULL, "invariant"); + assert(event->should_commit(), "invariant"); + assert(op != NULL, "invariant"); + const bool is_concurrent = op->evaluate_concurrently(); + const bool evaluate_at_safepoint = op->evaluate_at_safepoint(); + event->set_operation(op->type()); + event->set_safepoint(evaluate_at_safepoint); + event->set_blocking(!is_concurrent); + // Only write caller thread information for non-concurrent vm operations. + // 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->commit(); +} + void VMThread::evaluate_operation(VM_Operation* op) { ResourceMark rm; @@ -373,19 +391,9 @@ #endif /* USDT2 */ EventExecuteVMOperation event; - op->evaluate(); - if (event.should_commit()) { - bool is_concurrent = op->evaluate_concurrently(); - event.set_operation(op->type()); - event.set_safepoint(op->evaluate_at_safepoint()); - event.set_blocking(!is_concurrent); - // Only write caller thread information for non-concurrent vm operations. - // 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 : op->calling_thread()->osthread()->thread_id()); - event.commit(); + post_vm_operation_event(&event, op); } #ifndef USDT2