# HG changeset patch # User Tom Rodriguez # Date 1445620217 25200 # Node ID 5cae0a06ca7dbc4f935ffab1469db5c7d337cbb7 # Parent 76e1d16c28cc9cdb3374d33f32a88a35a1f542c1 Add trap and recompilation statistics to LogCompilation diff -r 76e1d16c28cc -r 5cae0a06ca7d src/share/tools/LogCompilation/Makefile --- a/src/share/tools/LogCompilation/Makefile Fri Oct 23 10:09:48 2015 -0700 +++ b/src/share/tools/LogCompilation/Makefile Fri Oct 23 10:10:17 2015 -0700 @@ -62,7 +62,7 @@ logc.jar: filelist manifest.mf @mkdir -p $(OUTPUT_DIR) - $(JAVAC) -source 1.5 -deprecation -sourcepath $(SRC_DIR) -d $(OUTPUT_DIR) @filelist + $(JAVAC) -source 1.6 -deprecation -sourcepath $(SRC_DIR) -d $(OUTPUT_DIR) @filelist $(JAR) cvfm logc.jar manifest.mf -C $(OUTPUT_DIR) com .PHONY: filelist diff -r 76e1d16c28cc -r 5cae0a06ca7d src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Compilation.java --- a/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Compilation.java Fri Oct 23 10:09:48 2015 -0700 +++ b/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Compilation.java Fri Oct 23 10:10:17 2015 -0700 @@ -104,6 +104,15 @@ } } + public String longMethodName() { + if (getMethod() == null) { + return getSpecial(); + } else { + int bc = isOsr() ? getOsr_bci() : -1; + return getMethod().decodeFlags(bc) + getMethod().formatLong(bc); + } + } + public void printShort(PrintStream stream) { stream.println(shortName()); } diff -r 76e1d16c28cc -r 5cae0a06ca7d src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogCompilation.java --- a/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogCompilation.java Fri Oct 23 10:09:48 2015 -0700 +++ b/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogCompilation.java Fri Oct 23 10:10:17 2015 -0700 @@ -41,6 +41,7 @@ System.out.println(" -c: clean up malformed 1.5 xml"); System.out.println(" -i: print inlining decisions"); System.out.println(" -S: print compilation statistics"); + System.out.println(" -R: print method recompilation information"); System.out.println(" -s: sort events by start time"); System.out.println(" -e: sort events by elapsed time"); System.out.println(" -n: sort events by name and start"); @@ -52,6 +53,7 @@ public static void main(String[] args) throws Exception { Comparator defaultSort = LogParser.sortByStart; boolean statistics = false; + boolean recompilation = false; boolean printInlining = false; boolean cleanup = false; boolean printEliminatedLocks = false; @@ -74,6 +76,9 @@ } else if (args[index].equals("-S")) { statistics = true; index++; + } else if (args[index].equals("-R")) { + recompilation = true; + index++; } else if (args[index].equals("-h")) { usage(0); } else if (args[index].equals("-i")) { @@ -103,6 +108,8 @@ printEliminatedLocks(events, System.out, defaultSort); } else if (statistics) { printStatistics(events, System.out); + } else if (recompilation) { + printRecompilation(events, System.out); } else { Collections.sort(events, defaultSort); for (LogEvent c : events) { @@ -196,6 +203,54 @@ } } + public static void printRecompilation(ArrayList events, PrintStream out) { + LinkedHashMap>> traps = new LinkedHashMap>>(); + for (LogEvent e : events) { + if (e instanceof UncommonTrapEvent) { + UncommonTrapEvent uc = (UncommonTrapEvent) e; + Map> t = traps.get(uc.getCompilation().longMethodName()); + if (t == null) { + t = new LinkedHashMap>(); + traps.put(uc.getCompilation().longMethodName(), t); + } + String msg = uc.formatTrap().trim(); + List i = t.get(msg); + if (i == null) { + i = new ArrayList(); + t.put(msg, i); + } + i.add(uc.getId()); + } + } + + List> recompiles = new ArrayList>(); + Map, String> reverseMapping = new HashMap, String>(); + for (Map.Entry>> entry : traps.entrySet()) { + for (Map.Entry> trapEntry : entry.getValue().entrySet()) { + recompiles.add(trapEntry.getValue()); + reverseMapping.put(trapEntry.getValue(), trapEntry.getKey()); + } + } + recompiles.sort(new Comparator>() { + public int compare(List a, List b) { + return intCompare(a.size(), b.size()); + } + }); + for (List key : recompiles) { + if (key.size() > 1) { + out.print("Trap: "); + out.println(reverseMapping.get(key)); + out.print("Compilations: "); + out.println(key); + } + } + } + + + private static int intCompare(int o1, int o2) { + return (o1 > o2 ? -1 : (o1 == o2 ? 0 : 1)); + } + public static void printStatistics(ArrayList events, PrintStream out) { long cacheSize = 0; long maxCacheSize = 0; diff -r 76e1d16c28cc -r 5cae0a06ca7d src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Method.java --- a/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Method.java Fri Oct 23 10:09:48 2015 -0700 +++ b/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Method.java Fri Oct 23 10:10:17 2015 -0700 @@ -50,11 +50,19 @@ } String format(int osr_bci) { + String bci = ""; if (osr_bci >= 0) { - return getHolder().replace('/', '.') + "::" + getName() + " @ " + osr_bci + " (" + getBytes() + " bytes)"; - } else { - return getHolder().replace('/', '.') + "::" + getName() + " (" + getBytes() + " bytes)"; + bci = " @ " + osr_bci; } + return getHolder().replace('/', '.') + "::" + getName() + bci + " (" + getBytes() + " bytes)"; + } + + String formatLong(int osr_bci) { + String bci = ""; + if (osr_bci >= 0) { + bci = " @ " + osr_bci; + } + return getReturnType() + " " + getHolder().replace('/', '.') + "::" + getName() + "(" + getArguments() + ")" + bci; } @Override diff -r 76e1d16c28cc -r 5cae0a06ca7d src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/UncommonTrapEvent.java --- a/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/UncommonTrapEvent.java Fri Oct 23 10:09:48 2015 -0700 +++ b/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/UncommonTrapEvent.java Fri Oct 23 10:10:17 2015 -0700 @@ -53,6 +53,10 @@ stream.print(getJvms()); } + public String formatTrap() { + return String.format("uncommon trap %s %s\n%s", getReason(), getAction(), getJvms()); + } + public String getReason() { return reason; }