Mercurial > hg > graal-compiler
comparison src/share/vm/runtime/stubRoutines.cpp @ 1763:d6f45b55c972
4809552: Optimize Arrays.fill(...)
Reviewed-by: kvn
author | never |
---|---|
date | Fri, 27 Aug 2010 17:33:49 -0700 |
parents | d93949c5bdcc |
children | 14197af1010e |
comparison
equal
deleted
inserted
replaced
1731:ee5cc9e78493 | 1763:d6f45b55c972 |
---|---|
95 | 95 |
96 address StubRoutines::_checkcast_arraycopy = NULL; | 96 address StubRoutines::_checkcast_arraycopy = NULL; |
97 address StubRoutines::_unsafe_arraycopy = NULL; | 97 address StubRoutines::_unsafe_arraycopy = NULL; |
98 address StubRoutines::_generic_arraycopy = NULL; | 98 address StubRoutines::_generic_arraycopy = NULL; |
99 | 99 |
100 | |
101 address StubRoutines::_jbyte_fill; | |
102 address StubRoutines::_jshort_fill; | |
103 address StubRoutines::_jint_fill; | |
104 address StubRoutines::_arrayof_jbyte_fill; | |
105 address StubRoutines::_arrayof_jshort_fill; | |
106 address StubRoutines::_arrayof_jint_fill; | |
107 | |
108 | |
100 double (* StubRoutines::_intrinsic_log )(double) = NULL; | 109 double (* StubRoutines::_intrinsic_log )(double) = NULL; |
101 double (* StubRoutines::_intrinsic_log10 )(double) = NULL; | 110 double (* StubRoutines::_intrinsic_log10 )(double) = NULL; |
102 double (* StubRoutines::_intrinsic_exp )(double) = NULL; | 111 double (* StubRoutines::_intrinsic_exp )(double) = NULL; |
103 double (* StubRoutines::_intrinsic_pow )(double, double) = NULL; | 112 double (* StubRoutines::_intrinsic_pow )(double, double) = NULL; |
104 double (* StubRoutines::_intrinsic_sin )(double) = NULL; | 113 double (* StubRoutines::_intrinsic_sin )(double) = NULL; |
193 TEST_ARRAYCOPY(jint); | 202 TEST_ARRAYCOPY(jint); |
194 TEST_ARRAYCOPY(jlong); | 203 TEST_ARRAYCOPY(jlong); |
195 | 204 |
196 #undef TEST_ARRAYCOPY | 205 #undef TEST_ARRAYCOPY |
197 | 206 |
207 #define TEST_FILL(type) \ | |
208 if (_##type##_fill != NULL) { \ | |
209 union { \ | |
210 double d; \ | |
211 type body[96]; \ | |
212 } s; \ | |
213 \ | |
214 int v = 32; \ | |
215 for (int offset = -2; offset <= 2; offset++) { \ | |
216 for (int i = 0; i < 96; i++) { \ | |
217 s.body[i] = 1; \ | |
218 } \ | |
219 type* start = s.body + 8 + offset; \ | |
220 for (int aligned = 0; aligned < 2; aligned++) { \ | |
221 if (aligned) { \ | |
222 if (((intptr_t)start) % HeapWordSize == 0) { \ | |
223 ((void (*)(type*, int, int))StubRoutines::_arrayof_##type##_fill)(start, v, 80); \ | |
224 } else { \ | |
225 continue; \ | |
226 } \ | |
227 } else { \ | |
228 ((void (*)(type*, int, int))StubRoutines::_##type##_fill)(start, v, 80); \ | |
229 } \ | |
230 for (int i = 0; i < 96; i++) { \ | |
231 if (i < (8 + offset) || i >= (88 + offset)) { \ | |
232 assert(s.body[i] == 1, "what?"); \ | |
233 } else { \ | |
234 assert(s.body[i] == 32, "what?"); \ | |
235 } \ | |
236 } \ | |
237 } \ | |
238 } \ | |
239 } \ | |
240 | |
241 TEST_FILL(jbyte); | |
242 TEST_FILL(jshort); | |
243 TEST_FILL(jint); | |
244 | |
245 #undef TEST_FILL | |
246 | |
198 #define TEST_COPYRTN(type) \ | 247 #define TEST_COPYRTN(type) \ |
199 test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::conjoint_##type##s_atomic), sizeof(type)); \ | 248 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))) | 249 test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::arrayof_conjoint_##type##s), (int)MAX2(sizeof(HeapWord), sizeof(type))) |
201 | 250 |
202 // Make sure all the copy runtime routines properly handle zero count | 251 // Make sure all the copy runtime routines properly handle zero count |
313 assert(count != 0, "count should be non-zero"); | 362 assert(count != 0, "count should be non-zero"); |
314 gen_arraycopy_barrier_pre((oop *) dest, count); | 363 gen_arraycopy_barrier_pre((oop *) dest, count); |
315 Copy::arrayof_conjoint_oops(src, dest, count); | 364 Copy::arrayof_conjoint_oops(src, dest, count); |
316 gen_arraycopy_barrier((oop *) dest, count); | 365 gen_arraycopy_barrier((oop *) dest, count); |
317 JRT_END | 366 JRT_END |
367 | |
368 | |
369 address StubRoutines::select_fill_function(BasicType t, bool aligned, const char* &name) { | |
370 #define RETURN_STUB(xxx_fill) { \ | |
371 name = #xxx_fill; \ | |
372 return StubRoutines::xxx_fill(); } | |
373 | |
374 switch (t) { | |
375 case T_BYTE: | |
376 case T_BOOLEAN: | |
377 if (!aligned) RETURN_STUB(jbyte_fill); | |
378 RETURN_STUB(arrayof_jbyte_fill); | |
379 case T_CHAR: | |
380 case T_SHORT: | |
381 if (!aligned) RETURN_STUB(jshort_fill); | |
382 RETURN_STUB(arrayof_jshort_fill); | |
383 case T_INT: | |
384 case T_FLOAT: | |
385 if (!aligned) RETURN_STUB(jint_fill); | |
386 RETURN_STUB(arrayof_jint_fill); | |
387 case T_DOUBLE: | |
388 case T_LONG: | |
389 case T_ARRAY: | |
390 case T_OBJECT: | |
391 case T_NARROWOOP: | |
392 case T_ADDRESS: | |
393 // Currently unsupported | |
394 return NULL; | |
395 | |
396 default: | |
397 ShouldNotReachHere(); | |
398 return NULL; | |
399 } | |
400 | |
401 #undef RETURN_STUB | |
402 } |