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 StopThread #17806

Merged

Conversation

babsingh
Copy link
Contributor

Previously, StopThread returned JVMTI_ERROR_UNSUPPORTED_OPERATION for
a virtual thread.

In JDK21, StopThread 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 unomunted since it won't be able to
    throw an asynchronous exception from the current frame.

Related:

Also, StopThread should not clear the
J9_PUBLIC_FLAGS_HALT_THREAD_JAVA_SUSPEND flag. This behaviour is not
documented in the JVMTI specification. It causes incorrect behaviour
for ResumeThread when the following sequence of JVMTI functions are
invoked: SuspendThread -> StopThread -> ResumeThread.

@babsingh babsingh force-pushed the jdk21support_jvmtiStopThread branch from e03b95b to a15c1ef Compare July 17, 2023 16:03
@babsingh
Copy link
Contributor Author

babsingh commented Jul 17, 2023

Also, StopThread should not clear the J9_PUBLIC_FLAGS_HALT_THREAD_JAVA_SUSPEND flag. This behaviour is not
documented in the JVMTI specification. It causes incorrect behaviour for ResumeThread when the following sequence of JVMTI functions are invoked: SuspendThread -> StopThread -> ResumeThread.

Test code associated to the above behaviour:

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

@babsingh
Copy link
Contributor Author

JDK21 JVMTI Specification for StopThread: https://download.java.net/java/early_access/jdk21/docs/specs/jvmti.html#StopThread

@babsingh
Copy link
Contributor Author

@gacholio Requesting to review.

Previously, StopThread returned JVMTI_ERROR_UNSUPPORTED_OPERATION for
a virtual thread.

In JDK21, StopThread 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 unomunted since it won't be able to
  throw an asynchronous exception from the current frame.

Related:
- eclipse-openj9#17717
- eclipse-openj9#17718

Also, StopThread should not clear the
J9_PUBLIC_FLAGS_HALT_THREAD_JAVA_SUSPEND flag. This behaviour is not
documented in the JVMTI specification. It causes incorrect behaviour
for ResumeThread when the following sequence of JVMTI functions are
invoked: SuspendThread -> StopThread -> ResumeThread.

Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
@babsingh babsingh force-pushed the jdk21support_jvmtiStopThread branch from a15c1ef to a9f1c91 Compare July 17, 2023 19:17
@gacholio
Copy link
Contributor

jenkins test sanity zlinux jdk8,jdk21

@gacholio gacholio merged commit 674096f into eclipse-openj9:master Jul 19, 2023
babsingh added a commit to babsingh/aqa-tests that referenced this pull request Jul 25, 2023
- StopThreadTest fixed by eclipse-openj9/openj9#17806
- PopFrameTest fixed by eclipse-openj9/openj9#17809
- GetSetLocalUnsuspended fixed by eclipse-openj9/openj9#17829

Closes eclipse-openj9/openj9#17711
Closes eclipse-openj9/openj9#17715
Closes eclipse-openj9/openj9#17716
Closes eclipse-openj9/openj9#17717
Closes eclipse-openj9/openj9#17718

Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
babsingh added a commit to babsingh/aqa-tests that referenced this pull request Jul 25, 2023
- StopThreadTest is fixed by eclipse-openj9/openj9#17806.
- PopFrameTest is fixed by eclipse-openj9/openj9#17809.
- GetSetLocalUnsuspended is fixed by eclipse-openj9/openj9#17829.

Closes eclipse-openj9/openj9#17711
Closes eclipse-openj9/openj9#17715
Closes eclipse-openj9/openj9#17716
Closes eclipse-openj9/openj9#17717
Closes eclipse-openj9/openj9#17718

Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
llxia pushed a commit to adoptium/aqa-tests that referenced this pull request Jul 25, 2023
- StopThreadTest is fixed by eclipse-openj9/openj9#17806.
- PopFrameTest is fixed by eclipse-openj9/openj9#17809.
- GetSetLocalUnsuspended is fixed by eclipse-openj9/openj9#17829.

Closes eclipse-openj9/openj9#17711
Closes eclipse-openj9/openj9#17715
Closes eclipse-openj9/openj9#17716
Closes eclipse-openj9/openj9#17717
Closes eclipse-openj9/openj9#17718

Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
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