Commit 34499e98 authored by Peter Kasting's avatar Peter Kasting Committed by V8 LUCI CQ

Fix atomic initialization to work with C++20.

Bug: chromium:1284275
Change-Id: I727950c0bed499050ff550e90b9da07404057abe
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3630348
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80454}
parent e57f4bb3
......@@ -36,7 +36,12 @@ size_t gNumCodeObjects = 0;
CodeProtectionInfoListEntry* gCodeObjects = nullptr;
std::atomic_size_t gRecoveredTrapCount = {0};
#if !defined(__cpp_lib_atomic_value_initialization) || \
__cpp_lib_atomic_value_initialization < 201911L
std::atomic_flag MetadataLock::spinlock_ = ATOMIC_FLAG_INIT;
#else
std::atomic_flag MetadataLock::spinlock_;
#endif
MetadataLock::MetadataLock() {
if (g_thread_in_wasm_code) {
......
......@@ -120,16 +120,22 @@ class CompilationUnitQueues {
// Add one first queue, to add units to.
queues_.emplace_back(std::make_unique<QueueImpl>(0));
#if !defined(__cpp_lib_atomic_value_initialization) || \
__cpp_lib_atomic_value_initialization < 201911L
for (auto& atomic_counter : num_units_) {
std::atomic_init(&atomic_counter, size_t{0});
}
#endif
top_tier_compiled_ =
std::make_unique<std::atomic<bool>[]>(num_declared_functions);
#if !defined(__cpp_lib_atomic_value_initialization) || \
__cpp_lib_atomic_value_initialization < 201911L
for (int i = 0; i < num_declared_functions; i++) {
std::atomic_init(&top_tier_compiled_.get()[i], false);
}
#endif
}
Queue* GetQueueForTask(int task_id) {
......@@ -298,7 +304,10 @@ class CompilationUnitQueues {
struct BigUnitsQueue {
BigUnitsQueue() {
#if !defined(__cpp_lib_atomic_value_initialization) || \
__cpp_lib_atomic_value_initialization < 201911L
for (auto& atomic : has_units) std::atomic_init(&atomic, false);
#endif
}
base::Mutex mutex;
......
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