Skip to content

Conversation

@wenshao
Copy link
Contributor

@wenshao wenshao commented Sep 13, 2023

  1. Reduce duplicate stringSize code
  2. Move java.lang.StringLatin1.getChars to jdk.internal.util.DecimalDigits::getCharLatin1,not only java.lang, other packages also need to use this method

Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 2 Reviewers)

Integration blocker

 ⚠️ Title mismatch between PR and JBS for issue JDK-8316150

Issue

  • JDK-8316150: Refactor getChars and stringSize (Enhancement - P4) ⚠️ Title mismatch between PR and JBS.

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 15699

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 13, 2023

👋 Welcome back wenshao! 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 Sep 13, 2023

@wenshao The following labels will be automatically applied to this pull request:

  • core-libs
  • hotspot-compiler
  • i18n

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@wenshao wenshao changed the title Refactor get chars and string size 8316150: Refactor get chars and string size Sep 13, 2023
@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 13, 2023
@mlbridge
Copy link

mlbridge bot commented Sep 13, 2023

@wenshao
Copy link
Contributor Author

wenshao commented Sep 13, 2023

@cl4es can you help me to review this PR?

@AlanBateman
Copy link
Contributor

/reviewers 2

@openjdk
Copy link

openjdk bot commented Sep 13, 2023

@AlanBateman
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

@wenshao
Copy link
Contributor Author

wenshao commented Sep 16, 2023

/label remove i18n

@openjdk
Copy link

openjdk bot commented Sep 16, 2023

@wenshao
The i18n label was successfully removed.

@wenshao
Copy link
Contributor Author

wenshao commented Sep 16, 2023

/label remove hotspot-compiler

@openjdk
Copy link

openjdk bot commented Sep 16, 2023

@wenshao
The hotspot-compiler label was successfully removed.

@RogerRiggs
Copy link
Contributor

There's a lot of duplication exposed here between the digits method and the getCharsLatin1 method that should be resolved.
Can the callers of getCharsLatin1 be converted to use digits?

We also should keep HexDigits and OctalDigits classes have a consistent API and functionality.

@openjdk
Copy link

openjdk bot commented Sep 21, 2023

@wenshao this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout refactor_get_chars_and_string_size
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

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Sep 21, 2023
@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label Sep 22, 2023
…vides two implementations: prependLatin1 and prependUTF16
…vides two implementations: prependLatin1 and prependUTF16 [v2]
@liach
Copy link
Member

liach commented Sep 23, 2023

Since the current MethodHandle-based char putter can only put 1-byte at once, have you considered something like this:

// A replacement for setter MethodHandle, or VarHandle, to accept multiple value types
public interface DigitConsumer {
    void putChar(byte[] array, int index, byte value);
    // put 2 byte-sized chars at once, encoded little endian
    void putChar2(byte[] array, int index, short value);
    // you can add putChar4, putChar8, etc. if you need
}

and StringConcatHelper.selectPutChar will return a DigitConsumer instead of a MethodHandle.

Currently, you are allocating a new byte array for every number in the format, which I deem very inefficient.

@wenshao
Copy link
Contributor Author

wenshao commented Sep 23, 2023

Since the current MethodHandle-based char putter can only put 1-byte at once, have you considered something like this:

// A replacement for setter MethodHandle, or VarHandle, to accept multiple value types
public interface DigitConsumer {
    void putChar(byte[] array, int index, byte value);
    // put 2 byte-sized chars at once, encoded little endian
    void putChar2(byte[] array, int index, short value);
    // you can add putChar4, putChar8, etc. if you need
}

and StringConcatHelper.selectPutChar will return a DigitConsumer instead of a MethodHandle.

Currently, you are allocating a new byte array for every number in the format, which I deem very inefficient.

Code based on MethodHandler is difficult to maintain and debug. We should remove the use of MethodHandle in FormatItem.

Copy link

@ExE-Boss ExE-Boss left a comment

Choose a reason for hiding this comment

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

The throws Throwable declarations are no longer needed, as the prependers no longer depend on MethodHandles.

@RogerRiggs
Copy link
Contributor

You could benefit from compiling and testing in your repo before committing; it would cut down on the spurious changes.
and/or (before pushing) squash the intermediate commits to a single commit with a salient comment.

@wenshao
Copy link
Contributor Author

wenshao commented Sep 28, 2023

There are too many changes that need to be made to reduce the duplication of code in the digits method and the getCharsLatin1.

Can we temporarily allow duplicate code for digits and getCharLatin1? Revert changes related to FormatItem. After this PR is completed, submit a new PR to change FormatItem and reduce duplicate code.

@wenshao
Copy link
Contributor Author

wenshao commented Sep 30, 2023

There's a lot of duplication exposed here between the digits method and the getCharsLatin1 method that should be resolved. Can the callers of getCharsLatin1 be converted to use digits?

We also should keep HexDigits and OctalDigits classes have a consistent API and functionality.

Changes related to FormatItem have been reverted because too many changes were made. The duplicate code of getChars and digits will be solved with another PR later.

@AlanBateman
Copy link
Contributor

/reviewers 2 reviewer

@openjdk
Copy link

openjdk bot commented Oct 16, 2023

@AlanBateman
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 2 Reviewers).

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 13, 2023

@wenshao This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 12, 2023

@wenshao This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the /open pull request command.

@bridgekeeper bridgekeeper bot closed this Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core-libs [email protected] rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

8 participants