Commit 8442795a authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Fix destructor ordering for {NativeModule}.

R=clemensh@chromium.org
BUG=v8:7921

Change-Id: I82a1c5cff7fd00603a509221b448b11d82edee7e
Reviewed-on: https://chromium-review.googlesource.com/1131176Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54356}
parent d87287bc
...@@ -725,6 +725,7 @@ void NativeModule::DisableTrapHandler() { ...@@ -725,6 +725,7 @@ void NativeModule::DisableTrapHandler() {
NativeModule::~NativeModule() { NativeModule::~NativeModule() {
TRACE_HEAP("Deleting native module: %p\n", reinterpret_cast<void*>(this)); TRACE_HEAP("Deleting native module: %p\n", reinterpret_cast<void*>(this));
compilation_state_.reset(); // Cancels tasks, needs to be done first.
wasm_code_manager_->FreeNativeModule(this); wasm_code_manager_->FreeNativeModule(this);
} }
......
...@@ -387,15 +387,19 @@ class V8_EXPORT_PRIVATE NativeModule final { ...@@ -387,15 +387,19 @@ class V8_EXPORT_PRIVATE NativeModule final {
// Jump table used to easily redirect wasm function calls. // Jump table used to easily redirect wasm function calls.
WasmCode* jump_table_ = nullptr; WasmCode* jump_table_ = nullptr;
// The compilation state keeps track of compilation tasks for this module.
// Note that its destructor blocks until all tasks are finished/aborted and
// hence needs to be destructed first when this native module dies.
std::unique_ptr<CompilationState, CompilationStateDeleter> compilation_state_; std::unique_ptr<CompilationState, CompilationStateDeleter> compilation_state_;
// This mutex protects concurrent calls to {AddCode} and {AddCodeCopy}.
mutable base::Mutex allocation_mutex_;
DisjointAllocationPool free_code_space_; DisjointAllocationPool free_code_space_;
DisjointAllocationPool allocated_code_space_; DisjointAllocationPool allocated_code_space_;
std::list<VirtualMemory> owned_code_space_; std::list<VirtualMemory> owned_code_space_;
WasmCodeManager* wasm_code_manager_; WasmCodeManager* wasm_code_manager_;
// This mutex protects concurrent calls to {AddCode} and {AddCodeCopy}.
mutable base::Mutex allocation_mutex_;
size_t committed_code_space_ = 0; size_t committed_code_space_ = 0;
int modification_scope_depth_ = 0; int modification_scope_depth_ = 0;
bool can_request_more_memory_; bool can_request_more_memory_;
......
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