On Mon, 4 Dec 2023 16:08:32 GMT, Alan Bateman <al...@openjdk.org> wrote:
> When a virtual thread continues after Thread.yield it currently consumes > thread's parking permit. This is an oversight, the parking permit should only > be consumed when continuing after park. > > The changes are straight-forward. The internal "RUNNABLE" state is replaced > with UNPARKED and YIELDED state, effectively encoding the previous state. So > for the most part, it's just replacing the usages of RUNNABLE. The additional > states require refactoring tryGetStackTrace, this is the method that is used > for Thread::getStackTrace when the virtual thread is unmounted. It is also > changed to not not swallow the REE if the reesubmit fails (tryStackTrace has > to resubmit as the task for the thread may run, or the thread unparked, while > "suspended" and sampling its stack trace). The changes are a subset of larger > changes in the loom repo, future PRs will propose to bring in other changes > to get main line up to date. > > For testing the existing ThreadAPI has new test cases. > > Testing: test1-5. This includes the JVMTI tests as it maps the thread states > to JVMTI thread states. This pull request has now been integrated. Changeset: 29d7a223 Author: Alan Bateman <al...@openjdk.org> URL: https://git.openjdk.org/jdk/commit/29d7a22348e43cba253d0483c4c05922368f6b8a Stats: 158 lines in 4 files changed: 79 ins; 19 del; 60 mod 8321270: Virtual Thread.yield consumes parking permit Reviewed-by: sspitsyn ------------- PR: https://git.openjdk.org/jdk/pull/16953