Skip to content

8339217: Optimize ClassFile API loadConstant#20761

Closed
wenshao wants to merge 7 commits into
openjdk:masterfrom
wenshao:optim_classfile_loadconstant_2020408
Closed

8339217: Optimize ClassFile API loadConstant#20761
wenshao wants to merge 7 commits into
openjdk:masterfrom
wenshao:optim_classfile_loadconstant_2020408

Conversation

@wenshao

@wenshao wenshao commented Aug 29, 2024

Copy link
Copy Markdown
Contributor

This is a large method. By splitting it into multiple methods with the same name, the caller can automatically select based on the different types of parameters, avoiding this large call that cannot be inlined, which can also improve startup performance.

  • current
CodeBuilder {
    default CodeBuilder loadConstant(ConstantDesc value) { ... }
}

java.lang.classfile.CodeBuilder::loadConstant (465 bytes)   failed to inline: callee is too large

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Change requires CSR request JDK-8339256 to be approved
  • Commit message must refer to an issue

Issues

  • JDK-8339217: Optimize ClassFile API loadConstant (Enhancement - P4)
  • JDK-8339256: Optimize ClassFile API loadConstant (CSR)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 20761

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper

bridgekeeper Bot commented Aug 29, 2024

Copy link
Copy Markdown

👋 Welcome back swen! 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 commented Aug 29, 2024

Copy link
Copy Markdown

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

8339217: Optimize ClassFile API loadConstant

Reviewed-by: liach, redestad, asotona

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:

  • 08b2561: 8339781: Better use of Javadoc tags in javax.lang.model
  • 64275e6: 8340092: [Linux] containers/systemd/SystemdMemoryAwarenessTest.java failing on some systems
  • 5cffddc: 8338471: Assert deleted methods not returned by CallInfo
  • 40fba14: 8340232: Optimize DataInputStream::readUTF
  • ab81197: 8339198: Remove tag field from AbstractPoolEntry
  • 90d3a64: 8340537: Typo in javadoc of java.util.jar.JarFile
  • e087ede: 8340269: [s390x] TestLargeStub.java failure after 8338123
  • 9bcde4f: 8338658: New Object to ObjectMonitor mapping: s390x implementation
  • ae63aaa: 8340540: Problemlist DcmdMBeanPermissionsTest.java and SystemDumpMapTest.java
  • fe80618: 8339972: Make a few fields in SortingFocusTraversalPolicy static
  • ... and 95 more: https://git.openjdk.org/jdk/compare/37bf589ec087c80851abb9d35910f09850cea9f6...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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk

openjdk Bot commented Aug 29, 2024

Copy link
Copy Markdown

@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 29, 2024

@liach liach left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The primitive overloads of loadConstant avoid extraneous boxing. 👍

Comment thread src/java.base/share/classes/java/lang/classfile/CodeBuilder.java Outdated
Comment thread src/java.base/share/classes/java/lang/classfile/CodeBuilder.java Outdated
@wenshao wenshao changed the title Optimize ClassFile API loadConstant 8339217: Optimize ClassFile API loadConstant Aug 29, 2024
@openjdk openjdk Bot added the rfr Pull request is ready for review label Aug 29, 2024
@mlbridge

mlbridge Bot commented Aug 29, 2024

Copy link
Copy Markdown

Webrevs

@asotona

asotona commented Aug 29, 2024

Copy link
Copy Markdown
Member

/csr needed

@openjdk openjdk Bot added the csr Pull request needs approved CSR before integration label Aug 29, 2024
@openjdk

openjdk Bot commented Aug 29, 2024

Copy link
Copy Markdown

@asotona has indicated that a compatibility and specification (CSR) request is needed for this pull request.

@wenshao please create a CSR request for issue JDK-8339217 with the correct fix version. This pull request cannot be integrated until the CSR request is approved.

Comment thread src/java.base/share/classes/java/lang/classfile/CodeBuilder.java Outdated
Comment thread src/java.base/share/classes/java/lang/classfile/CodeBuilder.java
Comment thread src/java.base/share/classes/java/lang/classfile/CodeBuilder.java Outdated
@openjdk

openjdk Bot commented Aug 29, 2024

Copy link
Copy Markdown

@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 optim_classfile_loadconstant_2020408
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 Aug 29, 2024
@liach

liach commented Aug 29, 2024

Copy link
Copy Markdown
Member

I have updated the CSR with your latest specs.

…oadconstant_2020408

# Conflicts:
#	src/java.base/share/classes/java/lang/classfile/CodeBuilder.java
@openjdk openjdk Bot removed the merge-conflict Pull request has merge conflict with target branch label Aug 29, 2024
@wenshao wenshao requested a review from liach September 5, 2024 22:43
…oadconstant_2020408

# Conflicts:
#	src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java


/**
* Generate an instruction pushing a constant int value onto the operand stack.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@wenshao After offline discussion with @kevinb9n, we think we should add another sentence in the API specification:

This is identical to {@link #loadConstant(ConstantDesc) loadConstant(Integer.valueOf(value))}.

And repeat this for long, float, and double versions (with Long.valueOf(value) etc.)
This avoids confusions around this API.

@liach liach left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for this improvement.

@cl4es cl4es left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@asotona asotona left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me.

@openjdk openjdk Bot added the ready Pull request is ready to be integrated label Sep 20, 2024
@openjdk openjdk Bot removed the csr Pull request needs approved CSR before integration label Sep 20, 2024
@wenshao

wenshao commented Sep 21, 2024

Copy link
Copy Markdown
Contributor Author

/integrate

@openjdk

openjdk Bot commented Sep 21, 2024

Copy link
Copy Markdown

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

  • 08b2561: 8339781: Better use of Javadoc tags in javax.lang.model
  • 64275e6: 8340092: [Linux] containers/systemd/SystemdMemoryAwarenessTest.java failing on some systems
  • 5cffddc: 8338471: Assert deleted methods not returned by CallInfo
  • 40fba14: 8340232: Optimize DataInputStream::readUTF
  • ab81197: 8339198: Remove tag field from AbstractPoolEntry
  • 90d3a64: 8340537: Typo in javadoc of java.util.jar.JarFile
  • e087ede: 8340269: [s390x] TestLargeStub.java failure after 8338123
  • 9bcde4f: 8338658: New Object to ObjectMonitor mapping: s390x implementation
  • ae63aaa: 8340540: Problemlist DcmdMBeanPermissionsTest.java and SystemDumpMapTest.java
  • fe80618: 8339972: Make a few fields in SortingFocusTraversalPolicy static
  • ... and 95 more: https://git.openjdk.org/jdk/compare/37bf589ec087c80851abb9d35910f09850cea9f6...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk Bot added the integrated Pull request has been integrated label Sep 21, 2024
@openjdk openjdk Bot closed this Sep 21, 2024
@openjdk openjdk Bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Sep 21, 2024
@openjdk

openjdk Bot commented Sep 21, 2024

Copy link
Copy Markdown

@wenshao Pushed as commit 2461263.

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

@liach

liach commented Sep 21, 2024

Copy link
Copy Markdown
Member

The CSR asks to use equivalent instead of identical in the specs; I should fix that in a subsequent general ClassFile API docs cleanup.

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.

4 participants