[wasm] Generate a debug name from the function index
Up until now, the debug name of a WebAssembly function was "unknown" if no name was provided in the name section. With this CL we use the function index to generate the name "wasm#index" as the debug name. This debug name is used e.g. for --print-wasm-code or --trace-turbo-graph R=clemensh@chromium.org Change-Id: Ie9b14437fbdef8fd6602eab0d89e415599445099 Reviewed-on: https://chromium-review.googlesource.com/461923 Commit-Queue: Andreas Haas <ahaas@chromium.org> Reviewed-by: Clemens Hammacher <clemensh@chromium.org> Cr-Commit-Position: refs/heads/master@{#44230}
This commit is contained in:
parent
994a34f0fa
commit
f89b2970b8
@ -3890,6 +3890,23 @@ SourcePositionTable* WasmCompilationUnit::BuildGraphForWasmFunction(
|
|||||||
return source_position_table;
|
return source_position_table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
Vector<const char> GetDebugName(Zone* zone, wasm::WasmName name, int index) {
|
||||||
|
if (!name.is_empty()) {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
constexpr int kBufferLength = 15;
|
||||||
|
|
||||||
|
EmbeddedVector<char, kBufferLength> name_vector;
|
||||||
|
int name_len = SNPrintF(name_vector, "wasm#%d", index);
|
||||||
|
DCHECK(name_len > 0 && name_len < name_vector.length());
|
||||||
|
|
||||||
|
char* index_name = zone->NewArray<char>(name_len);
|
||||||
|
memcpy(index_name, name_vector.start(), name_len);
|
||||||
|
return Vector<const char>(index_name, name_len);
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
WasmCompilationUnit::WasmCompilationUnit(Isolate* isolate,
|
WasmCompilationUnit::WasmCompilationUnit(Isolate* isolate,
|
||||||
wasm::ModuleBytesEnv* module_env,
|
wasm::ModuleBytesEnv* module_env,
|
||||||
const wasm::WasmFunction* function)
|
const wasm::WasmFunction* function)
|
||||||
@ -3920,8 +3937,8 @@ WasmCompilationUnit::WasmCompilationUnit(Isolate* isolate,
|
|||||||
InstructionSelector::SupportedMachineOperatorFlags(),
|
InstructionSelector::SupportedMachineOperatorFlags(),
|
||||||
InstructionSelector::AlignmentRequirements()))),
|
InstructionSelector::AlignmentRequirements()))),
|
||||||
compilation_zone_(isolate->allocator(), ZONE_NAME),
|
compilation_zone_(isolate->allocator(), ZONE_NAME),
|
||||||
info_(name, isolate, &compilation_zone_,
|
info_(GetDebugName(&compilation_zone_, name, index), isolate,
|
||||||
Code::ComputeFlags(Code::WASM_FUNCTION)),
|
&compilation_zone_, Code::ComputeFlags(Code::WASM_FUNCTION)),
|
||||||
func_index_(index),
|
func_index_(index),
|
||||||
protected_instructions_(&compilation_zone_) {
|
protected_instructions_(&compilation_zone_) {
|
||||||
// Create and cache this node in the main thread.
|
// Create and cache this node in the main thread.
|
||||||
|
Loading…
Reference in New Issue
Block a user