From 2ab7aa9a3e70ab6a4018a147492f0ac03f781ba7 Mon Sep 17 00:00:00 2001 From: Tom Rodriguez Date: Thu, 15 Oct 2020 23:14:40 -0700 Subject: [PATCH] 8255068: [JVMCI] errors during compiler creation can be hidden --- .../vm/ci/hotspot/HotSpotJVMCIRuntime.java | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java index ed7df16761718..6915035af8376 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java @@ -46,6 +46,7 @@ import java.util.function.Predicate; import jdk.vm.ci.code.Architecture; +import jdk.vm.ci.code.CompilationRequest; import jdk.vm.ci.code.CompilationRequestResult; import jdk.vm.ci.code.CompiledCode; import jdk.vm.ci.code.InstalledCode; @@ -698,6 +699,19 @@ public Class getMirror(ResolvedJavaType type) { return null; } + static class ErrorCreatingCompiler implements JVMCICompiler { + private final RuntimeException t; + + ErrorCreatingCompiler(RuntimeException t) { + this.t = t; + } + + @Override + public CompilationRequestResult compileMethod(CompilationRequest request) { + throw t; + } + } + @Override public JVMCICompiler getCompiler() { if (compiler == null) { @@ -705,11 +719,19 @@ public JVMCICompiler getCompiler() { if (compiler == null) { assert !creatingCompiler : "recursive compiler creation"; creatingCompiler = true; - compiler = compilerFactory.createCompiler(this); - creatingCompiler = false; + try { + compiler = compilerFactory.createCompiler(this); + } catch (RuntimeException t) { + compiler = new ErrorCreatingCompiler(t); + } finally { + creatingCompiler = false; + } } } } + if (compiler instanceof ErrorCreatingCompiler) { + throw ((ErrorCreatingCompiler) compiler).t; + } return compiler; }