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

8263392: Allow current thread to be specified in ExceptionMark #2950

Closed
wants to merge 4 commits into from

Conversation

iklam
Copy link
Member

@iklam iklam commented Mar 11, 2021

ExceptionMark, usually used via the EXCEPTION_MARK marco, is used to guarantee that an exception is not thrown within a block of code. I made two changes to improve efficiency:

  • Avoid calling Thread::current() if a thread object is already available.
  • Avoid passing a reference to the ExceptionMark constructor. This helps C++ generate slightly better code.

This new variant of ExceptionMark is mainly intended for future clean up of TRAPS/CHECK/THREAD code, where an exception context is temporarily needed but we will guarantee that all exceptions will be handled. I modified SharedRuntime::monitor_exit_helper() to use this pattern:

Old style:

void a_func_that_never_throws() {
  EXCEPTION_MARK;
  a_func_that_could_throw(THREAD);
  if (HAS_PENDING_EXCEPTION) {
      // handle it
    CLEAR_PENDING_EXCEPTION;
  }
}

New style:

void a_func_that_never_throws(Thread* current) { // pass thread to avoid calling Thread::current()
  ExceptionMark em(current);
  Thread* THREAD = current; // For exception macros.
  a_func_that_could_throw(THREAD);
  if (HAS_PENDING_EXCEPTION) {
      // handle it
      CLEAR_PENDING_EXCEPTION;
  }
}

Progress

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

Issue

  • JDK-8263392: Allow current thread to be specified in ExceptionMark

Reviewers

Download

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

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 11, 2021

👋 Welcome back iklam! 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
Copy link

openjdk bot commented Mar 11, 2021

@iklam The following labels will be automatically applied to this pull request:

  • hotspot
  • serviceability

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.

@openjdk openjdk bot added serviceability serviceability-dev@openjdk.org hotspot hotspot-dev@openjdk.org labels Mar 11, 2021
@iklam
Copy link
Member Author

iklam commented Mar 11, 2021

/label remove serviceability

@openjdk openjdk bot removed the serviceability serviceability-dev@openjdk.org label Mar 11, 2021
@openjdk
Copy link

openjdk bot commented Mar 11, 2021

@iklam
The serviceability label was successfully removed.

@iklam iklam marked this pull request as ready for review March 11, 2021 22:02
@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 11, 2021
@mlbridge
Copy link

mlbridge bot commented Mar 11, 2021

Webrevs

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.

Looks good! Thanks for doing this cleanup.

David

@openjdk
Copy link

openjdk bot commented Mar 12, 2021

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

8263392: Allow current thread to be specified in ExceptionMark

Reviewed-by: dholmes, ccheung, coleenp, minqi

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 1 new commit pushed to the master branch:

  • 0c718ab: 8262277: URLClassLoader.getResource throws undocumented IllegalArgumentException

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
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 Mar 12, 2021
Copy link
Member

@calvinccheung calvinccheung left a comment

Choose a reason for hiding this comment

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

Looks good.

Copy link
Contributor

@coleenp coleenp left a comment

Choose a reason for hiding this comment

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

This looks good. It would be nice to replace more EXCEPTION_MARK as we find them.

Copy link
Contributor

@yminqi yminqi left a comment

Choose a reason for hiding this comment

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

This change is good.

@iklam
Copy link
Member Author

iklam commented Mar 15, 2021

Thanks @dholmes-ora @calvinccheung @coleenp @yminqi for the review.
/integrate

@openjdk openjdk bot closed this Mar 15, 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 Mar 15, 2021
@openjdk
Copy link

openjdk bot commented Mar 15, 2021

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

  • 4d1c08c: 8263616: 'Deprecatd' typo in src/hotspot/share/classfile/classFileParser.cpp
  • 0c718ab: 8262277: URLClassLoader.getResource throws undocumented IllegalArgumentException

Your commit was automatically rebased without conflicts.

Pushed as commit 1e57087.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

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
6 participants