src/share/vm/runtime/vmThread.cpp

Print this page
rev 4773 : 8005849: JEP 167: Event-Based JVM Tracing
Reviewed-by: acorn, coleenp, sla
Contributed-by: Karen Kinnear <karen.kinnear@oracle.com>, Bengt Rutisson <bengt.rutisson@oracle.com>, Calvin Cheung <calvin.cheung@oracle.com>, Erik Gahlin <erik.gahlin@oracle.com>, Erik Helin <erik.helin@oracle.com>, Jesper Wilhelmsson <jesper.wilhelmsson@oracle.com>, Keith McGuigan <keith.mcguigan@oracle.com>, Mattias Tobiasson <mattias.tobiasson@oracle.com>, Markus Gronlund <markus.gronlund@oracle.com>, Mikael Auno <mikael.auno@oracle.com>, Nils Eliasson <nils.eliasson@oracle.com>, Nils Loodin <nils.loodin@oracle.com>, Rickard Backman <rickard.backman@oracle.com>, Staffan Larsen <staffan.larsen@oracle.com>, Stefan Karlsson <stefan.karlsson@oracle.com>, Yekaterina Kantserova <yekaterina.kantserova@oracle.com>


  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "compiler/compileBroker.hpp"
  27 #include "gc_interface/collectedHeap.hpp"
  28 #include "memory/resourceArea.hpp"
  29 #include "oops/method.hpp"
  30 #include "oops/oop.inline.hpp"
  31 #include "runtime/interfaceSupport.hpp"
  32 #include "runtime/mutexLocker.hpp"
  33 #include "runtime/os.hpp"
  34 #include "runtime/thread.inline.hpp"
  35 #include "runtime/vmThread.hpp"
  36 #include "runtime/vm_operations.hpp"
  37 #include "services/runtimeService.hpp"

  38 #include "utilities/dtrace.hpp"
  39 #include "utilities/events.hpp"
  40 #include "utilities/xmlstream.hpp"
  41 
  42 #ifndef USDT2
  43 HS_DTRACE_PROBE_DECL3(hotspot, vmops__request, char *, uintptr_t, int);
  44 HS_DTRACE_PROBE_DECL3(hotspot, vmops__begin, char *, uintptr_t, int);
  45 HS_DTRACE_PROBE_DECL3(hotspot, vmops__end, char *, uintptr_t, int);
  46 #endif /* !USDT2 */
  47 
  48 // Dummy VM operation to act as first element in our circular double-linked list
  49 class VM_Dummy: public VM_Operation {
  50   VMOp_Type type() const { return VMOp_Dummy; }
  51   void  doit() {};
  52 };
  53 
  54 VMOperationQueue::VMOperationQueue() {
  55   // The queue is a circular doubled-linked list, which always contains
  56   // one element (i.e., one element means empty).
  57   for(int i = 0; i < nof_priorities; i++) {


 348 
 349 void VMThread::print_on(outputStream* st) const {
 350   st->print("\"%s\" ", name());
 351   Thread::print_on(st);
 352   st->cr();
 353 }
 354 
 355 void VMThread::evaluate_operation(VM_Operation* op) {
 356   ResourceMark rm;
 357 
 358   {
 359     PerfTraceTime vm_op_timer(perf_accumulated_vm_operation_time());
 360 #ifndef USDT2
 361     HS_DTRACE_PROBE3(hotspot, vmops__begin, op->name(), strlen(op->name()),
 362                      op->evaluation_mode());
 363 #else /* USDT2 */
 364     HOTSPOT_VMOPS_BEGIN(
 365                      (char *) op->name(), strlen(op->name()),
 366                      op->evaluation_mode());
 367 #endif /* USDT2 */



 368     op->evaluate();













 369 #ifndef USDT2
 370     HS_DTRACE_PROBE3(hotspot, vmops__end, op->name(), strlen(op->name()),
 371                      op->evaluation_mode());
 372 #else /* USDT2 */
 373     HOTSPOT_VMOPS_END(
 374                      (char *) op->name(), strlen(op->name()),
 375                      op->evaluation_mode());
 376 #endif /* USDT2 */
 377   }
 378 
 379   // Last access of info in _cur_vm_operation!
 380   bool c_heap_allocated = op->is_cheap_allocated();
 381 
 382   // Mark as completed
 383   if (!op->evaluate_concurrently()) {
 384     op->calling_thread()->increment_vm_operation_completed_count();
 385   }
 386   // It is unsafe to access the _cur_vm_operation after the 'increment_vm_operation_completed_count' call,
 387   // since if it is stack allocated the calling thread might have deallocated
 388   if (c_heap_allocated) {




  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "compiler/compileBroker.hpp"
  27 #include "gc_interface/collectedHeap.hpp"
  28 #include "memory/resourceArea.hpp"
  29 #include "oops/method.hpp"
  30 #include "oops/oop.inline.hpp"
  31 #include "runtime/interfaceSupport.hpp"
  32 #include "runtime/mutexLocker.hpp"
  33 #include "runtime/os.hpp"
  34 #include "runtime/thread.inline.hpp"
  35 #include "runtime/vmThread.hpp"
  36 #include "runtime/vm_operations.hpp"
  37 #include "services/runtimeService.hpp"
  38 #include "trace/tracing.hpp"
  39 #include "utilities/dtrace.hpp"
  40 #include "utilities/events.hpp"
  41 #include "utilities/xmlstream.hpp"
  42 
  43 #ifndef USDT2
  44 HS_DTRACE_PROBE_DECL3(hotspot, vmops__request, char *, uintptr_t, int);
  45 HS_DTRACE_PROBE_DECL3(hotspot, vmops__begin, char *, uintptr_t, int);
  46 HS_DTRACE_PROBE_DECL3(hotspot, vmops__end, char *, uintptr_t, int);
  47 #endif /* !USDT2 */
  48 
  49 // Dummy VM operation to act as first element in our circular double-linked list
  50 class VM_Dummy: public VM_Operation {
  51   VMOp_Type type() const { return VMOp_Dummy; }
  52   void  doit() {};
  53 };
  54 
  55 VMOperationQueue::VMOperationQueue() {
  56   // The queue is a circular doubled-linked list, which always contains
  57   // one element (i.e., one element means empty).
  58   for(int i = 0; i < nof_priorities; i++) {


 349 
 350 void VMThread::print_on(outputStream* st) const {
 351   st->print("\"%s\" ", name());
 352   Thread::print_on(st);
 353   st->cr();
 354 }
 355 
 356 void VMThread::evaluate_operation(VM_Operation* op) {
 357   ResourceMark rm;
 358 
 359   {
 360     PerfTraceTime vm_op_timer(perf_accumulated_vm_operation_time());
 361 #ifndef USDT2
 362     HS_DTRACE_PROBE3(hotspot, vmops__begin, op->name(), strlen(op->name()),
 363                      op->evaluation_mode());
 364 #else /* USDT2 */
 365     HOTSPOT_VMOPS_BEGIN(
 366                      (char *) op->name(), strlen(op->name()),
 367                      op->evaluation_mode());
 368 #endif /* USDT2 */
 369 
 370     EventExecuteVMOperation event;
 371 
 372     op->evaluate();
 373 
 374     if (event.should_commit()) {
 375       bool is_concurrent = op->evaluate_concurrently();
 376       event.set_operation(op->type());
 377       event.set_safepoint(op->evaluate_at_safepoint());
 378       event.set_blocking(!is_concurrent);
 379       // Only write caller thread information for non-concurrent vm operations.
 380       // For concurrent vm operations, the thread id is set to 0 indicating thread is unknown.
 381       // This is because the caller thread could have exited already.
 382       event.set_caller(is_concurrent ? 0 : op->calling_thread()->osthread()->thread_id());
 383       event.commit();
 384     }
 385 
 386 #ifndef USDT2
 387     HS_DTRACE_PROBE3(hotspot, vmops__end, op->name(), strlen(op->name()),
 388                      op->evaluation_mode());
 389 #else /* USDT2 */
 390     HOTSPOT_VMOPS_END(
 391                      (char *) op->name(), strlen(op->name()),
 392                      op->evaluation_mode());
 393 #endif /* USDT2 */
 394   }
 395 
 396   // Last access of info in _cur_vm_operation!
 397   bool c_heap_allocated = op->is_cheap_allocated();
 398 
 399   // Mark as completed
 400   if (!op->evaluate_concurrently()) {
 401     op->calling_thread()->increment_vm_operation_completed_count();
 402   }
 403   // It is unsafe to access the _cur_vm_operation after the 'increment_vm_operation_completed_count' call,
 404   // since if it is stack allocated the calling thread might have deallocated
 405   if (c_heap_allocated) {