From 0836e3050e9812a21e99d7bf6ab16619a9ef7b29 Mon Sep 17 00:00:00 2001 From: Boris Spasojevic Date: Thu, 17 Mar 2022 11:02:13 +0100 Subject: [PATCH] Use graph.checkCancellation instead of task.isCancelled. --- .../compiler/truffle/compiler/TruffleCompilerImpl.java | 4 +--- .../compiler/phases/InliningAcrossTruffleBoundaryPhase.java | 4 +--- .../truffle/compiler/phases/MaterializeFramesPhase.java | 4 +--- .../truffle/compiler/phases/NeverPartOfCompilationPhase.java | 4 +--- .../compiler/phases/SetIdentityForValueTypesPhase.java | 4 +--- .../compiler/phases/VerifyFrameDoesNotEscapePhase.java | 4 +--- 6 files changed, 6 insertions(+), 18 deletions(-) diff --git a/compiler/src/org.graalvm.compiler.truffle.compiler/src/org/graalvm/compiler/truffle/compiler/TruffleCompilerImpl.java b/compiler/src/org.graalvm.compiler.truffle.compiler/src/org/graalvm/compiler/truffle/compiler/TruffleCompilerImpl.java index c9f13af31556..da59c8af6a5a 100644 --- a/compiler/src/org.graalvm.compiler.truffle.compiler/src/org/graalvm/compiler/truffle/compiler/TruffleCompilerImpl.java +++ b/compiler/src/org.graalvm.compiler.truffle.compiler/src/org/graalvm/compiler/truffle/compiler/TruffleCompilerImpl.java @@ -505,9 +505,7 @@ private void compileAST(TruffleCompilationWrapper wrapper, DebugContext debug) { StructuredGraph graph = null; try (CompilationAlarm alarm = CompilationAlarm.trackCompilationPeriod(debug.getOptions())) { graph = truffleTier(wrapper, debug); - if (wrapper.task.isCancelled()) { - return; - } + graph.checkCancellation(); // The Truffle compiler owns the last 2 characters of the compilation name, and uses // them to encode the compilation tier, so escaping the target name is not necessary. String compilationName = wrapper.compilable.toString() + (wrapper.task.isFirstTier() ? TruffleCompiler.FIRST_TIER_COMPILATION_SUFFIX : TruffleCompiler.SECOND_TIER_COMPILATION_SUFFIX); diff --git a/compiler/src/org.graalvm.compiler.truffle.compiler/src/org/graalvm/compiler/truffle/compiler/phases/InliningAcrossTruffleBoundaryPhase.java b/compiler/src/org.graalvm.compiler.truffle.compiler/src/org/graalvm/compiler/truffle/compiler/phases/InliningAcrossTruffleBoundaryPhase.java index 4247da5c9880..24ff36d7b8e3 100644 --- a/compiler/src/org.graalvm.compiler.truffle.compiler/src/org/graalvm/compiler/truffle/compiler/phases/InliningAcrossTruffleBoundaryPhase.java +++ b/compiler/src/org.graalvm.compiler.truffle.compiler/src/org/graalvm/compiler/truffle/compiler/phases/InliningAcrossTruffleBoundaryPhase.java @@ -33,9 +33,7 @@ public final class InliningAcrossTruffleBoundaryPhase extends BasePhase { @Override protected void run(StructuredGraph graph, TruffleTierContext context) { - if (context.task.isCancelled()) { - return; - } + graph.checkCancellation(); TruffleCompilerRuntime rt = TruffleCompilerRuntime.getRuntime(); for (MethodCallTargetNode mct : graph.getNodes(MethodCallTargetNode.TYPE)) { TruffleCompilerRuntime.InlineKind inlineKind = rt.getInlineKind(mct.targetMethod(), false); diff --git a/compiler/src/org.graalvm.compiler.truffle.compiler/src/org/graalvm/compiler/truffle/compiler/phases/MaterializeFramesPhase.java b/compiler/src/org.graalvm.compiler.truffle.compiler/src/org/graalvm/compiler/truffle/compiler/phases/MaterializeFramesPhase.java index 3e5edf1788e8..1475dd86d35b 100644 --- a/compiler/src/org.graalvm.compiler.truffle.compiler/src/org/graalvm/compiler/truffle/compiler/phases/MaterializeFramesPhase.java +++ b/compiler/src/org.graalvm.compiler.truffle.compiler/src/org/graalvm/compiler/truffle/compiler/phases/MaterializeFramesPhase.java @@ -32,9 +32,7 @@ public final class MaterializeFramesPhase extends BasePhase { @Override protected void run(StructuredGraph graph, TruffleTierContext context) { - if (context.task.isCancelled()) { - return; - } + graph.checkCancellation(); for (AllowMaterializeNode materializeNode : graph.getNodes(AllowMaterializeNode.TYPE).snapshot()) { materializeNode.replaceAtUsages(materializeNode.getFrame()); graph.removeFixed(materializeNode); diff --git a/compiler/src/org.graalvm.compiler.truffle.compiler/src/org/graalvm/compiler/truffle/compiler/phases/NeverPartOfCompilationPhase.java b/compiler/src/org.graalvm.compiler.truffle.compiler/src/org/graalvm/compiler/truffle/compiler/phases/NeverPartOfCompilationPhase.java index 0432df5c6aa6..6b19b592adef 100644 --- a/compiler/src/org.graalvm.compiler.truffle.compiler/src/org/graalvm/compiler/truffle/compiler/phases/NeverPartOfCompilationPhase.java +++ b/compiler/src/org.graalvm.compiler.truffle.compiler/src/org/graalvm/compiler/truffle/compiler/phases/NeverPartOfCompilationPhase.java @@ -34,9 +34,7 @@ public final class NeverPartOfCompilationPhase extends BasePhase { @Override protected void run(StructuredGraph graph, TruffleTierContext context) { - if (context.task.isCancelled()) { - return; - } + graph.checkCancellation(); for (NeverPartOfCompilationNode neverPartOfCompilationNode : graph.getNodes(NeverPartOfCompilationNode.TYPE)) { final NeverPartOfCompilationException neverPartOfCompilationException = new NeverPartOfCompilationException(neverPartOfCompilationNode.getMessage()); neverPartOfCompilationException.setStackTrace(GraphUtil.approxSourceStackTraceElement(neverPartOfCompilationNode)); diff --git a/compiler/src/org.graalvm.compiler.truffle.compiler/src/org/graalvm/compiler/truffle/compiler/phases/SetIdentityForValueTypesPhase.java b/compiler/src/org.graalvm.compiler.truffle.compiler/src/org/graalvm/compiler/truffle/compiler/phases/SetIdentityForValueTypesPhase.java index 739328bf9db9..79207608c58f 100644 --- a/compiler/src/org.graalvm.compiler.truffle.compiler/src/org/graalvm/compiler/truffle/compiler/phases/SetIdentityForValueTypesPhase.java +++ b/compiler/src/org.graalvm.compiler.truffle.compiler/src/org/graalvm/compiler/truffle/compiler/phases/SetIdentityForValueTypesPhase.java @@ -36,9 +36,7 @@ public final class SetIdentityForValueTypesPhase extends BasePhase { @Override protected void run(StructuredGraph graph, TruffleTierContext context) { - if (context.task.isCancelled()) { - return; - } + graph.checkCancellation(); TruffleCompilerRuntime rt = TruffleCompilerRuntime.getRuntime(); for (VirtualObjectNode virtualObjectNode : graph.getNodes(VirtualObjectNode.TYPE)) { if (virtualObjectNode instanceof VirtualInstanceNode) { diff --git a/compiler/src/org.graalvm.compiler.truffle.compiler/src/org/graalvm/compiler/truffle/compiler/phases/VerifyFrameDoesNotEscapePhase.java b/compiler/src/org.graalvm.compiler.truffle.compiler/src/org/graalvm/compiler/truffle/compiler/phases/VerifyFrameDoesNotEscapePhase.java index d94d48545ae1..2a28adfc7c87 100644 --- a/compiler/src/org.graalvm.compiler.truffle.compiler/src/org/graalvm/compiler/truffle/compiler/phases/VerifyFrameDoesNotEscapePhase.java +++ b/compiler/src/org.graalvm.compiler.truffle.compiler/src/org/graalvm/compiler/truffle/compiler/phases/VerifyFrameDoesNotEscapePhase.java @@ -39,9 +39,7 @@ public class VerifyFrameDoesNotEscapePhase extends BasePhase { @Override protected void run(StructuredGraph graph, TruffleTierContext context) { - if (context.task.isCancelled()) { - return; - } + graph.checkCancellation(); for (NewFrameNode virtualFrame : graph.getNodes(NewFrameNode.TYPE)) { for (MethodCallTargetNode callTarget : virtualFrame.usages().filter(MethodCallTargetNode.class)) { if (callTarget.invoke() != null) {