-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: change tick processor install path #4021
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
lib/internal/v8_prof_polyfill.js | ||
lib/punycode.js | ||
test/addons/doc-*/ | ||
test/fixtures | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' }); | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,6 +145,7 @@ static const char** preload_modules = nullptr; | |
static bool use_debug_agent = false; | ||
static bool debug_wait_connect = false; | ||
static int debug_port = 5858; | ||
static bool prof_process = false; | ||
static bool v8_is_profiling = false; | ||
static bool node_is_initialized = false; | ||
static node_module* modpending; | ||
|
@@ -2957,6 +2958,11 @@ void SetupProcessObject(Environment* env, | |
READONLY_PROPERTY(process, "throwDeprecation", True(env->isolate())); | ||
} | ||
|
||
// --prof-process | ||
if (prof_process) { | ||
READONLY_PROPERTY(process, "profProcess", True(env->isolate())); | ||
} | ||
|
||
// --trace-deprecation | ||
if (trace_deprecation) { | ||
READONLY_PROPERTY(process, "traceDeprecation", True(env->isolate())); | ||
|
@@ -3194,6 +3200,8 @@ static void PrintHelp() { | |
" is detected after the first tick\n" | ||
" --track-heap-objects track heap object allocations for heap " | ||
"snapshots\n" | ||
" --prof-process process v8 profiler output generated\n" | ||
" using --prof\n" | ||
" --v8-options print v8 command line options\n" | ||
#if HAVE_OPENSSL | ||
" --tls-cipher-list=val use an alternative default TLS cipher list\n" | ||
|
@@ -3265,7 +3273,8 @@ static void ParseArgs(int* argc, | |
new_argv[0] = argv[0]; | ||
|
||
unsigned int index = 1; | ||
while (index < nargs && argv[index][0] == '-') { | ||
bool short_circuit = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was the easiest way I could find to pass all args after --process-prof to the processing script. Is there a more idiomatic way to accomplish this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess there isn't currently. It wasn't entirely clear to me it was for passing extra arguments verbatim. |
||
while (index < nargs && argv[index][0] == '-' && !short_circuit) { | ||
const char* const arg = argv[index]; | ||
unsigned int args_consumed = 1; | ||
|
||
|
@@ -3326,6 +3335,9 @@ static void ParseArgs(int* argc, | |
track_heap_objects = true; | ||
} else if (strcmp(arg, "--throw-deprecation") == 0) { | ||
throw_deprecation = true; | ||
} else if (strcmp(arg, "--prof-process") == 0) { | ||
prof_process = true; | ||
short_circuit = true; | ||
} else if (strcmp(arg, "--v8-options") == 0) { | ||
new_v8_argv[new_v8_argc] = "--help"; | ||
new_v8_argc += 1; | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to do this without writing temp files and forking a new process? I imagine you can just concatenate the files and then
eval()
orvm.runInNewContext()
them.(EDIT: It's perhaps a bit of a pain to send the output through
c++filt
. Shouldn't be impossible, though.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would definitely be a big improvement. The current state was the easiest way to get things working but I'm hoping to get rid of the temp files/forking in a future PR.