← Back to Pull requests

Let an embedder subclass CompiledWasmModuleHolder #8101

Open
unknown opened this pull request with 288 lines diff across 3 files
View on GitHub
unknown unknown commented on Oct 30, 2026 12:06 UTC
Author

jsg::CompiledWasmModuleHolder (added in #7706) keeps the compiled code of one builtin Wasm module, today Pyodide's pyodide.asm.wasm, alive for its own lifetime, so that every isolate in the process that loads the module instantiates it from the same compiled code instead of compiling it again. ModuleRegistry::addBuiltinModule(), addBuiltinBundle() and the Python module registration take a holder by reference and call getOrCompile() on it whenever an isolate loads the module. The holder guarantees that concurrent callers on any thread get a module compiled with their isolate's Wasm ESM integration builtins setting, compiling at most once per setting except for concurrent first loads.

The holder is a concrete class with a non-virtual getOrCompile() that always keeps the compiled modules in its own two slots. An embedder that keeps compiled Wasm code in a store of its own, such as a process-wide, size-bounded store keyed by content hash that also serves user modules, therefore can't pass an entry of that store to the module registry. It would have to keep a second copy of Pyodide's compiled code in a separate holder, retaining the wire bytes and machine code twice and reporting them outside its store, or change the registry's signatures to accept something other than a holder.

This change makes getOrCompile() virtual and gives the class a virtual destructor, so an embedder can subclass the holder and route getOrCompile() to its own store while the registry APIs stay as they are. The default implementation is unchanged, and so is every existing caller. The class comment now states the contract an override has to keep: it may be called concurrently from any thread, and it returns a module compiled with the calling isolate's setting.

The cost is one virtual call per module load, next to a Wasm instantiation, and a subclass still carries the base class's two unused slots (two empty mutex-guarded kj::Maybes). The existing holder test in modules-new-test ("CompiledWasmModuleHolder keeps compiled code after its isolate is gone") continues to cover the default path. Cloudflare's runtime will use the subclass to keep Pyodide's interpreter pinned in a process-wide store of compiled Wasm modules.

🤖 Generated with Claude Code

Diff: 288 lines (+216 / -72) across 3 files Reviewer: ryanking13 Review duration: 11449m
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.40) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 288 lines diff across 3 files
0.40
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
0.02
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
46%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth shallow_review_depth
0.344
Diff Size diff_size
0.339
Real PR Conversation Timeline
1 comments
"Review active on #8101"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 46.7% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 39.8% (MEDIUM) · Higher = larger blast radius
39.8%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 46.7% · Lower = rushed or shallow review
46.7%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 21.2% · Safe to merge
21.2%