-
Notifications
You must be signed in to change notification settings - Fork 176
8382226: [lworld] C2: Fix _copyOf/_copyOfRange intrinsic for flat abstract value class arrays #2569
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
base: lworld
Are you sure you want to change the base?
Changes from 3 commits
61240a2
bf89360
b1de11c
e3b4f88
0819467
2868844
da29a68
02fdea6
30400c2
53493bc
20cd921
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 |
|---|---|---|
|
|
@@ -5197,15 +5197,22 @@ bool LibraryCallKit::inline_array_copyOf(bool is_copyOfRange) { | |
| // write barrier. Conservatively, go to slow path. | ||
| // TODO 8251971: Optimize for the case when flat src/dst are later found | ||
| // to not contain oops (i.e., move this check to the macro expansion phase). | ||
| // TODO 8382226: Revisit for flat abstract value class arrays | ||
| BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2(); | ||
| const TypeAryPtr* orig_t = _gvn.type(original)->isa_aryptr(); | ||
| const TypeKlassPtr* tklass = _gvn.type(klass_node)->is_klassptr(); | ||
| bool exclude_flat = UseArrayFlattening && bs->array_copy_requires_gc_barriers(true, T_OBJECT, false, false, BarrierSetC2::Parsing) && | ||
| const bool can_src_be_abstract_flat_value_class_array = orig_t != nullptr && !orig_t->elem()->is_inlinetypeptr() && !orig_t->is_not_flat(); | ||
| const bool can_dest_be_value_class_array = tklass->can_be_inline_array(); | ||
| const bool can_dest_be_abstract_flat_value_class_array = can_dest_be_value_class_array && !tklass->is_not_flat() && tklass->isa_aryklassptr() != nullptr && | ||
| !tklass->is_aryklassptr()->elem()->is_instklassptr()->instance_klass()->is_inlinetype(); | ||
| const bool is_abstract_flat_value_class_array_involved = can_src_be_abstract_flat_value_class_array || can_dest_be_abstract_flat_value_class_array; | ||
| const bool exclude_flat = UseArrayFlattening && | ||
| // We do not know the exact layout of an abstract flat value class array. Bail out. | ||
| (is_abstract_flat_value_class_array_involved || | ||
| (bs->array_copy_requires_gc_barriers(true, T_OBJECT, false, false, BarrierSetC2::Parsing) && | ||
| // Can src array be flat and contain oops? | ||
| (orig_t == nullptr || (!orig_t->is_not_flat() && (!orig_t->is_flat() || orig_t->elem()->inline_klass()->contains_oops()))) && | ||
| // Can dest array be flat and contain oops? | ||
| tklass->can_be_inline_array() && (!tklass->is_flat() || tklass->is_aryklassptr()->elem()->is_instklassptr()->instance_klass()->as_inline_klass()->contains_oops()); | ||
| can_dest_be_value_class_array && (!tklass->is_flat() || tklass->is_aryklassptr()->elem()->is_instklassptr()->instance_klass()->as_inline_klass()->contains_oops()))); | ||
|
Member
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. This should also check for
Member
Author
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 agree. I also took another look at the code again and refactored it a bit to make |
||
| Node* not_objArray = exclude_flat ? generate_non_refArray_guard(klass_node, bailout) : generate_typeArray_guard(klass_node, bailout); | ||
|
|
||
| Node* refined_klass_node = load_default_refined_array_klass(klass_node, /* type_array_guard= */ false); | ||
|
|
||
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 name is a little misleading, I think you want to catch the case
orig_t == nullptrbelow, but if the static type isj.l.O, the runtime type can still be an abstract flat array.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.
That's true. Though, I'm wondering if
orig_tcould even be a non-array pointer at all. TheArrays.copyOf()takes aU[], so after type erasure, we should know it's anObject[]and thus have an arraypointer. It looks like the original code was just defensive by checking
orig_tas well. I removed it and testing passed.