summaryrefslogtreecommitdiff
path: root/lib/internal/v8_prof_processor.js
blob: d647d4749f9adc12111c803bb5dbfa81350bc655 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'use strict';

const {
  JSONStringify,
} = primordials;

const vm = require('vm');

const scriptFiles = [
  'internal/v8_prof_polyfill',
  'internal/deps/v8/tools/splaytree',
  'internal/deps/v8/tools/codemap',
  'internal/deps/v8/tools/csvparser',
  'internal/deps/v8/tools/consarray',
  'internal/deps/v8/tools/profile',
  'internal/deps/v8/tools/profile_view',
  'internal/deps/v8/tools/logreader',
  'internal/deps/v8/tools/arguments',
  'internal/deps/v8/tools/tickprocessor',
  'internal/deps/v8/tools/SourceMap',
  'internal/deps/v8/tools/tickprocessor-driver'
];
let script = '';

scriptFiles.forEach((s) => {
  script += internalBinding('natives')[s] + '\n';
});

const tickArguments = [];
if (process.platform === 'darwin') {
  tickArguments.push('--mac');
} else if (process.platform === 'win32') {
  tickArguments.push('--windows');
}
tickArguments.push.apply(tickArguments, process.argv.slice(1));
script = `(function(module, require) {
  arguments = ${JSONStringify(tickArguments)};
  function write (s) { process.stdout.write(s) }
  function printErr(err) { console.error(err); }
  ${script}
})`;
vm.runInThisContext(script)(module, require);