Blame jdk8209639-rh1640127-02-coalesce_attempted_spill_non_spillable.patch

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