Repository navigation
fix: hash source contents for V8 code cache - #36743
Merged
Merged
Conversation
- Explain why `cli/rt/run.rs` hashes source bytes rather than the `&str`: it has to match `SharedModuleLoaderState::get_code_cache` for the same specifier, and the two hash differently. - Note that `CliModuleLoader`'s two hash domains are deliberately disjoint. - Note that hashing the pre-wrap source in the lazy ext-script path is sound because the wrap is a pure function of the source. - Document on the `ModuleLoader::get_code_cache` and `EvalContextGetCodeCacheCb` contracts that the key must cover the full source, why the source arrives as UTF-16, and that `Err` degrades to an uncached compile. - Factor the duplicated code-unit copy in `op_eval_context` and `op_compile_function` into a helper. - Assert the eval result and that nothing is written back in the cache error test, and add coverage that the callback observes the full source contents for equal-length rewrites.
bartlomieju
enabled auto-merge (squash)
August 31, 2026 18:28
bartlomieju
added a commit
that referenced
this pull request
Sep 16, 2026
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hash full source contents when keying persistent V8 caches for CJS scripts and lazy-loaded modules, rather than relying on V8 string identity hashes. Cache callback errors now degrade to uncached compilation, and regression coverage verifies equal-length large CJS rewrites do not execute stale code.
Fixes #36413.