comparison src/share/vm/opto/library_call.cpp @ 2446:13bc79b5c9c8

7033154: Improve C1 arraycopy performance Summary: better static analysis. Take advantage of array copy stubs. Reviewed-by: never
author roland
date Sun, 03 Apr 2011 12:00:54 +0200
parents 07acc51c1d2a
children 5d046bf49ce7 66b0e2371912
comparison
equal deleted inserted replaced
2445:08eb13460b3a 2446:13bc79b5c9c8
4290 push(_gvn.transform(result_val)); 4290 push(_gvn.transform(result_val));
4291 4291
4292 return true; 4292 return true;
4293 } 4293 }
4294 4294
4295
4296 // constants for computing the copy function
4297 enum {
4298 COPYFUNC_UNALIGNED = 0,
4299 COPYFUNC_ALIGNED = 1, // src, dest aligned to HeapWordSize
4300 COPYFUNC_CONJOINT = 0,
4301 COPYFUNC_DISJOINT = 2 // src != dest, or transfer can descend
4302 };
4303
4304 // Note: The condition "disjoint" applies also for overlapping copies
4305 // where an descending copy is permitted (i.e., dest_offset <= src_offset).
4306 static address
4307 select_arraycopy_function(BasicType t, bool aligned, bool disjoint, const char* &name, bool dest_uninitialized) {
4308 int selector =
4309 (aligned ? COPYFUNC_ALIGNED : COPYFUNC_UNALIGNED) +
4310 (disjoint ? COPYFUNC_DISJOINT : COPYFUNC_CONJOINT);
4311
4312 #define RETURN_STUB(xxx_arraycopy) { \
4313 name = #xxx_arraycopy; \
4314 return StubRoutines::xxx_arraycopy(); }
4315
4316 #define RETURN_STUB_PARM(xxx_arraycopy, parm) { \
4317 name = #xxx_arraycopy; \
4318 return StubRoutines::xxx_arraycopy(parm); }
4319
4320 switch (t) {
4321 case T_BYTE:
4322 case T_BOOLEAN:
4323 switch (selector) {
4324 case COPYFUNC_CONJOINT | COPYFUNC_UNALIGNED: RETURN_STUB(jbyte_arraycopy);
4325 case COPYFUNC_CONJOINT | COPYFUNC_ALIGNED: RETURN_STUB(arrayof_jbyte_arraycopy);
4326 case COPYFUNC_DISJOINT | COPYFUNC_UNALIGNED: RETURN_STUB(jbyte_disjoint_arraycopy);
4327 case COPYFUNC_DISJOINT | COPYFUNC_ALIGNED: RETURN_STUB(arrayof_jbyte_disjoint_arraycopy);
4328 }
4329 case T_CHAR:
4330 case T_SHORT:
4331 switch (selector) {
4332 case COPYFUNC_CONJOINT | COPYFUNC_UNALIGNED: RETURN_STUB(jshort_arraycopy);
4333 case COPYFUNC_CONJOINT | COPYFUNC_ALIGNED: RETURN_STUB(arrayof_jshort_arraycopy);
4334 case COPYFUNC_DISJOINT | COPYFUNC_UNALIGNED: RETURN_STUB(jshort_disjoint_arraycopy);
4335 case COPYFUNC_DISJOINT | COPYFUNC_ALIGNED: RETURN_STUB(arrayof_jshort_disjoint_arraycopy);
4336 }
4337 case T_INT:
4338 case T_FLOAT:
4339 switch (selector) {
4340 case COPYFUNC_CONJOINT | COPYFUNC_UNALIGNED: RETURN_STUB(jint_arraycopy);
4341 case COPYFUNC_CONJOINT | COPYFUNC_ALIGNED: RETURN_STUB(arrayof_jint_arraycopy);
4342 case COPYFUNC_DISJOINT | COPYFUNC_UNALIGNED: RETURN_STUB(jint_disjoint_arraycopy);
4343 case COPYFUNC_DISJOINT | COPYFUNC_ALIGNED: RETURN_STUB(arrayof_jint_disjoint_arraycopy);
4344 }
4345 case T_DOUBLE:
4346 case T_LONG:
4347 switch (selector) {
4348 case COPYFUNC_CONJOINT | COPYFUNC_UNALIGNED: RETURN_STUB(jlong_arraycopy);
4349 case COPYFUNC_CONJOINT | COPYFUNC_ALIGNED: RETURN_STUB(arrayof_jlong_arraycopy);
4350 case COPYFUNC_DISJOINT | COPYFUNC_UNALIGNED: RETURN_STUB(jlong_disjoint_arraycopy);
4351 case COPYFUNC_DISJOINT | COPYFUNC_ALIGNED: RETURN_STUB(arrayof_jlong_disjoint_arraycopy);
4352 }
4353 case T_ARRAY:
4354 case T_OBJECT:
4355 switch (selector) {
4356 case COPYFUNC_CONJOINT | COPYFUNC_UNALIGNED: RETURN_STUB_PARM(oop_arraycopy, dest_uninitialized);
4357 case COPYFUNC_CONJOINT | COPYFUNC_ALIGNED: RETURN_STUB_PARM(arrayof_oop_arraycopy, dest_uninitialized);
4358 case COPYFUNC_DISJOINT | COPYFUNC_UNALIGNED: RETURN_STUB_PARM(oop_disjoint_arraycopy, dest_uninitialized);
4359 case COPYFUNC_DISJOINT | COPYFUNC_ALIGNED: RETURN_STUB_PARM(arrayof_oop_disjoint_arraycopy, dest_uninitialized);
4360 }
4361 default:
4362 ShouldNotReachHere();
4363 return NULL;
4364 }
4365
4366 #undef RETURN_STUB
4367 #undef RETURN_STUB_PARM
4368 }
4369
4370 //------------------------------basictype2arraycopy---------------------------- 4295 //------------------------------basictype2arraycopy----------------------------
4371 address LibraryCallKit::basictype2arraycopy(BasicType t, 4296 address LibraryCallKit::basictype2arraycopy(BasicType t,
4372 Node* src_offset, 4297 Node* src_offset,
4373 Node* dest_offset, 4298 Node* dest_offset,
4374 bool disjoint_bases, 4299 bool disjoint_bases,
4397 } else if (src_offset == dest_offset && src_offset != NULL) { 4322 } else if (src_offset == dest_offset && src_offset != NULL) {
4398 // This can occur if the offsets are identical non-constants. 4323 // This can occur if the offsets are identical non-constants.
4399 disjoint = true; 4324 disjoint = true;
4400 } 4325 }
4401 4326
4402 return select_arraycopy_function(t, aligned, disjoint, name, dest_uninitialized); 4327 return StubRoutines::select_arraycopy_function(t, aligned, disjoint, name, dest_uninitialized);
4403 } 4328 }
4404 4329
4405 4330
4406 //------------------------------inline_arraycopy----------------------- 4331 //------------------------------inline_arraycopy-----------------------
4407 bool LibraryCallKit::inline_arraycopy() { 4332 bool LibraryCallKit::inline_arraycopy() {