Commit 91111a40 authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[wasm] Add trace events for wrapper compilation

This adds a few more trace events, also tracing the number of wrappers.
This can help to understand instantiation time better.

R=ahaas@chromium.org

Bug: v8:12287
Change-Id: Ic1a03b2e278af64908f0dc45cd5db60ecf7c79f5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3226323Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77412}
parent 7366f6e2
......@@ -3737,6 +3737,7 @@ class CompileJSToWasmWrapperJob final : public JobTask {
void CompileJsToWasmWrappers(Isolate* isolate, const WasmModule* module,
Handle<FixedArray>* export_wrappers_out) {
TRACE_EVENT0("v8.wasm", "wasm.CompileJsToWasmWrappers");
*export_wrappers_out = isolate->factory()->NewFixedArray(
MaxNumExportWrappers(module), AllocationType::kOld);
......@@ -3757,16 +3758,22 @@ void CompileJsToWasmWrappers(Isolate* isolate, const WasmModule* module,
}
}
auto job =
std::make_unique<CompileJSToWasmWrapperJob>(&queue, &compilation_units);
if (FLAG_wasm_num_compilation_tasks > 0) {
auto job_handle = V8::GetCurrentPlatform()->PostJob(
TaskPriority::kUserVisible, std::move(job));
// Wait for completion, while contributing to the work.
job_handle->Join();
} else {
job->Run(nullptr);
{
// This is nested inside the event above, so the name can be less
// descriptive. It's mainly to log the number of wrappers.
TRACE_EVENT1("v8.wasm", "wasm.JsToWasmWrapperCompilation", "num_wrappers",
compilation_units.size());
auto job =
std::make_unique<CompileJSToWasmWrapperJob>(&queue, &compilation_units);
if (FLAG_wasm_num_compilation_tasks > 0) {
auto job_handle = V8::GetCurrentPlatform()->PostJob(
TaskPriority::kUserVisible, std::move(job));
// Wait for completion, while contributing to the work.
job_handle->Join();
} else {
job->Run(nullptr);
}
}
// Finalize compilation jobs in the main thread.
......
......@@ -66,6 +66,7 @@ class CompileImportWrapperJob final : public JobTask {
}
void Run(JobDelegate* delegate) override {
TRACE_EVENT0("v8.wasm", "wasm.CompileImportWrapperJob.Run");
while (base::Optional<WasmImportWrapperCache::CacheKey> key =
queue_->pop()) {
// TODO(wasm): Batch code publishing, to avoid repeated locking and
......@@ -1493,6 +1494,8 @@ bool InstanceBuilder::ProcessImportedGlobal(Handle<WasmInstanceObject> instance,
void InstanceBuilder::CompileImportWrappers(
Handle<WasmInstanceObject> instance) {
int num_imports = static_cast<int>(module_->import_table.size());
TRACE_EVENT1("v8.wasm", "wasm.CompileImportWrappers", "num_imports",
num_imports);
NativeModule* native_module = instance->module_object().native_module();
WasmImportWrapperCache::ModificationScope cache_scope(
native_module->import_wrapper_cache());
......
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