On Mon, 28 Oct 2024 23:09:58 GMT, Dean Long <dl...@openjdk.org> wrote:
>> Not sure. We would have to return from wait0 and immediately clear the >> physical stack from the frames just copied without safepoint polls in the >> middle. Otherwise if someone walks the thread's stack it will find the >> frames appearing twice: in the physical stack and in the heap. > > It's conceivable that in the future we might have more native methods we want > to preempt. Instead of enumerating them all, we could set a flag on the > method. > > I was assuming that David was suggesting we have the Java caller do a yield() > or something, instead of having the native code call freeze. Yes. Instead of calling wait0 for a virtual thread we would call another method `needToBlockForWait` that enqueues the VT in the wait-set, releases the monitor and returns true so that caller can then "yield". It would return false if there was no longer a need to block. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21565#discussion_r1820337946