diff --git a/compiler/test/__snapshots__/basic_functionality.1d2ec323.0.snapshot b/compiler/test/__snapshots__/basic_functionality.1d2ec323.0.snapshot index 0cdb8dd40f..fd337b590e 100644 --- a/compiler/test/__snapshots__/basic_functionality.1d2ec323.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.1d2ec323.0.snapshot @@ -1,11 +1,10 @@ basic functionality › comp22 (module - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) @@ -16,6 +15,7 @@ basic functionality › comp22 (import \"GRAIN$MODULE$runtime/gc\" \"malloc\" (func $wimport_GRAIN$MODULE$runtime/gc_malloc (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"[...]\" (func $gimport_pervasives_[...] (param i32 i32 i32) (result i32))) (import \"GRAIN$MODULE$pervasives\" \"isnt\" (func $gimport_pervasives_isnt (param i32 i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) @@ -64,17 +64,10 @@ basic functionality › comp22 (local.set $2 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -84,9 +77,6 @@ basic functionality › comp22 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[]) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -131,17 +121,10 @@ basic functionality › comp22 (local.set $4 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -151,9 +134,6 @@ basic functionality › comp22 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[]) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) diff --git a/compiler/test/__snapshots__/basic_functionality.3c2ba165.0.snapshot b/compiler/test/__snapshots__/basic_functionality.3c2ba165.0.snapshot index 15ef5b8cd4..59f856dbcb 100644 --- a/compiler/test/__snapshots__/basic_functionality.3c2ba165.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.3c2ba165.0.snapshot @@ -1,11 +1,10 @@ basic functionality › comp20 (module - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef (mut i32))) @@ -14,6 +13,7 @@ basic functionality › comp20 (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$isnt\" (global $gimport_pervasives_isnt (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"[...]\" (func $gimport_pervasives_[...] (param i32 i32 i32) (result i32))) (import \"GRAIN$MODULE$pervasives\" \"isnt\" (func $gimport_pervasives_isnt (param i32 i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) @@ -26,29 +26,19 @@ basic functionality › comp20 (local $2 i32) (local $3 i32) (local $4 i32) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (i32.const 0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 5) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[]) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -57,27 +47,17 @@ basic functionality › comp20 ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 3) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) - ) - (i32.load offset=8 (local.get $0) ) ) @@ -88,29 +68,19 @@ basic functionality › comp20 ) ) ) - (local.set $3 + (local.set $2 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 5) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[]) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -119,28 +89,18 @@ basic functionality › comp20 ) ) ) - (local.set $4 + (local.set $3 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 3) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $3) - ) - (i32.load offset=8 - (local.get $0) + (local.get $2) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -150,7 +110,7 @@ basic functionality › comp20 ) ) ) - (local.set $0 + (local.set $4 (tuple.extract 0 (tuple.make (call $gimport_pervasives_isnt @@ -160,42 +120,42 @@ basic functionality › comp20 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) + (local.get $1) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $4) + (local.get $3) ) ) - (local.get $0) + (i32.const 0) ) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $2) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $4) + (local.get $3) ) ) - (local.get $0) + (local.get $4) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/basic_functionality.52ca8e0e.0.snapshot b/compiler/test/__snapshots__/basic_functionality.52ca8e0e.0.snapshot index 35146174e8..46f31ed064 100644 --- a/compiler/test/__snapshots__/basic_functionality.52ca8e0e.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.52ca8e0e.0.snapshot @@ -1,11 +1,9 @@ basic functionality › func_shadow (module (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) @@ -17,16 +15,18 @@ basic functionality › func_shadow (import \"GRAIN$MODULE$pervasives\" \"print\" (func $gimport_pervasives_print (param i32 i32) (result i32))) (global $global_1 (mut i32) (i32.const 0)) (global $global_0 (mut i32) (i32.const 0)) - (global $global_3 i32 (i32.const 2)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $foo_1131 $foo_1133) + (global $global_3 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_3)) - (func $foo_1131 (; has Stack IR ;) (param $0 i32) (result i32) + (func $_gmain (; has Stack IR ;) (result i32) + (local $0 i32) (local $1 i32) + (local $2 i32) + (local $3 i32) (i32.store - (local.tee $1 + (local.tee $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_malloc @@ -37,76 +37,45 @@ basic functionality › func_shadow ) ) ) - (i32.const 1) + (i32.const 6) ) (i32.store offset=4 - (local.get $1) - (i32.const 3) + (local.get $0) + (i32.const 1) ) - (i64.store offset=8 - (local.get $1) - (i64.const 7496034) + (i32.store offset=8 + (local.get $0) + (i32.const -1) ) - (local.set $1 + (i32.store offset=12 + (local.get $0) + (i32.const 0) + ) + (global.set $global_0 (tuple.extract 0 (tuple.make - (local.get $1) - (local.get $1) - ) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) - ) - ) - (local.get $1) - ) - (func $foo_1133 (; has Stack IR ;) (param $0 i32) (result i32) - (local $1 i32) - (i32.store - (local.tee $1 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_malloc - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) - (i32.const 16) - ) - (i32.const 0) + (local.get $0) + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (global.get $global_0) ) ) ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $1) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $1) - (i64.const 8020322) ) (local.set $1 (tuple.extract 0 (tuple.make - (local.get $1) - (local.get $1) + (global.get $global_0) + (local.get $0) ) ) ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) + (local.set $2 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $global_0) ) ) - (local.get $1) - ) - (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) (i32.store (local.tee $0 (tuple.extract 0 @@ -119,46 +88,29 @@ basic functionality › func_shadow ) ) ) - (i32.const 6) - ) - (i32.store offset=4 - (local.get $0) (i32.const 1) ) - (i32.store offset=8 + (i32.store offset=4 (local.get $0) - (global.get $wimport__grainEnv_relocBase) + (i32.const 3) ) - (i32.store offset=12 + (i64.store offset=8 (local.get $0) - (i32.const 0) - ) - (global.set $global_0 - (tuple.extract 0 - (tuple.make - (local.get $0) - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (global.get $global_0) - ) - ) - ) + (i64.const 7496034) ) - (local.set $0 - (tuple.extract 0 - (tuple.make - (global.get $global_0) - (local.get $0) - ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $2) ) ) (local.set $2 (tuple.extract 0 (tuple.make - (call $foo_1131 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $global_0) + (tuple.extract 0 + (tuple.make + (local.get $0) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -188,7 +140,7 @@ basic functionality › func_shadow (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) (i32.const 16) ) - (local.get $0) + (local.get $1) ) ) ) @@ -200,10 +152,7 @@ basic functionality › func_shadow ) (i32.store offset=8 (local.get $0) - (i32.add - (global.get $wimport__grainEnv_relocBase) - (i32.const 1) - ) + (i32.const -1) ) (i32.store offset=12 (local.get $0) @@ -228,13 +177,47 @@ basic functionality › func_shadow ) ) ) + (local.set $3 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $global_1) + ) + ) + (i32.store + (local.tee $0 + (tuple.extract 0 + (tuple.make + (call $wimport_GRAIN$MODULE$runtime/gc_malloc + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) + (i32.const 16) + ) + (i32.const 0) + ) + ) + ) + (i32.const 1) + ) + (i32.store offset=4 + (local.get $0) + (i32.const 3) + ) + (i64.store offset=8 + (local.get $0) + (i64.const 8020322) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $3) + ) + ) (local.set $0 (tuple.extract 0 (tuple.make - (call $foo_1133 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $global_1) + (tuple.extract 0 + (tuple.make + (local.get $0) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef diff --git a/compiler/test/__snapshots__/basic_functionality.61c58118.0.snapshot b/compiler/test/__snapshots__/basic_functionality.61c58118.0.snapshot index 789b4dde23..640d50f442 100644 --- a/compiler/test/__snapshots__/basic_functionality.61c58118.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.61c58118.0.snapshot @@ -1,11 +1,9 @@ basic functionality › block_no_expression (module (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) @@ -14,23 +12,14 @@ basic functionality › block_no_expression (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (global $global_0 (mut i32) (i32.const 0)) - (global $global_2 i32 (i32.const 1)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $f_1131) + (global $global_2 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_2)) - (func $f_1131 (; has Stack IR ;) (param $0 i32) (result i32) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) (func $_gmain (; has Stack IR ;) (result i32) (local $0 i32) + (local $1 i32) (i32.store (local.tee $0 (tuple.extract 0 @@ -51,7 +40,7 @@ basic functionality › block_no_expression ) (i32.store offset=8 (local.get $0) - (global.get $wimport__grainEnv_relocBase) + (i32.const -1) ) (i32.store offset=12 (local.get $0) @@ -76,14 +65,21 @@ basic functionality › block_no_expression ) ) ) + (local.set $1 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $global_0) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $1) + ) + ) (tuple.extract 0 (tuple.make - (call $f_1131 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $global_0) - ) - ) + (i32.const 1879048190) (local.get $0) ) ) diff --git a/compiler/test/__snapshots__/basic_functionality.711a4824.0.snapshot b/compiler/test/__snapshots__/basic_functionality.711a4824.0.snapshot index 1d93a221b0..9f9b2baecb 100644 --- a/compiler/test/__snapshots__/basic_functionality.711a4824.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.711a4824.0.snapshot @@ -1,11 +1,9 @@ basic functionality › pattern_match_unsafe_wasm (module (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) @@ -16,78 +14,11 @@ basic functionality › pattern_match_unsafe_wasm (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$pervasives\" \"print\" (func $gimport_pervasives_print (param i32 i32) (result i32))) (global $global_0 (mut i32) (i32.const 0)) - (global $global_2 i32 (i32.const 2)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $test_1131 $foo_1132) + (global $global_2 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_2)) - (func $test_1131 (; has Stack IR ;) (param $0 i32) (result i32) - (i32.store - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_malloc - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) - (i32.const 16) - ) - (i32.const 0) - ) - ) - ) - (i32.const 6) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.add - (global.get $wimport__grainEnv_relocBase) - (i32.const 1) - ) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (drop - (call $foo_1132 - (local.tee $0 - (tuple.extract 0 - (tuple.make - (local.get $0) - (i32.const 0) - ) - ) - ) - (i32.const 0) - ) - ) - (drop - (call $foo_1132 - (local.get $0) - (i32.const 1) - ) - ) - (drop - (call $foo_1132 - (local.get $0) - (i32.const 5) - ) - ) - (drop - (call $foo_1132 - (local.get $0) - (i32.const 8) - ) - ) - (call $foo_1132 - (local.get $0) - (i32.const 42) - ) - ) (func $foo_1132 (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (block $switch.31_outer (result i32) @@ -338,6 +269,7 @@ basic functionality › pattern_match_unsafe_wasm ) (func $_gmain (; has Stack IR ;) (result i32) (local $0 i32) + (local $1 i32) (i32.store (local.tee $0 (tuple.extract 0 @@ -358,7 +290,7 @@ basic functionality › pattern_match_unsafe_wasm ) (i32.store offset=8 (local.get $0) - (global.get $wimport__grainEnv_relocBase) + (i32.const -1) ) (i32.store offset=12 (local.get $0) @@ -375,7 +307,7 @@ basic functionality › pattern_match_unsafe_wasm ) ) ) - (local.set $0 + (local.set $1 (tuple.extract 0 (tuple.make (global.get $global_0) @@ -383,15 +315,76 @@ basic functionality › pattern_match_unsafe_wasm ) ) ) - (tuple.extract 0 - (tuple.make - (call $test_1131 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $global_0) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $global_0) + ) + ) + (i32.store + (local.tee $0 + (tuple.extract 0 + (tuple.make + (call $wimport_GRAIN$MODULE$runtime/gc_malloc + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) + (i32.const 16) + ) + (i32.const 0) + ) + ) + ) + (i32.const 6) + ) + (i32.store offset=4 + (local.get $0) + (i32.const 2) + ) + (i32.store offset=8 + (local.get $0) + (i32.const -1) + ) + (i32.store offset=12 + (local.get $0) + (i32.const 0) + ) + (drop + (call $foo_1132 + (local.tee $0 + (tuple.extract 0 + (tuple.make + (local.get $0) + (i32.const 0) + ) ) ) + (i32.const 0) + ) + ) + (drop + (call $foo_1132 (local.get $0) + (i32.const 1) + ) + ) + (drop + (call $foo_1132 + (local.get $0) + (i32.const 5) + ) + ) + (drop + (call $foo_1132 + (local.get $0) + (i32.const 8) + ) + ) + (tuple.extract 0 + (tuple.make + (call $foo_1132 + (local.get $0) + (i32.const 42) + ) + (local.get $1) ) ) ) diff --git a/compiler/test/__snapshots__/basic_functionality.9379df0d.0.snapshot b/compiler/test/__snapshots__/basic_functionality.9379df0d.0.snapshot index 9aa5a375b6..948ee9c5a4 100644 --- a/compiler/test/__snapshots__/basic_functionality.9379df0d.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.9379df0d.0.snapshot @@ -1,11 +1,10 @@ basic functionality › comp21 (module (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) @@ -15,6 +14,7 @@ basic functionality › comp21 (import \"GRAIN$MODULE$runtime/gc\" \"malloc\" (func $wimport_GRAIN$MODULE$runtime/gc_malloc (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"[...]\" (func $gimport_pervasives_[...] (param i32 i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) @@ -62,17 +62,10 @@ basic functionality › comp21 (local.set $2 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -82,9 +75,6 @@ basic functionality › comp21 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[]) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -129,17 +119,10 @@ basic functionality › comp21 (local.set $4 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -149,9 +132,6 @@ basic functionality › comp21 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[]) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) diff --git a/compiler/test/__snapshots__/basic_functionality.f58be537.0.snapshot b/compiler/test/__snapshots__/basic_functionality.f58be537.0.snapshot index 24e9eeedad..9d6116e03a 100644 --- a/compiler/test/__snapshots__/basic_functionality.f58be537.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.f58be537.0.snapshot @@ -1,11 +1,10 @@ basic functionality › comp19 (module - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef (mut i32))) @@ -13,6 +12,7 @@ basic functionality › comp19 (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$[...]\" (global $gimport_pervasives_[...] (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"[...]\" (func $gimport_pervasives_[...] (param i32 i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) @@ -24,29 +24,19 @@ basic functionality › comp19 (local $2 i32) (local $3 i32) (local $4 i32) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (i32.const 0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 5) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[]) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -55,27 +45,17 @@ basic functionality › comp19 ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 3) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) - ) - (i32.load offset=8 (local.get $0) ) ) @@ -86,29 +66,19 @@ basic functionality › comp19 ) ) ) - (local.set $3 + (local.set $2 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 5) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[]) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -117,28 +87,18 @@ basic functionality › comp19 ) ) ) - (local.set $4 + (local.set $3 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 3) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $3) - ) - (i32.load offset=8 - (local.get $0) + (local.get $2) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -148,7 +108,7 @@ basic functionality › comp19 ) ) ) - (local.set $0 + (local.set $4 (tuple.extract 0 (tuple.make (i32.or @@ -156,46 +116,46 @@ basic functionality › comp19 (i32.eq (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) + (local.get $1) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $4) + (local.get $3) ) ) (i32.const 31) ) (i32.const 2147483646) ) - (local.get $0) + (i32.const 0) ) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $2) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $4) + (local.get $3) ) ) - (local.get $0) + (local.get $4) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/basic_functionality.fe88cb04.0.snapshot b/compiler/test/__snapshots__/basic_functionality.fe88cb04.0.snapshot index e82a70e285..12e97c97bc 100644 --- a/compiler/test/__snapshots__/basic_functionality.fe88cb04.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.fe88cb04.0.snapshot @@ -1,7 +1,7 @@ basic functionality › func_shadow_and_indirect_call (module - (type $i32_=>_i32 (func (param i32) (result i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) + (type $i32_=>_i32 (func (param i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) @@ -19,53 +19,13 @@ basic functionality › func_shadow_and_indirect_call (global $global_2 (mut i32) (i32.const 0)) (global $global_1 (mut i32) (i32.const 0)) (global $global_0 (mut i32) (i32.const 0)) - (global $global_5 i32 (i32.const 4)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $foo_1131 $foo_1133 $foo_1135 $func_1148) + (global $global_5 i32 (i32.const 1)) + (elem $elem (global.get $wimport__grainEnv_relocBase) $func_1148) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_5)) - (func $foo_1131 (; has Stack IR ;) (param $0 i32) (result i32) - (local $1 i32) - (i32.store - (local.tee $1 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_malloc - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) - (i32.const 16) - ) - (i32.const 0) - ) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $1) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $1) - (i64.const 7496034) - ) - (local.set $1 - (tuple.extract 0 - (tuple.make - (local.get $1) - (local.get $1) - ) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) - ) - ) - (local.get $1) - ) - (func $foo_1133 (; has Stack IR ;) (param $0 i32) (result i32) + (func $func_1148 (; has Stack IR ;) (param $0 i32) (result i32) (local $1 i32) (i32.store (local.tee $1 @@ -87,7 +47,7 @@ basic functionality › func_shadow_and_indirect_call ) (i64.store offset=8 (local.get $1) - (i64.const 8020322) + (i64.const 7894385) ) (local.set $1 (tuple.extract 0 @@ -105,10 +65,14 @@ basic functionality › func_shadow_and_indirect_call ) (local.get $1) ) - (func $foo_1135 (; has Stack IR ;) (param $0 i32) (result i32) + (func $_gmain (; has Stack IR ;) (result i32) + (local $0 i32) (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) (i32.store - (local.tee $1 + (local.tee $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_malloc @@ -122,40 +86,44 @@ basic functionality › func_shadow_and_indirect_call (i32.const 6) ) (i32.store offset=4 - (local.get $1) + (local.get $0) (i32.const 1) ) (i32.store offset=8 - (local.get $1) - (i32.add - (global.get $wimport__grainEnv_relocBase) - (i32.const 3) - ) + (local.get $0) + (i32.const -1) ) (i32.store offset=12 - (local.get $1) + (local.get $0) (i32.const 0) ) + (global.set $global_0 + (tuple.extract 0 + (tuple.make + (local.get $0) + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (global.get $global_0) + ) + ) + ) + ) (local.set $1 (tuple.extract 0 (tuple.make - (local.get $1) - (local.get $1) + (global.get $global_0) + (local.get $0) ) ) ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) + (local.set $3 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $global_0) ) ) - (local.get $1) - ) - (func $func_1148 (; has Stack IR ;) (param $0 i32) (result i32) - (local $1 i32) (i32.store - (local.tee $1 + (local.tee $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_malloc @@ -169,34 +137,47 @@ basic functionality › func_shadow_and_indirect_call (i32.const 1) ) (i32.store offset=4 - (local.get $1) + (local.get $0) (i32.const 3) ) (i64.store offset=8 - (local.get $1) - (i64.const 7894385) + (local.get $0) + (i64.const 7496034) ) - (local.set $1 + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $3) + ) + ) + (local.set $3 (tuple.extract 0 (tuple.make - (local.get $1) - (local.get $1) + (tuple.extract 0 + (tuple.make + (local.get $0) + (local.get $0) + ) + ) + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 0) + ) ) ) ) (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) + (call $gimport_pervasives_print + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_print) + ) + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (local.get $3) + ) ) ) - (local.get $1) - ) - (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) (i32.store (local.tee $0 (tuple.extract 0 @@ -205,7 +186,7 @@ basic functionality › func_shadow_and_indirect_call (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) (i32.const 16) ) - (i32.const 0) + (local.get $1) ) ) ) @@ -217,38 +198,72 @@ basic functionality › func_shadow_and_indirect_call ) (i32.store offset=8 (local.get $0) - (global.get $wimport__grainEnv_relocBase) + (i32.const -1) ) (i32.store offset=12 (local.get $0) (i32.const 0) ) - (global.set $global_0 + (global.set $global_1 (tuple.extract 0 (tuple.make (local.get $0) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (global.get $global_0) + (global.get $global_1) ) ) ) ) - (local.set $0 + (local.set $2 (tuple.extract 0 (tuple.make - (global.get $global_0) + (global.get $global_1) (local.get $0) ) ) ) + (local.set $1 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $global_1) + ) + ) + (i32.store + (local.tee $0 + (tuple.extract 0 + (tuple.make + (call $wimport_GRAIN$MODULE$runtime/gc_malloc + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) + (i32.const 16) + ) + (i32.const 0) + ) + ) + ) + (i32.const 1) + ) + (i32.store offset=4 + (local.get $0) + (i32.const 3) + ) + (i64.store offset=8 + (local.get $0) + (i64.const 8020322) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $1) + ) + ) (local.set $1 (tuple.extract 0 (tuple.make - (call $foo_1131 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $global_0) + (tuple.extract 0 + (tuple.make + (local.get $0) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -278,7 +293,7 @@ basic functionality › func_shadow_and_indirect_call (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) (i32.const 16) ) - (local.get $0) + (local.get $2) ) ) ) @@ -290,60 +305,35 @@ basic functionality › func_shadow_and_indirect_call ) (i32.store offset=8 (local.get $0) - (i32.add - (global.get $wimport__grainEnv_relocBase) - (i32.const 1) - ) + (i32.const -1) ) (i32.store offset=12 (local.get $0) (i32.const 0) ) - (global.set $global_1 + (global.set $global_2 (tuple.extract 0 (tuple.make (local.get $0) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (global.get $global_1) + (global.get $global_2) ) ) ) ) - (local.set $0 - (tuple.extract 0 - (tuple.make - (global.get $global_1) - (local.get $0) - ) - ) - ) (local.set $2 (tuple.extract 0 (tuple.make - (call $foo_1133 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $global_1) - ) - ) - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (i32.const 0) - ) + (global.get $global_2) + (local.get $0) ) ) ) - (drop - (call $gimport_pervasives_print - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_print) - ) - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) - ) + (local.set $4 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $global_2) ) ) (i32.store @@ -354,7 +344,7 @@ basic functionality › func_shadow_and_indirect_call (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) (i32.const 16) ) - (local.get $0) + (i32.const 0) ) ) ) @@ -366,41 +356,25 @@ basic functionality › func_shadow_and_indirect_call ) (i32.store offset=8 (local.get $0) - (i32.add - (global.get $wimport__grainEnv_relocBase) - (i32.const 2) - ) + (global.get $wimport__grainEnv_relocBase) ) (i32.store offset=12 (local.get $0) (i32.const 0) ) - (global.set $global_2 - (tuple.extract 0 - (tuple.make - (local.get $0) - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (global.get $global_2) - ) - ) - ) - ) - (local.set $0 - (tuple.extract 0 - (tuple.make - (global.get $global_2) - (local.get $0) - ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $4) ) ) (global.set $global_3 (tuple.extract 0 (tuple.make - (call $foo_1135 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $global_2) + (tuple.extract 0 + (tuple.make + (local.get $0) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -410,7 +384,7 @@ basic functionality › func_shadow_and_indirect_call ) ) ) - (local.set $3 + (local.set $2 (tuple.extract 0 (tuple.make (call_indirect (type $i32_=>_i32) @@ -421,7 +395,7 @@ basic functionality › func_shadow_and_indirect_call (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $global_3) ) - (local.get $0) + (local.get $2) ) ) ) @@ -446,7 +420,7 @@ basic functionality › func_shadow_and_indirect_call ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $3) + (local.get $2) ) ) (local.get $0) @@ -456,19 +430,19 @@ basic functionality › func_shadow_and_indirect_call (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $3) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $2) ) ) (local.get $0) diff --git a/compiler/test/__snapshots__/enums.aa34084a.0.snapshot b/compiler/test/__snapshots__/enums.aa34084a.0.snapshot index 1711718212..44a24be52e 100644 --- a/compiler/test/__snapshots__/enums.aa34084a.0.snapshot +++ b/compiler/test/__snapshots__/enums.aa34084a.0.snapshot @@ -4,7 +4,6 @@ enums › adt_trailing (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"_grainEnv\" \"moduleRuntimeId\" (global $wimport__grainEnv_moduleRuntimeId i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) @@ -15,69 +14,13 @@ enums › adt_trailing (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (global $global_1 (mut i32) (i32.const 0)) (global $global_0 (mut i32) (i32.const 0)) - (global $global_3 i32 (i32.const 1)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $Cheese_1132) + (global $global_3 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"GRAIN$EXPORT$Pepperoni\" (global $global_1)) (export \"GRAIN$EXPORT$Cheese\" (global $global_0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_3)) - (func $Cheese_1132 (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (i32.store - (local.tee $2 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_malloc - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) - (i32.const 24) - ) - (i32.const 0) - ) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $2) - (i32.shl - (global.get $wimport__grainEnv_moduleRuntimeId) - (i32.const 1) - ) - ) - (i32.store offset=8 - (local.get $2) - (i32.const 2263) - ) - (i32.store offset=12 - (local.get $2) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $2) - (i32.const 1) - ) - (i32.store offset=20 - (local.get $2) - (local.get $1) - ) - (local.set $1 - (tuple.extract 0 - (tuple.make - (local.get $2) - (local.get $2) - ) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) - ) - ) - (local.get $1) - ) (func $_gmain (; has Stack IR ;) (result i32) (local $0 i32) (i32.store @@ -178,7 +121,7 @@ enums › adt_trailing ) (i32.store offset=8 (local.get $0) - (global.get $wimport__grainEnv_relocBase) + (i32.const -1) ) (i32.store offset=12 (local.get $0) diff --git a/compiler/test/__snapshots__/enums.ae26523b.0.snapshot b/compiler/test/__snapshots__/enums.ae26523b.0.snapshot index e353e02ce1..3fa8c8a2c6 100644 --- a/compiler/test/__snapshots__/enums.ae26523b.0.snapshot +++ b/compiler/test/__snapshots__/enums.ae26523b.0.snapshot @@ -5,7 +5,6 @@ enums › enum_recursive_data_definition (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"_grainEnv\" \"moduleRuntimeId\" (global $wimport__grainEnv_moduleRuntimeId i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) @@ -21,8 +20,7 @@ enums › enum_recursive_data_definition (global $global_4 (mut i32) (i32.const 0)) (global $global_1 (mut i32) (i32.const 0)) (global $global_2 (mut i32) (i32.const 0)) - (global $global_6 i32 (i32.const 2)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $Node_1134 $Cons_1136) + (global $global_6 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"GRAIN$EXPORT$Cons\" (global $global_3)) (export \"GRAIN$EXPORT$Empty\" (global $global_0)) @@ -356,7 +354,7 @@ enums › enum_recursive_data_definition ) (i32.store offset=8 (local.get $0) - (global.get $wimport__grainEnv_relocBase) + (i32.const -1) ) (i32.store offset=12 (local.get $0) @@ -442,10 +440,7 @@ enums › enum_recursive_data_definition ) (i32.store offset=8 (local.get $0) - (i32.add - (global.get $wimport__grainEnv_relocBase) - (i32.const 1) - ) + (i32.const -1) ) (i32.store offset=12 (local.get $0) diff --git a/compiler/test/__snapshots__/exceptions.a68ae348.0.snapshot b/compiler/test/__snapshots__/exceptions.a68ae348.0.snapshot index e269173f9b..42fa03ff94 100644 --- a/compiler/test/__snapshots__/exceptions.a68ae348.0.snapshot +++ b/compiler/test/__snapshots__/exceptions.a68ae348.0.snapshot @@ -5,7 +5,6 @@ exceptions › exception_4 (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"_grainEnv\" \"moduleRuntimeId\" (global $wimport__grainEnv_moduleRuntimeId i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) @@ -16,9 +15,9 @@ exceptions › exception_4 (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (global $global_1 (mut i32) (i32.const 0)) (global $global_0 (mut i32) (i32.const 0)) - (global $global_3 i32 (i32.const 1)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $Foo_1131) + (global $global_3 i32 (i32.const 0)) (export \"memory\" (memory $0)) + (export \"Foo\" (func $Foo_1131)) (export \"GRAIN$EXPORT$Bar\" (global $global_1)) (export \"GRAIN$EXPORT$Foo\" (global $global_0)) (export \"_gmain\" (func $_gmain)) @@ -188,7 +187,7 @@ exceptions › exception_4 ) (i32.store offset=8 (local.get $0) - (global.get $wimport__grainEnv_relocBase) + (i32.const -1) ) (i32.store offset=12 (local.get $0) @@ -272,5 +271,5 @@ exceptions › exception_4 (call $_gmain) ) ) - ;; custom section \"cmi\", size 1093 + ;; custom section \"cmi\", size 1254 ) diff --git a/compiler/test/__snapshots__/exceptions.ccac3e71.0.snapshot b/compiler/test/__snapshots__/exceptions.ccac3e71.0.snapshot index d8678726bf..0c6f159f4e 100644 --- a/compiler/test/__snapshots__/exceptions.ccac3e71.0.snapshot +++ b/compiler/test/__snapshots__/exceptions.ccac3e71.0.snapshot @@ -142,5 +142,5 @@ exceptions › exception_2 (call $_gmain) ) ) - ;; custom section \"cmi\", size 566 + ;; custom section \"cmi\", size 620 ) diff --git a/compiler/test/__snapshots__/exports.a2013f43.0.snapshot b/compiler/test/__snapshots__/exports.a2013f43.0.snapshot index deae89c351..2c64ea1eab 100644 --- a/compiler/test/__snapshots__/exports.a2013f43.0.snapshot +++ b/compiler/test/__snapshots__/exports.a2013f43.0.snapshot @@ -5,15 +5,13 @@ exports › let_rec_export (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"malloc\" (func $wimport_GRAIN$MODULE$runtime/gc_malloc (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (global $global_0 (mut i32) (i32.const 0)) - (global $global_2 i32 (i32.const 1)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $foo_1131) + (global $global_2 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"foo\" (func $foo_1131)) (export \"GRAIN$EXPORT$foo\" (global $global_0)) @@ -51,7 +49,7 @@ exports › let_rec_export ) (i32.store offset=8 (local.get $0) - (global.get $wimport__grainEnv_relocBase) + (i32.const -1) ) (i32.store offset=12 (local.get $0) diff --git a/compiler/test/__snapshots__/functions.06134c8a.0.snapshot b/compiler/test/__snapshots__/functions.06134c8a.0.snapshot index e93011c94e..d29556fbe8 100644 --- a/compiler/test/__snapshots__/functions.06134c8a.0.snapshot +++ b/compiler/test/__snapshots__/functions.06134c8a.0.snapshot @@ -1,11 +1,9 @@ functions › dup_func (module (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) @@ -14,23 +12,14 @@ functions › dup_func (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (global $global_0 (mut i32) (i32.const 0)) - (global $global_2 i32 (i32.const 1)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $foo_1135) + (global $global_2 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_2)) - (func $foo_1135 (; has Stack IR ;) (param $0 i32) (result i32) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) - ) - ) - (i32.const 19) - ) (func $_gmain (; has Stack IR ;) (result i32) (local $0 i32) + (local $1 i32) (i32.store (local.tee $0 (tuple.extract 0 @@ -51,7 +40,7 @@ functions › dup_func ) (i32.store offset=8 (local.get $0) - (global.get $wimport__grainEnv_relocBase) + (i32.const -1) ) (i32.store offset=12 (local.get $0) @@ -76,14 +65,21 @@ functions › dup_func ) ) ) + (local.set $1 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $global_0) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $1) + ) + ) (tuple.extract 0 (tuple.make - (call $foo_1135 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $global_0) - ) - ) + (i32.const 19) (local.get $0) ) ) diff --git a/compiler/test/__snapshots__/functions.14922a92.0.snapshot b/compiler/test/__snapshots__/functions.14922a92.0.snapshot index e2638455f7..72c7f73db6 100644 --- a/compiler/test/__snapshots__/functions.14922a92.0.snapshot +++ b/compiler/test/__snapshots__/functions.14922a92.0.snapshot @@ -5,7 +5,6 @@ functions › shorthand_4 (type $none_=>_none (func)) (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) @@ -16,48 +15,15 @@ functions › shorthand_4 (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$pervasives\" \"+\" (func $gimport_pervasives_+ (param i32 i32 i32) (result i32))) (global $global_0 (mut i32) (i32.const 0)) - (global $global_2 i32 (i32.const 1)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $foo_1131) + (global $global_2 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_2)) - (func $foo_1131 (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local.set $2 - (tuple.extract 0 - (tuple.make - (call $gimport_pervasives_+ - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) - ) - (i32.const 7) - ) - (i32.const 0) - ) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) - ) - ) - (local.get $2) - ) (func $_gmain (; has Stack IR ;) (result i32) (local $0 i32) + (local $1 i32) + (local $2 i32) (i32.store (local.tee $0 (tuple.extract 0 @@ -78,7 +44,7 @@ functions › shorthand_4 ) (i32.store offset=8 (local.get $0) - (global.get $wimport__grainEnv_relocBase) + (i32.const -1) ) (i32.store offset=12 (local.get $0) @@ -103,15 +69,45 @@ functions › shorthand_4 ) ) ) - (tuple.extract 0 - (tuple.make - (call $foo_1131 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $global_0) + (local.set $1 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $global_0) + ) + ) + (local.set $2 + (tuple.extract 0 + (tuple.make + (call $gimport_pervasives_+ + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_+) + ) + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (i32.const 3) + ) + (i32.const 7) ) - (i32.const 3) + (i32.const 0) ) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $1) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 3) + ) + ) + (tuple.extract 0 + (tuple.make + (local.get $2) (local.get $0) ) ) diff --git a/compiler/test/__snapshots__/functions.1be5ecd5.0.snapshot b/compiler/test/__snapshots__/functions.1be5ecd5.0.snapshot index b10e11b7a1..091434df9d 100644 --- a/compiler/test/__snapshots__/functions.1be5ecd5.0.snapshot +++ b/compiler/test/__snapshots__/functions.1be5ecd5.0.snapshot @@ -4,7 +4,6 @@ functions › shorthand_1 (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) @@ -13,41 +12,15 @@ functions › shorthand_1 (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (global $global_0 (mut i32) (i32.const 0)) - (global $global_2 i32 (i32.const 1)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $foo_1131) + (global $global_2 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_2)) - (func $foo_1131 (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local.set $2 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) - ) - (i32.const 0) - ) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) - ) - ) - (local.get $2) - ) (func $_gmain (; has Stack IR ;) (result i32) (local $0 i32) + (local $1 i32) + (local $2 i32) (i32.store (local.tee $0 (tuple.extract 0 @@ -68,7 +41,7 @@ functions › shorthand_1 ) (i32.store offset=8 (local.get $0) - (global.get $wimport__grainEnv_relocBase) + (i32.const -1) ) (i32.store offset=12 (local.get $0) @@ -93,15 +66,38 @@ functions › shorthand_1 ) ) ) - (tuple.extract 0 - (tuple.make - (call $foo_1131 + (local.set $1 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $global_0) + ) + ) + (local.set $2 + (tuple.extract 0 + (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $global_0) + (i32.const 3) ) - (i32.const 3) + (i32.const 0) ) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $1) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 3) + ) + ) + (tuple.extract 0 + (tuple.make + (local.get $2) (local.get $0) ) ) diff --git a/compiler/test/__snapshots__/functions.23afd9c9.0.snapshot b/compiler/test/__snapshots__/functions.23afd9c9.0.snapshot index 6c4c4b890a..cbc8230efe 100644 --- a/compiler/test/__snapshots__/functions.23afd9c9.0.snapshot +++ b/compiler/test/__snapshots__/functions.23afd9c9.0.snapshot @@ -1,11 +1,10 @@ functions › lam_destructure_5 (module (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) @@ -15,13 +14,15 @@ functions › lam_destructure_5 (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$pervasives\" \"+\" (func $gimport_pervasives_+ (param i32 i32 i32) (result i32))) - (global $global_1 i32 (i32.const 1)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $lam_lambda_1136) + (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) - (func $lam_lambda_1136 (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $_gmain (; has Stack IR ;) (result i32) + (local $0 i32) + (local $1 i32) + (local $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -31,7 +32,149 @@ functions › lam_destructure_5 (local $9 i32) (local $10 i32) (local $11 i32) + (local $12 i32) + (local $13 i32) + (local $14 i32) + (local $15 i32) + (i32.store + (local.tee $0 + (tuple.extract 0 + (tuple.make + (call $wimport_GRAIN$MODULE$runtime/gc_malloc + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) + (i32.const 16) + ) + (i32.const 0) + ) + ) + ) + (i32.const 6) + ) + (i32.store offset=4 + (local.get $0) + (i32.const 3) + ) + (i32.store offset=8 + (local.get $0) + (i32.const -1) + ) + (i32.store offset=12 + (local.get $0) + (i32.const 0) + ) + (local.set $2 + (tuple.extract 0 + (tuple.make + (local.get $0) + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 0) + ) + ) + ) + ) + (i32.store + (local.tee $0 + (tuple.extract 0 + (tuple.make + (call $wimport_GRAIN$MODULE$runtime/gc_malloc + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) + (i32.const 20) + ) + (tuple.extract 0 + (tuple.make + (local.get $2) + (local.get $0) + ) + ) + ) + ) + ) + (i32.const 7) + ) + (i32.store offset=4 + (local.get $0) + (i32.const 3) + ) + (i32.store offset=8 + (local.get $0) + (i32.const 3) + ) + (i32.store offset=12 + (local.get $0) + (i32.const 5) + ) + (i32.store offset=16 + (local.get $0) + (i32.const 7) + ) + (local.set $4 + (tuple.extract 0 + (tuple.make + (local.get $0) + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 0) + ) + ) + ) + ) + (i32.store + (local.tee $0 + (tuple.extract 0 + (tuple.make + (call $wimport_GRAIN$MODULE$runtime/gc_malloc + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) + (i32.const 16) + ) + (local.get $0) + ) + ) + ) + (i32.const 7) + ) + (i32.store offset=4 + (local.get $0) + (i32.const 2) + ) + (i32.store offset=8 + (local.get $0) + (i32.const 9) + ) + (i32.store offset=12 + (local.get $0) + (i32.const 11) + ) + (local.set $5 + (tuple.extract 0 + (tuple.make + (local.get $0) + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 0) + ) + ) + ) + ) + (local.set $14 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (local.get $2) + ) + ) + (local.set $1 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (local.get $4) + ) + ) (local.set $3 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (local.get $5) + ) + ) + (local.set $6 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -47,7 +190,7 @@ functions › lam_destructure_5 ) ) ) - (local.set $4 + (local.set $7 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -63,7 +206,7 @@ functions › lam_destructure_5 ) ) ) - (local.set $5 + (local.set $8 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -79,13 +222,13 @@ functions › lam_destructure_5 ) ) ) - (local.set $6 + (local.set $9 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=12 - (local.get $2) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -95,13 +238,13 @@ functions › lam_destructure_5 ) ) ) - (local.set $7 + (local.set $10 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=8 - (local.get $2) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -111,7 +254,7 @@ functions › lam_destructure_5 ) ) ) - (local.set $8 + (local.set $11 (tuple.extract 0 (tuple.make (call $gimport_pervasives_+ @@ -121,11 +264,11 @@ functions › lam_destructure_5 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $5) + (local.get $8) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $4) + (local.get $7) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -135,7 +278,7 @@ functions › lam_destructure_5 ) ) ) - (local.set $9 + (local.set $12 (tuple.extract 0 (tuple.make (call $gimport_pervasives_+ @@ -145,11 +288,11 @@ functions › lam_destructure_5 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $8) + (local.get $11) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $3) + (local.get $6) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -159,7 +302,7 @@ functions › lam_destructure_5 ) ) ) - (local.set $10 + (local.set $13 (tuple.extract 0 (tuple.make (call $gimport_pervasives_+ @@ -169,11 +312,11 @@ functions › lam_destructure_5 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $9) + (local.get $12) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $7) + (local.get $10) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -183,7 +326,7 @@ functions › lam_destructure_5 ) ) ) - (local.set $11 + (local.set $15 (tuple.extract 0 (tuple.make (call $gimport_pervasives_+ @@ -193,11 +336,11 @@ functions › lam_destructure_5 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $10) + (local.get $13) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $6) + (local.get $9) ) ) (i32.const 0) @@ -207,7 +350,7 @@ functions › lam_destructure_5 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) + (local.get $14) ) ) (drop @@ -219,201 +362,61 @@ functions › lam_destructure_5 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $3) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $6) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $4) + (local.get $7) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $5) + (local.get $8) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $6) + (local.get $9) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $7) + (local.get $10) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $8) + (local.get $11) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $9) + (local.get $12) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $10) - ) - ) - (local.get $11) - ) - (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (i32.store - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_malloc - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) - (i32.const 16) - ) - (i32.const 0) - ) - ) - ) - (i32.const 6) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (global.get $wimport__grainEnv_relocBase) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (local.set $1 - (tuple.extract 0 - (tuple.make - (local.get $0) - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (i32.const 0) - ) - ) - ) - ) - (i32.store - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_malloc - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) - (i32.const 20) - ) - (tuple.extract 0 - (tuple.make - (local.get $1) - (local.get $0) - ) - ) - ) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.set $2 - (tuple.extract 0 - (tuple.make - (local.get $0) - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (i32.const 0) - ) - ) - ) - ) - (i32.store - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_malloc - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) - (i32.const 16) - ) - (local.get $0) - ) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 11) - ) - (local.set $3 - (tuple.extract 0 - (tuple.make - (local.get $0) - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (i32.const 0) - ) - ) + (local.get $13) ) ) (local.set $0 (tuple.extract 0 (tuple.make - (call $lam_lambda_1136 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) - ) - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) - ) - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $3) - ) - ) + (local.get $15) (local.get $0) ) ) @@ -421,19 +424,19 @@ functions › lam_destructure_5 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $2) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $4) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $5) ) ) (local.get $0) diff --git a/compiler/test/__snapshots__/functions.28e0f2b3.0.snapshot b/compiler/test/__snapshots__/functions.28e0f2b3.0.snapshot index 6362558b6a..f551927079 100644 --- a/compiler/test/__snapshots__/functions.28e0f2b3.0.snapshot +++ b/compiler/test/__snapshots__/functions.28e0f2b3.0.snapshot @@ -4,7 +4,6 @@ functions › lambda_pat_any (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) @@ -13,30 +12,16 @@ functions › lambda_pat_any (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (global $global_0 (mut i32) (i32.const 0)) - (global $global_2 i32 (i32.const 1)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $x_1131) + (global $global_2 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_2)) - (func $x_1131 (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) - ) - ) - (i32.const 11) - ) (func $_gmain (; has Stack IR ;) (result i32) (local $0 i32) (local $1 i32) + (local $2 i32) + (local $3 i32) (i32.store (local.tee $0 (tuple.extract 0 @@ -57,7 +42,7 @@ functions › lambda_pat_any ) (i32.store offset=8 (local.get $0) - (global.get $wimport__grainEnv_relocBase) + (i32.const -1) ) (i32.store offset=12 (local.get $0) @@ -115,19 +100,34 @@ functions › lambda_pat_any ) ) ) + (local.set $2 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $global_0) + ) + ) + (local.set $3 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (local.get $1) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $2) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $3) + ) + ) (local.set $0 (tuple.extract 0 (tuple.make - (call $x_1131 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $global_0) - ) - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) - ) - ) + (i32.const 11) (local.get $0) ) ) diff --git a/compiler/test/__snapshots__/functions.49ccab54.0.snapshot b/compiler/test/__snapshots__/functions.49ccab54.0.snapshot index ee4c903ad7..465714c230 100644 --- a/compiler/test/__snapshots__/functions.49ccab54.0.snapshot +++ b/compiler/test/__snapshots__/functions.49ccab54.0.snapshot @@ -16,72 +16,12 @@ functions › curried_func (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$pervasives\" \"+\" (func $gimport_pervasives_+ (param i32 i32 i32) (result i32))) (global $global_0 (mut i32) (i32.const 0)) - (global $global_2 i32 (i32.const 2)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $add_1131 $func_1141) + (global $global_2 i32 (i32.const 1)) + (elem $elem (global.get $wimport__grainEnv_relocBase) $func_1141) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_2)) - (func $add_1131 (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (i32.store - (local.tee $2 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_malloc - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) - (i32.const 20) - ) - (i32.const 0) - ) - ) - ) - (i32.const 6) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $2) - (i32.add - (global.get $wimport__grainEnv_relocBase) - (i32.const 1) - ) - ) - (i32.store offset=12 - (local.get $2) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $2) - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) - ) - ) - (local.set $2 - (tuple.extract 0 - (tuple.make - (local.get $2) - (local.get $2) - ) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) - ) - ) - (local.get $2) - ) (func $func_1141 (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local.set $2 @@ -124,6 +64,7 @@ functions › curried_func (func $_gmain (; has Stack IR ;) (result i32) (local $0 i32) (local $1 i32) + (local $2 i32) (i32.store (local.tee $0 (tuple.extract 0 @@ -144,7 +85,7 @@ functions › curried_func ) (i32.store offset=8 (local.get $0) - (global.get $wimport__grainEnv_relocBase) + (i32.const -1) ) (i32.store offset=12 (local.get $0) @@ -169,15 +110,65 @@ functions › curried_func ) ) ) + (local.set $2 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $global_0) + ) + ) + (i32.store + (local.tee $0 + (tuple.extract 0 + (tuple.make + (call $wimport_GRAIN$MODULE$runtime/gc_malloc + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) + (i32.const 20) + ) + (i32.const 0) + ) + ) + ) + (i32.const 6) + ) + (i32.store offset=4 + (local.get $0) + (i32.const 2) + ) + (i32.store offset=8 + (local.get $0) + (global.get $wimport__grainEnv_relocBase) + ) + (i32.store offset=12 + (local.get $0) + (i32.const 1) + ) + (i32.store offset=16 + (local.get $0) + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (i32.const 5) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $2) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 5) + ) + ) (local.set $0 (tuple.extract 0 (tuple.make - (call $add_1131 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $global_0) + (tuple.extract 0 + (tuple.make + (local.get $0) + (local.get $0) ) - (i32.const 5) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) diff --git a/compiler/test/__snapshots__/functions.6eacded0.0.snapshot b/compiler/test/__snapshots__/functions.6eacded0.0.snapshot index bd1041197f..c182b8fb8e 100644 --- a/compiler/test/__snapshots__/functions.6eacded0.0.snapshot +++ b/compiler/test/__snapshots__/functions.6eacded0.0.snapshot @@ -22,74 +22,14 @@ functions › func_recursive_closure (import \"GRAIN$MODULE$pervasives\" \"+\" (func $gimport_pervasives_+ (param i32 i32 i32) (result i32))) (global $global_1 (mut i32) (i32.const 0)) (global $global_0 (mut i32) (i32.const 0)) - (global $global_3 i32 (i32.const 5)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $makeAdder_1131 $truc_1134 $func_1165 $foo_1135 $bar_1138) + (global $global_3 i32 (i32.const 1)) + (elem $elem (global.get $wimport__grainEnv_relocBase) $func_1165) (export \"memory\" (memory $0)) (export \"truc\" (func $truc_1134)) (export \"GRAIN$EXPORT$truc\" (global $global_1)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_3)) - (func $makeAdder_1131 (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (i32.store - (local.tee $2 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_malloc - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) - (i32.const 20) - ) - (i32.const 0) - ) - ) - ) - (i32.const 6) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $2) - (i32.add - (global.get $wimport__grainEnv_relocBase) - (i32.const 2) - ) - ) - (i32.store offset=12 - (local.get $2) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $2) - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) - ) - ) - (local.set $2 - (tuple.extract 0 - (tuple.make - (local.get $2) - (local.get $2) - ) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) - ) - ) - (local.get $2) - ) (func $truc_1134 (; has Stack IR ;) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) @@ -113,10 +53,7 @@ functions › func_recursive_closure ) (i32.store offset=8 (local.get $1) - (i32.add - (global.get $wimport__grainEnv_relocBase) - (i32.const 3) - ) + (i32.const -1) ) (i32.store offset=12 (local.get $1) @@ -210,15 +147,69 @@ functions › func_recursive_closure (local $3 i32) (local $4 i32) (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + (local $9 i32) + (local.set $3 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $global_0) + ) + ) + (i32.store + (local.tee $2 + (tuple.extract 0 + (tuple.make + (call $wimport_GRAIN$MODULE$runtime/gc_malloc + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) + (i32.const 20) + ) + (i32.const 0) + ) + ) + ) + (i32.const 6) + ) + (i32.store offset=4 + (local.get $2) + (i32.const 2) + ) + (i32.store offset=8 + (local.get $2) + (global.get $wimport__grainEnv_relocBase) + ) + (i32.store offset=12 + (local.get $2) + (i32.const 1) + ) + (i32.store offset=16 + (local.get $2) + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (i32.const 3) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $3) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 3) + ) + ) (local.set $3 (tuple.extract 0 (tuple.make - (call $makeAdder_1131 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $global_0) + (tuple.extract 0 + (tuple.make + (local.get $2) + (local.get $2) ) - (i32.const 3) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -247,20 +238,17 @@ functions › func_recursive_closure ) (i32.store offset=8 (local.get $2) - (i32.add - (global.get $wimport__grainEnv_relocBase) - (i32.const 4) - ) + (i32.const -1) ) (i32.store offset=12 (local.get $2) (i32.const 2) ) (i32.store offset=16 - (local.tee $2 + (local.tee $6 (tuple.extract 0 (tuple.make - (local.tee $4 + (local.tee $5 (tuple.extract 0 (tuple.make (local.get $2) @@ -281,7 +269,7 @@ functions › func_recursive_closure ) ) (i32.store offset=20 - (local.get $2) + (local.get $6) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $3) @@ -331,15 +319,110 @@ functions › func_recursive_closure ) (i32.const 31) ) - (call $bar_1138 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $4) + (block (result i32) + (local.set $2 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (local.get $5) + ) + ) + (local.set $7 + (tuple.extract 0 + (tuple.make + (call $foo_1135 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (i32.load offset=16 + (local.get $2) + ) + ) + (i32.const 1) + ) + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 0) + ) + ) + ) ) - (i32.const 3) + (local.set $8 + (tuple.extract 0 + (tuple.make + (call_indirect (type $i32_i32_=>_i32) + (local.tee $4 + (tuple.extract 0 + (tuple.make + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (i32.load offset=20 + (local.get $2) + ) + ) + (i32.const 0) + ) + ) + ) + (i32.const 3) + (i32.load offset=8 + (local.get $4) + ) + ) + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 0) + ) + ) + ) + ) + (local.set $4 + (tuple.extract 0 + (tuple.make + (call $gimport_pervasives_+ + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_+) + ) + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (local.get $7) + ) + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (local.get $8) + ) + ) + (local.get $4) + ) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $2) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 3) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $7) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $8) + ) + ) + (local.get $4) ) (block (result i32) - (local.set $5 + (local.set $9 (tuple.extract 0 (tuple.make (call $gimport_pervasives_- @@ -367,13 +450,13 @@ functions › func_recursive_closure ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $5) + (local.get $9) ) ) ) ) ) - (local.get $2) + (local.get $6) ) ) ) @@ -395,115 +478,16 @@ functions › func_recursive_closure (local.get $3) ) ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $4) - ) - ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) (local.get $5) ) ) - (local.get $2) - ) - (func $bar_1138 (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local.set $3 - (tuple.extract 0 - (tuple.make - (call $foo_1135 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (i32.load offset=16 - (local.get $0) - ) - ) - (i32.const 1) - ) - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (i32.const 0) - ) - ) - ) - ) - (local.set $4 - (tuple.extract 0 - (tuple.make - (call_indirect (type $i32_i32_=>_i32) - (local.tee $2 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (i32.load offset=20 - (local.get $0) - ) - ) - (i32.const 0) - ) - ) - ) - (i32.const 3) - (i32.load offset=8 - (local.get $2) - ) - ) - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (i32.const 0) - ) - ) - ) - ) - (local.set $2 - (tuple.extract 0 - (tuple.make - (call $gimport_pervasives_+ - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $3) - ) - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $4) - ) - ) - (local.get $2) - ) - ) - ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $4) + (local.get $9) ) ) (local.get $2) @@ -530,7 +514,7 @@ functions › func_recursive_closure ) (i32.store offset=8 (local.get $0) - (global.get $wimport__grainEnv_relocBase) + (i32.const -1) ) (i32.store offset=12 (local.get $0) @@ -575,10 +559,7 @@ functions › func_recursive_closure ) (i32.store offset=8 (local.get $0) - (i32.add - (global.get $wimport__grainEnv_relocBase) - (i32.const 1) - ) + (i32.const -1) ) (i32.store offset=12 (local.get $0) diff --git a/compiler/test/__snapshots__/functions.7a8986a5.0.snapshot b/compiler/test/__snapshots__/functions.7a8986a5.0.snapshot index 720f68abf5..6ebca664d0 100644 --- a/compiler/test/__snapshots__/functions.7a8986a5.0.snapshot +++ b/compiler/test/__snapshots__/functions.7a8986a5.0.snapshot @@ -4,7 +4,6 @@ functions › app_1 (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) @@ -12,42 +11,16 @@ functions › app_1 (import \"GRAIN$MODULE$runtime/gc\" \"malloc\" (func $wimport_GRAIN$MODULE$runtime/gc_malloc (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) - (global $global_1 i32 (i32.const 1)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $lam_lambda_1132) + (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) - (func $lam_lambda_1132 (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local.set $2 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) - ) - (i32.const 0) - ) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) - ) - ) - (local.get $2) - ) (func $_gmain (; has Stack IR ;) (result i32) (local $0 i32) (local $1 i32) + (local $2 i32) + (local $3 i32) (i32.store (local.tee $0 (tuple.extract 0 @@ -68,7 +41,7 @@ functions › app_1 ) (i32.store offset=8 (local.get $0) - (global.get $wimport__grainEnv_relocBase) + (i32.const -1) ) (i32.store offset=12 (local.get $0) @@ -85,16 +58,39 @@ functions › app_1 ) ) ) - (local.set $0 + (local.set $2 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (local.get $1) + ) + ) + (local.set $3 (tuple.extract 0 (tuple.make - (call $lam_lambda_1132 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) - ) + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.const 3) ) + (i32.const 0) + ) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $2) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 3) + ) + ) + (local.set $0 + (tuple.extract 0 + (tuple.make + (local.get $3) (tuple.extract 0 (tuple.make (local.get $1) diff --git a/compiler/test/__snapshots__/functions.84b6e84b.0.snapshot b/compiler/test/__snapshots__/functions.84b6e84b.0.snapshot index 2148df686b..f4a5f97cc7 100644 --- a/compiler/test/__snapshots__/functions.84b6e84b.0.snapshot +++ b/compiler/test/__snapshots__/functions.84b6e84b.0.snapshot @@ -4,7 +4,6 @@ functions › shorthand_3 (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) @@ -13,41 +12,15 @@ functions › shorthand_3 (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (global $global_0 (mut i32) (i32.const 0)) - (global $global_2 i32 (i32.const 1)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $foo_1131) + (global $global_2 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_2)) - (func $foo_1131 (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local.set $2 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) - ) - (i32.const 0) - ) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) - ) - ) - (local.get $2) - ) (func $_gmain (; has Stack IR ;) (result i32) (local $0 i32) + (local $1 i32) + (local $2 i32) (i32.store (local.tee $0 (tuple.extract 0 @@ -68,7 +41,7 @@ functions › shorthand_3 ) (i32.store offset=8 (local.get $0) - (global.get $wimport__grainEnv_relocBase) + (i32.const -1) ) (i32.store offset=12 (local.get $0) @@ -93,15 +66,38 @@ functions › shorthand_3 ) ) ) - (tuple.extract 0 - (tuple.make - (call $foo_1131 + (local.set $1 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $global_0) + ) + ) + (local.set $2 + (tuple.extract 0 + (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $global_0) + (i32.const 3) ) - (i32.const 3) + (i32.const 0) ) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $1) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 3) + ) + ) + (tuple.extract 0 + (tuple.make + (local.get $2) (local.get $0) ) ) diff --git a/compiler/test/__snapshots__/functions.8baf471f.0.snapshot b/compiler/test/__snapshots__/functions.8baf471f.0.snapshot index 8a28dc5bba..44eb571fc4 100644 --- a/compiler/test/__snapshots__/functions.8baf471f.0.snapshot +++ b/compiler/test/__snapshots__/functions.8baf471f.0.snapshot @@ -5,7 +5,6 @@ functions › lam_destructure_3 (type $none_=>_none (func)) (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) @@ -15,19 +14,118 @@ functions › lam_destructure_3 (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$pervasives\" \"+\" (func $gimport_pervasives_+ (param i32 i32 i32) (result i32))) - (global $global_1 i32 (i32.const 1)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $lam_lambda_1134) + (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) - (func $lam_lambda_1134 (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) + (func $_gmain (; has Stack IR ;) (result i32) + (local $0 i32) + (local $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) + (local $7 i32) + (local $8 i32) + (local $9 i32) + (i32.store + (local.tee $0 + (tuple.extract 0 + (tuple.make + (call $wimport_GRAIN$MODULE$runtime/gc_malloc + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) + (i32.const 16) + ) + (i32.const 0) + ) + ) + ) + (i32.const 6) + ) + (i32.store offset=4 + (local.get $0) + (i32.const 2) + ) + (i32.store offset=8 + (local.get $0) + (i32.const -1) + ) + (i32.store offset=12 + (local.get $0) + (i32.const 0) + ) (local.set $2 + (tuple.extract 0 + (tuple.make + (local.get $0) + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 0) + ) + ) + ) + ) + (i32.store + (local.tee $0 + (tuple.extract 0 + (tuple.make + (call $wimport_GRAIN$MODULE$runtime/gc_malloc + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) + (i32.const 20) + ) + (tuple.extract 0 + (tuple.make + (local.get $2) + (local.get $0) + ) + ) + ) + ) + ) + (i32.const 7) + ) + (i32.store offset=4 + (local.get $0) + (i32.const 3) + ) + (i32.store offset=8 + (local.get $0) + (i32.const 3) + ) + (i32.store offset=12 + (local.get $0) + (i32.const 5) + ) + (i32.store offset=16 + (local.get $0) + (i32.const 7) + ) + (local.set $3 + (tuple.extract 0 + (tuple.make + (local.get $0) + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 0) + ) + ) + ) + ) + (local.set $8 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (local.get $2) + ) + ) + (local.set $1 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (local.get $3) + ) + ) + (local.set $4 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -43,7 +141,7 @@ functions › lam_destructure_3 ) ) ) - (local.set $3 + (local.set $5 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -59,7 +157,7 @@ functions › lam_destructure_3 ) ) ) - (local.set $4 + (local.set $6 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -75,7 +173,7 @@ functions › lam_destructure_3 ) ) ) - (local.set $5 + (local.set $7 (tuple.extract 0 (tuple.make (call $gimport_pervasives_+ @@ -85,11 +183,11 @@ functions › lam_destructure_3 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $4) + (local.get $6) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $3) + (local.get $5) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -99,7 +197,7 @@ functions › lam_destructure_3 ) ) ) - (local.set $6 + (local.set $9 (tuple.extract 0 (tuple.make (call $gimport_pervasives_+ @@ -109,11 +207,11 @@ functions › lam_destructure_3 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $5) + (local.get $7) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) + (local.get $4) ) ) (i32.const 0) @@ -123,7 +221,7 @@ functions › lam_destructure_3 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) + (local.get $8) ) ) (drop @@ -135,129 +233,31 @@ functions › lam_destructure_3 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $4) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $5) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $4) + (local.get $6) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $5) - ) - ) - (local.get $6) - ) - (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (i32.store - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_malloc - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) - (i32.const 16) - ) - (i32.const 0) - ) - ) - ) - (i32.const 6) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (global.get $wimport__grainEnv_relocBase) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (local.set $1 - (tuple.extract 0 - (tuple.make - (local.get $0) - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (i32.const 0) - ) - ) - ) - ) - (i32.store - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_malloc - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) - (i32.const 20) - ) - (tuple.extract 0 - (tuple.make - (local.get $1) - (local.get $0) - ) - ) - ) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.set $2 - (tuple.extract 0 - (tuple.make - (local.get $0) - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (i32.const 0) - ) - ) + (local.get $7) ) ) (local.set $0 (tuple.extract 0 (tuple.make - (call $lam_lambda_1134 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) - ) - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) - ) - ) + (local.get $9) (local.get $0) ) ) @@ -265,13 +265,13 @@ functions › lam_destructure_3 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $2) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $3) ) ) (local.get $0) diff --git a/compiler/test/__snapshots__/functions.9223245d.0.snapshot b/compiler/test/__snapshots__/functions.9223245d.0.snapshot index a2c6b35383..faaee6a114 100644 --- a/compiler/test/__snapshots__/functions.9223245d.0.snapshot +++ b/compiler/test/__snapshots__/functions.9223245d.0.snapshot @@ -5,7 +5,6 @@ functions › lam_destructure_7 (type $none_=>_none (func)) (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) @@ -15,13 +14,14 @@ functions › lam_destructure_7 (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$pervasives\" \"+\" (func $gimport_pervasives_+ (param i32 i32 i32) (result i32))) - (global $global_1 i32 (i32.const 1)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $lam_lambda_1135) + (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) - (func $lam_lambda_1135 (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) + (func $_gmain (; has Stack IR ;) (result i32) + (local $0 i32) + (local $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -30,7 +30,146 @@ functions › lam_destructure_7 (local $7 i32) (local $8 i32) (local $9 i32) + (local $10 i32) + (local $11 i32) + (local $12 i32) + (local $13 i32) + (i32.store + (local.tee $0 + (tuple.extract 0 + (tuple.make + (call $wimport_GRAIN$MODULE$runtime/gc_malloc + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) + (i32.const 16) + ) + (i32.const 0) + ) + ) + ) + (i32.const 6) + ) + (i32.store offset=4 + (local.get $0) + (i32.const 2) + ) + (i32.store offset=8 + (local.get $0) + (i32.const -1) + ) + (i32.store offset=12 + (local.get $0) + (i32.const 0) + ) (local.set $2 + (tuple.extract 0 + (tuple.make + (local.get $0) + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 0) + ) + ) + ) + ) + (i32.store + (local.tee $0 + (tuple.extract 0 + (tuple.make + (call $wimport_GRAIN$MODULE$runtime/gc_malloc + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) + (i32.const 16) + ) + (tuple.extract 0 + (tuple.make + (local.get $2) + (local.get $0) + ) + ) + ) + ) + ) + (i32.const 7) + ) + (i32.store offset=4 + (local.get $0) + (i32.const 2) + ) + (i32.store offset=8 + (local.get $0) + (i32.const 7) + ) + (i32.store offset=12 + (local.get $0) + (i32.const 9) + ) + (local.set $4 + (tuple.extract 0 + (tuple.make + (local.get $0) + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 0) + ) + ) + ) + ) + (i32.store + (local.tee $0 + (tuple.extract 0 + (tuple.make + (call $wimport_GRAIN$MODULE$runtime/gc_malloc + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) + (i32.const 20) + ) + (local.get $0) + ) + ) + ) + (i32.const 7) + ) + (i32.store offset=4 + (local.get $0) + (i32.const 3) + ) + (i32.store offset=8 + (local.get $0) + (i32.const 3) + ) + (i32.store offset=12 + (local.get $0) + (i32.const 5) + ) + (i32.store offset=16 + (local.get $0) + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (local.get $4) + ) + ) + (local.set $5 + (tuple.extract 0 + (tuple.make + (local.get $0) + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 0) + ) + ) + ) + ) + (local.set $12 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (local.get $2) + ) + ) + (local.set $1 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (local.get $5) + ) + ) + (local.set $3 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -46,13 +185,13 @@ functions › lam_destructure_7 ) ) ) - (local.set $3 + (local.set $6 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=12 - (local.get $2) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -62,13 +201,13 @@ functions › lam_destructure_7 ) ) ) - (local.set $4 + (local.set $7 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=8 - (local.get $2) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -78,7 +217,7 @@ functions › lam_destructure_7 ) ) ) - (local.set $5 + (local.set $8 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -94,7 +233,7 @@ functions › lam_destructure_7 ) ) ) - (local.set $6 + (local.set $9 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -110,7 +249,7 @@ functions › lam_destructure_7 ) ) ) - (local.set $7 + (local.set $10 (tuple.extract 0 (tuple.make (call $gimport_pervasives_+ @@ -120,11 +259,11 @@ functions › lam_destructure_7 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $6) + (local.get $9) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $5) + (local.get $8) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -134,7 +273,7 @@ functions › lam_destructure_7 ) ) ) - (local.set $8 + (local.set $11 (tuple.extract 0 (tuple.make (call $gimport_pervasives_+ @@ -144,11 +283,11 @@ functions › lam_destructure_7 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $7) + (local.get $10) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $4) + (local.get $7) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -158,7 +297,7 @@ functions › lam_destructure_7 ) ) ) - (local.set $9 + (local.set $13 (tuple.extract 0 (tuple.make (call $gimport_pervasives_+ @@ -168,11 +307,11 @@ functions › lam_destructure_7 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $8) + (local.get $11) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $3) + (local.get $6) ) ) (i32.const 0) @@ -182,7 +321,7 @@ functions › lam_destructure_7 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) + (local.get $12) ) ) (drop @@ -194,188 +333,49 @@ functions › lam_destructure_7 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $3) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $6) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $4) + (local.get $7) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $5) + (local.get $8) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $6) + (local.get $9) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $7) + (local.get $10) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $8) - ) - ) - (local.get $9) - ) - (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (i32.store - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_malloc - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) - (i32.const 16) - ) - (i32.const 0) - ) - ) - ) - (i32.const 6) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (global.get $wimport__grainEnv_relocBase) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (local.set $1 - (tuple.extract 0 - (tuple.make - (local.get $0) - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (i32.const 0) - ) - ) - ) - ) - (i32.store - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_malloc - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) - (i32.const 16) - ) - (tuple.extract 0 - (tuple.make - (local.get $1) - (local.get $0) - ) - ) - ) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 9) - ) - (local.set $2 - (tuple.extract 0 - (tuple.make - (local.get $0) - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (i32.const 0) - ) - ) - ) - ) - (i32.store - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_malloc - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) - (i32.const 20) - ) - (local.get $0) - ) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) - ) - ) - (local.set $3 - (tuple.extract 0 - (tuple.make - (local.get $0) - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (i32.const 0) - ) - ) + (local.get $11) ) ) (local.set $0 (tuple.extract 0 (tuple.make - (call $lam_lambda_1135 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) - ) - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $3) - ) - ) + (local.get $13) (local.get $0) ) ) @@ -383,19 +383,19 @@ functions › lam_destructure_7 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $2) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $4) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $5) ) ) (local.get $0) diff --git a/compiler/test/__snapshots__/functions.9fd69835.0.snapshot b/compiler/test/__snapshots__/functions.9fd69835.0.snapshot index 05376dc502..cf9568c105 100644 --- a/compiler/test/__snapshots__/functions.9fd69835.0.snapshot +++ b/compiler/test/__snapshots__/functions.9fd69835.0.snapshot @@ -5,7 +5,6 @@ functions › shorthand_2 (type $none_=>_none (func)) (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) @@ -16,48 +15,15 @@ functions › shorthand_2 (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$pervasives\" \"+\" (func $gimport_pervasives_+ (param i32 i32 i32) (result i32))) (global $global_0 (mut i32) (i32.const 0)) - (global $global_2 i32 (i32.const 1)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $foo_1131) + (global $global_2 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_2)) - (func $foo_1131 (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local.set $2 - (tuple.extract 0 - (tuple.make - (call $gimport_pervasives_+ - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) - ) - (i32.const 7) - ) - (i32.const 0) - ) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) - ) - ) - (local.get $2) - ) (func $_gmain (; has Stack IR ;) (result i32) (local $0 i32) + (local $1 i32) + (local $2 i32) (i32.store (local.tee $0 (tuple.extract 0 @@ -78,7 +44,7 @@ functions › shorthand_2 ) (i32.store offset=8 (local.get $0) - (global.get $wimport__grainEnv_relocBase) + (i32.const -1) ) (i32.store offset=12 (local.get $0) @@ -103,15 +69,45 @@ functions › shorthand_2 ) ) ) - (tuple.extract 0 - (tuple.make - (call $foo_1131 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $global_0) + (local.set $1 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $global_0) + ) + ) + (local.set $2 + (tuple.extract 0 + (tuple.make + (call $gimport_pervasives_+ + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_+) + ) + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (i32.const 3) + ) + (i32.const 7) ) - (i32.const 3) + (i32.const 0) ) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $1) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 3) + ) + ) + (tuple.extract 0 + (tuple.make + (local.get $2) (local.get $0) ) ) diff --git a/compiler/test/__snapshots__/functions.b37949b2.0.snapshot b/compiler/test/__snapshots__/functions.b37949b2.0.snapshot index 8dc7446a36..472094b948 100644 --- a/compiler/test/__snapshots__/functions.b37949b2.0.snapshot +++ b/compiler/test/__snapshots__/functions.b37949b2.0.snapshot @@ -5,7 +5,6 @@ functions › lam_destructure_4 (type $none_=>_none (func)) (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) @@ -16,19 +15,120 @@ functions › lam_destructure_4 (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$pervasives\" \"+\" (func $gimport_pervasives_+ (param i32 i32 i32) (result i32))) (global $global_0 (mut i32) (i32.const 0)) - (global $global_2 i32 (i32.const 1)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $foo_1131) + (global $global_2 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_2)) - (func $foo_1131 (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) + (func $_gmain (; has Stack IR ;) (result i32) + (local $0 i32) + (local $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) + (local $7 i32) + (local $8 i32) + (i32.store + (local.tee $0 + (tuple.extract 0 + (tuple.make + (call $wimport_GRAIN$MODULE$runtime/gc_malloc + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) + (i32.const 16) + ) + (i32.const 0) + ) + ) + ) + (i32.const 6) + ) + (i32.store offset=4 + (local.get $0) + (i32.const 2) + ) + (i32.store offset=8 + (local.get $0) + (i32.const -1) + ) + (i32.store offset=12 + (local.get $0) + (i32.const 0) + ) + (global.set $global_0 + (tuple.extract 0 + (tuple.make + (local.get $0) + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (global.get $global_0) + ) + ) + ) + ) + (local.set $0 + (tuple.extract 0 + (tuple.make + (global.get $global_0) + (local.get $0) + ) + ) + ) + (i32.store + (local.tee $0 + (tuple.extract 0 + (tuple.make + (call $wimport_GRAIN$MODULE$runtime/gc_malloc + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) + (i32.const 20) + ) + (local.get $0) + ) + ) + ) + (i32.const 7) + ) + (i32.store offset=4 + (local.get $0) + (i32.const 3) + ) + (i32.store offset=8 + (local.get $0) + (i32.const 3) + ) + (i32.store offset=12 + (local.get $0) + (i32.const 5) + ) + (i32.store offset=16 + (local.get $0) + (i32.const 7) + ) (local.set $2 + (tuple.extract 0 + (tuple.make + (local.get $0) + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 0) + ) + ) + ) + ) + (local.set $7 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $global_0) + ) + ) + (local.set $1 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (local.get $2) + ) + ) + (local.set $3 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -44,7 +144,7 @@ functions › lam_destructure_4 ) ) ) - (local.set $3 + (local.set $4 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -60,7 +160,7 @@ functions › lam_destructure_4 ) ) ) - (local.set $4 + (local.set $5 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -76,7 +176,7 @@ functions › lam_destructure_4 ) ) ) - (local.set $5 + (local.set $6 (tuple.extract 0 (tuple.make (call $gimport_pervasives_+ @@ -86,11 +186,11 @@ functions › lam_destructure_4 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $4) + (local.get $5) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $3) + (local.get $4) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -100,7 +200,7 @@ functions › lam_destructure_4 ) ) ) - (local.set $6 + (local.set $8 (tuple.extract 0 (tuple.make (call $gimport_pervasives_+ @@ -110,11 +210,11 @@ functions › lam_destructure_4 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $5) + (local.get $6) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) + (local.get $3) ) ) (i32.const 0) @@ -124,7 +224,7 @@ functions › lam_destructure_4 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) + (local.get $7) ) ) (drop @@ -133,12 +233,6 @@ functions › lam_destructure_4 (local.get $1) ) ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) - ) - ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -157,110 +251,16 @@ functions › lam_destructure_4 (local.get $5) ) ) - (local.get $6) - ) - (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (local $1 i32) - (i32.store - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_malloc - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) - (i32.const 16) - ) - (i32.const 0) - ) - ) - ) - (i32.const 6) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (global.get $wimport__grainEnv_relocBase) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (global.set $global_0 - (tuple.extract 0 - (tuple.make - (local.get $0) - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (global.get $global_0) - ) - ) - ) - ) - (local.set $0 - (tuple.extract 0 - (tuple.make - (global.get $global_0) - (local.get $0) - ) - ) - ) - (i32.store - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_malloc - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) - (i32.const 20) - ) - (local.get $0) - ) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.set $1 - (tuple.extract 0 - (tuple.make - (local.get $0) - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (i32.const 0) - ) - ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $6) ) ) (local.set $0 (tuple.extract 0 (tuple.make - (call $foo_1131 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $global_0) - ) - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) - ) - ) + (local.get $8) (local.get $0) ) ) @@ -268,7 +268,7 @@ functions › lam_destructure_4 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $2) ) ) (local.get $0) diff --git a/compiler/test/__snapshots__/functions.b3a8d88b.0.snapshot b/compiler/test/__snapshots__/functions.b3a8d88b.0.snapshot index 8bfc98d8d8..dcce961b08 100644 --- a/compiler/test/__snapshots__/functions.b3a8d88b.0.snapshot +++ b/compiler/test/__snapshots__/functions.b3a8d88b.0.snapshot @@ -5,7 +5,6 @@ functions › lam_destructure_8 (type $none_=>_none (func)) (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) @@ -16,13 +15,14 @@ functions › lam_destructure_8 (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$pervasives\" \"+\" (func $gimport_pervasives_+ (param i32 i32 i32) (result i32))) (global $global_0 (mut i32) (i32.const 0)) - (global $global_2 i32 (i32.const 1)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $foo_1131) + (global $global_2 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_2)) - (func $foo_1131 (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) + (func $_gmain (; has Stack IR ;) (result i32) + (local $0 i32) + (local $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -31,6 +31,147 @@ functions › lam_destructure_8 (local $7 i32) (local $8 i32) (local $9 i32) + (local $10 i32) + (local $11 i32) + (local $12 i32) + (i32.store + (local.tee $0 + (tuple.extract 0 + (tuple.make + (call $wimport_GRAIN$MODULE$runtime/gc_malloc + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) + (i32.const 16) + ) + (i32.const 0) + ) + ) + ) + (i32.const 6) + ) + (i32.store offset=4 + (local.get $0) + (i32.const 2) + ) + (i32.store offset=8 + (local.get $0) + (i32.const -1) + ) + (i32.store offset=12 + (local.get $0) + (i32.const 0) + ) + (global.set $global_0 + (tuple.extract 0 + (tuple.make + (local.get $0) + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (global.get $global_0) + ) + ) + ) + ) + (local.set $0 + (tuple.extract 0 + (tuple.make + (global.get $global_0) + (local.get $0) + ) + ) + ) + (i32.store + (local.tee $0 + (tuple.extract 0 + (tuple.make + (call $wimport_GRAIN$MODULE$runtime/gc_malloc + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) + (i32.const 16) + ) + (local.get $0) + ) + ) + ) + (i32.const 7) + ) + (i32.store offset=4 + (local.get $0) + (i32.const 2) + ) + (i32.store offset=8 + (local.get $0) + (i32.const 7) + ) + (i32.store offset=12 + (local.get $0) + (i32.const 9) + ) + (local.set $3 + (tuple.extract 0 + (tuple.make + (local.get $0) + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 0) + ) + ) + ) + ) + (i32.store + (local.tee $0 + (tuple.extract 0 + (tuple.make + (call $wimport_GRAIN$MODULE$runtime/gc_malloc + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) + (i32.const 20) + ) + (local.get $0) + ) + ) + ) + (i32.const 7) + ) + (i32.store offset=4 + (local.get $0) + (i32.const 3) + ) + (i32.store offset=8 + (local.get $0) + (i32.const 3) + ) + (i32.store offset=12 + (local.get $0) + (i32.const 5) + ) + (i32.store offset=16 + (local.get $0) + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (local.get $3) + ) + ) + (local.set $4 + (tuple.extract 0 + (tuple.make + (local.get $0) + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 0) + ) + ) + ) + ) + (local.set $11 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $global_0) + ) + ) + (local.set $1 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (local.get $4) + ) + ) (local.set $2 (tuple.extract 0 (tuple.make @@ -47,7 +188,7 @@ functions › lam_destructure_8 ) ) ) - (local.set $3 + (local.set $5 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -63,7 +204,7 @@ functions › lam_destructure_8 ) ) ) - (local.set $4 + (local.set $6 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -79,7 +220,7 @@ functions › lam_destructure_8 ) ) ) - (local.set $5 + (local.set $7 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -95,7 +236,7 @@ functions › lam_destructure_8 ) ) ) - (local.set $6 + (local.set $8 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -111,7 +252,7 @@ functions › lam_destructure_8 ) ) ) - (local.set $7 + (local.set $9 (tuple.extract 0 (tuple.make (call $gimport_pervasives_+ @@ -121,11 +262,11 @@ functions › lam_destructure_8 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $6) + (local.get $8) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $5) + (local.get $7) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -135,7 +276,7 @@ functions › lam_destructure_8 ) ) ) - (local.set $8 + (local.set $10 (tuple.extract 0 (tuple.make (call $gimport_pervasives_+ @@ -145,11 +286,11 @@ functions › lam_destructure_8 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $7) + (local.get $9) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $4) + (local.get $6) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -159,7 +300,7 @@ functions › lam_destructure_8 ) ) ) - (local.set $9 + (local.set $12 (tuple.extract 0 (tuple.make (call $gimport_pervasives_+ @@ -169,11 +310,11 @@ functions › lam_destructure_8 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $8) + (local.get $10) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $3) + (local.get $5) ) ) (i32.const 0) @@ -183,7 +324,7 @@ functions › lam_destructure_8 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) + (local.get $11) ) ) (drop @@ -201,184 +342,43 @@ functions › lam_destructure_8 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $5) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $4) + (local.get $6) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $5) + (local.get $7) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $6) + (local.get $8) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $7) + (local.get $9) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $8) - ) - ) - (local.get $9) - ) - (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (i32.store - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_malloc - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) - (i32.const 16) - ) - (i32.const 0) - ) - ) - ) - (i32.const 6) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (global.get $wimport__grainEnv_relocBase) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (global.set $global_0 - (tuple.extract 0 - (tuple.make - (local.get $0) - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (global.get $global_0) - ) - ) + (local.get $10) ) ) (local.set $0 (tuple.extract 0 (tuple.make - (global.get $global_0) - (local.get $0) - ) - ) - ) - (i32.store - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_malloc - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) - (i32.const 16) - ) - (local.get $0) - ) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 9) - ) - (local.set $1 - (tuple.extract 0 - (tuple.make - (local.get $0) - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (i32.const 0) - ) - ) - ) - ) - (i32.store - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_malloc - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) - (i32.const 20) - ) - (local.get $0) - ) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) - ) - ) - (local.set $2 - (tuple.extract 0 - (tuple.make - (local.get $0) - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (i32.const 0) - ) - ) - ) - ) - (local.set $0 - (tuple.extract 0 - (tuple.make - (call $foo_1131 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $global_0) - ) - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) - ) - ) + (local.get $12) (local.get $0) ) ) @@ -386,13 +386,13 @@ functions › lam_destructure_8 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $3) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $4) ) ) (local.get $0) diff --git a/compiler/test/__snapshots__/functions.b632a2ab.0.snapshot b/compiler/test/__snapshots__/functions.b632a2ab.0.snapshot index fcaf57bce0..b13b7dd271 100644 --- a/compiler/test/__snapshots__/functions.b632a2ab.0.snapshot +++ b/compiler/test/__snapshots__/functions.b632a2ab.0.snapshot @@ -4,7 +4,6 @@ functions › lam_destructure_1 (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) @@ -12,31 +11,17 @@ functions › lam_destructure_1 (import \"GRAIN$MODULE$runtime/gc\" \"malloc\" (func $wimport_GRAIN$MODULE$runtime/gc_malloc (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) - (global $global_1 i32 (i32.const 1)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $lam_lambda_1131) + (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) - (func $lam_lambda_1131 (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) - ) - ) - (i32.const 11) - ) (func $_gmain (; has Stack IR ;) (result i32) (local $0 i32) (local $1 i32) (local $2 i32) + (local $3 i32) + (local $4 i32) (i32.store (local.tee $0 (tuple.extract 0 @@ -57,7 +42,7 @@ functions › lam_destructure_1 ) (i32.store offset=8 (local.get $0) - (global.get $wimport__grainEnv_relocBase) + (i32.const -1) ) (i32.store offset=12 (local.get $0) @@ -112,19 +97,34 @@ functions › lam_destructure_1 ) ) ) + (local.set $3 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (local.get $1) + ) + ) + (local.set $4 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (local.get $2) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $3) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $4) + ) + ) (local.set $0 (tuple.extract 0 (tuple.make - (call $lam_lambda_1131 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) - ) - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) - ) - ) + (i32.const 11) (local.get $0) ) ) diff --git a/compiler/test/__snapshots__/functions.c6e8a9aa.0.snapshot b/compiler/test/__snapshots__/functions.c6e8a9aa.0.snapshot index bbcff8659f..8de27aeab5 100644 --- a/compiler/test/__snapshots__/functions.c6e8a9aa.0.snapshot +++ b/compiler/test/__snapshots__/functions.c6e8a9aa.0.snapshot @@ -4,7 +4,6 @@ functions › lam_destructure_2 (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) @@ -13,30 +12,16 @@ functions › lam_destructure_2 (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (global $global_0 (mut i32) (i32.const 0)) - (global $global_2 i32 (i32.const 1)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $foo_1131) + (global $global_2 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_2)) - (func $foo_1131 (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) - ) - ) - (i32.const 11) - ) (func $_gmain (; has Stack IR ;) (result i32) (local $0 i32) (local $1 i32) + (local $2 i32) + (local $3 i32) (i32.store (local.tee $0 (tuple.extract 0 @@ -57,7 +42,7 @@ functions › lam_destructure_2 ) (i32.store offset=8 (local.get $0) - (global.get $wimport__grainEnv_relocBase) + (i32.const -1) ) (i32.store offset=12 (local.get $0) @@ -115,19 +100,34 @@ functions › lam_destructure_2 ) ) ) + (local.set $2 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $global_0) + ) + ) + (local.set $3 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (local.get $1) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $2) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $3) + ) + ) (local.set $0 (tuple.extract 0 (tuple.make - (call $foo_1131 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $global_0) - ) - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) - ) - ) + (i32.const 11) (local.get $0) ) ) diff --git a/compiler/test/__snapshots__/functions.e6c6212b.0.snapshot b/compiler/test/__snapshots__/functions.e6c6212b.0.snapshot index 1ecad58ed9..baed642549 100644 --- a/compiler/test/__snapshots__/functions.e6c6212b.0.snapshot +++ b/compiler/test/__snapshots__/functions.e6c6212b.0.snapshot @@ -1,11 +1,10 @@ functions › fn_trailing_comma (module (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) @@ -16,57 +15,15 @@ functions › fn_trailing_comma (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$pervasives\" \"+\" (func $gimport_pervasives_+ (param i32 i32 i32) (result i32))) (global $global_0 (mut i32) (i32.const 0)) - (global $global_2 i32 (i32.const 1)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $testFn_1131) + (global $global_2 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_2)) - (func $testFn_1131 (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (local.set $3 - (tuple.extract 0 - (tuple.make - (call $gimport_pervasives_+ - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) - ) - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) - ) - ) - (i32.const 0) - ) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) - ) - ) - (local.get $3) - ) (func $_gmain (; has Stack IR ;) (result i32) (local $0 i32) + (local $1 i32) + (local $2 i32) (i32.store (local.tee $0 (tuple.extract 0 @@ -87,7 +44,7 @@ functions › fn_trailing_comma ) (i32.store offset=8 (local.get $0) - (global.get $wimport__grainEnv_relocBase) + (i32.const -1) ) (i32.store offset=12 (local.get $0) @@ -112,16 +69,54 @@ functions › fn_trailing_comma ) ) ) - (tuple.extract 0 - (tuple.make - (call $testFn_1131 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $global_0) + (local.set $1 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $global_0) + ) + ) + (local.set $2 + (tuple.extract 0 + (tuple.make + (call $gimport_pervasives_+ + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_+) + ) + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (i32.const 5) + ) + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (i32.const 7) + ) ) - (i32.const 5) - (i32.const 7) + (i32.const 0) ) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $1) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 5) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 7) + ) + ) + (tuple.extract 0 + (tuple.make + (local.get $2) (local.get $0) ) ) diff --git a/compiler/test/__snapshots__/functions.f400bb7b.0.snapshot b/compiler/test/__snapshots__/functions.f400bb7b.0.snapshot index e460e59594..415f16f1b5 100644 --- a/compiler/test/__snapshots__/functions.f400bb7b.0.snapshot +++ b/compiler/test/__snapshots__/functions.f400bb7b.0.snapshot @@ -1,11 +1,10 @@ functions › lam_destructure_6 (module (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) @@ -16,13 +15,15 @@ functions › lam_destructure_6 (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$pervasives\" \"+\" (func $gimport_pervasives_+ (param i32 i32 i32) (result i32))) (global $global_0 (mut i32) (i32.const 0)) - (global $global_2 i32 (i32.const 1)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $foo_1131) + (global $global_2 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_2)) - (func $foo_1131 (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $_gmain (; has Stack IR ;) (result i32) + (local $0 i32) + (local $1 i32) + (local $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -32,7 +33,151 @@ functions › lam_destructure_6 (local $9 i32) (local $10 i32) (local $11 i32) + (local $12 i32) + (local $13 i32) + (local $14 i32) + (i32.store + (local.tee $0 + (tuple.extract 0 + (tuple.make + (call $wimport_GRAIN$MODULE$runtime/gc_malloc + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) + (i32.const 16) + ) + (i32.const 0) + ) + ) + ) + (i32.const 6) + ) + (i32.store offset=4 + (local.get $0) + (i32.const 3) + ) + (i32.store offset=8 + (local.get $0) + (i32.const -1) + ) + (i32.store offset=12 + (local.get $0) + (i32.const 0) + ) + (global.set $global_0 + (tuple.extract 0 + (tuple.make + (local.get $0) + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (global.get $global_0) + ) + ) + ) + ) + (local.set $0 + (tuple.extract 0 + (tuple.make + (global.get $global_0) + (local.get $0) + ) + ) + ) + (i32.store + (local.tee $0 + (tuple.extract 0 + (tuple.make + (call $wimport_GRAIN$MODULE$runtime/gc_malloc + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) + (i32.const 20) + ) + (local.get $0) + ) + ) + ) + (i32.const 7) + ) + (i32.store offset=4 + (local.get $0) + (i32.const 3) + ) + (i32.store offset=8 + (local.get $0) + (i32.const 3) + ) + (i32.store offset=12 + (local.get $0) + (i32.const 5) + ) + (i32.store offset=16 + (local.get $0) + (i32.const 7) + ) (local.set $3 + (tuple.extract 0 + (tuple.make + (local.get $0) + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 0) + ) + ) + ) + ) + (i32.store + (local.tee $0 + (tuple.extract 0 + (tuple.make + (call $wimport_GRAIN$MODULE$runtime/gc_malloc + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) + (i32.const 16) + ) + (local.get $0) + ) + ) + ) + (i32.const 7) + ) + (i32.store offset=4 + (local.get $0) + (i32.const 2) + ) + (i32.store offset=8 + (local.get $0) + (i32.const 9) + ) + (i32.store offset=12 + (local.get $0) + (i32.const 11) + ) + (local.set $4 + (tuple.extract 0 + (tuple.make + (local.get $0) + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 0) + ) + ) + ) + ) + (local.set $13 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $global_0) + ) + ) + (local.set $1 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (local.get $3) + ) + ) + (local.set $2 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (local.get $4) + ) + ) + (local.set $5 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -48,7 +193,7 @@ functions › lam_destructure_6 ) ) ) - (local.set $4 + (local.set $6 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -64,7 +209,7 @@ functions › lam_destructure_6 ) ) ) - (local.set $5 + (local.set $7 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -80,7 +225,7 @@ functions › lam_destructure_6 ) ) ) - (local.set $6 + (local.set $8 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -96,7 +241,7 @@ functions › lam_destructure_6 ) ) ) - (local.set $7 + (local.set $9 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -112,7 +257,7 @@ functions › lam_destructure_6 ) ) ) - (local.set $8 + (local.set $10 (tuple.extract 0 (tuple.make (call $gimport_pervasives_+ @@ -122,11 +267,11 @@ functions › lam_destructure_6 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $5) + (local.get $7) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $4) + (local.get $6) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -136,7 +281,7 @@ functions › lam_destructure_6 ) ) ) - (local.set $9 + (local.set $11 (tuple.extract 0 (tuple.make (call $gimport_pervasives_+ @@ -146,11 +291,11 @@ functions › lam_destructure_6 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $8) + (local.get $10) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $3) + (local.get $5) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -160,7 +305,7 @@ functions › lam_destructure_6 ) ) ) - (local.set $10 + (local.set $12 (tuple.extract 0 (tuple.make (call $gimport_pervasives_+ @@ -170,11 +315,11 @@ functions › lam_destructure_6 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $9) + (local.get $11) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $7) + (local.get $9) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -184,7 +329,7 @@ functions › lam_destructure_6 ) ) ) - (local.set $11 + (local.set $14 (tuple.extract 0 (tuple.make (call $gimport_pervasives_+ @@ -194,11 +339,11 @@ functions › lam_destructure_6 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $10) + (local.get $12) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $6) + (local.get $8) ) ) (i32.const 0) @@ -208,7 +353,7 @@ functions › lam_destructure_6 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) + (local.get $13) ) ) (drop @@ -223,18 +368,6 @@ functions › lam_destructure_6 (local.get $2) ) ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $4) - ) - ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -271,152 +404,22 @@ functions › lam_destructure_6 (local.get $10) ) ) - (local.get $11) - ) - (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (i32.store - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_malloc - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) - (i32.const 16) - ) - (i32.const 0) - ) - ) - ) - (i32.const 6) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (global.get $wimport__grainEnv_relocBase) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (global.set $global_0 - (tuple.extract 0 - (tuple.make - (local.get $0) - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (global.get $global_0) - ) - ) - ) - ) - (local.set $0 - (tuple.extract 0 - (tuple.make - (global.get $global_0) - (local.get $0) - ) - ) - ) - (i32.store - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_malloc - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) - (i32.const 20) - ) - (local.get $0) - ) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.set $1 - (tuple.extract 0 - (tuple.make - (local.get $0) - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (i32.const 0) - ) - ) - ) - ) - (i32.store - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_malloc - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) - (i32.const 16) - ) - (local.get $0) - ) - ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $11) ) - (i32.const 7) ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 11) - ) - (local.set $2 - (tuple.extract 0 - (tuple.make - (local.get $0) - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (i32.const 0) - ) - ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $12) ) ) (local.set $0 (tuple.extract 0 (tuple.make - (call $foo_1131 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $global_0) - ) - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) - ) - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) - ) - ) + (local.get $14) (local.get $0) ) ) @@ -424,13 +427,13 @@ functions › lam_destructure_6 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $3) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $4) ) ) (local.get $0) diff --git a/compiler/test/__snapshots__/imports.0706ac31.0.snapshot b/compiler/test/__snapshots__/imports.0706ac31.0.snapshot index aec56ae64e..285cc7049d 100644 --- a/compiler/test/__snapshots__/imports.0706ac31.0.snapshot +++ b/compiler/test/__snapshots__/imports.0706ac31.0.snapshot @@ -1,47 +1,36 @@ imports › import_all_constructor (module (type $none_=>_i32 (func (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $none_=>_none (func)) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) (import \"GRAIN$MODULE$tlists\" \"GRAIN$EXPORT$Empty\" (global $gimport_tlists_Empty (mut i32))) (import \"GRAIN$MODULE$tlists\" \"GRAIN$EXPORT$Cons\" (global $gimport_tlists_Cons (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$tlists\" \"Cons\" (func $gimport_tlists_Cons (param i32 i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_tlists_Cons) - ) - (i32.const 0) - ) - ) + (call $gimport_tlists_Cons + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_tlists_Cons) ) (i32.const 5) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_tlists_Empty) ) - (i32.load offset=8 - (local.get $0) - ) ) - (local.get $0) + (i32.const 0) ) ) ) diff --git a/compiler/test/__snapshots__/imports.2f957040.0.snapshot b/compiler/test/__snapshots__/imports.2f957040.0.snapshot index 6b8d47c9a4..d44a4285af 100644 --- a/compiler/test/__snapshots__/imports.2f957040.0.snapshot +++ b/compiler/test/__snapshots__/imports.2f957040.0.snapshot @@ -2,10 +2,9 @@ imports › import_alias_multiple_constructor (module (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (type $none_=>_i32 (func (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $none_=>_none (func)) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef (mut i32))) @@ -14,6 +13,7 @@ imports › import_alias_multiple_constructor (import \"GRAIN$MODULE$tlists\" \"GRAIN$EXPORT$sum\" (global $gimport_tlists_sum (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$tlists\" \"Cons\" (func $gimport_tlists_Cons (param i32 i32 i32) (result i32))) (import \"GRAIN$MODULE$tlists\" \"sum\" (func $gimport_tlists_sum (param i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) @@ -23,29 +23,19 @@ imports › import_alias_multiple_constructor (func $_gmain (; has Stack IR ;) (result i32) (local $0 i32) (local $1 i32) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_tlists_Cons) - ) - (i32.const 0) - ) - ) + (call $gimport_tlists_Cons + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_tlists_Cons) ) (i32.const 3) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_tlists_Empty) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -54,7 +44,7 @@ imports › import_alias_multiple_constructor ) ) ) - (local.set $0 + (local.set $1 (tuple.extract 0 (tuple.make (call $gimport_tlists_sum @@ -64,20 +54,20 @@ imports › import_alias_multiple_constructor ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (local.get $0) ) ) - (local.get $0) + (i32.const 0) ) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) - (local.get $0) + (local.get $1) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/imports.7fc65fd4.0.snapshot b/compiler/test/__snapshots__/imports.7fc65fd4.0.snapshot index ef94d8aaf5..f318555915 100644 --- a/compiler/test/__snapshots__/imports.7fc65fd4.0.snapshot +++ b/compiler/test/__snapshots__/imports.7fc65fd4.0.snapshot @@ -1,47 +1,36 @@ imports › import_some_constructor (module (type $none_=>_i32 (func (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $none_=>_none (func)) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) (import \"GRAIN$MODULE$tlists\" \"GRAIN$EXPORT$Empty\" (global $gimport_tlists_Empty (mut i32))) (import \"GRAIN$MODULE$tlists\" \"GRAIN$EXPORT$Cons\" (global $gimport_tlists_Cons (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$tlists\" \"Cons\" (func $gimport_tlists_Cons (param i32 i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_tlists_Cons) - ) - (i32.const 0) - ) - ) + (call $gimport_tlists_Cons + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_tlists_Cons) ) (i32.const 11) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_tlists_Empty) ) - (i32.load offset=8 - (local.get $0) - ) ) - (local.get $0) + (i32.const 0) ) ) ) diff --git a/compiler/test/__snapshots__/imports.a3a21ec1.0.snapshot b/compiler/test/__snapshots__/imports.a3a21ec1.0.snapshot index 81d52636be..7c3d12c240 100644 --- a/compiler/test/__snapshots__/imports.a3a21ec1.0.snapshot +++ b/compiler/test/__snapshots__/imports.a3a21ec1.0.snapshot @@ -1,47 +1,36 @@ imports › import_same_module_unify2 (module (type $none_=>_i32 (func (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $none_=>_none (func)) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) (import \"GRAIN$MODULE$tlists\" \"GRAIN$EXPORT$Empty\" (global $gimport_tlists_Empty (mut i32))) (import \"GRAIN$MODULE$tlists\" \"GRAIN$EXPORT$Cons\" (global $gimport_tlists_Cons (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$tlists\" \"Cons\" (func $gimport_tlists_Cons (param i32 i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_tlists_Cons) - ) - (i32.const 0) - ) - ) + (call $gimport_tlists_Cons + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_tlists_Cons) ) (i32.const 11) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_tlists_Empty) ) - (i32.load offset=8 - (local.get $0) - ) ) - (local.get $0) + (i32.const 0) ) ) ) diff --git a/compiler/test/__snapshots__/imports.c06afb4d.0.snapshot b/compiler/test/__snapshots__/imports.c06afb4d.0.snapshot index a29187a0f0..5af5f990bf 100644 --- a/compiler/test/__snapshots__/imports.c06afb4d.0.snapshot +++ b/compiler/test/__snapshots__/imports.c06afb4d.0.snapshot @@ -1,47 +1,36 @@ imports › import_same_module_unify (module (type $none_=>_i32 (func (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $none_=>_none (func)) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) (import \"GRAIN$MODULE$tlists\" \"GRAIN$EXPORT$Empty\" (global $gimport_tlists_Empty (mut i32))) (import \"GRAIN$MODULE$tlists\" \"GRAIN$EXPORT$Cons\" (global $gimport_tlists_Cons (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$tlists\" \"Cons\" (func $gimport_tlists_Cons (param i32 i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_tlists_Cons) - ) - (i32.const 0) - ) - ) + (call $gimport_tlists_Cons + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_tlists_Cons) ) (i32.const 11) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_tlists_Empty) ) - (i32.load offset=8 - (local.get $0) - ) ) - (local.get $0) + (i32.const 0) ) ) ) diff --git a/compiler/test/__snapshots__/imports.f36bd08d.0.snapshot b/compiler/test/__snapshots__/imports.f36bd08d.0.snapshot index 41b4f5da6d..f964763182 100644 --- a/compiler/test/__snapshots__/imports.f36bd08d.0.snapshot +++ b/compiler/test/__snapshots__/imports.f36bd08d.0.snapshot @@ -1,37 +1,29 @@ imports › import_muliple_modules (module (type $none_=>_i32 (func (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $none_=>_none (func)) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) (import \"GRAIN$MODULE$tlists\" \"GRAIN$EXPORT$Empty\" (global $gimport_tlists_Empty (mut i32))) (import \"GRAIN$MODULE$exportStar\" \"GRAIN$EXPORT$x\" (global $gimport_exportStar_x (mut i32))) (import \"GRAIN$MODULE$tlists\" \"GRAIN$EXPORT$Cons\" (global $gimport_tlists_Cons (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$tlists\" \"Cons\" (func $gimport_tlists_Cons (param i32 i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_tlists_Cons) - ) - (i32.const 0) - ) - ) + (call $gimport_tlists_Cons + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_tlists_Cons) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -41,11 +33,8 @@ imports › import_muliple_modules (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_tlists_Empty) ) - (i32.load offset=8 - (local.get $0) - ) ) - (local.get $0) + (i32.const 0) ) ) ) diff --git a/compiler/test/__snapshots__/imports.f4cfe044.0.snapshot b/compiler/test/__snapshots__/imports.f4cfe044.0.snapshot index f5d7d4f0af..0e33cc5c2f 100644 --- a/compiler/test/__snapshots__/imports.f4cfe044.0.snapshot +++ b/compiler/test/__snapshots__/imports.f4cfe044.0.snapshot @@ -2,10 +2,9 @@ imports › import_some_mixed (module (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (type $none_=>_i32 (func (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $none_=>_none (func)) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef (mut i32))) @@ -14,6 +13,7 @@ imports › import_some_mixed (import \"GRAIN$MODULE$tlists\" \"GRAIN$EXPORT$sum\" (global $gimport_tlists_sum (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$tlists\" \"Cons\" (func $gimport_tlists_Cons (param i32 i32 i32) (result i32))) (import \"GRAIN$MODULE$tlists\" \"sum\" (func $gimport_tlists_sum (param i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) @@ -23,29 +23,19 @@ imports › import_some_mixed (func $_gmain (; has Stack IR ;) (result i32) (local $0 i32) (local $1 i32) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_tlists_Cons) - ) - (i32.const 0) - ) - ) + (call $gimport_tlists_Cons + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_tlists_Cons) ) (i32.const 11) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_tlists_Empty) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -54,7 +44,7 @@ imports › import_some_mixed ) ) ) - (local.set $0 + (local.set $1 (tuple.extract 0 (tuple.make (call $gimport_tlists_sum @@ -64,20 +54,20 @@ imports › import_some_mixed ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (local.get $0) ) ) - (local.get $0) + (i32.const 0) ) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) - (local.get $0) + (local.get $1) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/lists.884ce894.0.snapshot b/compiler/test/__snapshots__/lists.884ce894.0.snapshot index af0751fdac..e8578537f6 100644 --- a/compiler/test/__snapshots__/lists.884ce894.0.snapshot +++ b/compiler/test/__snapshots__/lists.884ce894.0.snapshot @@ -1,11 +1,10 @@ lists › list_spread (module - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef (mut i32))) @@ -13,6 +12,7 @@ lists › list_spread (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$[...]\" (global $gimport_pervasives_[...] (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"[...]\" (func $gimport_pervasives_[...] (param i32 i32 i32) (result i32))) (global $global_0 (mut i32) (i32.const 0)) (global $global_2 i32 (i32.const 0)) (export \"memory\" (memory $0)) @@ -23,29 +23,19 @@ lists › list_spread (local $0 i32) (local $1 i32) (local $2 i32) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (i32.const 0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 9) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[]) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -57,24 +47,14 @@ lists › list_spread (global.set $global_0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 7) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) - ) - (i32.load offset=8 (local.get $0) ) ) @@ -85,29 +65,19 @@ lists › list_spread ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 5) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $global_0) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -116,47 +86,37 @@ lists › list_spread ) ) ) - (local.set $0 + (local.set $2 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 3) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) - ) - (i32.load offset=8 - (local.get $0) + (local.get $1) ) ) - (local.get $0) + (i32.const 0) ) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) - (local.get $0) + (local.get $2) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/lists.d9fd46fb.0.snapshot b/compiler/test/__snapshots__/lists.d9fd46fb.0.snapshot index b4bf56ab0d..89e537a7f5 100644 --- a/compiler/test/__snapshots__/lists.d9fd46fb.0.snapshot +++ b/compiler/test/__snapshots__/lists.d9fd46fb.0.snapshot @@ -1,11 +1,10 @@ lists › list1_trailing_space (module - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef (mut i32))) @@ -13,6 +12,7 @@ lists › list1_trailing_space (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$[...]\" (global $gimport_pervasives_[...] (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"[...]\" (func $gimport_pervasives_[...] (param i32 i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) @@ -22,29 +22,19 @@ lists › list1_trailing_space (local $0 i32) (local $1 i32) (local $2 i32) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (i32.const 0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 7) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[]) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -53,27 +43,17 @@ lists › list1_trailing_space ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 5) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) - ) - (i32.load offset=8 (local.get $0) ) ) @@ -84,47 +64,37 @@ lists › list1_trailing_space ) ) ) - (local.set $0 + (local.set $2 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 3) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) - ) - (i32.load offset=8 - (local.get $0) + (local.get $1) ) ) - (local.get $0) + (i32.const 0) ) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) - (local.get $0) + (local.get $2) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/lists.e5378351.0.snapshot b/compiler/test/__snapshots__/lists.e5378351.0.snapshot index 48872e0233..61698dd669 100644 --- a/compiler/test/__snapshots__/lists.e5378351.0.snapshot +++ b/compiler/test/__snapshots__/lists.e5378351.0.snapshot @@ -1,11 +1,10 @@ lists › list1_trailing (module - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef (mut i32))) @@ -13,6 +12,7 @@ lists › list1_trailing (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$[...]\" (global $gimport_pervasives_[...] (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"[...]\" (func $gimport_pervasives_[...] (param i32 i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) @@ -22,29 +22,19 @@ lists › list1_trailing (local $0 i32) (local $1 i32) (local $2 i32) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (i32.const 0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 7) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[]) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -53,27 +43,17 @@ lists › list1_trailing ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 5) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) - ) - (i32.load offset=8 (local.get $0) ) ) @@ -84,47 +64,37 @@ lists › list1_trailing ) ) ) - (local.set $0 + (local.set $2 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 3) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) - ) - (i32.load offset=8 - (local.get $0) + (local.get $1) ) ) - (local.get $0) + (i32.const 0) ) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) - (local.get $0) + (local.get $2) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/optimizations.d72b00c6.0.snapshot b/compiler/test/__snapshots__/optimizations.d72b00c6.0.snapshot index 4d9a5013e1..46d0c52453 100644 --- a/compiler/test/__snapshots__/optimizations.d72b00c6.0.snapshot +++ b/compiler/test/__snapshots__/optimizations.d72b00c6.0.snapshot @@ -1,11 +1,9 @@ optimizations › trs1 (module (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) @@ -14,47 +12,15 @@ optimizations › trs1 (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (global $global_0 (mut i32) (i32.const 0)) - (global $global_2 i32 (i32.const 1)) - (elem $elem (global.get $wimport__grainEnv_relocBase) $f1_1131) + (global $global_2 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_2)) - (func $f1_1131 (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (local.set $3 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) - ) - (i32.const 0) - ) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) - ) - ) - (drop - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) - ) - ) - (local.get $3) - ) (func $_gmain (; has Stack IR ;) (result i32) (local $0 i32) + (local $1 i32) + (local $2 i32) (i32.store (local.tee $0 (tuple.extract 0 @@ -75,7 +41,7 @@ optimizations › trs1 ) (i32.store offset=8 (local.get $0) - (global.get $wimport__grainEnv_relocBase) + (i32.const -1) ) (i32.store offset=12 (local.get $0) @@ -100,16 +66,44 @@ optimizations › trs1 ) ) ) - (tuple.extract 0 - (tuple.make - (call $f1_1131 + (local.set $1 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $global_0) + ) + ) + (local.set $2 + (tuple.extract 0 + (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $global_0) + (i32.const 3) ) - (i32.const 3) - (i32.const 5) + (i32.const 0) ) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (local.get $1) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 3) + ) + ) + (drop + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 5) + ) + ) + (tuple.extract 0 + (tuple.make + (local.get $2) (local.get $0) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.05b60a1e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.05b60a1e.0.snapshot index a4190dea96..b52ecee6c7 100644 --- a/compiler/test/__snapshots__/pattern_matching.05b60a1e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.05b60a1e.0.snapshot @@ -2,10 +2,9 @@ pattern matching › adt_match_deep (module (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (type $none_=>_i32 (func (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $none_=>_none (func)) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"_grainEnv\" \"moduleRuntimeId\" (global $wimport__grainEnv_moduleRuntimeId i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) @@ -16,6 +15,7 @@ pattern matching › adt_match_deep (import \"GRAIN$MODULE$runtime/gc\" \"malloc\" (func $wimport_GRAIN$MODULE$runtime/gc_malloc (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"[...]\" (func $gimport_pervasives_[...] (param i32 i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) @@ -137,14 +137,14 @@ pattern matching › adt_match_deep (local.set $0 (tuple.extract 0 (tuple.make - (block $switch.21_outer (result i32) + (block $switch.20_outer (result i32) (drop - (block $switch.21_branch_1 (result i32) + (block $switch.20_branch_1 (result i32) (drop - (block $switch.21_branch_2 (result i32) + (block $switch.20_branch_2 (result i32) (drop - (block $switch.21_default (result i32) - (br_table $switch.21_branch_1 $switch.21_branch_2 $switch.21_default + (block $switch.20_default (result i32) + (br_table $switch.20_branch_1 $switch.20_branch_2 $switch.20_default (i32.const 0) (i32.shr_s (tuple.extract 0 @@ -163,17 +163,10 @@ pattern matching › adt_match_deep (local.tee $2 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -183,9 +176,6 @@ pattern matching › adt_match_deep (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[]) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -263,7 +253,7 @@ pattern matching › adt_match_deep ) ) ) - (br $switch.21_outer + (br $switch.20_outer (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=16 diff --git a/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot b/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot index f8d06aa46c..886658b28a 100644 --- a/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot @@ -5,7 +5,6 @@ pattern matching › tuple_match_deep4 (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) @@ -17,6 +16,7 @@ pattern matching › tuple_match_deep4 (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$pervasives\" \"+\" (func $gimport_pervasives_+ (param i32 i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"[...]\" (func $gimport_pervasives_[...] (param i32 i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) @@ -41,26 +41,16 @@ pattern matching › tuple_match_deep4 (local.set $9 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (i32.const 0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 5) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[]) ) - (i32.load offset=8 - (local.get $1) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -77,7 +67,7 @@ pattern matching › tuple_match_deep4 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) (i32.const 16) ) - (local.get $1) + (i32.const 0) ) ) ) @@ -98,7 +88,7 @@ pattern matching › tuple_match_deep4 (local.get $9) ) ) - (local.set $1 + (local.set $3 (tuple.extract 0 (tuple.make (local.get $4) @@ -112,20 +102,20 @@ pattern matching › tuple_match_deep4 (local.set $4 (tuple.extract 0 (tuple.make - (block $switch.53_outer (result i32) + (block $switch.52_outer (result i32) (drop - (block $switch.53_branch_1 (result i32) + (block $switch.52_branch_1 (result i32) (drop - (block $switch.53_branch_2 (result i32) + (block $switch.52_branch_2 (result i32) (drop - (block $switch.53_branch_3 (result i32) + (block $switch.52_branch_3 (result i32) (drop - (block $switch.53_branch_4 (result i32) + (block $switch.52_branch_4 (result i32) (drop - (block $switch.53_branch_5 (result i32) + (block $switch.52_branch_5 (result i32) (drop - (block $switch.53_default (result i32) - (br_table $switch.53_branch_1 $switch.53_branch_2 $switch.53_branch_3 $switch.53_branch_4 $switch.53_branch_5 $switch.53_default + (block $switch.52_default (result i32) + (br_table $switch.52_branch_1 $switch.52_branch_2 $switch.52_branch_3 $switch.52_branch_4 $switch.52_branch_5 $switch.52_default (i32.const 0) (i32.shr_s (tuple.extract 0 @@ -147,7 +137,7 @@ pattern matching › tuple_match_deep4 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=12 - (local.get $1) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -227,7 +217,7 @@ pattern matching › tuple_match_deep4 (tuple.extract 0 (tuple.make (i32.load offset=12 - (local.tee $2 + (local.tee $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -271,13 +261,13 @@ pattern matching › tuple_match_deep4 (tuple.extract 0 (tuple.make (i32.load offset=12 - (local.tee $3 + (local.tee $2 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $2) + (local.get $1) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -385,7 +375,7 @@ pattern matching › tuple_match_deep4 (unreachable) ) ) - (br $switch.53_outer + (br $switch.52_outer (i32.const 1999) ) ) @@ -396,7 +386,7 @@ pattern matching › tuple_match_deep4 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=12 - (local.get $1) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -406,7 +396,7 @@ pattern matching › tuple_match_deep4 ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -417,23 +407,23 @@ pattern matching › tuple_match_deep4 ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) ) ) - (local.set $3 + (local.set $2 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $2) + (local.get $1) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $2) ) ) ) @@ -444,7 +434,7 @@ pattern matching › tuple_match_deep4 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $3) + (local.get $2) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -460,7 +450,7 @@ pattern matching › tuple_match_deep4 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $2) + (local.get $1) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -492,7 +482,7 @@ pattern matching › tuple_match_deep4 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=8 - (local.get $1) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -550,7 +540,7 @@ pattern matching › tuple_match_deep4 ) ) ) - (br $switch.53_outer + (br $switch.52_outer (call $gimport_pervasives_+ (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -574,7 +564,7 @@ pattern matching › tuple_match_deep4 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=12 - (local.get $1) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -584,7 +574,7 @@ pattern matching › tuple_match_deep4 ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -595,23 +585,23 @@ pattern matching › tuple_match_deep4 ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) ) ) - (local.set $3 + (local.set $2 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $2) + (local.get $1) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $2) ) ) ) @@ -638,7 +628,7 @@ pattern matching › tuple_match_deep4 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=8 - (local.get $1) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -672,7 +662,7 @@ pattern matching › tuple_match_deep4 ) ) ) - (br $switch.53_outer + (br $switch.52_outer (call $gimport_pervasives_+ (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -684,7 +674,7 @@ pattern matching › tuple_match_deep4 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $3) + (local.get $2) ) ) ) @@ -696,7 +686,7 @@ pattern matching › tuple_match_deep4 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=12 - (local.get $1) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -706,7 +696,7 @@ pattern matching › tuple_match_deep4 ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -717,28 +707,28 @@ pattern matching › tuple_match_deep4 ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) ) ) - (local.set $3 + (local.set $2 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=8 - (local.get $1) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $2) ) ) ) ) - (br $switch.53_outer + (br $switch.52_outer (call $gimport_pervasives_+ (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -746,11 +736,11 @@ pattern matching › tuple_match_deep4 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $3) + (local.get $2) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) + (local.get $1) ) ) ) @@ -759,7 +749,7 @@ pattern matching › tuple_match_deep4 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=8 - (local.get $1) + (local.get $3) ) ) ) @@ -776,7 +766,7 @@ pattern matching › tuple_match_deep4 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $3) ) ) (drop @@ -794,13 +784,13 @@ pattern matching › tuple_match_deep4 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $2) ) ) (drop diff --git a/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot index d798648405..3e3e6f9c68 100644 --- a/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot @@ -1,11 +1,10 @@ pattern matching › adt_match_4 (module - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef (mut i32))) @@ -15,6 +14,7 @@ pattern matching › adt_match_4 (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$pervasives\" \"+\" (func $gimport_pervasives_+ (param i32 i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"[...]\" (func $gimport_pervasives_[...] (param i32 i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) @@ -32,30 +32,19 @@ pattern matching › adt_match_4 (local $8 i32) (local $9 i32) (local $10 i32) - (local $11 i32) (local.set $5 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (i32.const 0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 13) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[]) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -67,26 +56,16 @@ pattern matching › adt_match_4 (local.set $6 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 11) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $5) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -98,20 +77,20 @@ pattern matching › adt_match_4 (local.set $3 (tuple.extract 0 (tuple.make - (block $switch.54_outer (result i32) + (block $switch.51_outer (result i32) (drop - (block $switch.54_branch_1 (result i32) + (block $switch.51_branch_1 (result i32) (drop - (block $switch.54_branch_2 (result i32) + (block $switch.51_branch_2 (result i32) (drop - (block $switch.54_branch_3 (result i32) + (block $switch.51_branch_3 (result i32) (drop - (block $switch.54_branch_4 (result i32) + (block $switch.51_branch_4 (result i32) (drop - (block $switch.54_branch_5 (result i32) + (block $switch.51_branch_5 (result i32) (drop - (block $switch.54_default (result i32) - (br_table $switch.54_branch_1 $switch.54_branch_2 $switch.54_branch_3 $switch.54_branch_4 $switch.54_branch_5 $switch.54_default + (block $switch.51_default (result i32) + (br_table $switch.51_branch_1 $switch.51_branch_2 $switch.51_branch_3 $switch.51_branch_4 $switch.51_branch_5 $switch.51_default (i32.const 0) (i32.shr_s (tuple.extract 0 @@ -127,29 +106,19 @@ pattern matching › adt_match_4 (tuple.extract 0 (tuple.make (i32.load offset=12 - (local.tee $0 + (local.tee $2 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $7 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 9) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $6) ) - (i32.load offset=8 - (local.get $7) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -185,13 +154,13 @@ pattern matching › adt_match_4 (tuple.extract 0 (tuple.make (i32.load offset=12 - (local.tee $1 + (local.tee $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $0) + (local.get $2) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -224,17 +193,17 @@ pattern matching › adt_match_4 (i32.or (i32.shl (i32.eq - (local.tee $11 + (local.tee $10 (tuple.extract 0 (tuple.make (i32.load offset=12 - (local.tee $2 + (local.tee $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -278,7 +247,7 @@ pattern matching › adt_match_4 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $2) + (local.get $1) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -313,7 +282,7 @@ pattern matching › adt_match_4 (i32.or (i32.shl (i32.eq - (local.get $11) + (local.get $10) (i32.const 1) ) (i32.const 31) @@ -386,39 +355,39 @@ pattern matching › adt_match_4 (unreachable) ) ) - (br $switch.54_outer + (br $switch.51_outer (i32.const 1999) ) ) ) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $0) + (local.get $2) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) ) @@ -429,7 +398,7 @@ pattern matching › adt_match_4 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $2) + (local.get $1) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -439,13 +408,13 @@ pattern matching › adt_match_4 ) ) ) - (local.set $8 + (local.set $7 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -455,13 +424,13 @@ pattern matching › adt_match_4 ) ) ) - (local.set $9 + (local.set $8 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $0) + (local.get $2) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -471,7 +440,7 @@ pattern matching › adt_match_4 ) ) ) - (local.set $10 + (local.set $9 (tuple.extract 0 (tuple.make (call $gimport_pervasives_+ @@ -481,11 +450,11 @@ pattern matching › adt_match_4 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $9) + (local.get $8) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $8) + (local.get $7) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -495,7 +464,7 @@ pattern matching › adt_match_4 ) ) ) - (br $switch.54_outer + (br $switch.51_outer (call $gimport_pervasives_+ (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -503,7 +472,7 @@ pattern matching › adt_match_4 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $10) + (local.get $9) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -513,34 +482,34 @@ pattern matching › adt_match_4 ) ) ) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $0) + (local.get $2) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) ) @@ -551,7 +520,7 @@ pattern matching › adt_match_4 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $0) + (local.get $2) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -561,7 +530,7 @@ pattern matching › adt_match_4 ) ) ) - (br $switch.54_outer + (br $switch.51_outer (call $gimport_pervasives_+ (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -573,17 +542,17 @@ pattern matching › adt_match_4 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) + (local.get $1) ) ) ) ) ) - (br $switch.54_outer + (br $switch.51_outer (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $0) + (local.get $2) ) ) ) @@ -591,7 +560,7 @@ pattern matching › adt_match_4 ) (i32.const 1) ) - (local.get $7) + (i32.const 0) ) ) ) @@ -610,19 +579,19 @@ pattern matching › adt_match_4 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) + (local.get $2) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) (drop @@ -634,19 +603,19 @@ pattern matching › adt_match_4 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $8) + (local.get $7) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $9) + (local.get $8) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $10) + (local.get $9) ) ) (local.get $3) diff --git a/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot b/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot index 7457503b09..c5ca64d870 100644 --- a/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot @@ -1,11 +1,10 @@ pattern matching › tuple_match_deep6 (module - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) @@ -17,6 +16,7 @@ pattern matching › tuple_match_deep6 (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$pervasives\" \"+\" (func $gimport_pervasives_+ (param i32 i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"[...]\" (func $gimport_pervasives_[...] (param i32 i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) @@ -43,26 +43,16 @@ pattern matching › tuple_match_deep6 (local.set $9 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (i32.const 0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 13) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[]) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -74,26 +64,16 @@ pattern matching › tuple_match_deep6 (local.set $10 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 11) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $9) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -105,26 +85,16 @@ pattern matching › tuple_match_deep6 (local.set $11 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 9) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $10) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -141,7 +111,7 @@ pattern matching › tuple_match_deep6 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) (i32.const 16) ) - (local.get $0) + (i32.const 0) ) ) ) @@ -162,7 +132,7 @@ pattern matching › tuple_match_deep6 (local.get $11) ) ) - (local.set $0 + (local.set $3 (tuple.extract 0 (tuple.make (local.get $4) @@ -176,20 +146,20 @@ pattern matching › tuple_match_deep6 (local.set $4 (tuple.extract 0 (tuple.make - (block $switch.59_outer (result i32) + (block $switch.56_outer (result i32) (drop - (block $switch.59_branch_1 (result i32) + (block $switch.56_branch_1 (result i32) (drop - (block $switch.59_branch_2 (result i32) + (block $switch.56_branch_2 (result i32) (drop - (block $switch.59_branch_3 (result i32) + (block $switch.56_branch_3 (result i32) (drop - (block $switch.59_branch_4 (result i32) + (block $switch.56_branch_4 (result i32) (drop - (block $switch.59_branch_5 (result i32) + (block $switch.56_branch_5 (result i32) (drop - (block $switch.59_default (result i32) - (br_table $switch.59_branch_1 $switch.59_branch_2 $switch.59_branch_3 $switch.59_branch_4 $switch.59_branch_5 $switch.59_default + (block $switch.56_default (result i32) + (br_table $switch.56_branch_1 $switch.56_branch_2 $switch.56_branch_3 $switch.56_branch_4 $switch.56_branch_5 $switch.56_default (i32.const 0) (i32.shr_s (tuple.extract 0 @@ -211,7 +181,7 @@ pattern matching › tuple_match_deep6 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=12 - (local.get $0) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -248,7 +218,7 @@ pattern matching › tuple_match_deep6 (tuple.extract 0 (tuple.make (i32.load offset=12 - (local.tee $1 + (local.tee $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -291,13 +261,13 @@ pattern matching › tuple_match_deep6 (tuple.extract 0 (tuple.make (i32.load offset=12 - (local.tee $2 + (local.tee $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -335,13 +305,13 @@ pattern matching › tuple_match_deep6 (tuple.extract 0 (tuple.make (i32.load offset=12 - (local.tee $3 + (local.tee $2 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $2) + (local.get $1) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -449,55 +419,55 @@ pattern matching › tuple_match_deep6 (unreachable) ) ) - (br $switch.59_outer + (br $switch.56_outer (i32.const 1999) ) ) ) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=12 - (local.get $0) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) ) ) - (local.set $3 + (local.set $2 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $2) + (local.get $1) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $2) ) ) ) @@ -508,7 +478,7 @@ pattern matching › tuple_match_deep6 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $3) + (local.get $2) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -524,7 +494,7 @@ pattern matching › tuple_match_deep6 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $2) + (local.get $1) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -540,7 +510,7 @@ pattern matching › tuple_match_deep6 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -556,7 +526,7 @@ pattern matching › tuple_match_deep6 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=8 - (local.get $0) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -614,7 +584,7 @@ pattern matching › tuple_match_deep6 ) ) ) - (br $switch.59_outer + (br $switch.56_outer (call $gimport_pervasives_+ (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -632,50 +602,50 @@ pattern matching › tuple_match_deep6 ) ) ) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=12 - (local.get $0) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) ) ) - (local.set $3 + (local.set $2 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $2) + (local.get $1) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $2) ) ) ) @@ -686,7 +656,7 @@ pattern matching › tuple_match_deep6 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -702,7 +672,7 @@ pattern matching › tuple_match_deep6 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=8 - (local.get $0) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -736,7 +706,7 @@ pattern matching › tuple_match_deep6 ) ) ) - (br $switch.59_outer + (br $switch.56_outer (call $gimport_pervasives_+ (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -748,61 +718,61 @@ pattern matching › tuple_match_deep6 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $3) + (local.get $2) ) ) ) ) ) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=12 - (local.get $0) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) ) ) - (local.set $3 + (local.set $2 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=8 - (local.get $0) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $2) ) ) ) ) - (br $switch.59_outer + (br $switch.56_outer (call $gimport_pervasives_+ (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -810,11 +780,11 @@ pattern matching › tuple_match_deep6 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $3) + (local.get $2) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) + (local.get $1) ) ) ) @@ -823,7 +793,7 @@ pattern matching › tuple_match_deep6 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=8 - (local.get $0) + (local.get $3) ) ) ) @@ -852,7 +822,7 @@ pattern matching › tuple_match_deep6 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) + (local.get $3) ) ) (drop @@ -864,19 +834,19 @@ pattern matching › tuple_match_deep6 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $2) ) ) (drop diff --git a/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot b/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot index 3fc8240cb8..4449836168 100644 --- a/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot @@ -1,11 +1,10 @@ pattern matching › adt_match_2 (module - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef (mut i32))) @@ -15,6 +14,7 @@ pattern matching › adt_match_2 (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$pervasives\" \"+\" (func $gimport_pervasives_+ (param i32 i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"[...]\" (func $gimport_pervasives_[...] (param i32 i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) @@ -30,24 +30,23 @@ pattern matching › adt_match_2 (local $6 i32) (local $7 i32) (local $8 i32) - (local $9 i32) (local.set $3 (tuple.extract 0 (tuple.make - (block $switch.48_outer (result i32) + (block $switch.47_outer (result i32) (drop - (block $switch.48_branch_1 (result i32) + (block $switch.47_branch_1 (result i32) (drop - (block $switch.48_branch_2 (result i32) + (block $switch.47_branch_2 (result i32) (drop - (block $switch.48_branch_3 (result i32) + (block $switch.47_branch_3 (result i32) (drop - (block $switch.48_branch_4 (result i32) + (block $switch.47_branch_4 (result i32) (drop - (block $switch.48_branch_5 (result i32) + (block $switch.47_branch_5 (result i32) (drop - (block $switch.48_default (result i32) - (br_table $switch.48_branch_1 $switch.48_branch_2 $switch.48_branch_3 $switch.48_branch_4 $switch.48_branch_5 $switch.48_default + (block $switch.47_default (result i32) + (br_table $switch.47_branch_1 $switch.47_branch_2 $switch.47_branch_3 $switch.47_branch_4 $switch.47_branch_5 $switch.47_default (i32.const 0) (i32.shr_s (tuple.extract 0 @@ -66,26 +65,16 @@ pattern matching › adt_match_2 (local.tee $2 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $5 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (i32.const 0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 5) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[]) ) - (i32.load offset=8 - (local.get $5) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -160,7 +149,7 @@ pattern matching › adt_match_2 (i32.or (i32.shl (i32.eq - (local.tee $9 + (local.tee $8 (tuple.extract 0 (tuple.make (i32.load offset=12 @@ -249,7 +238,7 @@ pattern matching › adt_match_2 (i32.or (i32.shl (i32.eq - (local.get $9) + (local.get $8) (i32.const 1) ) (i32.const 31) @@ -322,7 +311,7 @@ pattern matching › adt_match_2 (unreachable) ) ) - (br $switch.48_outer + (br $switch.47_outer (i32.const 1999) ) ) @@ -375,7 +364,7 @@ pattern matching › adt_match_2 ) ) ) - (local.set $6 + (local.set $5 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -391,7 +380,7 @@ pattern matching › adt_match_2 ) ) ) - (local.set $7 + (local.set $6 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -407,7 +396,7 @@ pattern matching › adt_match_2 ) ) ) - (local.set $8 + (local.set $7 (tuple.extract 0 (tuple.make (call $gimport_pervasives_+ @@ -417,11 +406,11 @@ pattern matching › adt_match_2 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $7) + (local.get $6) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $6) + (local.get $5) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -431,7 +420,7 @@ pattern matching › adt_match_2 ) ) ) - (br $switch.48_outer + (br $switch.47_outer (call $gimport_pervasives_+ (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -439,7 +428,7 @@ pattern matching › adt_match_2 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $8) + (local.get $7) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -497,7 +486,7 @@ pattern matching › adt_match_2 ) ) ) - (br $switch.48_outer + (br $switch.47_outer (call $gimport_pervasives_+ (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -515,7 +504,7 @@ pattern matching › adt_match_2 ) ) ) - (br $switch.48_outer + (br $switch.47_outer (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 @@ -527,7 +516,7 @@ pattern matching › adt_match_2 ) (i32.const 1) ) - (local.get $5) + (i32.const 0) ) ) ) @@ -558,19 +547,19 @@ pattern matching › adt_match_2 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $6) + (local.get $5) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $7) + (local.get $6) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $8) + (local.get $7) ) ) (local.get $3) diff --git a/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot b/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot index ba7b06f84e..8b054ac181 100644 --- a/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot @@ -1,11 +1,10 @@ pattern matching › adt_match_3 (module - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef (mut i32))) @@ -15,6 +14,7 @@ pattern matching › adt_match_3 (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$pervasives\" \"+\" (func $gimport_pervasives_+ (param i32 i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"[...]\" (func $gimport_pervasives_[...] (param i32 i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) @@ -31,30 +31,19 @@ pattern matching › adt_match_3 (local $7 i32) (local $8 i32) (local $9 i32) - (local $10 i32) (local.set $5 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (i32.const 0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 11) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[]) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -66,20 +55,20 @@ pattern matching › adt_match_3 (local.set $3 (tuple.extract 0 (tuple.make - (block $switch.51_outer (result i32) + (block $switch.49_outer (result i32) (drop - (block $switch.51_branch_1 (result i32) + (block $switch.49_branch_1 (result i32) (drop - (block $switch.51_branch_2 (result i32) + (block $switch.49_branch_2 (result i32) (drop - (block $switch.51_branch_3 (result i32) + (block $switch.49_branch_3 (result i32) (drop - (block $switch.51_branch_4 (result i32) + (block $switch.49_branch_4 (result i32) (drop - (block $switch.51_branch_5 (result i32) + (block $switch.49_branch_5 (result i32) (drop - (block $switch.51_default (result i32) - (br_table $switch.51_branch_1 $switch.51_branch_2 $switch.51_branch_3 $switch.51_branch_4 $switch.51_branch_5 $switch.51_default + (block $switch.49_default (result i32) + (br_table $switch.49_branch_1 $switch.49_branch_2 $switch.49_branch_3 $switch.49_branch_4 $switch.49_branch_5 $switch.49_default (i32.const 0) (i32.shr_s (tuple.extract 0 @@ -95,29 +84,19 @@ pattern matching › adt_match_3 (tuple.extract 0 (tuple.make (i32.load offset=12 - (local.tee $0 + (local.tee $2 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $6 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 9) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $5) ) - (i32.load offset=8 - (local.get $6) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -153,13 +132,13 @@ pattern matching › adt_match_3 (tuple.extract 0 (tuple.make (i32.load offset=12 - (local.tee $1 + (local.tee $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $0) + (local.get $2) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -192,17 +171,17 @@ pattern matching › adt_match_3 (i32.or (i32.shl (i32.eq - (local.tee $10 + (local.tee $9 (tuple.extract 0 (tuple.make (i32.load offset=12 - (local.tee $2 + (local.tee $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -246,7 +225,7 @@ pattern matching › adt_match_3 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $2) + (local.get $1) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -281,7 +260,7 @@ pattern matching › adt_match_3 (i32.or (i32.shl (i32.eq - (local.get $10) + (local.get $9) (i32.const 1) ) (i32.const 31) @@ -354,39 +333,39 @@ pattern matching › adt_match_3 (unreachable) ) ) - (br $switch.51_outer + (br $switch.49_outer (i32.const 1999) ) ) ) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $0) + (local.get $2) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) ) @@ -397,7 +376,7 @@ pattern matching › adt_match_3 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $2) + (local.get $1) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -407,13 +386,13 @@ pattern matching › adt_match_3 ) ) ) - (local.set $7 + (local.set $6 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -423,13 +402,13 @@ pattern matching › adt_match_3 ) ) ) - (local.set $8 + (local.set $7 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $0) + (local.get $2) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -439,7 +418,7 @@ pattern matching › adt_match_3 ) ) ) - (local.set $9 + (local.set $8 (tuple.extract 0 (tuple.make (call $gimport_pervasives_+ @@ -449,11 +428,11 @@ pattern matching › adt_match_3 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $8) + (local.get $7) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $7) + (local.get $6) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -463,7 +442,7 @@ pattern matching › adt_match_3 ) ) ) - (br $switch.51_outer + (br $switch.49_outer (call $gimport_pervasives_+ (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -471,7 +450,7 @@ pattern matching › adt_match_3 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $9) + (local.get $8) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -481,34 +460,34 @@ pattern matching › adt_match_3 ) ) ) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $0) + (local.get $2) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) ) @@ -519,7 +498,7 @@ pattern matching › adt_match_3 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $0) + (local.get $2) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -529,7 +508,7 @@ pattern matching › adt_match_3 ) ) ) - (br $switch.51_outer + (br $switch.49_outer (call $gimport_pervasives_+ (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -541,17 +520,17 @@ pattern matching › adt_match_3 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) + (local.get $1) ) ) ) ) ) - (br $switch.51_outer + (br $switch.49_outer (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $0) + (local.get $2) ) ) ) @@ -559,7 +538,7 @@ pattern matching › adt_match_3 ) (i32.const 1) ) - (local.get $6) + (i32.const 0) ) ) ) @@ -572,19 +551,19 @@ pattern matching › adt_match_3 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) + (local.get $2) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) (drop @@ -596,19 +575,19 @@ pattern matching › adt_match_3 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $7) + (local.get $6) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $8) + (local.get $7) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $9) + (local.get $8) ) ) (local.get $3) diff --git a/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot b/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot index 6f79a5ffaf..30474fd508 100644 --- a/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot @@ -1,11 +1,10 @@ pattern matching › adt_match_5 (module - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef (mut i32))) @@ -15,6 +14,7 @@ pattern matching › adt_match_5 (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$pervasives\" \"+\" (func $gimport_pervasives_+ (param i32 i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"[...]\" (func $gimport_pervasives_[...] (param i32 i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) @@ -33,30 +33,19 @@ pattern matching › adt_match_5 (local $9 i32) (local $10 i32) (local $11 i32) - (local $12 i32) (local.set $5 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (i32.const 0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 15) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[]) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -68,26 +57,16 @@ pattern matching › adt_match_5 (local.set $6 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 13) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $5) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -99,26 +78,16 @@ pattern matching › adt_match_5 (local.set $7 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 11) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $6) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -130,20 +99,20 @@ pattern matching › adt_match_5 (local.set $3 (tuple.extract 0 (tuple.make - (block $switch.57_outer (result i32) + (block $switch.53_outer (result i32) (drop - (block $switch.57_branch_1 (result i32) + (block $switch.53_branch_1 (result i32) (drop - (block $switch.57_branch_2 (result i32) + (block $switch.53_branch_2 (result i32) (drop - (block $switch.57_branch_3 (result i32) + (block $switch.53_branch_3 (result i32) (drop - (block $switch.57_branch_4 (result i32) + (block $switch.53_branch_4 (result i32) (drop - (block $switch.57_branch_5 (result i32) + (block $switch.53_branch_5 (result i32) (drop - (block $switch.57_default (result i32) - (br_table $switch.57_branch_1 $switch.57_branch_2 $switch.57_branch_3 $switch.57_branch_4 $switch.57_branch_5 $switch.57_default + (block $switch.53_default (result i32) + (br_table $switch.53_branch_1 $switch.53_branch_2 $switch.53_branch_3 $switch.53_branch_4 $switch.53_branch_5 $switch.53_default (i32.const 0) (i32.shr_s (tuple.extract 0 @@ -159,29 +128,19 @@ pattern matching › adt_match_5 (tuple.extract 0 (tuple.make (i32.load offset=12 - (local.tee $0 + (local.tee $2 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $8 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 9) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $7) ) - (i32.load offset=8 - (local.get $8) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -217,13 +176,13 @@ pattern matching › adt_match_5 (tuple.extract 0 (tuple.make (i32.load offset=12 - (local.tee $1 + (local.tee $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $0) + (local.get $2) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -256,17 +215,17 @@ pattern matching › adt_match_5 (i32.or (i32.shl (i32.eq - (local.tee $12 + (local.tee $11 (tuple.extract 0 (tuple.make (i32.load offset=12 - (local.tee $2 + (local.tee $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -310,7 +269,7 @@ pattern matching › adt_match_5 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $2) + (local.get $1) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -345,7 +304,7 @@ pattern matching › adt_match_5 (i32.or (i32.shl (i32.eq - (local.get $12) + (local.get $11) (i32.const 1) ) (i32.const 31) @@ -418,39 +377,39 @@ pattern matching › adt_match_5 (unreachable) ) ) - (br $switch.57_outer + (br $switch.53_outer (i32.const 1999) ) ) ) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $0) + (local.get $2) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) ) @@ -461,7 +420,7 @@ pattern matching › adt_match_5 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $2) + (local.get $1) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -471,13 +430,13 @@ pattern matching › adt_match_5 ) ) ) - (local.set $9 + (local.set $8 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -487,13 +446,13 @@ pattern matching › adt_match_5 ) ) ) - (local.set $10 + (local.set $9 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $0) + (local.get $2) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -503,7 +462,7 @@ pattern matching › adt_match_5 ) ) ) - (local.set $11 + (local.set $10 (tuple.extract 0 (tuple.make (call $gimport_pervasives_+ @@ -513,11 +472,11 @@ pattern matching › adt_match_5 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $10) + (local.get $9) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $9) + (local.get $8) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -527,7 +486,7 @@ pattern matching › adt_match_5 ) ) ) - (br $switch.57_outer + (br $switch.53_outer (call $gimport_pervasives_+ (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -535,7 +494,7 @@ pattern matching › adt_match_5 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $11) + (local.get $10) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -545,34 +504,34 @@ pattern matching › adt_match_5 ) ) ) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $0) + (local.get $2) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) ) @@ -583,7 +542,7 @@ pattern matching › adt_match_5 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $0) + (local.get $2) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -593,7 +552,7 @@ pattern matching › adt_match_5 ) ) ) - (br $switch.57_outer + (br $switch.53_outer (call $gimport_pervasives_+ (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -605,17 +564,17 @@ pattern matching › adt_match_5 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) + (local.get $1) ) ) ) ) ) - (br $switch.57_outer + (br $switch.53_outer (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $0) + (local.get $2) ) ) ) @@ -623,7 +582,7 @@ pattern matching › adt_match_5 ) (i32.const 1) ) - (local.get $8) + (i32.const 0) ) ) ) @@ -648,19 +607,19 @@ pattern matching › adt_match_5 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) + (local.get $2) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) (drop @@ -672,19 +631,19 @@ pattern matching › adt_match_5 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $9) + (local.get $8) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $10) + (local.get $9) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $11) + (local.get $10) ) ) (local.get $3) diff --git a/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot index e427cbd85a..dd5954f322 100644 --- a/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot @@ -1,11 +1,10 @@ pattern matching › tuple_match_deep5 (module - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) @@ -17,6 +16,7 @@ pattern matching › tuple_match_deep5 (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$pervasives\" \"+\" (func $gimport_pervasives_+ (param i32 i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"[...]\" (func $gimport_pervasives_[...] (param i32 i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) @@ -42,26 +42,16 @@ pattern matching › tuple_match_deep5 (local.set $9 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (i32.const 0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 11) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[]) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -73,26 +63,16 @@ pattern matching › tuple_match_deep5 (local.set $10 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 9) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $9) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -109,7 +89,7 @@ pattern matching › tuple_match_deep5 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) (i32.const 16) ) - (local.get $0) + (i32.const 0) ) ) ) @@ -130,7 +110,7 @@ pattern matching › tuple_match_deep5 (local.get $10) ) ) - (local.set $0 + (local.set $3 (tuple.extract 0 (tuple.make (local.get $4) @@ -144,20 +124,20 @@ pattern matching › tuple_match_deep5 (local.set $4 (tuple.extract 0 (tuple.make - (block $switch.56_outer (result i32) + (block $switch.54_outer (result i32) (drop - (block $switch.56_branch_1 (result i32) + (block $switch.54_branch_1 (result i32) (drop - (block $switch.56_branch_2 (result i32) + (block $switch.54_branch_2 (result i32) (drop - (block $switch.56_branch_3 (result i32) + (block $switch.54_branch_3 (result i32) (drop - (block $switch.56_branch_4 (result i32) + (block $switch.54_branch_4 (result i32) (drop - (block $switch.56_branch_5 (result i32) + (block $switch.54_branch_5 (result i32) (drop - (block $switch.56_default (result i32) - (br_table $switch.56_branch_1 $switch.56_branch_2 $switch.56_branch_3 $switch.56_branch_4 $switch.56_branch_5 $switch.56_default + (block $switch.54_default (result i32) + (br_table $switch.54_branch_1 $switch.54_branch_2 $switch.54_branch_3 $switch.54_branch_4 $switch.54_branch_5 $switch.54_default (i32.const 0) (i32.shr_s (tuple.extract 0 @@ -179,7 +159,7 @@ pattern matching › tuple_match_deep5 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=12 - (local.get $0) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -216,7 +196,7 @@ pattern matching › tuple_match_deep5 (tuple.extract 0 (tuple.make (i32.load offset=12 - (local.tee $1 + (local.tee $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -259,13 +239,13 @@ pattern matching › tuple_match_deep5 (tuple.extract 0 (tuple.make (i32.load offset=12 - (local.tee $2 + (local.tee $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -303,13 +283,13 @@ pattern matching › tuple_match_deep5 (tuple.extract 0 (tuple.make (i32.load offset=12 - (local.tee $3 + (local.tee $2 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $2) + (local.get $1) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -417,55 +397,55 @@ pattern matching › tuple_match_deep5 (unreachable) ) ) - (br $switch.56_outer + (br $switch.54_outer (i32.const 1999) ) ) ) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=12 - (local.get $0) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) ) ) - (local.set $3 + (local.set $2 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $2) + (local.get $1) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $2) ) ) ) @@ -476,7 +456,7 @@ pattern matching › tuple_match_deep5 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $3) + (local.get $2) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -492,7 +472,7 @@ pattern matching › tuple_match_deep5 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $2) + (local.get $1) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -508,7 +488,7 @@ pattern matching › tuple_match_deep5 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -524,7 +504,7 @@ pattern matching › tuple_match_deep5 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=8 - (local.get $0) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -582,7 +562,7 @@ pattern matching › tuple_match_deep5 ) ) ) - (br $switch.56_outer + (br $switch.54_outer (call $gimport_pervasives_+ (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -600,50 +580,50 @@ pattern matching › tuple_match_deep5 ) ) ) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=12 - (local.get $0) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) ) ) - (local.set $3 + (local.set $2 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $2) + (local.get $1) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $2) ) ) ) @@ -654,7 +634,7 @@ pattern matching › tuple_match_deep5 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -670,7 +650,7 @@ pattern matching › tuple_match_deep5 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=8 - (local.get $0) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -704,7 +684,7 @@ pattern matching › tuple_match_deep5 ) ) ) - (br $switch.56_outer + (br $switch.54_outer (call $gimport_pervasives_+ (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -716,61 +696,61 @@ pattern matching › tuple_match_deep5 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $3) + (local.get $2) ) ) ) ) ) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=12 - (local.get $0) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) ) ) - (local.set $3 + (local.set $2 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=8 - (local.get $0) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $2) ) ) ) ) - (br $switch.56_outer + (br $switch.54_outer (call $gimport_pervasives_+ (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -778,11 +758,11 @@ pattern matching › tuple_match_deep5 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $3) + (local.get $2) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) + (local.get $1) ) ) ) @@ -791,7 +771,7 @@ pattern matching › tuple_match_deep5 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=8 - (local.get $0) + (local.get $3) ) ) ) @@ -814,7 +794,7 @@ pattern matching › tuple_match_deep5 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) + (local.get $3) ) ) (drop @@ -826,19 +806,19 @@ pattern matching › tuple_match_deep5 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $2) ) ) (drop diff --git a/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot b/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot index cf5f9ec188..20bce4ee2a 100644 --- a/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot @@ -1,11 +1,10 @@ pattern matching › tuple_match_deep7 (module - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) @@ -17,6 +16,7 @@ pattern matching › tuple_match_deep7 (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$pervasives\" \"+\" (func $gimport_pervasives_+ (param i32 i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"[...]\" (func $gimport_pervasives_[...] (param i32 i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) @@ -44,26 +44,16 @@ pattern matching › tuple_match_deep7 (local.set $9 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (i32.const 0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 15) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[]) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -75,26 +65,16 @@ pattern matching › tuple_match_deep7 (local.set $10 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 13) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $9) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -106,26 +86,16 @@ pattern matching › tuple_match_deep7 (local.set $11 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 11) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $10) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -137,26 +107,16 @@ pattern matching › tuple_match_deep7 (local.set $12 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 9) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $11) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -173,7 +133,7 @@ pattern matching › tuple_match_deep7 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) (i32.const 16) ) - (local.get $0) + (i32.const 0) ) ) ) @@ -194,7 +154,7 @@ pattern matching › tuple_match_deep7 (local.get $12) ) ) - (local.set $0 + (local.set $3 (tuple.extract 0 (tuple.make (local.get $4) @@ -208,20 +168,20 @@ pattern matching › tuple_match_deep7 (local.set $4 (tuple.extract 0 (tuple.make - (block $switch.62_outer (result i32) + (block $switch.58_outer (result i32) (drop - (block $switch.62_branch_1 (result i32) + (block $switch.58_branch_1 (result i32) (drop - (block $switch.62_branch_2 (result i32) + (block $switch.58_branch_2 (result i32) (drop - (block $switch.62_branch_3 (result i32) + (block $switch.58_branch_3 (result i32) (drop - (block $switch.62_branch_4 (result i32) + (block $switch.58_branch_4 (result i32) (drop - (block $switch.62_branch_5 (result i32) + (block $switch.58_branch_5 (result i32) (drop - (block $switch.62_default (result i32) - (br_table $switch.62_branch_1 $switch.62_branch_2 $switch.62_branch_3 $switch.62_branch_4 $switch.62_branch_5 $switch.62_default + (block $switch.58_default (result i32) + (br_table $switch.58_branch_1 $switch.58_branch_2 $switch.58_branch_3 $switch.58_branch_4 $switch.58_branch_5 $switch.58_default (i32.const 0) (i32.shr_s (tuple.extract 0 @@ -243,7 +203,7 @@ pattern matching › tuple_match_deep7 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=12 - (local.get $0) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -280,7 +240,7 @@ pattern matching › tuple_match_deep7 (tuple.extract 0 (tuple.make (i32.load offset=12 - (local.tee $1 + (local.tee $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -323,13 +283,13 @@ pattern matching › tuple_match_deep7 (tuple.extract 0 (tuple.make (i32.load offset=12 - (local.tee $2 + (local.tee $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -367,13 +327,13 @@ pattern matching › tuple_match_deep7 (tuple.extract 0 (tuple.make (i32.load offset=12 - (local.tee $3 + (local.tee $2 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $2) + (local.get $1) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -481,55 +441,55 @@ pattern matching › tuple_match_deep7 (unreachable) ) ) - (br $switch.62_outer + (br $switch.58_outer (i32.const 1999) ) ) ) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=12 - (local.get $0) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) ) ) - (local.set $3 + (local.set $2 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $2) + (local.get $1) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $2) ) ) ) @@ -540,7 +500,7 @@ pattern matching › tuple_match_deep7 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $3) + (local.get $2) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -556,7 +516,7 @@ pattern matching › tuple_match_deep7 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $2) + (local.get $1) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -572,7 +532,7 @@ pattern matching › tuple_match_deep7 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -588,7 +548,7 @@ pattern matching › tuple_match_deep7 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=8 - (local.get $0) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -646,7 +606,7 @@ pattern matching › tuple_match_deep7 ) ) ) - (br $switch.62_outer + (br $switch.58_outer (call $gimport_pervasives_+ (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -664,50 +624,50 @@ pattern matching › tuple_match_deep7 ) ) ) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=12 - (local.get $0) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=24 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) ) ) - (local.set $3 + (local.set $2 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $2) + (local.get $1) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $2) ) ) ) @@ -718,7 +678,7 @@ pattern matching › tuple_match_deep7 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -734,7 +694,7 @@ pattern matching › tuple_match_deep7 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=8 - (local.get $0) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -768,7 +728,7 @@ pattern matching › tuple_match_deep7 ) ) ) - (br $switch.62_outer + (br $switch.58_outer (call $gimport_pervasives_+ (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -780,61 +740,61 @@ pattern matching › tuple_match_deep7 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $3) + (local.get $2) ) ) ) ) ) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=12 - (local.get $0) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=20 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) ) ) - (local.set $3 + (local.set $2 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=8 - (local.get $0) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $2) ) ) ) ) - (br $switch.62_outer + (br $switch.58_outer (call $gimport_pervasives_+ (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -842,11 +802,11 @@ pattern matching › tuple_match_deep7 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $3) + (local.get $2) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) + (local.get $1) ) ) ) @@ -855,7 +815,7 @@ pattern matching › tuple_match_deep7 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=8 - (local.get $0) + (local.get $3) ) ) ) @@ -890,7 +850,7 @@ pattern matching › tuple_match_deep7 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $0) + (local.get $3) ) ) (drop @@ -902,19 +862,19 @@ pattern matching › tuple_match_deep7 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $2) ) ) (drop diff --git a/compiler/test/__snapshots__/records.60c0a141.0.snapshot b/compiler/test/__snapshots__/records.60c0a141.0.snapshot index 717d271a3e..6e7b933481 100644 --- a/compiler/test/__snapshots__/records.60c0a141.0.snapshot +++ b/compiler/test/__snapshots__/records.60c0a141.0.snapshot @@ -4,7 +4,6 @@ records › record_recursive_data_definition (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"_grainEnv\" \"moduleRuntimeId\" (global $wimport__grainEnv_moduleRuntimeId i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc (mut i32))) @@ -15,6 +14,7 @@ records › record_recursive_data_definition (import \"GRAIN$MODULE$runtime/gc\" \"malloc\" (func $wimport_GRAIN$MODULE$runtime/gc_malloc (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"Some\" (func $gimport_pervasives_Some (param i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) @@ -196,25 +196,15 @@ records › record_recursive_data_definition (local.set $3 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_Some) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_Some + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_Some) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $1) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -243,25 +233,15 @@ records › record_recursive_data_definition (local.set $4 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_Some) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_Some + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_Some) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $2) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) diff --git a/compiler/test/__snapshots__/stdlib.37483d2d.0.snapshot b/compiler/test/__snapshots__/stdlib.37483d2d.0.snapshot index 37803ec65a..330c282330 100644 --- a/compiler/test/__snapshots__/stdlib.37483d2d.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.37483d2d.0.snapshot @@ -1,11 +1,10 @@ stdlib › stdlib_cons (module - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef (mut i32))) @@ -13,6 +12,7 @@ stdlib › stdlib_cons (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$[...]\" (global $gimport_pervasives_[...] (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"[...]\" (func $gimport_pervasives_[...] (param i32 i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) @@ -22,29 +22,19 @@ stdlib › stdlib_cons (local $0 i32) (local $1 i32) (local $2 i32) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (i32.const 0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 7) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[]) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -53,27 +43,17 @@ stdlib › stdlib_cons ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 5) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) - ) - (i32.load offset=8 (local.get $0) ) ) @@ -84,47 +64,37 @@ stdlib › stdlib_cons ) ) ) - (local.set $0 + (local.set $2 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 3) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) - ) - (i32.load offset=8 - (local.get $0) + (local.get $1) ) ) - (local.get $0) + (i32.const 0) ) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) - (local.get $0) + (local.get $2) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/stdlib.8300ad7c.0.snapshot b/compiler/test/__snapshots__/stdlib.8300ad7c.0.snapshot index 2dad32cd86..3d6394815b 100644 --- a/compiler/test/__snapshots__/stdlib.8300ad7c.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.8300ad7c.0.snapshot @@ -1,11 +1,10 @@ stdlib › stdlib_equal_3 (module - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) - (import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) (import \"_grainEnv\" \"relocBase\" (global $wimport__grainEnv_relocBase i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef (mut i32))) @@ -14,6 +13,7 @@ stdlib › stdlib_equal_3 (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $gimport_pervasives_== (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $wimport_GRAIN$MODULE$runtime/gc_decRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"[...]\" (func $gimport_pervasives_[...] (param i32 i32 i32) (result i32))) (import \"GRAIN$MODULE$pervasives\" \"==\" (func $gimport_pervasives_== (param i32 i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) @@ -28,29 +28,19 @@ stdlib › stdlib_equal_3 (local $4 i32) (local $5 i32) (local $6 i32) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (i32.const 0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 7) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[]) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -59,27 +49,17 @@ stdlib › stdlib_equal_3 ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 5) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) - ) - (i32.load offset=8 (local.get $0) ) ) @@ -90,28 +70,18 @@ stdlib › stdlib_equal_3 ) ) ) - (local.set $3 + (local.set $2 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 3) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) - ) - (i32.load offset=8 - (local.get $0) + (local.get $1) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -121,29 +91,19 @@ stdlib › stdlib_equal_3 ) ) ) - (local.set $4 + (local.set $3 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 7) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[]) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -152,28 +112,18 @@ stdlib › stdlib_equal_3 ) ) ) - (local.set $5 + (local.set $4 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 5) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $4) - ) - (i32.load offset=8 - (local.get $0) + (local.get $3) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -183,28 +133,18 @@ stdlib › stdlib_equal_3 ) ) ) - (local.set $6 + (local.set $5 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (tuple.extract 0 - (tuple.make - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_[...]) - ) - (local.get $0) - ) - ) + (call $gimport_pervasives_[...] + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_[...]) ) (i32.const 3) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $5) - ) - (i32.load offset=8 - (local.get $0) + (local.get $4) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -214,7 +154,7 @@ stdlib › stdlib_equal_3 ) ) ) - (local.set $0 + (local.set $6 (tuple.extract 0 (tuple.make (call $gimport_pervasives_== @@ -224,54 +164,54 @@ stdlib › stdlib_equal_3 ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $3) + (local.get $2) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $6) + (local.get $5) ) ) - (local.get $0) + (i32.const 0) ) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $2) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $4) + (local.get $3) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $5) + (local.get $4) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $6) + (local.get $5) ) ) - (local.get $0) + (local.get $6) ) (func $_start (; has Stack IR ;) (drop