diff src/share/vm/c1/c1_Runtime1.cpp @ 23745:a074ae16281d

backport of JDK-8164480
author Doug Simon <doug.simon@oracle.com>
date Fri, 26 Aug 2016 17:49:18 +0200
parents dd9cc155639c
children f13e777eb255
line wrap: on
line diff
--- a/src/share/vm/c1/c1_Runtime1.cpp	Wed Aug 24 22:31:34 2016 +0200
+++ b/src/share/vm/c1/c1_Runtime1.cpp	Fri Aug 26 17:49:18 2016 +0200
@@ -544,9 +544,8 @@
     // normal bytecode execution.
     thread->clear_exception_oop_and_pc();
 
-    Handle original_exception(thread, exception());
-
-    continuation = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, false, false);
+    bool recursive_exception = false;
+    continuation = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, false, false, recursive_exception);
     // If an exception was thrown during exception dispatch, the exception oop may have changed
     thread->set_exception_oop(exception());
     thread->set_exception_pc(pc);
@@ -554,8 +553,9 @@
     // the exception cache is used only by non-implicit exceptions
     // Update the exception cache only when there didn't happen
     // another exception during the computation of the compiled
-    // exception handler.
-    if (continuation != NULL && original_exception() == exception()) {
+    // exception handler. Checking for exception oop equality is not
+    // sufficient because some exceptions are pre-allocated and reused.
+    if (continuation != NULL && !recursive_exception) {
       nm->add_handler_for_exception_and_pc(exception, pc, continuation);
     }
   }