Skip to content

Commit 233ec7c

Browse files
committed
[GR-51012] The LibGraal Truffle gate fails on host compilation error.
PullRequest: graal/16518
2 parents f5b7d19 + b99d44e commit 233ec7c

File tree

5 files changed

+59
-50
lines changed

5 files changed

+59
-50
lines changed

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/ExceptionActionTest.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import jdk.graal.compiler.truffle.test.nodes.RootTestNode;
4545
import org.graalvm.polyglot.Context;
4646
import org.junit.Assert;
47-
import org.junit.BeforeClass;
4847
import org.junit.Test;
4948

5049
import com.oracle.truffle.api.CompilerAsserts;
@@ -63,17 +62,6 @@ public class ExceptionActionTest extends TestWithPolyglotOptions {
6362

6463
static Object nonConstant;
6564

66-
@BeforeClass
67-
public static void setUp() {
68-
// All ExceptionActionTest's tests are executed in the spawned subprocess. The
69-
// PermanentBailoutNode is used only by the code running in the subprocess. Needless
70-
// PermanentBailoutNode initialization in the parent process will cause ExceptionActionTest
71-
// failure when running with the engine.ExceptionAction=Throw.
72-
if (SubprocessTestUtils.isSubprocess()) {
73-
createPermanentBailoutNode().getCallTarget().call();
74-
}
75-
}
76-
7765
@Test
7866
public void testDefault() throws Exception {
7967
BiConsumer<String, String> verifier = (log, output) -> {
@@ -126,6 +114,21 @@ public void testPermanentBailoutThrow() throws Exception {
126114
executeInSubProcess(verifier, "engine.CompilationFailureAction", "Throw");
127115
}
128116

117+
@Test
118+
public void testPermanentBailoutThrowWithGraalExitVM() throws Exception {
119+
BiConsumer<String, String> verifier = (log, output) -> {
120+
Assert.assertFalse(formatMessage("Unexpected bailout.", log, output), hasBailout(log));
121+
Assert.assertFalse(formatMessage("Unexpected exit.", log, output), hasExit(log));
122+
Assert.assertTrue(formatMessage("Expected OptimizationFailedException.", log, output), hasOptFailedException(log));
123+
};
124+
executeInSubProcess(verifier, ExceptionActionTest::createPermanentBailoutNode,
125+
new String[]{
126+
"-Djdk.graal.CompilationFailureAction=ExitVM",
127+
"-Djdk.graal.CompilationBailoutAsFailure=true",
128+
},
129+
"engine.CompilationFailureAction", "Throw");
130+
}
131+
129132
@Test
130133
public void testNonPermanentBailout() throws Exception {
131134
BiConsumer<String, String> verifier = (log, output) -> {
@@ -164,7 +167,7 @@ private void executeInSubProcess(BiConsumer<String, String> verifier, Supplier<R
164167
String[] useVMOptions = Arrays.copyOf(additionalVmOptions, additionalVmOptions.length + 2);
165168
useVMOptions[useVMOptions.length - 2] = String.format("-D%s=%s", LOG_FILE_PROPERTY, log);
166169
// Prevent graal graph dumping for ExceptionAction#Diagnose
167-
useVMOptions[useVMOptions.length - 1] = "-Djdk.graal.Dump=Truffle:0";
170+
useVMOptions[useVMOptions.length - 1] = "~~-Djdk.graal.Dump";
168171
subprocess = SubprocessTestUtils.executeInSubprocess(ExceptionActionTest.class, () -> {
169172
setupContext(contextOptions);
170173
OptimizedCallTarget target = (OptimizedCallTarget) rootNodeFactory.get().getCallTarget();

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/GraalTruffleRuntimeListenerTest.java

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -205,49 +205,51 @@ public void testBlockCompilationLargeBlocks() {
205205
}
206206

207207
@Test
208-
public void testBlockCompilationMaximumGraalGraphSize() {
209-
int blockSize = 100;
210-
int nodeCount = 1000;
211-
setupContext("engine.CompileImmediately", "true",
212-
"engine.BackgroundCompilation", "false",
213-
"engine.PartialBlockCompilationSize", String.valueOf(blockSize),
214-
"compiler.MaximumGraalGraphSize", "20000");
215-
OptimizedTruffleRuntime runtime = OptimizedTruffleRuntime.getRuntime();
216-
AbstractTestNode[] children = new AbstractTestNode[nodeCount];
217-
for (int i = 0; i < children.length; i++) {
218-
children[i] = new ExpensiveTestNode();
219-
}
220-
BlockNode<AbstractTestNode> block = BlockNode.create(children, new NodeExecutor());
221-
OptimizedCallTarget compilable = (OptimizedCallTarget) new TestRootNode(block).getCallTarget();
222-
TestListener listener = new TestListener(compilable);
223-
try {
224-
runtime.addListener(listener);
225-
compilable.compile(!compilable.engine.multiTier);
226-
List<EventType> expectedEvents = new ArrayList<>();
227-
// Main CallTarget
228-
expectedEvents.add(EventType.ENQUEUED);
229-
expectedEvents.add(EventType.COMPILATION_STARTED);
230-
expectedEvents.add(EventType.COMPILATION_FAILURE);
231-
expectedEvents.add(EventType.DEQUEUED);
232-
// Main CallTarget enqueued for re-compilation
233-
expectedEvents.add(EventType.ENQUEUED);
234-
// New partial blocks CallTargets
235-
for (int i = 0; i < nodeCount / blockSize; i++) {
208+
public void testBlockCompilationMaximumGraalGraphSize() throws Exception {
209+
executeInSubprocess(() -> {
210+
int blockSize = 100;
211+
int nodeCount = 1000;
212+
setupContext("engine.CompileImmediately", "true",
213+
"engine.BackgroundCompilation", "false",
214+
"engine.PartialBlockCompilationSize", String.valueOf(blockSize),
215+
"compiler.MaximumGraalGraphSize", "20000");
216+
OptimizedTruffleRuntime runtime = OptimizedTruffleRuntime.getRuntime();
217+
AbstractTestNode[] children = new AbstractTestNode[nodeCount];
218+
for (int i = 0; i < children.length; i++) {
219+
children[i] = new ExpensiveTestNode();
220+
}
221+
BlockNode<AbstractTestNode> block = BlockNode.create(children, new NodeExecutor());
222+
OptimizedCallTarget compilable = (OptimizedCallTarget) new TestRootNode(block).getCallTarget();
223+
TestListener listener = new TestListener(compilable);
224+
try {
225+
runtime.addListener(listener);
226+
compilable.compile(!compilable.engine.multiTier);
227+
List<EventType> expectedEvents = new ArrayList<>();
228+
// Main CallTarget
236229
expectedEvents.add(EventType.ENQUEUED);
237230
expectedEvents.add(EventType.COMPILATION_STARTED);
231+
expectedEvents.add(EventType.COMPILATION_FAILURE);
232+
expectedEvents.add(EventType.DEQUEUED);
233+
// Main CallTarget enqueued for re-compilation
234+
expectedEvents.add(EventType.ENQUEUED);
235+
// New partial blocks CallTargets
236+
for (int i = 0; i < nodeCount / blockSize; i++) {
237+
expectedEvents.add(EventType.ENQUEUED);
238+
expectedEvents.add(EventType.COMPILATION_STARTED);
239+
expectedEvents.add(EventType.TRUFFLE_TIER_FINISHED);
240+
expectedEvents.add(EventType.GRAAL_TIER_FINISHED);
241+
expectedEvents.add(EventType.COMPILATION_SUCCESS);
242+
}
243+
// Main CallTarget re-compilation
244+
expectedEvents.add(EventType.COMPILATION_STARTED);
238245
expectedEvents.add(EventType.TRUFFLE_TIER_FINISHED);
239246
expectedEvents.add(EventType.GRAAL_TIER_FINISHED);
240247
expectedEvents.add(EventType.COMPILATION_SUCCESS);
248+
listener.assertEvents(expectedEvents.toArray(new EventType[expectedEvents.size()]));
249+
} finally {
250+
runtime.removeListener(listener);
241251
}
242-
// Main CallTarget re-compilation
243-
expectedEvents.add(EventType.COMPILATION_STARTED);
244-
expectedEvents.add(EventType.TRUFFLE_TIER_FINISHED);
245-
expectedEvents.add(EventType.GRAAL_TIER_FINISHED);
246-
expectedEvents.add(EventType.COMPILATION_SUCCESS);
247-
listener.assertEvents(expectedEvents.toArray(new EventType[expectedEvents.size()]));
248-
} finally {
249-
runtime.removeListener(listener);
250-
}
252+
});
251253
}
252254

253255
private static RootNode createFailureNode() {

truffle/mx.truffle/mx_truffle.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,7 @@ def tck(args):
846846
"-Dpolyglot.engine.AllowExperimentalOptions=true",
847847
"-Dpolyglot.engine.Mode=latency",
848848
# "-Dpolyglot.engine.CompilationFailureAction=Throw", GR-49399
849+
"-Djdk.graal.CompilationFailureAction=ExitVM",
849850
"-Dpolyglot.engine.CompileImmediately=true",
850851
"-Dpolyglot.engine.BackgroundCompilation=false",
851852
"-Dtck.inlineVerifierInstrument=false",

truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/EngineData.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ private void updateCompilerOptions(Map<String, String> options) {
326326
options.put("compiler.DiagnoseFailure", "true");
327327
} else if (compilationFailureAction == ExceptionAction.Diagnose) {
328328
options.put("compiler.DiagnoseFailure", "true");
329+
} else if (compilationFailureAction == ExceptionAction.Throw) {
330+
options.put("compiler.DiagnoseFailure", "true");
329331
}
330332
if (TruffleOptions.AOT && traceTransferToInterpreter) {
331333
options.put("compiler.NodeSourcePositions", "true");

vm/mx.vm/mx_vm_gate.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ def is_truffle_fallback(arg):
490490
"-Dpolyglot.engine.CompileImmediately=true",
491491
"-Dpolyglot.engine.BackgroundCompilation=false",
492492
"-Dpolyglot.engine.CompilationFailureAction=Throw",
493+
"-Djdk.graal.CompilationFailureAction=ExitVM",
493494
"-Dgraalvm.locatorDisabled=true",
494495
"truffle", "LibGraalCompilerTest"])
495496

0 commit comments

Comments
 (0)