Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8338745

Intrinsify Continuation.pin() and Continuation.unpin()

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • 24
    • None
    • hotspot
    • None
    • jfr
    • b13

      // Native stub for Contination.pin() to invoke CONT_pin
                                                                  
      00000219`01df2390 8984240080ffff mov dword ptr [rsp-8000h],eax
      00000219`01df2397 55 push rbp
      00000219`01df2398 488bec mov rbp,rsp
      00000219`01df239b 4883ec60 sub rsp,60h
      00000219`01df239f 90 nop
      00000219`01df23a0 41817f2003000000 cmp dword ptr [r15+20h],3
      00000219`01df23a8 7405 je 00000219`01df23af
      00000219`01df23aa e8315465ff call 00000219`014477e0
      00000219`01df23af 49be78ec2b0206000000 mov r14,6022BEC78h
      00000219`01df23b9 4c89742450 mov qword ptr [rsp+50h],r14
      00000219`01df23be 4c8d742450 lea r14,[rsp+50h]
      00000219`01df23c3 498bd6 mov rdx,r14
      00000219`01df23c6 c5f877 vzeroupper
      00000219`01df23c9 49bac623df0119020000 mov r10,21901DF23C6h
      00000219`01df23d3 4d8997a8030000 mov qword ptr [r15+3A8h],r10 // ljf
      00000219`01df23da 4989a7a0030000 mov qword ptr [r15+3A0h],rsp
      00000219`01df23e1 498d8fc0030000 lea rcx,[r15+3C0h] // JNI Environment
      00000219`01df23e8 41c7875004000004000000 mov dword ptr [r15+450h],4 // Transtion state to _thread_in_native
      00000219`01df23f3 48b8a0eb163dfc7f0000 mov rax,offset jvm!CONT_pin (00007ffc`3d16eba0)
      00000219`01df23fd ffd0 call rax
      00000219`01df23ff c5f877 vzeroupper
      00000219`01df2402 41c7875004000005000000 mov dword ptr [r15+450h],5
      00000219`01df240d f0834424c000 lock add dword ptr [rsp-40h],0 <<--- serializing instruction
      00000219`01df2413 493baf58040000 cmp rbp,qword ptr [r15+458h]
      00000219`01df241a 0f870e000000 ja 00000219`01df242e
      00000219`01df2420 4183bf4c04000000 cmp dword ptr [r15+44Ch],0
      00000219`01df2428 0f8423000000 je 00000219`01df2451
      00000219`01df242e c5f877 vzeroupper
      00000219`01df2431 498bcf mov rcx,r15
      00000219`01df2434 4c8be4 mov r12,rsp
      00000219`01df2437 4883ec20 sub rsp,20h
      00000219`01df243b 4883e4f0 and rsp,0FFFFFFFFFFFFFFF0h
      00000219`01df243f 48b8f0ce2f3dfc7f0000 mov rax,offset jvm!JavaThread::check_special_condition_for_native_trans (00007ffc`3d2fcef0)
      00000219`01df2449 ffd0 call rax
      00000219`01df244b 498be4 mov rsp,r12
      00000219`01df244e 4d33e4 xor r12,r12
      00000219`01df2451 41c7875004000008000000 mov dword ptr [r15+450h],8
      00000219`01df245c 4183bfe004000002 cmp dword ptr [r15+4E0h],2
      00000219`01df2464 0f843c000000 je 00000219`01df24a6
      00000219`01df246a 49c787a003000000000000 mov qword ptr [r15+3A0h],0
      00000219`01df2475 49c787a803000000000000 mov qword ptr [r15+3A8h],0
      00000219`01df2480 c5f877 vzeroupper
      00000219`01df2483 498b8f30040000 mov rcx,qword ptr [r15+430h]
      00000219`01df248a c7810001000000000000 mov dword ptr [rcx+100h],0
      00000219`01df2494 c9 leave
      00000219`01df2495 49837f0800 cmp qword ptr [r15+8],0
      00000219`01df249a 0f8501000000 jne 00000219`01df24a1
      00000219`01df24a0 c3 ret
                                                                 
      Instruction tracing to return address 00000219`01df57ec
          2 0 [ 0] 0x00000219`01df2397
          1 0 [ 0] 0x00000219`01df2398
          1 0 [ 0] 0x00000219`01df239b
          1 0 [ 0] 0x00000219`01df239f
          1 0 [ 0] 0x00000219`01df23a0
          1 0 [ 0] 0x00000219`01df23a8
          1 0 [ 0] 0x00000219`01df23af
          1 0 [ 0] 0x00000219`01df23b9
          1 0 [ 0] 0x00000219`01df23be
          1 0 [ 0] 0x00000219`01df23c3
          1 0 [ 0] 0x00000219`01df23c6
          1 0 [ 0] 0x00000219`01df23c9
          1 0 [ 0] 0x00000219`01df23d3
          1 0 [ 0] 0x00000219`01df23da
          1 0 [ 0] 0x00000219`01df23e1
          1 0 [ 0] 0x00000219`01df23e8
          1 0 [ 0] 0x00000219`01df23f3
          1 0 [ 0] 0x00000219`01df23fd
         12 0 [ 1] jvm!CONT_pin
          4 0 [ 2] jvm!OrderAccess::StubRoutines_fence
          1 0 [ 2] 0x00000219`014110ba
          1 0 [ 2] 0x00000219`014110c0
         48 6 [ 1] jvm!CONT_pin
         11 0 [ 2] jvm!JavaFrameAnchor::make_walkable
         54 17 [ 1] jvm!CONT_pin
          1 71 [ 0] 0x00000219`01df23fd
          1 0 [ 0] 0x00000219`01df23ff
          1 0 [ 0] 0x00000219`01df2402
          1 0 [ 0] 0x00000219`01df240d
          1 0 [ 0] 0x00000219`01df2413
          1 0 [ 0] 0x00000219`01df241a
          1 0 [ 0] 0x00000219`01df2420
          1 0 [ 0] 0x00000219`01df2428
          1 0 [ 0] 0x00000219`01df2451
          1 0 [ 0] 0x00000219`01df245c
          1 0 [ 0] 0x00000219`01df2464
          1 0 [ 0] 0x00000219`01df246a
          1 0 [ 0] 0x00000219`01df2475
          1 0 [ 0] 0x00000219`01df2480
          1 0 [ 0] 0x00000219`01df2483
          1 0 [ 0] 0x00000219`01df248a
          1 0 [ 0] 0x00000219`01df2494
          1 0 [ 0] 0x00000219`01df2495
          1 0 [ 0] 0x00000219`01df249a
          1 0 [ 0] 0x00000219`01df24a0

      109 instructions were executed in 108 events (0 from other threads)

      Function Name Invocations MinInst MaxInst AvgInst
      0x00000219`014110ba 1 1 1 1
      0x00000219`014110c0 1 1 1 1
      0x00000219`01df2397 1 2 2 2
      0x00000219`01df2398 1 1 1 1
      0x00000219`01df239b 1 1 1 1
      0x00000219`01df239f 1 1 1 1
      0x00000219`01df23a0 1 1 1 1
      0x00000219`01df23a8 1 1 1 1
      0x00000219`01df23af 1 1 1 1
      0x00000219`01df23b9 1 1 1 1
      0x00000219`01df23be 1 1 1 1
      0x00000219`01df23c3 1 1 1 1
      0x00000219`01df23c6 1 1 1 1
      0x00000219`01df23c9 1 1 1 1
      0x00000219`01df23d3 1 1 1 1
      0x00000219`01df23da 1 1 1 1
      0x00000219`01df23e1 1 1 1 1
      0x00000219`01df23e8 1 1 1 1
      0x00000219`01df23f3 1 1 1 1
      0x00000219`01df23fd 1 1 1 1
      0x00000219`01df23ff 1 1 1 1
      0x00000219`01df2402 1 1 1 1
      0x00000219`01df240d 1 1 1 1
      0x00000219`01df2413 1 1 1 1
      0x00000219`01df241a 1 1 1 1
      0x00000219`01df2420 1 1 1 1
      0x00000219`01df2428 1 1 1 1
      0x00000219`01df2451 1 1 1 1
      0x00000219`01df245c 1 1 1 1
      0x00000219`01df2464 1 1 1 1
      0x00000219`01df246a 1 1 1 1
      0x00000219`01df2475 1 1 1 1
      0x00000219`01df2480 1 1 1 1
      0x00000219`01df2483 1 1 1 1
      0x00000219`01df248a 1 1 1 1
      0x00000219`01df2494 1 1 1 1
      0x00000219`01df2495 1 1 1 1
      0x00000219`01df249a 1 1 1 1
      0x00000219`01df24a0 1 1 1 1
      jvm!CONT_pin 1 54 54 54
      jvm!JavaFrameAnchor::make_walkable 1 11 11 11
      jvm!OrderAccess::StubRoutines_fence 1 4 4 4

      0 system calls were executed
                                                                  

      108 instructions + 4 instructions == 112 instructions (including spill and restore for calls to Continuation.pin() and Continuation.unpin())


      // Continuation.pin() as intrinsic

      0x0000012580a0f6a8: mov r10,QWORD PTR [r15+0x550] ;*invokestatic pin {reexecute=1 rethrow=0 return_oop=0} // load last_continuation
      0x0000012580a0f6af: test r10,r10 ; null check last_continuation
      0x0000012580a0f6b2: je 0x0000012580a0f6c9 ; no last continuation mounted --> regular thread
      0x0000012580a0f6b4: mov r9d,DWORD PTR [r10+0x38] ; load pin count
      0x0000012580a0f6b8: cmp r9d,0xffffffff ; check pin count for overflow
      0x0000012580a0f6bc: je 0x0000012580a0fb0c ; uncommon trap for overflow (restart in interpreter to throw IllegalStateException)
      0x0000012580a0f6c2: inc r9d ; increment pin count
      0x0000012580a0f6c5: mov DWORD PTR [r10+0x38],r9d ; store back updated pin count

      Only 8 instructions when intrinsified.

            mgronlun Markus Grönlund
            mgronlun Markus Grönlund
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: