Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8266368: Inaccurate after_unwind hook in C2 exception handler
Reviewed-by: dlong, thartmann
  • Loading branch information
fisk committed Nov 18, 2021
1 parent 77cc508 commit 2c06bca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/hotspot/share/opto/runtime.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/runtime/sharedRuntime.cpp
Expand Up @@ -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();
}
Expand Down

1 comment on commit 2c06bca

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.