137 }
138
139 // Check is all offsets and lengths are non negative
140 if (src_pos < 0 || dst_pos < 0 || length < 0) {
141 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
142 }
143 // Check if the ranges are valid
144 if ( (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length())
145 || (((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length()) ) {
146 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
147 }
148 // Check zero copy
149 if (length == 0)
150 return;
151
152 // This is an attempt to make the copy_array fast.
153 int l2es = log2_element_size();
154 int ihs = array_header_in_bytes() / wordSize;
155 char* src = (char*) ((oop*)s + ihs) + ((size_t)src_pos << l2es);
156 char* dst = (char*) ((oop*)d + ihs) + ((size_t)dst_pos << l2es);
157 Copy::conjoint_memory_atomic(src, dst, (size_t)length << l2es);
158 }
159
160
161 // create a klass of array holding typeArrays
162 Klass* TypeArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) {
163 int dim = dimension();
164 assert(dim <= n, "check order of chain");
165 if (dim == n)
166 return this;
167
168 // lock-free read needs acquire semantics
169 if (higher_dimension_acquire() == NULL) {
170 if (or_null) return NULL;
171
172 ResourceMark rm;
173 JavaThread *jt = (JavaThread *)THREAD;
174 {
175 MutexLocker mc(Compile_lock, THREAD); // for vtables
176 // Atomic create higher dimension and link into list
177 MutexLocker mu(MultiArray_lock, THREAD);
|
137 }
138
139 // Check is all offsets and lengths are non negative
140 if (src_pos < 0 || dst_pos < 0 || length < 0) {
141 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
142 }
143 // Check if the ranges are valid
144 if ( (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length())
145 || (((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length()) ) {
146 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
147 }
148 // Check zero copy
149 if (length == 0)
150 return;
151
152 // This is an attempt to make the copy_array fast.
153 int l2es = log2_element_size();
154 int ihs = array_header_in_bytes() / wordSize;
155 char* src = (char*) ((oop*)s + ihs) + ((size_t)src_pos << l2es);
156 char* dst = (char*) ((oop*)d + ihs) + ((size_t)dst_pos << l2es);
157 HeapAccess<>::arraycopy(s, d, src, dst, (size_t)length << l2es);
158 }
159
160
161 // create a klass of array holding typeArrays
162 Klass* TypeArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) {
163 int dim = dimension();
164 assert(dim <= n, "check order of chain");
165 if (dim == n)
166 return this;
167
168 // lock-free read needs acquire semantics
169 if (higher_dimension_acquire() == NULL) {
170 if (or_null) return NULL;
171
172 ResourceMark rm;
173 JavaThread *jt = (JavaThread *)THREAD;
174 {
175 MutexLocker mc(Compile_lock, THREAD); // for vtables
176 // Atomic create higher dimension and link into list
177 MutexLocker mu(MultiArray_lock, THREAD);
|