changeset 481:a211c1a525fd

meth: improve display of poly-sig method names -Xprof, -XX:+PrintCompilation
author jrose
date Mon, 16 Jul 2012 01:12:03 -0700
parents 481644d9a6c5
children 4765d908e696
files meth-lazy-7023639.review.patch
diffstat 1 files changed, 135 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/meth-lazy-7023639.review.patch	Sat Jul 14 17:57:27 2012 -0700
+++ b/meth-lazy-7023639.review.patch	Mon Jul 16 01:12:03 2012 -0700
@@ -1,5 +1,6 @@
 # HG changeset patch
-# Parent bb58a0b59bb5a35eb987814dfb51044033b9e41f
+# Parent 80f2a5825abb717dc55c38358758a373258beadd
+
 diff --git a/src/share/vm/classfile/javaClasses.cpp b/src/share/vm/classfile/javaClasses.cpp
 --- a/src/share/vm/classfile/javaClasses.cpp
 +++ b/src/share/vm/classfile/javaClasses.cpp
@@ -22,3 +23,136 @@
    }
    java_lang_StackTraceElement::set_lineNumber(element(), line_number);
  
+diff --git a/src/share/vm/oops/methodOop.cpp b/src/share/vm/oops/methodOop.cpp
+--- a/src/share/vm/oops/methodOop.cpp
++++ b/src/share/vm/oops/methodOop.cpp
+@@ -1177,13 +1177,8 @@
+ #endif
+   name()->print_symbol_on(st);
+   if (WizardMode) signature()->print_symbol_on(st);
+-  else if (MethodHandles::is_signature_polymorphic(intrinsic_id())) {
+-    st->print("(");
+-    for (SignatureStream ss(signature()); !ss.is_done(); ss.next()) {
+-      if (ss.at_return_type())  st->print(")");
+-      st->print("%c", type2char(ss.type()));
+-    }
+-  }
++  else if (MethodHandles::is_signature_polymorphic(intrinsic_id()))
++    MethodHandles::print_as_basic_type_signature_on(st, signature(), true);
+ }
+ 
+ // This is only done during class loading, so it is OK to assume method_idnum matches the methods() array
+diff --git a/src/share/vm/prims/methodHandles.cpp b/src/share/vm/prims/methodHandles.cpp
+--- a/src/share/vm/prims/methodHandles.cpp
++++ b/src/share/vm/prims/methodHandles.cpp
+@@ -473,6 +473,76 @@
+   return java_lang_invoke_MethodTypeForm::basicType(form);
+ }
+ 
++void MethodHandles::print_as_basic_type_signature_on(outputStream* st,
++                                                     Symbol* sig,
++                                                     bool keep_arrays,
++                                                     bool keep_basic_names) {
++  st = st ? st : tty;
++  int len  = sig->utf8_length();
++  int array = 0;
++  bool prev_type = false;
++  for (int i = 0; i < len; i++) {
++    char ch = sig->byte_at(i);
++    switch (ch) {
++    case '(': case ')':
++      prev_type = false;
++      st->put(ch);
++      continue;
++    case '[':
++      if (!keep_basic_names && keep_arrays)
++        st->put(ch);
++      array++;
++      continue;
++    case 'L':
++      {
++        if (prev_type)  st->put(',');
++        int start = i+1, slash = start;
++        while (++i < len && (ch = sig->byte_at(i)) != ';') {
++          if (ch == '/' || ch == '.' || ch == '$')  slash = i+1;
++        }
++        if (slash < i)  start = slash;
++        if (!keep_basic_names) {
++          st->put('L');
++        } else {
++          for (int j = start; j < i; j++)
++            st->put(sig->byte_at(j));
++          prev_type = true;
++        }
++        break;
++      }
++    default:
++      {
++        if (array && char2type(ch) != T_ILLEGAL && !keep_arrays) {
++          ch = '[';
++          array = 0;
++        }
++        if (prev_type)  st->put(',');
++        const char* n = NULL;
++        if (keep_basic_names)
++          n = type2name(char2type(ch));
++        if (n == NULL) {
++          // unknown letter, or we don't want to know its name
++          st->put(ch);
++        } else {
++          st->print(n);
++          prev_type = true;
++        }
++        break;
++      }
++    }
++    // Switch break goes here to take care of array suffix:
++    if (prev_type) {
++      while (array > 0) {
++        st->print("[]");
++        --array;
++      }
++    }
++    array = 0;
++  }
++}
++
++
++
+ static oop object_java_mirror() {
+   return Klass::cast(SystemDictionary::Object_klass())->java_mirror();
+ }
+diff --git a/src/share/vm/prims/methodHandles.hpp b/src/share/vm/prims/methodHandles.hpp
+--- a/src/share/vm/prims/methodHandles.hpp
++++ b/src/share/vm/prims/methodHandles.hpp
+@@ -144,6 +144,11 @@
+   static oop method_type_basic_type(oop method_type);
+   static Symbol* lookup_method_type(Symbol* msig, Handle mtype, TRAPS);
+ 
++  static void print_as_method_type_on(outputStream* st, Symbol* sig) {
++    print_as_basic_type_signature_on(st, sig, true, true);
++  }
++  static void print_as_basic_type_signature_on(outputStream* st, Symbol* sig, bool keep_arrays = false, bool keep_basic_names = false);
++
+   // decoding CONSTANT_MethodHandle constants
+   enum { JVM_REF_MIN = JVM_REF_getField, JVM_REF_MAX = JVM_REF_invokeInterface };
+   static bool ref_kind_is_valid(int ref_kind) {
+diff --git a/src/share/vm/runtime/fprofiler.cpp b/src/share/vm/runtime/fprofiler.cpp
+--- a/src/share/vm/runtime/fprofiler.cpp
++++ b/src/share/vm/runtime/fprofiler.cpp
+@@ -337,11 +337,13 @@
+       char c = (char) n->byte_at(i);
+       st->print("%c", c);
+     }
+-    if( Verbose ) {
++    if (Verbose || WizardMode) {
+       // Disambiguate overloaded methods
+       Symbol* sig = m->signature();
+       sig->print_symbol_on(st);
+-    }
++    } else if (MethodHandles::is_signature_polymorphic(m->intrinsic_id()))
++      // compare with methodOopDesc::print_short_name
++      MethodHandles::print_as_basic_type_signature_on(st, m->signature(), true);
+   }
+ 
+   virtual void print(outputStream* st, int total_ticks) {