-
Notifications
You must be signed in to change notification settings - Fork 30k
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
vm: pass correct context to CompileFunctionInContext in CompileFunction #23206
Conversation
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.
Looks great! Could you please add a test?
@ryzokuken I'm also wondering. In these lines: https://github.com/nodejs/node/pull/23206/files#diff-0cf206672499c2f86db4ffb0cc5b668bR1041 and https://github.com/nodejs/node/pull/23206/files#diff-0cf206672499c2f86db4ffb0cc5b668bR1052 should we also be checking against Sorry for the slowness here, I've never actually written c++ before and I'm not exactly familiar with the v8 APIs. I am trying though 😄 |
@ryzokuken I'd be happy to help write a test. Is it good enough to test this from the JS layer or should the test be written in C++? Sorry for all the questions! |
Nope. Those get calls should happen in whatever the current context is. |
@devsnek thanks. Now I think understand what's happening in both of those loops. We're basically checking (by name) to see if that particular value exists in the current context, and if so, then we can add it right? Working on some small tests now! |
@ryzokuken just added some small test cases. Hope they're okay :) |
JS tests should be fine. Thanks. |
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.
The tests look great, can you confirm that they all pass with the changed code?
@ryzokuken using Additionally, I was able to run the individual test file I modified with Surely this would be running in the Travis build too right? |
@darahayes It would, yes! The CI failures are probably not related to your change, and it will be fixed soon. |
pinging @ryzokuken, just wondering is there any more work to be done on my side to get this merged? Thanks! |
@darahayes while we are at it could you rebase on master to make CI easier? |
@lundibundi just rebased! |
CI is green! If nobody lands with in the next few hours, I will. |
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.
Final LG.
@darahayes shucks, the other two commits aren't |
ContextifyContext::CompileFunction in src/node_contextify.cc was incorrectly passing the context variable to ScriptCompiler::CompileFunctionInContext This meant that the parsingContext option in vm.compileFunction was not being applied properly to the compiled function. fixes: nodejs#23194 doc: clarify parsingContext option for vm.compileScript test: usage of parsingContext in vm.compileFunction
@ryzokuken looks like the build failed for some unrelated reason. Some timeout. Is it possible to rerun it and see what happens? |
@darahayes timeout in |
@darahayes here we go: #23277 |
/cc @Trott |
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.
Now that parsingContext
is also the context/realm in which the function is created, the name becomes a misnomer. For v8.Script
, the parsingContext
option only controls behavior seen through the Inspector API, as the created script is not bound to a V8 context. I suggest we change the name to context
or something similar, if we can still do so.
Hi! Are you looking for a review from me? Or is there something else you'd like/need? |
Resume CI: https://ci.nodejs.org/job/node-test-pull-request/17728/ Though, @darahayes perhaps you can come up with a better name for the |
@Trott pinged you because of the flaky test, thought it'd bring this particular failure to your notice plus you'll have a better idea about the flake in general 😅. |
Ah! Well, yes, that test has been observed timing out elsewhere and is reported in #23277. The Resume Build passed, so I think you can proceed. |
Landed in 8da674d. |
ContextifyContext::CompileFunction in src/node_contextify.cc was incorrectly passing the context variable to ScriptCompiler::CompileFunctionInContext This meant that the parsingContext option in vm.compileFunction was not being applied properly to the compiled function. fixes: #23194 doc: clarify parsingContext option for vm.compileScript test: usage of parsingContext in vm.compileFunction PR-URL: #23206 Fixes: #23194 Reviewed-By: Ujjwal Sharma <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Apologies for the delay in getting back to this. I would have preferred to get my changes right over getting them merged right now.
You'll have to forgive me, I'm super new to this.
In any case if you folks think it's more appropriate, I'd be happy to submit a small PR that renames This would rename an option passed in from userland code, so these would be breaking changes right? Is there anything from a process or technical perspective that I need to be aware of when submitting a PR with breaking changes? |
Sorry about that. I saw the |
It's all good. It's really my fault because I didn't respond quick enough 😄 |
IMO it's not like this PR is not 'ready', that part was an addition that could happen here or in a follow-up PR as this one was opened for 'pass correct context to CompileFunctionInContext in CompileFunction'. Edit: also, @darahayes no worries, there is no such thing as |
Thanks @lundibundi I'm happy to create a new issue around the naming and work on a follow up PR if you think that's the way to go 😊 |
ContextifyContext::CompileFunction in src/node_contextify.cc was incorrectly passing the context variable to ScriptCompiler::CompileFunctionInContext This meant that the parsingContext option in vm.compileFunction was not being applied properly to the compiled function. fixes: #23194 doc: clarify parsingContext option for vm.compileScript test: usage of parsingContext in vm.compileFunction PR-URL: #23206 Fixes: #23194 Reviewed-By: Ujjwal Sharma <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
ContextifyContext::CompileFunction in src/node_contextify.cc was incorrectly passing the context variable to ScriptCompiler::CompileFunctionInContext This meant that the parsingContext option in vm.compileFunction was not being applied properly to the compiled function. fixes: #23194 doc: clarify parsingContext option for vm.compileScript test: usage of parsingContext in vm.compileFunction PR-URL: #23206 Fixes: #23194 Reviewed-By: Ujjwal Sharma <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
ContextifyContext::CompileFunction in src/node_contextify.cc was incorrectly passing the context variable to ScriptCompiler::CompileFunctionInContext This meant that the parsingContext option in vm.compileFunction was not being applied properly to the compiled function. fixes: #23194 doc: clarify parsingContext option for vm.compileScript test: usage of parsingContext in vm.compileFunction PR-URL: #23206 Fixes: #23194 Reviewed-By: Ujjwal Sharma <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
ContextifyContext::CompileFunction in src/node_contextify.cc was incorrectly passing the context variable to ScriptCompiler::CompileFunctionInContext This meant that the parsingContext option in vm.compileFunction was not being applied properly to the compiled function. fixes: #23194 doc: clarify parsingContext option for vm.compileScript test: usage of parsingContext in vm.compileFunction PR-URL: #23206 Fixes: #23194 Reviewed-By: Ujjwal Sharma <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
ContextifyContext::CompileFunction in src/node_contextify.cc was incorrectly passing the context variable to ScriptCompiler::CompileFunctionInContext This meant that the parsingContext option in vm.compileFunction was not being applied properly to the compiled function. fixes: #23194 doc: clarify parsingContext option for vm.compileScript test: usage of parsingContext in vm.compileFunction PR-URL: #23206 Fixes: #23194 Reviewed-By: Ujjwal Sharma <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Fixes: #23194
The
ContextifyContext::CompileFunction
function was accidentally passing the wrong context variable intoScriptCompiler::CompileFunctionInContext
this resulted in the incorrect context being passed to the compiled function.You can quickly test this with the following code:
With Node v10.10.0 I get the following output:
With the proposed changes, the output is
hello world
.I also edited the description of the
parsingContext
option in the docs to explicitly use the wordcontextified
. The docs use this word everywhere else when referring to a context object.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes