Commit 037e64c8 authored by Paolo Severini's avatar Paolo Severini Committed by Commit Bot

[wasm] Generate distinct IR trace files for Wasm import call wrappers

Currently, when running with --trace-turbo, V8 generates a different
.json file for each wasm-to-js thunk that it compiles, but these files
all have the same name "turbo-wasm-to-js-0.json", and only one file is
generated.
This makes it difficult to actually examine the difference in the IR
for this call wrappers produced for different signatures.

This patch fixes this by naming each trace file as:
"wasm-to-js-<kind>-<signature>-0.json", like for example
"turbo-wasm-to-js-5-ii-i-0.json".

Change-Id: Iebb73829cddd4f6bbf9d02ed1ce94a80dcfa5ca7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2316834
Commit-Queue: Paolo Severini <paolosev@microsoft.com>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69085}
parent 413bee87
......@@ -6974,7 +6974,12 @@ wasm::WasmCompilationResult CompileWasmImportCallWrapper(
env->enabled_features);
builder.BuildWasmImportCallWrapper(kind);
const char* func_name = "wasm-to-js";
// Build a name in the form "wasm-to-js-<kind>-<signature>".
constexpr size_t kMaxNameLen = 128;
char func_name[kMaxNameLen];
int name_prefix_len = SNPrintF(VectorOf(func_name, kMaxNameLen),
"wasm-to-js-%d-", static_cast<int>(kind));
PrintSignature(VectorOf(func_name, kMaxNameLen) + name_prefix_len, sig, '-');
// Schedule and compile to machine code.
CallDescriptor* incoming =
......
......@@ -650,7 +650,8 @@ size_t EstimateStoredSize(const WasmModule* module) {
VectorSize(module->exceptions) + VectorSize(module->elem_segments);
}
size_t PrintSignature(Vector<char> buffer, const wasm::FunctionSig* sig) {
size_t PrintSignature(Vector<char> buffer, const wasm::FunctionSig* sig,
char delimiter) {
if (buffer.empty()) return 0;
size_t old_size = buffer.size();
auto append_char = [&buffer](char c) {
......@@ -661,7 +662,7 @@ size_t PrintSignature(Vector<char> buffer, const wasm::FunctionSig* sig) {
for (wasm::ValueType t : sig->parameters()) {
append_char(t.short_name());
}
append_char(':');
append_char(delimiter);
for (wasm::ValueType t : sig->returns()) {
append_char(t.short_name());
}
......
......@@ -539,10 +539,12 @@ class TruncatedUserString {
char buffer_[kMaxLen];
};
// Print the signature into the given {buffer}. If {buffer} is non-empty, it
// will be null-terminated, even if the signature is cut off. Returns the number
// of characters written, excluding the terminating null-byte.
size_t PrintSignature(Vector<char> buffer, const wasm::FunctionSig*);
// Print the signature into the given {buffer}, using {delimiter} as separator
// between parameter types and return types. If {buffer} is non-empty, it will
// be null-terminated, even if the signature is cut off. Returns the number of
// characters written, excluding the terminating null-byte.
size_t PrintSignature(Vector<char> buffer, const wasm::FunctionSig*,
char delimiter = ':');
} // namespace wasm
} // namespace internal
......
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