src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/debug/MethodMetricsTest.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File
*** old/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/debug/MethodMetricsTest.java	Mon Mar 20 17:37:38 2017
--- new/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/debug/MethodMetricsTest.java	Mon Mar 20 17:37:37 2017

*** 24,44 **** --- 24,43 ---- import java.io.PrintStream; 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; import java.util.stream.Collectors; import org.junit.After; 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; import org.graalvm.compiler.debug.DebugConfig; import org.graalvm.compiler.debug.DebugConfigScope;
*** 61,72 **** --- 60,70 ---- import org.graalvm.compiler.nodes.calc.FixedBinaryNode; import org.graalvm.compiler.nodes.calc.MulNode; 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.OptionValues; import org.graalvm.compiler.options.OptionValue.OverrideScope; import org.graalvm.compiler.phases.BasePhase; import org.graalvm.compiler.phases.Phase; import org.graalvm.compiler.phases.PhaseSuite; import org.graalvm.compiler.phases.common.CanonicalizerPhase; import org.graalvm.compiler.phases.common.ConvertDeoptimizeToGuardPhase;
*** 239,282 **** --- 237,276 ---- } static DebugConfig overrideGraalDebugConfig(PrintStream log, String methodFilter, String methodMeter) { List<DebugDumpHandler> dumpHandlers = new ArrayList<>(); List<DebugVerifyHandler> 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<OptionValue<?>, Object> mapping = new HashMap<>(); mapping.put(MethodMetricsPrinter.Options.MethodMeterPrintAscii, true); return OptionValue.override(mapping); } abstract Phase additionalPhase(); @Override ! protected Suites createSuites(OptionValues options) { ! Suites ret = super.createSuites(options); ListIterator<BasePhase<? super HighTierContext>> iter = ret.getHighTier().findPhase(ConvertDeoptimizeToGuardPhase.class, true); PhaseSuite.findNextPhase(iter, CanonicalizerPhase.class); iter.add(additionalPhase()); return ret; } @Test @SuppressWarnings("try") public void test() throws Throwable { - try (DebugConfigScope s = Debug.setConfig(getConfig()); OverrideScope o = getOScope();) { executeMethod(TestApplication.class.getMethod("m01", testSignature), null, testArgs); executeMethod(TestApplication.class.getMethod("m02", testSignature), null, testArgs); executeMethod(TestApplication.class.getMethod("m03", testSignature), null, testArgs); executeMethod(TestApplication.class.getMethod("m04", testSignature), null, testArgs); executeMethod(TestApplication.class.getMethod("m05", testSignature), null, testArgs);
*** 287,296 **** --- 281,295 ---- executeMethod(TestApplication.class.getMethod("m10", testSignature), null, testArgs); assertValues(); } } + 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(); }
*** 299,320 **** --- 298,315 ---- MethodMetricsImpl.clearMM(); } abstract DebugConfig getConfig(); OverrideScope getOScope() { return overrideMetricPrinterConfig(); } abstract void assertValues() throws Throwable; @SuppressWarnings("unchecked") private static Map<ResolvedJavaMethod, CompilationData> readMethodMetricsImplData() { Map<ResolvedJavaMethod, CompilationData> 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(); } catch (Throwable t) { throw new RuntimeException(t);
*** 371,381 **** --- 366,371 ---- Assert.assertEquals(vals[8], readValFromCurrThread(asResolvedJavaMethod(TestApplication.class.getMethod("m09", testSignature)), metricName)); } catch (Throwable t) { throw new RuntimeException(t); } } void executeMethod(Method m, Object receiver, Object... args) { test(asResolvedJavaMethod(m), receiver, args); } }

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/debug/MethodMetricsTest.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File