Merge
authorjcm
Fri, 27 Oct 2017 05:30:16 +0000
changeset 47755 32201e2d5719
parent 47754 00e1afbd0a76 (current diff)
parent 47700 c6d2381c6932 (diff)
child 47757 1821be9ca11b
child 47758 17676a23cf3f
Merge
--- a/src/hotspot/share/c1/c1_Compilation.cpp	Thu Oct 26 22:18:15 2017 -0700
+++ b/src/hotspot/share/c1/c1_Compilation.cpp	Fri Oct 27 05:30:16 2017 +0000
@@ -500,18 +500,22 @@
     scope_depths->trunc_to(0);
     pcos->trunc_to(0);
 
+    int prev_scope = 0;
     for (int i = 0; i < handlers->length(); i++) {
       XHandler* handler = handlers->handler_at(i);
       assert(handler->entry_pco() != -1, "must have been generated");
+      assert(handler->scope_count() >= prev_scope, "handlers should be sorted by scope");
 
-      int e = bcis->find(handler->handler_bci());
-      if (e >= 0 && scope_depths->at(e) == handler->scope_count()) {
-        // two different handlers are declared to dispatch to the same
-        // catch bci.  During parsing we created edges for each
-        // handler but we really only need one.  The exception handler
-        // table will also get unhappy if we try to declare both since
-        // it's nonsensical.  Just skip this handler.
-        continue;
+      if (handler->scope_count() == prev_scope) {
+        int e = bcis->find_from_end(handler->handler_bci());
+        if (e >= 0 && scope_depths->at(e) == handler->scope_count()) {
+          // two different handlers are declared to dispatch to the same
+          // catch bci.  During parsing we created edges for each
+          // handler but we really only need one.  The exception handler
+          // table will also get unhappy if we try to declare both since
+          // it's nonsensical.  Just skip this handler.
+          continue;
+        }
       }
 
       bcis->append(handler->handler_bci());
@@ -521,13 +525,14 @@
         scope_depths->append(0);
       } else {
         scope_depths->append(handler->scope_count());
-    }
+      }
       pcos->append(handler->entry_pco());
 
       // stop processing once we hit a catch any
       if (handler->is_catch_all()) {
         assert(i == handlers->length() - 1, "catch all must be last handler");
-  }
+      }
+      prev_scope = handler->scope_count();
     }
     exception_handler_table()->add_subtable(info->pco(), bcis, scope_depths, pcos);
   }
--- a/src/hotspot/share/runtime/thread.hpp	Thu Oct 26 22:18:15 2017 -0700
+++ b/src/hotspot/share/runtime/thread.hpp	Fri Oct 27 05:30:16 2017 +0000
@@ -1272,7 +1272,7 @@
     // we have checked is_external_suspend(), we will recheck its value
     // under SR_lock in java_suspend_self().
     return (_special_runtime_exit_condition != _no_async_condition) ||
-            is_external_suspend() || is_deopt_suspend() || is_trace_suspend();
+            is_external_suspend() || is_trace_suspend();
   }
 
   void set_pending_unsafe_access_error()          { _special_runtime_exit_condition = _async_unsafe_access_error; }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/compiler/exceptions/TestC1ExceptionHandlersSameBCI.java	Fri Oct 27 05:30:16 2017 +0000
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2017, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8188151
+ * @summary assert failure with 2 handlers at same bci
+ * @run main/othervm -XX:-BackgroundCompilation -XX:CompileOnly=TestC1ExceptionHandlersSameBCI::test1 -XX:CompileOnly=TestC1ExceptionHandlersSameBCI::test2 -XX:CompileCommand=dontinline,TestC1ExceptionHandlersSameBCI::not_inline1 -XX:CompileCommand=dontinline,TestC1ExceptionHandlersSameBCI::not_inline2 TestC1ExceptionHandlersSameBCI
+ *
+ */
+
+public class TestC1ExceptionHandlersSameBCI {
+    static class Ex1 extends Exception {
+
+    }
+    static class Ex2 extends Exception {
+
+    }
+
+    static void not_inline1() throws Ex1, Ex2 {
+
+    }
+
+    static void not_inline2(int v) {
+
+    }
+
+    static void test1() throws Ex1, Ex2 {
+        int i = 0;
+        try {
+            not_inline1();
+            i = 1;
+            not_inline1();
+        } catch (Ex1|Ex2 ex) {
+            not_inline2(i);
+        }
+    }
+
+    static void test2() {
+        int i = 0;
+        try {
+            test1();
+            i = 1;
+            test1();
+        } catch (Ex1|Ex2 ex) {
+            not_inline2(i);
+        }
+    }
+
+    static public void main(String[] args) {
+        for (int i = 0; i < 5000; i++) {
+            test2();
+        }
+    }
+}