changeset 853:1427b5899632

profilers: perfasm, show warning message when duplicate addresses are detected.
author shade
date Fri, 27 Jun 2014 01:11:21 +0400
parents 7b1c1bacd8b9
children 188235b20cf8
files jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java
diffstat 1 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java	Fri Jun 27 00:42:57 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java	Fri Jun 27 01:11:21 2014 +0400
@@ -368,6 +368,18 @@
         pw.println("<unresolved>");
         pw.println();
 
+        {
+            Set<Long> addrHistory = new HashSet<Long>();
+            for (Long addr : assembly.addressMap.keySet()) {
+                if (!addrHistory.add(addr)) {
+                    pw.println("WARNING: Duplicate instruction addresses detected. This is probably due to compiler reusing\n " +
+                            "the code arena for the new generated code. We can not differentiate between methods sharing\n" +
+                            "the same addresses, and therefore the profile might be wrong. Increasing generated code\n" +
+                            "storage might help.");
+                }
+            }
+        }
+
         /**
          * Print perf output, if needed:
          */
@@ -522,6 +534,10 @@
             this.methodMap = methodMap;
         }
 
+        public Assembly() {
+            this(new ArrayList<ASMLine>(), new TreeMap<Long, Integer>(), new TreeMap<Long, String>());
+        }
+
         public boolean isEmpty() {
             return lines.isEmpty();
         }
@@ -612,7 +628,7 @@
             }
             return new Assembly(lines, addressMap, methodMap);
         } catch (IOException e) {
-            return new Assembly(new ArrayList<ASMLine>(), new TreeMap<Long, Integer>(), new TreeMap<Long, String>());
+            return new Assembly();
         }
     }