-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8315968: Move java.util.Digits to jdk.internal.util and refactor to reduce duplication #15651
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
Conversation
|
👋 Welcome back wenshao! A progress list of the required criteria for merging this PR into |
Webrevs
|
|
Instead of packing more stuff into SharedSecrets, how about moving some common utilities into package jdk.internal.util or a new package jdk.internal.string. |
|
Yes, moving java.util.Digits to jdk.internal.util was what I had in mind, too. SharedSecrets are only necessary when we have things that need to stay package-private, such as member functions on String. Static utilities like this are generally easier to maintain when they are public but in a non-exported package like jdk.internal.util. |
RogerRiggs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would cleaner and easier to review, if you moved the classes together and did not refactor the functions. Only include the dependencies. Update the functions in a separate PR. (We can retitle the issue to match).
src/java.base/share/classes/jdk/internal/util/DecimalDigits.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In short: I suggest splitting the change of moving getChars stringSize into another patch; they are sufficiently distinct and can shrink this PR's size by a half at least.
总结:推荐这个PR专门处理移除StringLatin1.PACKED_DIGITS字段和Digits移包。
迁移getChars和stringSize分另外一个补丁。这两个内容唯一共通点是StringLatin1.getChars有些冲突,但是除此之外没必要两个补丁合并,大幅增加代码改动,难review,回滚和git blame,比如这个补丁里面Long AbstractStringBuilder等一堆改动实际上是这两个method,和PACKED_DIGITS无关。
src/java.base/share/classes/jdk/internal/util/DecimalDigits.java
Outdated
Show resolved
Hide resolved
| * wins. The iteration results are also routinely inlined in the generated | ||
| * code after loop unrolling. | ||
| */ | ||
| public static int stringSize(int x) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest splitting the moves of stringSize getChars into a new PR dependent on this one; your future date and time optimizations can depend on that one, which exposes stringSize.
Having the DecimalDigits package move and stringSize getChars moves together complicates the file changes, and it's hard to detect if there's any accidental typo/malicious code in the new additions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, do the package move separate from the refactoring.
The other PRs can wait a bit or be committed as is and take part in the refactoring later.
One step at a time please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactoring of stringSize has been restored
|
@wenshao this pull request can not be integrated into git checkout reduce_duplicate
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push |
| * wins. The iteration results are also routinely inlined in the generated | ||
| * code after loop unrolling. | ||
| */ | ||
| public static int stringSize(int x) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, do the package move separate from the refactoring.
The other PRs can wait a bit or be committed as is and take part in the refactoring later.
One step at a time please.
| @@ -0,0 +1,294 @@ | |||
| /* | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can git be convinced to show this as a rename instead of a delete and add?
The history will be cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just looked it up and git actually doesn't have commands for renames like hg, but rather decides if something is a delete+add or a rename based on the amount of changes. Too many changes and it'll automatically look like a remove+add.
Which is yet another argument for splitting up this in multiple PRs. One to move, one to refactor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactoring of stringSize has been restored, the problem of 'delete & add' has been resolved
0395293 to
6cc34be
Compare
|
@wenshao Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information. |
6cc34be to
70bf229
Compare
|
@wenshao Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information. |
70bf229 to
9bccc89
Compare
|
@wenshao Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information. |
9bccc89 to
27174f4
Compare
|
@wenshao Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information. |
|
Running some additional testing. This mostly looks fine. One issue is that you're swapping the byte-order in I also would like to see performance numbers of the byte order swap evaluated in isolation. I suspect the real effect is small and might be due to JIT noise rather than a real effect, and that this swap got rushed in without solid evidence that it helps. If there's no significant performance difference I would prefer if we kept |
Just a datapoint but when I test implementing |
I prefer to use little endian, most environments are little endian. Changes to HexDigit will have to wait until #PR 14745 is merged. |
|
Please update this PR title and description to indicate this refactoring to move to jdk.internal.util. |
The title has been updated, please help update the title of JIRA |
The description needs an update too. |
|
I have updated the JBS bug title and explicitly stated the actions in this patch:
|
The description has also been updated |
I don't have a very strong opinion except that we should be consistent across these related implementations. If you could either include |
|
|
@wenshao 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: 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 12 new commits pushed to the
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 (@RogerRiggs, @cl4es) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
RogerRiggs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates.
|
/integrate |
|
/sponsor |
|
Going to push as commit e084516.
Your commit was automatically rebased without conflicts. |
java.util.DecimalDigits::DIGITS and java.lang.StringLatin1.PACKED_DIGITS are duplicates, We need to move java.util.Digits/OctalDigits/DecimalDigits/HexDigits to the jdk.internal.util package, and modify these classes to public class, so that classes in other packages can also access them.
DecimalDigits::DIGITS provides a new digitPair static method, used to replace StringLatin1.PACKED_DIGITS access.
In order to be consistent with the original StringLatin1.PACKED_DIGITS, OctalDigits::DIGITS and DecimalDigits::DIGITS are modified to little-endian. HexDigits::DIGITS will also be modified after PR #14745 is merged.
These changes will be used by PR #15658 #15555
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/15651/head:pull/15651$ git checkout pull/15651Update a local copy of the PR:
$ git checkout pull/15651$ git pull https://git.openjdk.org/jdk.git pull/15651/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 15651View PR using the GUI difftool:
$ git pr show -t 15651Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/15651.diff
Webrev
Link to Webrev Comment