diff options
author | 2024-01-22 08:57:31 +0000 | |
---|---|---|
committer | 2024-01-22 10:49:24 +0000 | |
commit | b5b98b9bb31acb2deffb692c50d0fbc71476663b (patch) | |
tree | 3bda094f8d5ea90ad34e5d357889ce4933f657f5 /compiler/optimizing/code_generator.cc | |
parent | dbf9d9309f3df9c9ac8a9e30277b31ebb2977f4d (diff) |
Revert^3 "Disable write-barrier elimination pass"
This reverts commit 9f8df195b7ff2ce47eec4e9b193ff3214ebed19c.
Reason for revert: Fix for x86_64 with heap poison enabled
This case uses a temp with index `1` in the regular FieldSet case.
This is done like this due to GenerateVarHandleSet also calling
HandleFieldSet. The bug was that we were allocating only one
temp in the regular FieldSet case and therefore not having the
temp with index `1` available.
PS1 is the revert as-is.
PS2 contains the fix.
Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b
Test: Same command with heap poison enabled too
Bug: 301833859
Bug: 310755375
Bug: 260843353
Change-Id: Ie2740b4c443158c4e72810ce1d8268353c5f0055
Diffstat (limited to 'compiler/optimizing/code_generator.cc')
-rw-r--r-- | compiler/optimizing/code_generator.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/compiler/optimizing/code_generator.cc b/compiler/optimizing/code_generator.cc index b00e7e1873..441a93c38f 100644 --- a/compiler/optimizing/code_generator.cc +++ b/compiler/optimizing/code_generator.cc @@ -158,6 +158,25 @@ ReadBarrierOption CodeGenerator::GetCompilerReadBarrierOption() const { return EmitReadBarrier() ? kWithReadBarrier : kWithoutReadBarrier; } +bool CodeGenerator::ShouldCheckGCCard(DataType::Type type, + HInstruction* value, + WriteBarrierKind write_barrier_kind) const { + const CompilerOptions& options = GetCompilerOptions(); + const bool result = + // Check the GC card in debug mode, + options.EmitRunTimeChecksInDebugMode() && + // only for CC GC, + options.EmitReadBarrier() && + // and if we eliminated the write barrier in WBE. + !StoreNeedsWriteBarrier(type, value, write_barrier_kind) && + CodeGenerator::StoreNeedsWriteBarrier(type, value); + + DCHECK_IMPLIES(result, write_barrier_kind == WriteBarrierKind::kDontEmit); + DCHECK_IMPLIES(result, !GetGraph()->IsCompilingBaseline()); + + return result; +} + ScopedArenaAllocator* CodeGenerator::GetScopedAllocator() { DCHECK(code_generation_data_ != nullptr); return code_generation_data_->GetScopedAllocator(); @@ -1608,6 +1627,17 @@ void CodeGenerator::EmitParallelMoves(Location from1, GetMoveResolver()->EmitNativeCode(¶llel_move); } +bool CodeGenerator::StoreNeedsWriteBarrier(DataType::Type type, + HInstruction* value, + WriteBarrierKind write_barrier_kind) const { + // Check that null value is not represented as an integer constant. + DCHECK_IMPLIES(type == DataType::Type::kReference, !value->IsIntConstant()); + // Branch profiling currently doesn't support running optimizations. + return GetGraph()->IsCompilingBaseline() + ? CodeGenerator::StoreNeedsWriteBarrier(type, value) + : write_barrier_kind != WriteBarrierKind::kDontEmit; +} + void CodeGenerator::ValidateInvokeRuntime(QuickEntrypointEnum entrypoint, HInstruction* instruction, SlowPathCode* slow_path) { |