-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8362968: [JVMCI] support modifying locals in StackIntrospection on virtual threads #26422
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
base: master
Are you sure you want to change the base?
Conversation
👋 Welcome back never! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
@tkrodriguez The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
@tkrodriguez Thank you for working on this! I'll look at the JVMTI and related changes but it is going to take some time. |
For the traditional usage, in the debugger, then it's not clear to me if it's worth having JVMTI deferred locals work with virtual threads. In the debugger it should be rare to want to change a local that is not in the top frame. So I think this is more about the Truffle usage. |
I think it would be as likely as wanting to change a local that is not in the top frame for a platform thread. |
That doesn't necessarily have to be addressed in this PR. If this change lands then in the future it would be possible to support it in JVMTI with some minor additional changes. If there was stronger interest in supporting JVMTI with this change then it would be additional motivation for the changes. |
@AlanBateman I don't know all the details of stackChunkOop management and one of my assumptions is that JavaThread::exit would have the chance to clean up any live frames that have jvmtiDeferredLocals. Otherwise we would leak this storage. Is that a reasonable assumption or is it possible for a virtual JavaThread to just be reclaimed by GC? |
As things stand, a virtual thread must run to completion and terminate before it can be GC'ed. This means no live frames in the heap when GC'ed. That said, there is interest in exploring the topic of "ephemeral threads" that could be GC'ed before they terminate. This would mean a continuation and the stack chunks with frame information could get GC'ed. The JDK can't rush into allowing that of course as it would impact many parts of the system. Separately, there is interest in more exotic control flow, including generators, where there could be continuations that are GC'ed before they are "done". So not an issue right now, but something that might get explored further at some point. |
It is better to decouple the JVMCI deferred locals support from JVMTI at this point of time. Of course, it is always nice to align support for virtual and platform threads. But in this case there are some risks involved as Alan explained above. It would be relatively easy to add JVMTI support later if we decide to do so. |
The only way to fully decouple it would be to duplicate the deferred locals frame data structure for use by JVMCI. Is that what you're suggesting? It would have to be something somewhat restricted, like it was only used for virtual threads, while the existing data structure was used for regular threads. Otherwise there would be some major duplication. |
Now I see that my comment was very confusing, sorry. I wanted to say that we do not want JVMTI support of deferred locals for virtual threads other than just for top frame when suspended at an event. This will keep JVMTI for virtual threads as it is. Also, it is related to the following suggestion in the PR description:
|
This a draft of adding support for JVMTI deferred locals on virtual threads. The JDK issue has a more full description but basically I'd like some feedback on whether the strategy seems ok and whether full JVMTI support for deferred locals would be a desired outcome. If it's not then I might be able to recast this in a way that is more JVMCI specific so it requires fewer changes to the core JVMTI deferred locals support which is probably the scariest looking part. Maybe @AlanBateman and @kevinjwalls could offer some opinions here?
For the deopt/loom interactions I tried to make the use of the chunk for heap frames fairly explicit as the absolutized heap frames make me nervous. But maybe I'm just making it too complicated?
Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26422/head:pull/26422
$ git checkout pull/26422
Update a local copy of the PR:
$ git checkout pull/26422
$ git pull https://git.openjdk.org/jdk.git pull/26422/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26422
View PR using the GUI difftool:
$ git pr show -t 26422
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26422.diff