-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8358326: Use oopFactory array allocation #25590
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 13 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.
This looks good to me. I a few suggestions that you could take if you want to.
if (type == T_VOID) { | ||
THROW_NULL(vmSymbols::java_lang_IllegalArgumentException()); | ||
} |
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 first wondering where this came from but I now see that this was duplicated from basic_type_mirror_to_arrayklass
. I wonder if this could could be deduplicated by moving this check into basic_type_mirror_to_basic_type
and then removed from -basic_type_mirror_to_arrayklass
:
static BasicType basic_type_mirror_to_basic_type(oop basic_type_mirror, TRAPS) {
assert(java_lang_Class::is_primitive(basic_type_mirror),
"just checking");
if (type == T_VOID) {
THROW_NULL(vmSymbols::java_lang_IllegalArgumentException());
}
return java_lang_Class::primitive_type(basic_type_mirror);
}
static Klass* basic_type_mirror_to_arrayklass(oop basic_type_mirror, TRAPS) {
BasicType type = basic_type_mirror_to_basic_type(basic_type_mirror, CHECK_NULL);
return Universe::typeArrayKlass(type);
}
And then this code could be a two-liner again:
if (java_lang_Class::is_primitive(element_mirror)) {
BasicType type = basic_type_mirror_to_basic_type(element_mirror, CHECK_NULL);
return oopFactory::new_typeArray(type, length, 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.
Unfortunately the caller to basic_type_mirror_to_basic_type() can legitimately return T_VOID for the caller in reflect_method, so that's why I had to duplicate the exception code. Maybe a future enhancement would be to move these to javaClasses.hpp in java_lang_Class, where it knows all about is_primitive types, and boxing classes, which I guess boxing T_VOID is a thing.
friend class oopFactory; | ||
friend class Deoptimization; |
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 you want you could consider sorting the friend declarations (here and in the other place where you added it)
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.
Do we sort friends? The sorting looks funny since VMStructs is usually at the beginning.
class ObjArrayKlass : public ArrayKlass {
- friend class VMStructs;
+ friend class Deoptimization;
friend class JVMCIVMStructs;
friend class oopFactory;
- friend class Deoptimization;
+ friend class VMStructs;
@@ -78,7 +82,6 @@ class ObjArrayKlass : public ArrayKlass { | |||
static ObjArrayKlass* allocate_objArray_klass(ClassLoaderData* loader_data, | |||
int n, Klass* element_klass, TRAPS); | |||
|
|||
objArrayOop allocate(int length, TRAPS); |
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.
Do you think multi_allocate
will need a better name in the future?
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 thought if changing multi_allocate_instance so that it's clear that it's an instance, but decided to limit this. Maybe this would be helpful but the allocate() function was the most confusing to me, that's why I picked that one.
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.
Thank you for this cleanup.
Thanks for reviewing Stefan and Frederic. |
Going to push as commit eb256de.
Your commit was automatically rebased without conflicts. |
This patch removes cases of direct calls to {type,obj}ArrayKlass->allocate() and calls oopFactory::new_*array instead. It also renames {type,obj}ArrayKlass->allocate functions to allocate_klass and allocate_instance so it's more clear which allocation it's doing and to match InstanceKlass allocate functions, and makes these functions private with friends for Deoptimization and oopFactory. For JEP 401, arrays are being extended to support new formats and attributes and this reduces the call sites.
Tested with tier1-7.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25590/head:pull/25590
$ git checkout pull/25590
Update a local copy of the PR:
$ git checkout pull/25590
$ git pull https://git.openjdk.org/jdk.git pull/25590/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 25590
View PR using the GUI difftool:
$ git pr show -t 25590
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25590.diff
Using Webrev
Link to Webrev Comment