Perfect your code
With built-in code review tools, GitHub makes it easy to raise the quality bar before you ship. Join the 36 million developers who've merged over 200 million pull requests.
Sign up for free See pricing for teams and enterprisesvm: update source, related basic & cached data tests for ArrayBuffer #22921
Conversation
nodejs-github-bot
added
the
vm
label
Sep 18, 2018
BeniCheni
referenced this pull request
Sep 18, 2018
Open
Accept ArrayBuffer (and typed array/data view?) anywhere Buffer is allowed in the API #1826
addaleax
approved these changes
Sep 18, 2018
targos
reviewed
Sep 18, 2018
|
The native code must be changed to handle the new allowed types. |
This comment has been minimized.
This comment has been minimized.
|
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) } );
|
BeniCheni
force-pushed the
BeniCheni:vm-array-buffer-view
branch
from
3f29942
to
e136b76
Sep 26, 2018
BeniCheni
added a commit
to BeniCheni/node
that referenced
this pull request
Sep 26, 2018
This comment has been minimized.
This comment has been minimized.
|
Thank you, @ targos / ping reviewer(s). Learned about the “vm” module & dug deeper in the Tested w. the following test snippet:
|
This comment has been minimized.
This comment has been minimized.
|
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. |
jasnell
approved these changes
Oct 1, 2018
lundibundi
reviewed
Oct 3, 2018
|
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 |
BeniCheni
force-pushed the
BeniCheni:vm-array-buffer-view
branch
from
e136b76
to
6f63ef5
Oct 3, 2018
BeniCheni
added a commit
to BeniCheni/node
that referenced
this pull request
Oct 3, 2018
This comment has been minimized.
This comment has been minimized.
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?
|
This comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
|
@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?
|
This comment has been minimized.
This comment has been minimized.
|
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!) |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
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 |
BeniCheni
force-pushed the
BeniCheni:vm-array-buffer-view
branch
from
6f63ef5
to
262787d
Oct 21, 2018
BeniCheni
added a commit
to BeniCheni/node
that referenced
this pull request
Oct 21, 2018
This comment has been minimized.
This comment has been minimized.
|
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. |
BeniCheni
force-pushed the
BeniCheni:vm-array-buffer-view
branch
from
262787d
to
19eb056
Oct 22, 2018
BeniCheni
added a commit
to BeniCheni/node
that referenced
this pull request
Oct 22, 2018
lundibundi
approved these changes
Oct 23, 2018
| for (const parsedData of common.getArrayBufferViews(data)) { | ||
| // It should consume code cache | ||
| const script = new vm.Script(source, { | ||
| cachedData: parsedData |
This comment has been minimized.
This comment has been minimized.
lundibundi
Oct 23, 2018
Member
Nit: I'd prefer to just rename parsedData -> cachedData and the this line will become just
| cachedData: parsedData | |
| cachedData |
This comment has been minimized.
This comment has been minimized.
|
CI: https://ci.nodejs.org/job/node-test-pull-request/18070/ Also, ping @targos, I believe your concerns were addressed. |
targos
dismissed
their
stale review
Oct 23, 2018
native layer was updated and tests added
BeniCheni
force-pushed the
BeniCheni:vm-array-buffer-view
branch
from
b4b26f5
to
c47abe4
Oct 23, 2018
BeniCheni
added a commit
to BeniCheni/node
that referenced
this pull request
Oct 23, 2018
This comment has been minimized.
This comment has been minimized.
|
@lundibundi, updated to use (P.S: also thank you @targos for reviewing the "native layer" part!) |
BeniCheni
added some commits
Oct 23, 2018
BeniCheni
force-pushed the
BeniCheni:vm-array-buffer-view
branch
from
b6b21b1
to
0f20aca
Oct 31, 2018
This comment has been minimized.
This comment has been minimized.
|
Dear reviewers, (cc @refack & @lundibundi) Thanks for validating for the "author ready" status & label & the CI run. Would you mind guiding to landing at your convenience? |
This comment has been minimized.
This comment has been minimized.
|
If you are not familiar with our review and landing process, it's covered in CONTRIBUTING.md P.S. If you have any question you can also feel free to contact me directly. [that is my canned response to new contributors] |
refack
self-assigned this
Nov 1, 2018
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Resume CI again: https://ci.nodejs.org/job/node-test-pull-request/18289/ |
This comment has been minimized.
This comment has been minimized.
|
Landed in 65fe999 |
BeniCheni commentedSep 18, 2018
Refs: #1826
Referring to the comment in "mentor-available" #1826, this PR tries out the
vmitem from the checklist of the comment:accept
ArrayBufferViewtype(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
vmdoc update is missed, please advise. Thanks!)make -j4 test(UNIX), orvcbuild test(Windows) passes