changeset 1036:ac23d8538728

7901103: perfasm should support old JDK 7 nmethod headers
author shade
date Fri, 14 Nov 2014 13:57:17 +0300
parents db42cb5e9439
children 42438fd5f38a
files jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java	Fri Nov 14 01:20:54 2014 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java	Fri Nov 14 13:57:17 2014 +0300
@@ -680,16 +680,20 @@
                 ASMLine asmLine = new ASMLine(line);
 
                 if (line.contains("# {method}")) {
-                    if (elements.length == 7) {
+                    if (elements.length == 6) {
+                        // old JDKs may print the line with 6 fields: # {method} <name> <signature> in <class>
+                        method = (elements[5].replace("/", ".") + "::" + elements[2]).replace("'", "");
+                    } else if (elements.length == 7) {
+                        // newer JDKs always print 7 fields: # {method} <address> <name> <signature> in <class>
                         method = (elements[6].replace("/", ".") + "::" + elements[3]).replace("'", "");
-                        method = method.replace("&apos;", "");
-                        method = method.replace("&lt;", "<");
-                        method = method.replace("&gt;", ">");
                     } else {
                         // {method} line is corrupted, other writer had possibly interjected;
                         // honestly say we can't figure the method name out instead of lying.
                         method = "<name unparseable>";
                     }
+                    method = method.replace("&apos;", "");
+                    method = method.replace("&lt;", "<");
+                    method = method.replace("&gt;", ">");
                 } else if (elements.length >= 1 && elements[0].startsWith("0x")) {
                     // Seems to be line with address.
                     try {