Propagate bytecode offset in SamplingProfiler and use it to name unnamed functions

Reviewed By: cwdick

Differential Revision: D4251568

fbshipit-source-id: 2343d8f6a5b2f247a7af1bbd0112bed8edadcbfe
This commit is contained in:
Lukas Piatkowski 2016-12-01 09:37:25 -08:00 committed by Facebook Github Bot
parent 48b95f08fb
commit 81b1a2c6a5
1 changed files with 6 additions and 1 deletions

View File

@ -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;