135 if (!d->is_typeArray() || element_type() != TypeArrayKlass::cast(d->klass())->element_type()) {
136 THROW(vmSymbols::java_lang_ArrayStoreException());
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 void* src = (char*) (s->base(element_type())) + ((size_t)src_pos << l2es);
156 void* dst = (char*) (d->base(element_type())) + ((size_t)dst_pos << l2es);
157 HeapAccess<ARRAYCOPY_ATOMIC>::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);
|
135 if (!d->is_typeArray() || element_type() != TypeArrayKlass::cast(d->klass())->element_type()) {
136 THROW(vmSymbols::java_lang_ArrayStoreException());
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 size_t src_offset = arrayOopDesc::base_offset_in_bytes(element_type()) + ((size_t)src_pos << l2es);
156 size_t dst_offset = arrayOopDesc::base_offset_in_bytes(element_type()) + ((size_t)dst_pos << l2es);
157 HeapAccess<ARRAYCOPY_ATOMIC>::arraycopy<void>(s, src_offset, NULL, d, dst_offset, NULL, (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);
|