Skip to content

Conversation

@cl4es
Copy link
Member

@cl4es cl4es commented Apr 29, 2021

This patch refactors AbstractInterpreter::method_kind to reduce branches on average while better compartmentalizing the exceptional cases.

Additionally Method::is_empty_method is trivial enough that making it inlineable helps reduce cost while reducing size of the libjvm.

Result is a 40% speed-up, or a reduction of .25% of instructions on Hello World that scales to larger applications.


Progress

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

Issue

  • JDK-8266252: Streamline AbstractInterpreter::method_kind

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3798/head:pull/3798
$ git checkout pull/3798

Update a local copy of the PR:
$ git checkout pull/3798
$ git pull https://git.openjdk.java.net/jdk pull/3798/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 3798

View PR using the GUI difftool:
$ git pr show -t 3798

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/3798.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 29, 2021

👋 Welcome back redestad! 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 Apr 29, 2021
@openjdk
Copy link

openjdk bot commented Apr 29, 2021

@cl4es 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 Apr 29, 2021
@mlbridge
Copy link

mlbridge bot commented Apr 29, 2021

Webrevs

@cl4es
Copy link
Member Author

cl4es commented Apr 30, 2021

/label remove hotspot
/label add hotspot-runtime

@openjdk openjdk bot removed the hotspot hotspot-dev@openjdk.org label Apr 30, 2021
@openjdk
Copy link

openjdk bot commented Apr 30, 2021

@cl4es
The hotspot label was successfully removed.

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Apr 30, 2021
@openjdk
Copy link

openjdk bot commented Apr 30, 2021

@cl4es
The hotspot-runtime label was successfully added.

Copy link
Member

@iklam iklam 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 to me. Just a minor nit about asserts.

For other reviewers, you can get better diffs by adding ?w=1 to ignore whitespace changes. I.e., https://github.com/openjdk/jdk/pull/3798/files?w=1

case vmIntrinsics::_dabs: return java_lang_math_abs;
// _dsqrt will be selected for both Math::sqrt and StrictMath::sqrt, but the latter
// is native. Keep treating it like a native method in the interpreter
case vmIntrinsics::_dsqrt: return m->is_native() ? native : java_lang_math_sqrt;
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should add an assert that m must be one of the two methods mentioned by the above comment?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok. I'll add an assertion that allows for the StrictMath variant to be re-implemented in java

@openjdk
Copy link

openjdk bot commented May 4, 2021

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

8266252: Streamline AbstractInterpreter::method_kind

Reviewed-by: iklam, coleenp

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 36 new commits pushed to the master branch:

  • 0f925d1: 8266015: Implement AdapterHandlerLibrary lookup fast-path for common adapters
  • 69b96f9: 8266610: Method RandomAccessFile#length() returns 0 for block devices on linux.
  • 9b76955: 8266249: javax/swing/JPopupMenu/7156657/bug7156657.java fails on macOS
  • 3af4efd: 8265291: Error in Javadoc for doAccessibleAction API in AccessibleJSlider class
  • be4f25b: 8266369: (se) Add wepoll based Selector
  • ff77ca8: 8266675: Optimize IntHashTable for encapsulation and ease of use
  • 04fad70: 8266765: [BACKOUT] JDK-8255493 Support for pre-generated java.lang.invoke classes in CDS dynamic archive
  • 0790e60: 8196743: jstatd doesn't see new Java processes inside Docker container
  • c6aa8f1: 8232644: bugs in serialized-form.html
  • b5b3119: 8266589: (fs) Improve performance of Files.copy() on macOS using copyfile(3)
  • ... and 26 more: https://git.openjdk.java.net/jdk/compare/c665dba591ae5c15c9ca49e14d1aaa4eea38e7ae...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 May 4, 2021
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.

Ok with some minor nits and questions.

case vmIntrinsics::_doubleToRawLongBits: return java_lang_Double_doubleToRawLongBits;
default: break;
}
switch (m->intrinsic_id()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this just be switch (id) since you fetched m->intrinsic_id() above?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, or maybe iid is a better name for that variable.

case vmIntrinsics::_floatToRawIntBits: return java_lang_Float_floatToRawIntBits;
case vmIntrinsics::_longBitsToDouble: return java_lang_Double_longBitsToDouble;
case vmIntrinsics::_doubleToRawLongBits: return java_lang_Double_doubleToRawLongBits;
case vmIntrinsics::_dsin: return java_lang_math_sin;
Copy link
Contributor

Choose a reason for hiding this comment

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

So ZERO doesn't have these?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, I looked at the math intrinsics, which are all unimplemented in zero. I see now that there are some intrinsics implemented in ZERO, so I'll take the conservative route and move the #ifndef to only exclude such cases as were excluded before.

case vmIntrinsics::_intBitsToFloat: return java_lang_Float_intBitsToFloat;
case vmIntrinsics::_floatToRawIntBits: return java_lang_Float_floatToRawIntBits;
case vmIntrinsics::_longBitsToDouble: return java_lang_Double_longBitsToDouble;
case vmIntrinsics::_doubleToRawLongBits: return java_lang_Double_doubleToRawLongBits;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you align these return statements?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I'll try tidying up - is there some rule of thumb on how to align in a switch like this where the longest case label is.. pretty long?


// Native method?
// Note: This test must come _before_ the test for intrinsic
// methods. See also comments below.
Copy link
Contributor

Choose a reason for hiding this comment

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

So apparently this is no longer true?

Copy link
Member Author

Choose a reason for hiding this comment

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

The one case of a native and intrinsic method is StrictMath::sqrt, which is handles specially above to retain the order of precedence.

@cl4es
Copy link
Member Author

cl4es commented May 10, 2021

/integrate

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

openjdk bot commented May 10, 2021

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

  • b823b3e: 8266797: Fix for 8266610 breaks the build on macos
  • 53db2a0: 8226384: Implement a better logic to switch between OpenGL and Metal pipeline
  • 1603ca2: 8241248: NullPointerException in sun.security.ssl.HKDF.extract(HKDF.java:93)
  • 0f925d1: 8266015: Implement AdapterHandlerLibrary lookup fast-path for common adapters
  • 69b96f9: 8266610: Method RandomAccessFile#length() returns 0 for block devices on linux.
  • 9b76955: 8266249: javax/swing/JPopupMenu/7156657/bug7156657.java fails on macOS
  • 3af4efd: 8265291: Error in Javadoc for doAccessibleAction API in AccessibleJSlider class
  • be4f25b: 8266369: (se) Add wepoll based Selector
  • ff77ca8: 8266675: Optimize IntHashTable for encapsulation and ease of use
  • 04fad70: 8266765: [BACKOUT] JDK-8255493 Support for pre-generated java.lang.invoke classes in CDS dynamic archive
  • ... and 29 more: https://git.openjdk.java.net/jdk/compare/c665dba591ae5c15c9ca49e14d1aaa4eea38e7ae...master

Your commit was automatically rebased without conflicts.

Pushed as commit e41fd73.

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

@cl4es cl4es deleted the method_kind branch May 10, 2021 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

3 participants