1.1 --- a/src/share/vm/c1/c1_GraphBuilder.cpp Wed Sep 19 16:50:26 2012 -0700 1.2 +++ b/src/share/vm/c1/c1_GraphBuilder.cpp Thu Sep 20 16:49:17 2012 +0200 1.3 @@ -3383,6 +3383,41 @@ 1.4 append_unsafe_CAS(callee); 1.5 return true; 1.6 1.7 + case vmIntrinsics::_getAndAddInt: 1.8 + if (!VM_Version::supports_atomic_getadd4()) { 1.9 + return false; 1.10 + } 1.11 + return append_unsafe_get_and_set_obj(callee, true); 1.12 + case vmIntrinsics::_getAndAddLong: 1.13 + if (!VM_Version::supports_atomic_getadd8()) { 1.14 + return false; 1.15 + } 1.16 + return append_unsafe_get_and_set_obj(callee, true); 1.17 + case vmIntrinsics::_getAndSetInt: 1.18 + if (!VM_Version::supports_atomic_getset4()) { 1.19 + return false; 1.20 + } 1.21 + return append_unsafe_get_and_set_obj(callee, false); 1.22 + case vmIntrinsics::_getAndSetLong: 1.23 + if (!VM_Version::supports_atomic_getset8()) { 1.24 + return false; 1.25 + } 1.26 + return append_unsafe_get_and_set_obj(callee, false); 1.27 + case vmIntrinsics::_getAndSetObject: 1.28 +#ifdef _LP64 1.29 + if (!UseCompressedOops && !VM_Version::supports_atomic_getset8()) { 1.30 + return false; 1.31 + } 1.32 + if (UseCompressedOops && !VM_Version::supports_atomic_getset4()) { 1.33 + return false; 1.34 + } 1.35 +#else 1.36 + if (!VM_Version::supports_atomic_getset4()) { 1.37 + return false; 1.38 + } 1.39 +#endif 1.40 + return append_unsafe_get_and_set_obj(callee, false); 1.41 + 1.42 case vmIntrinsics::_Reference_get: 1.43 // Use the intrinsic version of Reference.get() so that the value in 1.44 // the referent field can be registered by the G1 pre-barrier code. 1.45 @@ -4106,6 +4141,22 @@ 1.46 } 1.47 } 1.48 1.49 +bool GraphBuilder::append_unsafe_get_and_set_obj(ciMethod* callee, bool is_add) { 1.50 + if (InlineUnsafeOps) { 1.51 + Values* args = state()->pop_arguments(callee->arg_size()); 1.52 + BasicType t = callee->return_type()->basic_type(); 1.53 + null_check(args->at(0)); 1.54 + Instruction* offset = args->at(2); 1.55 +#ifndef _LP64 1.56 + offset = append(new Convert(Bytecodes::_l2i, offset, as_ValueType(T_INT))); 1.57 +#endif 1.58 + Instruction* op = append(new UnsafeGetAndSetObject(t, args->at(1), offset, args->at(3), is_add)); 1.59 + compilation()->set_has_unsafe_access(true); 1.60 + kill_all(); 1.61 + push(op->type(), op); 1.62 + } 1.63 + return InlineUnsafeOps; 1.64 +} 1.65 1.66 #ifndef PRODUCT 1.67 void GraphBuilder::print_stats() {