8266368: Inaccurate after_unwind hook in C2 exception handler

Reviewed-by: dlong, thartmann
This commit is contained in:
Erik Österlund 2021-11-18 11:17:00 +00:00
parent 77cc508802
commit 2c06bca98f
2 changed files with 7 additions and 7 deletions

View File

@ -1280,6 +1280,11 @@ static void trace_exception(outputStream* st, oop exception_oop, address excepti
// directly from compiled code. Compiled code will call the C++ method following.
// We can't allow async exception to be installed during exception processing.
JRT_ENTRY_NO_ASYNC(address, OptoRuntime::handle_exception_C_helper(JavaThread* current, nmethod* &nm))
// The frame we rethrow the exception to might not have been processed by the GC yet.
// The stack watermark barrier takes care of detecting that and ensuring the frame
// has updated oops.
StackWatermarkSet::after_unwind(current);
// Do not confuse exception_oop with pending_exception. The exception_oop
// is only used to pass arguments into the method. Not for general
// exception handling. DO NOT CHANGE IT to use pending_exception, since
@ -1422,7 +1427,7 @@ address OptoRuntime::handle_exception_C(JavaThread* current) {
// deoptimized frame
if (nm != NULL) {
RegisterMap map(current, false);
RegisterMap map(current, false /* update_map */, false /* process_frames */);
frame caller = current->last_frame().sender(&map);
#ifdef ASSERT
assert(caller.is_compiled_frame(), "must be");
@ -1461,11 +1466,6 @@ address OptoRuntime::rethrow_C(oopDesc* exception, JavaThread* thread, address r
// Enable WXWrite: the function called directly by compiled code.
MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, thread));
// The frame we rethrow the exception to might not have been processed by the GC yet.
// The stack watermark barrier takes care of detecting that and ensuring the frame
// has updated oops.
StackWatermarkSet::after_unwind(thread);
#ifndef PRODUCT
SharedRuntime::_rethrow_ctr++; // count rethrows
#endif

View File

@ -497,7 +497,7 @@ address SharedRuntime::raw_exception_handler_for_return_address(JavaThread* curr
return SharedRuntime::deopt_blob()->unpack_with_exception();
} else {
// The deferred StackWatermarkSet::after_unwind check will be performed in
// * OptoRuntime::rethrow_C for C2 code
// * OptoRuntime::handle_exception_C_helper for C2 code
// * exception_handler_for_pc_helper via Runtime1::handle_exception_from_callee_id for C1 code
return nm->exception_begin();
}