-
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
lib: replace eval
with vm.runInThisContext
#18623
Conversation
lib/internal/v8_prof_processor.js
Outdated
@@ -1,4 +1,6 @@ | |||
/* eslint-disable strict */ |
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.
Can we enable strict mode, since we are no longer using eval()
?
f8d48a6
to
aca1ece
Compare
updated @TimothyGu |
V8's profiler scripts weren't strict mode compatible at one point. You probably want to double-check that turning it on doesn't break anything. edit: but they're executed as a separate script so it's probably fine. |
@bnoordhuis or @nodejs/benchmarking how would I go about testing this? |
@MylesBorins In theory |
@addaleax turtles! Will report back |
Floated this on the 8.10.0 proposal branch... So this breaks the world 🎉
/cc @nodejs/v8 edit: |
@MylesBorins I guess that’s because You can probably get around that by making the evaluated script a normal function instead of an IIFE, then compile that using That being said: It’s not really obvious to me why we don’t just use |
3e96fb8
to
aca1ece
Compare
@addaleax removing the IIFE doesn't solve anything. Using require instead also didn't work. I tried banging my head against the wall to figure out why the behavior is different, but it doesn't seem like I can get the tests to pass if eval is switched out. @bnoordhuis is this change totally neccessary? Could we instead check the V8 flag and bail with a clear warning if eval is disabled? |
diff --git a/lib/internal/v8_prof_processor.js b/lib/internal/v8_prof_processor.js
index deb8d77d0acb..bb71213a8f4d 100644
--- a/lib/internal/v8_prof_processor.js
+++ b/lib/internal/v8_prof_processor.js
@@ -33,9 +33,9 @@ if (process.platform === 'darwin') {
tickArguments.push('--windows');
}
tickArguments.push.apply(tickArguments, process.argv.slice(1));
-script = `(function() {
+script = `(function(require) {
arguments = ${JSON.stringify(tickArguments)};
function write (s) { process.stdout.write(s) }
${script}
-})()`;
-vm.runInThisContext(script);
+})`;
+vm.runInThisContext(script)(require); works fine for me? (edit: on v8.x-staging) |
aca1ece
to
267bc78
Compare
@addaleax OHHHHHH. Got it working on my machine. I hadn't considered using specifically |
CI is being weird, one more time https://ci.nodejs.org/job/node-test-pull-request/13117/ |
Here's a build off master to compare to see if these failures are from this PR https://ci.nodejs.org/job/node-test-commit/16182/ |
267bc78
to
2c5fcb7
Compare
2c5fcb7
to
4dd2749
Compare
@TimothyGu it looks like I regressed moving between machines 🤦🏽♂️ one more ci: https://ci.nodejs.org/job/node-test-pull-request/13152/ |
YACI (yet another CI): https://ci.nodejs.org/job/node-test-pull-request/13180/ |
CI failures appear to be unrelated, but trying again on arm due to a total build bot failure: https://ci.nodejs.org/job/node-test-commit-arm-fanned/14534/ |
It came out green. Landed in 99d693d 🎉 |
PR-URL: nodejs#18623 Refs: nodejs#18212 (review) Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: #18623 Refs: #18212 (review) Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: #18623 Refs: #18212 (review) Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: #18623 Refs: #18212 (review) Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Make the script not error out immediately because of a missing pseudo-global. (Note that it seems like tests are still broken on `master`.) Fixes: nodejs#19044 Refs: nodejs#18623
Make the script not error out immediately because of a missing pseudo-global. (Note that it seems like tests are still broken on `master`.) PR-URL: #19059 Fixes: #19044 Refs: #18623 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Make the script not error out immediately because of a missing pseudo-global. (Note that it seems like tests are still broken on `master`.) PR-URL: nodejs#19059 Fixes: nodejs#19044 Refs: nodejs#18623 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: nodejs#18623 Refs: nodejs#18212 (review) Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Make the script not error out immediately because of a missing pseudo-global. (Note that it seems like tests are still broken on `master`.) PR-URL: nodejs#19059 Fixes: nodejs#19044 Refs: nodejs#18623 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: #18623 Refs: #18212 (review) Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Make the script not error out immediately because of a missing pseudo-global. (Note that it seems like tests are still broken on `master`.) PR-URL: #19059 Fixes: #19044 Refs: #18623 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: #18623 Refs: #18212 (review) Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Make the script not error out immediately because of a missing pseudo-global. (Note that it seems like tests are still broken on `master`.) PR-URL: #19059 Fixes: #19044 Refs: #18623 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Refs: #18212 (review)