diff options
author | 2024-01-25 09:56:06 +0000 | |
---|---|---|
committer | 2024-01-29 08:47:22 +0000 | |
commit | d76551c7229060a3fe11258b490a11f4ee91e9f8 (patch) | |
tree | f8fcb5e839b1d2c0a61347b764f6a76dda117a84 /compiler/optimizing/code_generator.cc | |
parent | b782659336403e125e33f829afad49b901027c22 (diff) |
Revert^7 "Disable write-barrier elimination pass"
This reverts commit 1ba3516e8c3e2b86c73084893dd297f468469181.
Reason for revert:
PS1 is reland as-is
PS2 has two related fixes (for RISC-V and arm64) taking into
account that when we store zero, we use a special register.
Bug: 301833859
Bug: 310755375
Bug: 260843353
Test: lunch cf_riscv64_wear-trunk_staging-userdebug && m
Test: lunch starnix_wear_yukawa-trunk_staging-userdebug && m
Change-Id: I5e69890fd56404ddde56ebc457179241363d9243
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) { |