Commit ee68662a authored by Dominik Inführ's avatar Dominik Inführ Committed by Commit Bot

[heap] Use CAS for incrementing MemoryChunk::live_byte_count_

Experimenting with incrementing live_byte_count_ using a relaxed CAS
operation. If no regression is found, we could get away with background
threads increasing that counter directly, instead of using separate
counters like concurrent markers.

Bug: v8:10315
Change-Id: I2e7a1f941a728f59d6e1fbd686d2eeb01ea4378a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2201765Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67809}
parent 99a361ee
......@@ -303,15 +303,15 @@ class MajorMarkingState final
// Concurrent marking uses local live bytes so we may do these accesses
// non-atomically.
void IncrementLiveBytes(MemoryChunk* chunk, intptr_t by) {
chunk->live_byte_count_ += by;
chunk->live_byte_count_.fetch_add(by, std::memory_order_relaxed);
}
intptr_t live_bytes(MemoryChunk* chunk) const {
return chunk->live_byte_count_;
return chunk->live_byte_count_.load(std::memory_order_relaxed);
}
void SetLiveBytes(MemoryChunk* chunk, intptr_t value) {
chunk->live_byte_count_ = value;
chunk->live_byte_count_.store(value, std::memory_order_relaxed);
}
};
......@@ -328,8 +328,7 @@ class MajorAtomicMarkingState final
}
void IncrementLiveBytes(MemoryChunk* chunk, intptr_t by) {
std::atomic_fetch_add(
reinterpret_cast<std::atomic<intptr_t>*>(&chunk->live_byte_count_), by);
chunk->live_byte_count_.fetch_add(by);
}
};
......@@ -346,15 +345,15 @@ class MajorNonAtomicMarkingState final
}
void IncrementLiveBytes(MemoryChunk* chunk, intptr_t by) {
chunk->live_byte_count_ += by;
chunk->live_byte_count_.fetch_add(by, std::memory_order_relaxed);
}
intptr_t live_bytes(MemoryChunk* chunk) const {
return chunk->live_byte_count_;
return chunk->live_byte_count_.load(std::memory_order_relaxed);
}
void SetLiveBytes(MemoryChunk* chunk, intptr_t value) {
chunk->live_byte_count_ = value;
chunk->live_byte_count_.store(value, std::memory_order_relaxed);
}
};
......
......@@ -410,7 +410,7 @@ class MemoryChunk : public BasicMemoryChunk {
std::atomic<size_t> progress_bar_;
// Count of bytes marked black on page.
intptr_t live_byte_count_;
std::atomic<intptr_t> live_byte_count_;
// A single slot set for small pages (of size kPageSize) or an array of slot
// set for large pages. In the latter case the number of entries in the array
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment