src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.test/src/org/graalvm/compiler/test/GraalTest.java
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.test/src/org/graalvm/compiler/test/GraalTest.java Fri Feb 02 10:37:48 2018 -0500
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.test/src/org/graalvm/compiler/test/GraalTest.java Fri Feb 02 17:28:17 2018 -0800
@@ -24,7 +24,6 @@
import static org.graalvm.compiler.debug.DebugContext.DEFAULT_LOG_STREAM;
import static org.graalvm.compiler.debug.DebugContext.NO_DESCRIPTION;
-import static org.graalvm.compiler.debug.DebugContext.NO_GLOBAL_METRIC_VALUES;
import java.io.PrintStream;
import java.io.PrintWriter;
@@ -36,16 +35,17 @@
import java.util.Collections;
import java.util.List;
-import jdk.vm.ci.meta.ResolvedJavaMethod;
-import org.graalvm.compiler.debug.DebugHandlersFactory;
import org.graalvm.compiler.debug.DebugContext;
import org.graalvm.compiler.debug.DebugDumpHandler;
+import org.graalvm.compiler.debug.DebugHandlersFactory;
+import org.graalvm.compiler.debug.GlobalMetrics;
import org.graalvm.compiler.options.OptionValues;
import org.junit.After;
import org.junit.Assert;
import org.junit.internal.ComparisonCriteria;
import org.junit.internal.ExactComparisonCriteria;
+import jdk.vm.ci.meta.ResolvedJavaMethod;
import sun.misc.Unsafe;
/**
@@ -398,7 +398,7 @@
/**
* Gets a {@link DebugContext} object corresponding to {@code options}, creating a new one if
- * none currently exists.Debug contexts created by this method will have their
+ * none currently exists. Debug contexts created by this method will have their
* {@link DebugDumpHandler}s closed in {@link #afterTest()}.
*
* @param options currently active options
@@ -423,11 +423,21 @@
} else {
descr = new DebugContext.Description(method, id == null ? method.getName() : id);
}
- DebugContext debug = DebugContext.create(options, descr, NO_GLOBAL_METRIC_VALUES, DEFAULT_LOG_STREAM, getDebugHandlersFactories());
+ DebugContext debug = DebugContext.create(options, descr, globalMetrics, DEFAULT_LOG_STREAM, getDebugHandlersFactories());
cached.add(debug);
return debug;
}
+ private static final GlobalMetrics globalMetrics = new GlobalMetrics();
+
+ static {
+ Runtime.getRuntime().addShutdownHook(new Thread("GlobalMetricsPrinter") {
+ @Override
+ public void run() {
+ globalMetrics.print(new OptionValues(OptionValues.newOptionMap()));
+ }
+ });
+ }
private final ThreadLocal<List<DebugContext>> cachedDebugs = new ThreadLocal<>();
@After
@@ -435,6 +445,7 @@
List<DebugContext> cached = cachedDebugs.get();
if (cached != null) {
for (DebugContext debug : cached) {
+ debug.close();
debug.closeDumpHandlers(true);
}
}