Repository navigation
stage1 の出力を Wasm GC に完全移行する - #815
Merged
Merged
Conversation
値を線形メモリのタグ付きの箱ではなく Wasm GC の struct / array で表し, 使わなくなった値をランタイムの GC が回収するようにした (docs/wasm-gc.md)。 - ランタイム関数を GC 版に書き直し (31 個), 型・エクスポートもパーツにした - 文字列リテラルはグローバル変数にし, start 関数が passive data から作る - ホスト (src/stage1_compiler.ts) はエクスポートしたランタイム関数で値を作って読む - 型チェッカーのインスタンスを 32 パーツごとに作り直すのをやめた - デプロイ先の worker.js も GC 版にし, Node.js で動かすテストを足した - stage1.wasm は 115KB から 67KB, core 全体のコミットの RSS 増加は約 700MB から約 24MB Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DHYnFxNrErMzq3M2VvJN6M
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.
Requested by ナルミンチョ · project thread
概要
definy のコンパイラ (
core.compile-to-wasm) の出力を Wasm GC に完全移行しました。値は線形メモリのタグ付きの箱ではなく GC のヒープの struct / array になり、使わなくなった値はランタイムの GC が回収します。線形メモリは仕様上縮められず伸びっぱなしだったため、#814 で core 全体のコミットが Workers の上限 128MB に迫っていた問題を根本から解きます。詳細は新しい
docs/wasm-gc.mdにまとめました。変更
core.wasm-type-*(value / bytes / values / number / boolean / string / list / closure / variant / float と、コンパイルした関数の型)。値はどれも(ref null value)で扱い、フィールド 0 のタグで分岐するcore.wasm-runtime-*を GC 版に書き直し (31 個)。ホストが値を作って読むための関数 (box_number,values_get,string_from_memoryなど) もエクスポートする。型セクション・関数の型・エクスポートもパーツにしたarray.new_fixed/struct.new。呼び出しは引数を名前の順に積む (core.compile-call-arguments-ranked)。文字列リテラルはグローバル変数にし、start 関数が passive data からarray.new_dataで作るsrc/stage1_compiler.ts): ポインタの代わりに不透明な参照ValueRefを扱う。書いたオブジェクトの値はWeakMapで使い回すworker.js(definy.cloudflare-workers-runtime-script) も GC 版にし、src/wasi_io.test.tsでアップロードする worker.js を Node.js で動かして確かめるようにしたwasm/stage1.wasmを再生成 (115KB → 67KB, 不動点を確認)測定 (Node.js 26)
SubmitEventの RSSテスト
npm test582 件通過,npm run check:stage1通過,npm run check/npm run lint通過npm run test:e2e) 41 件通過 (1 回目は同時に走らせたnpm testが wasm を書き直して 2 件が落ちたので, その 2 件を単独で再実行して通過)https://claude.ai/code/session_01DHYnFxNrErMzq3M2VvJN6M
Generated by Claude Code