diff options
author | 2023-12-08 14:01:44 +0000 | |
---|---|---|
committer | 2024-01-19 11:42:17 +0000 | |
commit | 7c1dd6e2d1893f288214413c4b97273980f3aa4a (patch) | |
tree | d2912acfaed1cee70670d3497236a4b0d81baff3 /compiler/optimizing/code_generator.cc | |
parent | 921cc7db943144fe8a45f00527ad4950570637d0 (diff) |
Revert "Disable write-barrier elimination pass"
This reverts commit 5a3271d7caafefd10a20f5a5db09d2c178838b76.
Reason for revert:
This CL has two fixes (codegen not doing a null check if a write
barrier is being relied on, and codegen not recomputing
skipping write barriers), regression tests, a new
runtime check which runs in debug mode for the CC GC to ensure
that the card table is set correctly for skipped write barriers,
and new compile time (graph checker) tests to ensure graph
consistency.
This patchset updates the WriteBarrierKind to be
{emit being relied on, emit not being relied on, dont emit},
which leaves the null check skip implementation to codegen.
Test 2247- is removed from knownfailures.json but still skipped
in MTS due to SLO requirements.
Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b
Bug: 301833859
Bug: 310755375
Bug: 260843353
Change-Id: I025597e284b2765986e2091538680ee629fb5ae7
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 b0e07e32ea..0e294b560a 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) { |