From 81b1a2c6a528de09745ffc8c8605438a7acc4c02 Mon Sep 17 00:00:00 2001 From: Lukas Piatkowski Date: Thu, 1 Dec 2016 09:37:25 -0800 Subject: [PATCH] Propagate bytecode offset in SamplingProfiler and use it to name unnamed functions Reviewed By: cwdick Differential Revision: D4251568 fbshipit-source-id: 2343d8f6a5b2f247a7af1bbd0112bed8edadcbfe --- local-cli/server/middleware/jscProfilerMiddleware.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/local-cli/server/middleware/jscProfilerMiddleware.js b/local-cli/server/middleware/jscProfilerMiddleware.js index 2fbb40a72..2410f02f0 100644 --- a/local-cli/server/middleware/jscProfilerMiddleware.js +++ b/local-cli/server/middleware/jscProfilerMiddleware.js @@ -50,8 +50,13 @@ class TreeTransformator { line: tree.lineNumber, column: tree.columnNumber, }); - tree.functionName = tree.functionName || original.name + const functionName = original.name || (path.posix.basename(original.source || '') + ':' + original.line); + if (tree.functionName === '(unnamed builtin)') { + tree.functionName += ':' + functionName; + } else { + tree.functionName = tree.functionName || functionName; + } tree.scriptId = tree.id; tree.url = 'file://' + original.source; tree.lineNumber = original.line;