changeset 13108:d84fa69a9874

added support for printing method profiles for virtual calls
author Doug Simon <doug.simon@oracle.com>
date Fri, 22 Nov 2013 01:30:06 +0100
parents 91933915d1d0
children 58dfd753ada8
files src/share/vm/oops/methodData.cpp src/share/vm/oops/methodData.hpp
diffstat 2 files changed, 46 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/oops/methodData.cpp	Fri Nov 22 01:22:34 2013 +0100
+++ b/src/share/vm/oops/methodData.cpp	Fri Nov 22 01:30:06 2013 +0100
@@ -397,7 +397,11 @@
   for (row = 0; row < row_limit(); row++) {
     if (receiver(row) != NULL)  entries++;
   }
+#ifdef GRAAL
+  st->print_cr("count(%u) nonprofiled_count(%u) entries(%u)", count(), nonprofiled_count(), entries);
+#else
   st->print_cr("count(%u) entries(%u)", count(), entries);
+#endif
   int total = count();
   for (row = 0; row < row_limit(); row++) {
     if (receiver(row) != NULL) {
@@ -416,9 +420,38 @@
   print_shared(st, "ReceiverTypeData");
   print_receiver_data_on(st);
 }
+
+#ifdef GRAAL
+void VirtualCallData::print_method_data_on(outputStream* st) const {
+  uint row;
+  int entries = 0;
+  for (row = 0; row < method_row_limit(); row++) {
+    if (method(row) != NULL) entries++;
+  }
+  tab(st);
+  st->print_cr("method_entries(%u)", entries);
+  int total = count();
+  for (row = 0; row < method_row_limit(); row++) {
+    if (method(row) != NULL) {
+      total += method_count(row);
+    }
+  }
+  for (row = 0; row < method_row_limit(); row++) {
+    if (method(row) != NULL) {
+      tab(st);
+      method(row)->print_value_on(st);
+      st->print_cr("(%u %4.2f)", method_count(row), (float) method_count(row) / (float) total);
+    }
+  }
+}
+#endif
+
 void VirtualCallData::print_data_on(outputStream* st) const {
   print_shared(st, "VirtualCallData");
   print_receiver_data_on(st);
+#ifdef GRAAL
+  print_method_data_on(st);
+#endif
 }
 #endif // !PRODUCT
 
--- a/src/share/vm/oops/methodData.hpp	Fri Nov 22 01:22:34 2013 +0100
+++ b/src/share/vm/oops/methodData.hpp	Fri Nov 22 01:30:06 2013 +0100
@@ -1079,7 +1079,7 @@
     //          TODO (chaeubl): in fact, Graal should also increment the count for failed type checks to mimic the C1/C2 behavior
     // VirtualCallData for invokevirtual/invokeinterface:
     //   C1/C2: count is incremented on type overflow
-    //   Graal: count is incremented on type overflow, nonprofiled_count is increment on method overflow
+    //   Graal: count is incremented on type overflow, nonprofiled_count is incremented on method overflow
 
     // Graal is interested in knowing the percentage of type checks involving a type not explicitly in the profile
     nonprofiled_count_off_set = counter_cell_count,
@@ -1183,6 +1183,9 @@
   static ByteSize nonprofiled_receiver_count_offset() {
     return cell_offset(nonprofiled_count_off_set);
   }
+  uint nonprofiled_count() const {
+    return uint_at(nonprofiled_count_off_set);
+  }
   void set_nonprofiled_count(uint count) {
     set_uint_at(nonprofiled_count_off_set, count);
   }
@@ -1245,7 +1248,7 @@
     return MethodProfileWidth;
   }
 
-  Method* method(uint row) {
+  Method* method(uint row) const {
     assert(row < method_row_limit(), "oob");
 
     Method* method = (Method*)intptr_at(method_cell_index(row));
@@ -1253,6 +1256,11 @@
     return method;
   }
 
+  uint method_count(uint row) const {
+    assert(row < method_row_limit(), "oob");
+    return uint_at(method_count_cell_index(row));
+  }
+
   void set_method(uint row, Method* m) {
     assert((uint)row < method_row_limit(), "oob");
     set_intptr_at(method_cell_index(row), (uintptr_t)m);
@@ -1276,6 +1284,9 @@
 #endif
 
 #ifndef PRODUCT
+#ifdef GRAAL
+  void print_method_data_on(outputStream* st) const;
+#endif
   void print_data_on(outputStream* st) const;
 #endif
 };