Commit f03bf4c4 authored by Camillo Bruni's avatar Camillo Bruni Committed by V8 LUCI CQ

[zone-stats] Fix race-condition when reading Zone stats across threads

Bug: v8:12639
Change-Id: I10aaa576fdc84d848aa28ed8e07d5793a0954ff1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3472023Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79173}
parent da51af28
......@@ -39,8 +39,7 @@ Zone::Zone(AccountingAllocator* allocator, const char* name,
Zone::~Zone() {
DeleteAll();
DCHECK_EQ(segment_bytes_allocated_, 0);
DCHECK_EQ(segment_bytes_allocated_.load(), 0);
}
void* Zone::AsanNew(size_t size) {
......
......@@ -198,12 +198,12 @@ class V8_EXPORT_PRIVATE Zone final {
static const size_t kMaximumSegmentSize = 32 * KB;
// The number of bytes allocated in this zone so far.
size_t allocation_size_ = 0;
std::atomic<size_t> allocation_size_ = {0};
// The number of bytes allocated in segments. Note that this number
// includes memory allocated from the OS but not yet allocated from
// the zone.
size_t segment_bytes_allocated_ = 0;
std::atomic<size_t> segment_bytes_allocated_ = {0};
// Expand the Zone to hold at least 'size' more bytes and allocate
// the bytes. Returns the address of the newly allocated chunk of
......@@ -226,10 +226,10 @@ class V8_EXPORT_PRIVATE Zone final {
#ifdef V8_ENABLE_PRECISE_ZONE_STATS
TypeStats type_stats_;
size_t allocation_size_for_tracing_ = 0;
std::atomic<size_t> allocation_size_for_tracing_ = {0};
// The number of bytes freed in this zone so far.
size_t freed_size_for_tracing_ = 0;
stdd::atomic<size_t> freed_size_for_tracing_ = {0};
#endif
friend class ZoneScope;
......
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