Skip to content

Add jsg support for shared-ownership module sources - #7523

Merged
mikea merged 1 commit into
mainfrom
maizatskyi/2026-09-25-module-source-ownership-base
Sep 25, 2026
Merged

mikea merged 1 commit into
mainfrom
maizatskyi/2026-09-25-module-source-ownership-base

Conversation

@mikea

@mikea mikea commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Builtin modules that aren't compiled into the binary need to reach V8 as external strings that keep their own storage alive, not as borrowed buffers that V8 can outlive.

  • Add jsg::copyToArc() to copy a buffer into a kj::Arc.
  • Pick the ModuleInfo ESM constructor by source type: ArrayPtr is copied, StaticExternalStringSource is borrowed, Arc is shared. This replaces ModuleInfoCompileOption.
  • Add addBuiltinModule(Arc) to the legacy registry and BuiltinBuilder::addEsm(Arc) to the new one.
  • gen-compile-cache: copy the Rust-owned path and source before making external strings from them.

@ask-bonk

ask-bonk Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

LGTM

github run

Builtin modules that aren't compiled into the binary need to reach V8 as
external strings that keep their own storage alive, not as borrowed
buffers that V8 can outlive.

- Add jsg::copyToArc() to copy a buffer into a kj::Arc.
- Pick the ModuleInfo ESM constructor by source type: ArrayPtr is copied,
  StaticExternalStringSource is borrowed, Arc<OwnedAscii> is shared.
  This replaces ModuleInfoCompileOption.
- Add addBuiltinModule(Arc<OwnedAscii>) to the legacy registry and
  BuiltinBuilder::addEsm(Arc<OwnedAscii>) to the new one.
- gen-compile-cache: copy the Rust-owned path and source before making
  external strings from them.
@mikea
mikea force-pushed the maizatskyi/2026-09-25-module-source-ownership-base branch from bfc98fb to a745140 Compare September 25, 2026 18:15
@mikea
mikea marked this pull request as ready for review September 25, 2026 19:00
@mikea
mikea requested review from a team as code owners September 25, 2026 19:00
@mikea
mikea requested a review from jasnell September 25, 2026 19:40
Comment thread src/rust/gen-compile-cache/cxx-bridge.c++
@mikea
mikea enabled auto-merge September 25, 2026 19:48
@mikea
mikea disabled auto-merge September 25, 2026 19:51
@mikea
mikea merged commit d76924c into main Sep 25, 2026
41 of 42 checks passed
@mikea
mikea deleted the maizatskyi/2026-09-25-module-source-ownership-base branch September 25, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants