Commit 3a31737
feat: Add WasmGC (typed WASM) codegen target
Implement the WebAssembly GC proposal as a second compilation target
alongside the existing WASM 1.0 linear memory backend. The --wasm-gc
flag on the compile subcommand activates the new pipeline.
Three new modules:
- wasm_gc.ml: GC IR types (heap types, ref types, struct/array defs,
GC instructions with 0xFB prefix opcodes)
- wasm_gc_encode.ml: binary encoder for GC modules (type section with
struct 0x5F / array 0x5E markers, ref types 0x63/0x64)
- codegen_gc.ml: GC codegen mapping AffineScript types to GC types
(records→struct.new, arrays→array.new_fixed, field access→struct.get,
affine values→non-null GcRef, shared→GcAnyref)
Key design: AffineScript affine types map to non-null WasmGC refs
(GcRef), giving compile-time null safety enforced by the WASM type
validator. No bump allocator or linear memory needed — the runtime GC
handles collection.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent fb2bc07 commit 3a31737
6 files changed
Lines changed: 1822 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | | - | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
232 | | - | |
233 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
234 | 235 | | |
235 | 236 | | |
236 | 237 | | |
| |||
257 | 258 | | |
258 | 259 | | |
259 | 260 | | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
260 | 270 | | |
261 | 271 | | |
262 | 272 | | |
| |||
304 | 314 | | |
305 | 315 | | |
306 | 316 | | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
307 | 327 | | |
308 | 328 | | |
309 | 329 | | |
| |||
407 | 427 | | |
408 | 428 | | |
409 | 429 | | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
410 | 436 | | |
411 | 437 | | |
412 | 438 | | |
| |||
433 | 459 | | |
434 | 460 | | |
435 | 461 | | |
436 | | - | |
| 462 | + | |
437 | 463 | | |
438 | | - | |
| 464 | + | |
439 | 465 | | |
440 | 466 | | |
441 | 467 | | |
| |||
0 commit comments