src/share/vm/c1/c1_Runtime1.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File c1-coops Sdiff src/share/vm/c1

src/share/vm/c1/c1_Runtime1.cpp

Print this page




1157 
1158   if (src == NULL || dst == NULL || src_pos < 0 || dst_pos < 0 || length < 0) return ac_failed;
1159   if (!dst->is_array() || !src->is_array()) return ac_failed;
1160   if ((unsigned int) arrayOop(src)->length() < (unsigned int)src_pos + (unsigned int)length) return ac_failed;
1161   if ((unsigned int) arrayOop(dst)->length() < (unsigned int)dst_pos + (unsigned int)length) return ac_failed;
1162 
1163   if (length == 0) return ac_ok;
1164   if (src->is_typeArray()) {
1165     const klassOop klass_oop = src->klass();
1166     if (klass_oop != dst->klass()) return ac_failed;
1167     typeArrayKlass* klass = typeArrayKlass::cast(klass_oop);
1168     const int l2es = klass->log2_element_size();
1169     const int ihs = klass->array_header_in_bytes() / wordSize;
1170     char* src_addr = (char*) ((oopDesc**)src + ihs) + (src_pos << l2es);
1171     char* dst_addr = (char*) ((oopDesc**)dst + ihs) + (dst_pos << l2es);
1172     // Potential problem: memmove is not guaranteed to be word atomic
1173     // Revisit in Merlin
1174     memmove(dst_addr, src_addr, length << l2es);
1175     return ac_ok;
1176   } else if (src->is_objArray() && dst->is_objArray()) {
1177     if (UseCompressedOops) {  // will need for tiered
1178       narrowOop *src_addr  = objArrayOop(src)->obj_at_addr<narrowOop>(src_pos);
1179       narrowOop *dst_addr  = objArrayOop(dst)->obj_at_addr<narrowOop>(dst_pos);
1180       return obj_arraycopy_work(src, src_addr, dst, dst_addr, length);
1181     } else {
1182       oop *src_addr  = objArrayOop(src)->obj_at_addr<oop>(src_pos);
1183       oop *dst_addr  = objArrayOop(dst)->obj_at_addr<oop>(dst_pos);
1184       return obj_arraycopy_work(src, src_addr, dst, dst_addr, length);
1185     }
1186   }
1187   return ac_failed;
1188 JRT_END
1189 
1190 
1191 JRT_LEAF(void, Runtime1::primitive_arraycopy(HeapWord* src, HeapWord* dst, int length))
1192 #ifndef PRODUCT
1193   _primitive_arraycopy_cnt++;
1194 #endif
1195 
1196   if (length == 0) return;
1197   // Not guaranteed to be word atomic, but that doesn't matter
1198   // for anything but an oop array, which is covered by oop_arraycopy.
1199   Copy::conjoint_jbytes(src, dst, length);
1200 JRT_END
1201 
1202 JRT_LEAF(void, Runtime1::oop_arraycopy(HeapWord* src, HeapWord* dst, int num))
1203 #ifndef PRODUCT
1204   _oop_arraycopy_cnt++;
1205 #endif
1206 
1207   if (num == 0) return;
1208   BarrierSet* bs = Universe::heap()->barrier_set();
1209   assert(bs->has_write_ref_array_opt(), "Barrier set must have ref array opt");
1210   assert(bs->has_write_ref_array_pre_opt(), "For pre-barrier as well.");
1211   if (UseCompressedOops) {
1212     bs->write_ref_array_pre((narrowOop*)dst, num);

1213   } else {
1214     bs->write_ref_array_pre((oop*)dst, num);
1215   }
1216   Copy::conjoint_oops_atomic((oop*) src, (oop*) dst, num);

1217   bs->write_ref_array(dst, num);
1218 JRT_END
1219 
1220 
1221 #ifndef PRODUCT
1222 void Runtime1::print_statistics() {
1223   tty->print_cr("C1 Runtime statistics:");
1224   tty->print_cr(" _resolve_invoke_virtual_cnt:     %d", SharedRuntime::_resolve_virtual_ctr);
1225   tty->print_cr(" _resolve_invoke_opt_virtual_cnt: %d", SharedRuntime::_resolve_opt_virtual_ctr);
1226   tty->print_cr(" _resolve_invoke_static_cnt:      %d", SharedRuntime::_resolve_static_ctr);
1227   tty->print_cr(" _handle_wrong_method_cnt:        %d", SharedRuntime::_wrong_method_ctr);
1228   tty->print_cr(" _ic_miss_cnt:                    %d", SharedRuntime::_ic_miss_ctr);
1229   tty->print_cr(" _generic_arraycopy_cnt:          %d", _generic_arraycopy_cnt);
1230   tty->print_cr(" _primitive_arraycopy_cnt:        %d", _primitive_arraycopy_cnt);
1231   tty->print_cr(" _oop_arraycopy_cnt:              %d", _oop_arraycopy_cnt);
1232   tty->print_cr(" _arraycopy_slowcase_cnt:         %d", _arraycopy_slowcase_cnt);
1233 
1234   tty->print_cr(" _new_type_array_slowcase_cnt:    %d", _new_type_array_slowcase_cnt);
1235   tty->print_cr(" _new_object_array_slowcase_cnt:  %d", _new_object_array_slowcase_cnt);
1236   tty->print_cr(" _new_instance_slowcase_cnt:      %d", _new_instance_slowcase_cnt);


1157 
1158   if (src == NULL || dst == NULL || src_pos < 0 || dst_pos < 0 || length < 0) return ac_failed;
1159   if (!dst->is_array() || !src->is_array()) return ac_failed;
1160   if ((unsigned int) arrayOop(src)->length() < (unsigned int)src_pos + (unsigned int)length) return ac_failed;
1161   if ((unsigned int) arrayOop(dst)->length() < (unsigned int)dst_pos + (unsigned int)length) return ac_failed;
1162 
1163   if (length == 0) return ac_ok;
1164   if (src->is_typeArray()) {
1165     const klassOop klass_oop = src->klass();
1166     if (klass_oop != dst->klass()) return ac_failed;
1167     typeArrayKlass* klass = typeArrayKlass::cast(klass_oop);
1168     const int l2es = klass->log2_element_size();
1169     const int ihs = klass->array_header_in_bytes() / wordSize;
1170     char* src_addr = (char*) ((oopDesc**)src + ihs) + (src_pos << l2es);
1171     char* dst_addr = (char*) ((oopDesc**)dst + ihs) + (dst_pos << l2es);
1172     // Potential problem: memmove is not guaranteed to be word atomic
1173     // Revisit in Merlin
1174     memmove(dst_addr, src_addr, length << l2es);
1175     return ac_ok;
1176   } else if (src->is_objArray() && dst->is_objArray()) {
1177     if (UseCompressedOops) {
1178       narrowOop *src_addr  = objArrayOop(src)->obj_at_addr<narrowOop>(src_pos);
1179       narrowOop *dst_addr  = objArrayOop(dst)->obj_at_addr<narrowOop>(dst_pos);
1180       return obj_arraycopy_work(src, src_addr, dst, dst_addr, length);
1181     } else {
1182       oop *src_addr  = objArrayOop(src)->obj_at_addr<oop>(src_pos);
1183       oop *dst_addr  = objArrayOop(dst)->obj_at_addr<oop>(dst_pos);
1184       return obj_arraycopy_work(src, src_addr, dst, dst_addr, length);
1185     }
1186   }
1187   return ac_failed;
1188 JRT_END
1189 
1190 
1191 JRT_LEAF(void, Runtime1::primitive_arraycopy(HeapWord* src, HeapWord* dst, int length))
1192 #ifndef PRODUCT
1193   _primitive_arraycopy_cnt++;
1194 #endif
1195 
1196   if (length == 0) return;
1197   // Not guaranteed to be word atomic, but that doesn't matter
1198   // for anything but an oop array, which is covered by oop_arraycopy.
1199   Copy::conjoint_jbytes(src, dst, length);
1200 JRT_END
1201 
1202 JRT_LEAF(void, Runtime1::oop_arraycopy(HeapWord* src, HeapWord* dst, int num))
1203 #ifndef PRODUCT
1204   _oop_arraycopy_cnt++;
1205 #endif
1206 
1207   if (num == 0) return;
1208   BarrierSet* bs = Universe::heap()->barrier_set();
1209   assert(bs->has_write_ref_array_opt(), "Barrier set must have ref array opt");
1210   assert(bs->has_write_ref_array_pre_opt(), "For pre-barrier as well.");
1211   if (UseCompressedOops) {
1212     bs->write_ref_array_pre((narrowOop*)dst, num);
1213     Copy::conjoint_oops_atomic((narrowOop*) src, (narrowOop*) dst, num);
1214   } else {
1215     bs->write_ref_array_pre((oop*)dst, num);

1216     Copy::conjoint_oops_atomic((oop*) src, (oop*) dst, num);
1217   }
1218   bs->write_ref_array(dst, num);
1219 JRT_END
1220 
1221 
1222 #ifndef PRODUCT
1223 void Runtime1::print_statistics() {
1224   tty->print_cr("C1 Runtime statistics:");
1225   tty->print_cr(" _resolve_invoke_virtual_cnt:     %d", SharedRuntime::_resolve_virtual_ctr);
1226   tty->print_cr(" _resolve_invoke_opt_virtual_cnt: %d", SharedRuntime::_resolve_opt_virtual_ctr);
1227   tty->print_cr(" _resolve_invoke_static_cnt:      %d", SharedRuntime::_resolve_static_ctr);
1228   tty->print_cr(" _handle_wrong_method_cnt:        %d", SharedRuntime::_wrong_method_ctr);
1229   tty->print_cr(" _ic_miss_cnt:                    %d", SharedRuntime::_ic_miss_ctr);
1230   tty->print_cr(" _generic_arraycopy_cnt:          %d", _generic_arraycopy_cnt);
1231   tty->print_cr(" _primitive_arraycopy_cnt:        %d", _primitive_arraycopy_cnt);
1232   tty->print_cr(" _oop_arraycopy_cnt:              %d", _oop_arraycopy_cnt);
1233   tty->print_cr(" _arraycopy_slowcase_cnt:         %d", _arraycopy_slowcase_cnt);
1234 
1235   tty->print_cr(" _new_type_array_slowcase_cnt:    %d", _new_type_array_slowcase_cnt);
1236   tty->print_cr(" _new_object_array_slowcase_cnt:  %d", _new_object_array_slowcase_cnt);
1237   tty->print_cr(" _new_instance_slowcase_cnt:      %d", _new_instance_slowcase_cnt);
src/share/vm/c1/c1_Runtime1.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File