Blame SOURCES/jdk8209639-rh1640127-02-coalesce_attempted_spill_non_spillable.patch

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