Skip to content

Conversation

wenshao
Copy link
Contributor

@wenshao wenshao commented Aug 25, 2024

optimize the construction of MethodType and MethodTypeDesc to reduce memory allocate


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-8338936: StringConcatFactory optimize the construction of MethodType and MethodTypeDesc (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 20704

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 25, 2024

👋 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 Aug 25, 2024

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

8338936: StringConcatFactory optimize the construction of MethodType and MethodTypeDesc

Reviewed-by: redestad, liach

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

  • 0c744ea: 8338928: Update SwingSet2 "About" image to reference openjdk.org
  • a15af69: 8338538: [JVMCI] Allow HotSpotJVMCIRuntime#getJObjectValue to be called by a HotSpot CompileBroker compiler thread
  • 3f00da8: 8338906: Avoid passing EnumDescs and extra classes to type switch methods that don't use them
  • e63418e: 8338979: Avoid bootstrapped switches in the classfile API
  • 20d8f58: 8331671: Implement JEP 472: Prepare to Restrict the Use of JNI
  • ce83f6a: 8338844: C2: remove useless code in PhaseIdealLoop::place_outside_loop() after 8335709
  • 0c14579: 8336830: C2: assert(get_loop(lca)->_nest < n_loop->_nest || lca->in(0)->is_NeverBranch()) failed: must not be moved into inner loop

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
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 (@cl4es, @liach) 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
Copy link

openjdk bot commented Aug 25, 2024

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

  • core-libs

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 core-libs core-libs-dev@openjdk.org label Aug 25, 2024
Comment on lines 1199 to 1200
* Construct the MethodType of the coder method, if there are no parameters it may be UTF16, return null.
* The first parameter is the initialized coder, Only parameter types that can be UTF16 are added.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Construct the MethodType of the coder method, if there are no parameters it may be UTF16, return null.
* The first parameter is the initialized coder, Only parameter types that can be UTF16 are added.
* Construct the MethodType of the coder method. The first parameter is the initialized coder.
* Only parameter types which can be UTF16 are added. Returns null if no such parameter exists.

Copy link
Member

Choose a reason for hiding this comment

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

Something to consider (for a follow up) is to not add the initial coder as an argument but test that in the outer method: No point calling the coder method if we already know that we're UTF-16.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If initCoder is UTF16, the coder method does not need to be generated. This is an optimization and may be a separate PR. Of course, if you agree, I can also put it here.

Copy link
Member

Choose a reason for hiding this comment

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

Right, if initCoder is always UTF16 (-XX:-CompactStrings) then we never need the coder method. Nor really if any of the constants have UTF-16 chars, but in those cases it might be more appropriate to inject the derived value and have a runtime test - as long as it get optimized away. Otherwise we might need to generate two different classes per shape.

Copy link
Member

Choose a reason for hiding this comment

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

If we're to pre-generate code for concats when linking JDK images (something that might be a big help for startup) then it'd be nice to be agnostic regarding CompactStrings

…ry.java

Co-authored-by: Claes Redestad <claes.redestad@oracle.com>
@wenshao wenshao changed the title StringConcatFactory optimize the construction of MethodType and MethodTypeDesc 8338936: StringConcatFactory optimize the construction of MethodType and MethodTypeDesc Aug 25, 2024
@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 25, 2024
@mlbridge
Copy link

mlbridge bot commented Aug 25, 2024

Webrevs

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 25, 2024
@liach
Copy link
Member

liach commented Aug 25, 2024

@wenshao Can you change all MethodTypeDesc.of and the CONSTRUCTOR_METHOD_TYPE static final fields in inlined strategy to be optimized too?

@wenshao
Copy link
Contributor Author

wenshao commented Aug 25, 2024

@wenshao Can you change all MethodTypeDesc.of and the CONSTRUCTOR_METHOD_TYPE static final fields in inlined strategy to be optimized too?

CONSTRUCTOR_METHOD_TYPE The current strategy is optimization:

MethodType CONSTRUCTOR_METHOD_TYPE = MethodType.methodType(void.class, String[].class);

-> static MethodType methodType(Class<?> rtype, Class<?> ptype0) {
-> makeImpl(rtype, new Class<?>[]{ ptype0 }, true);

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Aug 25, 2024
@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 25, 2024
@wenshao
Copy link
Contributor Author

wenshao commented Aug 26, 2024

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Aug 26, 2024
@openjdk
Copy link

openjdk bot commented Aug 26, 2024

@wenshao
Your change (at version 727ec21) is now ready to be sponsored by a Committer.

@liach
Copy link
Member

liach commented Aug 26, 2024

/sponsor

Thanks!

@openjdk
Copy link

openjdk bot commented Aug 26, 2024

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

  • 0c744ea: 8338928: Update SwingSet2 "About" image to reference openjdk.org
  • a15af69: 8338538: [JVMCI] Allow HotSpotJVMCIRuntime#getJObjectValue to be called by a HotSpot CompileBroker compiler thread
  • 3f00da8: 8338906: Avoid passing EnumDescs and extra classes to type switch methods that don't use them
  • e63418e: 8338979: Avoid bootstrapped switches in the classfile API
  • 20d8f58: 8331671: Implement JEP 472: Prepare to Restrict the Use of JNI
  • ce83f6a: 8338844: C2: remove useless code in PhaseIdealLoop::place_outside_loop() after 8335709
  • 0c14579: 8336830: C2: assert(get_loop(lca)->_nest < n_loop->_nest || lca->in(0)->is_NeverBranch()) failed: must not be moved into inner loop

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Aug 26, 2024

@liach @wenshao Pushed as commit 5ecbecf.

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

Successfully merging this pull request may close these issues.

3 participants