-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
src: remove unneeded AssignToContext() call #9213
Conversation
Does this affect the result |
Yes, it does, and no, it shouldn't. Everything in the binding layer should be using |
Maybe I’m being naïve, but to me all of these look like exceptions to that rule? |
Those are from module initialization functions; those operate on the context they're passed when loaded (which is always a node context.) |
Oh, right. The (Sorry for the question spam) |
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) { |
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. |
#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
63c47e7
Compare
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]>
@bnoordhuis should this be backported? |
ping @bnoordhuis |
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/