-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8259713: Fix comments about ResetNoHandleMark in deoptimization #2069
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
Conversation
👋 Welcome back coleenp! A progress list of the required criteria for merging this PR into |
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Lois
@coleenp This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 42 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
Thanks Lois! |
ResetNoHandleMark rnhm; // No-op in release/product versions | ||
// Beware though because allocating Handles must have a HandleMark or else the | ||
// Handles will be leaked. | ||
ResetNoHandleMark rnhm; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I'm confused. The bug description says:
the ResetNoHandleMark is unneeded
but it is still here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is needed because it's in a JRT_LEAF. The one above in the JRT_BLOCK_ENTRY is unneeded (along with the comment that matched the one in this unpack_frames() function.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correction, I didn't remove a ResetNoHandleMark in fetch_unroll_info, because there wasn't one there. It was removed already. I just removed the comment that described the code that isn't there anymore.
// Beware though because allocating Handles must have a HandleMark or else the | ||
// Handles will be leaked. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is confusing because there is HandleMark on L693.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point of this comment is that you should make sure you have a HandleMark if you've used ResetNoHandleMark in JRT_LEAF.
The comment in the bug says this:
so I read this as you are changing Deoptimization::fetch_unroll_info to:
The comment in the bug doesn't mention JRT_LEAF at all, but you're No where in this fix do I see a ResetNoHandleMark being removed. Is the reason for my confusion more clear yet? |
ResetNoHandleMark rnhm; // No-op in release/product versions | ||
// Beware though because allocating Handles must have a HandleMark or else the | ||
// Handles will be leaked. | ||
ResetNoHandleMark rnhm; | ||
HandleMark hm(thread); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a simpler rewrite for L687 -> L693:
// This code wants to allocate handles which is okay in a leaf method,
// but JRT_LEAF contains a NoHandleMark so we have to work around
// that with ResetNoHandleMark in order to create a HandleMark here:
ResetNoHandleMark rnhm;
HandleMark hm(thread);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately this is not entirely what I want to say.
I want to say that you must have a HandleMark if you have ResetNoHandleMark in a JRT_LEAF.
You need a ResetNoHandleMark to create Handles but there are no asserts to make sure you have a HandleMark.
ie:
ResetNoHandleMark rnhm;
Handle h(THREAD, obj); // OK no problem
But the Handle will leak once this function returns (until the next JRT_ENTRY anyway).
// This code wants to allocate handles which is okay in a leaf method,
// but JRT_LEAF contains a NoHandleMark so we have to work around
// that with ResetNoHandleMark in order to create a Handles here.
// There must also be a HandleMark here to clean up any handles created in this scope.
How about that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion:
// JRT_LEAF methods don't normally allocate handles and there is a
// NoHandleMark to enforce that. It is actually safe to use Handles
// in a JRT_LEAF method, and sometimes desirable, but to do so we
// must use ResetNoHandleMark to bypass the NoHandleMark, and
// then use a HandleMark to ensure any Handles we do create are
// cleaned up in this scope.
I still question why such a function declares itself a LEAF instead of just being a JRT_ENTRY but that is a different argument. :)
Cheers,
David
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, your comment says the same thing as mine and includes what I want to say, so I'll use your comment.
I'm pretty sure this function wants a NoSafepointVerifier but some of the calls it uses might need handles, because we were pretty aggressive about making arguments into handles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually think the HandleMark is there because of the PreserveExceptionMark call in VerifyStack, which is the thing that Erik ran into also with stack watermarks, and prompted the original request about lifting the restrictions for JRT_LEAF functions. I don't want there to be an unhandleized version of PreserveExceptionMark, and I don't want JRT_LEAF to allow Handles by default, so hopefully this comment is adequate documentation.
Please fix the bug synopsis and make the PR description match. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like David's comment much more than the one I proposed!
Thumbs up! For the first time in a long time, I had to use a
webrev to review the code since there were so many comments
in the Git view that made it hard to see the code... :-)
Thanks Dan! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG.
Thanks Coleen!
David
Thanks, David for the suggestions. |
@coleenp Since your change was applied there have been 43 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit bf28f92. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This is a small part of the withdrawn change for #1990 to fix the out-of-date comments in deoptimization.cpp.
Tested with tier1-3.
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/2069/head:pull/2069
$ git checkout pull/2069