Commit 494da13b authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[wasm] Simplify logging of js-to-wasm wrappers

Avoid an additional copy of the name, and inline single-use (and small)
functions. Also, use an early exit for the generic wrapper to make the
code simpler.

R=zhin@chromium.org

Bug: v8:11879
Change-Id: Ic66a2c9430f7c3481b9038d2a517c4c76888503b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3132267Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#76600}
parent 760682da
......@@ -142,30 +142,6 @@ WasmCompilationResult WasmCompilationUnit::ExecuteFunctionCompilation(
return result;
}
namespace {
bool must_record_function_compilation(Isolate* isolate) {
return isolate->logger()->is_listening_to_code_events() ||
isolate->is_profiling();
}
PRINTF_FORMAT(3, 4)
void RecordWasmHeapStubCompilation(Isolate* isolate, Handle<Code> code,
const char* format, ...) {
DCHECK(must_record_function_compilation(isolate));
base::ScopedVector<char> buffer(128);
va_list arguments;
va_start(arguments, format);
int len = base::VSNPrintF(buffer, format, arguments);
CHECK_LT(0, len);
va_end(arguments);
Handle<String> name_str =
isolate->factory()->NewStringFromAsciiChecked(buffer.begin());
PROFILE(isolate, CodeCreateEvent(CodeEventListener::STUB_TAG,
Handle<AbstractCode>::cast(code), name_str));
}
} // namespace
// static
void WasmCompilationUnit::CompileWasmFunction(Isolate* isolate,
NativeModule* native_module,
......@@ -243,17 +219,19 @@ void JSToWasmWrapperCompilationUnit::Execute() {
}
Handle<Code> JSToWasmWrapperCompilationUnit::Finalize() {
Handle<Code> code;
if (use_generic_wrapper_) {
code = isolate_->builtins()->code_handle(Builtin::kGenericJSToWasmWrapper);
} else {
CompilationJob::Status status = job_->FinalizeJob(isolate_);
CHECK_EQ(status, CompilationJob::SUCCEEDED);
code = job_->compilation_info()->code();
return isolate_->builtins()->code_handle(Builtin::kGenericJSToWasmWrapper);
}
if (!use_generic_wrapper_ && must_record_function_compilation(isolate_)) {
RecordWasmHeapStubCompilation(
isolate_, code, "%s", job_->compilation_info()->GetDebugName().get());
CompilationJob::Status status = job_->FinalizeJob(isolate_);
CHECK_EQ(status, CompilationJob::SUCCEEDED);
Handle<Code> code = job_->compilation_info()->code();
if (isolate_->logger()->is_listening_to_code_events() ||
isolate_->is_profiling()) {
Handle<String> name = isolate_->factory()->NewStringFromAsciiChecked(
job_->compilation_info()->GetDebugName().get());
PROFILE(isolate_, CodeCreateEvent(CodeEventListener::STUB_TAG,
Handle<AbstractCode>::cast(code), name));
}
return code;
}
......
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