diff src/share/vm/jvmci/jvmciRuntime.cpp @ 23745:a074ae16281d

backport of JDK-8164480
author Doug Simon <doug.simon@oracle.com>
date Fri, 26 Aug 2016 17:49:18 +0200
parents 1b939a613788
children b1b5c71c04b7
line wrap: on
line diff
--- a/src/share/vm/jvmci/jvmciRuntime.cpp	Wed Aug 24 22:31:34 2016 +0200
+++ b/src/share/vm/jvmci/jvmciRuntime.cpp	Fri Aug 26 17:49:18 2016 +0200
@@ -305,13 +305,19 @@
     // normal bytecode execution.
     thread->clear_exception_oop_and_pc();
 
-    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);
 
-    // the exception cache is used only by non-implicit exceptions
-    if (continuation != NULL && !SharedRuntime::deopt_blob()->contains(continuation)) {
+    // The exception cache is used only for non-implicit exceptions
+    // Update the exception cache only when another exception did
+    // occur during the computation of the compiled exception handler
+    // (e.g., when loading the class of the catch type).
+    // Checking for exception oop equality is not
+    // sufficient because some exceptions are pre-allocated and reused.
+    if (continuation != NULL && !recursive_exception && !SharedRuntime::deopt_blob()->contains(continuation)) {
       nm->add_handler_for_exception_and_pc(exception, pc, continuation);
     }
   }