blob: 7ea75ed69a28efcd7cc3969954e87b5bd1a33752 [file] [log] [blame]
commit 99a93c3a223e3bfc9a9781bfbf98d2fd4551f923
Author: Vitaly Buka <vitalybuka@google.com>
Date: Thu Sep 3 18:54:52 2020 -0700
[NFC][Asan] Rename internal enum value.
New name better represents the state of chunk.
diff --git a/compiler-rt/lib/asan/asan_allocator.cpp b/compiler-rt/lib/asan/asan_allocator.cpp
index 16b264080b5..c7c9d7a7b3c 100644
--- a/compiler-rt/lib/asan/asan_allocator.cpp
+++ b/compiler-rt/lib/asan/asan_allocator.cpp
@@ -106,8 +106,11 @@ COMPILER_CHECK(kChunkHeader2Size <= 16);
// CHUNK_ALLOCATED: the chunk is allocated and not yet freed.
// CHUNK_QUARANTINE: the chunk was freed and put into quarantine zone.
enum {
- CHUNK_AVAILABLE = 0, // 0 is the default value even if we didn't set it.
- CHUNK_ALLOCATED = 2,
+ // Either just allocated by underlying allocator, but AsanChunk is not yet
+ // ready, or almost returned to undelying allocator and AsanChunk is already
+ // meaningless.
+ CHUNK_INVALID = 0,
+ CHUNK_ALLOCATED = 2,
CHUNK_QUARANTINE = 3
};
@@ -142,8 +145,7 @@ struct QuarantineCallback {
void Recycle(AsanChunk *m) {
u8 old_chunk_state = CHUNK_QUARANTINE;
if (!atomic_compare_exchange_strong(&m->chunk_state, &old_chunk_state,
- CHUNK_AVAILABLE,
- memory_order_acquire)) {
+ CHUNK_INVALID, memory_order_acquire)) {
CHECK_EQ(old_chunk_state, CHUNK_QUARANTINE);
}
@@ -859,7 +861,7 @@ static AsanAllocator &get_allocator() {
bool AsanChunkView::IsValid() const {
return chunk_ && atomic_load(&chunk_->chunk_state, memory_order_relaxed) !=
- CHUNK_AVAILABLE;
+ CHUNK_INVALID;
}
bool AsanChunkView::IsAllocated() const {
return chunk_ && atomic_load(&chunk_->chunk_state, memory_order_relaxed) ==