This is an update to the Virtual thread implementation that we'd like to 
integrate in advance of JEP 491.

The update removes the use of  "temporary transitions", basically cases where 
the thread identity switches to the carrier thread to do something in the 
context of the carrier while a virtual thread is mounted. These cases create 
complexity for JVMTI and observability tools. It has also attracted attention 
in the review of the JEP 491 implementation as the object monitor changes have 
to deal with the possibility of entering monitors while in this state. There 
are 3 usages changes:

1. In submitRunContinuation the submit to the scheduler is changed so that it 
executes in the context of a virtual thread for cases where one virtual thread 
unparks another. This requires pinning to prevent preemption during this 
sensitive operation. ForkJoinPool.poolSubmit is changed so that it uses the 
identity of the carrier. This change has no impact on the uses of lazySubmit or 
externalSubmit.
2. Timed-park. The current implementation schedules/cancels the timer task with 
the virtual thread mounted. This runs in the context of the carrier as any 
contention would infer with thread state, park blocker and the parking permit. 
The implementation is changed to schedule the timeout after unmounting, and to 
cancel before re-mounting. The downside of this is that it will scheduled later 
(maybe 200us later than before). We could capture the time and adjust but it 
doesn't seem worth it.

- jdk.tracePinnedThreads. This is a diagnostic option for finding usages of 
thread locals in code executed by virtual threads. This is changed so use a 
thread local to detect reentrancy.

The changes means that notifyJvmtiHideFrames, its intrinsic, and the JVMTI "tmp 
VTMS_transition" bit go away.

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

Commit messages:
 - Initial commit

Changes: https://git.openjdk.org/jdk/pull/21735/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=21735&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8343132
  Stats: 354 lines in 16 files changed: 91 ins; 170 del; 93 mod
  Patch: https://git.openjdk.org/jdk/pull/21735.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/21735/head:pull/21735

PR: https://git.openjdk.org/jdk/pull/21735

Reply via email to