--- old/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/debug/MethodMetricsTest.java 2017-03-20 17:37:38.000000000 -0700 +++ new/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/debug/MethodMetricsTest.java 2017-03-20 17:37:37.000000000 -0700 @@ -26,7 +26,6 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.ListIterator; import java.util.Map; @@ -36,7 +35,7 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; - +import org.graalvm.compiler.core.common.util.Util; import org.graalvm.compiler.core.test.GraalCompilerTest; import org.graalvm.compiler.debug.Debug; import org.graalvm.compiler.debug.DebugCloseable; @@ -63,8 +62,7 @@ import org.graalvm.compiler.nodes.calc.ShiftNode; import org.graalvm.compiler.nodes.calc.SignedDivNode; import org.graalvm.compiler.nodes.calc.SubNode; -import org.graalvm.compiler.options.OptionValue; -import org.graalvm.compiler.options.OptionValue.OverrideScope; +import org.graalvm.compiler.options.OptionValues; import org.graalvm.compiler.phases.BasePhase; import org.graalvm.compiler.phases.Phase; import org.graalvm.compiler.phases.PhaseSuite; @@ -241,30 +239,26 @@ static DebugConfig overrideGraalDebugConfig(PrintStream log, String methodFilter, String methodMeter) { List dumpHandlers = new ArrayList<>(); List verifyHandlers = new ArrayList<>(); + OptionValues options = getInitialOptions(); GraalDebugConfig debugConfig = new GraalDebugConfig( - GraalDebugConfig.Options.Log.getValue(), - GraalDebugConfig.Options.Count.getValue(), - GraalDebugConfig.Options.TrackMemUse.getValue(), - GraalDebugConfig.Options.Time.getValue(), - GraalDebugConfig.Options.Dump.getValue(), - GraalDebugConfig.Options.Verify.getValue(), + options, + GraalDebugConfig.Options.Log.getValue(options), + GraalDebugConfig.Options.Count.getValue(options), + GraalDebugConfig.Options.TrackMemUse.getValue(options), + GraalDebugConfig.Options.Time.getValue(options), + GraalDebugConfig.Options.Dump.getValue(options), + GraalDebugConfig.Options.Verify.getValue(options), methodFilter, methodMeter, log, dumpHandlers, verifyHandlers); return debugConfig; } - private static OverrideScope overrideMetricPrinterConfig() { - Map, Object> mapping = new HashMap<>(); - mapping.put(MethodMetricsPrinter.Options.MethodMeterPrintAscii, true); - return OptionValue.override(mapping); - } - abstract Phase additionalPhase(); @Override - protected Suites createSuites() { - Suites ret = super.createSuites(); + protected Suites createSuites(OptionValues options) { + Suites ret = super.createSuites(options); ListIterator> iter = ret.getHighTier().findPhase(ConvertDeoptimizeToGuardPhase.class, true); PhaseSuite.findNextPhase(iter, CanonicalizerPhase.class); iter.add(additionalPhase()); @@ -274,7 +268,7 @@ @Test @SuppressWarnings("try") public void test() throws Throwable { - try (DebugConfigScope s = Debug.setConfig(getConfig()); OverrideScope o = getOScope();) { + try (DebugConfigScope s = Debug.setConfig(getConfig())) { executeMethod(TestApplication.class.getMethod("m01", testSignature), null, testArgs); executeMethod(TestApplication.class.getMethod("m02", testSignature), null, testArgs); executeMethod(TestApplication.class.getMethod("m03", testSignature), null, testArgs); @@ -289,6 +283,11 @@ } } + void executeMethod(Method m, Object receiver, Object... args) { + OptionValues options = new OptionValues(getInitialOptions(), MethodMetricsPrinter.Options.MethodMeterPrintAscii, true); + test(options, asResolvedJavaMethod(m), receiver, args); + } + @Before public void rememberScopeId() { scopeIdBeforeAccess = DebugScope.getCurrentGlobalScopeId(); @@ -301,10 +300,6 @@ abstract DebugConfig getConfig(); - OverrideScope getOScope() { - return overrideMetricPrinterConfig(); - } - abstract void assertValues() throws Throwable; @SuppressWarnings("unchecked") @@ -312,7 +307,7 @@ Map threadLocalMap = null; for (Field f : MethodMetricsImpl.class.getDeclaredFields()) { if (f.getName().equals("threadEntries")) { - f.setAccessible(true); + Util.setAccessible(f, true); Object map; try { map = ((ThreadLocal) f.get(null)).get(); @@ -373,9 +368,4 @@ throw new RuntimeException(t); } } - - void executeMethod(Method m, Object receiver, Object... args) { - test(asResolvedJavaMethod(m), receiver, args); - } - }