mirror of https://github.com/lukechilds/node.git
Browse Source
This change cleans up outstanding comments on #3032. It improves error handling when no isolate file is provided and adds the --prof-process flag to the node binary which executes the tick processor on the provided isolate file. PR-URL: https://github.com/nodejs/node/pull/4021 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Evan Lucas <evanlucas@me.com>process-exit-stdio-flushing
Matt Loring
9 years ago
committed by
Ben Noordhuis
12 changed files with 88 additions and 107 deletions
@ -0,0 +1,44 @@ |
|||
'use strict'; |
|||
var cp = require('child_process'); |
|||
var fs = require('fs'); |
|||
var path = require('path'); |
|||
|
|||
var scriptFiles = [ |
|||
'internal/v8_prof_polyfill', |
|||
'v8/tools/splaytree', |
|||
'v8/tools/codemap', |
|||
'v8/tools/csvparser', |
|||
'v8/tools/consarray', |
|||
'v8/tools/profile', |
|||
'v8/tools/profile_view', |
|||
'v8/tools/logreader', |
|||
'v8/tools/tickprocessor', |
|||
'v8/tools/SourceMap', |
|||
'v8/tools/tickprocessor-driver' |
|||
]; |
|||
var tempScript = 'tick-processor-tmp-' + process.pid; |
|||
var tempNm = 'mac-nm-' + process.pid; |
|||
|
|||
process.on('exit', function() { |
|||
try { fs.unlinkSync(tempScript); } catch (e) {} |
|||
try { fs.unlinkSync(tempNm); } catch (e) {} |
|||
}); |
|||
process.on('uncaughtException', function(err) { |
|||
try { fs.unlinkSync(tempScript); } catch (e) {} |
|||
try { fs.unlinkSync(tempNm); } catch (e) {} |
|||
throw err; |
|||
}); |
|||
|
|||
scriptFiles.forEach(function(script) { |
|||
fs.appendFileSync(tempScript, process.binding('natives')[script]); |
|||
}); |
|||
var tickArguments = [tempScript]; |
|||
if (process.platform === 'darwin') { |
|||
fs.writeFileSync(tempNm, process.binding('natives')['v8/tools/mac-nm'], |
|||
{ mode: 0o555 }); |
|||
tickArguments.push('--mac', '--nm=' + path.join(process.cwd(), tempNm)); |
|||
} else if (process.platform === 'win32') { |
|||
tickArguments.push('--windows'); |
|||
} |
|||
tickArguments.push.apply(tickArguments, process.argv.slice(1)); |
|||
cp.spawn(process.execPath, tickArguments, { stdio: 'inherit' }); |
@ -1,51 +0,0 @@ |
|||
'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' }); |
|||
}); |
Loading…
Reference in new issue