From 5a92a1709c547920920adf05feaef518a101d573 Mon Sep 17 00:00:00 2001 From: mtrofin Date: Thu, 18 Feb 2016 08:51:43 -0800 Subject: [PATCH] Names for wasm stubs. Synthetic names for wasm-to-js functions, for debug scenarios. BUG= Review URL: https://codereview.chromium.org/1709893002 Cr-Commit-Position: refs/heads/master@{#34124} --- src/compiler/wasm-compiler.cc | 42 +++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc index 109bfedd36..6742d987ff 100644 --- a/src/compiler/wasm-compiler.cc +++ b/src/compiler/wasm-compiler.cc @@ -2007,9 +2007,29 @@ Handle CompileJSToWasmWrapper( &zone, false, params + 1, CallDescriptor::kNoFlags); // TODO(titzer): this is technically a WASM wrapper, not a wasm function. Code::Flags flags = Code::ComputeFlags(Code::WASM_FUNCTION); - CompilationInfo info("js-to-wasm", isolate, &zone, flags); + bool debugging = +#if DEBUG + true; +#else + FLAG_print_opt_code || FLAG_trace_turbo || FLAG_trace_turbo_graph; +#endif + const char* func_name = "js-to-wasm"; + + static unsigned id = 0; + Vector buffer; + if (debugging) { + buffer = Vector::New(128); + SNPrintF(buffer, "js-to-wasm#%d", id); + func_name = buffer.start(); + } + + CompilationInfo info(func_name, isolate, &zone, flags); Handle code = Pipeline::GenerateCodeForTesting(&info, incoming, &graph, nullptr); + if (debugging) { + buffer.Dispose(); + } + RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, "js-to-wasm", index, module->module->GetName(func->name_offset)); // Set the JSFunction's machine code. @@ -2069,8 +2089,26 @@ Handle CompileWasmToJSWrapper(Isolate* isolate, wasm::ModuleEnv* module, CallDescriptor* incoming = module->GetWasmCallDescriptor(&zone, func->sig); // TODO(titzer): this is technically a WASM wrapper, not a wasm function. Code::Flags flags = Code::ComputeFlags(Code::WASM_FUNCTION); - CompilationInfo info("wasm-to-js", isolate, &zone, flags); + bool debugging = +#if DEBUG + true; +#else + FLAG_print_opt_code || FLAG_trace_turbo || FLAG_trace_turbo_graph; +#endif + const char* func_name = "wasm-to-js"; + static unsigned id = 0; + Vector buffer; + if (debugging) { + buffer = Vector::New(128); + SNPrintF(buffer, "wasm-to-js#%d", id); + func_name = buffer.start(); + } + + CompilationInfo info(func_name, isolate, &zone, flags); code = Pipeline::GenerateCodeForTesting(&info, incoming, &graph, nullptr); + if (debugging) { + buffer.Dispose(); + } RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, "wasm-to-js", index, module->module->GetName(func->name_offset));