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

4887998: Use Integer.rotateLeft() and rotateRight() in crypto implementations #9456

Closed
wants to merge 3 commits into from

Conversation

mcpowers
Copy link
Contributor

@mcpowers mcpowers commented Jul 11, 2022

https://bugs.openjdk.org/browse/JDK-4887998


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-4887998: Use Integer.rotateLeft() and rotateRight() in crypto implementations

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/9456/head:pull/9456
$ git checkout pull/9456

Update a local copy of the PR:
$ git checkout pull/9456
$ git pull https://git.openjdk.org/jdk pull/9456/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 9456

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/9456.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 11, 2022

👋 Welcome back mcpowers! 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 changed the title JDK-4887998 4887998: Use Integer.rotateLeft() and rotateRight() in crypto implementations Jul 11, 2022
@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 11, 2022
@openjdk
Copy link

openjdk bot commented Jul 11, 2022

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

  • security

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 security security-dev@openjdk.org label Jul 11, 2022
@mlbridge
Copy link

mlbridge bot commented Jul 11, 2022

Webrevs

@wangweij
Copy link
Contributor

Two comments:

  1. There are many unnecessary parenthesis, like (32 - s) or (Integer... + 5).
  2. Why choose rotateRight and not rotateLeft? https://en.wikipedia.org/wiki/SHA-1 uses "circular left shift operation" to describe the rotation.

@mcpowers
Copy link
Contributor Author

  1. I tried to keep as much of the original parenthesis as possible. I can do the minimum number if that is what you prefer.
  2. I'll change MD4, MD5, and SHA-1 to use rotateLeft in keeping with how they are described in their respective RFCs.

@jatin-bhateja
Copy link
Member

Hi @mcpowers , Currently scalar rotate inferencing is done by way of ideal transforms if it finds a matching graph pattern, apart from explicit replacement of expression with Java SE APIs do we see any performance improvements with this patch.

@wangweij
Copy link
Contributor

  • I tried to keep as much of the original parenthesis as possible. I can do the minimum number if that is what you prefer.

Yes, it's always a good choice to keep the styles consistent. With you recent code change from rotateRight(a, (32 -b)) to rotateLeft(a, b), I think it already looks much better.

@mcpowers
Copy link
Contributor Author

@wangweij , I agree it looks much better. Thanks for the rotateLeft suggestion.

@jatin-bhateja , I ran micro performance tests on my MacBook (macosx-aarch64) and didn't see any change in performance. Can you suggest a test that might show better performance? I'm assuming it would involve some platform other than my laptop.

@jatin-bhateja
Copy link
Member

jatin-bhateja commented Jul 13, 2022

@wangweij , I agree it looks much better. Thanks for the rotateLeft suggestion.

@jatin-bhateja , I ran micro performance tests on my MacBook (macosx-aarch64) and didn't see any change in performance. Can you suggest a test that might show better performance? I'm assuming it would involve some platform other than my laptop.

Hi @mcpowers , prior to pattern matching over graph snippet, non-intrinsic rotate routines will get in-lined into into its caller, so your change should ideally not impact the generate JIT code.

@mcpowers
Copy link
Contributor Author

Is there anything more that I need to check before integration?

Copy link
Contributor

@wangweij wangweij 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. No more comment.

@openjdk
Copy link

openjdk bot commented Jul 18, 2022

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

4887998: Use Integer.rotateLeft() and rotateRight() in crypto implementations

Reviewed-by: weijun

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

  • e72742e: 8286172: Create an automated test for JDK-4516019
  • b9de0a7: 8284524: Create an automated test for JDK-4422362
  • 5ae4320: 8284767: Create an automated test for JDK-4422535
  • efed7a7: 8289908: Skip bounds check for cases when String is constructed from entirely used byte[]
  • b2010a7: 8287805: Shenandoah: consolidate evacuate-update-root closures
  • ea8b75c: 8290334: Update FreeType to 2.12.1
  • 6882f0e: 8290013: serviceability/jvmti/GetLocalVariable/GetLocalWithoutSuspendTest.java failed "assert(!in_vm) failed: Undersized StackShadowPages"
  • 92067e2: 8290137: riscv: small refactoring for add_memory_int32/64
  • 87340fd: 8288883: C2: assert(allow_address || t != T_ADDRESS) failed after JDK-8283091
  • bc7a1ea: 8288948: Few J2DBench tests indicate lower primitive drawing performance with metal rendering pipeline
  • ... and 95 more: https://git.openjdk.org/jdk/compare/87aa3ce03e5e294b35cf2cab3cbba0d1964bbbff...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 (@wangweij) 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 Jul 18, 2022
@mcpowers
Copy link
Contributor Author

/integrate

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

openjdk bot commented Jul 18, 2022

@mcpowers
Your change (at version 919851a) is now ready to be sponsored by a Committer.

@wangweij
Copy link
Contributor

/sponsor

@openjdk
Copy link

openjdk bot commented Jul 18, 2022

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

  • 6c8d0e6: 8282526: Default icon is not painted properly
  • e72742e: 8286172: Create an automated test for JDK-4516019
  • b9de0a7: 8284524: Create an automated test for JDK-4422362
  • 5ae4320: 8284767: Create an automated test for JDK-4422535
  • efed7a7: 8289908: Skip bounds check for cases when String is constructed from entirely used byte[]
  • b2010a7: 8287805: Shenandoah: consolidate evacuate-update-root closures
  • ea8b75c: 8290334: Update FreeType to 2.12.1
  • 6882f0e: 8290013: serviceability/jvmti/GetLocalVariable/GetLocalWithoutSuspendTest.java failed "assert(!in_vm) failed: Undersized StackShadowPages"
  • 92067e2: 8290137: riscv: small refactoring for add_memory_int32/64
  • 87340fd: 8288883: C2: assert(allow_address || t != T_ADDRESS) failed after JDK-8283091
  • ... and 96 more: https://git.openjdk.org/jdk/compare/87aa3ce03e5e294b35cf2cab3cbba0d1964bbbff...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jul 18, 2022
@openjdk openjdk bot closed this Jul 18, 2022
@openjdk openjdk bot 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 Jul 18, 2022
@openjdk
Copy link

openjdk bot commented Jul 18, 2022

@wangweij @mcpowers Pushed as commit b65f7ec.

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

@mcpowers mcpowers deleted the JDK-4887998 branch July 20, 2022 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated security security-dev@openjdk.org
3 participants