• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const {
4  ArrayPrototypePush,
5  ArrayPrototypeSlice,
6  JSONStringify,
7} = primordials;
8
9const vm = require('vm');
10
11const scriptFiles = [
12  'internal/v8_prof_polyfill',
13  'internal/deps/v8/tools/splaytree',
14  'internal/deps/v8/tools/codemap',
15  'internal/deps/v8/tools/csvparser',
16  'internal/deps/v8/tools/consarray',
17  'internal/deps/v8/tools/profile',
18  'internal/deps/v8/tools/profile_view',
19  'internal/deps/v8/tools/logreader',
20  'internal/deps/v8/tools/arguments',
21  'internal/deps/v8/tools/tickprocessor',
22  'internal/deps/v8/tools/SourceMap',
23  'internal/deps/v8/tools/tickprocessor-driver',
24];
25let script = '';
26
27for (const s of scriptFiles) {
28  script += internalBinding('natives')[s] + '\n';
29}
30
31const tickArguments = [];
32if (process.platform === 'darwin') {
33  ArrayPrototypePush(tickArguments, '--mac');
34} else if (process.platform === 'win32') {
35  ArrayPrototypePush(tickArguments, '--windows');
36}
37ArrayPrototypePush(tickArguments,
38                   ...ArrayPrototypeSlice(process.argv, 1));
39script = `(function(module, require) {
40  arguments = ${JSONStringify(tickArguments)};
41  function write (s) { process.stdout.write(s) }
42  function printErr(err) { console.error(err); }
43  ${script}
44})`;
45vm.runInThisContext(script)(module, require);
46