changeset 23377:6a01ba690eb2

GraalCompiler.emitLIR: allow multiple restarts.
author Josef Eisl <josef.eisl@jku.at>
date Wed, 03 Feb 2016 12:07:15 +0100
parents 4d74344a78a5
children 3cbb2c456543
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java
diffstat 1 files changed, 13 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Wed Feb 03 12:18:19 2016 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Wed Feb 03 12:07:15 2016 +0100
@@ -32,6 +32,7 @@
 import jdk.vm.ci.code.TargetDescription;
 import jdk.vm.ci.code.site.ConstantReference;
 import jdk.vm.ci.code.site.DataPatch;
+import jdk.vm.ci.common.JVMCIError;
 import jdk.vm.ci.meta.Assumptions;
 import jdk.vm.ci.meta.JavaConstant;
 import jdk.vm.ci.meta.JavaKind;
@@ -236,18 +237,22 @@
 
     @SuppressWarnings("try")
     public static LIRGenerationResult emitLIR(Backend backend, StructuredGraph graph, Object stub, RegisterConfig registerConfig, LIRSuites lirSuites) {
-        try {
-            return emitLIR0(backend, graph, stub, registerConfig, lirSuites);
-        } catch (BailoutAndRestartBackendException e) {
-            if (BailoutAndRestartBackendException.Options.LIRUnlockBackendRestart.getValue() && e.shouldRestart()) {
-                try (OverrideScope scope = e.getOverrideScope()) {
-                    LIRSuites lirSuites0 = e.updateLIRSuites(lirSuites);
+        OverrideScope overrideScope = null;
+        LIRSuites lirSuites0 = lirSuites;
+        while (true) {
+            try (OverrideScope scope = overrideScope) {
+                return emitLIR0(backend, graph, stub, registerConfig, lirSuites0);
+            } catch (BailoutAndRestartBackendException e) {
+                if (BailoutAndRestartBackendException.Options.LIRUnlockBackendRestart.getValue() && e.shouldRestart()) {
+                    overrideScope = e.getOverrideScope();
+                    lirSuites0 = e.updateLIRSuites(lirSuites);
                     if (lirSuites0 != null) {
-                        return emitLIR0(backend, graph, stub, registerConfig, lirSuites0);
+                        continue;
                     }
                 }
+                /* If the restart fails we convert the exception into a "hard" failure */
+                throw new JVMCIError(e);
             }
-            throw e;
         }
     }