Blame jdk8209639-rh1640127-02-coalesce_attempted_spill_non_spillable.patch

298b521
298b521
# HG changeset patch
298b521
# User roland
298b521
# Date 1540370574 -7200
298b521
# Node ID d853bac073f8a4851e313ba8fa9768b38396a204
298b521
# Parent  e044997c2edaeae97866394a7f8e2ddebbd41392
298b521
8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
298b521
Reviewed-by: neliasso, kvn
298b521
298b521
diff -r e044997c2eda -r d853bac073f8 src/share/vm/opto/coalesce.cpp
298b521
--- openjdk/hotspot/src/share/vm/opto/coalesce.cpp	Mon Oct 15 11:00:27 2018 +0200
298b521
+++ openjdk/hotspot/src/share/vm/opto/coalesce.cpp	Wed Oct 24 10:42:54 2018 +0200
298b521
@@ -25,6 +25,7 @@
298b521
 #include "precompiled.hpp"
298b521
 #include "memory/allocation.inline.hpp"
298b521
 #include "opto/block.hpp"
298b521
+#include "opto/c2compiler.hpp"
298b521
 #include "opto/cfgnode.hpp"
298b521
 #include "opto/chaitin.hpp"
298b521
 #include "opto/coalesce.hpp"
298b521
@@ -294,9 +295,13 @@
298b521
             } else {
298b521
               int ireg = m->ideal_reg();
298b521
               if (ireg == 0 || ireg == Op_RegFlags) {
298b521
-                assert(false, err_msg("attempted to spill a non-spillable item: %d: %s, ireg = %d",
298b521
-                                      m->_idx, m->Name(), ireg));
298b521
-                C->record_method_not_compilable("attempted to spill a non-spillable item");
298b521
+                if (C->subsume_loads()) {
298b521
+                  C->record_failure(C2Compiler::retry_no_subsuming_loads());
298b521
+                } else {
298b521
+                  assert(false, err_msg("attempted to spill a non-spillable item: %d: %s, ireg = %d",
298b521
+                                        m->_idx, m->Name(), ireg));
298b521
+                  C->record_method_not_compilable("attempted to spill a non-spillable item");
298b521
+                }
298b521
                 return;
298b521
               }
298b521
               const RegMask *rm = C->matcher()->idealreg2spillmask[ireg];
298b521
diff -r e044997c2eda -r d853bac073f8 test/compiler/c2/SubsumingLoadsCauseFlagSpill.java
298b521
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
298b521
+++ openjdk/hotspot/test/compiler/c2/SubsumingLoadsCauseFlagSpill.java	Wed Oct 24 10:42:54 2018 +0200
298b521
@@ -0,0 +1,72 @@
298b521
+/*
298b521
+ * Copyright (c) 2018, Red Hat, Inc. All rights reserved.
298b521
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
298b521
+ *
298b521
+ * This code is free software; you can redistribute it and/or modify it
298b521
+ * under the terms of the GNU General Public License version 2 only, as
298b521
+ * published by the Free Software Foundation.
298b521
+ *
298b521
+ * This code is distributed in the hope that it will be useful, but WITHOUT
298b521
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
298b521
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
298b521
+ * version 2 for more details (a copy is included in the LICENSE file that
298b521
+ * accompanied this code).
298b521
+ *
298b521
+ * You should have received a copy of the GNU General Public License version
298b521
+ * 2 along with this work; if not, write to the Free Software Foundation,
298b521
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
298b521
+ *
298b521
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
298b521
+ * or visit www.oracle.com if you need additional information or have any
298b521
+ * questions.
298b521
+ */
298b521
+
298b521
+/**
298b521
+ * @test
298b521
+ * @bug 8209639
298b521
+ * @summary assert failure in coalesce.cpp: attempted to spill a non-spillable item
298b521
+ *
298b521
+ * @run main/othervm -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,SubsumingLoadsCauseFlagSpill::not_inlined -Xmx1024m SubsumingLoadsCauseFlagSpill
298b521
+ *
298b521
+ */
298b521
+
298b521
+public class SubsumingLoadsCauseFlagSpill {
298b521
+    private static Object field;
298b521
+    private static boolean do_throw;
298b521
+    private static volatile boolean barrier;
298b521
+
298b521
+    public static void main(String[] args) {
298b521
+        for (int i = 0; i < 20_000; i++) {
298b521
+            do_throw = true;
298b521
+            field = null;
298b521
+            test(0);
298b521
+            do_throw = false;
298b521
+            field = new Object();
298b521
+            test(0);
298b521
+        }
298b521
+    }
298b521
+
298b521
+    private static float test(float f) {
298b521
+        Object v = null;
298b521
+        try {
298b521
+            not_inlined();
298b521
+            v = field;
298b521
+        } catch (MyException me) {
298b521
+            v = field;
298b521
+            barrier = true;
298b521
+        }
298b521
+        if (v == null) {
298b521
+            return f * f;
298b521
+        }
298b521
+        return f;
298b521
+    }
298b521
+
298b521
+    private static void not_inlined() throws MyException{
298b521
+        if (do_throw) {
298b521
+            throw new MyException();
298b521
+        }
298b521
+    }
298b521
+
298b521
+    private static class MyException extends Throwable {
298b521
+    }
298b521
+}
298b521