-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8339576: Speed up raw bytecode processing in ClassFile API #20863
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
… for escape analysis
/contributor add swen |
👋 Welcome back liach! A progress list of the required criteria for merging this PR into |
@liach 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 24 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 |
@liach |
src/java.base/share/classes/jdk/internal/classfile/impl/RawBytecodeHelper.java
Outdated
Show resolved
Hide resolved
Webrevs
|
* {@link #ILLEGAL}, so we can perform value access without bound checks if | ||
* we have a valid opcode. | ||
*/ | ||
public boolean next() { |
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 C1, this cannot be inlined. See if you need to add ForceInline
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 don't think we should worry too much about making C1 inline more aggressively.
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.
C2 needs 10000 calls to inline this method, so wenshao is worried. However, this method call is almost always followed by a huge switch to handle different opcode, so I doubt how much of a difference inlining brings.
But wenshao discovered that this method has too many field gets; I should indeed convert them to local variable access if possible.
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.
Yes, things like storing endBci()
to a local variable can be great if it both reduces code size and improves interpreter/C1 speed - but don't over-do it as it's likely never-ending work for a kind of optimizations leyden might make pointless.
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.
It is not necessary to use RawBytecodeHelper in the StackMapGenerator#detectFrameOffsets method. It may be better to operate directly on the byte[] bytecode
.
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.
We could have just tracked the offsets when labels from DirectCodeBuilder are bound; we can explore such a fix in another patch.
src/java.base/share/classes/jdk/internal/classfile/impl/RawBytecodeHelper.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.
From the Class-File API perspective the changes look good to me.
8339576: Speed up raw bytecode processing in ClassFile API
Thanks for the reviews! |
Going to push as commit a1eebbd.
Your commit was automatically rebased without conflicts. |
Currently, raw bytecode access goes through multiple wrappers, include one from ClassFile API and another ByteBuffer for merged big endian value reads. We can merge the ByteBuffer =into the ClassFile API one (RawBytecodeHelper) for safer access.
RawBytecodeHelper is also restructured so we avoid allocating it on the heap. Large
rawNext
method is now also inlined into the smallernext
method.Current benchmark results show this significantly speeds up
jdk.classfile.Write
and some degree of speedup for simple lambda startup. The impact on general application workloads is minuscule, but this doesn't seem to bring any regression.Pinging @wenshao and @cl4es for review.
Progress
Issue
Reviewers
Contributors
<swen@openjdk.org>
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/20863/head:pull/20863
$ git checkout pull/20863
Update a local copy of the PR:
$ git checkout pull/20863
$ git pull https://git.openjdk.org/jdk.git pull/20863/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 20863
View PR using the GUI difftool:
$ git pr show -t 20863
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/20863.diff
Webrev
Link to Webrev Comment