< prev index next >

src/hotspot/share/oops/typeArrayKlass.cpp

Print this page
rev 50331 : 8198285: More consistent Access API for arraycopy
rev 50332 : [mq]: JDK-8203232-2.patch
rev 50333 : [mq]: JDK-8198285-3.patch


 161     if (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) {
 162       ss.print("arraycopy: last source index %u out of bounds for %s[%d]",
 163                (unsigned int) length + (unsigned int) src_pos,
 164                type2name_tab[ArrayKlass::cast(s->klass())->element_type()], s->length());
 165     } else {
 166       ss.print("arraycopy: last destination index %u out of bounds for %s[%d]",
 167                (unsigned int) length + (unsigned int) dst_pos,
 168                type2name_tab[ArrayKlass::cast(d->klass())->element_type()], d->length());
 169     }
 170     THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), ss.as_string());
 171   }
 172   // Check zero copy
 173   if (length == 0)
 174     return;
 175 
 176   // This is an attempt to make the copy_array fast.
 177   int l2es = log2_element_size();
 178   int ihs = array_header_in_bytes() / wordSize;
 179   size_t src_offset = arrayOopDesc::base_offset_in_bytes(element_type()) + ((size_t)src_pos << l2es);
 180   size_t dst_offset = arrayOopDesc::base_offset_in_bytes(element_type()) + ((size_t)dst_pos << l2es);
 181   ArrayAccess<ARRAYCOPY_ATOMIC>::arraycopy<void>(s, src_offset, d, dst_offset, (size_t)length << l2es);
 182 }
 183 
 184 // create a klass of array holding typeArrays
 185 Klass* TypeArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) {
 186   int dim = dimension();
 187   assert(dim <= n, "check order of chain");
 188     if (dim == n)
 189       return this;
 190 
 191   // lock-free read needs acquire semantics
 192   if (higher_dimension_acquire() == NULL) {
 193     if (or_null)  return NULL;
 194 
 195     ResourceMark rm;
 196     JavaThread *jt = (JavaThread *)THREAD;
 197     {
 198       MutexLocker mc(Compile_lock, THREAD);   // for vtables
 199       // Atomic create higher dimension and link into list
 200       MutexLocker mu(MultiArray_lock, THREAD);
 201 




 161     if (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) {
 162       ss.print("arraycopy: last source index %u out of bounds for %s[%d]",
 163                (unsigned int) length + (unsigned int) src_pos,
 164                type2name_tab[ArrayKlass::cast(s->klass())->element_type()], s->length());
 165     } else {
 166       ss.print("arraycopy: last destination index %u out of bounds for %s[%d]",
 167                (unsigned int) length + (unsigned int) dst_pos,
 168                type2name_tab[ArrayKlass::cast(d->klass())->element_type()], d->length());
 169     }
 170     THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), ss.as_string());
 171   }
 172   // Check zero copy
 173   if (length == 0)
 174     return;
 175 
 176   // This is an attempt to make the copy_array fast.
 177   int l2es = log2_element_size();
 178   int ihs = array_header_in_bytes() / wordSize;
 179   size_t src_offset = arrayOopDesc::base_offset_in_bytes(element_type()) + ((size_t)src_pos << l2es);
 180   size_t dst_offset = arrayOopDesc::base_offset_in_bytes(element_type()) + ((size_t)dst_pos << l2es);
 181   ArrayAccess<ARRAYCOPY_ATOMIC>::template arraycopy<void>(s, src_offset, d, dst_offset, (size_t)length << l2es);
 182 }
 183 
 184 // create a klass of array holding typeArrays
 185 Klass* TypeArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) {
 186   int dim = dimension();
 187   assert(dim <= n, "check order of chain");
 188     if (dim == n)
 189       return this;
 190 
 191   // lock-free read needs acquire semantics
 192   if (higher_dimension_acquire() == NULL) {
 193     if (or_null)  return NULL;
 194 
 195     ResourceMark rm;
 196     JavaThread *jt = (JavaThread *)THREAD;
 197     {
 198       MutexLocker mc(Compile_lock, THREAD);   // for vtables
 199       // Atomic create higher dimension and link into list
 200       MutexLocker mu(MultiArray_lock, THREAD);
 201 


< prev index next >