--- old/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/CompilationStatistics.java 2017-03-20 17:38:28.000000000 -0700 +++ new/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/CompilationStatistics.java 2017-03-20 17:38:28.000000000 -0700 @@ -44,7 +44,8 @@ import org.graalvm.compiler.debug.CSVUtil; import org.graalvm.compiler.debug.Management; import org.graalvm.compiler.options.Option; -import org.graalvm.compiler.options.OptionValue; +import org.graalvm.compiler.options.OptionKey; +import org.graalvm.compiler.options.OptionValues; import com.sun.management.ThreadMXBean; import jdk.vm.ci.hotspot.HotSpotInstalledCode; @@ -56,12 +57,11 @@ public static class Options { // @formatter:off @Option(help = "Enables CompilationStatistics.") - public static final OptionValue UseCompilationStatistics = new OptionValue<>(false); + public static final OptionKey UseCompilationStatistics = new OptionKey<>(false); // @formatter:on } private static final long RESOLUTION = 100000000; - private static final boolean ENABLED = Options.UseCompilationStatistics.getValue(); private static final CompilationStatistics DUMMY = new CompilationStatistics(null, false); @@ -114,6 +114,7 @@ bytecodeCount = method.getCodeSize(); threadAllocatedBytesStart = getThreadAllocatedBytes(); } else { + assert DUMMY == null : "only DUMMY has no method"; holder = ""; name = ""; signature = ""; @@ -122,7 +123,7 @@ } public void finish(HotSpotResolvedJavaMethod method, HotSpotInstalledCode code) { - if (ENABLED) { + if (isEnabled()) { duration = System.nanoTime() - startTime; codeSize = (int) code.getCodeSize(); memoryUsed = getThreadAllocatedBytes() - threadAllocatedBytesStart; @@ -137,8 +138,8 @@ return current.get().isEmpty() ? null : current.get().getLast(); } - public static CompilationStatistics create(HotSpotResolvedJavaMethod method, boolean isOSR) { - if (ENABLED) { + public static CompilationStatistics create(OptionValues options, HotSpotResolvedJavaMethod method, boolean isOSR) { + if (Options.UseCompilationStatistics.getValue(options)) { CompilationStatistics stats = new CompilationStatistics(method, isOSR); list.add(stats); current.get().addLast(stats); @@ -148,11 +149,12 @@ } } + public boolean isEnabled() { + return this != DUMMY; + } + @SuppressWarnings("deprecation") public static void clear(String dumpName) { - if (!ENABLED) { - return; - } try { ConcurrentLinkedDeque snapshot = list; long snapshotZeroTime = zeroTime;