Repository navigation
vm: allow createCachedData() in any module status - #67508
Conversation
|
Review requested:
|
|
Welcome to Node.js, and thank you for your first contribution! Before review, please take a moment to read:
Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal. |
2f22f01 to
ad44309
Compare
|
The V8 change that fixes the stale comment of |
|
I checked that Node's bundled V8 already supports this: |
|
FYI, the |
ad44309 to
cc9cecf
Compare
|
@inoway46 Thanks for the info! rebased |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #67508 +/- ##
==========================================
- Coverage 90.52% 90.51% -0.02%
==========================================
Files 805 805
Lines 285669 286357 +688
Branches 55151 55324 +173
==========================================
+ Hits 258616 259192 +576
- Misses 17173 17248 +75
- Partials 9880 9917 +37
🚀 New features to boost your workflow:
|
This comment was marked as resolved.
This comment was marked as resolved.
cc9cecf to
4dba7b7
Compare
|
@MikeMcC399 Rebased. Thanks! |
|
The code and tests look good to me for the intended change. The check introduced in #31278 matched V8’s restriction at the time, but V8 now handles both Sorry I only noticed this after the rebase and CI rerun. |
|
LGTM. Before we rerun CI, could you squash the three commits into one and update the commit message and PR description to say that createCachedData() can now be called in any module state? That way, the commit queue can land it with the correct message. |
|
@inoway46 Thanks! I just updated the PR description to correctly reflect the current implementation |
sourceTextModule.createCachedData() threw ERR_VM_MODULE_CANNOT_CREATE_CACHED_DATA after the module started evaluation. V8 removed this restriction in 2020, and it handles every module status when it creates a code cache. A code cache that is created after evaluation can also contain the functions that V8 compiled lazily during the evaluation, so a new module that uses this code cache can compile less. Allow the call in any module status, and remove ERR_VM_MODULE_CANNOT_CREATE_CACHED_DATA, which is no longer thrown. Throw ERR_INVALID_THIS if the receiver is not a SourceTextModule. A SyntheticModule receiver could reach a CHECK in ModuleWrap::CreateCachedData() and abort the process. Assisted-by: claude:opus-5.5 Signed-off-by: Yusuke "YT" Tanaka <ytanaka@cloudflare.com>
592df7d to
5bc14b8
Compare
|
And squashed the commits into one with the right message |
|
Landed in 4b26c72 |
sourceTextModule.createCachedData()throwsERR_VM_MODULE_CANNOT_CREATE_CACHED_DATAif the module is already evaluated. This check came from #31278, which matched a V8 check at that time. V8 removed its check in https://crrev.com/c/2504256 in Nov 2020, but Node has not caught up with it. So this PR allows the call tocreateCachedData()for any status.This will help speed up the vm pools of Vitest. A code cache created after evaluation can also contain the functions that V8 compiled lazily, so a module that uses it can compile less. A Vitest prototype that uses cached data after evaluation in subsequent test files took 12-24% less wall-clock time on a 500-file benchmark.
I used an AI coding assistant to help write the patch and the tests. I reviewed them.
Refs: https://chromium-review.googlesource.com/c/v8/v8/+/2504256
Refs: https://chromium-review.googlesource.com/c/v8/v8/+/8811778