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

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