-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
lib,src: iterate module requests of a module wrap in JS #52058
Conversation
Review requested:
|
26b9280
to
b201582
Compare
c372b99
to
6daec91
Compare
a79c903
to
572d6b0
Compare
Rebased on top of the tip of the main branch. |
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.
General idea LGTM though this needs a rebase
assert.fail('link callback should not be called'); | ||
}); | ||
[kLink]() { | ||
/** nothing to do for synthetic modules */ |
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.
Doesn't need to be solved in this PR but it seems weird that we provide the link method for SyntheticModule at all....
Avoid repetitively calling into JS callback from C++ in `ModuleWrap::Link`. This removes the convoluted callback style of the internal `ModuleWrap` link step.
@joyeecheung thanks, rebased and CI is green. |
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.
LGTM with a suggestion
ObjectSetPrototypeOf(dependencyJobs, null); | ||
|
||
// Specifiers should be aligned with the moduleRequests array in order. | ||
const specifiers = Array(moduleRequests.length); |
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.
This leads to holey arrays, it might still be better to just use ArrayPrototyprPush since this is in a hot path (I think ArrayPrototypePush can be optimized properly the last time I checked).
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.
Do you have a figure for it? As far as I can tell with the latest V8 version, using a microbenchmark to allocate a 20-length array with the two patterns, the result is outstanding that pre-allocating could be ~40% faster: https://jsbench.me/9tlvebajbe/1.
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 problem with holey arrays come more from the access instead of the creation, since V8 needs to defend against things like this:
Array.prototype[1] = 1;
let a = Array(2);
a[1]; // 1
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.
(Also, it's not blocking, I am fine landing with holey arrays, since it's probably still not that much work compared to all the other things the resolution is doing..)
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.
Thanks for bringing this up. I think in this particular case the array is not accessed repetitively so I'd find pre-allocation would be a good solution here.
Landed in d5c7ffd |
Avoid repetitively calling into JS callback from C++ in `ModuleWrap::Link`. This removes the convoluted callback style of the internal `ModuleWrap` link step. PR-URL: #52058 Reviewed-By: Joyee Cheung <[email protected]>
Avoid repetitively calling into JS callback from C++ in `ModuleWrap::Link`. This removes the convoluted callback style of the internal `ModuleWrap` link step. PR-URL: nodejs#52058 Reviewed-By: Joyee Cheung <[email protected]>
Avoid repetitively calling into JS callback from C++ in `ModuleWrap::Link`. This removes the convoluted callback style of the internal `ModuleWrap` link step. PR-URL: nodejs#52058 Reviewed-By: Joyee Cheung <[email protected]>
Avoid repetitively calling into JS callback from C++ in
ModuleWrap::Link
. This removes the convoluted callback style of theinternal
ModuleWrap
link step.Refs: #51977 (comment)