mirror of
https://github.com/hanzoai/wasm2go.git
synced 2026-10-30 15:06:48 +00:00
* ssa: accept bool-typed br_table selectors wasm comparisons leave i32 0/1 on the stack and a br_table may select on one directly — SpiderMonkey's with-Intl build does (its Fn7964), which made the whole engine untranslatable: the SSA verifier rejected the selector because wasm2go types comparison results as TypeBool. The emitter always materializes bool values through b2i32, so a bool selector already emits as a plain i32 switch operand; accepting the type in the verifier is the entire fix. New fixture cg_brtable_bool.wat reproduces the exact failure (differential against wazero: selector 0/1 routes to the right arm) and passes after; go test ./... exit 0. Co-Authored-By: Claude Fable 5 <[email protected]> * codegen: add negative-zero flow fixture (locals/phi/select/copysign/load) Documents that every tested -0 flow shape emits correctly in the pure backend: through locals, block results, phi merges, select, copysign with constant magnitude or sign, f64.neg, data-segment loads, and arithmetic. All shapes build the -0 inside wasm (the fixture harness's synthesized main passes f64 args as decimal literals, so raw-bit f64 arguments cannot be used in fixtures). The remaining -0 e2e failures against the translated SpiderMonkey are engine-code-shape dependent (same translator: the without-intl engine loses -0 in Math.sumPrecise / gcasm atan2 while the with-intl engine passes), so they live in shapes not yet captured here. Co-Authored-By: Claude Fable 5 <[email protected]> --------- Co-authored-by: Claude Fable 5 <[email protected]>
15 lines
626 B
WebAssembly Text Format
15 lines
626 B
WebAssembly Text Format
;; cg_brtable_bool.wat — br_table whose selector is a comparison result.
|
|
;; wasm comparisons leave i32 0/1 on the stack, so this is valid wasm, but
|
|
;; wasm2go's SSA types comparisons as bool; the BrTable verifier must accept
|
|
;; that (emitters always materialize bool values via b2i32, i.e. as i32).
|
|
;; Shape found in SpiderMonkey's with-Intl build (Fn7964).
|
|
(module
|
|
(func (export "pick") (param i32) (result i32)
|
|
(block $b2
|
|
(block $b1
|
|
(block $b0
|
|
(br_table $b0 $b1 $b2 (i32.ge_u (local.get 0) (i32.const 5))))
|
|
(return (i32.const 10)))
|
|
(return (i32.const 20)))
|
|
(i32.const 30)))
|