From 3322cc5ff93b83c49e694bff14a8f43c893b2ed8 Mon Sep 17 00:00:00 2001 From: Ulya Trafimovich Date: Fri, 19 Nov 2021 12:48:28 +0000 Subject: x86_64: Implement VarHandle.getAnd* for arrays and byte array views. Benchmarks improvements (using benchmarks provided by https://android-review.googlesource.com/1420959): benchmark before after ---------------------------------------------------------- GetAndSetArrayElementInt 2.771 0.013 GetAndSetArrayElementDouble 2.709 0.011 GetAndSetArrayElementString 3.105 0.012 GetAndAddArrayElementInt 2.769 0.013 GetAndAddArrayElementDouble 2.713 0.011 GetAndBitwiseXorArrayElementInt 2.767 0.011 GetAndSetByteArrayViewInt 2.819 0.013 GetAndAddByteArrayViewInt 2.830 0.013 GetAndBitwiseXorByteArrayViewInt 2.822 0.012 GetAndSetByteArrayViewBigEndianInt 2.829 0.012 GetAndAddByteArrayViewBigEndianInt 2.826 0.012 GetAndBitwiseXorByteArrayViewBigEndianInt 2.824 0.012 Bug: 71781600 Test: lunch aosp_cf_x86_64_phone-userdebug \ && art/test.py --host -r -t 712-varhandle-invocations --64 Test: Repeat with ART_USE_READ_BARRIER=false. Test: Repeat with ART_HEAP_POISONING=true. Change-Id: Icdc066bb5cbef7b7afe5513842ec8e1ee1d8eb94 --- compiler/optimizing/instruction_builder.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'compiler/optimizing/instruction_builder.cc') diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc index ed760f190d..f8bf126eeb 100644 --- a/compiler/optimizing/instruction_builder.cc +++ b/compiler/optimizing/instruction_builder.cc @@ -1302,6 +1302,11 @@ static void DecideVarHandleIntrinsic(HInvoke* invoke) { if (IsVarHandleGetAndAdd(invoke) && (value_type == DataType::Type::kReference || value_type == DataType::Type::kBool)) { // We should only add numerical types. + // + // For byte array views floating-point types are not allowed, see javadoc comments for + // java.lang.invoke.MethodHandles.byteArrayViewVarHandle(). But ART treats them as numeric + // types in ByteArrayViewVarHandle::Access(). Consequently we do generate intrinsic code, + // but it always fails access mode check at runtime. optimizations.SetDoNotIntrinsify(); return; } else if (IsVarHandleGetAndBitwiseOp(invoke) && !DataType::IsIntegralType(value_type)) { -- cgit v1.2.3-59-g8ed1b