|
37 | 37 | import org.graalvm.collections.EconomicMap;
|
38 | 38 |
|
39 | 39 | import jdk.graal.compiler.core.GraalCompilerOptions;
|
| 40 | +import jdk.graal.compiler.core.common.CompilationIdentifier; |
40 | 41 | import jdk.graal.compiler.core.common.util.CompilationAlarm;
|
41 | 42 | import jdk.graal.compiler.debug.CounterKey;
|
42 | 43 | import jdk.graal.compiler.debug.DebugCloseable;
|
|
66 | 67 | import jdk.graal.compiler.phases.contract.NodeCostUtil;
|
67 | 68 | import jdk.graal.compiler.phases.contract.PhaseSizeContract;
|
68 | 69 | import jdk.graal.compiler.serviceprovider.GraalServices;
|
| 70 | +import jdk.vm.ci.meta.JavaMethod; |
69 | 71 | import jdk.vm.ci.meta.SpeculationLog;
|
70 | 72 |
|
71 | 73 | /**
|
@@ -205,11 +207,11 @@ public static class PhaseOptions {
|
205 | 207 | @Option(help = "Exclude certain phases from compilation based on the given phase filter(s)." + PhaseFilterKey.HELP, type = OptionType.Debug)
|
206 | 208 | public static final PhaseFilterKey CompilationExcludePhases = new PhaseFilterKey(null, null);
|
207 | 209 | @Option(help = "Report hot metrics after each phase matching the given phase filter(s).", type = OptionType.Debug)
|
208 |
| - public static final PhaseFilterKey ReportHotMetricsAfterPhases = new PhaseFilterKey(null, null); |
| 210 | + public static final OptionKey<String> ReportHotMetricsAfterPhases = new OptionKey<>(null);; |
209 | 211 | @Option(help = "Report hot metrics before each phase matching the given phase filter(s).", type = OptionType.Debug)
|
210 |
| - public static final PhaseFilterKey ReportHotMetricsBeforePhases = new PhaseFilterKey("HighTierLoweringPhase=*", null); |
| 212 | + public static final OptionKey<String> ReportHotMetricsBeforePhases = new OptionKey<String>("HighTierLoweringPhase"); |
211 | 213 | @Option(help = "Report hot metrics extracted from compiler IR.", type = OptionType.Debug)
|
212 |
| - public static final OptionKey<Boolean> ReportHotMetrics = new OptionKey<>(false); |
| 214 | + public static final OptionKey<String> ReportHotMetrics = new OptionKey<>(null); |
213 | 215 | // @formatter:on
|
214 | 216 | }
|
215 | 217 |
|
@@ -456,12 +458,23 @@ public final void apply(final StructuredGraph graph, final C context, final bool
|
456 | 458 | dumpedBefore = dumpBefore(graph, context, isTopLevel, true);
|
457 | 459 | }
|
458 | 460 |
|
459 |
| - if (PhaseOptions.ReportHotMetrics.getValue(options) && PhaseOptions.ReportHotMetricsBeforePhases.matches(options, this, graph)) { |
460 |
| - // if there is a method filter set we must also match that one |
461 |
| - if (graph.getDebug().methodFilterMatchesCurrentMethod()) { |
462 |
| - String label = graph.name != null ? graph.name : graph.method().format("%H.%n(%p)"); |
463 |
| - TTY.println("Reporting hot metrics before " + getName() + " during compilation of " + label); |
464 |
| - new ReportHotCodePhase().apply(graph, context); |
| 461 | + String reportHotMetricsMethodFilter = PhaseOptions.ReportHotMetrics.getValue(options); |
| 462 | + boolean logHotMetricsForGraph = false; |
| 463 | + if (reportHotMetricsMethodFilter != null) { |
| 464 | + jdk.graal.compiler.debug.MethodFilter hotMetricsMethodFilter = null; |
| 465 | + hotMetricsMethodFilter = jdk.graal.compiler.debug.MethodFilter.parse(reportHotMetricsMethodFilter); |
| 466 | + logHotMetricsForGraph = graph.method() != null && hotMetricsMethodFilter.matches(graph.method()); |
| 467 | + if (!logHotMetricsForGraph) { |
| 468 | + CompilationIdentifier id = graph.compilationId(); |
| 469 | + JavaMethod idMethod = id.asJavaMethod(); |
| 470 | + logHotMetricsForGraph = idMethod != null && hotMetricsMethodFilter.matches(idMethod); |
| 471 | + } |
| 472 | + if (logHotMetricsForGraph) { |
| 473 | + if (PhaseOptions.ReportHotMetricsBeforePhases.getValue(graph.getOptions()).equals(getClass().getSimpleName())) { |
| 474 | + String label = graph.name != null ? graph.name : graph.method().format("%H.%n(%p)"); |
| 475 | + TTY.println("Reporting hot metrics before " + getName() + " during compilation of " + label); |
| 476 | + new ReportHotCodePhase().apply(graph, context); |
| 477 | + } |
465 | 478 | }
|
466 | 479 | }
|
467 | 480 |
|
@@ -511,9 +524,9 @@ public final void apply(final StructuredGraph graph, final C context, final bool
|
511 | 524 | }
|
512 | 525 | }
|
513 | 526 |
|
514 |
| - if (PhaseOptions.ReportHotMetrics.getValue(options) && PhaseOptions.ReportHotMetricsAfterPhases.matches(options, this, graph)) { |
515 |
| - // if there is a method filter set we must also match that one |
516 |
| - if (graph.getDebug().methodFilterMatchesCurrentMethod()) { |
| 527 | + if (logHotMetricsForGraph) { |
| 528 | + String reportAfterPhase = PhaseOptions.ReportHotMetricsAfterPhases.getValue(graph.getOptions()); |
| 529 | + if (reportAfterPhase != null && reportAfterPhase.equals(getClass().getSimpleName())) { |
517 | 530 | String label = graph.name != null ? graph.name : graph.method().format("%H.%n(%p)");
|
518 | 531 | TTY.println("Reporting hot metrics after " + getName() + " during compilation of " + label);
|
519 | 532 | new ReportHotCodePhase().apply(graph, context);
|
|
0 commit comments