RFR: 8338383: Implement JEP 491: Synchronize Virtual Threads without Pinning

Patricio Chilano Mateo pchilanomate at openjdk.org
Wed Nov 6 17:40:02 UTC 2024


On Fri, 1 Nov 2024 20:08:51 GMT, Dean Long <dlong at openjdk.org> wrote:

>> It turns out if we try to set last pc to the instruction after the adjustment, then we need an oopmap there, and that would require more C2 changes.  Then I thought about restoring SP from FP or last_Java_fp, but I don't think we can rely on either of those being valid after resume from preemption, so I'll try the other alternative.
>
> Here's my suggested C2 change:
> 
> diff --git a/src/hotspot/cpu/aarch64/aarch64.ad b/src/hotspot/cpu/aarch64/aarch64.ad
> index d9c77a2f529..1e99db191ae 100644
> --- a/src/hotspot/cpu/aarch64/aarch64.ad
> +++ b/src/hotspot/cpu/aarch64/aarch64.ad
> @@ -3692,14 +3692,13 @@ encode %{
>        __ post_call_nop();
>      } else {
>        Label retaddr;
> +      // Make the anchor frame walkable
>        __ adr(rscratch2, retaddr);
> +      __ str(rscratch2, Address(rthread, JavaThread::last_Java_pc_offset()));
>        __ lea(rscratch1, RuntimeAddress(entry));
> -      // Leave a breadcrumb for JavaFrameAnchor::capture_last_Java_pc()
> -      __ stp(zr, rscratch2, Address(__ pre(sp, -2 * wordSize)));
>        __ blr(rscratch1);
>        __ bind(retaddr);
>        __ post_call_nop();
> -      __ add(sp, sp, 2 * wordSize);
>      }
>      if (Compile::current()->max_vector_size() > 0) {
>        __ reinitialize_ptrue();

Great, thanks Dean. I removed `possibly_adjust_frame()` and the related code.
@RealFYang I made the equivalent change for riscv, could you verify it's okay?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21565#discussion_r1828186069


More information about the core-libs-dev mailing list