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

JDK-8251513: Code around Parse::do_lookupswitch/do_tableswitch should be cleaned up #5837

Closed
wants to merge 2 commits into from

Conversation

tobiasholenstein
Copy link
Contributor

@tobiasholenstein tobiasholenstein commented Oct 6, 2021

  • default_cnt can be computed without using a loop:
An example of how `defaults` was computed before at parse2.cpp:521-533 with switch labels `-10`, `0`, `10`, `42` and `200`:

defaults = 0
defaults += -10 - (-2147483648)
defaults += 0 - (-10 + 1)
defaults += 10 - (0 + 1)
defaults += 42 - (10 + 1) 
defaults += 200 - (42 + 1)
defaults += 2147483647 - (200 + 1) + 1

=> `defaults`  = 
-10 - (-2147483648) + 0 - (-10 + 1) + 10 - (0 + 1) + 42 - (10 + 1) + 200 - (42 + 1) + 2147483647 - (200 + 1) + 1 = 
4294967291 = 2147483648 + 2147483648 - 5
BUT actually `defaults` was : `defaults` = 2147483648 + 2147483648

The reason has to do with using floats:
((float)match_int - (float)prev) == (-(float)prev) is True
for match_int=-10, prev=-2147483648

BUT actually `defaults` (2147483648 + 2147483648 - 5) can also be computed without using a loop with `juint defaults = max_juint - len`
  • also made some casts explicit

  • A lot of casts could be avoided by making _cnt in SwitchRange a uint. Unfortunately, the Range for the default values of a switch in do_lookupswitch calculates the count by scaling the average cnt/label up to cnt/range which needs a float to store an accurate result


Progress

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

Issue

  • JDK-8251513: Code around Parse::do_lookupswitch/do_tableswitch should be cleaned up

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 5837

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 6, 2021

👋 Welcome back tobiasholenstein! 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 Oct 6, 2021

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

  • hotspot-compiler

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-compiler hotspot-compiler-dev@openjdk.org label Oct 6, 2021
@tobiasholenstein
Copy link
Contributor Author

tobiasholenstein commented Oct 6, 2021

in do_lookupswitch the ranges for the defaults values have very accurate value (by taking the average). Whereas the ranges for the defaults values in do_tableswitch are just calculated by taking profile->default_count() / 2 for the lower and upper default ranges. But this can be very imbalanced if lower and upper range for the default have very different size. Should this be changed?

@tobiasholenstein tobiasholenstein marked this pull request as ready for review October 7, 2021 13:26
@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 7, 2021
@mlbridge
Copy link

mlbridge bot commented Oct 7, 2021

Webrevs

Copy link
Contributor

@rwestrel rwestrel left a comment

Choose a reason for hiding this comment

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

That looks good to me.

@openjdk
Copy link

openjdk bot commented Oct 13, 2021

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

8251513: Code around Parse::do_lookupswitch/do_tableswitch should  be cleaned up

Reviewed-by: roland, thartmann

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

  • 3150069: 8271949: dumppath in -XX:FlightRecorderOptions does not affect
  • bfcf6a2: 8275277: assert(dest_attr.is_in_cset() == (obj->forwardee() == obj)) failed: Only evac-failed objects must be in the collection set here but is not
  • 96fef40: 8189591: No way to locally suppress doclint warnings
  • 7fc3a8d: 8275149: (ch) ReadableByteChannel returned by Channels.newChannel(InputStream) throws ReadOnlyBufferException
  • 831802d: 8275163: Deflater::deflate methods omit javadoc for ReadOnlyBufferException
  • ad9e234: 8275145: file.encoding system property has an incorrect value on Windows
  • f178185: 8275249: Suppress warnings on non-serializable array component types in jdk.jlink
  • ee64ce9: 8274937: Revert the timeout setting for DynamicLoaderConstraintsTest
  • 8c4da9c: 8275013: Improve discussion of serialization method declarations in java.io.Object{Input, Output}Stream
  • da8da3a: 8269698: Specification for methods of java.awt.im.InputContext should mention that they do nothing
  • ... and 135 more: https://git.openjdk.java.net/jdk/compare/3953e0774c59c5e936e752aa08b6b6778e232994...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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@rwestrel, @TobiHartmann) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 13, 2021
Copy link
Member

@TobiHartmann TobiHartmann 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 too.

@tobiasholenstein
Copy link
Contributor Author

tobiasholenstein commented Oct 18, 2021

@rwestrel and @TobiHartmann thanks for the reviews!

@tobiasholenstein
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Oct 18, 2021
@openjdk
Copy link

openjdk bot commented Oct 18, 2021

@tobiasholenstein
Your change (at version 1d6f00a) is now ready to be sponsored by a Committer.

@TobiHartmann
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Oct 18, 2021

Going to push as commit ebb1363.
Since your change was applied there have been 146 commits pushed to the master branch:

  • bb7dacd: 8275334: Move class loading Events to a separate section in hs_err files
  • 3150069: 8271949: dumppath in -XX:FlightRecorderOptions does not affect
  • bfcf6a2: 8275277: assert(dest_attr.is_in_cset() == (obj->forwardee() == obj)) failed: Only evac-failed objects must be in the collection set here but is not
  • 96fef40: 8189591: No way to locally suppress doclint warnings
  • 7fc3a8d: 8275149: (ch) ReadableByteChannel returned by Channels.newChannel(InputStream) throws ReadOnlyBufferException
  • 831802d: 8275163: Deflater::deflate methods omit javadoc for ReadOnlyBufferException
  • ad9e234: 8275145: file.encoding system property has an incorrect value on Windows
  • f178185: 8275249: Suppress warnings on non-serializable array component types in jdk.jlink
  • ee64ce9: 8274937: Revert the timeout setting for DynamicLoaderConstraintsTest
  • 8c4da9c: 8275013: Improve discussion of serialization method declarations in java.io.Object{Input, Output}Stream
  • ... and 136 more: https://git.openjdk.java.net/jdk/compare/3953e0774c59c5e936e752aa08b6b6778e232994...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Oct 18, 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 sponsor Pull request is ready to be sponsored labels Oct 18, 2021
@openjdk
Copy link

openjdk bot commented Oct 18, 2021

@TobiHartmann @tobiasholenstein Pushed as commit ebb1363.

💡 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-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants