RFR: 8254263: Remove special_runtime_exit_condition() check from ~ThreadInVMForHandshake()

Richard Reingruber rrich at openjdk.java.net
Mon Oct 12 08:15:09 UTC 2020


On Mon, 12 Oct 2020 04:55:51 GMT, Patricio Chilano Mateo <pchilanomate at openjdk.org> wrote:

>> src/hotspot/share/runtime/interfaceSupport.inline.hpp line 146:
>> 
>>> 144:
>>> 145:   ~ThreadInVMForHandshake() {
>>> 146:     assert(_thread->thread_state() == _thread_in_vm, "should only call when leaving VM after handshake");
>> 
>> Can we also assert `!_thread->has_special_runtime_exit_condition()`? Or at least that the value of this has not changed
>> between the TIVFH constructor and destructor.
>
> has_special_runtime_exit_condition() checks for async exceptions, external_suspend and JFR suspend. The last two can
> actually be set while we are in the handshake. It doesn't mean that the caller will consider the target suspended, but
> the _suspend_flags might be different at construction and destruction of TIVFH. As for async exceptions, I realized we
> have a similar issue as the one described in 8223572 when calling handle_polling_page_exception() on a return poll:
> - T calls ThreadSafepointState::handle_polling_page_exception() because another thread called T.stop() (which we
>   implement with a handshake)
> - T calls SafepointMechanism::process_if_requested(thread())
> - T calls HandshakeState::process_self_inner() and processes the handshake which calls set_pending_async_exception()
> - T returns from SafepointMechanism::process_if_requested(thread()) and goes back to java without calling
>   check_and_handle_async_exceptions() to throw the ThreadDeath() exception
> 
> I'm not sure if delaying the throw of ThreadDeath is allowed, so if we need to keep the current behaviour I can add a
> call to check_and_handle_async_exceptions():
> @@ -987,6 +987,7 @@ void ThreadSafepointState::handle_polling_page_exception() {
>      // Process pending operation
>      SafepointMechanism::process_if_requested(thread());
> +   thread()->check_and_handle_async_exceptions();
> 
>      // restore oop result, if any

Reading that comment I realized that this change would break in flight pr #119

To refresh memories: there I'm adding a new suspend flag currently required for object reallocation. I'm using a
handshake to synchronize with the suspendee thread S. After the handshake it is guaranteed that the stack of S is
walkable and S cannot push/pop frames. This would not work anymore.

I could replace the handshakes (in [escapeBarrier.cpp line 172,
218](https://github.com/openjdk/jdk/pull/119/files#diff-b72c15f49cba82da2158d4e9a4ab0e92R172-R173)) with vm operations
though. Should be ok.

-------------

PR: https://git.openjdk.java.net/jdk/pull/577


More information about the hotspot-runtime-dev mailing list