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

add ForceEarlyReturn support for virtual threads

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 21
    • hotspot
    • None
    • behavioral
    • minimal
    • The compatibility risk is minimal. The spec update only defines the ForceEarlyReturnXXX minimal support for virtual threads which was undefined before.
    • Other
    • SE

      Summary

      Specify minimal JVMTI ForceEarlyReturn support for virtual threads.

      Problem

      The JVMTI ForceEarlyReturnXXX functions are allowed to be supported by implementations in a general form but no minimal support is defined by the spec.

      Solution

      Specify that the ForceEarlyReturnXXX functions can be used to force early return from the current frame of a virtual thread suspended at an event.

      Specification

      The ForceEarlyReturn description starts with the statement:

      These functions allow an agent to force a method
      to return at any point during its execution.

      Replace it with:

      These functions allow an agent to force a return from the current frame.
      The specified thread must be suspended or must be the current thread.
      These functions may be used to force a return from the current frame
      of a virtual thread when it is suspended at an event.
      An implementation may support forcing a return from the current frame
      of a suspended virtual thread in other cases.

      Remove the duplication of the line which was already copied to the beginning of description (see above):

      The specified thread must be suspended or must be the current thread.

      The description of the JVMTI_ERROR_OPAQUE_FRAME error code for each ForceEarlyReturnXXX function is:

      The thread is a virtual thread and the implementation is
      unable to force its current frame to return.

      Replace it with:

      The thread is a suspended virtual thread and the implementation was
      unable to force its current frame to return.

      The spec change is:

      diff --git a/src/hotspot/share/prims/jvmti.xml b/src/hotspot/share/prims/jvmti.xml
      index ae466071de2..2f6ac9e5d1c 100644
      --- a/src/hotspot/share/prims/jvmti.xml
      +++ b/src/hotspot/share/prims/jvmti.xml
      @@ -3067,8 +3067,12 @@ err = (*jvmti)->Deallocate(jvmti, stack_info);
      
         <category id="ForceEarlyReturn" label="Force Early Return">
           <intro>
      -      These functions allow an agent to force a method
      -      to return at any point during its execution.
      +      These functions allow an agent to force a return from the current frame.
      +      The specified thread must be suspended or must be the current thread.
      +      These functions may be used to force a return from the current frame
      +      of a virtual thread when it is suspended at an event.
      +      An implementation may support forcing a return from the current frame
      +      of a suspended virtual thread in other cases.
             The method which will return early is referred to as the <i>called method</i>.
             The called method is the current method
             (as defined by
      @@ -3076,7 +3080,6 @@ err = (*jvmti)-&gt;Deallocate(jvmti, stack_info);
             for the specified thread at
             the time the function is called.
             <p/>
      -      The specified thread must be suspended or must be the current thread.
             The return occurs when execution of Java programming
             language code is resumed on this thread.
             Between calling one of these functions and resumption
      @@ -3132,7 +3135,7 @@ err = (*jvmti)-&gt;Deallocate(jvmti, stack_info);
               <error id="JVMTI_ERROR_OPAQUE_FRAME">
                 Attempted to return early from a frame
                 corresponding to a native method.
      -          The thread is a virtual thread and the implementation is
      +          The thread is a suspended virtual thread and the implementation was
                 unable to force its current frame to return.
                 Or the implementation is unable to provide
                 this functionality on this frame.
      @@ -3184,7 +3187,7 @@ err = (*jvmti)-&gt;Deallocate(jvmti, stack_info);
               <error id="JVMTI_ERROR_OPAQUE_FRAME">
                 Attempted to return early from a frame
                 corresponding to a native method.
      -          The thread is a virtual thread and the implementation is
      +          The thread is a suspended virtual thread and the implementation was
                 unable to force its current frame to return.
                 Or the implementation is unable to provide
                 this functionality on this frame.
      @@ -3232,7 +3235,7 @@ err = (*jvmti)-&gt;Deallocate(jvmti, stack_info);
               <error id="JVMTI_ERROR_OPAQUE_FRAME">
                 Attempted to return early from a frame
                 corresponding to a native method.
      -          The thread is a virtual thread and the implementation is
      +          The thread is a suspended virtual thread and the implementation was
                 unable to force its current frame to return.
                 Or the implementation is unable to provide
                 this functionality on this frame.
      @@ -3277,7 +3280,7 @@ err = (*jvmti)-&gt;Deallocate(jvmti, stack_info);
               <error id="JVMTI_ERROR_OPAQUE_FRAME">
                 Attempted to return early from a frame
                 corresponding to a native method.
      -          The thread is a virtual thread and the implementation is
      +          The thread is a suspended virtual thread and the implementation was
                 unable to force its current frame to return.
                 Or the implementation is unable to provide
                 this functionality on this frame.
      @@ -3322,7 +3325,7 @@ err = (*jvmti)-&gt;Deallocate(jvmti, stack_info);
               <error id="JVMTI_ERROR_OPAQUE_FRAME">
                 Attempted to return early from a frame
                 corresponding to a native method.
      -          The thread is a virtual thread and the implementation is
      +          The thread is a suspended virtual thread and the implementation was
                 unable to force its current frame to return.
                 Or the implementation is unable to provide
                 this functionality on this frame.
      @@ -3361,7 +3364,7 @@ err = (*jvmti)-&gt;Deallocate(jvmti, stack_info);
               <error id="JVMTI_ERROR_OPAQUE_FRAME">
                 Attempted to return early from a frame
                 corresponding to a native method.
      -          The thread is a virtual thread and the implementation is
      +          The thread is a suspended virtual thread and the implementation was
                 unable to force its current frame to return.
                 Or the implementation is unable to provide
                 this functionality on this frame.

            sspitsyn Serguei Spitsyn
            sspitsyn Serguei Spitsyn
            Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: