From 56dcaeec46dd53e271d6f201d2028996bf19f9dd Mon Sep 17 00:00:00 2001 From: Santiago Aboy Solanes Date: Fri, 22 Mar 2024 10:45:15 +0000 Subject: Remove extra uses of ClearAllBits ArenaBitVector creation guarantees it starts empty. Add a debug check to make sure this assumption doesn't change. Note that ArenaAllocator guarantees zero-initialized memory but ScopedArenaAllocators do not. This is fine either way since the BitVector constructor calls ClearAllBits. Bug: 329037671 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: Icbf5e5dd1869e80b5d5828ecca9f13de30c0242b --- libartbase/base/bit_vector.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libartbase/base/bit_vector.cc') diff --git a/libartbase/base/bit_vector.cc b/libartbase/base/bit_vector.cc index 8e3d4c9bf7..85f326385e 100644 --- a/libartbase/base/bit_vector.cc +++ b/libartbase/base/bit_vector.cc @@ -46,6 +46,12 @@ BitVector::BitVector(uint32_t start_bits, BitsToWords(start_bits), static_cast(allocator->Alloc(BitsToWords(start_bits) * kWordBytes))) { // We don't know if the allocator cleared things. + // TODO(solanes): We should be able to remove this call to `ClearAllBits`. Currently we have: + // * `MallocAllocator` and `ArenaAllocator` which sets it to zero, and + // * `ScopedArenaAllocator` which does not. + // We also have `NoopAllocator` but that allocator should never call this method (as the Alloc + // call will turn into a LOG(FATAL)). + // As a note, MallocAllocator is a misnomer as it uses `calloc` which sets the memory to zero. ClearAllBits(); } -- cgit v1.2.3-59-g8ed1b