lib: replace eval with vm.runInThisContext#18623
lib: replace eval with vm.runInThisContext#18623MylesBorins wants to merge 1 commit intonodejs:masterfrom
eval with vm.runInThisContext#18623Conversation
lib/internal/v8_prof_processor.js
Outdated
There was a problem hiding this comment.
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 <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: #18623 Refs: #18212 (review) Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: #18623 Refs: #18212 (review) Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: #18623 Refs: #18212 (review) Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
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 <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matheus Marchini <matheus@sthima.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
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 <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matheus Marchini <matheus@sthima.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: nodejs#18623 Refs: nodejs#18212 (review) Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
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 <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matheus Marchini <matheus@sthima.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: #18623 Refs: #18212 (review) Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
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 <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matheus Marchini <matheus@sthima.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: #18623 Refs: #18212 (review) Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
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 <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matheus Marchini <matheus@sthima.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Refs: #18212 (review)