Commit 3b7f2738 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Fix race when assigning {NativeModule} ids.

R=clemensh@chromium.org
BUG=chromium:801878

Change-Id: I32a3cf3a63dfe073a06066f1db2fb32eb739f153
Reviewed-on: https://chromium-review.googlesource.com/883367Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50836}
parent 625a0e51
......@@ -30,7 +30,6 @@ namespace internal {
namespace wasm {
namespace {
size_t native_module_ids = 0;
#if V8_TARGET_ARCH_X64
#define __ masm->
......@@ -75,6 +74,7 @@ void PatchTrampolineAndStubCalls(
SKIP_ICACHE_FLUSH);
}
}
} // namespace
DisjointAllocationPool::DisjointAllocationPool(Address start, Address end) {
......@@ -271,10 +271,12 @@ WasmCode::~WasmCode() {
}
}
base::AtomicNumber<size_t> NativeModule::next_id_;
NativeModule::NativeModule(uint32_t num_functions, uint32_t num_imports,
bool can_request_more, VirtualMemory* mem,
WasmCodeManager* code_manager)
: instance_id(native_module_ids++),
: instance_id(next_id_.Increment(1)),
code_table_(num_functions),
num_imported_functions_(num_imports),
free_memory_(reinterpret_cast<Address>(mem->address()),
......
......@@ -274,7 +274,7 @@ class V8_EXPORT_PRIVATE NativeModule final {
}
};
static base::AtomicNumber<uint32_t> next_id_;
static base::AtomicNumber<size_t> next_id_;
NativeModule(const NativeModule&) = delete;
NativeModule& operator=(const NativeModule&) = delete;
NativeModule(uint32_t num_functions, uint32_t num_imports,
......
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