From abf032d28d6ee925386379369403b364fbcb0d34 Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Mon, 24 Mar 2025 10:26:27 +0000 Subject: Fix two issues in fast baseline compiler. - Add a missing fence after allocation. - Create a frame before fetching any register, otherwise, we may wrongly use a caller-saved register that can be overwritten by the hotness slow path. Test: 719-varhandle-concurrency Change-Id: I90278172e3d4f9a3561b269b35a59bd3e8ad1dfd --- compiler/optimizing/fast_compiler_arm64.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/compiler/optimizing/fast_compiler_arm64.cc b/compiler/optimizing/fast_compiler_arm64.cc index 027d114f6d..a820fc9422 100644 --- a/compiler/optimizing/fast_compiler_arm64.cc +++ b/compiler/optimizing/fast_compiler_arm64.cc @@ -1034,6 +1034,7 @@ bool FastCompilerARM64::BuildNewInstance(uint32_t vreg, entrypoint = kQuickAllocObjectWithChecks; } InvokeRuntime(entrypoint, dex_pc); + __ Dmb(InnerShareable, BarrierWrites); if (!MoveLocation(CreateNewRegisterLocation(vreg, DataType::Type::kReference, next), calling_convention.GetReturnLocation(DataType::Type::kReference), DataType::Type::kReference)) { @@ -1871,6 +1872,8 @@ bool FastCompilerARM64::ProcessDexInstruction(const Instruction& instruction, return true; case Instruction::IGET_OBJECT: + is_object = true; + FALLTHROUGH_INTENDED; case Instruction::IGET: case Instruction::IGET_WIDE: case Instruction::IGET_BOOLEAN: @@ -1896,8 +1899,9 @@ bool FastCompilerARM64::ProcessDexInstruction(const Instruction& instruction, } } - if (can_receiver_be_null) { - // We need a frame in case the null check throws. + if (can_receiver_be_null || is_object) { + // We need a frame in case the null check throws or there is a read + // barrier. if (!EnsureHasFrame()) { return false; } @@ -1910,11 +1914,7 @@ bool FastCompilerARM64::ProcessDexInstruction(const Instruction& instruction, if (HitUnimplemented()) { return false; } - if (instruction.Opcode() == Instruction::IGET_OBJECT) { - // Generate a frame because of the read barrier. - if (!EnsureHasFrame()) { - return false; - } + if (is_object) { Register dst = WRegisterFrom( CreateNewRegisterLocation(source_or_dest_reg, DataType::Type::kReference, next)); if (HitUnimplemented()) { -- cgit v1.2.3-59-g8ed1b