-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -320,9 +320,16 @@ void Reflection::array_set(jvalue* value, arrayOop a, int index, BasicType value | |
| } | ||
| } | ||
|
|
||
|
|
||
| // Conversion | ||
| static BasicType basic_type_mirror_to_basic_type(oop basic_type_mirror) { | ||
| assert(java_lang_Class::is_primitive(basic_type_mirror), | ||
| "just checking"); | ||
| return java_lang_Class::primitive_type(basic_type_mirror); | ||
| } | ||
|
|
||
| static Klass* basic_type_mirror_to_arrayklass(oop basic_type_mirror, TRAPS) { | ||
| assert(java_lang_Class::is_primitive(basic_type_mirror), "just checking"); | ||
| BasicType type = java_lang_Class::primitive_type(basic_type_mirror); | ||
| BasicType type = basic_type_mirror_to_basic_type(basic_type_mirror); | ||
| if (type == T_VOID) { | ||
| THROW_NULL(vmSymbols::java_lang_IllegalArgumentException()); | ||
| } | ||
|
|
@@ -339,8 +346,11 @@ arrayOop Reflection::reflect_new_array(oop element_mirror, jint length, TRAPS) { | |
| THROW_MSG_NULL(vmSymbols::java_lang_NegativeArraySizeException(), err_msg("%d", length)); | ||
| } | ||
| if (java_lang_Class::is_primitive(element_mirror)) { | ||
| Klass* tak = basic_type_mirror_to_arrayklass(element_mirror, CHECK_NULL); | ||
| return TypeArrayKlass::cast(tak)->allocate(length, THREAD); | ||
| BasicType type = basic_type_mirror_to_basic_type(element_mirror); | ||
| if (type == T_VOID) { | ||
| THROW_NULL(vmSymbols::java_lang_IllegalArgumentException()); | ||
| } | ||
|
Comment on lines
+350
to
+352
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 And then this code could be a two-liner again: There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| return oopFactory::new_typeArray(type, length, CHECK_NULL); | ||
| } else { | ||
| Klass* k = java_lang_Class::as_Klass(element_mirror); | ||
| if (k->is_array_klass() && ArrayKlass::cast(k)->dimension() >= MAX_DIM) { | ||
|
|
@@ -907,13 +917,6 @@ static methodHandle resolve_interface_call(InstanceKlass* klass, | |
| return methodHandle(THREAD, info.selected_method()); | ||
| } | ||
|
|
||
| // Conversion | ||
| static BasicType basic_type_mirror_to_basic_type(oop basic_type_mirror) { | ||
| assert(java_lang_Class::is_primitive(basic_type_mirror), | ||
| "just checking"); | ||
| return java_lang_Class::primitive_type(basic_type_mirror); | ||
| } | ||
|
|
||
| // Narrowing of basic types. Used to create correct jvalues for | ||
| // boolean, byte, char and short return return values from interpreter | ||
| // which are returned as ints. Throws 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.
Do you think
multi_allocatewill 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.