From a3fe0452f6972218fce5aacd81ced3dc20ea482d Mon Sep 17 00:00:00 2001 From: Ulya Trafimovich Date: Mon, 6 Sep 2021 16:53:56 +0100 Subject: x86_64: Implement VarHandle.get{,Acquire,Opaque,Volatile} for arrays. Benchmarks improvements (using benchmarks provided by https://android-review.googlesource.com/1420959): benchmark before after ----------------------------------------------------- VarHandleGetArrayElementInt 2.725 0.002 VarHandleGetArrayElementString 2.778 0.003 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: Ie9c6cef4ef3cf459cbfebbc17d1f449c489ec357 --- compiler/optimizing/intrinsics_utils.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'compiler/optimizing/intrinsics_utils.h') diff --git a/compiler/optimizing/intrinsics_utils.h b/compiler/optimizing/intrinsics_utils.h index 546d5b3b93..3713b32a6c 100644 --- a/compiler/optimizing/intrinsics_utils.h +++ b/compiler/optimizing/intrinsics_utils.h @@ -146,6 +146,18 @@ static inline bool IsVarHandleGetAndAdd(HInvoke* invoke) { } } +static inline DataType::Type GetVarHandleExpectedValueType(HInvoke* invoke, + size_t expected_coordinates_count) { + DCHECK_EQ(expected_coordinates_count, GetExpectedVarHandleCoordinatesCount(invoke)); + uint32_t number_of_arguments = invoke->GetNumberOfArguments(); + DCHECK_GE(number_of_arguments, /* VarHandle object */ 1u + expected_coordinates_count); + if (number_of_arguments == /* VarHandle object */ 1u + expected_coordinates_count) { + return invoke->GetType(); + } else { + return GetDataTypeFromShorty(invoke, number_of_arguments - 1u); + } +} + } // namespace art #endif // ART_COMPILER_OPTIMIZING_INTRINSICS_UTILS_H_ -- cgit v1.2.3-59-g8ed1b