Mercurial > hg > truffle
comparison src/share/vm/c1/c1_GraphBuilder.cpp @ 6795:7eca5de9e0b6
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
Summary: use shorter instruction sequences for atomic add and atomic exchange when possible.
Reviewed-by: kvn, jrose
author | roland |
---|---|
date | Thu, 20 Sep 2012 16:49:17 +0200 |
parents | da91efe96a93 |
children | c3e799c37717 |
comparison
equal
deleted
inserted
replaced
6794:8ae8f9dd7099 | 6795:7eca5de9e0b6 |
---|---|
3381 case vmIntrinsics::_compareAndSwapInt: | 3381 case vmIntrinsics::_compareAndSwapInt: |
3382 case vmIntrinsics::_compareAndSwapObject: | 3382 case vmIntrinsics::_compareAndSwapObject: |
3383 append_unsafe_CAS(callee); | 3383 append_unsafe_CAS(callee); |
3384 return true; | 3384 return true; |
3385 | 3385 |
3386 case vmIntrinsics::_getAndAddInt: | |
3387 if (!VM_Version::supports_atomic_getadd4()) { | |
3388 return false; | |
3389 } | |
3390 return append_unsafe_get_and_set_obj(callee, true); | |
3391 case vmIntrinsics::_getAndAddLong: | |
3392 if (!VM_Version::supports_atomic_getadd8()) { | |
3393 return false; | |
3394 } | |
3395 return append_unsafe_get_and_set_obj(callee, true); | |
3396 case vmIntrinsics::_getAndSetInt: | |
3397 if (!VM_Version::supports_atomic_getset4()) { | |
3398 return false; | |
3399 } | |
3400 return append_unsafe_get_and_set_obj(callee, false); | |
3401 case vmIntrinsics::_getAndSetLong: | |
3402 if (!VM_Version::supports_atomic_getset8()) { | |
3403 return false; | |
3404 } | |
3405 return append_unsafe_get_and_set_obj(callee, false); | |
3406 case vmIntrinsics::_getAndSetObject: | |
3407 #ifdef _LP64 | |
3408 if (!UseCompressedOops && !VM_Version::supports_atomic_getset8()) { | |
3409 return false; | |
3410 } | |
3411 if (UseCompressedOops && !VM_Version::supports_atomic_getset4()) { | |
3412 return false; | |
3413 } | |
3414 #else | |
3415 if (!VM_Version::supports_atomic_getset4()) { | |
3416 return false; | |
3417 } | |
3418 #endif | |
3419 return append_unsafe_get_and_set_obj(callee, false); | |
3420 | |
3386 case vmIntrinsics::_Reference_get: | 3421 case vmIntrinsics::_Reference_get: |
3387 // Use the intrinsic version of Reference.get() so that the value in | 3422 // Use the intrinsic version of Reference.get() so that the value in |
3388 // the referent field can be registered by the G1 pre-barrier code. | 3423 // the referent field can be registered by the G1 pre-barrier code. |
3389 // Also to prevent commoning reads from this field across safepoint | 3424 // Also to prevent commoning reads from this field across safepoint |
3390 // since GC can change its value. | 3425 // since GC can change its value. |
4104 if (success && CIPrintMethodCodes) { | 4139 if (success && CIPrintMethodCodes) { |
4105 callee->print_codes(); | 4140 callee->print_codes(); |
4106 } | 4141 } |
4107 } | 4142 } |
4108 | 4143 |
4144 bool GraphBuilder::append_unsafe_get_and_set_obj(ciMethod* callee, bool is_add) { | |
4145 if (InlineUnsafeOps) { | |
4146 Values* args = state()->pop_arguments(callee->arg_size()); | |
4147 BasicType t = callee->return_type()->basic_type(); | |
4148 null_check(args->at(0)); | |
4149 Instruction* offset = args->at(2); | |
4150 #ifndef _LP64 | |
4151 offset = append(new Convert(Bytecodes::_l2i, offset, as_ValueType(T_INT))); | |
4152 #endif | |
4153 Instruction* op = append(new UnsafeGetAndSetObject(t, args->at(1), offset, args->at(3), is_add)); | |
4154 compilation()->set_has_unsafe_access(true); | |
4155 kill_all(); | |
4156 push(op->type(), op); | |
4157 } | |
4158 return InlineUnsafeOps; | |
4159 } | |
4109 | 4160 |
4110 #ifndef PRODUCT | 4161 #ifndef PRODUCT |
4111 void GraphBuilder::print_stats() { | 4162 void GraphBuilder::print_stats() { |
4112 vmap()->print(); | 4163 vmap()->print(); |
4113 } | 4164 } |