< prev index next >

src/hotspot/share/runtime/thread.cpp

Print this page
rev 50464 : Thread Dump Extension (memory allocation)

@@ -235,10 +235,13 @@
   set_metadata_handles(new (ResourceObj::C_HEAP, mtClass) GrowableArray<Metadata*>(30, true));
   set_active_handles(NULL);
   set_free_handle_block(NULL);
   set_last_handle_mark(NULL);
 
+  _statistic_info.setStartTime(os::javaTimeMillis());
+  _statistic_info.setDefineClassCount(0);
+
   // This initial value ==> never claimed.
   _oops_do_parity = 0;
   _threads_hazard_ptr = NULL;
   _threads_list_ptr = NULL;
   _nested_threads_hazard_ptr_cnt = 0;

@@ -867,17 +870,30 @@
       f(metadata_handles()->at(i));
     }
   }
 }
 
-void Thread::print_on(outputStream* st) const {
+void Thread::print_on(outputStream* st, bool extended_thread_info) const {
   // get_priority assumes osthread initialized
   if (osthread() != NULL) {
     int os_prio;
     if (os::get_native_priority(this, &os_prio) == OS_OK) {
       st->print("os_prio=%d ", os_prio);
     }
+
+    st->print("cpu=%.2fms ",
+              os::thread_cpu_time(const_cast<Thread*>(this), true) / 1000000.0
+              );
+    st->print("elapsed=%.2fs ",
+              _statistic_info.getElapsedTime() / 1000.0);
+
+    if (is_Java_thread() && (PrintExtendedThreadInfo || extended_thread_info)) {
+      jlong allocated_bytes = const_cast<Thread*>(this)->cooked_allocated_bytes();
+      st->print("allocated=" JLONG_FORMAT "B ", allocated_bytes);
+      st->print("defined_classes=" INT64_FORMAT " ", _statistic_info.getDefineClassCount());
+    }
+
     st->print("tid=" INTPTR_FORMAT " ", p2i(this));
     osthread()->print_on(st);
   }
   ThreadsSMRSupport::print_info_on(this, st);
   st->print(" ");

@@ -2898,21 +2914,21 @@
   print_thread_state_on(tty);
 }
 #endif // PRODUCT
 
 // Called by Threads::print() for VM_PrintThreads operation
-void JavaThread::print_on(outputStream *st) const {
+void JavaThread::print_on(outputStream *st, bool extended_thread_info) const {
   st->print_raw("\"");
   st->print_raw(get_thread_name());
   st->print_raw("\" ");
   oop thread_oop = threadObj();
   if (thread_oop != NULL) {
     st->print("#" INT64_FORMAT " ", (int64_t)java_lang_Thread::thread_id(thread_oop));
     if (java_lang_Thread::is_daemon(thread_oop))  st->print("daemon ");
     st->print("prio=%d ", java_lang_Thread::priority(thread_oop));
   }
-  Thread::print_on(st);
+  Thread::print_on(st, extended_thread_info);
   // print guess for valid stack memory region (assume 4K pages); helps lock debugging
   st->print_cr("[" INTPTR_FORMAT "]", (intptr_t)last_Java_sp() & ~right_n_bits(12));
   if (thread_oop != NULL) {
     st->print_cr("   java.lang.Thread.State: %s", java_lang_Thread::thread_status_name(thread_oop));
   }

@@ -4553,11 +4569,12 @@
   return the_owner;
 }
 
 // Threads::print_on() is called at safepoint by VM_PrintThreads operation.
 void Threads::print_on(outputStream* st, bool print_stacks,
-                       bool internal_format, bool print_concurrent_locks) {
+                       bool internal_format, bool print_concurrent_locks,
+                       bool extended_thread_info) {
   char buf[32];
   st->print_raw_cr(os::local_time_string(buf, sizeof(buf)));
 
   st->print_cr("Full thread dump %s (%s %s):",
                Abstract_VM_Version::vm_name(),

@@ -4576,11 +4593,11 @@
   ThreadsSMRSupport::print_info_on(st);
   st->cr();
 
   ALL_JAVA_THREADS(p) {
     ResourceMark rm;
-    p->print_on(st);
+    p->print_on(st, extended_thread_info);
     if (print_stacks) {
       if (internal_format) {
         p->trace_stack();
       } else {
         p->print_stack_on(st);
< prev index next >