-
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
8329750: Change Universe functions to return more specific Klass* types #18652
Conversation
👋 Welcome back stefank! A progress list of the required criteria for merging this PR into |
@stefank 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 22 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.
Yes, this looks really good!
k = Universe::typeArrayKlass(t); | ||
k = TypeArrayKlass::cast(k)->array_klass(ndims, CHECK_NULL); | ||
k = k->array_klass(ndims, CHECK_NULL); |
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 assume the cast was an attempt to de-virtualize the array_klass() call, so it is better not to use Klass* here.
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.
My experience is that these type of casts doesn't make the compiler devirtualize the calls. I tried it now and verified that both with and without the cast we still get the virtual call. You typically need to tell the compiler what function it should be using. (I played around a lot with this when writing the devirtualization layer for the oop_iterate/OopIterateClosure code.)
I tested writing the code above as TypeArrayKlass::cast(k)->TypeArrayKlass::array_klass(ndims, CHECK_NULL)
and that gets rid of the virtual call. However, the compiler still can't inline the code ArrayKlass::array_klass code because it is inside a .cpp file and not an .inline.hpp, so this results in a direct call instead of inlined code.
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.
OK, I guess the compiler needs to be conservative in case TypeArrayKlass has a subclass.
Dean's suggestion Co-authored-by: Dean Long <17332032+dean-long@users.noreply.github.com>
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 change just makes it confusing and doesn't add anything. If array_klass changed more, then not sure what to do with these lines.
k = TypeArrayKlass::cast(k)->array_klass(ndims, CHECK_NULL); | ||
TypeArrayKlass* tak = Universe::typeArrayKlass(t); | ||
k = tak->array_klass(ndims, CHECK_NULL); | ||
k = k->array_klass(ndims, CHECK_NULL); |
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 puzzling. Why are there two array_klass calls now? Add short comments to explain.
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 sort of see now but am getting squint lines. It's not important for performance to eliminate a virtual call here.
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.
Hmm. Having two array_klass
calls were not intentional. I accepted Dean's suggestion in the GitHub UI, but that didn't remove the old array_klass
. I think I'll revert that change given that it is not important to devirtualize this.
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.
Oh good because I was going to need a lot more coffee to understand why there was a second call. Thanks.
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.
Why devirtualize elsehwere but not here? Maybe it's not a big deal.
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.
Or to put it another way, what's the advantage of using TypeArrayKlass* tak
in similar situations below?
This reverts commit d36f650.
k = TypeArrayKlass::cast(k)->array_klass(ndims, CHECK_NULL); | ||
TypeArrayKlass* tak = Universe::typeArrayKlass(t); | ||
k = tak->array_klass(ndims, CHECK_NULL); | ||
k = k->array_klass(ndims, CHECK_NULL); |
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.
Oh good because I was going to need a lot more coffee to understand why there was a second call. Thanks.
Thanks for the reviews! Dean, I reverted the suggestion to go with the typed TypeArrayKlass given that it had no visible effects on inlining. If you still want it I can fix it in separate commit. |
Going to push as commit 492b954.
Your commit was automatically rebased without conflicts. |
If there's no benefit, then it would just be for consistency with the other changes. It's not a big deal though. |
We have various functions in Universe that returns Klass* where they could be returning TypeArrayKlass* and ObjArrayKlass* instead. If we change these functions we could get rid of some casts in the code. Does this seem like a reasonable change?
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/18652/head:pull/18652
$ git checkout pull/18652
Update a local copy of the PR:
$ git checkout pull/18652
$ git pull https://git.openjdk.org/jdk.git pull/18652/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 18652
View PR using the GUI difftool:
$ git pr show -t 18652
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/18652.diff
Webrev
Link to Webrev Comment