RFR: 8274379: Allow process of unsafe access errors in check_special_condition_for_native_trans [v2]
Patricio Chilano Mateo
pchilanomate at openjdk.java.net
Tue Oct 5 20:00:15 UTC 2021
On Tue, 5 Oct 2021 19:57:32 GMT, Patricio Chilano Mateo <pchilanomate at openjdk.org> wrote:
>> Please review the following patch to allow processing of unsafe access errors in check_special_condition_for_native_trans().
>> Today we special case unsafe access errors from other async exceptions in that we don't process them when transitioning from native back to Java. Code comments in check_special_condition_for_native_trans() mention that unsafe access errors should not be handled because that may block while creating the exception. But that should not be an issue since we can always make sure we call process_if_requested_with_exit_check() after the call to throw_unsafe_access_internal_error() to process any pending operations not already handled in a ThreadBlockInVM wrapper (today that only means suspend requests and object reallocation operations).
>> By removing this special treatment for unsafe access errors we can also simplify the async exception support API. For instance we can remove _async_exception_condition and simplify some of the supporting methods. I also removed the _thread_in_native case from the switch statement in check_and_handle_async_exceptions() since we never call that method in that state.
>> Testing by running tiers1-6 in mach5.
> Patricio Chilano Mateo has updated the pull request incrementally with four additional commits since the last revision:
> - async API cleanup
> - general cleanup
> - allow process of unsafe access errors in check_special_condition_for_native_trans
> - revert to separate commits
> Hi Patricio,
> Separate commits would be good if you can easily manage that, but if it is too much effort then don't bother.
I ended up separating the commits since it makes the change easier to review. I separated them into a commit for the actual functional changes, a commit for some general cleanups that could have been done independent of this bug, and the cleanup of the API possible after the functional changes.
> I'm surprised to see that Unsafe_CopySwapMemory0 is UNSAFE_LEAF rather than UNSAFE_ENTRY.
The comment says it's to avoid blocking a GC in case both src and dst are in native memory and the copy is large. We still have a JVM_ENTRY_FROM_LEAF block on the else branch for the other cases. I guess we expect those to be shorter so there is no need to be in native.
More information about the hotspot-runtime-dev