src/share/vm/runtime/vmThread.cpp

Print this page
rev 4215 : 8007147: Trace event ExecuteVMOperation may get dangling pointer
Reviewed-by:


 366 
 367 void VMThread::evaluate_operation(VM_Operation* op) {
 368   ResourceMark rm;
 369 
 370   {
 371     PerfTraceTime vm_op_timer(perf_accumulated_vm_operation_time());
 372 #ifndef USDT2
 373     HS_DTRACE_PROBE3(hotspot, vmops__begin, op->name(), strlen(op->name()),
 374                      op->evaluation_mode());
 375 #else /* USDT2 */
 376     HOTSPOT_VMOPS_BEGIN(
 377                      (char *) op->name(), strlen(op->name()),
 378                      op->evaluation_mode());
 379 #endif /* USDT2 */
 380 
 381     EventExecuteVMOperation event;
 382 
 383     op->evaluate();
 384 
 385     if (event.should_commit()) {



 386       event.set_operation(op->type());
 387       event.set_safepoint(op->evaluate_at_safepoint());
 388       event.set_blocking(!op->evaluate_concurrently());
 389       event.set_caller(op->calling_thread()->osthread()->thread_id());
 390       event.commit();



 391     }
 392 
 393 #ifndef USDT2
 394     HS_DTRACE_PROBE3(hotspot, vmops__end, op->name(), strlen(op->name()),
 395                      op->evaluation_mode());
 396 #else /* USDT2 */
 397     HOTSPOT_VMOPS_END(
 398                      (char *) op->name(), strlen(op->name()),
 399                      op->evaluation_mode());
 400 #endif /* USDT2 */
 401   }
 402 
 403   // Last access of info in _cur_vm_operation!
 404   bool c_heap_allocated = op->is_cheap_allocated();
 405 
 406   // Mark as completed
 407   if (!op->evaluate_concurrently()) {
 408     op->calling_thread()->increment_vm_operation_completed_count();
 409   }
 410   // It is unsafe to access the _cur_vm_operation after the 'increment_vm_operation_completed_count' call,




 366 
 367 void VMThread::evaluate_operation(VM_Operation* op) {
 368   ResourceMark rm;
 369 
 370   {
 371     PerfTraceTime vm_op_timer(perf_accumulated_vm_operation_time());
 372 #ifndef USDT2
 373     HS_DTRACE_PROBE3(hotspot, vmops__begin, op->name(), strlen(op->name()),
 374                      op->evaluation_mode());
 375 #else /* USDT2 */
 376     HOTSPOT_VMOPS_BEGIN(
 377                      (char *) op->name(), strlen(op->name()),
 378                      op->evaluation_mode());
 379 #endif /* USDT2 */
 380 
 381     EventExecuteVMOperation event;
 382 
 383     op->evaluate();
 384 
 385     if (event.should_commit()) {
 386       if (!op->evaluate_concurrently()) {
 387         // Only try to commit vm operation event for non-concurrent vm operations.
 388         // For concurrent vm operations, the caller thread could have exited already.
 389         event.set_operation(op->type());
 390         event.set_safepoint(op->evaluate_at_safepoint());
 391         event.set_blocking(true);
 392         event.set_caller(op->calling_thread()->osthread()->thread_id());
 393         event.commit();
 394       } else {
 395         event.cancel();
 396       }
 397     }
 398 
 399 #ifndef USDT2
 400     HS_DTRACE_PROBE3(hotspot, vmops__end, op->name(), strlen(op->name()),
 401                      op->evaluation_mode());
 402 #else /* USDT2 */
 403     HOTSPOT_VMOPS_END(
 404                      (char *) op->name(), strlen(op->name()),
 405                      op->evaluation_mode());
 406 #endif /* USDT2 */
 407   }
 408 
 409   // Last access of info in _cur_vm_operation!
 410   bool c_heap_allocated = op->is_cheap_allocated();
 411 
 412   // Mark as completed
 413   if (!op->evaluate_concurrently()) {
 414     op->calling_thread()->increment_vm_operation_completed_count();
 415   }
 416   // It is unsafe to access the _cur_vm_operation after the 'increment_vm_operation_completed_count' call,