From 9135bc219b27801c07f8d71e227f3963e27d2db2 Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Thu, 23 May 2019 12:02:15 -0400 Subject: [PATCH] deps: V8: use ATOMIC_VAR_INIT instead of std::atomic_init MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `std::atomic_init` is not implemented on all platforms. Backport-PR-URL: https://github.com/nodejs/node/pull/30109 PR-URL: https://github.com/nodejs/node/pull/27375 Reviewed-By: Michaƫl Zasso Reviewed-By: Ujjwal Sharma Reviewed-By: Refael Ackermann Reviewed-By: Matteo Collina Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott --- common.gypi | 2 +- deps/v8/src/wasm/module-compiler.cc | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/common.gypi b/common.gypi index e2a3c99e61ba23..30357657690169 100644 --- a/common.gypi +++ b/common.gypi @@ -38,7 +38,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.5', + 'v8_embedder_string': '-node.6', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/wasm/module-compiler.cc b/deps/v8/src/wasm/module-compiler.cc index c264bac96e8f1d..2847b02c643d0b 100644 --- a/deps/v8/src/wasm/module-compiler.cc +++ b/deps/v8/src/wasm/module-compiler.cc @@ -152,9 +152,6 @@ class CompilationUnitQueues { for (int task_id = 0; task_id < max_tasks; ++task_id) { queues_[task_id].next_steal_task_id = next_task_id(task_id); } - for (auto& atomic_counter : num_units_) { - std::atomic_init(&atomic_counter, size_t{0}); - } } base::Optional GetNextUnit( @@ -257,14 +254,15 @@ class CompilationUnitQueues { }; struct BigUnitsQueue { - BigUnitsQueue() { - for (auto& atomic : has_units) std::atomic_init(&atomic, false); - } + BigUnitsQueue() = default; base::Mutex mutex; // Can be read concurrently to check whether any elements are in the queue. - std::atomic has_units[kNumTiers]; + std::atomic_bool has_units[kNumTiers] = { + ATOMIC_VAR_INIT(false), + ATOMIC_VAR_INIT(false) + }; // Protected by {mutex}: std::priority_queue units[kNumTiers]; @@ -273,8 +271,11 @@ class CompilationUnitQueues { std::vector queues_; BigUnitsQueue big_units_queue_; - std::atomic num_units_[kNumTiers]; - std::atomic next_queue_to_add{0}; + std::atomic_size_t num_units_[kNumTiers] = { + ATOMIC_VAR_INIT(0), + ATOMIC_VAR_INIT(0) + }; + std::atomic_int next_queue_to_add{0}; int next_task_id(int task_id) const { int next = task_id + 1; @@ -481,7 +482,7 @@ class CompilationStateImpl { // Compilation error, atomically updated. This flag can be updated and read // using relaxed semantics. - std::atomic compile_failed_{false}; + std::atomic_bool compile_failed_{false}; const int max_background_tasks_ = 0;