-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
8331187: Optimize MethodTypeDesc and ClassDesc.ofDescriptor for primitive types #18971
Conversation
👋 Welcome back redestad! A progress list of the required criteria for merging this PR into |
@cl4es 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 18 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 |
Webrevs
|
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.
Looks like your MethodTypeDescFactories
benchmark is missing form the PR?
Does removing the explicit null checks make that much difference for performance? They are kind of nice for clarity.
Also, looks like the copyright year still needs to be updated on some of the files.
src/java.base/share/classes/java/lang/constant/MethodTypeDescImpl.java
Outdated
Show resolved
Hide resolved
Pre-existing.
It helps startup at least. The redundant array depth check mattered a bit for peak performance, but not much. I don't have a strong opinion really, just find them a bit superfluous when there's a dereference on the next line.
Fixed, along with using |
Sure, I'm mostly talking about cases where the value is passed to another method. |
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.
LGTM
Primitive class desc sharing should be really helpful, especially considering that they are represented as condy and their |
Ok. We could consider overriding |
/integrate |
Going to push as commit 8bbd725.
Your commit was automatically rebased without conflicts. |
For the |
Hmm, that is unfortunate, yes. |
@@ -376,6 +380,9 @@ public static Wrapper forBasicType(Class<?> type) { | |||
} | |||
} | |||
|
|||
/** A nominal descriptor of the primitive type */ | |||
public ClassDesc primitiveClassDescriptor() { return primitiveTypeDesc; } |
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.
As this method is named as primitiveClassDescriptor
, I expect this should either throw or return null for OBJECT
and even VOID
wrapper. Or should be named "classDescriptor".
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.
While I agree it may seem non-sensical to define CD_Object
for Object
, there's precedent in that Wrapper.primitiveType
is Object.class
- so for consistency I wired it up the same way. For the usage patterns introduced with this patch we'll never call primitiveClassDescriptor()
on Wrapper.OBJECT
, though - and Wrapper.forPrimitiveType
will throw an IAE
if you try - so we can always revisit this.
void.class
is the primitive type for Void.class
, allowed as a return type and recognized by Wrapper.forPrimitiveType
. There are checks in for example ConstantUtils.parseMethodDescriptor
which disallows void.class
anywhere but as a return type.
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 know it'll never call primitiveClassDescriptor()
besides primitive types. While void.class.isPrimitive()
returns true, void
is not a primitive type and called out explicitly in the spec.
My point is about the behavior does not match the method name. It may be better to rename it to classDescriptor
instead. It's okay to clean up in your other performance fix (perhaps #18945).
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.
Updated #18945, will try ignoring the pre-existing Wrapper.primitiveType
inconsistencies.
This PR makes ClassDesc.ofDescriptor return the shared constant for primitive descriptor strings ("I" etc..), and leverages this further by refactoring
MethodTypeDescImpl.ofDescriptor
to avoid the intermediate substring for primitives.Microbenchmarks results look good with expected speedups and allocation reductions any time a primitive is part of the descriptor string, and a non-significant cost otherwise:
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/18971/head:pull/18971
$ git checkout pull/18971
Update a local copy of the PR:
$ git checkout pull/18971
$ git pull https://git.openjdk.org/jdk.git pull/18971/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 18971
View PR using the GUI difftool:
$ git pr show -t 18971
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/18971.diff
Webrev
Link to Webrev Comment