mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 10:04:42 +02:00
8076188: Optimize arraycopy out for non escaping destination
If the destination of an arraycopy is non escaping, the arraycopy may be optimized out Reviewed-by: kvn, vlivanov
This commit is contained in:
parent
3dc9461bc8
commit
a9cdbd0407
17 changed files with 1224 additions and 486 deletions
|
@ -30,7 +30,9 @@ ArrayCopyNode::ArrayCopyNode(Compile* C, bool alloc_tightly_coupled)
|
|||
: CallNode(arraycopy_type(), NULL, TypeRawPtr::BOTTOM),
|
||||
_alloc_tightly_coupled(alloc_tightly_coupled),
|
||||
_kind(None),
|
||||
_arguments_validated(false) {
|
||||
_arguments_validated(false),
|
||||
_src_type(TypeOopPtr::BOTTOM),
|
||||
_dest_type(TypeOopPtr::BOTTOM) {
|
||||
init_class_id(Class_ArrayCopy);
|
||||
init_flags(Flag_is_macro);
|
||||
C->add_macro_node(this);
|
||||
|
@ -595,3 +597,17 @@ Node *ArrayCopyNode::Ideal(PhaseGVN *phase, bool can_reshape) {
|
|||
|
||||
return mem;
|
||||
}
|
||||
|
||||
bool ArrayCopyNode::may_modify(const TypeOopPtr *t_oop, PhaseTransform *phase) {
|
||||
const TypeOopPtr* dest_t = phase->type(in(ArrayCopyNode::Dest))->is_oopptr();
|
||||
assert(!dest_t->is_known_instance() || _dest_type->is_known_instance(), "result of EA not recorded");
|
||||
const TypeOopPtr* src_t = phase->type(in(ArrayCopyNode::Src))->is_oopptr();
|
||||
assert(!src_t->is_known_instance() || _src_type->is_known_instance(), "result of EA not recorded");
|
||||
|
||||
if (_dest_type != TypeOopPtr::BOTTOM || t_oop->is_known_instance()) {
|
||||
assert(_dest_type == TypeOopPtr::BOTTOM || _dest_type->is_known_instance(), "result of EA is known instance");
|
||||
return t_oop->instance_id() == _dest_type->instance_id();
|
||||
}
|
||||
|
||||
return CallNode::may_modify_arraycopy_helper(dest_t, t_oop, phase);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue