diff --git a/.hgtags b/.hgtags index be5a9a93666c9db1b6fedffbc71286e4635614b6..88bff50ab46e2c016a3e41f723f580e7339ccb43 100644 --- a/.hgtags +++ b/.hgtags @@ -1131,6 +1131,13 @@ c3618e1cdefdda6c262f082791bfd988e0e9d9c9 jdk8u162-b10 39e2895b795aded8b584626fb019d35f12e9d1e7 jdk8u162-b11 69aec2ca5d905dde1d0f29a89076d02a531808a3 jdk8u162-b12 caac74fe3cfa9a8c859c28c97d1046a58252af27 jdk8u162-b31 +c9b7abadf150328d2187de05b9e8a9cba2486e47 jdk8u162-b32 +e8041f2ec96eb6a41307732e6cf6ed90901438ae jdk8u162-b33 +bf2e8b1e8e8e6bc1f9b9475de54ba0329a6b24b1 jdk8u162-b34 +9b3f207379cf6ecfb8603640269e31ff4e064294 jdk8u162-b35 +d2ebd6530396b0afc700cd1a8eaf1f7a7f9fce8d jdk8u162-b36 +700ad8745f3fdc5ba3702616fc5ed6a6248dfa78 jdk8u162-b37 +405800ccc4c7b81475b01392f2145cc3675d1f86 jdk8u162-b38 a17bab9405474602b18cd62e060a09b17d6413ac jdk8u171-b00 ebfd57cc21e6b7f0c22b17c666b6b28c9340e207 jdk8u171-b01 1acd7c1b80241def8fac90f70b0df16356adad47 jdk8u171-b02 @@ -1156,6 +1163,13 @@ a311a45523b19d59f77e76b0441a2085bb5355c8 jdk8u172-b07 aafd1bb21e2636ba982d3eae162f5c635a1df03a jdk8u172-b09 dcd3ace969fcde4eedaddba629647656289d4264 jdk8u172-b10 083a9d6562100353708e4b73656282b21a78f714 jdk8u172-b11 +d5a33d109309138a1e9bed43d2a2bda04356dbac jdk8u172-b31 +b62c44a689e4d339b1129bffceee94119c84b1b2 jdk8u172-b32 +e8745ad08d55bb56b2ac5a70ec0a972c38fa6ca2 jdk8u172-b33 +74350ee9c013a39acb6af32049599a26e6dc3911 jdk8u172-b34 +0d1b5f9b3ab040eb9023cde206cd67d4b5a54535 jdk8u172-b35 +1e7855b1ecd3d069bcaaf35259d35f79a7c66987 jdk8u172-b36 +6a9482b43d79e3e017f58a23ec4574dd696e04db jdk8u172-b37 6e2be123a2e1c7671086c767e79ffe8ad5d4f9ca jdk8u181-b01 1d0b6fcff115a57ca02081da84589630ba282789 jdk8u181-b02 1127faef22f14d56cdd6c0c8bded598f492c2611 jdk8u181-b03 diff --git a/src/share/vm/c1/c1_Runtime1.cpp b/src/share/vm/c1/c1_Runtime1.cpp index f64c60e08a3cec104452bbbbaa28a7a694938f51..5a614b6a22462dd4558f7023c573bde1326b2586 100644 --- a/src/share/vm/c1/c1_Runtime1.cpp +++ b/src/share/vm/c1/c1_Runtime1.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2018, Oracle and/or its affiliates. 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 @@ -547,9 +547,8 @@ JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* t // 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); @@ -557,8 +556,9 @@ JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* t // 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); } } diff --git a/src/share/vm/opto/runtime.cpp b/src/share/vm/opto/runtime.cpp index c4bac05179bd1d35305ef5a1ef06077413042923..4cf1afb4ab78ac893b5eb81b41641e0c8a74c9ce 100644 --- a/src/share/vm/opto/runtime.cpp +++ b/src/share/vm/opto/runtime.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2018, Oracle and/or its affiliates. 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 @@ -1234,17 +1234,23 @@ JRT_ENTRY_NO_ASYNC(address, OptoRuntime::handle_exception_C_helper(JavaThread* t force_unwind ? NULL : nm->handler_for_exception_and_pc(exception, pc); if (handler_address == NULL) { - Handle original_exception(thread, exception()); - handler_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true); + bool recursive_exception = false; + handler_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true, recursive_exception); assert (handler_address != NULL, "must have compiled handler"); // 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. - if (!force_unwind && original_exception() == exception()) { + // compiled exception handler. Checking for exception oop equality is not + // sufficient because some exceptions are pre-allocated and reused. + if (!force_unwind && !recursive_exception) { nm->add_handler_for_exception_and_pc(exception,pc,handler_address); } } else { - assert(handler_address == SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true), "Must be the same"); +#ifdef ASSERT + bool recursive_exception = false; + address computed_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true, recursive_exception); + assert(recursive_exception || (handler_address == computed_address), err_msg("Handler address inconsistency: " PTR_FORMAT " != " PTR_FORMAT, + p2i(handler_address), p2i(computed_address))); +#endif } } diff --git a/src/share/vm/runtime/sharedRuntime.cpp b/src/share/vm/runtime/sharedRuntime.cpp index 8ffa8ab31935f829b4985abb696becb28af42cff..a831012ddf8a051b7cef1a8dcbed1e8798a77ffa 100644 --- a/src/share/vm/runtime/sharedRuntime.cpp +++ b/src/share/vm/runtime/sharedRuntime.cpp @@ -639,7 +639,7 @@ JRT_END // ret_pc points into caller; we are returning caller's exception handler // for given exception address SharedRuntime::compute_compiled_exc_handler(nmethod* nm, address ret_pc, Handle& exception, - bool force_unwind, bool top_frame_only) { + bool force_unwind, bool top_frame_only, bool& recursive_exception_occurred) { assert(nm != NULL, "must exist"); ResourceMark rm; @@ -667,6 +667,7 @@ address SharedRuntime::compute_compiled_exc_handler(nmethod* nm, address ret_pc, // BCI of the exception handler which caused the exception to be // thrown (bugs 4307310 and 4546590). Set "exception" reference // argument to ensure that the correct exception is thrown (4870175). + recursive_exception_occurred = true; exception = Handle(THREAD, PENDING_EXCEPTION); CLEAR_PENDING_EXCEPTION; if (handler_bci >= 0) { diff --git a/src/share/vm/runtime/sharedRuntime.hpp b/src/share/vm/runtime/sharedRuntime.hpp index 2167eb8d977e9f94913280b6bb1b12a6f31cde5c..c6a96a858efac07602da3a9a364914c5e948b120 100644 --- a/src/share/vm/runtime/sharedRuntime.hpp +++ b/src/share/vm/runtime/sharedRuntime.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2018, Oracle and/or its affiliates. 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 @@ -184,7 +184,7 @@ class SharedRuntime: AllStatic { // exception handling and implicit exceptions static address compute_compiled_exc_handler(nmethod* nm, address ret_pc, Handle& exception, - bool force_unwind, bool top_frame_only); + bool force_unwind, bool top_frame_only, bool& recursive_exception_occurred); enum ImplicitExceptionKind { IMPLICIT_NULL, IMPLICIT_DIVIDE_BY_ZERO,