Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JDK21] Add support for JVMTI ForceEarlyReturn #17874

Merged

Conversation

babsingh
Copy link
Contributor

Previously, ForceEarlyReturn returned JVMTI_ERROR_OPAQUE_FRAME for a
virtual thread.

In JDK21, ForceEarlyReturn includes support for virtual threads as
per the JVMTI specification:

  • Error if a virtual thread is not suspended and not the current
    thread.
  • Error if a virtual thread is unmounted since it won't be able to
    force an early return.
  • For a carrier thread with a virtual thread mounted, the details of
    the carrier thread are derived from targetThread->currentContinuation.

Also, there is no need to halt and resume a thread for inspection since
ForceEarlyReturn expects the thread to be suspended as per the JVMTI
spec. If a thread is not suspended,
it returns JVMTI_ERROR_THREAD_NOT_SUSPENDED.

Related: #17713

Previously, ForceEarlyReturn returned JVMTI_ERROR_OPAQUE_FRAME for a
virtual thread.

In JDK21, ForceEarlyReturn includes support for virtual threads as
per the JVMTI specification:
- Error if a virtual thread is not suspended and not the current
  thread.
- Error if a virtual thread is unmounted since it won't be able to
  force an early return.
- For a carrier thread with a virtual thread mounted, the details of
  the carrier thread are derived from targetThread->currentContinuation.

Also, there is no need to halt and resume a thread for inspection since
ForceEarlyReturn expects the thread to be suspended as per the JVMTI
spec. If a thread is not suspended,
it returns JVMTI_ERROR_THREAD_NOT_SUSPENDED.

Related: eclipse-openj9#17713

Signed-off-by: Babneet Singh <[email protected]>
@babsingh babsingh force-pushed the jdk21support_jvmtiForceEarlyReturn branch from 043f8d1 to dbaf246 Compare July 27, 2023 21:01
@babsingh
Copy link
Contributor Author

Verified locally that ForceEarlyReturnTest passes with the changes from this PR.

@tajila Requesting your review. This PR is identical to #17809, which you had reviewed earlier.

Also, there is no need to halt and resume a thread for inspection since ForceEarlyReturn expects the thread to be suspended as per the JVMTI spec. If a thread is not suspended, it returns JVMTI_ERROR_THREAD_NOT_SUSPENDED.

The above requirement to suspend is enforced from JDK8 to JDK21:

JDK8 - https://docs.oracle.com/javase/8/docs/platform/jvmti/jvmti.html#ForceEarlyReturn
JDK21 - https://download.java.net/java/early_access/jdk21/docs/specs/jvmti.html#ForceEarlyReturn

@babsingh babsingh requested a review from tajila July 27, 2023 21:01
@tajila
Copy link
Contributor

tajila commented Jul 28, 2023

jenkins test sanity,extended alinux64 jdk21

@tajila
Copy link
Contributor

tajila commented Jul 28, 2023

jenkins compile win jdk11

@tajila tajila merged commit bf919a7 into eclipse-openj9:master Jul 28, 2023
babsingh added a commit to babsingh/aqa-tests that referenced this pull request Jul 28, 2023
llxia pushed a commit to adoptium/aqa-tests that referenced this pull request Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants