src/share/vm/runtime/vmThread.cpp

changeset 9858
b985cbb00e68
parent 9676
bf1c9a3312a4
child 9896
1b8c45b8216a
equal deleted inserted replaced
9727:c7a3e57fdf4a 9858:b985cbb00e68
23 */ 23 */
24 24
25 #include "precompiled.hpp" 25 #include "precompiled.hpp"
26 #include "compiler/compileBroker.hpp" 26 #include "compiler/compileBroker.hpp"
27 #include "gc_interface/collectedHeap.hpp" 27 #include "gc_interface/collectedHeap.hpp"
28 #include "jfr/jfrEvents.hpp"
29 #include "jfr/support/jfrThreadId.hpp"
28 #include "memory/resourceArea.hpp" 30 #include "memory/resourceArea.hpp"
29 #include "oops/method.hpp" 31 #include "oops/method.hpp"
30 #include "oops/oop.inline.hpp" 32 #include "oops/oop.inline.hpp"
31 #include "runtime/interfaceSupport.hpp" 33 #include "runtime/interfaceSupport.hpp"
32 #include "runtime/mutexLocker.hpp" 34 #include "runtime/mutexLocker.hpp"
33 #include "runtime/os.hpp" 35 #include "runtime/os.hpp"
34 #include "runtime/thread.inline.hpp" 36 #include "runtime/thread.inline.hpp"
35 #include "runtime/vmThread.hpp" 37 #include "runtime/vmThread.hpp"
36 #include "runtime/vm_operations.hpp" 38 #include "runtime/vm_operations.hpp"
37 #include "services/runtimeService.hpp" 39 #include "services/runtimeService.hpp"
38 #include "trace/tracing.hpp"
39 #include "utilities/dtrace.hpp" 40 #include "utilities/dtrace.hpp"
40 #include "utilities/events.hpp" 41 #include "utilities/events.hpp"
41 #include "utilities/xmlstream.hpp" 42 #include "utilities/xmlstream.hpp"
42 43
43 #ifndef USDT2 44 #ifndef USDT2
357 st->print("\"%s\" ", name()); 358 st->print("\"%s\" ", name());
358 Thread::print_on(st); 359 Thread::print_on(st);
359 st->cr(); 360 st->cr();
360 } 361 }
361 362
363 static void post_vm_operation_event(EventExecuteVMOperation* event, VM_Operation* op) {
364 assert(event != NULL, "invariant");
365 assert(event->should_commit(), "invariant");
366 assert(op != NULL, "invariant");
367 const bool is_concurrent = op->evaluate_concurrently();
368 const bool evaluate_at_safepoint = op->evaluate_at_safepoint();
369 event->set_operation(op->type());
370 event->set_safepoint(evaluate_at_safepoint);
371 event->set_blocking(!is_concurrent);
372 // Only write caller thread information for non-concurrent vm operations.
373 // For concurrent vm operations, the thread id is set to 0 indicating thread is unknown.
374 // This is because the caller thread could have exited already.
375 event->set_caller(is_concurrent ? 0 : JFR_THREAD_ID(op->calling_thread()));
376 event->set_safepointId(evaluate_at_safepoint ? SafepointSynchronize::safepoint_counter() : 0);
377 event->commit();
378 }
379
362 void VMThread::evaluate_operation(VM_Operation* op) { 380 void VMThread::evaluate_operation(VM_Operation* op) {
363 ResourceMark rm; 381 ResourceMark rm;
364 382
365 { 383 {
366 PerfTraceTime vm_op_timer(perf_accumulated_vm_operation_time()); 384 PerfTraceTime vm_op_timer(perf_accumulated_vm_operation_time());
372 (char *) op->name(), strlen(op->name()), 390 (char *) op->name(), strlen(op->name()),
373 op->evaluation_mode()); 391 op->evaluation_mode());
374 #endif /* USDT2 */ 392 #endif /* USDT2 */
375 393
376 EventExecuteVMOperation event; 394 EventExecuteVMOperation event;
377
378 op->evaluate(); 395 op->evaluate();
379
380 if (event.should_commit()) { 396 if (event.should_commit()) {
381 bool is_concurrent = op->evaluate_concurrently(); 397 post_vm_operation_event(&event, op);
382 event.set_operation(op->type());
383 event.set_safepoint(op->evaluate_at_safepoint());
384 event.set_blocking(!is_concurrent);
385 // Only write caller thread information for non-concurrent vm operations.
386 // For concurrent vm operations, the thread id is set to 0 indicating thread is unknown.
387 // This is because the caller thread could have exited already.
388 event.set_caller(is_concurrent ? 0 : op->calling_thread()->osthread()->thread_id());
389 event.commit();
390 } 398 }
391 399
392 #ifndef USDT2 400 #ifndef USDT2
393 HS_DTRACE_PROBE3(hotspot, vmops__end, op->name(), strlen(op->name()), 401 HS_DTRACE_PROBE3(hotspot, vmops__end, op->name(), strlen(op->name()),
394 op->evaluation_mode()); 402 op->evaluation_mode());

mercurial