JDK-8238585 : JvmtiEventControllerPrivate::enter_interp_only_mode() should not make compiled methods on stack not_entrant
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: jvmti
  • Affected Version: 15
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-02-06
  • Updated: 2024-10-17
  • Resolved: 2020-06-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 15
15 b27Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
JvmtiEventControllerPrivate::enter_interp_only_mode() switches execution mode for one JavaThread to
interpreter only execution. To do so it executes the vm operation VM_EnterInterpOnlyMode which makes
all compiled java methods on stack not_entrant. This is not necessary. It is sufficient to
deoptimize the compiled frames, i.e. patch their return address with the address of the deopt
handler. It might be for historical reasons that the compiled methods are made not_entrant. If I
remember correctly, deoptimizing a frame meant overriding the corresponding compiled method with a
slide of nops leading to the deopt handler, but this changed long ago.

That clean-up is the main goal of the item.

The following enhancement is a sub-goal: replace the vm operation VM_EnterInterpOnlyMode with a
direct handshake. The safepoint for VM_EnterInterpOnlyMode synchronizes accesses of
JvmtiThreadState::_cur_stack_depth and JavaThread::_interp_only_mode, but the weaker synchronization
of a direct handshake is sufficient, because other accesses of _cur_stack_depth are either at
safepoints or directly by the associated thread.

JavaThread::_interp_only_mode is a little more difficult, because it is set to 0 by other threads
without synchronization with the owner thread (see JvmtiThreadState::leave_interp_only_mode() and
note that the value is also read in the assertion before). But at least the accesses from other
threads are well synchronized using JvmtiThreadState_lock. E.g. let Thread A1 turn on interp. only
mode for target thread T. A direct handshake is sufficient to sync. this action with execution of
T. If another thread A2 turns interp. only mode off for T, then this is synchronized with A1's
action, because both acquired JvmtiThreadState_lock. Only T's execution is not in sync with A2's
action, but that's ok: leaving interp. only mode can be asynchronous, whereas entering has to be
synchronous.

Note that VM_EnterInterpOnlyMode can be executed at a safepoint as nested vm operation. This is
currently not supported for handshakes. As a workaround the do_thread() method of the
HandshakeClosure can be called directly at safepoints (w/o handshake, see also JDK-8239084).
Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/bf7c2e28618e User: rrich Date: 2020-06-05 07:09:08 +0000
05-06-2020

Webrev.1: http://cr.openjdk.java.net/~rrich/webrevs/8238585/webrev.1/ Delta: http://cr.openjdk.java.net/~rrich/webrevs/8238585/webrev.1.inc/ Posted April 24: http://mail.openjdk.java.net/pipermail/serviceability-dev/2020-April/031245.html Note that webrev.1 might be outdated when you read this. For the latest check http://cr.openjdk.java.net/~rrich/webrevs/8238585/
04-05-2020

Moving from hotspot/svc -> hotspot/jvmti.
06-02-2020

Webrev: http://mail.openjdk.java.net/pipermail/serviceability-dev/2020-February/030359.html Prev discussion: http://mail.openjdk.java.net/pipermail/serviceability-dev/2020-January/030339.html
06-02-2020