Clean up VarHandles.set*() for arrays and byte array views.
This CL is a clean up for https://r.android.com/1875684. Changes:
- Use setters instead of constructor arguments.
- Rerun benchmarks and add improvements for arrays to commit message
(as aosp/1875684 forgot to mention changes for arrays).
- Do BSWAP at compile time if the argument is a constant value.
`HandleFieldSet` now can optionally perform byte swap. The function
is rewritten so that constant and non-constant values are handled in
separate branches, which makes both cases simpler.
- Add helper function `CodeGeneratorX86_64::GetInstructionCodegen` to
reduce boilerplate.
Benchmarks improvements (using benchmarks provided by
https://android-review.googlesource.com/1420959):
benchmark before aosp/1875684 now
----------------------------------------------------------------
VarHandleSetArrayElementInt 2.79 0.002
VarHandleSetArrayElementString 3.09 0.003
VarHandleSetByteArrayViewInt 2.89 0.004
VarHandleSetByteArrayViewBigEndianInt 2.89 0.004
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: I8cc37321228ffb2833a1158a75ced65f18af968e
diff --git a/compiler/optimizing/code_generator_x86_64.h b/compiler/optimizing/code_generator_x86_64.h
index 1115c83..a130994 100644
--- a/compiler/optimizing/code_generator_x86_64.h
+++ b/compiler/optimizing/code_generator_x86_64.h
@@ -249,7 +249,10 @@
CpuRegister base,
bool is_volatile,
bool is_atomic,
- bool value_can_be_null);
+ bool value_can_be_null,
+ bool byte_swap = false);
+
+ void Bswap(Location value, DataType::Type type, CpuRegister* temp = nullptr);
private:
// Generate code for the given suspend check. If not null, `successor`
@@ -421,6 +424,10 @@
return InstructionSet::kX86_64;
}
+ InstructionCodeGeneratorX86_64* GetInstructionCodegen() {
+ return down_cast<InstructionCodeGeneratorX86_64*>(GetInstructionVisitor());
+ }
+
const X86_64InstructionSetFeatures& GetInstructionSetFeatures() const;
// Emit a write barrier.
@@ -650,7 +657,6 @@
void GenerateExplicitNullCheck(HNullCheck* instruction) override;
void MaybeGenerateInlineCacheCheck(HInstruction* instruction, CpuRegister cls);
-
void MaybeIncrementHotness(bool is_frame_entry);
static void BlockNonVolatileXmmRegisters(LocationSummary* locations);