Skip to content

Commit 6ea8ec1

Browse files
Matt Loringrvagg
Matt Loring
authored andcommitted
tools: single, cross-platform tick processor
Currently there are three separate tick processor scripts for mac, windows, and linux. These have been replaced with a single node.js script to improve maintainability and remove the need to preserve parallel logic in these separate places. PR-URL: #2868 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
1 parent 2600fb8 commit 6ea8ec1

File tree

5 files changed

+54
-62
lines changed

5 files changed

+54
-62
lines changed

test/parallel/test-tick-processor.js

+3-13
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var common = require('../common');
88
common.refreshTmpDir();
99
process.chdir(common.tmpDir);
1010
var processor =
11-
path.join(common.testDir, '..', 'tools', 'v8-prof', getScriptName());
11+
path.join(common.testDir, '..', 'tools', 'v8-prof', 'tick-processor.js');
1212
// Unknown checked for to prevent flakiness, if pattern is not found,
1313
// then a large number of unknown ticks should be present
1414
runTest(/LazyCompile.*\[eval\]:1|.*% UNKNOWN/,
@@ -43,19 +43,9 @@ function runTest(pattern, code) {
4343
assert.fail('There should be a single log file.');
4444
}
4545
var log = matches[0];
46-
var out = cp.execSync(processor + ' --call-graph-size=10 ' + log,
46+
var out = cp.execSync(process.execPath + ' ' + processor +
47+
' --call-graph-size=10 ' + log,
4748
{encoding: 'utf8'});
4849
assert(out.match(pattern));
4950
fs.unlinkSync(log);
5051
}
51-
52-
function getScriptName() {
53-
switch (process.platform) {
54-
case 'darwin':
55-
return 'mac-tick-processor';
56-
case 'win32':
57-
return 'windows-tick-processor.bat';
58-
default:
59-
return 'linux-tick-processor';
60-
}
61-
}

tools/v8-prof/linux-tick-processor

-23
This file was deleted.

tools/v8-prof/mac-tick-processor

-7
This file was deleted.

tools/v8-prof/tick-processor.js

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
'use strict';
2+
var cp = require('child_process');
3+
var fs = require('fs');
4+
var path = require('path');
5+
6+
var toolsPath = path.join(__dirname, '..', '..', 'deps', 'v8', 'tools');
7+
var scriptFiles = [
8+
path.join(__dirname, 'polyfill.js'),
9+
path.join(toolsPath, 'splaytree.js'),
10+
path.join(toolsPath, 'codemap.js'),
11+
path.join(toolsPath, 'csvparser.js'),
12+
path.join(toolsPath, 'consarray.js'),
13+
path.join(toolsPath, 'csvparser.js'),
14+
path.join(toolsPath, 'consarray.js'),
15+
path.join(toolsPath, 'profile.js'),
16+
path.join(toolsPath, 'profile_view.js'),
17+
path.join(toolsPath, 'logreader.js'),
18+
path.join(toolsPath, 'tickprocessor.js'),
19+
path.join(toolsPath, 'SourceMap.js'),
20+
path.join(toolsPath, 'tickprocessor-driver.js')];
21+
var tempScript = path.join(__dirname, 'tick-processor-tmp-' + process.pid);
22+
23+
process.on('exit', function() {
24+
try { fs.unlinkSync(tempScript); } catch (e) {}
25+
});
26+
process.on('uncaughtException', function(err) {
27+
try { fs.unlinkSync(tempScript); } catch (e) {}
28+
throw err;
29+
});
30+
31+
var inStreams = scriptFiles.map(function(f) {
32+
return fs.createReadStream(f);
33+
});
34+
var outStream = fs.createWriteStream(tempScript);
35+
inStreams.reduce(function(prev, curr, i) {
36+
prev.on('end', function() {
37+
curr.pipe(outStream, { end: i === inStreams.length - 1});
38+
});
39+
return curr;
40+
});
41+
inStreams[0].pipe(outStream, { end: false });
42+
outStream.on('close', function() {
43+
var tickArguments = [tempScript];
44+
if (process.platform === 'darwin') {
45+
tickArguments.push('--mac', '--nm=' + path.join(toolsPath, 'mac-nm'));
46+
} else if (process.platform === 'win32') {
47+
tickArguments.push('--windows');
48+
}
49+
tickArguments.push.apply(tickArguments, process.argv.slice(2));
50+
var processTicks = cp.spawn(process.execPath, tickArguments, { stdio: 'inherit' });
51+
});

tools/v8-prof/windows-tick-processor.bat

-19
This file was deleted.

0 commit comments

Comments
 (0)