hotspot/src/share/vm/oops/typeArrayKlass.cpp
changeset 5119 7bf54ea07181
parent 3576 4ceec8fb3e18
child 5547 f4b087cbb361
equal deleted inserted replaced
4306:1d0121b741f0 5119:7bf54ea07181
   121   // Check if the ranges are valid
   121   // Check if the ranges are valid
   122   if  ( (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length())
   122   if  ( (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length())
   123      || (((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length()) ) {
   123      || (((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length()) ) {
   124     THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
   124     THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
   125   }
   125   }
       
   126   // Check zero copy
       
   127   if (length == 0)
       
   128     return;
   126 
   129 
   127   // This is an attempt to make the copy_array fast.
   130   // This is an attempt to make the copy_array fast.
   128   // NB: memmove takes care of overlapping memory segments.
       
   129   // Potential problem: memmove is not guaranteed to be word atomic
       
   130   // Revisit in Merlin
       
   131   int l2es = log2_element_size();
   131   int l2es = log2_element_size();
   132   int ihs = array_header_in_bytes() / wordSize;
   132   int ihs = array_header_in_bytes() / wordSize;
   133   char* src = (char*) ((oop*)s + ihs) + (src_pos << l2es);
   133   char* src = (char*) ((oop*)s + ihs) + ((size_t)src_pos << l2es);
   134   char* dst = (char*) ((oop*)d + ihs) + (dst_pos << l2es);
   134   char* dst = (char*) ((oop*)d + ihs) + ((size_t)dst_pos << l2es);
   135   memmove(dst, src, length << l2es);
   135   Copy::conjoint_memory_atomic(src, dst, (size_t)length << l2es);
   136 }
   136 }
   137 
   137 
   138 
   138 
   139 // create a klass of array holding typeArrays
   139 // create a klass of array holding typeArrays
   140 klassOop typeArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) {
   140 klassOop typeArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) {