Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: single, cross-platform tick processor #2868

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions test/parallel/test-tick-processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var common = require('../common');
common.refreshTmpDir();
process.chdir(common.tmpDir);
var processor =
path.join(common.testDir, '..', 'tools', 'v8-prof', getScriptName());
path.join(common.testDir, '..', 'tools', 'v8-prof', 'tick-processor.js');
// Unknown checked for to prevent flakiness, if pattern is not found,
// then a large number of unknown ticks should be present
runTest(/LazyCompile.*\[eval\]:1|.*% UNKNOWN/,
Expand Down Expand Up @@ -43,19 +43,9 @@ function runTest(pattern, code) {
assert.fail('There should be a single log file.');
}
var log = matches[0];
var out = cp.execSync(processor + ' --call-graph-size=10 ' + log,
var out = cp.execSync(process.execPath + ' ' + processor +
' --call-graph-size=10 ' + log,
{encoding: 'utf8'});
assert(out.match(pattern));
fs.unlinkSync(log);
}

function getScriptName() {
switch (process.platform) {
case 'darwin':
return 'mac-tick-processor';
case 'win32':
return 'windows-tick-processor.bat';
default:
return 'linux-tick-processor';
}
}
23 changes: 0 additions & 23 deletions tools/v8-prof/linux-tick-processor

This file was deleted.

7 changes: 0 additions & 7 deletions tools/v8-prof/mac-tick-processor

This file was deleted.

51 changes: 51 additions & 0 deletions tools/v8-prof/tick-processor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'use strict';
var cp = require('child_process');
var fs = require('fs');
var path = require('path');

var toolsPath = path.join(__dirname, '..', '..', 'deps', 'v8', 'tools');
var scriptFiles = [
path.join(__dirname, 'polyfill.js'),
path.join(toolsPath, 'splaytree.js'),
path.join(toolsPath, 'codemap.js'),
path.join(toolsPath, 'csvparser.js'),
path.join(toolsPath, 'consarray.js'),
path.join(toolsPath, 'csvparser.js'),
path.join(toolsPath, 'consarray.js'),
path.join(toolsPath, 'profile.js'),
path.join(toolsPath, 'profile_view.js'),
path.join(toolsPath, 'logreader.js'),
path.join(toolsPath, 'tickprocessor.js'),
path.join(toolsPath, 'SourceMap.js'),
path.join(toolsPath, 'tickprocessor-driver.js')];
var tempScript = path.join(__dirname, 'tick-processor-tmp-' + process.pid);

process.on('exit', function() {
try { fs.unlinkSync(tempScript); } catch (e) {}
});
process.on('uncaughtException', function(err) {
try { fs.unlinkSync(tempScript); } catch (e) {}
throw err;
});

var inStreams = scriptFiles.map(function(f) {
return fs.createReadStream(f);
});
var outStream = fs.createWriteStream(tempScript);
inStreams.reduce(function(prev, curr, i) {
prev.on('end', function() {
curr.pipe(outStream, { end: i === inStreams.length - 1});
});
return curr;
});
inStreams[0].pipe(outStream, { end: false });
outStream.on('close', function() {
var tickArguments = [tempScript];
if (process.platform === 'darwin') {
tickArguments.push('--mac', '--nm=' + path.join(toolsPath, 'mac-nm'));
} else if (process.platform === 'win32') {
tickArguments.push('--windows');
}
tickArguments.push.apply(tickArguments, process.argv.slice(2));
var processTicks = cp.spawn(process.execPath, tickArguments, { stdio: 'inherit' });
});
19 changes: 0 additions & 19 deletions tools/v8-prof/windows-tick-processor.bat

This file was deleted.