Skip to content

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

Closed
wants to merge 2 commits into from

Conversation

coleenp
Copy link
Contributor

@coleenp coleenp commented Jan 13, 2021

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

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8259713: Fix comments about ResetNoHandleMark in deoptimization

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk pull/2069/head:pull/2069
$ git checkout pull/2069

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 13, 2021

👋 Welcome back coleenp! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 13, 2021
@openjdk
Copy link

openjdk bot commented Jan 13, 2021

@coleenp The following label will be automatically applied to this pull request:

  • hotspot

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot hotspot-dev@openjdk.org label Jan 13, 2021
@mlbridge
Copy link

mlbridge bot commented Jan 13, 2021

Webrevs

Copy link
Member

@lfoltan lfoltan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Lois

@openjdk
Copy link

openjdk bot commented Jan 13, 2021

@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:

8259713: Fix comments about ResetNoHandleMark in deoptimization

Reviewed-by: lfoltan, dcubed, dholmes

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 master branch:

  • d18d26e: 8259350: Add some internal debugging APIs to the debug agent
  • a6b2162: 8259278: Optimize Vector API slice and unslice operations
  • da6bcf9: 8255019: Shenandoah: Split STW and concurrent mark into separate classes
  • aba3431: 8258956: Memory Leak in StringCoding on ThreadLocal resultCached StringCoding.Result
  • 8554fe6: 8253866: Security Libs Terminology Refresh
  • c2a3c7e: 8259727: Remove redundant "target" arguments to methods in Links
  • 1620664: 8259723: Move Table class to formats.html package
  • 38a1201: 8258912: Remove JVM options CountJNICalls and CountJVMCalls
  • be57cf1: 8226416: MonitorUsedDeflationThreshold can cause repeated async deflation requests
  • c822eda: 8259699: Reduce char[] copying in URLEncoder.encode(String, Charset)
  • ... and 32 more: https://git.openjdk.java.net/jdk/compare/535f2da5e2f58e92b5b788faac25c53acb3750b8...master

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 master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 13, 2021
@coleenp
Copy link
Contributor Author

coleenp commented Jan 13, 2021

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;
Copy link
Member

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.

Copy link
Contributor Author

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.)

Copy link
Contributor Author

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.

Comment on lines 690 to 691
// Beware though because allocating Handles must have a HandleMark or else the
// Handles will be leaked.
Copy link
Member

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.

Copy link
Contributor Author

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.

@dcubed-ojdk
Copy link
Member

The comment in the bug says this:

The comments are wrong and the ResetNoHandleMark is unneeded
since Deoptimization::fetch_unroll_info is a JRT_BLOCK_ENTRY (has a HandleMarkCleaner).

so I read this as you are changing Deoptimization::fetch_unroll_info to:

  • fix a comment
  • remove a ResetNoHandleMark

The comment in the bug doesn't mention JRT_LEAF at all, but you're
making comment changes there also.

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);
Copy link
Member

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);

Copy link
Contributor Author

@coleenp coleenp Jan 14, 2021

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?

Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@dcubed-ojdk
Copy link
Member

Please fix the bug synopsis and make the PR description match.
Please correct the bug description to describe what you are doing.
I also added a proposed comment rewrite for you.

@coleenp coleenp changed the title 8259713: Fix comments and ResetNoHandleMark in deoptimization 8259713: Fix comments about ResetNoHandleMark in deoptimization Jan 14, 2021
Copy link
Member

@dcubed-ojdk dcubed-ojdk left a 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... :-)

@coleenp
Copy link
Contributor Author

coleenp commented Jan 14, 2021

Thanks Dan!

Copy link
Member

@dholmes-ora dholmes-ora left a 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

@coleenp
Copy link
Contributor Author

coleenp commented Jan 14, 2021

Thanks, David for the suggestions.
/integrate

@openjdk openjdk bot closed this Jan 14, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jan 14, 2021
@openjdk
Copy link

openjdk bot commented Jan 14, 2021

@coleenp Since your change was applied there have been 43 commits pushed to the master branch:

  • 4f881ba: 8258652: Assert in JvmtiThreadState::cur_stack_depth() can noticeably slow down debugging single stepping
  • d18d26e: 8259350: Add some internal debugging APIs to the debug agent
  • a6b2162: 8259278: Optimize Vector API slice and unslice operations
  • da6bcf9: 8255019: Shenandoah: Split STW and concurrent mark into separate classes
  • aba3431: 8258956: Memory Leak in StringCoding on ThreadLocal resultCached StringCoding.Result
  • 8554fe6: 8253866: Security Libs Terminology Refresh
  • c2a3c7e: 8259727: Remove redundant "target" arguments to methods in Links
  • 1620664: 8259723: Move Table class to formats.html package
  • 38a1201: 8258912: Remove JVM options CountJNICalls and CountJVMCalls
  • be57cf1: 8226416: MonitorUsedDeflationThreshold can cause repeated async deflation requests
  • ... and 33 more: https://git.openjdk.java.net/jdk/compare/535f2da5e2f58e92b5b788faac25c53acb3750b8...master

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.

@coleenp coleenp deleted the deopt-comments branch January 15, 2021 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

4 participants