Mercurial > hg > truffle
changeset 11366:d335c16d2fe7
replaced PerThreadDebugValues, SummarizeDebugValues and SummarisePerPhase options with DebugValueSummary option
omit printing of scopes without any non-zero nested debug values
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 19 Aug 2013 22:04:00 +0200 |
parents | 5a7644d5fe20 |
children | 39b86b83ddeb |
files | graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfig.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java |
diffstat | 2 files changed, 73 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfig.java Mon Aug 19 22:01:07 2013 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfig.java Mon Aug 19 22:04:00 2013 +0200 @@ -48,12 +48,12 @@ public static final OptionValue<String> Log = new OptionValue<>(null); @Option(help = "Filters debug scope output by method name/pattern") public static final OptionValue<String> MethodFilter = new OptionValue<>(null); - @Option(help = "") - public static final OptionValue<Boolean> PerThreadDebugValues = new OptionValue<>(false); - @Option(help = "") - public static final OptionValue<Boolean> SummarizeDebugValues = new OptionValue<>(false); - @Option(help = "") - public static final OptionValue<Boolean> SummarizePerPhase = new OptionValue<>(false); + @Option(help = "How to print metric and timing values:%n" + + "Name - aggregate by unqualified name%n" + + "Thread - aggregate by qualified name and thread%n" + + "Complete - aggregate by qualified name%n" + + "Partial - aggregate by partially qualified name (e.g., A.B.C.D.Counter and X.Y.Z.D.Counter will be merged to D.Counter)") + public static final OptionValue<String> DebugValueSummary = new OptionValue<>("Complete"); @Option(help = "Send Graal IR to dump handlers on error") public static final OptionValue<Boolean> DumpOnError = new OptionValue<>(false); @Option(help = "Enable expensive assertions")
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Mon Aug 19 22:01:07 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Mon Aug 19 22:04:00 2013 +0200 @@ -446,29 +446,42 @@ ArrayList<DebugValue> sortedValues = new ArrayList<>(debugValues); Collections.sort(sortedValues); - if (SummarizeDebugValues.getValue()) { - printSummary(topLevelMaps, sortedValues); - } else if (PerThreadDebugValues.getValue()) { - for (DebugValueMap map : topLevelMaps) { - TTY.println("Showing the results for thread: " + map.getName()); - map.group(); - map.normalize(); - printMap(map, sortedValues, 0); + String summary = DebugValueSummary.getValue(); + if (summary == null) { + summary = "Scope"; + } + switch (summary) { + case "PartialScope": { + DebugValueMap globalMap = new DebugValueMap("Global"); + for (DebugValueMap map : topLevelMaps) { + flattenChildren(map, globalMap); + } + globalMap.normalize(); + printMap(new DebugValueScope(null, globalMap), sortedValues); + break; } - } else { - DebugValueMap globalMap = new DebugValueMap("Global"); - for (DebugValueMap map : topLevelMaps) { - if (SummarizePerPhase.getValue()) { - flattenChildren(map, globalMap); - } else { + case "Thread": + for (DebugValueMap map : topLevelMaps) { + TTY.println("Showing the results for thread: " + map.getName()); + map.group(); + map.normalize(); + printMap(new DebugValueScope(null, map), sortedValues); + } + break; + case "Name": + printSummary(topLevelMaps, sortedValues); + break; + case "Scope": // fall through + default: { + DebugValueMap globalMap = new DebugValueMap("Global"); + for (DebugValueMap map : topLevelMaps) { globalMap.addChild(map); } + globalMap.group(); + globalMap.normalize(); + printMap(new DebugValueScope(null, globalMap), sortedValues); + break; } - if (!SummarizePerPhase.getValue()) { - globalMap.group(); - } - globalMap.normalize(); - printMap(globalMap, sortedValues, 0); } } } @@ -501,7 +514,7 @@ long total = collectTotal(topLevelMaps, index); result.setCurrentValue(index, total); } - printMap(result, debugValues, 0); + printMap(new DebugValueScope(null, result), debugValues); } static long collectTotal(DebugValue value) { @@ -526,21 +539,48 @@ return total; } - private static void printMap(DebugValueMap map, List<DebugValue> debugValues, int level) { + /** + * Tracks the scope when printing a {@link DebugValueMap}, allowing "empty" scopes to be + * omitted. An empty scope is one in which there are no (nested) non-zero debug values. + */ + static class DebugValueScope { + + final DebugValueScope parent; + final int level; + final DebugValueMap map; + private boolean printed; - printIndent(level); - TTY.println("%s", map.getName()); + public DebugValueScope(DebugValueScope parent, DebugValueMap map) { + this.parent = parent; + this.map = map; + this.level = parent == null ? 0 : parent.level + 1; + } + + public void print() { + if (!printed) { + printed = true; + if (parent != null) { + parent.print(); + } + printIndent(level); + TTY.println("%s", map.getName()); + } + } + } + + private static void printMap(DebugValueScope scope, List<DebugValue> debugValues) { for (DebugValue value : debugValues) { - long l = map.getCurrentValue(value.getIndex()); + long l = scope.map.getCurrentValue(value.getIndex()); if (l != 0) { - printIndent(level + 1); + scope.print(); + printIndent(scope.level + 1); TTY.println(value.getName() + "=" + value.toString(l)); } } - for (DebugValueMap child : map.getChildren()) { - printMap(child, debugValues, level + 1); + for (DebugValueMap child : scope.map.getChildren()) { + printMap(new DebugValueScope(scope, child), debugValues); } }