-
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
8340710: Optimize DirectClassBuilder::build #21118
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 no new commits pushed to the ➡️ To integrate this PR with the above commit message to the |
src/java.base/share/classes/jdk/internal/classfile/impl/BufWriterImpl.java
Outdated
Show resolved
Hide resolved
writeAttribute(buf, e); | ||
int size = list.size(); | ||
buf.writeU2(size); | ||
for (int i = 0; i < size; i++) { |
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.
👍 Manual loop unrolling is good for startup
head.writeInt(ClassFile.MAGIC_NUMBER); | ||
head.writeU2(minorVersion); | ||
head.writeU2(majorVersion); | ||
head.writeLong(((long) ClassFile.MAGIC_NUMBER) << 32 | minorVersion << 16 | majorVersion); |
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.
minorVersion
needs to be cast to a long
first, as otherwise when the MSB is set after the shift, then it’ll overwrite the magic number with all 1s.
head.writeLong(((long) ClassFile.MAGIC_NUMBER) << 32 | minorVersion << 16 | majorVersion); | |
head.writeLong(((long) ClassFile.MAGIC_NUMBER) << 32 | ((long) minorVersion) << 16 | majorVersion); |
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.
For clarity, I think using Integer.toUnsignedLong on the shift result is better
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 minorVersion > 0xFFFF, the result of using Integer.toUnsignedLong will be wrong. I guess this is the reason why the previous version build failed
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.
Should we add a & 0xFFFF
on majorVersion
to defend against majorVersion > 0xFFFF
too?
@@ -94,6 +96,10 @@ public ClassFileImpl context() { | |||
return context; | |||
} | |||
|
|||
void writeMagic(int minorVersion, int majorVersion) { |
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.
Can we call this writeHeader
as this writes both the magic and the 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.
Now, through the local variable constantPool, codeSize < 325 can be achieved without extracting a separate method.
head.writeInt(ClassFile.MAGIC_NUMBER); | ||
head.writeU2(minorVersion); | ||
head.writeU2(majorVersion); | ||
head.writeLong((((long) ClassFile.MAGIC_NUMBER) << 32) | ((minorVersion & 0xFFFFL) << 16) | majorVersion); |
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.
head.writeLong((((long) ClassFile.MAGIC_NUMBER) << 32) | ((minorVersion & 0xFFFFL) << 16) | majorVersion); | |
head.writeLong((((long) ClassFile.MAGIC_NUMBER) << 32) | ((minorVersion & 0xFFFFL) << 16) | (majorVersion & 0xFFFFL)); |
@wenshao this pull request can not be integrated into git checkout optim_classfile_build_202409
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 |
…uild_202409 # Conflicts: # src/java.base/share/classes/jdk/internal/classfile/impl/Util.java
/integrate |
Going to push as commit 2e0554a.
Your commit was automatically rebased without conflicts. |
Do some refactoring so that the code can be inlined by the C1/C2 optimizer.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/21118/head:pull/21118
$ git checkout pull/21118
Update a local copy of the PR:
$ git checkout pull/21118
$ git pull https://git.openjdk.org/jdk.git pull/21118/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 21118
View PR using the GUI difftool:
$ git pr show -t 21118
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/21118.diff
Webrev
Link to Webrev Comment