-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8346567: Make Class.getModifiers() non-native #22652
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
|
👋 Welcome back coleenp! A progress list of the required criteria for merging this PR into |
|
@coleenp 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 98 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 |
|
@coleenp The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
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.
The change to java.lang.Class looks good.
|
@coleenp this pull request can not be integrated into git checkout modifiers2
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 |
|
/assign @iwanowww |
|
Looking at #23396, we might need to filter this field too. |
|
@coleenp Unknown command |
Yes, I agree. This patch is a follow on to that one, so I'll add it to the same places when that one is merged in here. |
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.
Overall looks good to me. Please ask @iwanowww to review compiler changes.
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.
Thank you for the detailed comments.
| writer->write(mark_symbol(klass, leakp)); | ||
| writer->write(package_id(klass, leakp)); | ||
| writer->write(klass->modifier_flags()); | ||
| writer->write(klass->compute_modifier_flags()); |
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 was trying not to add a Klass::modifier_flags function, but now I have.
| print(" unloaded='1'"); | ||
| } else { | ||
| print(" flags='%d'", klass->modifier_flags()); | ||
| print(" flags='%d'", klass->access_flags()); |
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.
Okay, I wanted to remove the one use of ciKlass::modifier_flags() and the field with this change, but I'll add it back since I added a Klass::modifier_flags() function.
| @Benchmark | ||
| public int getAppArrayModifiers() { | ||
| return clazzArray.getClass().getModifiers(); | ||
| } |
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. Yes it does.
Co-authored-by: Dean Long <17332032+dean-long@users.noreply.github.com>
…ifier_flags, add benchmark.
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. (Except a left-over ??? in a comment.)
I very much like this cleanup. Migrating from Klass to Class simplifies compiler logic since there's no need to care about primitives at runtime anymore.
Speaking of missing optimization opportunities (demonstrated by one microbenchmark), it looks like a corner case and can be addressed later.
|
Thank you Vladimir for encouraging me to continue this change. I removed the ??? and hid the modifiers field for reflection as suggested in this PR. |
|
I added some code to hide the Class.modifiers field and fixed the JVMCI test. Please re-review. Also @iwanowww I think the intrinsic for isInterface can be removed and just be Java code like: |
Good point. Moreover, it seems most of intrinsics on Class queries can be replaced with a flag bit check on the mirror. (Do we have 16 unused bits in Class::modifiers after this change?) |
Yes, I think so. isArray and isPrimitive definitely. We could first change the modifiers field to "char" because that's its size and then have a booleans for each of these. |
|
Making |
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.
No more comments from me.
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.
JVMCI change looks good to me
|
Thank you for the reviews Yudi, Alan, Chen, Vladimir and Dean, and the help and comments with the various pieces of this. |
|
Going to push as commit c9cadbd.
Your commit was automatically rebased without conflicts. |
The Class.getModifiers() method is implemented as a native method in java.lang.Class to access a field that we've calculated when creating the mirror. The field is final after that point. The VM doesn't need it anymore, so there's no real need for the jdk code to call into the VM to get it. This moves the field to Java and removes the intrinsic code. I promoted the compute_modifiers() functions to return int since that's how java.lang.Class uses the value. It should really be an unsigned short though.
There's a couple of JMH benchmarks added with this change. One does show that for array classes for non-bootstrap class loader, this results in one extra load which in a long loop of just that, is observable. I don't think this is real life code. The other benchmarks added show no regression.
Tested with tier1-8.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/22652/head:pull/22652$ git checkout pull/22652Update a local copy of the PR:
$ git checkout pull/22652$ git pull https://git.openjdk.org/jdk.git pull/22652/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 22652View PR using the GUI difftool:
$ git pr show -t 22652Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/22652.diff
Using Webrev
Link to Webrev Comment