--- old/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.debug/src/org/graalvm/compiler/debug/internal/DebugValuesPrinter.java 2017-03-20 17:37:54.000000000 -0700
+++ new/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.debug/src/org/graalvm/compiler/debug/internal/DebugValuesPrinter.java 2017-03-20 17:37:54.000000000 -0700
@@ -35,7 +35,6 @@
import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;
-import java.util.stream.Collectors;
import org.graalvm.compiler.debug.CSVUtil;
import org.graalvm.compiler.debug.GraalError;
@@ -43,6 +42,8 @@
import org.graalvm.compiler.debug.TTY;
import org.graalvm.compiler.debug.internal.method.MethodMetricsImpl;
import org.graalvm.compiler.debug.internal.method.MethodMetricsPrinter;
+import org.graalvm.compiler.options.OptionValues;
+import org.graalvm.util.CollectionsUtil;
/**
* Facility for printing the {@linkplain KeyRegistry#getDebugValues() values} collected across all
@@ -61,7 +62,7 @@
this.mmPrinter = mmPrinter;
}
- public void printDebugValues() throws GraalError {
+ public void printDebugValues(OptionValues options) throws GraalError {
TTY.println();
TTY.println("");
List topLevelMaps = DebugValueMap.getTopLevelMaps();
@@ -71,20 +72,20 @@
ArrayList sortedValues = new ArrayList<>(debugValues);
Collections.sort(sortedValues);
- String summary = DebugValueSummary.getValue();
+ String summary = DebugValueSummary.getValue(options);
if (summary == null) {
summary = "Complete";
}
- if (DebugValueThreadFilter.getValue() != null && topLevelMaps.size() != 0) {
- topLevelMaps = topLevelMaps.stream().filter(map -> Pattern.compile(DebugValueThreadFilter.getValue()).matcher(map.getName()).find()).collect(Collectors.toList());
+ if (DebugValueThreadFilter.getValue(options) != null && topLevelMaps.size() != 0) {
+ topLevelMaps = CollectionsUtil.filterToList(topLevelMaps, map -> Pattern.compile(DebugValueThreadFilter.getValue(options)).matcher(map.getName()).find());
if (topLevelMaps.size() == 0) {
- TTY.println("Warning: DebugValueThreadFilter=%s eliminated all maps so nothing will be printed", DebugValueThreadFilter.getValue());
+ TTY.println("Warning: DebugValueThreadFilter=%s eliminated all maps so nothing will be printed", DebugValueThreadFilter.getValue(options));
}
}
switch (summary) {
case "Name": {
- LogStream log = getLogStream();
- printSummary(log, topLevelMaps, sortedValues);
+ LogStream log = getLogStream(options);
+ printSummary(options, log, topLevelMaps, sortedValues);
break;
}
case "Partial": {
@@ -93,8 +94,8 @@
flattenChildren(map, globalMap);
}
globalMap.normalize();
- LogStream log = getLogStream();
- printMap(log, new DebugValueScope(null, globalMap), sortedValues);
+ LogStream log = getLogStream(options);
+ printMap(options, log, new DebugValueScope(null, globalMap), sortedValues);
break;
}
case "Complete": {
@@ -104,8 +105,8 @@
}
globalMap.group();
globalMap.normalize();
- LogStream log = getLogStream();
- printMap(log, new DebugValueScope(null, globalMap), sortedValues);
+ LogStream log = getLogStream(options);
+ printMap(options, log, new DebugValueScope(null, globalMap), sortedValues);
break;
}
case "Thread":
@@ -113,8 +114,8 @@
TTY.println("Showing the results for thread: " + map.getName());
map.group();
map.normalize();
- LogStream log = getLogStream(map.getName().replace(' ', '_'));
- printMap(log, new DebugValueScope(null, map), sortedValues);
+ LogStream log = getLogStream(options, map.getName().replace(' ', '_'));
+ printMap(options, log, new DebugValueScope(null, map), sortedValues);
}
break;
default:
@@ -136,12 +137,12 @@
TTY.println("");
}
- private static LogStream getLogStream() {
- return getLogStream(null);
+ private static LogStream getLogStream(OptionValues options) {
+ return getLogStream(options, null);
}
- private static LogStream getLogStream(String prefix) {
- String debugValueFile = DebugValueFile.getValue();
+ private static LogStream getLogStream(OptionValues options, String prefix) {
+ String debugValueFile = DebugValueFile.getValue(options);
if (debugValueFile != null) {
try {
final String fileName;
@@ -168,7 +169,7 @@
map.clearChildren();
}
- private void printSummary(LogStream log, List topLevelMaps, List debugValues) {
+ private void printSummary(OptionValues options, LogStream log, List topLevelMaps, List debugValues) {
DebugValueMap result = new DebugValueMap("Summary");
for (int i = debugValues.size() - 1; i >= 0; i--) {
DebugValue debugValue = debugValues.get(i);
@@ -176,7 +177,7 @@
long total = collectTotal(topLevelMaps, index);
result.setCurrentValue(index, total);
}
- printMap(log, new DebugValueScope(null, result), debugValues);
+ printMap(options, log, new DebugValueScope(null, result), debugValues);
}
private long collectTotal(List maps, int index) {
@@ -228,19 +229,19 @@
}
- private void printMap(LogStream log, DebugValueScope scope, List debugValues) {
- if (DebugValueHumanReadable.getValue()) {
- printMapHumanReadable(log, scope, debugValues);
+ private void printMap(OptionValues options, LogStream log, DebugValueScope scope, List debugValues) {
+ if (DebugValueHumanReadable.getValue(options)) {
+ printMapHumanReadable(options, log, scope, debugValues);
} else {
- printMapComputerReadable(log, scope, debugValues);
+ printMapComputerReadable(options, log, scope, debugValues);
}
}
- private void printMapComputerReadable(LogStream log, DebugValueScope scope, List debugValues) {
+ private void printMapComputerReadable(OptionValues options, LogStream log, DebugValueScope scope, List debugValues) {
for (DebugValue value : debugValues) {
long l = scope.map.getCurrentValue(value.getIndex());
- if (l != 0 || !SuppressZeroDebugValues.getValue()) {
+ if (l != 0 || !SuppressZeroDebugValues.getValue(options)) {
CSVUtil.Escape.println(log, COMPUTER_READABLE_FMT, scope.toRawString(), value.getName(), value.toRawString(l), value.rawUnit());
}
}
@@ -248,15 +249,15 @@
List children = scope.map.getChildren();
for (int i = 0; i < children.size(); i++) {
DebugValueMap child = children.get(i);
- printMapComputerReadable(log, new DebugValueScope(scope, child), debugValues);
+ printMapComputerReadable(options, log, new DebugValueScope(scope, child), debugValues);
}
}
- private void printMapHumanReadable(LogStream log, DebugValueScope scope, List debugValues) {
+ private void printMapHumanReadable(OptionValues options, LogStream log, DebugValueScope scope, List debugValues) {
for (DebugValue value : debugValues) {
long l = scope.map.getCurrentValue(value.getIndex());
- if (l != 0 || !SuppressZeroDebugValues.getValue()) {
+ if (l != 0 || !SuppressZeroDebugValues.getValue(options)) {
scope.print(log);
printIndent(log, scope.level + 1);
log.println(value.getName() + "=" + value.toString(l));
@@ -266,7 +267,7 @@
List children = scope.map.getChildren();
for (int i = 0; i < children.size(); i++) {
DebugValueMap child = children.get(i);
- printMapHumanReadable(log, new DebugValueScope(scope, child), debugValues);
+ printMapHumanReadable(options, log, new DebugValueScope(scope, child), debugValues);
}
}