-
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: update source, related basic & cached data tests for ArrayBuffer #22921
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.
The native code must be changed to handle the new allowed types.
Example showing that the C++ part is not ready for it: 'use strict';
const vm = require('vm');
let script = new vm.Script('var x = 0;', { produceCachedData: true });
const cachedData = script.cachedData;
new vm.Script('var x = 0;', { cachedData: new Uint16Array(cachedData.buffer) } );
|
Thank you, @ targos / ping reviewer(s). Learned about the “vm” module & dug deeper in the Tested w. the following test snippet:
|
Ping/Dear reviewers, Friendly reminder that - Made updates according per previous review comments, & was able to passed the suggested “vm” test w. cached data. Please review again at convenience. |
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.
I think change to the doc is missing here https://github.com/nodejs/node/blob/master/doc/api/vm.md#new-vmscriptcode-options and here https://github.com/nodejs/node/blob/master/doc/api/vm.md#vmcompilefunctioncode-params-options.
Also, I don't see any tests for TypedArray or DataView as cachedData
, is there any?
Updated the "cachedData" description for new-vmscriptcode-options & vmcompilefunctioncode-params-options docs. Thank you!
The updated test in Please guide me other test(s) that'd add test for TypedArray or DataView as cachedData?
|
Thanks for the swift changes =). It seems there is no reasonable way to test for Though, I cannot understand how can we actually get the Also, this line https://github.com/nodejs/node/pull/22921/files#diff-0cf206672499c2f86db4ffb0cc5b668bR683 and this https://github.com/nodejs/node/pull/22921/files#diff-0cf206672499c2f86db4ffb0cc5b668bR1019 extracts data as |
@lundibundi and/or other dear reviewers, Per these two topics, I'd need some guideline to know how to update the PR to move forward. Would you mind advising?
|
Ping / dear reviewers, Would you mind guiding this PR for next step based on the questions in last comment? (Hoping the PR would not become stale; thank you!) |
ping @addaleax @jasnell @targos as the ones who reviewed this could you provide some input on #22921 (comment)? Just to be clear: I'm not blocking this, my concern is - maybe it's worth changing something here for it to become a bit more relevant. |
I don’t quite see any tests for the newly supported types. You could use the common.getArrayBufferViews() function to make sure all TypedArray and DataView types are actually supported. Check out https://github.com/nodejs/node/blob/master/test/parallel/test-fs-write-file-typedarrays.js for an example |
Ping / dear reviewers, Per the suggestion in last comment, I've rebased & updated the tests in "test-vm-cached-data.js" to use (P.S.: sorry about the delayed update. Was in Node+JS Interactive (glad to meet some of you in person), & a busy week at work after the conf. Looking forward to your review again to pick back up this PR, to work towards landing/closure. 🙏 ) |
test/parallel/test-vm-cached-data.js
Outdated
for (const parsedData of common.getArrayBufferViews(data)) { | ||
// It should consume code cache | ||
const script = new vm.Script(source, { | ||
cachedData: parsedData |
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.
Nit: I'd prefer to just rename parsedData
-> cachedData
and the this line will become just
cachedData: parsedData | |
cachedData |
CI: https://ci.nodejs.org/job/node-test-pull-request/18070/ Also, ping @targos, I believe your concerns were addressed. |
@lundibundi, updated to use (P.S: also thank you @targos for reviewing the "native layer" part!) |
@lundibundi & reviewers, Friendly reminder that Updated to use Would you mind reviewing to see if the PR is okay for “author ready” label, since all previous feedback & advice have been addressed? Thank you! |
In vm module, accept ArrayBuffer in place of Uint8Array in the source code & related test code in "test-vm-basic.js" & "test-vm-cached-data.js", per the "vm" item in the checklist of the comment in #1826. Refs: #1826 (comment)
Use ArrayBufferView/IsArrayBufferView in places of Uint8Array/IsUint8Array, in the node_contextify.cc source code. Refs: #22921 (comment)
Update the "cachedData" description with support of TypedArray or DataView support in “new vm.Script” & “vm.compileFunction”.
Resume CI again: https://ci.nodejs.org/job/node-test-pull-request/18289/ |
Landed in 65fe999 🎉 |
PR-URL: #22921 Refs: #1826 Refs: #22921 (comment) Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
PR-URL: #22921 Refs: #1826 Refs: #22921 (comment) Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
PR-URL: #22921 Refs: #1826 Refs: #22921 (comment) Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Refs: #1826
Referring to the comment in "mentor-available" #1826, this PR tries out the
vm
item from the checklist of the comment:accept
ArrayBufferView
type(s) in place of Uint8Array in the sourcerelated test code in
test-vm-basic.js
&test-vm-cached-data.js
.(P.S.: if any potential test case(s) or
vm
doc update is missed, please advise. Thanks!)make -j4 test
(UNIX), orvcbuild test
(Windows) passes