Commit 5fc3ac29 authored by gdeepti's avatar gdeepti Committed by Commit bot

[wasm] Identify wasm functions with index into the function tables.

Currently, the default name for wasm functions in generated code is 'wasm', tag wasm functions with the index into the function table to identify functions. Snippets of sample output with --print-code below.

Before:
--- Code ---
kind = WASM_FUNCTION
name = wasm
compiler = turbofan

After:
--- Code ---
kind = WASM_FUNCTION
name = wasm#200
compiler = turbofan

R=mtrofin@chromium.org

Review-Url: https://codereview.chromium.org/2690113012
Cr-Commit-Position: refs/heads/master@{#43296}
parent d9bc0ffb
...@@ -4011,6 +4011,13 @@ SourcePositionTable* WasmCompilationUnit::BuildGraphForWasmFunction( ...@@ -4011,6 +4011,13 @@ SourcePositionTable* WasmCompilationUnit::BuildGraphForWasmFunction(
return source_position_table; return source_position_table;
} }
char* WasmCompilationUnit::GetTaggedFunctionName(
const wasm::WasmFunction* function) {
snprintf(function_name_, sizeof(function_name_), "wasm#%d",
function->func_index);
return function_name_;
}
WasmCompilationUnit::WasmCompilationUnit(wasm::ErrorThrower* thrower, WasmCompilationUnit::WasmCompilationUnit(wasm::ErrorThrower* thrower,
Isolate* isolate, Isolate* isolate,
wasm::ModuleBytesEnv* module_env, wasm::ModuleBytesEnv* module_env,
...@@ -4031,7 +4038,7 @@ WasmCompilationUnit::WasmCompilationUnit(wasm::ErrorThrower* thrower, ...@@ -4031,7 +4038,7 @@ WasmCompilationUnit::WasmCompilationUnit(wasm::ErrorThrower* thrower,
compilation_zone_(isolate->allocator(), ZONE_NAME), compilation_zone_(isolate->allocator(), ZONE_NAME),
info_(function->name_length != 0 info_(function->name_length != 0
? module_env->wire_bytes.GetNameOrNull(function) ? module_env->wire_bytes.GetNameOrNull(function)
: ArrayVector("wasm"), : CStrVector(GetTaggedFunctionName(function)),
isolate, &compilation_zone_, isolate, &compilation_zone_,
Code::ComputeFlags(Code::WASM_FUNCTION)), Code::ComputeFlags(Code::WASM_FUNCTION)),
job_(), job_(),
......
...@@ -68,11 +68,14 @@ class WasmCompilationUnit final { ...@@ -68,11 +68,14 @@ class WasmCompilationUnit final {
private: private:
SourcePositionTable* BuildGraphForWasmFunction(double* decode_ms); SourcePositionTable* BuildGraphForWasmFunction(double* decode_ms);
char* GetTaggedFunctionName(const wasm::WasmFunction* function);
wasm::ErrorThrower* thrower_; wasm::ErrorThrower* thrower_;
Isolate* isolate_; Isolate* isolate_;
wasm::ModuleBytesEnv* module_env_; wasm::ModuleBytesEnv* module_env_;
const wasm::WasmFunction* function_; const wasm::WasmFunction* function_;
// Function name is tagged with uint32 func_index - wasm#<func_index>
char function_name_[16];
// The graph zone is deallocated at the end of ExecuteCompilation. // The graph zone is deallocated at the end of ExecuteCompilation.
std::unique_ptr<Zone> graph_zone_; std::unique_ptr<Zone> graph_zone_;
JSGraph* jsgraph_; JSGraph* jsgraph_;
......
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