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
8274299: Make Method/Constructor/Field accessors @Stable #5694
Conversation
👋 Welcome back plevart! A progress list of the required criteria for merging this PR into |
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.
This looks good, assuming Mandy is OK with extracting and adding to the microbenchmarks from JEP 416
A stray thought is why not most fields in Field
/Method
/Constructor
are final
, as my IDE suggests. I can't find any hotspot code that injects values to these fields. Experimentally changing most fields in Field
to final seem to pass at least all the java/lang/reflect tests. Since this is a trusted package @Stable
should then be pointless.
@plevart 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 116 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 |
Adding to Peter's description - separating this patch from JEP 416 will give some bake time on this change of the existing core reflection implementation. When JEP 416 is integrated, it will switch the new implementation and the changes in |
I'm okay to include these microbenchmarks in this patch. I will merge the change with JEP 416.
See
This reminds to double check [1] and realized that [1] https://github.com/openjdk/jdk/blob/master/src/hotspot/share/ci/ciField.cpp#L219 |
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 good to me. Very nice performance improvement.
One minor comment: I think the change in UnsafeFieldAccessorImpl.java
and UnsafeStaticFieldAccessorImpl.java
isn't necessary since they're final fields. It can be reverted.
This is a good observation. I took another look. The only place to set those fields are in One thing I'm puzzling is why the performance result is better but |
I think for deciding if a field can be treated as constant, Adding java/lang/reflect to the trusted package list seem reasonable, though. |
Gotcha, I misremembered it as-if all packages under java/lang were already considered to be in that list. |
There are two changes in |
I made them final in newly added patch now. So we can either merge this or previous commit if desired. |
Does We lack a microbenchmark for |
I don't think they need special treatment currently. The Method/Constructor/Field instances created by native code and returned via native methods are always the |
Thanks for clarifying it. Okay to keep those changes.
I would suggest to use the previous commit so that this patch focuses on this specific change - making the accessor @stable. We can make the fields final together with adding |
I'm fine with going back to the previous iteration. I'd add |
Good catch. I'll add @stable to select Constructor fields. They are important for optimizing |
1f273e9
to
0298253
Compare
I checked the git history. |
Alternatively, it'd become a non-issue when |
Can you surreptitiously add "java.lang" too (asking for a friend) |
[1] https://github.com/openjdk/jdk/blob/master/src/hotspot/share/ci/ciField.cpp#L219 |
I miss that, that very cool. |
I added Constructor benchmarks in latest commit. Here are the results: https://jmh.morethan.io/?gists=f57a49ce833d5a53a01ce996570c11d2,de4a8a4b7ddc4bec1090d2113d9c50e6 I rest now, waiting for comments. |
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 good.
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.
Excellent, thanks!
/integrate |
Going to push as commit 7ad74d8.
Your commit was automatically rebased without conflicts. |
This patch improves reflective access speed as shown by the included benchmarks:
https://jmh.morethan.io/?gists=902f4b43519c4f96c7abcd14cdc2d27d,ac490481e3001c710d75d6071c10b23a
... and is also a prerequisite to make JEP 416 (Reimplement Core Reflection with Method Handle) perform better in some circumstances.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5694/head:pull/5694
$ git checkout pull/5694
Update a local copy of the PR:
$ git checkout pull/5694
$ git pull https://git.openjdk.java.net/jdk pull/5694/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 5694
View PR using the GUI difftool:
$ git pr show -t 5694
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5694.diff