From 88d24368239407260a0e316e2a8f63783f8833ec Mon Sep 17 00:00:00 2001 From: David Leopoldseder Date: Fri, 11 Aug 2023 13:10:35 +0200 Subject: [PATCH] graph order: run some form of schedule verification in all tiers if possible --- .../graalvm/compiler/phases/util/GraphOrder.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/phases/util/GraphOrder.java b/compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/phases/util/GraphOrder.java index 5dd05724f255..ffe9c02843e0 100644 --- a/compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/phases/util/GraphOrder.java +++ b/compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/phases/util/GraphOrder.java @@ -29,6 +29,7 @@ import org.graalvm.collections.EconomicMap; import org.graalvm.collections.Equivalence; +import org.graalvm.compiler.debug.Assertions; import org.graalvm.compiler.debug.DebugContext; import org.graalvm.compiler.debug.GraalError; import org.graalvm.compiler.graph.GraalGraphError; @@ -150,12 +151,24 @@ private static void visitForward(ArrayList nodes, NodeBitMap visited, Node } } + public static boolean assertSchedulableGraph(StructuredGraph g) { + assert GraphOrder.assertNonCyclicGraph(g); + assert g.getGuardsStage() == GuardsStage.AFTER_FSA || GraphOrder.assertScheduleableBeforeFSA(g); + if (g.getGuardsStage() == GuardsStage.AFTER_FSA && Assertions.detailedAssertionsEnabled(g.getOptions())) { + // we still want to do a memory verification of the schedule even if we can + // no longer use assertSchedulableGraph after the floating reads phase + SchedulePhase.runWithoutContextOptimizations(g, SchedulePhase.SchedulingStrategy.LATEST_OUT_OF_LOOPS, true); + } + assert g.verify(); + return true; + } + /** * This method schedules the graph and makes sure that, for every node, all inputs are available * at the position where it is scheduled. This is a very expensive assertion. */ @SuppressWarnings("try") - public static boolean assertSchedulableGraph(final StructuredGraph graph) { + private static boolean assertScheduleableBeforeFSA(final StructuredGraph graph) { assert graph.getGuardsStage() != GuardsStage.AFTER_FSA : "Cannot use the BlockIteratorClosure after FrameState Assignment, HIR Loop Data Structures are no longer valid."; try (DebugContext.Scope s = graph.getDebug().scope("AssertSchedulableGraph")) { SchedulePhase.runWithoutContextOptimizations(graph, getSchedulingPolicy(graph), true);