Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
src: remove unneeded AssignToContext() call#9213
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
bnoordhuis commented Oct 20, 2016 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
addaleax commented Oct 20, 2016
Does this affect the result |
bnoordhuis commented Oct 20, 2016
Yes, it does, and no, it shouldn't. Everything in the binding layer should be using |
addaleax commented Oct 20, 2016
Maybe I’m being naïve, but to me all of these look like exceptions to that rule? |
bnoordhuis commented Oct 20, 2016
Those are from module initialization functions; those operate on the context they're passed when loaded (which is always a node context.) |
addaleax commented Oct 20, 2016
Oh, right. The (Sorry for the question spam) |
bnoordhuis commented Oct 21, 2016
Oh, that's a good point. Those functions use On the flip side, using diff --git a/test/addons/make-callback/test.js b/test/addons/make-callback/test.js index 43ad014..b67d114 100644 --- a/test/addons/make-callback/test.js+++ b/test/addons/make-callback/test.js@@ -36,6 +36,10 @@ const recv ={assert.strictEqual(42, makeCallback(recv, 'one')); assert.strictEqual(42, makeCallback(recv, 'two', 1337)); +// Check that callbacks on a receiver from a different context works.+const foreignObject = vm.runInNewContext('({fortytwo(){return 42} })');+assert.strictEqual(42, makeCallback(foreignObject, 'fortytwo'));+ // Check that the callback is made in the context of the receiver. const target = vm.runInNewContext(` (function($Object){ |
bnoordhuis commented Oct 21, 2016
I've been prodding at it and I observe that the AssignToContext() calls cause the weird issue where: auto context_1 = object->CreationContext(); auto context_2 = Environment::GetCurrent(context_1)->context(); CHECK_EQ(context_1, context_2); // Boom!It's not difficult to work around (I'll file a pull request) but it seems broken to me. |
bnoordhuis commented Oct 25, 2016
#9221 landed. I'm going to land the first commit and drop the second one. |
It's only used once at startup in a single place so create the string in place instead of caching it for the lifetime of the isolate. PR-URL: nodejs#9213 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
810e256 to 63c47e7CompareIt's only used once at startup in a single place so create the string in place instead of caching it for the lifetime of the isolate. PR-URL: #9213 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
MylesBorins commented Nov 18, 2016
@bnoordhuis should this be backported? |
gibfahn commented Jun 17, 2017
ping @bnoordhuis |
addaleax commented Jun 18, 2017
It's only used once at startup in a single place so create the string in place instead of caching it for the lifetime of the isolate. PR-URL: #9213 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
It's only used once at startup in a single place so create the string in place instead of caching it for the lifetime of the isolate. PR-URL: #9213 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
It's only used once at startup in a single place so create the string in place instead of caching it for the lifetime of the isolate. PR-URL: #9213 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
It was added in commit 681fe59 ("vm: assign Environment to created
context") from April 2014 to work around a segmentation fault when
accessing process.env from another context but that is not necessary
anymore after commit 7e88a93 ("src: make accessors immune to context
confusion") from March 2015.
CI: https://ci.nodejs.org/job/node-test-pull-request/4599/