Commit 3410d142 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Postpone trap handler registration until publish

Trap handler registration happens under a spin lock, which causes lots
of wasted cycles. With 48 background compilation threads, half of the
wall-clock time is being spent on that spin lock.
Moving this registration inside {PublishCodeLocked} avoids any lock
contention (if a single module is being compiled), since we already
sequentialize code publication. This speeds up background compilation
for large numbers of background tasks, and has no measurable effect for
small numbers.

R=ahaas@chromium.org

Bug: v8:8916
Change-Id: I572b53b9b581e4d5f6e441f6685350017d08d0be
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1634928Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61957}
parent 27ca3b3d
......@@ -920,8 +920,6 @@ std::unique_ptr<WasmCode> NativeModule::AddCodeWithCodeSpace(
code->MaybePrint();
code->Validate();
code->RegisterTrapHandlerData();
return code;
}
......@@ -990,6 +988,8 @@ WasmCode* NativeModule::PublishCodeLocked(std::unique_ptr<WasmCode> code) {
jump_table_->instruction_start(), slot_idx, code->instruction_start(),
WasmCode::kFlushICache);
}
code->RegisterTrapHandlerData();
}
WasmCodeRefScope::AddRef(code.get());
WasmCode* result = code.get();
......@@ -1017,8 +1017,6 @@ WasmCode* NativeModule::AddDeserializedCode(
std::move(protected_instructions), std::move(reloc_info),
std::move(source_position_table), kind, tier}};
code->RegisterTrapHandlerData();
// Note: we do not flush the i-cache here, since the code needs to be
// relocated anyway. The caller is responsible for flushing the i-cache later.
......
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