502 // further to JVM_ArrayCopy on the first per-oop check that fails.
503 // (Actually, we don't move raw bits only; the GC requires card marks.)
504
505 // Get the klass* for both src and dest
506 Node* src_klass = ac->in(ArrayCopyNode::SrcKlass);
507 Node* dest_klass = ac->in(ArrayCopyNode::DestKlass);
508
509 assert(src_klass != NULL && dest_klass != NULL, "should have klasses");
510
511 // Generate the subtype check.
512 // This might fold up statically, or then again it might not.
513 //
514 // Non-static example: Copying List<String>.elements to a new String[].
515 // The backing store for a List<String> is always an Object[],
516 // but its elements are always type String, if the generic types
517 // are correct at the source level.
518 //
519 // Test S[] against D[], not S against D, because (probably)
520 // the secondary supertype cache is less busy for S[] than S.
521 // This usually only matters when D is an interface.
522 Node* not_subtype_ctrl = ac->is_arraycopy_notest() ? top() : Phase::gen_subtype_check(src_klass, dest_klass, ctrl, mem, &_igvn);
523 // Plug failing path into checked_oop_disjoint_arraycopy
524 if (not_subtype_ctrl != top()) {
525 Node* local_ctrl = not_subtype_ctrl;
526 MergeMemNode* local_mem = MergeMemNode::make(mem);
527 transform_later(local_mem);
528
529 // (At this point we can assume disjoint_bases, since types differ.)
530 int ek_offset = in_bytes(ObjArrayKlass::element_klass_offset());
531 Node* p1 = basic_plus_adr(dest_klass, ek_offset);
532 Node* n1 = LoadKlassNode::make(_igvn, NULL, C->immutable_memory(), p1, TypeRawPtr::BOTTOM);
533 Node* dest_elem_klass = transform_later(n1);
534 Node* cv = generate_checkcast_arraycopy(&local_ctrl, &local_mem,
535 adr_type,
536 dest_elem_klass,
537 src, src_offset, dest, dest_offset,
538 ConvI2X(copy_length), dest_uninitialized);
539 if (cv == NULL) cv = intcon(-1); // failure (no stub available)
540 checked_control = local_ctrl;
541 checked_i_o = *io;
542 checked_mem = local_mem->memory_at(alias_idx);
1092 AllocateArrayNode* alloc = NULL;
1093 if (ac->is_alloc_tightly_coupled()) {
1094 alloc = AllocateArrayNode::Ideal_array_allocation(dest, &_igvn);
1095 assert(alloc != NULL, "expect alloc");
1096 }
1097
1098 generate_arraycopy(ac, alloc, &ctrl, merge_mem, &io,
1099 TypeAryPtr::OOPS, T_OBJECT,
1100 src, src_offset, dest, dest_offset, length,
1101 true, !ac->is_copyofrange());
1102
1103 return;
1104 }
1105
1106 AllocateArrayNode* alloc = NULL;
1107 if (ac->is_alloc_tightly_coupled()) {
1108 alloc = AllocateArrayNode::Ideal_array_allocation(dest, &_igvn);
1109 assert(alloc != NULL, "expect alloc");
1110 }
1111
1112 assert(ac->is_arraycopy() || ac->is_arraycopy_notest(), "should be an arraycopy");
1113
1114 // Compile time checks. If any of these checks cannot be verified at compile time,
1115 // we do not make a fast path for this call. Instead, we let the call remain as it
1116 // is. The checks we choose to mandate at compile time are:
1117 //
1118 // (1) src and dest are arrays.
1119 const Type* src_type = src->Value(&_igvn);
1120 const Type* dest_type = dest->Value(&_igvn);
1121 const TypeAryPtr* top_src = src_type->isa_aryptr();
1122 const TypeAryPtr* top_dest = dest_type->isa_aryptr();
1123
1124 if (top_src == NULL || top_src->klass() == NULL ||
1125 top_dest == NULL || top_dest->klass() == NULL) {
1126 // Conservatively insert a memory barrier on all memory slices.
1127 // Do not let writes into the source float below the arraycopy.
1128 {
1129 Node* mem = ac->in(TypeFunc::Memory);
1130 insert_mem_bar(&ctrl, &mem, Op_MemBarCPUOrder);
1131
1132 merge_mem = MergeMemNode::make(mem);
1174
1175 // We have the following tests left to perform:
1176 //
1177 // (3) src and dest must not be null.
1178 // (4) src_offset must not be negative.
1179 // (5) dest_offset must not be negative.
1180 // (6) length must not be negative.
1181 // (7) src_offset + length must not exceed length of src.
1182 // (8) dest_offset + length must not exceed length of dest.
1183 // (9) each element of an oop array must be assignable
1184
1185 {
1186 Node* mem = ac->in(TypeFunc::Memory);
1187 merge_mem = MergeMemNode::make(mem);
1188 transform_later(merge_mem);
1189 }
1190
1191 RegionNode* slow_region = new RegionNode(1);
1192 transform_later(slow_region);
1193
1194 if (!ac->is_arraycopy_notest()) {
1195 // (3) operands must not be null
1196 // We currently perform our null checks with the null_check routine.
1197 // This means that the null exceptions will be reported in the caller
1198 // rather than (correctly) reported inside of the native arraycopy call.
1199 // This should be corrected, given time. We do our null check with the
1200 // stack pointer restored.
1201 // null checks done library_call.cpp
1202
1203 // (4) src_offset must not be negative.
1204 generate_negative_guard(&ctrl, src_offset, slow_region);
1205
1206 // (5) dest_offset must not be negative.
1207 generate_negative_guard(&ctrl, dest_offset, slow_region);
1208
1209 // (6) length must not be negative (moved to generate_arraycopy()).
1210 // generate_negative_guard(length, slow_region);
1211
1212 // (7) src_offset + length must not exceed length of src.
1213 Node* alen = ac->in(ArrayCopyNode::SrcLen);
1214 assert(alen != NULL, "need src len");
|
502 // further to JVM_ArrayCopy on the first per-oop check that fails.
503 // (Actually, we don't move raw bits only; the GC requires card marks.)
504
505 // Get the klass* for both src and dest
506 Node* src_klass = ac->in(ArrayCopyNode::SrcKlass);
507 Node* dest_klass = ac->in(ArrayCopyNode::DestKlass);
508
509 assert(src_klass != NULL && dest_klass != NULL, "should have klasses");
510
511 // Generate the subtype check.
512 // This might fold up statically, or then again it might not.
513 //
514 // Non-static example: Copying List<String>.elements to a new String[].
515 // The backing store for a List<String> is always an Object[],
516 // but its elements are always type String, if the generic types
517 // are correct at the source level.
518 //
519 // Test S[] against D[], not S against D, because (probably)
520 // the secondary supertype cache is less busy for S[] than S.
521 // This usually only matters when D is an interface.
522 Node* not_subtype_ctrl = ac->is_arraycopy_validated() ? top() :
523 Phase::gen_subtype_check(src_klass, dest_klass, ctrl, mem, &_igvn);
524 // Plug failing path into checked_oop_disjoint_arraycopy
525 if (not_subtype_ctrl != top()) {
526 Node* local_ctrl = not_subtype_ctrl;
527 MergeMemNode* local_mem = MergeMemNode::make(mem);
528 transform_later(local_mem);
529
530 // (At this point we can assume disjoint_bases, since types differ.)
531 int ek_offset = in_bytes(ObjArrayKlass::element_klass_offset());
532 Node* p1 = basic_plus_adr(dest_klass, ek_offset);
533 Node* n1 = LoadKlassNode::make(_igvn, NULL, C->immutable_memory(), p1, TypeRawPtr::BOTTOM);
534 Node* dest_elem_klass = transform_later(n1);
535 Node* cv = generate_checkcast_arraycopy(&local_ctrl, &local_mem,
536 adr_type,
537 dest_elem_klass,
538 src, src_offset, dest, dest_offset,
539 ConvI2X(copy_length), dest_uninitialized);
540 if (cv == NULL) cv = intcon(-1); // failure (no stub available)
541 checked_control = local_ctrl;
542 checked_i_o = *io;
543 checked_mem = local_mem->memory_at(alias_idx);
1093 AllocateArrayNode* alloc = NULL;
1094 if (ac->is_alloc_tightly_coupled()) {
1095 alloc = AllocateArrayNode::Ideal_array_allocation(dest, &_igvn);
1096 assert(alloc != NULL, "expect alloc");
1097 }
1098
1099 generate_arraycopy(ac, alloc, &ctrl, merge_mem, &io,
1100 TypeAryPtr::OOPS, T_OBJECT,
1101 src, src_offset, dest, dest_offset, length,
1102 true, !ac->is_copyofrange());
1103
1104 return;
1105 }
1106
1107 AllocateArrayNode* alloc = NULL;
1108 if (ac->is_alloc_tightly_coupled()) {
1109 alloc = AllocateArrayNode::Ideal_array_allocation(dest, &_igvn);
1110 assert(alloc != NULL, "expect alloc");
1111 }
1112
1113 assert(ac->is_arraycopy() || ac->is_arraycopy_validated(), "should be an arraycopy");
1114
1115 // Compile time checks. If any of these checks cannot be verified at compile time,
1116 // we do not make a fast path for this call. Instead, we let the call remain as it
1117 // is. The checks we choose to mandate at compile time are:
1118 //
1119 // (1) src and dest are arrays.
1120 const Type* src_type = src->Value(&_igvn);
1121 const Type* dest_type = dest->Value(&_igvn);
1122 const TypeAryPtr* top_src = src_type->isa_aryptr();
1123 const TypeAryPtr* top_dest = dest_type->isa_aryptr();
1124
1125 if (top_src == NULL || top_src->klass() == NULL ||
1126 top_dest == NULL || top_dest->klass() == NULL) {
1127 // Conservatively insert a memory barrier on all memory slices.
1128 // Do not let writes into the source float below the arraycopy.
1129 {
1130 Node* mem = ac->in(TypeFunc::Memory);
1131 insert_mem_bar(&ctrl, &mem, Op_MemBarCPUOrder);
1132
1133 merge_mem = MergeMemNode::make(mem);
1175
1176 // We have the following tests left to perform:
1177 //
1178 // (3) src and dest must not be null.
1179 // (4) src_offset must not be negative.
1180 // (5) dest_offset must not be negative.
1181 // (6) length must not be negative.
1182 // (7) src_offset + length must not exceed length of src.
1183 // (8) dest_offset + length must not exceed length of dest.
1184 // (9) each element of an oop array must be assignable
1185
1186 {
1187 Node* mem = ac->in(TypeFunc::Memory);
1188 merge_mem = MergeMemNode::make(mem);
1189 transform_later(merge_mem);
1190 }
1191
1192 RegionNode* slow_region = new RegionNode(1);
1193 transform_later(slow_region);
1194
1195 if (!ac->is_arraycopy_validated()) {
1196 // (3) operands must not be null
1197 // We currently perform our null checks with the null_check routine.
1198 // This means that the null exceptions will be reported in the caller
1199 // rather than (correctly) reported inside of the native arraycopy call.
1200 // This should be corrected, given time. We do our null check with the
1201 // stack pointer restored.
1202 // null checks done library_call.cpp
1203
1204 // (4) src_offset must not be negative.
1205 generate_negative_guard(&ctrl, src_offset, slow_region);
1206
1207 // (5) dest_offset must not be negative.
1208 generate_negative_guard(&ctrl, dest_offset, slow_region);
1209
1210 // (6) length must not be negative (moved to generate_arraycopy()).
1211 // generate_negative_guard(length, slow_region);
1212
1213 // (7) src_offset + length must not exceed length of src.
1214 Node* alen = ac->in(ArrayCopyNode::SrcLen);
1215 assert(alen != NULL, "need src len");
|