comparison src/share/vm/runtime/stubRoutines.cpp @ 1603:d93949c5bdcc

6730276: JDI_REGRESSION tests fail with "Error: count must be non-zero" error on x86 Summary: Modify assembler code to check for 0 count for all copy routines. Reviewed-by: never, ysr, jcoomes
author kvn
date Thu, 10 Jun 2010 13:04:20 -0700
parents c18cbe5936b8
children 3e8fbc61cee8 d6f45b55c972
comparison
equal deleted inserted replaced
1602:136b78722a08 1603:d93949c5bdcc
133 133
134 // simple tests of generated arraycopy functions 134 // simple tests of generated arraycopy functions
135 static void test_arraycopy_func(address func, int alignment) { 135 static void test_arraycopy_func(address func, int alignment) {
136 int v = 0xcc; 136 int v = 0xcc;
137 int v2 = 0x11; 137 int v2 = 0x11;
138 jlong lbuffer[2]; 138 jlong lbuffer[8];
139 jlong lbuffer2[2]; 139 jlong lbuffer2[8];
140 address buffer = (address) lbuffer; 140 address fbuffer = (address) lbuffer;
141 address buffer2 = (address) lbuffer2; 141 address fbuffer2 = (address) lbuffer2;
142 unsigned int i; 142 unsigned int i;
143 for (i = 0; i < sizeof(lbuffer); i++) { 143 for (i = 0; i < sizeof(lbuffer); i++) {
144 buffer[i] = v; buffer2[i] = v2; 144 fbuffer[i] = v; fbuffer2[i] = v2;
145 } 145 }
146 // C++ does not guarantee jlong[] array alignment to 8 bytes.
147 // Use middle of array to check that memory before it is not modified.
148 address buffer = (address) round_to((intptr_t)&lbuffer[4], BytesPerLong);
149 address buffer2 = (address) round_to((intptr_t)&lbuffer2[4], BytesPerLong);
146 // do an aligned copy 150 // do an aligned copy
147 ((arraycopy_fn)func)(buffer, buffer2, 0); 151 ((arraycopy_fn)func)(buffer, buffer2, 0);
148 for (i = 0; i < sizeof(lbuffer); i++) { 152 for (i = 0; i < sizeof(lbuffer); i++) {
149 assert(buffer[i] == v && buffer2[i] == v2, "shouldn't have copied anything"); 153 assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
150 } 154 }
151 // adjust destination alignment 155 // adjust destination alignment
152 ((arraycopy_fn)func)(buffer, buffer2 + alignment, 0); 156 ((arraycopy_fn)func)(buffer, buffer2 + alignment, 0);
153 for (i = 0; i < sizeof(lbuffer); i++) { 157 for (i = 0; i < sizeof(lbuffer); i++) {
154 assert(buffer[i] == v && buffer2[i] == v2, "shouldn't have copied anything"); 158 assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
155 } 159 }
156 // adjust source alignment 160 // adjust source alignment
157 ((arraycopy_fn)func)(buffer + alignment, buffer2, 0); 161 ((arraycopy_fn)func)(buffer + alignment, buffer2, 0);
158 for (i = 0; i < sizeof(lbuffer); i++) { 162 for (i = 0; i < sizeof(lbuffer); i++) {
159 assert(buffer[i] == v && buffer2[i] == v2, "shouldn't have copied anything"); 163 assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
160 } 164 }
161 } 165 }
162 #endif 166 #endif
163 167
164 168
181 test_arraycopy_func( type##_arraycopy(), sizeof(type)); \ 185 test_arraycopy_func( type##_arraycopy(), sizeof(type)); \
182 test_arraycopy_func( type##_disjoint_arraycopy(), sizeof(type)); \ 186 test_arraycopy_func( type##_disjoint_arraycopy(), sizeof(type)); \
183 test_arraycopy_func(arrayof_##type##_arraycopy(), sizeof(HeapWord)); \ 187 test_arraycopy_func(arrayof_##type##_arraycopy(), sizeof(HeapWord)); \
184 test_arraycopy_func(arrayof_##type##_disjoint_arraycopy(), sizeof(HeapWord)) 188 test_arraycopy_func(arrayof_##type##_disjoint_arraycopy(), sizeof(HeapWord))
185 189
186 // Make sure all the arraycopy stubs properly handle zeros 190 // Make sure all the arraycopy stubs properly handle zero count
187 TEST_ARRAYCOPY(jbyte); 191 TEST_ARRAYCOPY(jbyte);
188 TEST_ARRAYCOPY(jshort); 192 TEST_ARRAYCOPY(jshort);
189 TEST_ARRAYCOPY(jint); 193 TEST_ARRAYCOPY(jint);
190 TEST_ARRAYCOPY(jlong); 194 TEST_ARRAYCOPY(jlong);
191 195
192 #undef TEST_ARRAYCOPY 196 #undef TEST_ARRAYCOPY
197
198 #define TEST_COPYRTN(type) \
199 test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::conjoint_##type##s_atomic), sizeof(type)); \
200 test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::arrayof_conjoint_##type##s), (int)MAX2(sizeof(HeapWord), sizeof(type)))
201
202 // Make sure all the copy runtime routines properly handle zero count
203 TEST_COPYRTN(jbyte);
204 TEST_COPYRTN(jshort);
205 TEST_COPYRTN(jint);
206 TEST_COPYRTN(jlong);
207
208 #undef TEST_COPYRTN
209
210 test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::conjoint_words), sizeof(HeapWord));
211 test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::disjoint_words), sizeof(HeapWord));
212 test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::disjoint_words_atomic), sizeof(HeapWord));
213 // Aligned to BytesPerLong
214 test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::aligned_conjoint_words), sizeof(jlong));
215 test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::aligned_disjoint_words), sizeof(jlong));
193 216
194 #endif 217 #endif
195 } 218 }
196 219
197 220
219 242
220 JRT_LEAF(void, StubRoutines::jbyte_copy(jbyte* src, jbyte* dest, size_t count)) 243 JRT_LEAF(void, StubRoutines::jbyte_copy(jbyte* src, jbyte* dest, size_t count))
221 #ifndef PRODUCT 244 #ifndef PRODUCT
222 SharedRuntime::_jbyte_array_copy_ctr++; // Slow-path byte array copy 245 SharedRuntime::_jbyte_array_copy_ctr++; // Slow-path byte array copy
223 #endif // !PRODUCT 246 #endif // !PRODUCT
224 assert(count != 0, "count should be non-zero"); 247 Copy::conjoint_jbytes_atomic(src, dest, count);
225 Copy::conjoint_bytes_atomic(src, dest, count);
226 JRT_END 248 JRT_END
227 249
228 JRT_LEAF(void, StubRoutines::jshort_copy(jshort* src, jshort* dest, size_t count)) 250 JRT_LEAF(void, StubRoutines::jshort_copy(jshort* src, jshort* dest, size_t count))
229 #ifndef PRODUCT 251 #ifndef PRODUCT
230 SharedRuntime::_jshort_array_copy_ctr++; // Slow-path short/char array copy 252 SharedRuntime::_jshort_array_copy_ctr++; // Slow-path short/char array copy
231 #endif // !PRODUCT 253 #endif // !PRODUCT
232 assert(count != 0, "count should be non-zero");
233 Copy::conjoint_jshorts_atomic(src, dest, count); 254 Copy::conjoint_jshorts_atomic(src, dest, count);
234 JRT_END 255 JRT_END
235 256
236 JRT_LEAF(void, StubRoutines::jint_copy(jint* src, jint* dest, size_t count)) 257 JRT_LEAF(void, StubRoutines::jint_copy(jint* src, jint* dest, size_t count))
237 #ifndef PRODUCT 258 #ifndef PRODUCT
238 SharedRuntime::_jint_array_copy_ctr++; // Slow-path int/float array copy 259 SharedRuntime::_jint_array_copy_ctr++; // Slow-path int/float array copy
239 #endif // !PRODUCT 260 #endif // !PRODUCT
240 assert(count != 0, "count should be non-zero");
241 Copy::conjoint_jints_atomic(src, dest, count); 261 Copy::conjoint_jints_atomic(src, dest, count);
242 JRT_END 262 JRT_END
243 263
244 JRT_LEAF(void, StubRoutines::jlong_copy(jlong* src, jlong* dest, size_t count)) 264 JRT_LEAF(void, StubRoutines::jlong_copy(jlong* src, jlong* dest, size_t count))
245 #ifndef PRODUCT 265 #ifndef PRODUCT
246 SharedRuntime::_jlong_array_copy_ctr++; // Slow-path long/double array copy 266 SharedRuntime::_jlong_array_copy_ctr++; // Slow-path long/double array copy
247 #endif // !PRODUCT 267 #endif // !PRODUCT
248 assert(count != 0, "count should be non-zero");
249 Copy::conjoint_jlongs_atomic(src, dest, count); 268 Copy::conjoint_jlongs_atomic(src, dest, count);
250 JRT_END 269 JRT_END
251 270
252 JRT_LEAF(void, StubRoutines::oop_copy(oop* src, oop* dest, size_t count)) 271 JRT_LEAF(void, StubRoutines::oop_copy(oop* src, oop* dest, size_t count))
253 #ifndef PRODUCT 272 #ifndef PRODUCT
261 280
262 JRT_LEAF(void, StubRoutines::arrayof_jbyte_copy(HeapWord* src, HeapWord* dest, size_t count)) 281 JRT_LEAF(void, StubRoutines::arrayof_jbyte_copy(HeapWord* src, HeapWord* dest, size_t count))
263 #ifndef PRODUCT 282 #ifndef PRODUCT
264 SharedRuntime::_jbyte_array_copy_ctr++; // Slow-path byte array copy 283 SharedRuntime::_jbyte_array_copy_ctr++; // Slow-path byte array copy
265 #endif // !PRODUCT 284 #endif // !PRODUCT
266 assert(count != 0, "count should be non-zero"); 285 Copy::arrayof_conjoint_jbytes(src, dest, count);
267 Copy::arrayof_conjoint_bytes(src, dest, count);
268 JRT_END 286 JRT_END
269 287
270 JRT_LEAF(void, StubRoutines::arrayof_jshort_copy(HeapWord* src, HeapWord* dest, size_t count)) 288 JRT_LEAF(void, StubRoutines::arrayof_jshort_copy(HeapWord* src, HeapWord* dest, size_t count))
271 #ifndef PRODUCT 289 #ifndef PRODUCT
272 SharedRuntime::_jshort_array_copy_ctr++; // Slow-path short/char array copy 290 SharedRuntime::_jshort_array_copy_ctr++; // Slow-path short/char array copy
273 #endif // !PRODUCT 291 #endif // !PRODUCT
274 assert(count != 0, "count should be non-zero");
275 Copy::arrayof_conjoint_jshorts(src, dest, count); 292 Copy::arrayof_conjoint_jshorts(src, dest, count);
276 JRT_END 293 JRT_END
277 294
278 JRT_LEAF(void, StubRoutines::arrayof_jint_copy(HeapWord* src, HeapWord* dest, size_t count)) 295 JRT_LEAF(void, StubRoutines::arrayof_jint_copy(HeapWord* src, HeapWord* dest, size_t count))
279 #ifndef PRODUCT 296 #ifndef PRODUCT
280 SharedRuntime::_jint_array_copy_ctr++; // Slow-path int/float array copy 297 SharedRuntime::_jint_array_copy_ctr++; // Slow-path int/float array copy
281 #endif // !PRODUCT 298 #endif // !PRODUCT
282 assert(count != 0, "count should be non-zero");
283 Copy::arrayof_conjoint_jints(src, dest, count); 299 Copy::arrayof_conjoint_jints(src, dest, count);
284 JRT_END 300 JRT_END
285 301
286 JRT_LEAF(void, StubRoutines::arrayof_jlong_copy(HeapWord* src, HeapWord* dest, size_t count)) 302 JRT_LEAF(void, StubRoutines::arrayof_jlong_copy(HeapWord* src, HeapWord* dest, size_t count))
287 #ifndef PRODUCT 303 #ifndef PRODUCT
288 SharedRuntime::_jlong_array_copy_ctr++; // Slow-path int/float array copy 304 SharedRuntime::_jlong_array_copy_ctr++; // Slow-path int/float array copy
289 #endif // !PRODUCT 305 #endif // !PRODUCT
290 assert(count != 0, "count should be non-zero");
291 Copy::arrayof_conjoint_jlongs(src, dest, count); 306 Copy::arrayof_conjoint_jlongs(src, dest, count);
292 JRT_END 307 JRT_END
293 308
294 JRT_LEAF(void, StubRoutines::arrayof_oop_copy(HeapWord* src, HeapWord* dest, size_t count)) 309 JRT_LEAF(void, StubRoutines::arrayof_oop_copy(HeapWord* src, HeapWord* dest, size_t count))
295 #ifndef PRODUCT 310 #ifndef PRODUCT