-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
8342650: Move getChars to DecimalDigits #21593
Conversation
👋 Welcome back swen! A progress list of the required criteria for merging this PR into |
@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 72 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. ➡️ To integrate this PR with the above commit message to the |
Webrevs
|
char[] coeff; | ||
int offset; // offset is the starting index for coeff array | ||
// Get the significand as an absolute value | ||
if (intCompact != INFLATED) { | ||
offset = sbHelper.putIntCompact(Math.abs(intCompact)); | ||
coeff = sbHelper.getCompactCharArray(); | ||
coeff = new char[19]; |
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.
A possibility here would be to change coeff
to be a String. The “else” branch already creates a string and has to additionally create a char array from it. If this is the only place where the DecimalDigits.getChars(… char[])
is used, some extra code duplication could be removed.
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.
If this PR can be merged, we can continue to complete PR #16006, which can also remove DecimalDigits.getChars(… char[])
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.
/label remove security |
@wenshao |
src/java.base/share/classes/jdk/internal/util/DecimalDigits.java
Outdated
Show resolved
Hide resolved
public static void putPairLatin1(byte[] buf, int charPos, int v) { | ||
int packed = DIGITS[v]; | ||
putCharLatin1(buf, charPos, packed & 0xFF); | ||
putCharLatin1(buf, charPos + 1, packed >> 8); |
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.
Does merge store work here? Original code in StringLatin1 uses direct array writes, not sure about this version.
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.
Tests show that the current version of MergeStore also works
[TraceMergeStores] found:
0--> 114 StoreB === 80 91 113 95 [[ 18 ]] @byte[int:>=0] (java/lang/Cloneable,java/io/Serializable):exact+any *, idx=5; unsafe Memory: @byte[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=5; !jvms: DecimalDigits::putCharLatin1 @ bci:12 (line 430) DecimalDigits::putPairLatin1 @ bci:24 (line 413)
1--> 91 StoreB === 80 7 90 51 [[ 114 ]] @byte[int:>=0] (java/lang/Cloneable,java/io/Serializable):exact+any *, idx=5; unsafe Memory: @byte[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=5; !jvms: DecimalDigits::putCharLatin1 @ bci:12 (line 430) DecimalDigits::putPairLatin1 @ bci:13 (line 412)
[TraceMergeStores] truncated:
0--> 114 StoreB === 80 91 113 95 [[ 18 ]] @byte[int:>=0] (java/lang/Cloneable,java/io/Serializable):exact+any *, idx=5; unsafe Memory: @byte[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=5; !jvms: DecimalDigits::putCharLatin1 @ bci:12 (line 430) DecimalDigits::putPairLatin1 @ bci:24 (line 413)
1--> 91 StoreB === 80 7 90 51 [[ 114 ]] @byte[int:>=0] (java/lang/Cloneable,java/io/Serializable):exact+any *, idx=5; unsafe Memory: @byte[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=5; !jvms: DecimalDigits::putCharLatin1 @ bci:12 (line 430) DecimalDigits::putPairLatin1 @ bci:13 (line 412)
[TraceMergeStores]: Replace
91 StoreB === 80 7 90 51 [[ 114 ]] @byte[int:>=0] (java/lang/Cloneable,java/io/Serializable):exact+any *, idx=5; unsafe Memory: @byte[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=5; !jvms: DecimalDigits::putCharLatin1 @ bci:12 (line 430) DecimalDigits::putPairLatin1 @ bci:13 (line 412)
114 StoreB === 80 91 113 95 [[ 18 ]] @byte[int:>=0] (java/lang/Cloneable,java/io/Serializable):exact+any *, idx=5; unsafe Memory: @byte[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=5; !jvms: DecimalDigits::putCharLatin1 @ bci:12 (line 430) DecimalDigits::putPairLatin1 @ bci:24 (line 413)
[TraceMergeStores]: with
51 LoadS === 33 7 49 [[ 91 85 95 70 118 ]] @short[int:>=0] (java/lang/Cloneable,java/io/Serializable):exact+any *, idx=4; #short !jvms: DecimalDigits::putPairLatin1 @ bci:4 (line 411)
118 StoreC === 80 7 90 51 [[ ]] @byte[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=5; mismatched Memory: @byte[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=5;
[TraceMergeStores] MergePrimitiveStores::run: 118 StoreC === 80 7 90 51 [[ 18 ]] @byte[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=5; mismatched Memory: @byte[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=5; !orig=[114] !jvms: DecimalDigits::putCharLatin1 @ bci:12 (line 430) DecimalDigits::putPairLatin1 @ bci:24 (line 413)
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.
Looks good. Tier 1-3 tests pass.
This PR will improve the performance of Integer/Long.toString and StringBuilder.append(int/long) scenarios. This is because Unsafe.putByte is used to eliminate array bounds checks, and of course this elimination is safe. In previous versions, in Integer/Long.toString and StringBuilder.append(int/long) scenarios, |
/integrate |
Going to push as commit e1d684c.
Your commit was automatically rebased without conflicts. |
This caused a regression, see JDK-8343925. You might want to consider a quick backout. |
I see Shaojin has created an issue to exclude the test but I think better to back this out quickly. |
I think the fix is easy: Unsafe calls are using a bad offset which should be cast to long. Will submit a PR, but since I cannot reproduce the original issue locally or on internal CI, need others review first. |
I submitted a rollback PR #22012. I can't reproduce the problem on a MacBook M1 Max, but I agree that more testing is needed, so let's roll it back first. |
/open |
@wenshao The command |
Move getChars methods of StringLatin1 and StringUTF16 to DecimalDigits to reduce duplication
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/21593/head:pull/21593
$ git checkout pull/21593
Update a local copy of the PR:
$ git checkout pull/21593
$ git pull https://git.openjdk.org/jdk.git pull/21593/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 21593
View PR using the GUI difftool:
$ git pr show -t 21593
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/21593.diff
Using Webrev
Link to Webrev Comment