Skip to content

Commit df93bb1

Browse files
avrabeclaude
andauthored
fix(globals): #649 i64.const global initializers reach the emitted image — decoder captures both words, startup materializes the R9 table (#652)
The decoder's `init_i32` captured only a leading `i32.const`; an i64 global's init decoded to `None` and every consumer's `unwrap_or(0)` silently ZEROED the slot. #645 fixed the get/set PAIR lowering and the width-aware slot layout, but a nonzero `(global (mut i64) (i64.const X))` read before any set still returned garbage — the init existed nowhere in the output. Decoder: `WasmGlobal.init_i32` is RENAMED to `init: Option<GlobalInit>` (I32/I64) so no consumer survives by wildcard. f32/f64 inits stay `None` on purpose — float global access is the GI-FPU-001 (#369/#648) loud-skip lane and capturing bits here must not quietly unskip it. Consumers audited (all of them, post-rename): - `identify_stack_pointer_global`: matches `GlobalInit::I32` only (an SP is an i32 address; i64 inits are data, never promoted). - `--native-pointer-abi` `__synth_globals` region: stays 4-byte i32 slots; wide globals are already REFUSED up front (#643 bail — the decline-loudly arm), so only I32 inits can land. Byte-identical for i32-global modules (verified against origin/main). - Self-contained Cortex-M image (the #649 repro shape): globals were never materialized AT ALL — R9 was never even initialized. Now `generate_minimal_startup` gets the table words (#643 summed-width layout, i64 = two words lo-first), points R9 at `0x2000_0000 + linmem_size`, and stores every word before calling the user function; RAM sizing + the NoBits region cover the table. Both the all-exports and single-function builders. Tables past the STR.W #imm12 range decline loudly. No globals => the historical 28-byte startup blob and the whole ELF stay BYTE-IDENTICAL (verified). Red -> green: scripts/repro/i64_global_init_649_differential.py runs the default cortex-m4f image's REAL reset path in unicorn (artifact-derived, nothing fabricated), then the stateful export sequence vs one wasmtime instance. origin/main: FAIL (4 divergences — init reads return vector- table garbage). This branch: PASS (init reads, i32-after-i64 offset canary, #645 set-then-get pin, control). Gates: frozen anchors 10/10, #643 oracle PASS, cargo test --workspace green, fmt + clippy --workspace -D warnings clean. Fixes #649. Refs #645, #643, #648, #369. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent b471c38 commit df93bb1

5 files changed

Lines changed: 562 additions & 90 deletions

File tree

0 commit comments

Comments
 (0)