diff options
author | Matt Loring <mattloring@google.com> | 2015-09-14 15:28:27 -0700 |
---|---|---|
committer | Rod Vagg <rod@vagg.org> | 2015-09-22 16:31:38 +1000 |
commit | 6ea8ec1c591777b5ddff314d28bc4cc642971033 (patch) | |
tree | 8af2e4ab7c269c5df48450ded6a2c97fd7f56b15 /tools | |
parent | 2600fb8ae690ac8805bafe15d0c5d2f11ce4acef (diff) | |
download | nodejs-6ea8ec1c591777b5ddff314d28bc4cc642971033.tar.gz nodejs-6ea8ec1c591777b5ddff314d28bc4cc642971033.tar.bz2 nodejs-6ea8ec1c591777b5ddff314d28bc4cc642971033.zip |
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: https://github.com/nodejs/node/pull/2868
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/v8-prof/linux-tick-processor | 23 | ||||
-rwxr-xr-x | tools/v8-prof/mac-tick-processor | 7 | ||||
-rw-r--r-- | tools/v8-prof/tick-processor.js | 51 | ||||
-rwxr-xr-x | tools/v8-prof/windows-tick-processor.bat | 19 |
4 files changed, 51 insertions, 49 deletions
diff --git a/tools/v8-prof/linux-tick-processor b/tools/v8-prof/linux-tick-processor deleted file mode 100755 index ba72b3a2b..000000000 --- a/tools/v8-prof/linux-tick-processor +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash - -umask 077 -TEMP_SCRIPT_FILE="/tmp/node-tick-processor-input-script-$$" -tools_path=`cd $(dirname "$0");pwd` -v8_tools="$tools_path/../../deps/v8/tools" - -cat "$tools_path/polyfill.js" "$v8_tools/splaytree.js" "$v8_tools/codemap.js" \ - "$v8_tools/csvparser.js" "$v8_tools/consarray.js" \ - "$v8_tools/profile.js" "$v8_tools/profile_view.js" \ - "$v8_tools/logreader.js" "$v8_tools/tickprocessor.js" \ - "$v8_tools/SourceMap.js" \ - "$v8_tools/tickprocessor-driver.js" >> "$TEMP_SCRIPT_FILE" - -NODE=${NODE:-node} - -if [ ! -x "$NODE" ] && [ -x "$(dirname "$0")/../../node" ]; then - NODE="$(dirname "$0")/../../node" -fi - -"$NODE" "$TEMP_SCRIPT_FILE" $@ - -rm -f "$TEMP_SCRIPT_FILE" diff --git a/tools/v8-prof/mac-tick-processor b/tools/v8-prof/mac-tick-processor deleted file mode 100755 index 968df80c2..000000000 --- a/tools/v8-prof/mac-tick-processor +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -# A wrapper script to call 'linux-tick-processor' with Mac-specific settings. - -tools_path=`cd $(dirname "$0");pwd` -v8_tools="$tools_path/../../deps/v8/tools" -"$tools_path/linux-tick-processor" --mac --nm="$v8_tools/mac-nm" $@ diff --git a/tools/v8-prof/tick-processor.js b/tools/v8-prof/tick-processor.js new file mode 100644 index 000000000..b25bcb75a --- /dev/null +++ b/tools/v8-prof/tick-processor.js @@ -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' }); +}); diff --git a/tools/v8-prof/windows-tick-processor.bat b/tools/v8-prof/windows-tick-processor.bat deleted file mode 100755 index 8b5d791ef..000000000 --- a/tools/v8-prof/windows-tick-processor.bat +++ /dev/null @@ -1,19 +0,0 @@ -@echo off -setlocal - -SET tools_dir=%~dp0 -SET v8_tools=%tools_dir%..\..\deps\v8\tools\ - -SET temp_script=%TEMP%\node-tick-processor-input-script - -IF NOT DEFINED NODE (SET NODE=node.exe) -%NODE% --version 2> NUL -if %ERRORLEVEL%==9009 (SET NODE=%~dp0\..\..\Release\node.exe) - - -type %tools_dir%polyfill.js %v8_tools%splaytree.js %v8_tools%codemap.js^ - %v8_tools%csvparser.js %v8_tools%consarray.js %v8_tools%profile.js^ - %v8_tools%profile_view.js %v8_tools%logreader.js %v8_tools%SourceMap.js^ - %v8_tools%tickprocessor.js %v8_tools%tickprocessor-driver.js >> %temp_script% -%NODE% %temp_script% --windows %* -del %temp_script% |