--- old/src/share/vm/opto/runtime.cpp	2011-07-25 18:45:42.969276848 +0200
+++ new/src/share/vm/opto/runtime.cpp	2011-07-25 18:45:42.889278557 +0200
@@ -930,10 +930,16 @@
         force_unwind ? NULL : nm->handler_for_exception_and_pc(exception, pc);
 
       if (handler_address == NULL) {
+        oop original_exception = exception();
         handler_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true);
         assert (handler_address != NULL, "must have compiled handler");
-        // Update the exception cache only when the unwind was not forced.
-        if (!force_unwind) {
+        // Update the exception cache only when the unwind was not forced
+        // and there didn't happen another exception during the computation of the 
+        // compiled exception handler. (Notice that the comparison below may wrongly fail
+        // because a GC can happen while the compiled exception handler is computed.
+        // But that should be a very rare case and updating the exception cache only
+        // during the next exception occurence should have no measurable performance impact.
+        if (!force_unwind && original_exception == exception()) {
           nm->add_handler_for_exception_and_pc(exception,pc,handler_address);
         }
       } else {
