< prev index next >

src/hotspot/share/oops/objArrayKlass.cpp

Print this page




 295       ss.print("arraycopy: last source index %u out of bounds for object array[%d]",
 296                (unsigned int) length + (unsigned int) src_pos, s->length());
 297     } else {
 298       ss.print("arraycopy: last destination index %u out of bounds for object array[%d]",
 299                (unsigned int) length + (unsigned int) dst_pos, d->length());
 300     }
 301     THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), ss.as_string());
 302   }
 303 
 304   // Special case. Boundary cases must be checked first
 305   // This allows the following call: copy_array(s, s.length(), d.length(), 0).
 306   // This is correct, since the position is supposed to be an 'in between point', i.e., s.length(),
 307   // points to the right of the last element.
 308   if (length==0) {
 309     return;
 310   }
 311   if (UseCompressedOops) {
 312     size_t src_offset = (size_t) objArrayOopDesc::obj_at_offset<narrowOop>(src_pos);
 313     size_t dst_offset = (size_t) objArrayOopDesc::obj_at_offset<narrowOop>(dst_pos);
 314     assert(arrayOopDesc::obj_offset_to_raw<narrowOop>(s, src_offset, NULL) ==
 315            objArrayOop(s)->obj_at_addr<narrowOop>(src_pos), "sanity");
 316     assert(arrayOopDesc::obj_offset_to_raw<narrowOop>(d, dst_offset, NULL) ==
 317            objArrayOop(d)->obj_at_addr<narrowOop>(dst_pos), "sanity");
 318     do_copy(s, src_offset, d, dst_offset, length, CHECK);
 319   } else {
 320     size_t src_offset = (size_t) objArrayOopDesc::obj_at_offset<oop>(src_pos);
 321     size_t dst_offset = (size_t) objArrayOopDesc::obj_at_offset<oop>(dst_pos);
 322     assert(arrayOopDesc::obj_offset_to_raw<oop>(s, src_offset, NULL) ==
 323            objArrayOop(s)->obj_at_addr<oop>(src_pos), "sanity");
 324     assert(arrayOopDesc::obj_offset_to_raw<oop>(d, dst_offset, NULL) ==
 325            objArrayOop(d)->obj_at_addr<oop>(dst_pos), "sanity");
 326     do_copy(s, src_offset, d, dst_offset, length, CHECK);
 327   }
 328 }
 329 
 330 
 331 Klass* ObjArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) {
 332 
 333   assert(dimension() <= n, "check order of chain");
 334   int dim = dimension();
 335   if (dim == n) return this;
 336 
 337   // lock-free read needs acquire semantics
 338   if (higher_dimension_acquire() == NULL) {
 339     if (or_null)  return NULL;
 340 
 341     ResourceMark rm;
 342     JavaThread *jt = (JavaThread *)THREAD;
 343     {
 344       MutexLocker mc(Compile_lock, THREAD);   // for vtables
 345       // Ensure atomic creation of higher dimensions




 295       ss.print("arraycopy: last source index %u out of bounds for object array[%d]",
 296                (unsigned int) length + (unsigned int) src_pos, s->length());
 297     } else {
 298       ss.print("arraycopy: last destination index %u out of bounds for object array[%d]",
 299                (unsigned int) length + (unsigned int) dst_pos, d->length());
 300     }
 301     THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), ss.as_string());
 302   }
 303 
 304   // Special case. Boundary cases must be checked first
 305   // This allows the following call: copy_array(s, s.length(), d.length(), 0).
 306   // This is correct, since the position is supposed to be an 'in between point', i.e., s.length(),
 307   // points to the right of the last element.
 308   if (length==0) {
 309     return;
 310   }
 311   if (UseCompressedOops) {
 312     size_t src_offset = (size_t) objArrayOopDesc::obj_at_offset<narrowOop>(src_pos);
 313     size_t dst_offset = (size_t) objArrayOopDesc::obj_at_offset<narrowOop>(dst_pos);
 314     assert(arrayOopDesc::obj_offset_to_raw<narrowOop>(s, src_offset, NULL) ==
 315            objArrayOop(s)->obj_at_addr_raw<narrowOop>(src_pos), "sanity");
 316     assert(arrayOopDesc::obj_offset_to_raw<narrowOop>(d, dst_offset, NULL) ==
 317            objArrayOop(d)->obj_at_addr_raw<narrowOop>(dst_pos), "sanity");
 318     do_copy(s, src_offset, d, dst_offset, length, CHECK);
 319   } else {
 320     size_t src_offset = (size_t) objArrayOopDesc::obj_at_offset<oop>(src_pos);
 321     size_t dst_offset = (size_t) objArrayOopDesc::obj_at_offset<oop>(dst_pos);
 322     assert(arrayOopDesc::obj_offset_to_raw<oop>(s, src_offset, NULL) ==
 323            objArrayOop(s)->obj_at_addr_raw<oop>(src_pos), "sanity");
 324     assert(arrayOopDesc::obj_offset_to_raw<oop>(d, dst_offset, NULL) ==
 325            objArrayOop(d)->obj_at_addr_raw<oop>(dst_pos), "sanity");
 326     do_copy(s, src_offset, d, dst_offset, length, CHECK);
 327   }
 328 }
 329 
 330 
 331 Klass* ObjArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) {
 332 
 333   assert(dimension() <= n, "check order of chain");
 334   int dim = dimension();
 335   if (dim == n) return this;
 336 
 337   // lock-free read needs acquire semantics
 338   if (higher_dimension_acquire() == NULL) {
 339     if (or_null)  return NULL;
 340 
 341     ResourceMark rm;
 342     JavaThread *jt = (JavaThread *)THREAD;
 343     {
 344       MutexLocker mc(Compile_lock, THREAD);   // for vtables
 345       // Ensure atomic creation of higher dimensions


< prev index next >