From 0f967645fe1c17d62eeab1dcef9c2dbc63ec872b Mon Sep 17 00:00:00 2001 From: Oscar Spencer Date: Tue, 22 Mar 2022 03:32:57 -0400 Subject: [PATCH 1/3] feat(compiler): Allow function re-exports to use regular call instruction --- compiler/src/codegen/compcore.re | 66 ++++++++-------- compiler/src/codegen/mashtree.re | 13 +++- compiler/src/codegen/transl_anf.re | 76 ++++++++++++++----- compiler/src/middle_end/optimize_constants.re | 24 ++++++ 4 files changed, 124 insertions(+), 55 deletions(-) diff --git a/compiler/src/codegen/compcore.re b/compiler/src/codegen/compcore.re index 2b973ebaed..705aaf3ed3 100644 --- a/compiler/src/codegen/compcore.re +++ b/compiler/src/codegen/compcore.re @@ -3393,53 +3393,51 @@ let compile_imports = (wasm_mod, env, {imports}) => { ); }; -let compile_exports = (wasm_mod, env, {functions, imports, exports, globals}) => { - let compile_export = (i, {ex_name, ex_global_index}) => { - let internal_name = Printf.sprintf("global_%ld", ex_global_index); - let exported_name = "GRAIN$EXPORT$" ++ Ident.name(ex_name); - ignore @@ Export.add_global_export(wasm_mod, internal_name, exported_name); - }; - - let compile_external_function_export = ((internal_name, external_name)) => { - ignore @@ - Export.add_function_export(wasm_mod, internal_name, external_name); +let compile_exports = (wasm_mod, env, {imports, exports, globals}) => { + let compile_export = (i, export) => { + switch (export) { + | GlobalExport({ex_global_name, ex_global_index}) => + let internal_name = Printf.sprintf("global_%ld", ex_global_index); + let exported_name = "GRAIN$EXPORT$" ++ Ident.name(ex_global_name); + ignore @@ + Export.add_global_export(wasm_mod, internal_name, exported_name); + | FunctionExport({ex_function_internal_name, ex_function_name}) => + ignore @@ + Export.add_function_export( + wasm_mod, + ex_function_internal_name, + ex_function_name, + ) + }; }; let exports = { - let exported = Hashtbl.create(14); + module StringSet = Set.Make(String); + let exported_globals = ref(StringSet.empty); + let exported_functions = ref(StringSet.empty); /* Exports are already reversed, so keeping the first of any name is the correct behavior. */ List.filter( - ({ex_name}) => - if (Hashtbl.mem(exported, Ident.name(ex_name))) { + fun + | GlobalExport({ex_global_name}) => + if (StringSet.mem(Ident.name(ex_global_name), exported_globals^)) { false; } else { - Hashtbl.add(exported, Ident.name(ex_name), ()); + exported_globals := + StringSet.add(Ident.name(ex_global_name), exported_globals^); + true; + } + | FunctionExport({ex_function_name}) => + if (StringSet.mem(ex_function_name, exported_functions^)) { + false; + } else { + exported_functions := + StringSet.add(ex_function_name, exported_functions^); true; }, exports, ); }; - let functions = { - let exported = Hashtbl.create(14); - /* Functions will be reversed, so keeping the first of any name is the correct behavior. */ - List.filter_map( - ({index, name, id}) => - switch (name) { - | Some(name) => - if (Hashtbl.mem(exported, name)) { - None; - } else { - Hashtbl.add(exported, name, ()); - let internal_name = Ident.unique_name(id); - Some((internal_name, name)); - } - | None => None - }, - functions, - ); - }; List.iteri(compile_export, exports); - List.iter(compile_external_function_export, List.rev(functions)); ignore @@ Export.add_function_export(wasm_mod, grain_main, grain_main); ignore @@ Export.add_function_export(wasm_mod, grain_start, grain_start); ignore @@ diff --git a/compiler/src/codegen/mashtree.re b/compiler/src/codegen/mashtree.re index d61ba8f27c..788b558ae3 100644 --- a/compiler/src/codegen/mashtree.re +++ b/compiler/src/codegen/mashtree.re @@ -456,10 +456,15 @@ type import = { }; [@deriving sexp] -type export = { - ex_name: Ident.t, - ex_global_index: int32, -}; +type export = + | FunctionExport({ + ex_function_name: string, + ex_function_internal_name: string, + }) + | GlobalExport({ + ex_global_name: Ident.t, + ex_global_index: int32, + }); [@deriving sexp] type mash_function = { diff --git a/compiler/src/codegen/transl_anf.re b/compiler/src/codegen/transl_anf.re index 9c6f609c81..3f20602a59 100644 --- a/compiler/src/codegen/transl_anf.re +++ b/compiler/src/codegen/transl_anf.re @@ -79,9 +79,9 @@ let global_index = ref(0); let global_exports = () => { let tbl = global_table^; Ident.fold_all( - (ex_name, (exported, ex_global_index, _), acc) => + (ex_global_name, (exported, ex_global_index, _), acc) => if (exported) { - [{ex_name, ex_global_index}, ...acc]; + [GlobalExport({ex_global_name, ex_global_index}), ...acc]; } else { acc; }, @@ -511,6 +511,12 @@ let run_register_allocation = (instrs: list(Mashtree.instr)) => { |> run(Types.StackAllocated(WasmF64)); }; +let grain_import_name = (mod_, name) => + Printf.sprintf("gimport_%s_%s", mod_, name); + +let wasm_import_name = (mod_, name) => + Printf.sprintf("wimport_%s_%s", mod_, name); + let compile_const = (c: Asttypes.constant) => switch (c) { | Const_number(Const_number_int(i)) => MConstI32(Int64.to_int32(i)) @@ -565,6 +571,7 @@ let known_function = f => let compile_lambda = (~name=?, id, env, args, body, attrs, loc): Mashtree.closure_data => { register_function(Internal(id)); + let (body, return_type) = body; // NOTE: we special-case `id`, since we want to // have simply-recursive uses of identifiers use @@ -654,6 +661,7 @@ let compile_lambda = let compile_wrapper = (~export_name=?, id, env, func_name, args, rets): Mashtree.closure_data => { register_function(Internal(id)); + let body = [ { instr_desc: @@ -1058,7 +1066,7 @@ let lift_imports = (env, imports) => { | GrainValue(mod_, name) => let mimp_mod = Ident.create_persistent(mod_); let mimp_name = Ident.create_persistent(name); - let import_name = Printf.sprintf("gimport_%s_%s", mod_, name); + let import_name = grain_import_name(mod_, name); let (alloc, mods) = switch (imp_shape) { | GlobalShape(alloc) => ( @@ -1137,8 +1145,7 @@ let lift_imports = (env, imports) => { Ident.add( imp_use_id, MGlobalBind( - Printf.sprintf( - "wimport_%s_%s", + wasm_import_name( Ident.name(mimp_mod), Ident.name(mimp_name), ), @@ -1160,7 +1167,7 @@ let lift_imports = (env, imports) => { mimp_setup: MWrap(Int32.zero), mimp_used: true, }; - let func_name = Printf.sprintf("wimport_%s_%s", mod_, name); + let func_name = wasm_import_name(mod_, name); let export_name = if (exported) { Some(name); @@ -1228,36 +1235,70 @@ let lift_imports = (env, imports) => { (imports, setups, env); }; -let transl_signature = (functions, signature) => { +let transl_signature = (functions, imports, signature) => { open Types; + let function_exports = ref([]); + // At this point in compilation, we know which functions can be called // directly/indirectly at the wasm level. We add this information to the // module signature. let func_map = Ident_tbl.create(30); List.iter( - func => Ident_tbl.add(func_map, (func: mash_function).id, func), + (func: mash_function) => + switch (func.name) { + | Some(name) => + Ident_tbl.add(func_map, func.id, Ident.unique_name(func.id)) + | None => () + }, functions, ); + List.iter( + imp => + switch (imp.imp_shape) { + | FunctionShape(_) => + let internal_name = + switch (imp.imp_desc) { + | GrainValue(mod_, name) => grain_import_name(mod_, name) + | WasmFunction(mod_, name) => Ident.unique_name(imp.imp_use_id) + | _ => failwith("Wasm or js value had FunctionShape") + }; + Ident_tbl.add(func_map, imp.imp_use_id, internal_name); + | _ => () + }, + imports, + ); let sign = List.map( fun | TSigValue( - _, + vid, { val_repr: ReprFunction(args, rets, _), val_fullpath: Path.PIdent(id), } as vd, ) => { switch (Ident_tbl.find_opt(func_map, id)) { - | Some({name: Some(name)}) => + | Some(internal_name) => + let external_name = Ident.name(vid); + function_exports := + [ + FunctionExport({ + ex_function_name: external_name, + ex_function_internal_name: internal_name, + }), + ...function_exports^, + ]; TSigValue( - id, - {...vd, val_repr: ReprFunction(args, rets, Direct(name))}, - ) + vid, + { + ...vd, + val_repr: ReprFunction(args, rets, Direct(external_name)), + }, + ); | _ => TSigValue( - id, + vid, {...vd, val_repr: ReprFunction(args, rets, Indirect)}, ) }; @@ -1265,7 +1306,7 @@ let transl_signature = (functions, signature) => { | _ as item => item, signature.Cmi_format.cmi_sign, ); - {...signature, cmi_sign: sign}; + ({...signature, cmi_sign: sign}, function_exports^); }; let transl_anf_program = @@ -1297,14 +1338,15 @@ let transl_anf_program = }; let main_body = run_register_allocation @@ setups @ compile_anf_expr(env, anf_prog.body); - let exports = global_exports(); let functions = List.map( ({body} as f: Mashtree.mash_function) => {...f, body: run_register_allocation(body)}, compile_remaining_worklist(), ); - let signature = transl_signature(functions, anf_prog.signature); + let (signature, function_exports) = + transl_signature(functions, anf_prog.imports, anf_prog.signature); + let exports = function_exports @ global_exports(); { functions, diff --git a/compiler/src/middle_end/optimize_constants.re b/compiler/src/middle_end/optimize_constants.re index 3a14150278..e1eefb6d59 100644 --- a/compiler/src/middle_end/optimize_constants.re +++ b/compiler/src/middle_end/optimize_constants.re @@ -49,6 +49,30 @@ module ConstantPropagationArg: Anf_mapper.MapArgument = { } | _ => i }; + + let leave_anf_program = ({signature} as p) => { + // Support directly exporting imports + let cmi_sign = + List.map( + fun + | TSigValue(vid, {val_fullpath: Path.PIdent(id)} as vd) as item => { + switch (Ident.find_same_opt(id, known_constants^)) { + | Some(ImmId(immid)) => + TSigValue(vid, {...vd, val_fullpath: Path.PIdent(immid)}) + | _ => item + }; + } + | item => item, + signature.cmi_sign, + ); + { + ...p, + signature: { + ...signature, + cmi_sign, + }, + }; + }; }; module ConstantPropagationMapper = Anf_mapper.MakeMap(ConstantPropagationArg); From 7dfc92132fe5bc41e2b7eaddda089a13c27daad3 Mon Sep 17 00:00:00 2001 From: Oscar Spencer Date: Tue, 22 Mar 2022 04:09:43 -0400 Subject: [PATCH 2/3] snapshots --- .../basic_functionality.0996c5f7.0.snapshot | 18 +- .../basic_functionality.0a230f18.0.snapshot | 18 +- .../basic_functionality.0a2e4afa.0.snapshot | 18 +- .../basic_functionality.0c0b170b.0.snapshot | 18 +- .../basic_functionality.0c400bde.0.snapshot | 18 +- .../basic_functionality.1ad0f349.0.snapshot | 31 +-- .../basic_functionality.1b68c8db.0.snapshot | 18 +- .../basic_functionality.1e4b1f39.0.snapshot | 18 +- .../basic_functionality.1f787365.0.snapshot | 16 +- .../basic_functionality.28405f1f.0.snapshot | 31 +-- .../basic_functionality.2f2f8795.0.snapshot | 18 +- .../basic_functionality.32a8c452.0.snapshot | 16 +- .../basic_functionality.3e5f990b.0.snapshot | 18 +- .../basic_functionality.3edefd23.0.snapshot | 16 +- .../basic_functionality.52ca8e0e.0.snapshot | 37 ++- .../basic_functionality.5705b20c.0.snapshot | 18 +- .../basic_functionality.5d973a3e.0.snapshot | 18 +- .../basic_functionality.65d36891.0.snapshot | 18 +- .../basic_functionality.68d08483.0.snapshot | 18 +- .../basic_functionality.711a4824.0.snapshot | 64 ++---- .../basic_functionality.7287219f.0.snapshot | 18 +- .../basic_functionality.974b7936.0.snapshot | 18 +- .../basic_functionality.994117f8.0.snapshot | 16 +- .../basic_functionality.a58a9361.0.snapshot | 18 +- .../basic_functionality.b07cc734.0.snapshot | 16 +- .../basic_functionality.b6a1b657.0.snapshot | 18 +- .../basic_functionality.b836b89a.0.snapshot | 16 +- .../basic_functionality.c2c74be4.0.snapshot | 18 +- .../basic_functionality.c4090bb1.0.snapshot | 67 ++---- .../basic_functionality.c49928a5.0.snapshot | 18 +- .../basic_functionality.c8095f7c.0.snapshot | 16 +- .../basic_functionality.cb9c6c66.0.snapshot | 16 +- .../basic_functionality.cdeddcd2.0.snapshot | 18 +- .../basic_functionality.cefeb364.0.snapshot | 18 +- .../basic_functionality.d0c0c62b.0.snapshot | 18 +- .../basic_functionality.d0cb4f44.0.snapshot | 16 +- .../basic_functionality.d6ca4146.0.snapshot | 16 +- .../basic_functionality.d8a7dcf9.0.snapshot | 18 +- .../basic_functionality.d9fc01df.0.snapshot | 18 +- .../basic_functionality.e58c3266.0.snapshot | 18 +- .../basic_functionality.ee7c0ebc.0.snapshot | 18 +- .../basic_functionality.f132ca8b.0.snapshot | 16 +- .../basic_functionality.fd64a58f.0.snapshot | 18 +- .../basic_functionality.fe88cb04.0.snapshot | 58 ++--- .../__snapshots__/boxes.08fca3f7.0.snapshot | 17 +- .../__snapshots__/boxes.0c59fc4e.0.snapshot | 17 +- .../__snapshots__/boxes.17668725.0.snapshot | 17 +- .../__snapshots__/boxes.2b56febf.0.snapshot | 17 +- .../__snapshots__/boxes.7d564476.0.snapshot | 17 +- .../__snapshots__/boxes.9035923e.0.snapshot | 17 +- .../__snapshots__/boxes.adbe1660.0.snapshot | 17 +- .../__snapshots__/boxes.bc258c1b.0.snapshot | 17 +- .../__snapshots__/enums.ae26523b.0.snapshot | 42 ++-- .../__snapshots__/exports.a2013f43.0.snapshot | 2 +- .../__snapshots__/exports.de3bf2b8.0.snapshot | 25 +- .../functions.14922a92.0.snapshot | 18 +- .../functions.23afd9c9.0.snapshot | 109 ++++----- .../functions.49ccab54.0.snapshot | 18 +- .../functions.6eacded0.0.snapshot | 118 ++++------ .../functions.8baf471f.0.snapshot | 59 ++--- .../functions.9223245d.0.snapshot | 92 ++++---- .../functions.9fd69835.0.snapshot | 18 +- .../functions.b37949b2.0.snapshot | 59 ++--- .../functions.b3a8d88b.0.snapshot | 92 ++++---- .../functions.e6c6212b.0.snapshot | 16 +- .../functions.f400bb7b.0.snapshot | 109 ++++----- .../__snapshots__/imports.644a1413.0.snapshot | 23 +- .../__snapshots__/let_mut.00e05fe2.0.snapshot | 17 +- .../__snapshots__/let_mut.1176df90.0.snapshot | 17 +- .../__snapshots__/let_mut.43f6980c.0.snapshot | 17 +- .../__snapshots__/let_mut.48249b50.0.snapshot | 17 +- .../__snapshots__/let_mut.4c75261e.0.snapshot | 17 +- .../__snapshots__/let_mut.634331f0.0.snapshot | 17 +- .../__snapshots__/let_mut.6796c72d.0.snapshot | 17 +- .../__snapshots__/let_mut.baaea1d3.0.snapshot | 17 +- .../__snapshots__/let_mut.cbbbaeb4.0.snapshot | 17 +- .../__snapshots__/let_mut.d2de286b.0.snapshot | 17 +- .../__snapshots__/let_mut.e90db621.0.snapshot | 17 +- .../__snapshots__/let_mut.f8f208a2.0.snapshot | 17 +- .../__snapshots__/let_mut.f9e32f30.0.snapshot | 17 +- .../__snapshots__/loops.0a25def1.0.snapshot | 45 ++-- .../__snapshots__/loops.0fafc5f0.0.snapshot | 61 ++--- .../__snapshots__/loops.c2b7bfc6.0.snapshot | 43 ++-- .../__snapshots__/loops.f1c03b79.0.snapshot | 63 ++---- .../optimizations.ff6d5bfb.0.snapshot | 25 +- .../pattern_matching.0539d13e.0.snapshot | 33 ++- .../pattern_matching.0ad4ac05.0.snapshot | 145 +++++------- .../pattern_matching.0bb6923e.0.snapshot | 78 +++---- .../pattern_matching.16eb3dbf.0.snapshot | 29 +-- .../pattern_matching.3722b060.0.snapshot | 97 ++++---- .../pattern_matching.5ff49e44.0.snapshot | 58 ++--- .../pattern_matching.702ed9b0.0.snapshot | 151 +++++------- .../pattern_matching.79346fef.0.snapshot | 142 +++++------- .../pattern_matching.8c0dc67a.0.snapshot | 43 ++-- .../pattern_matching.9561763b.0.snapshot | 214 ++++++++---------- .../pattern_matching.aa8d2963.0.snapshot | 114 +++++----- .../pattern_matching.ac58ffc3.0.snapshot | 29 +-- .../pattern_matching.b1b060ad.0.snapshot | 40 ++-- .../pattern_matching.b9db0dd9.0.snapshot | 114 +++++----- .../pattern_matching.c91eac29.0.snapshot | 74 +++--- .../pattern_matching.d048ece0.0.snapshot | 82 +++---- .../pattern_matching.e41ad64e.0.snapshot | 147 +++++------- .../pattern_matching.eb4334e1.0.snapshot | 74 +++--- .../pattern_matching.f0c08ea4.0.snapshot | 155 ++++++------- .../__snapshots__/records.02742729.0.snapshot | 33 ++- .../__snapshots__/records.54f5977c.0.snapshot | 58 ++--- .../__snapshots__/records.a3299dd2.0.snapshot | 33 ++- .../__snapshots__/records.d393173c.0.snapshot | 58 ++--- .../__snapshots__/stdlib.1c0b04b7.0.snapshot | 17 +- .../__snapshots__/stdlib.24cb9bbf.0.snapshot | 27 +-- .../__snapshots__/stdlib.4a5061c2.0.snapshot | 17 +- .../__snapshots__/stdlib.5fe88631.0.snapshot | 27 +-- .../__snapshots__/stdlib.648f406e.0.snapshot | 27 +-- .../__snapshots__/stdlib.69635cff.0.snapshot | 17 +- .../__snapshots__/stdlib.6bf88430.0.snapshot | 17 +- .../__snapshots__/stdlib.6de47be2.0.snapshot | 17 +- .../__snapshots__/stdlib.8300ad7c.0.snapshot | 14 +- .../__snapshots__/stdlib.91a94037.0.snapshot | 27 +-- .../__snapshots__/stdlib.a70e79ca.0.snapshot | 27 +-- .../__snapshots__/stdlib.b30d7785.0.snapshot | 27 +-- .../__snapshots__/stdlib.cbf0318e.0.snapshot | 17 +- .../__snapshots__/stdlib.d28dee65.0.snapshot | 27 +-- .../__snapshots__/stdlib.d4faa5bf.0.snapshot | 17 +- .../__snapshots__/stdlib.e306600a.0.snapshot | 17 +- .../__snapshots__/stdlib.e6349872.0.snapshot | 27 +-- .../__snapshots__/strings.fb85549f.0.snapshot | 27 +-- 126 files changed, 1839 insertions(+), 2899 deletions(-) diff --git a/compiler/test/__snapshots__/basic_functionality.0996c5f7.0.snapshot b/compiler/test/__snapshots__/basic_functionality.0996c5f7.0.snapshot index c8d6d556a8..533f444e67 100644 --- a/compiler/test/__snapshots__/basic_functionality.0996c5f7.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.0996c5f7.0.snapshot @@ -1,34 +1,28 @@ basic functionality › modulo4 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_%) - ) + (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 -33) (i32.const 35) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.0a230f18.0.snapshot b/compiler/test/__snapshots__/basic_functionality.0a230f18.0.snapshot index 751151d896..fe131748b5 100644 --- a/compiler/test/__snapshots__/basic_functionality.0a230f18.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.0a230f18.0.snapshot @@ -1,34 +1,28 @@ basic functionality › land4 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_&) - ) + (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 1) (i32.const 1) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.0a2e4afa.0.snapshot b/compiler/test/__snapshots__/basic_functionality.0a2e4afa.0.snapshot index 866e5a74b0..271dfe1810 100644 --- a/compiler/test/__snapshots__/basic_functionality.0a2e4afa.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.0a2e4afa.0.snapshot @@ -1,34 +1,28 @@ basic functionality › lxor1 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_^) - ) + (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) (i32.const 3) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.0c0b170b.0.snapshot b/compiler/test/__snapshots__/basic_functionality.0c0b170b.0.snapshot index bf78dbf056..17eb0af089 100644 --- a/compiler/test/__snapshots__/basic_functionality.0c0b170b.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.0c0b170b.0.snapshot @@ -1,34 +1,28 @@ basic functionality › lor1 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_|) - ) + (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) (i32.const 3) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.0c400bde.0.snapshot b/compiler/test/__snapshots__/basic_functionality.0c400bde.0.snapshot index 50ba15f7de..638fbb7759 100644 --- a/compiler/test/__snapshots__/basic_functionality.0c400bde.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.0c400bde.0.snapshot @@ -1,34 +1,28 @@ basic functionality › modulo6 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_%) - ) + (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 35) (i32.const 35) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.1ad0f349.0.snapshot b/compiler/test/__snapshots__/basic_functionality.1ad0f349.0.snapshot index b64030476f..72d025f23d 100644 --- a/compiler/test/__snapshots__/basic_functionality.1ad0f349.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.1ad0f349.0.snapshot @@ -1,11 +1,10 @@ basic functionality › precedence3 (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))) @@ -13,6 +12,8 @@ basic functionality › precedence3 (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)) (export \"_gmain\" (func $_gmain)) @@ -24,18 +25,13 @@ basic functionality › precedence3 (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_%) - ) + (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) (i32.const 13) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -45,21 +41,16 @@ basic functionality › precedence3 ) ) (local.set $1 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $0) ) - (i32.load offset=8 - (local.get $1) - ) ) ) (drop diff --git a/compiler/test/__snapshots__/basic_functionality.1b68c8db.0.snapshot b/compiler/test/__snapshots__/basic_functionality.1b68c8db.0.snapshot index 8141110d7f..fe8ea366af 100644 --- a/compiler/test/__snapshots__/basic_functionality.1b68c8db.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.1b68c8db.0.snapshot @@ -1,34 +1,28 @@ basic functionality › lsl1 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_<<) - ) + (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) (i32.const 3) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.1e4b1f39.0.snapshot b/compiler/test/__snapshots__/basic_functionality.1e4b1f39.0.snapshot index 63397ad8c7..a7e7fdac33 100644 --- a/compiler/test/__snapshots__/basic_functionality.1e4b1f39.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.1e4b1f39.0.snapshot @@ -1,34 +1,28 @@ basic functionality › land1 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_&) - ) + (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) (i32.const 3) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.1f787365.0.snapshot b/compiler/test/__snapshots__/basic_functionality.1f787365.0.snapshot index f51e96b419..7c563b88b2 100644 --- a/compiler/test/__snapshots__/basic_functionality.1f787365.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.1f787365.0.snapshot @@ -4,30 +4,24 @@ basic functionality › orshort2 (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$pervasives\" \"GRAIN$EXPORT$print\" (global $gimport_pervasives_print (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"print\" (func $gimport_pervasives_print (param 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) (drop - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_print) - ) + (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) ) (i32.const 3) - (i32.load offset=8 - (local.get $0) - ) ) ) (i32.const 2147483646) diff --git a/compiler/test/__snapshots__/basic_functionality.28405f1f.0.snapshot b/compiler/test/__snapshots__/basic_functionality.28405f1f.0.snapshot index 6d74563b6b..593881f7eb 100644 --- a/compiler/test/__snapshots__/basic_functionality.28405f1f.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.28405f1f.0.snapshot @@ -1,11 +1,10 @@ basic functionality › precedence4 (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))) @@ -13,6 +12,8 @@ basic functionality › precedence4 (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)) (export \"_gmain\" (func $_gmain)) @@ -24,18 +25,13 @@ basic functionality › precedence4 (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_%) - ) + (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) (i32.const 13) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -45,21 +41,16 @@ basic functionality › precedence4 ) ) (local.set $1 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $0) ) (i32.const 7) - (i32.load offset=8 - (local.get $1) - ) ) ) (drop diff --git a/compiler/test/__snapshots__/basic_functionality.2f2f8795.0.snapshot b/compiler/test/__snapshots__/basic_functionality.2f2f8795.0.snapshot index 1dd51933fc..b522541af8 100644 --- a/compiler/test/__snapshots__/basic_functionality.2f2f8795.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.2f2f8795.0.snapshot @@ -1,34 +1,28 @@ basic functionality › lsl2 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_<<) - ) + (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 1) (i32.const 3) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.32a8c452.0.snapshot b/compiler/test/__snapshots__/basic_functionality.32a8c452.0.snapshot index b9d5bf88a2..9c121dd905 100644 --- a/compiler/test/__snapshots__/basic_functionality.32a8c452.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.32a8c452.0.snapshot @@ -4,29 +4,23 @@ basic functionality › complex2 (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$pervasives\" \"GRAIN$EXPORT$print\" (global $gimport_pervasives_print (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"print\" (func $gimport_pervasives_print (param 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) - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_print) - ) + (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) ) (i32.const 11) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.3e5f990b.0.snapshot b/compiler/test/__snapshots__/basic_functionality.3e5f990b.0.snapshot index 7021e6a8bd..4912397c60 100644 --- a/compiler/test/__snapshots__/basic_functionality.3e5f990b.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.3e5f990b.0.snapshot @@ -1,34 +1,28 @@ basic functionality › lor3 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_|) - ) + (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 1) (i32.const 3) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.3edefd23.0.snapshot b/compiler/test/__snapshots__/basic_functionality.3edefd23.0.snapshot index 2da55a2b05..02e81745b9 100644 --- a/compiler/test/__snapshots__/basic_functionality.3edefd23.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.3edefd23.0.snapshot @@ -4,29 +4,23 @@ basic functionality › decr_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$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$decr\" (global $gimport_pervasives_decr (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"decr\" (func $gimport_pervasives_decr (param 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) - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_decr) - ) + (call $gimport_pervasives_decr + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_decr) ) (i32.const 1) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.52ca8e0e.0.snapshot b/compiler/test/__snapshots__/basic_functionality.52ca8e0e.0.snapshot index 94dac2ffae..eb942acf97 100644 --- a/compiler/test/__snapshots__/basic_functionality.52ca8e0e.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.52ca8e0e.0.snapshot @@ -14,6 +14,7 @@ basic functionality › func_shadow (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\" \"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)) @@ -128,7 +129,7 @@ basic functionality › func_shadow ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $foo_1131 @@ -145,19 +146,14 @@ basic functionality › func_shadow ) ) (drop - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_print) - ) - ) + (call $gimport_pervasives_print (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) + (global.get $gimport_pervasives_print) ) - (i32.load offset=8 - (local.get $0) + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (local.get $1) ) ) ) @@ -212,27 +208,22 @@ basic functionality › func_shadow ) ) ) - (local.set $1 - (call_indirect (type $i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_print) - ) + (local.set $2 + (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 $0) ) - (i32.load offset=8 - (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 $1) ) ) (drop @@ -241,7 +232,7 @@ basic functionality › func_shadow (local.get $0) ) ) - (local.get $1) + (local.get $2) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/basic_functionality.5705b20c.0.snapshot b/compiler/test/__snapshots__/basic_functionality.5705b20c.0.snapshot index 39e4895df1..36f7e9162c 100644 --- a/compiler/test/__snapshots__/basic_functionality.5705b20c.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.5705b20c.0.snapshot @@ -1,34 +1,28 @@ basic functionality › modulo5 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_%) - ) + (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 35) (i32.const -33) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.5d973a3e.0.snapshot b/compiler/test/__snapshots__/basic_functionality.5d973a3e.0.snapshot index 85b235de51..1940998852 100644 --- a/compiler/test/__snapshots__/basic_functionality.5d973a3e.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.5d973a3e.0.snapshot @@ -1,34 +1,28 @@ basic functionality › binop6 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_%) - ) + (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 19) (i32.const 11) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.65d36891.0.snapshot b/compiler/test/__snapshots__/basic_functionality.65d36891.0.snapshot index 0937b4fcd7..c4904c755e 100644 --- a/compiler/test/__snapshots__/basic_functionality.65d36891.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.65d36891.0.snapshot @@ -1,34 +1,28 @@ basic functionality › lor2 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_|) - ) + (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) (i32.const 1) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.68d08483.0.snapshot b/compiler/test/__snapshots__/basic_functionality.68d08483.0.snapshot index 9df2676d0c..15d3305210 100644 --- a/compiler/test/__snapshots__/basic_functionality.68d08483.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.68d08483.0.snapshot @@ -1,34 +1,28 @@ basic functionality › land2 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_&) - ) + (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) (i32.const 1) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.711a4824.0.snapshot b/compiler/test/__snapshots__/basic_functionality.711a4824.0.snapshot index 2628ca98c6..01c5a8fcbe 100644 --- a/compiler/test/__snapshots__/basic_functionality.711a4824.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.711a4824.0.snapshot @@ -14,6 +14,7 @@ basic functionality › pattern_match_unsafe_wasm (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\" \"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) @@ -234,91 +235,56 @@ basic functionality › pattern_match_unsafe_wasm ) ) (br $switch.31_outer - (call_indirect (type $i32_i32_=>_i32) - (local.tee $1 - (global.get $gimport_pervasives_print) - ) + (call $gimport_pervasives_print + (global.get $gimport_pervasives_print) (local.get $0) - (i32.load offset=8 - (local.get $1) - ) ) ) ) ) (br $switch.31_outer - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (global.get $gimport_pervasives_print) - ) + (call $gimport_pervasives_print + (global.get $gimport_pervasives_print) (i32.const 13) - (i32.load offset=8 - (local.get $0) - ) ) ) ) ) (br $switch.31_outer - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (global.get $gimport_pervasives_print) - ) + (call $gimport_pervasives_print + (global.get $gimport_pervasives_print) (i32.const 11) - (i32.load offset=8 - (local.get $0) - ) ) ) ) ) (br $switch.31_outer - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (global.get $gimport_pervasives_print) - ) + (call $gimport_pervasives_print + (global.get $gimport_pervasives_print) (i32.const 9) - (i32.load offset=8 - (local.get $0) - ) ) ) ) ) (br $switch.31_outer - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (global.get $gimport_pervasives_print) - ) + (call $gimport_pervasives_print + (global.get $gimport_pervasives_print) (i32.const 7) - (i32.load offset=8 - (local.get $0) - ) ) ) ) ) (br $switch.31_outer - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (global.get $gimport_pervasives_print) - ) + (call $gimport_pervasives_print + (global.get $gimport_pervasives_print) (i32.const 5) - (i32.load offset=8 - (local.get $0) - ) ) ) ) ) - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (global.get $gimport_pervasives_print) - ) + (call $gimport_pervasives_print + (global.get $gimport_pervasives_print) (i32.const 3) - (i32.load offset=8 - (local.get $0) - ) ) ) ) diff --git a/compiler/test/__snapshots__/basic_functionality.7287219f.0.snapshot b/compiler/test/__snapshots__/basic_functionality.7287219f.0.snapshot index 72f41d119e..1c039ebe73 100644 --- a/compiler/test/__snapshots__/basic_functionality.7287219f.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.7287219f.0.snapshot @@ -1,34 +1,28 @@ basic functionality › asr1 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_>>) - ) + (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 359) (i32.const 3) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.974b7936.0.snapshot b/compiler/test/__snapshots__/basic_functionality.974b7936.0.snapshot index 2c6dace64e..85185ea024 100644 --- a/compiler/test/__snapshots__/basic_functionality.974b7936.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.974b7936.0.snapshot @@ -1,34 +1,28 @@ basic functionality › lxor3 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_^) - ) + (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 1) (i32.const 3) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.994117f8.0.snapshot b/compiler/test/__snapshots__/basic_functionality.994117f8.0.snapshot index 5fb8f30bb0..d2804d371f 100644 --- a/compiler/test/__snapshots__/basic_functionality.994117f8.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.994117f8.0.snapshot @@ -4,29 +4,23 @@ basic functionality › incr_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$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$incr\" (global $gimport_pervasives_incr (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"incr\" (func $gimport_pervasives_incr (param 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) - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_incr) - ) + (call $gimport_pervasives_incr + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_incr) ) (i32.const -1) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.a58a9361.0.snapshot b/compiler/test/__snapshots__/basic_functionality.a58a9361.0.snapshot index 382a5f68cc..64a7233141 100644 --- a/compiler/test/__snapshots__/basic_functionality.a58a9361.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.a58a9361.0.snapshot @@ -1,34 +1,28 @@ basic functionality › lxor2 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_^) - ) + (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) (i32.const 1) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.b07cc734.0.snapshot b/compiler/test/__snapshots__/basic_functionality.b07cc734.0.snapshot index 976432a229..0edc891dbc 100644 --- a/compiler/test/__snapshots__/basic_functionality.b07cc734.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.b07cc734.0.snapshot @@ -4,29 +4,23 @@ basic functionality › if_one_sided (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$pervasives\" \"GRAIN$EXPORT$print\" (global $gimport_pervasives_print (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"print\" (func $gimport_pervasives_print (param 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) - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_print) - ) + (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) ) (i32.const 11) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.b6a1b657.0.snapshot b/compiler/test/__snapshots__/basic_functionality.b6a1b657.0.snapshot index 1002c8547b..cfaddc0490 100644 --- a/compiler/test/__snapshots__/basic_functionality.b6a1b657.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.b6a1b657.0.snapshot @@ -1,34 +1,28 @@ basic functionality › lxor4 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_^) - ) + (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 1) (i32.const 1) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.b836b89a.0.snapshot b/compiler/test/__snapshots__/basic_functionality.b836b89a.0.snapshot index 873384d481..d6b4785916 100644 --- a/compiler/test/__snapshots__/basic_functionality.b836b89a.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.b836b89a.0.snapshot @@ -4,30 +4,24 @@ basic functionality › complex1 (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$pervasives\" \"GRAIN$EXPORT$print\" (global $gimport_pervasives_print (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"print\" (func $gimport_pervasives_print (param 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) (drop - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_print) - ) + (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) ) (i32.const 7) - (i32.load offset=8 - (local.get $0) - ) ) ) (i32.const -5) diff --git a/compiler/test/__snapshots__/basic_functionality.c2c74be4.0.snapshot b/compiler/test/__snapshots__/basic_functionality.c2c74be4.0.snapshot index b57ee1925c..1bbb9d5f09 100644 --- a/compiler/test/__snapshots__/basic_functionality.c2c74be4.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.c2c74be4.0.snapshot @@ -1,34 +1,28 @@ basic functionality › lsr2 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_>>>) - ) + (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 1) (i32.const 3) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.c4090bb1.0.snapshot b/compiler/test/__snapshots__/basic_functionality.c4090bb1.0.snapshot index f3705f8a17..ca39bc510d 100644 --- a/compiler/test/__snapshots__/basic_functionality.c4090bb1.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.c4090bb1.0.snapshot @@ -4,13 +4,13 @@ basic functionality › toplevel_statements (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))) (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$print\" (global $gimport_pervasives_print (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\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"print\" (func $gimport_pervasives_print (param i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) @@ -19,73 +19,48 @@ basic functionality › toplevel_statements (func $_gmain (; has Stack IR ;) (result i32) (local $0 i32) (drop - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_print) - ) + (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) ) (i32.const 3) - (i32.load offset=8 - (local.get $0) - ) ) ) (drop - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_print) - ) + (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) ) (i32.const 5) - (i32.load offset=8 - (local.get $0) - ) ) ) (drop - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_print) - ) + (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) ) (i32.const 7) - (i32.load offset=8 - (local.get $0) - ) ) ) (drop - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_print) - ) + (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) ) (i32.const 9) - (i32.load offset=8 - (local.get $0) - ) ) ) (drop - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_print) - ) + (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) ) (i32.const 11) - (i32.load offset=8 - (local.get $0) - ) ) ) (i32.store diff --git a/compiler/test/__snapshots__/basic_functionality.c49928a5.0.snapshot b/compiler/test/__snapshots__/basic_functionality.c49928a5.0.snapshot index 95b09f27d5..33b858d975 100644 --- a/compiler/test/__snapshots__/basic_functionality.c49928a5.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.c49928a5.0.snapshot @@ -1,34 +1,28 @@ basic functionality › lsr1 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_>>>) - ) + (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) (i32.const 3) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.c8095f7c.0.snapshot b/compiler/test/__snapshots__/basic_functionality.c8095f7c.0.snapshot index f8196fc89f..6ea7a3e13b 100644 --- a/compiler/test/__snapshots__/basic_functionality.c8095f7c.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.c8095f7c.0.snapshot @@ -4,29 +4,23 @@ basic functionality › incr_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$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$incr\" (global $gimport_pervasives_incr (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"incr\" (func $gimport_pervasives_incr (param 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) - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_incr) - ) + (call $gimport_pervasives_incr + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_incr) ) (i32.const 5) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.cb9c6c66.0.snapshot b/compiler/test/__snapshots__/basic_functionality.cb9c6c66.0.snapshot index 78daf13fe7..ab87d1d48f 100644 --- a/compiler/test/__snapshots__/basic_functionality.cb9c6c66.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.cb9c6c66.0.snapshot @@ -4,29 +4,23 @@ basic functionality › incr_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$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$incr\" (global $gimport_pervasives_incr (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"incr\" (func $gimport_pervasives_incr (param 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) - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_incr) - ) + (call $gimport_pervasives_incr + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_incr) ) (i32.const 11) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.cdeddcd2.0.snapshot b/compiler/test/__snapshots__/basic_functionality.cdeddcd2.0.snapshot index 7045d3f776..67211533a8 100644 --- a/compiler/test/__snapshots__/basic_functionality.cdeddcd2.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.cdeddcd2.0.snapshot @@ -1,34 +1,28 @@ basic functionality › modulo3 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_%) - ) + (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 -33) (i32.const -7) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.cefeb364.0.snapshot b/compiler/test/__snapshots__/basic_functionality.cefeb364.0.snapshot index a7191db6e5..28e3f08d22 100644 --- a/compiler/test/__snapshots__/basic_functionality.cefeb364.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.cefeb364.0.snapshot @@ -1,34 +1,28 @@ basic functionality › lor4 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_|) - ) + (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 1) (i32.const 1) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.d0c0c62b.0.snapshot b/compiler/test/__snapshots__/basic_functionality.d0c0c62b.0.snapshot index 36954cd97f..004abd0abd 100644 --- a/compiler/test/__snapshots__/basic_functionality.d0c0c62b.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.d0c0c62b.0.snapshot @@ -1,34 +1,28 @@ basic functionality › int64_pun_1 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_*) - ) + (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 19999999) (i32.const 199999999) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.d0cb4f44.0.snapshot b/compiler/test/__snapshots__/basic_functionality.d0cb4f44.0.snapshot index a371943a24..af30a8ed78 100644 --- a/compiler/test/__snapshots__/basic_functionality.d0cb4f44.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.d0cb4f44.0.snapshot @@ -4,29 +4,23 @@ basic functionality › decr_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$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$decr\" (global $gimport_pervasives_decr (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"decr\" (func $gimport_pervasives_decr (param 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) - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_decr) - ) + (call $gimport_pervasives_decr + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_decr) ) (i32.const 5) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.d6ca4146.0.snapshot b/compiler/test/__snapshots__/basic_functionality.d6ca4146.0.snapshot index c784a27da7..3d83e0a23e 100644 --- a/compiler/test/__snapshots__/basic_functionality.d6ca4146.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.d6ca4146.0.snapshot @@ -4,30 +4,24 @@ basic functionality › andshort1 (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$pervasives\" \"GRAIN$EXPORT$print\" (global $gimport_pervasives_print (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"print\" (func $gimport_pervasives_print (param 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) (drop - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_print) - ) + (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) ) (i32.const 3) - (i32.load offset=8 - (local.get $0) - ) ) ) (i32.const 2147483646) diff --git a/compiler/test/__snapshots__/basic_functionality.d8a7dcf9.0.snapshot b/compiler/test/__snapshots__/basic_functionality.d8a7dcf9.0.snapshot index 02812b142b..5e314c9fd3 100644 --- a/compiler/test/__snapshots__/basic_functionality.d8a7dcf9.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.d8a7dcf9.0.snapshot @@ -1,34 +1,28 @@ basic functionality › modulo1 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_%) - ) + (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 -33) (i32.const 9) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.d9fc01df.0.snapshot b/compiler/test/__snapshots__/basic_functionality.d9fc01df.0.snapshot index 5b3dbcf73f..ed542b0c90 100644 --- a/compiler/test/__snapshots__/basic_functionality.d9fc01df.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.d9fc01df.0.snapshot @@ -1,34 +1,28 @@ basic functionality › land3 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_&) - ) + (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 1) (i32.const 3) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.e58c3266.0.snapshot b/compiler/test/__snapshots__/basic_functionality.e58c3266.0.snapshot index 6d22e3a480..302a5e3949 100644 --- a/compiler/test/__snapshots__/basic_functionality.e58c3266.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.e58c3266.0.snapshot @@ -1,34 +1,28 @@ basic functionality › asr2 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_>>) - ) + (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 1) (i32.const 3) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.ee7c0ebc.0.snapshot b/compiler/test/__snapshots__/basic_functionality.ee7c0ebc.0.snapshot index d441903d3f..82f700d1b7 100644 --- a/compiler/test/__snapshots__/basic_functionality.ee7c0ebc.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.ee7c0ebc.0.snapshot @@ -1,34 +1,28 @@ basic functionality › modulo2 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_%) - ) + (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 35) (i32.const -7) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.f132ca8b.0.snapshot b/compiler/test/__snapshots__/basic_functionality.f132ca8b.0.snapshot index 777be6ff9a..667e599ff6 100644 --- a/compiler/test/__snapshots__/basic_functionality.f132ca8b.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.f132ca8b.0.snapshot @@ -4,29 +4,23 @@ basic functionality › decr_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$incRef\" (global $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef (mut i32))) (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$decr\" (global $gimport_pervasives_decr (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $wimport_GRAIN$MODULE$runtime/gc_incRef (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"decr\" (func $gimport_pervasives_decr (param 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) - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_decr) - ) + (call $gimport_pervasives_decr + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (global.get $gimport_pervasives_decr) ) (i32.const 11) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.fd64a58f.0.snapshot b/compiler/test/__snapshots__/basic_functionality.fd64a58f.0.snapshot index c99d6651eb..8cff1d294c 100644 --- a/compiler/test/__snapshots__/basic_functionality.fd64a58f.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.fd64a58f.0.snapshot @@ -1,34 +1,28 @@ basic functionality › int64_pun_2 (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$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$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)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_1)) (func $_gmain (; has Stack IR ;) (result i32) - (local $0 i32) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_-) - ) + (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 -199999997) (i32.const 1999999999) - (i32.load offset=8 - (local.get $0) - ) ) ) (func $_start (; has Stack IR ;) diff --git a/compiler/test/__snapshots__/basic_functionality.fe88cb04.0.snapshot b/compiler/test/__snapshots__/basic_functionality.fe88cb04.0.snapshot index 6a2d929478..257d817246 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_=>_i32 (func (param i32 i32) (result i32))) (type $i32_=>_i32 (func (param i32) (result i32))) + (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_none (func)) (import \"_grainEnv\" \"mem\" (memory $0 0)) @@ -14,6 +14,7 @@ basic functionality › func_shadow_and_indirect_call (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\" \"print\" (func $gimport_pervasives_print (param i32 i32) (result i32))) (global $global_3 (mut i32) (i32.const 0)) (global $global_2 (mut i32) (i32.const 0)) (global $global_1 (mut i32) (i32.const 0)) @@ -208,7 +209,7 @@ basic functionality › func_shadow_and_indirect_call ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $foo_1131 @@ -225,19 +226,14 @@ basic functionality › func_shadow_and_indirect_call ) ) (drop - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_print) - ) - ) + (call $gimport_pervasives_print (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) + (global.get $gimport_pervasives_print) ) - (i32.load offset=8 - (local.get $0) + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (local.get $1) ) ) ) @@ -276,7 +272,7 @@ basic functionality › func_shadow_and_indirect_call ) ) ) - (local.set $3 + (local.set $2 (tuple.extract 0 (tuple.make (call $foo_1133 @@ -293,19 +289,14 @@ basic functionality › func_shadow_and_indirect_call ) ) (drop - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_print) - ) - ) + (call $gimport_pervasives_print (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $3) + (global.get $gimport_pervasives_print) ) - (i32.load offset=8 - (local.get $0) + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (local.get $2) ) ) ) @@ -381,33 +372,28 @@ basic functionality › func_shadow_and_indirect_call ) ) ) - (local.set $1 - (call_indirect (type $i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_print) - ) + (local.set $3 + (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 $0) ) - (i32.load offset=8 - (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 $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 @@ -416,7 +402,7 @@ basic functionality › func_shadow_and_indirect_call (local.get $0) ) ) - (local.get $1) + (local.get $3) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/boxes.08fca3f7.0.snapshot b/compiler/test/__snapshots__/boxes.08fca3f7.0.snapshot index 25a63a7549..7a41459955 100644 --- a/compiler/test/__snapshots__/boxes.08fca3f7.0.snapshot +++ b/compiler/test/__snapshots__/boxes.08fca3f7.0.snapshot @@ -2,10 +2,9 @@ boxes › box_subtraction1 (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$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,6 +13,7 @@ boxes › box_subtraction1 (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_0 (mut i32) (i32.const 0)) (global $global_2 i32 (i32.const 0)) (export \"memory\" (memory $0)) @@ -71,21 +71,16 @@ boxes › box_subtraction1 (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_-) - ) + (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 $0) ) (i32.const 39) - (i32.load offset=8 - (local.get $1) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) diff --git a/compiler/test/__snapshots__/boxes.0c59fc4e.0.snapshot b/compiler/test/__snapshots__/boxes.0c59fc4e.0.snapshot index 941a6e4390..475c5c9e01 100644 --- a/compiler/test/__snapshots__/boxes.0c59fc4e.0.snapshot +++ b/compiler/test/__snapshots__/boxes.0c59fc4e.0.snapshot @@ -2,10 +2,9 @@ boxes › box_multiplication2 (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$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,6 +13,7 @@ boxes › box_multiplication2 (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_0 (mut i32) (i32.const 0)) (global $global_2 i32 (i32.const 0)) (export \"memory\" (memory $0)) @@ -71,21 +71,16 @@ boxes › box_multiplication2 (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_*) - ) + (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 $0) ) (i32.const 39) - (i32.load offset=8 - (local.get $1) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) diff --git a/compiler/test/__snapshots__/boxes.17668725.0.snapshot b/compiler/test/__snapshots__/boxes.17668725.0.snapshot index fc5d0a2ed7..9fbb173701 100644 --- a/compiler/test/__snapshots__/boxes.17668725.0.snapshot +++ b/compiler/test/__snapshots__/boxes.17668725.0.snapshot @@ -2,10 +2,9 @@ boxes › box_division2 (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$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,6 +13,7 @@ boxes › box_division2 (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_0 (mut i32) (i32.const 0)) (global $global_2 i32 (i32.const 0)) (export \"memory\" (memory $0)) @@ -71,21 +71,16 @@ boxes › box_division2 (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_/) - ) + (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 $0) ) (i32.const 39) - (i32.load offset=8 - (local.get $1) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) diff --git a/compiler/test/__snapshots__/boxes.2b56febf.0.snapshot b/compiler/test/__snapshots__/boxes.2b56febf.0.snapshot index 417e574a49..f922419494 100644 --- a/compiler/test/__snapshots__/boxes.2b56febf.0.snapshot +++ b/compiler/test/__snapshots__/boxes.2b56febf.0.snapshot @@ -2,10 +2,9 @@ boxes › box_addition2 (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$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,6 +13,7 @@ boxes › box_addition2 (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_0 (mut i32) (i32.const 0)) (global $global_2 i32 (i32.const 0)) (export \"memory\" (memory $0)) @@ -71,21 +71,16 @@ boxes › box_addition2 (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $0) ) (i32.const 39) - (i32.load offset=8 - (local.get $1) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) diff --git a/compiler/test/__snapshots__/boxes.7d564476.0.snapshot b/compiler/test/__snapshots__/boxes.7d564476.0.snapshot index beb5158c38..419314a024 100644 --- a/compiler/test/__snapshots__/boxes.7d564476.0.snapshot +++ b/compiler/test/__snapshots__/boxes.7d564476.0.snapshot @@ -2,10 +2,9 @@ boxes › box_division1 (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$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,6 +13,7 @@ boxes › box_division1 (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_0 (mut i32) (i32.const 0)) (global $global_2 i32 (i32.const 0)) (export \"memory\" (memory $0)) @@ -71,21 +71,16 @@ boxes › box_division1 (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_/) - ) + (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 $0) ) (i32.const 39) - (i32.load offset=8 - (local.get $1) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) diff --git a/compiler/test/__snapshots__/boxes.9035923e.0.snapshot b/compiler/test/__snapshots__/boxes.9035923e.0.snapshot index 56756ac712..b5a623d3d8 100644 --- a/compiler/test/__snapshots__/boxes.9035923e.0.snapshot +++ b/compiler/test/__snapshots__/boxes.9035923e.0.snapshot @@ -2,10 +2,9 @@ boxes › box_subtraction2 (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$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,6 +13,7 @@ boxes › box_subtraction2 (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_0 (mut i32) (i32.const 0)) (global $global_2 i32 (i32.const 0)) (export \"memory\" (memory $0)) @@ -71,21 +71,16 @@ boxes › box_subtraction2 (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_-) - ) + (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 $0) ) (i32.const 39) - (i32.load offset=8 - (local.get $1) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) diff --git a/compiler/test/__snapshots__/boxes.adbe1660.0.snapshot b/compiler/test/__snapshots__/boxes.adbe1660.0.snapshot index bb6e37d4cc..8c809900f5 100644 --- a/compiler/test/__snapshots__/boxes.adbe1660.0.snapshot +++ b/compiler/test/__snapshots__/boxes.adbe1660.0.snapshot @@ -2,10 +2,9 @@ boxes › box_addition1 (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$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,6 +13,7 @@ boxes › box_addition1 (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_0 (mut i32) (i32.const 0)) (global $global_2 i32 (i32.const 0)) (export \"memory\" (memory $0)) @@ -71,21 +71,16 @@ boxes › box_addition1 (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $0) ) (i32.const 39) - (i32.load offset=8 - (local.get $1) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) diff --git a/compiler/test/__snapshots__/boxes.bc258c1b.0.snapshot b/compiler/test/__snapshots__/boxes.bc258c1b.0.snapshot index b70420c1ff..16896ab4b7 100644 --- a/compiler/test/__snapshots__/boxes.bc258c1b.0.snapshot +++ b/compiler/test/__snapshots__/boxes.bc258c1b.0.snapshot @@ -2,10 +2,9 @@ boxes › box_multiplication1 (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$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,6 +13,7 @@ boxes › box_multiplication1 (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_0 (mut i32) (i32.const 0)) (global $global_2 i32 (i32.const 0)) (export \"memory\" (memory $0)) @@ -71,21 +71,16 @@ boxes › box_multiplication1 (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_*) - ) + (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 $0) ) (i32.const 39) - (i32.load offset=8 - (local.get $1) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) diff --git a/compiler/test/__snapshots__/enums.ae26523b.0.snapshot b/compiler/test/__snapshots__/enums.ae26523b.0.snapshot index 35a010e49b..edb9f018a3 100644 --- a/compiler/test/__snapshots__/enums.ae26523b.0.snapshot +++ b/compiler/test/__snapshots__/enums.ae26523b.0.snapshot @@ -15,6 +15,7 @@ enums › enum_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\" \"print\" (func $gimport_pervasives_print (param i32 i32) (result i32))) (global $global_3 (mut i32) (i32.const 0)) (global $global_0 (mut i32) (i32.const 0)) (global $global_4 (mut i32) (i32.const 0)) @@ -428,7 +429,7 @@ enums › enum_recursive_data_definition (local.get $0) (i64.const 54015209861748) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (local.get $0) @@ -467,7 +468,7 @@ enums › enum_recursive_data_definition ) ) ) - (local.set $3 + (local.set $2 (tuple.extract 0 (tuple.make (call $Node_1134 @@ -491,7 +492,7 @@ enums › enum_recursive_data_definition ) ) ) - (local.set $4 + (local.set $3 (tuple.extract 0 (tuple.make (call $Cons_1136 @@ -501,7 +502,7 @@ enums › enum_recursive_data_definition ) (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) @@ -515,7 +516,7 @@ enums › enum_recursive_data_definition ) ) ) - (local.set $5 + (local.set $4 (tuple.extract 0 (tuple.make (call $Node_1134 @@ -525,11 +526,11 @@ enums › enum_recursive_data_definition ) (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) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -549,7 +550,7 @@ enums › enum_recursive_data_definition ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $5) + (local.get $4) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) @@ -563,27 +564,22 @@ enums › enum_recursive_data_definition ) ) ) - (local.set $1 - (call_indirect (type $i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_print) - ) + (local.set $5 + (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) (global.get $global_4) ) - (i32.load offset=8 - (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 $1) ) ) (drop @@ -595,22 +591,22 @@ enums › enum_recursive_data_definition (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) ) ) - (local.get $1) + (local.get $5) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/exports.a2013f43.0.snapshot b/compiler/test/__snapshots__/exports.a2013f43.0.snapshot index e9028c5623..fa9bd955b5 100644 --- a/compiler/test/__snapshots__/exports.a2013f43.0.snapshot +++ b/compiler/test/__snapshots__/exports.a2013f43.0.snapshot @@ -15,8 +15,8 @@ exports › let_rec_export (global $global_2 i32 (i32.const 1)) (elem $elem (global.get $wimport__grainEnv_relocBase) $foo_1131) (export \"memory\" (memory $0)) - (export \"GRAIN$EXPORT$foo\" (global $global_0)) (export \"foo\" (func $foo_1131)) + (export \"GRAIN$EXPORT$foo\" (global $global_0)) (export \"_gmain\" (func $_gmain)) (export \"_start\" (func $_start)) (export \"GRAIN$TABLE_SIZE\" (global $global_2)) diff --git a/compiler/test/__snapshots__/exports.de3bf2b8.0.snapshot b/compiler/test/__snapshots__/exports.de3bf2b8.0.snapshot index db4850b4ad..e01a0b5ebf 100644 --- a/compiler/test/__snapshots__/exports.de3bf2b8.0.snapshot +++ b/compiler/test/__snapshots__/exports.de3bf2b8.0.snapshot @@ -2,10 +2,9 @@ exports › export8 (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))) @@ -15,6 +14,7 @@ exports › export8 (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$exportStar\" \"y\" (func $gimport_exportStar_y (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)) @@ -23,7 +23,7 @@ exports › export8 (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 $gimport_exportStar_y @@ -40,13 +40,11 @@ exports › export8 ) ) ) - (local.set $0 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (local.set $1 + (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) @@ -54,9 +52,6 @@ exports › export8 ) (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) ) ) @@ -64,10 +59,10 @@ exports › export8 (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__/functions.14922a92.0.snapshot b/compiler/test/__snapshots__/functions.14922a92.0.snapshot index 3dbbd7074c..c4431c786e 100644 --- a/compiler/test/__snapshots__/functions.14922a92.0.snapshot +++ b/compiler/test/__snapshots__/functions.14922a92.0.snapshot @@ -1,9 +1,9 @@ functions › shorthand_4 (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)) @@ -14,6 +14,7 @@ functions › shorthand_4 (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_0 (mut i32) (i32.const 0)) (global $global_2 i32 (i32.const 1)) (elem $elem (global.get $wimport__grainEnv_relocBase) $foo_1131) @@ -26,23 +27,18 @@ functions › shorthand_4 (local.set $2 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $2 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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.load offset=8 - (local.get $2) - ) ) - (local.get $2) + (i32.const 0) ) ) ) diff --git a/compiler/test/__snapshots__/functions.23afd9c9.0.snapshot b/compiler/test/__snapshots__/functions.23afd9c9.0.snapshot index a9ea2f4805..c284862190 100644 --- a/compiler/test/__snapshots__/functions.23afd9c9.0.snapshot +++ b/compiler/test/__snapshots__/functions.23afd9c9.0.snapshot @@ -1,7 +1,7 @@ functions › lam_destructure_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)) @@ -14,6 +14,7 @@ functions › lam_destructure_5 (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 1)) (elem $elem (global.get $wimport__grainEnv_relocBase) $lam_lambda_1136) (export \"memory\" (memory $0)) @@ -68,7 +69,7 @@ functions › lam_destructure_5 ) ) ) - (local.set $12 + (local.set $8 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -84,7 +85,7 @@ functions › lam_destructure_5 ) ) ) - (local.set $13 + (local.set $9 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -100,7 +101,7 @@ functions › lam_destructure_5 ) ) ) - (local.set $14 + (local.set $10 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -125,7 +126,7 @@ functions › lam_destructure_5 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $14) + (local.get $10) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -147,7 +148,7 @@ functions › lam_destructure_5 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $13) + (local.get $9) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -169,7 +170,7 @@ functions › lam_destructure_5 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $12) + (local.get $8) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -204,7 +205,7 @@ functions › lam_destructure_5 ) ) ) - (local.set $15 + (local.set $11 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -220,7 +221,7 @@ functions › lam_destructure_5 ) ) ) - (local.set $16 + (local.set $12 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -245,7 +246,7 @@ functions › lam_destructure_5 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $16) + (local.get $12) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -267,7 +268,7 @@ functions › lam_destructure_5 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $15) + (local.get $11) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -280,15 +281,13 @@ functions › lam_destructure_5 ) ) ) - (local.set $8 + (local.set $13 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $8 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -298,9 +297,6 @@ functions › lam_destructure_5 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $4) ) - (i32.load offset=8 - (local.get $8) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -309,27 +305,22 @@ functions › lam_destructure_5 ) ) ) - (local.set $9 + (local.set $14 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $9 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $8) + (local.get $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 $9) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -338,27 +329,22 @@ functions › lam_destructure_5 ) ) ) - (local.set $10 + (local.set $15 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $10 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $9) + (local.get $14) ) (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 $10) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -367,29 +353,24 @@ functions › lam_destructure_5 ) ) ) - (local.set $11 + (local.set $16 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $11 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $10) + (local.get $15) ) (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 $11) - ) ) - (local.get $11) + (i32.const 0) ) ) ) @@ -432,19 +413,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 $12) + (local.get $8) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $13) + (local.get $9) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $14) + (local.get $10) ) ) (drop @@ -462,34 +443,34 @@ functions › lam_destructure_5 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $15) + (local.get $11) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $16) + (local.get $12) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $8) + (local.get $13) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $9) + (local.get $14) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $10) + (local.get $15) ) ) - (local.get $11) + (local.get $16) ) (func $_gmain (; has Stack IR ;) (result i32) (local $0 i32) diff --git a/compiler/test/__snapshots__/functions.49ccab54.0.snapshot b/compiler/test/__snapshots__/functions.49ccab54.0.snapshot index 57cfdbc3ce..1cfb1a2f5f 100644 --- a/compiler/test/__snapshots__/functions.49ccab54.0.snapshot +++ b/compiler/test/__snapshots__/functions.49ccab54.0.snapshot @@ -1,9 +1,9 @@ functions › curried_func (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)) @@ -14,6 +14,7 @@ functions › curried_func (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_0 (mut i32) (i32.const 0)) (global $global_2 i32 (i32.const 2)) (elem $elem (global.get $wimport__grainEnv_relocBase) $add_1131 $func_1141) @@ -81,12 +82,10 @@ functions › curried_func (local.set $2 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $2 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -98,11 +97,8 @@ functions › curried_func (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $1) ) - (i32.load offset=8 - (local.get $2) - ) ) - (local.get $2) + (i32.const 0) ) ) ) diff --git a/compiler/test/__snapshots__/functions.6eacded0.0.snapshot b/compiler/test/__snapshots__/functions.6eacded0.0.snapshot index f7c1f3a6cc..846c63ddb2 100644 --- a/compiler/test/__snapshots__/functions.6eacded0.0.snapshot +++ b/compiler/test/__snapshots__/functions.6eacded0.0.snapshot @@ -17,13 +17,16 @@ functions › func_recursive_closure (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\" \"==\" (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 (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) (export \"memory\" (memory $0)) - (export \"GRAIN$EXPORT$truc\" (global $global_1)) (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)) @@ -153,12 +156,10 @@ functions › func_recursive_closure (local.set $2 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $2 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -170,11 +171,8 @@ functions › func_recursive_closure (local.get $0) ) ) - (i32.load offset=8 - (local.get $2) - ) ) - (local.get $2) + (i32.const 0) ) ) ) @@ -240,14 +238,12 @@ functions › func_recursive_closure ) (i32.store offset=16 (local.tee $2 - (local.tee $4 - (tuple.extract 0 - (tuple.make - (local.get $2) - (call $wimport_GRAIN$MODULE$runtime/gc_decRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (i32.const 0) - ) + (tuple.extract 0 + (tuple.make + (local.get $2) + (call $wimport_GRAIN$MODULE$runtime/gc_decRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) + (i32.const 0) ) ) ) @@ -264,76 +260,61 @@ functions › func_recursive_closure (local.get $3) ) ) - (local.set $2 + (local.set $5 (tuple.extract 0 (tuple.make (if (result i32) (i32.shr_u - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $2 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) + (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 1) - (i32.load offset=8 - (local.get $2) - ) ) (i32.const 31) ) (i32.const 1) (if (result i32) (i32.shr_u - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $2 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) + (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 3) - (i32.load offset=8 - (local.get $2) - ) ) (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) + (local.get $2) ) (i32.const 3) ) (block (result i32) - (local.set $5 + (local.set $4 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $2 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_-) - ) + (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 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) @@ -349,7 +330,7 @@ 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 $4) ) ) ) @@ -380,22 +361,22 @@ functions › func_recursive_closure (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (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 $5) + (local.get $4) ) ) - (local.get $2) + (local.get $5) ) (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 $4 + (local.set $3 (tuple.extract 0 (tuple.make (call $foo_1135 @@ -414,7 +395,7 @@ functions › func_recursive_closure ) ) ) - (local.set $2 + (local.set $4 (tuple.extract 0 (tuple.make (call_indirect (type $i32_i32_=>_i32) @@ -438,29 +419,24 @@ functions › func_recursive_closure ) ) ) - (local.set $3 + (local.set $2 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $3 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) - ) + (call $gimport_pervasives_+ (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $4) + (global.get $gimport_pervasives_+) ) (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 $3) ) + (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 $2) ) ) ) @@ -479,16 +455,16 @@ functions › func_recursive_closure (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 $2) + (local.get $4) ) ) - (local.get $3) + (local.get $2) ) (func $_gmain (; has Stack IR ;) (result i32) (local $0 i32) diff --git a/compiler/test/__snapshots__/functions.8baf471f.0.snapshot b/compiler/test/__snapshots__/functions.8baf471f.0.snapshot index fb4fcd5036..7381537d7c 100644 --- a/compiler/test/__snapshots__/functions.8baf471f.0.snapshot +++ b/compiler/test/__snapshots__/functions.8baf471f.0.snapshot @@ -1,9 +1,9 @@ functions › lam_destructure_3 (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)) @@ -14,6 +14,7 @@ functions › lam_destructure_3 (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 1)) (elem $elem (global.get $wimport__grainEnv_relocBase) $lam_lambda_1134) (export \"memory\" (memory $0)) @@ -62,7 +63,7 @@ functions › lam_destructure_3 ) ) ) - (local.set $7 + (local.set $5 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -78,7 +79,7 @@ functions › lam_destructure_3 ) ) ) - (local.set $8 + (local.set $6 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -94,7 +95,7 @@ functions › lam_destructure_3 ) ) ) - (local.set $9 + (local.set $7 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -119,7 +120,7 @@ functions › lam_destructure_3 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $9) + (local.get $7) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -141,7 +142,7 @@ functions › lam_destructure_3 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $8) + (local.get $6) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -163,7 +164,7 @@ functions › lam_destructure_3 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $7) + (local.get $5) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -176,15 +177,13 @@ functions › lam_destructure_3 ) ) ) - (local.set $5 + (local.set $8 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $5 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -194,9 +193,6 @@ functions › lam_destructure_3 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $3) ) - (i32.load offset=8 - (local.get $5) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -205,29 +201,24 @@ functions › lam_destructure_3 ) ) ) - (local.set $6 + (local.set $9 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $6 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $5) + (local.get $8) ) (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 $6) - ) ) - (local.get $6) + (i32.const 0) ) ) ) @@ -264,28 +255,28 @@ functions › lam_destructure_3 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $7) + (local.get $5) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $8) + (local.get $6) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $9) + (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) ) ) - (local.get $6) + (local.get $9) ) (func $_gmain (; has Stack IR ;) (result i32) (local $0 i32) diff --git a/compiler/test/__snapshots__/functions.9223245d.0.snapshot b/compiler/test/__snapshots__/functions.9223245d.0.snapshot index 446dc2245f..ce2d6f7018 100644 --- a/compiler/test/__snapshots__/functions.9223245d.0.snapshot +++ b/compiler/test/__snapshots__/functions.9223245d.0.snapshot @@ -1,9 +1,9 @@ functions › lam_destructure_7 (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)) @@ -14,6 +14,7 @@ functions › lam_destructure_7 (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 1)) (elem $elem (global.get $wimport__grainEnv_relocBase) $lam_lambda_1135) (export \"memory\" (memory $0)) @@ -77,7 +78,7 @@ functions › lam_destructure_7 ) ) ) - (local.set $10 + (local.set $7 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -93,7 +94,7 @@ functions › lam_destructure_7 ) ) ) - (local.set $11 + (local.set $8 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -109,7 +110,7 @@ functions › lam_destructure_7 ) ) ) - (local.set $9 + (local.set $6 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -125,13 +126,13 @@ functions › lam_destructure_7 ) ) ) - (local.set $12 + (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=8 - (local.get $9) + (local.get $6) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -141,13 +142,13 @@ functions › lam_destructure_7 ) ) ) - (local.set $13 + (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=12 - (local.get $9) + (local.get $6) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -166,7 +167,7 @@ functions › lam_destructure_7 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $10) + (local.get $7) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -188,7 +189,7 @@ functions › lam_destructure_7 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $11) + (local.get $8) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -210,7 +211,7 @@ functions › lam_destructure_7 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $13) + (local.get $10) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -232,7 +233,7 @@ functions › lam_destructure_7 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $12) + (local.get $9) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -245,15 +246,13 @@ functions › lam_destructure_7 ) ) ) - (local.set $6 + (local.set $11 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $6 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -263,9 +262,6 @@ functions › lam_destructure_7 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $3) ) - (i32.load offset=8 - (local.get $6) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -274,27 +270,22 @@ functions › lam_destructure_7 ) ) ) - (local.set $7 + (local.set $12 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $7 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $6) + (local.get $11) ) (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 $7) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -303,29 +294,24 @@ functions › lam_destructure_7 ) ) ) - (local.set $8 + (local.set $13 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $8 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) + (local.get $12) ) (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 $8) - ) ) - (local.get $8) + (i32.const 0) ) ) ) @@ -368,46 +354,46 @@ functions › lam_destructure_7 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $10) + (local.get $7) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $11) + (local.get $8) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $9) + (local.get $6) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $12) + (local.get $9) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $13) + (local.get $10) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $6) + (local.get $11) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $7) + (local.get $12) ) ) - (local.get $8) + (local.get $13) ) (func $_gmain (; has Stack IR ;) (result i32) (local $0 i32) diff --git a/compiler/test/__snapshots__/functions.9fd69835.0.snapshot b/compiler/test/__snapshots__/functions.9fd69835.0.snapshot index fed82139d8..6973e2245d 100644 --- a/compiler/test/__snapshots__/functions.9fd69835.0.snapshot +++ b/compiler/test/__snapshots__/functions.9fd69835.0.snapshot @@ -1,9 +1,9 @@ functions › shorthand_2 (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)) @@ -14,6 +14,7 @@ functions › shorthand_2 (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_0 (mut i32) (i32.const 0)) (global $global_2 i32 (i32.const 1)) (elem $elem (global.get $wimport__grainEnv_relocBase) $foo_1131) @@ -26,23 +27,18 @@ functions › shorthand_2 (local.set $2 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $2 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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.load offset=8 - (local.get $2) - ) ) - (local.get $2) + (i32.const 0) ) ) ) diff --git a/compiler/test/__snapshots__/functions.b37949b2.0.snapshot b/compiler/test/__snapshots__/functions.b37949b2.0.snapshot index 68d4cbe97c..c6441415a4 100644 --- a/compiler/test/__snapshots__/functions.b37949b2.0.snapshot +++ b/compiler/test/__snapshots__/functions.b37949b2.0.snapshot @@ -1,9 +1,9 @@ functions › lam_destructure_4 (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)) @@ -14,6 +14,7 @@ functions › lam_destructure_4 (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_0 (mut i32) (i32.const 0)) (global $global_2 i32 (i32.const 1)) (elem $elem (global.get $wimport__grainEnv_relocBase) $foo_1131) @@ -63,7 +64,7 @@ functions › lam_destructure_4 ) ) ) - (local.set $7 + (local.set $5 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -79,7 +80,7 @@ functions › lam_destructure_4 ) ) ) - (local.set $8 + (local.set $6 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -95,7 +96,7 @@ functions › lam_destructure_4 ) ) ) - (local.set $9 + (local.set $7 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -120,7 +121,7 @@ functions › lam_destructure_4 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $9) + (local.get $7) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -142,7 +143,7 @@ functions › lam_destructure_4 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $8) + (local.get $6) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -164,7 +165,7 @@ functions › lam_destructure_4 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $7) + (local.get $5) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -177,15 +178,13 @@ functions › lam_destructure_4 ) ) ) - (local.set $5 + (local.set $8 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $5 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -195,9 +194,6 @@ functions › lam_destructure_4 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $3) ) - (i32.load offset=8 - (local.get $5) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -206,29 +202,24 @@ functions › lam_destructure_4 ) ) ) - (local.set $6 + (local.set $9 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $6 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $5) + (local.get $8) ) (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 $6) - ) ) - (local.get $6) + (i32.const 0) ) ) ) @@ -265,28 +256,28 @@ functions › lam_destructure_4 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $7) + (local.get $5) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $8) + (local.get $6) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $9) + (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) ) ) - (local.get $6) + (local.get $9) ) (func $_gmain (; has Stack IR ;) (result i32) (local $0 i32) diff --git a/compiler/test/__snapshots__/functions.b3a8d88b.0.snapshot b/compiler/test/__snapshots__/functions.b3a8d88b.0.snapshot index bdfe41953b..08d19e6cc1 100644 --- a/compiler/test/__snapshots__/functions.b3a8d88b.0.snapshot +++ b/compiler/test/__snapshots__/functions.b3a8d88b.0.snapshot @@ -1,9 +1,9 @@ functions › lam_destructure_8 (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)) @@ -14,6 +14,7 @@ functions › lam_destructure_8 (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_0 (mut i32) (i32.const 0)) (global $global_2 i32 (i32.const 1)) (elem $elem (global.get $wimport__grainEnv_relocBase) $foo_1131) @@ -78,7 +79,7 @@ functions › lam_destructure_8 ) ) ) - (local.set $10 + (local.set $7 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -94,7 +95,7 @@ functions › lam_destructure_8 ) ) ) - (local.set $11 + (local.set $8 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -110,7 +111,7 @@ functions › lam_destructure_8 ) ) ) - (local.set $9 + (local.set $6 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -126,13 +127,13 @@ functions › lam_destructure_8 ) ) ) - (local.set $12 + (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=8 - (local.get $9) + (local.get $6) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -142,13 +143,13 @@ functions › lam_destructure_8 ) ) ) - (local.set $13 + (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=12 - (local.get $9) + (local.get $6) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -167,7 +168,7 @@ functions › lam_destructure_8 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $10) + (local.get $7) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -189,7 +190,7 @@ functions › lam_destructure_8 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $11) + (local.get $8) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -211,7 +212,7 @@ functions › lam_destructure_8 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $13) + (local.get $10) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -233,7 +234,7 @@ functions › lam_destructure_8 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $12) + (local.get $9) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -246,15 +247,13 @@ functions › lam_destructure_8 ) ) ) - (local.set $6 + (local.set $11 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $6 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -264,9 +263,6 @@ functions › lam_destructure_8 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $3) ) - (i32.load offset=8 - (local.get $6) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -275,27 +271,22 @@ functions › lam_destructure_8 ) ) ) - (local.set $7 + (local.set $12 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $7 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $6) + (local.get $11) ) (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 $7) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -304,29 +295,24 @@ functions › lam_destructure_8 ) ) ) - (local.set $8 + (local.set $13 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $8 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) + (local.get $12) ) (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 $8) - ) ) - (local.get $8) + (i32.const 0) ) ) ) @@ -369,46 +355,46 @@ functions › lam_destructure_8 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $10) + (local.get $7) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $11) + (local.get $8) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $9) + (local.get $6) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $12) + (local.get $9) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $13) + (local.get $10) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $6) + (local.get $11) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $7) + (local.get $12) ) ) - (local.get $8) + (local.get $13) ) (func $_gmain (; has Stack IR ;) (result i32) (local $0 i32) diff --git a/compiler/test/__snapshots__/functions.e6c6212b.0.snapshot b/compiler/test/__snapshots__/functions.e6c6212b.0.snapshot index 750b6b9ba8..b0c75942d7 100644 --- a/compiler/test/__snapshots__/functions.e6c6212b.0.snapshot +++ b/compiler/test/__snapshots__/functions.e6c6212b.0.snapshot @@ -14,6 +14,7 @@ functions › fn_trailing_comma (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_0 (mut i32) (i32.const 0)) (global $global_2 i32 (i32.const 1)) (elem $elem (global.get $wimport__grainEnv_relocBase) $testFn_1131) @@ -26,12 +27,10 @@ functions › fn_trailing_comma (local.set $3 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $3 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -41,11 +40,8 @@ functions › fn_trailing_comma (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $2) ) - (i32.load offset=8 - (local.get $3) - ) ) - (local.get $3) + (i32.const 0) ) ) ) diff --git a/compiler/test/__snapshots__/functions.f400bb7b.0.snapshot b/compiler/test/__snapshots__/functions.f400bb7b.0.snapshot index 509ef617a5..7e3b87332b 100644 --- a/compiler/test/__snapshots__/functions.f400bb7b.0.snapshot +++ b/compiler/test/__snapshots__/functions.f400bb7b.0.snapshot @@ -1,7 +1,7 @@ functions › lam_destructure_6 (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)) @@ -14,6 +14,7 @@ functions › lam_destructure_6 (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_0 (mut i32) (i32.const 0)) (global $global_2 i32 (i32.const 1)) (elem $elem (global.get $wimport__grainEnv_relocBase) $foo_1131) @@ -69,7 +70,7 @@ functions › lam_destructure_6 ) ) ) - (local.set $12 + (local.set $8 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -85,7 +86,7 @@ functions › lam_destructure_6 ) ) ) - (local.set $13 + (local.set $9 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -101,7 +102,7 @@ functions › lam_destructure_6 ) ) ) - (local.set $14 + (local.set $10 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -126,7 +127,7 @@ functions › lam_destructure_6 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $14) + (local.get $10) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -148,7 +149,7 @@ functions › lam_destructure_6 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $13) + (local.get $9) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -170,7 +171,7 @@ functions › lam_destructure_6 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $12) + (local.get $8) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -205,7 +206,7 @@ functions › lam_destructure_6 ) ) ) - (local.set $15 + (local.set $11 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -221,7 +222,7 @@ functions › lam_destructure_6 ) ) ) - (local.set $16 + (local.set $12 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -246,7 +247,7 @@ functions › lam_destructure_6 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $16) + (local.get $12) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -268,7 +269,7 @@ functions › lam_destructure_6 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $15) + (local.get $11) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -281,15 +282,13 @@ functions › lam_destructure_6 ) ) ) - (local.set $8 + (local.set $13 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $8 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -299,9 +298,6 @@ functions › lam_destructure_6 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $4) ) - (i32.load offset=8 - (local.get $8) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -310,27 +306,22 @@ functions › lam_destructure_6 ) ) ) - (local.set $9 + (local.set $14 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $9 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $8) + (local.get $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 $9) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -339,27 +330,22 @@ functions › lam_destructure_6 ) ) ) - (local.set $10 + (local.set $15 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $10 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $9) + (local.get $14) ) (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 $10) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -368,29 +354,24 @@ functions › lam_destructure_6 ) ) ) - (local.set $11 + (local.set $16 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $11 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $10) + (local.get $15) ) (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 $11) - ) ) - (local.get $11) + (i32.const 0) ) ) ) @@ -433,19 +414,19 @@ functions › lam_destructure_6 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $12) + (local.get $8) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $13) + (local.get $9) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $14) + (local.get $10) ) ) (drop @@ -463,34 +444,34 @@ functions › lam_destructure_6 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $15) + (local.get $11) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $16) + (local.get $12) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $8) + (local.get $13) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $9) + (local.get $14) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $10) + (local.get $15) ) ) - (local.get $11) + (local.get $16) ) (func $_gmain (; has Stack IR ;) (result i32) (local $0 i32) diff --git a/compiler/test/__snapshots__/imports.644a1413.0.snapshot b/compiler/test/__snapshots__/imports.644a1413.0.snapshot index 994838d2ce..8781e5321c 100644 --- a/compiler/test/__snapshots__/imports.644a1413.0.snapshot +++ b/compiler/test/__snapshots__/imports.644a1413.0.snapshot @@ -4,7 +4,6 @@ imports › import_relative_path4 (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))) @@ -13,6 +12,7 @@ imports › import_relative_path4 (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$./bar/bar\" \"bar\" (func $gimport_./bar/bar_bar (param i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"print\" (func $gimport_pervasives_print (param i32 i32) (result i32))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) @@ -21,7 +21,7 @@ imports › import_relative_path4 (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 $gimport_./bar/bar_bar @@ -38,19 +38,14 @@ imports › import_relative_path4 ) ) ) - (local.set $0 - (call_indirect (type $i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_print) - ) - ) + (local.set $1 + (call $gimport_pervasives_print (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (global.get $gimport_pervasives_print) ) - (i32.load offset=8 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $0) ) ) @@ -58,10 +53,10 @@ imports › import_relative_path4 (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__/let_mut.00e05fe2.0.snapshot b/compiler/test/__snapshots__/let_mut.00e05fe2.0.snapshot index 2e5c99c863..d9359183b0 100644 --- a/compiler/test/__snapshots__/let_mut.00e05fe2.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.00e05fe2.0.snapshot @@ -2,16 +2,16 @@ let mut › let-mut_division1 (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))) (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)) @@ -35,21 +35,16 @@ let mut › let-mut_division1 (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_/) - ) + (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) (global.get $global_0) ) (i32.const 39) - (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__/let_mut.1176df90.0.snapshot b/compiler/test/__snapshots__/let_mut.1176df90.0.snapshot index 58ae3147fb..6974e479b2 100644 --- a/compiler/test/__snapshots__/let_mut.1176df90.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.1176df90.0.snapshot @@ -2,16 +2,16 @@ let mut › let-mut_multiplication2 (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))) (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)) @@ -35,21 +35,16 @@ let mut › let-mut_multiplication2 (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_*) - ) + (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) (global.get $global_0) ) (i32.const 39) - (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__/let_mut.43f6980c.0.snapshot b/compiler/test/__snapshots__/let_mut.43f6980c.0.snapshot index 48b64a0eb2..89fd46c730 100644 --- a/compiler/test/__snapshots__/let_mut.43f6980c.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.43f6980c.0.snapshot @@ -2,16 +2,16 @@ let mut › let-mut_division3 (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))) (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)) @@ -35,21 +35,16 @@ let mut › let-mut_division3 (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_/) - ) + (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) (global.get $global_0) ) (i32.const 39) - (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__/let_mut.48249b50.0.snapshot b/compiler/test/__snapshots__/let_mut.48249b50.0.snapshot index 8064a5a75c..d93d3264f3 100644 --- a/compiler/test/__snapshots__/let_mut.48249b50.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.48249b50.0.snapshot @@ -2,16 +2,16 @@ let mut › let-mut5 (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))) (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)) @@ -35,21 +35,16 @@ let mut › let-mut5 (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_-) - ) + (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) (global.get $global_0) ) (i32.const 3) - (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__/let_mut.4c75261e.0.snapshot b/compiler/test/__snapshots__/let_mut.4c75261e.0.snapshot index 081adf3bed..2e46e89294 100644 --- a/compiler/test/__snapshots__/let_mut.4c75261e.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.4c75261e.0.snapshot @@ -2,16 +2,16 @@ let mut › let-mut_multiplication1 (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))) (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)) @@ -35,21 +35,16 @@ let mut › let-mut_multiplication1 (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_*) - ) + (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) (global.get $global_0) ) (i32.const 39) - (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__/let_mut.634331f0.0.snapshot b/compiler/test/__snapshots__/let_mut.634331f0.0.snapshot index 2a005e92fb..bbab977187 100644 --- a/compiler/test/__snapshots__/let_mut.634331f0.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.634331f0.0.snapshot @@ -2,16 +2,16 @@ let mut › let-mut_multiplication3 (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))) (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)) @@ -35,21 +35,16 @@ let mut › let-mut_multiplication3 (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_*) - ) + (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) (global.get $global_0) ) (i32.const 39) - (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__/let_mut.6796c72d.0.snapshot b/compiler/test/__snapshots__/let_mut.6796c72d.0.snapshot index 88da702632..6466715a0f 100644 --- a/compiler/test/__snapshots__/let_mut.6796c72d.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.6796c72d.0.snapshot @@ -2,16 +2,16 @@ let mut › let-mut_subtraction1 (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))) (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)) @@ -35,21 +35,16 @@ let mut › let-mut_subtraction1 (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_-) - ) + (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) (global.get $global_0) ) (i32.const 39) - (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__/let_mut.baaea1d3.0.snapshot b/compiler/test/__snapshots__/let_mut.baaea1d3.0.snapshot index 7c57a065df..c45f7406b7 100644 --- a/compiler/test/__snapshots__/let_mut.baaea1d3.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.baaea1d3.0.snapshot @@ -2,16 +2,16 @@ let mut › let-mut_subtraction2 (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))) (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)) @@ -35,21 +35,16 @@ let mut › let-mut_subtraction2 (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_-) - ) + (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) (global.get $global_0) ) (i32.const 39) - (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__/let_mut.cbbbaeb4.0.snapshot b/compiler/test/__snapshots__/let_mut.cbbbaeb4.0.snapshot index 997aa4bab3..6669f0103f 100644 --- a/compiler/test/__snapshots__/let_mut.cbbbaeb4.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.cbbbaeb4.0.snapshot @@ -2,16 +2,16 @@ let mut › let-mut_addition2 (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))) (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)) @@ -35,21 +35,16 @@ let mut › let-mut_addition2 (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) (global.get $global_0) ) (i32.const 39) - (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__/let_mut.d2de286b.0.snapshot b/compiler/test/__snapshots__/let_mut.d2de286b.0.snapshot index 821594497f..3a5e743d31 100644 --- a/compiler/test/__snapshots__/let_mut.d2de286b.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.d2de286b.0.snapshot @@ -2,16 +2,16 @@ let mut › let-mut_addition1 (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))) (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)) @@ -35,21 +35,16 @@ let mut › let-mut_addition1 (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) (global.get $global_0) ) (i32.const 39) - (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__/let_mut.e90db621.0.snapshot b/compiler/test/__snapshots__/let_mut.e90db621.0.snapshot index ef0ddae7a3..e770268f82 100644 --- a/compiler/test/__snapshots__/let_mut.e90db621.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.e90db621.0.snapshot @@ -2,16 +2,16 @@ let mut › let-mut_subtraction3 (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))) (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)) @@ -35,21 +35,16 @@ let mut › let-mut_subtraction3 (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_-) - ) + (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) (global.get $global_0) ) (i32.const 39) - (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__/let_mut.f8f208a2.0.snapshot b/compiler/test/__snapshots__/let_mut.f8f208a2.0.snapshot index a97c40ea88..fda7004e2f 100644 --- a/compiler/test/__snapshots__/let_mut.f8f208a2.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.f8f208a2.0.snapshot @@ -2,16 +2,16 @@ let mut › let-mut_addition3 (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))) (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)) @@ -35,21 +35,16 @@ let mut › let-mut_addition3 (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) (global.get $global_0) ) (i32.const 39) - (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__/let_mut.f9e32f30.0.snapshot b/compiler/test/__snapshots__/let_mut.f9e32f30.0.snapshot index 2475a1ef1f..2b052591ed 100644 --- a/compiler/test/__snapshots__/let_mut.f9e32f30.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.f9e32f30.0.snapshot @@ -2,16 +2,16 @@ let mut › let-mut_division2 (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))) (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)) @@ -35,21 +35,16 @@ let mut › let-mut_division2 (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_/) - ) + (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) (global.get $global_0) ) (i32.const 39) - (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__/loops.0a25def1.0.snapshot b/compiler/test/__snapshots__/loops.0a25def1.0.snapshot index 2c7e57d7c1..c267824de7 100644 --- a/compiler/test/__snapshots__/loops.0a25def1.0.snapshot +++ b/compiler/test/__snapshots__/loops.0a25def1.0.snapshot @@ -1,11 +1,10 @@ loops › loop2 (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,9 @@ loops › loop2 (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\" \"+\" (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 (mut i32) (i32.const 0)) (global $global_0 (mut i32) (i32.const 0)) (global $global_3 i32 (i32.const 0)) @@ -109,21 +111,16 @@ loops › loop2 (i32.const 1879048190) (i32.eqz (i32.shr_u - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_>) - ) + (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 $0) ) (i32.const 1) - (i32.load offset=8 - (local.get $1) - ) ) (i32.const 31) ) @@ -149,21 +146,16 @@ loops › loop2 (local.set $2 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_-) - ) + (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 3) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -208,21 +200,16 @@ loops › loop2 (local.set $4 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) ) (i32.const 3) - (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__/loops.0fafc5f0.0.snapshot b/compiler/test/__snapshots__/loops.0fafc5f0.0.snapshot index 5890116abe..0cd2964c1d 100644 --- a/compiler/test/__snapshots__/loops.0fafc5f0.0.snapshot +++ b/compiler/test/__snapshots__/loops.0fafc5f0.0.snapshot @@ -5,7 +5,6 @@ loops › loop5 (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,9 @@ loops › loop5 (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))) + (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 0)) @@ -49,28 +51,23 @@ loops › loop5 (drop (loop $MFor_loop.6 (result i32) (block $MFor.5 (result i32) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_-) - ) + (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) (global.get $global_0) ) (i32.const 3) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) ) @@ -80,7 +77,7 @@ loops › loop5 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (local.get $0) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -94,49 +91,39 @@ loops › loop5 (i32.const 1879048190) (i32.eqz (i32.shr_u - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_>=) - ) + (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) (global.get $global_0) ) (i32.const 1) - (i32.load offset=8 - (local.get $0) - ) ) (i32.const 31) ) ) ) ) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) (global.get $global_1) ) (i32.const 3) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) ) @@ -146,7 +133,7 @@ loops › loop5 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (local.get $0) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -159,7 +146,7 @@ loops › loop5 ) ) ) - (local.set $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) @@ -168,7 +155,7 @@ loops › loop5 (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 @@ -177,7 +164,7 @@ loops › loop5 (i32.const 0) ) ) - (local.get $0) + (local.get $1) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/loops.c2b7bfc6.0.snapshot b/compiler/test/__snapshots__/loops.c2b7bfc6.0.snapshot index 6488d96658..ba3c97e428 100644 --- a/compiler/test/__snapshots__/loops.c2b7bfc6.0.snapshot +++ b/compiler/test/__snapshots__/loops.c2b7bfc6.0.snapshot @@ -1,11 +1,10 @@ loops › loop3 (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))) @@ -13,6 +12,8 @@ loops › loop3 (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_0 (mut i32) (i32.const 0)) (global $global_2 i32 (i32.const 0)) (export \"memory\" (memory $0)) @@ -37,47 +38,37 @@ loops › loop3 (loop $MFor_loop.4 (result i32) (if (result i32) (i32.shr_u - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_>) - ) + (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) (global.get $global_0) ) (i32.const 1) - (i32.load offset=8 - (local.get $0) - ) ) (i32.const 31) ) (block - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_-) - ) + (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) (global.get $global_0) ) (i32.const 3) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) ) @@ -87,7 +78,7 @@ loops › loop3 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (local.get $0) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -102,7 +93,7 @@ loops › loop3 ) ) ) - (local.set $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) @@ -111,10 +102,10 @@ loops › loop3 (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__/loops.f1c03b79.0.snapshot b/compiler/test/__snapshots__/loops.f1c03b79.0.snapshot index 2101b92440..7499c6bfe0 100644 --- a/compiler/test/__snapshots__/loops.f1c03b79.0.snapshot +++ b/compiler/test/__snapshots__/loops.f1c03b79.0.snapshot @@ -5,7 +5,6 @@ loops › loop4 (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,9 @@ loops › loop4 (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))) + (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 0)) @@ -51,47 +53,37 @@ loops › loop4 (loop $MFor_loop.6 (result i32) (if (result i32) (i32.shr_u - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_>) - ) + (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) (global.get $global_0) ) (i32.const 1) - (i32.load offset=8 - (local.get $0) - ) ) (i32.const 31) ) (block - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_-) - ) + (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) (global.get $global_0) ) (i32.const 3) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $0) ) ) ) @@ -101,7 +93,7 @@ loops › loop4 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (local.get $0) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -110,28 +102,23 @@ loops › loop4 ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) (global.get $global_1) ) (i32.const 3) - (i32.load offset=8 - (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) ) ) ) @@ -141,7 +128,7 @@ loops › loop4 (tuple.make (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_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -156,7 +143,7 @@ loops › loop4 ) ) ) - (local.set $0 + (local.set $2 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $global_1) @@ -165,16 +152,16 @@ loops › loop4 (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.ff6d5bfb.0.snapshot b/compiler/test/__snapshots__/optimizations.ff6d5bfb.0.snapshot index c6321ee396..0960cb84fa 100644 --- a/compiler/test/__snapshots__/optimizations.ff6d5bfb.0.snapshot +++ b/compiler/test/__snapshots__/optimizations.ff6d5bfb.0.snapshot @@ -2,10 +2,9 @@ optimizations › test_dead_branch_elimination_5 (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$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,6 +13,7 @@ optimizations › test_dead_branch_elimination_5 (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 (mut i32) (i32.const 0)) (global $global_0 (mut i32) (i32.const 0)) (global $global_3 i32 (i32.const 0)) @@ -125,7 +125,7 @@ optimizations › test_dead_branch_elimination_5 ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -141,13 +141,11 @@ optimizations › test_dead_branch_elimination_5 ) ) ) - (local.set $1 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (local.set $2 + (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) @@ -155,9 +153,6 @@ optimizations › test_dead_branch_elimination_5 ) (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 $1) ) ) @@ -171,10 +166,10 @@ optimizations › test_dead_branch_elimination_5 (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 $1) + (local.get $2) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/pattern_matching.0539d13e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.0539d13e.0.snapshot index 3259003d7a..e82ddfcb99 100644 --- a/compiler/test/__snapshots__/pattern_matching.0539d13e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.0539d13e.0.snapshot @@ -2,10 +2,9 @@ pattern matching › record_match_3 (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))) @@ -15,6 +14,7 @@ pattern matching › record_match_3 (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)) @@ -162,7 +162,7 @@ pattern matching › record_match_3 ) ) ) - (local.set $4 + (local.set $3 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -178,7 +178,7 @@ pattern matching › record_match_3 ) ) ) - (local.set $5 + (local.set $4 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -203,7 +203,7 @@ pattern matching › record_match_3 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $5) + (local.get $4) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -225,7 +225,7 @@ pattern matching › record_match_3 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $4) + (local.get $3) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -238,13 +238,11 @@ pattern matching › record_match_3 ) ) ) - (local.set $3 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $3 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (local.set $5 + (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) @@ -254,9 +252,6 @@ pattern matching › record_match_3 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $2) ) - (i32.load offset=8 - (local.get $3) - ) ) ) (drop @@ -280,16 +275,16 @@ pattern matching › record_match_3 (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) ) ) - (local.get $3) + (local.get $5) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot b/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot index 8c61f51b77..ab2c91d7b3 100644 --- a/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot @@ -1,7 +1,7 @@ pattern matching › tuple_match_deep4 (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)) @@ -16,6 +16,7 @@ pattern matching › tuple_match_deep4 (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)) @@ -47,7 +48,7 @@ pattern matching › tuple_match_deep4 (tuple.extract 0 (tuple.make (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 + (local.tee $0 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[...]) @@ -59,7 +60,7 @@ pattern matching › tuple_match_deep4 (global.get $gimport_pervasives_[]) ) (i32.load offset=8 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -70,7 +71,7 @@ pattern matching › tuple_match_deep4 ) ) (i32.store - (local.tee $1 + (local.tee $0 (call $wimport_GRAIN$MODULE$runtime/gc_malloc (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) (i32.const 16) @@ -79,15 +80,15 @@ pattern matching › tuple_match_deep4 (i32.const 7) ) (i32.store offset=4 - (local.get $1) + (local.get $0) (i32.const 2) ) (i32.store offset=8 - (local.get $1) + (local.get $0) (i32.const 3) ) (i32.store offset=12 - (local.get $1) + (local.get $0) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $18) @@ -96,7 +97,7 @@ pattern matching › tuple_match_deep4 (local.set $14 (tuple.extract 0 (tuple.make - (local.get $1) + (local.get $0) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) (i32.const 0) @@ -214,7 +215,7 @@ pattern matching › tuple_match_deep4 ) ) ) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -230,7 +231,7 @@ pattern matching › tuple_match_deep4 ) ) ) - (local.set $0 + (local.set $2 (block $switch.91_outer (result i32) (drop (block $switch.91_branch_1 (result i32) @@ -252,7 +253,7 @@ pattern matching › tuple_match_deep4 (i32.or (i32.shl (i32.eq - (local.tee $0 + (local.tee $2 (i32.load offset=12 (local.tee $15 (tuple.extract 0 @@ -281,7 +282,7 @@ pattern matching › tuple_match_deep4 (i32.const 31) ) (block (result i32) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -302,7 +303,7 @@ pattern matching › tuple_match_deep4 (i32.or (i32.shl (i32.eq - (local.tee $0 + (local.tee $2 (i32.load offset=12 (local.tee $3 (tuple.extract 0 @@ -352,7 +353,7 @@ pattern matching › tuple_match_deep4 (i32.or (i32.shl (i32.eq - (local.tee $0 + (local.tee $2 (i32.load offset=12 (local.tee $17 (tuple.extract 0 @@ -438,7 +439,7 @@ pattern matching › tuple_match_deep4 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (local.get $0) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -460,7 +461,7 @@ pattern matching › tuple_match_deep4 (tuple.make (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_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -527,7 +528,7 @@ pattern matching › tuple_match_deep4 (i32.or (i32.shl (i32.eq - (local.get $0) + (local.get $2) (i32.const 1) ) (i32.const 31) @@ -546,7 +547,7 @@ pattern matching › tuple_match_deep4 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (local.get $0) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -568,7 +569,7 @@ pattern matching › tuple_match_deep4 (tuple.make (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_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -614,7 +615,7 @@ pattern matching › tuple_match_deep4 (i32.or (i32.shl (i32.eq - (local.get $0) + (local.get $2) (i32.const 1) ) (i32.const 31) @@ -633,7 +634,7 @@ pattern matching › tuple_match_deep4 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (local.get $0) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -655,7 +656,7 @@ pattern matching › tuple_match_deep4 (tuple.make (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_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -679,7 +680,7 @@ pattern matching › tuple_match_deep4 (i32.or (i32.shl (i32.eq - (local.get $0) + (local.get $2) (i32.const 1) ) (i32.const 31) @@ -698,7 +699,7 @@ pattern matching › tuple_match_deep4 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (local.get $0) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -729,15 +730,13 @@ pattern matching › tuple_match_deep4 ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -747,13 +746,10 @@ pattern matching › tuple_match_deep4 (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) - (local.get $2) + (local.get $1) ) ) ) @@ -761,24 +757,19 @@ pattern matching › tuple_match_deep4 (local.set $3 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $2) + (local.get $1) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $12) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -788,12 +779,10 @@ pattern matching › tuple_match_deep4 ) ) (br $switch.91_outer - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -803,22 +792,17 @@ pattern matching › tuple_match_deep4 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $13) ) - (i32.load offset=8 - (local.get $0) - ) ) ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -828,47 +812,37 @@ pattern matching › tuple_match_deep4 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $8) ) - (i32.load offset=8 - (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) ) ) ) ) (br $switch.91_outer - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $2) + (local.get $1) ) (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) - ) ) ) ) ) (br $switch.91_outer - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -878,9 +852,6 @@ pattern matching › tuple_match_deep4 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $6) ) - (i32.load offset=8 - (local.get $0) - ) ) ) ) @@ -966,7 +937,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 $0) ) ) (drop @@ -978,7 +949,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 $2) + (local.get $1) ) ) (drop @@ -1011,7 +982,7 @@ pattern matching › tuple_match_deep4 (local.get $20) ) ) - (local.get $0) + (local.get $2) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot index 538eb275e3..1ac32b3fd8 100644 --- a/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot @@ -14,6 +14,7 @@ pattern matching › adt_match_4 (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)) @@ -40,7 +41,7 @@ pattern matching › adt_match_4 (tuple.extract 0 (tuple.make (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 + (local.tee $0 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[...]) @@ -52,7 +53,7 @@ pattern matching › adt_match_4 (global.get $gimport_pervasives_[]) ) (i32.load offset=8 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -66,7 +67,7 @@ pattern matching › adt_match_4 (tuple.extract 0 (tuple.make (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 + (local.tee $0 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[...]) @@ -78,7 +79,7 @@ pattern matching › adt_match_4 (local.get $12) ) (i32.load offset=8 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -88,11 +89,11 @@ pattern matching › adt_match_4 ) ) ) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 + (local.tee $0 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[...]) @@ -104,7 +105,7 @@ pattern matching › adt_match_4 (local.get $13) ) (i32.load offset=8 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -180,7 +181,7 @@ pattern matching › adt_match_4 ) ) ) - (local.set $0 + (local.set $1 (block $switch.78_outer (result i32) (drop (block $switch.78_branch_1 (result i32) @@ -202,9 +203,9 @@ pattern matching › adt_match_4 (i32.or (i32.shl (i32.eq - (local.tee $0 + (local.tee $1 (i32.load offset=12 - (local.get $1) + (local.get $0) ) ) (i32.const 3) @@ -222,7 +223,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 $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -237,7 +238,7 @@ pattern matching › adt_match_4 (i32.or (i32.shl (i32.eq - (local.tee $0 + (local.tee $1 (i32.load offset=12 (local.tee $9 (tuple.extract 0 @@ -245,7 +246,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 $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -287,7 +288,7 @@ pattern matching › adt_match_4 (i32.or (i32.shl (i32.eq - (local.tee $0 + (local.tee $1 (i32.load offset=12 (local.tee $11 (tuple.extract 0 @@ -440,7 +441,7 @@ pattern matching › adt_match_4 (i32.or (i32.shl (i32.eq - (local.get $0) + (local.get $1) (i32.const 1) ) (i32.const 31) @@ -505,7 +506,7 @@ pattern matching › adt_match_4 (i32.or (i32.shl (i32.eq - (local.get $0) + (local.get $1) (i32.const 1) ) (i32.const 31) @@ -548,7 +549,7 @@ pattern matching › adt_match_4 (i32.or (i32.shl (i32.eq - (local.get $0) + (local.get $1) (i32.const 1) ) (i32.const 31) @@ -577,12 +578,10 @@ pattern matching › adt_match_4 (local.set $2 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -592,9 +591,6 @@ pattern matching › adt_match_4 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $7) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -604,12 +600,10 @@ pattern matching › adt_match_4 ) ) (br $switch.78_outer - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -619,20 +613,15 @@ pattern matching › adt_match_4 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $8) ) - (i32.load offset=8 - (local.get $0) - ) ) ) ) ) (br $switch.78_outer - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -642,9 +631,6 @@ pattern matching › adt_match_4 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $5) ) - (i32.load offset=8 - (local.get $0) - ) ) ) ) @@ -675,7 +661,7 @@ 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 $1) + (local.get $0) ) ) (drop @@ -750,7 +736,7 @@ pattern matching › adt_match_4 (local.get $15) ) ) - (local.get $0) + (local.get $1) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/pattern_matching.16eb3dbf.0.snapshot b/compiler/test/__snapshots__/pattern_matching.16eb3dbf.0.snapshot index d6619ee706..8ed8b0fd18 100644 --- a/compiler/test/__snapshots__/pattern_matching.16eb3dbf.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.16eb3dbf.0.snapshot @@ -2,10 +2,9 @@ pattern matching › guarded_match_2 (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$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,6 +13,7 @@ pattern matching › guarded_match_2 (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)) @@ -212,33 +212,28 @@ pattern matching › guarded_match_2 ) ) (local.set $7 - (block $switch.29_outer (result i32) + (block $switch.28_outer (result i32) (drop - (block $switch.29_branch_1 (result i32) + (block $switch.28_branch_1 (result i32) (drop - (block $switch.29_branch_2 (result i32) + (block $switch.28_branch_2 (result i32) (drop - (block $switch.29_default (result i32) - (br_table $switch.29_branch_1 $switch.29_branch_2 $switch.29_default + (block $switch.28_default (result i32) + (br_table $switch.28_branch_1 $switch.28_branch_2 $switch.28_default (i32.const 0) (i32.shr_s (if (result i32) (i32.shr_u - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $7 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) + (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 3) - (i32.load offset=8 - (local.get $7) - ) ) (i32.const 31) ) @@ -321,7 +316,7 @@ pattern matching › guarded_match_2 (unreachable) ) ) - (br $switch.29_outer + (br $switch.28_outer (i32.const 199) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.3722b060.0.snapshot b/compiler/test/__snapshots__/pattern_matching.3722b060.0.snapshot index aabeae5b93..5c62f94cfb 100644 --- a/compiler/test/__snapshots__/pattern_matching.3722b060.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.3722b060.0.snapshot @@ -1,11 +1,10 @@ pattern matching › tuple_match_deep (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$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,6 +13,7 @@ pattern matching › tuple_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)) @@ -55,7 +55,7 @@ pattern matching › tuple_match_deep (local.get $0) (i32.const 11) ) - (local.set $9 + (local.set $6 (tuple.extract 0 (tuple.make (local.get $0) @@ -87,7 +87,7 @@ pattern matching › tuple_match_deep (local.get $0) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $9) + (local.get $6) ) ) (i32.store offset=16 @@ -149,7 +149,7 @@ pattern matching › tuple_match_deep ) ) ) - (local.set $10 + (local.set $7 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -165,7 +165,7 @@ pattern matching › tuple_match_deep ) ) ) - (local.set $7 + (local.set $5 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -181,7 +181,7 @@ pattern matching › tuple_match_deep ) ) ) - (local.set $11 + (local.set $8 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -197,13 +197,13 @@ pattern matching › tuple_match_deep ) ) ) - (local.set $12 + (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=8 - (local.get $7) + (local.get $5) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -213,13 +213,13 @@ pattern matching › tuple_match_deep ) ) ) - (local.set $13 + (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=12 - (local.get $7) + (local.get $5) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -238,7 +238,7 @@ pattern matching › tuple_match_deep (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $11) + (local.get $8) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -260,7 +260,7 @@ pattern matching › tuple_match_deep (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $10) + (local.get $7) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -282,7 +282,7 @@ pattern matching › tuple_match_deep (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $13) + (local.get $10) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -304,7 +304,7 @@ pattern matching › tuple_match_deep (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $12) + (local.get $9) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -317,15 +317,13 @@ pattern matching › tuple_match_deep ) ) ) - (local.set $5 + (local.set $11 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $5 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -335,9 +333,6 @@ pattern matching › tuple_match_deep (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $4) ) - (i32.load offset=8 - (local.get $5) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -346,27 +341,22 @@ pattern matching › tuple_match_deep ) ) ) - (local.set $6 + (local.set $12 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $6 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $5) + (local.get $11) ) (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 $6) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -375,31 +365,26 @@ pattern matching › tuple_match_deep ) ) ) - (local.set $8 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $8 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (local.set $13 + (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 $6) + (local.get $12) ) (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 $8) - ) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $9) + (local.get $6) ) ) (drop @@ -435,46 +420,46 @@ pattern matching › tuple_match_deep (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $10) + (local.get $7) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $7) + (local.get $5) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $11) + (local.get $8) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $12) + (local.get $9) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $13) + (local.get $10) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $5) + (local.get $11) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $6) + (local.get $12) ) ) - (local.get $8) + (local.get $13) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/pattern_matching.5ff49e44.0.snapshot b/compiler/test/__snapshots__/pattern_matching.5ff49e44.0.snapshot index c0fef25818..66679c2ae2 100644 --- a/compiler/test/__snapshots__/pattern_matching.5ff49e44.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.5ff49e44.0.snapshot @@ -1,11 +1,10 @@ pattern matching › record_match_4 (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 \"_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 @@ pattern matching › record_match_4 (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)) @@ -176,7 +176,7 @@ pattern matching › record_match_4 ) ) ) - (local.set $6 + (local.set $4 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -192,7 +192,7 @@ pattern matching › record_match_4 ) ) ) - (local.set $7 + (local.set $5 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -208,7 +208,7 @@ pattern matching › record_match_4 ) ) ) - (local.set $8 + (local.set $6 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -233,7 +233,7 @@ pattern matching › record_match_4 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $8) + (local.get $6) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -255,7 +255,7 @@ pattern matching › record_match_4 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $7) + (local.get $5) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -277,7 +277,7 @@ pattern matching › record_match_4 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $6) + (local.get $4) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -290,15 +290,13 @@ pattern matching › record_match_4 ) ) ) - (local.set $4 + (local.set $7 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $4 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -308,9 +306,6 @@ pattern matching › record_match_4 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $2) ) - (i32.load offset=8 - (local.get $4) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -319,25 +314,20 @@ pattern matching › record_match_4 ) ) ) - (local.set $5 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $5 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (local.set $8 + (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 $4) + (local.get $7) ) (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 $5) - ) ) ) (drop @@ -367,28 +357,28 @@ pattern matching › record_match_4 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $6) + (local.get $4) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $7) + (local.get $5) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $8) + (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) ) ) - (local.get $5) + (local.get $8) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot b/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot index b5b63e6079..7f4edb4cb5 100644 --- a/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot @@ -16,6 +16,7 @@ pattern matching › tuple_match_deep6 (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)) @@ -49,7 +50,7 @@ pattern matching › tuple_match_deep6 (tuple.extract 0 (tuple.make (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 + (local.tee $0 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[...]) @@ -61,7 +62,7 @@ pattern matching › tuple_match_deep6 (global.get $gimport_pervasives_[]) ) (i32.load offset=8 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -75,7 +76,7 @@ pattern matching › tuple_match_deep6 (tuple.extract 0 (tuple.make (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 + (local.tee $0 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[...]) @@ -87,7 +88,7 @@ pattern matching › tuple_match_deep6 (local.get $18) ) (i32.load offset=8 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -101,7 +102,7 @@ pattern matching › tuple_match_deep6 (tuple.extract 0 (tuple.make (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 + (local.tee $0 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[...]) @@ -113,7 +114,7 @@ pattern matching › tuple_match_deep6 (local.get $19) ) (i32.load offset=8 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -124,7 +125,7 @@ pattern matching › tuple_match_deep6 ) ) (i32.store - (local.tee $1 + (local.tee $0 (call $wimport_GRAIN$MODULE$runtime/gc_malloc (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) (i32.const 16) @@ -133,15 +134,15 @@ pattern matching › tuple_match_deep6 (i32.const 7) ) (i32.store offset=4 - (local.get $1) + (local.get $0) (i32.const 2) ) (i32.store offset=8 - (local.get $1) + (local.get $0) (i32.const 3) ) (i32.store offset=12 - (local.get $1) + (local.get $0) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $20) @@ -150,7 +151,7 @@ pattern matching › tuple_match_deep6 (local.set $14 (tuple.extract 0 (tuple.make - (local.get $1) + (local.get $0) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) (i32.const 0) @@ -268,7 +269,7 @@ pattern matching › tuple_match_deep6 ) ) ) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -284,7 +285,7 @@ pattern matching › tuple_match_deep6 ) ) ) - (local.set $0 + (local.set $2 (block $switch.97_outer (result i32) (drop (block $switch.97_branch_1 (result i32) @@ -306,7 +307,7 @@ pattern matching › tuple_match_deep6 (i32.or (i32.shl (i32.eq - (local.tee $0 + (local.tee $2 (i32.load offset=12 (local.tee $15 (tuple.extract 0 @@ -335,7 +336,7 @@ pattern matching › tuple_match_deep6 (i32.const 31) ) (block (result i32) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -356,7 +357,7 @@ pattern matching › tuple_match_deep6 (i32.or (i32.shl (i32.eq - (local.tee $0 + (local.tee $2 (i32.load offset=12 (local.tee $3 (tuple.extract 0 @@ -406,7 +407,7 @@ pattern matching › tuple_match_deep6 (i32.or (i32.shl (i32.eq - (local.tee $0 + (local.tee $2 (i32.load offset=12 (local.tee $17 (tuple.extract 0 @@ -492,7 +493,7 @@ pattern matching › tuple_match_deep6 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (local.get $0) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -514,7 +515,7 @@ pattern matching › tuple_match_deep6 (tuple.make (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_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -581,7 +582,7 @@ pattern matching › tuple_match_deep6 (i32.or (i32.shl (i32.eq - (local.get $0) + (local.get $2) (i32.const 1) ) (i32.const 31) @@ -600,7 +601,7 @@ pattern matching › tuple_match_deep6 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (local.get $0) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -622,7 +623,7 @@ pattern matching › tuple_match_deep6 (tuple.make (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_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -668,7 +669,7 @@ pattern matching › tuple_match_deep6 (i32.or (i32.shl (i32.eq - (local.get $0) + (local.get $2) (i32.const 1) ) (i32.const 31) @@ -687,7 +688,7 @@ pattern matching › tuple_match_deep6 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (local.get $0) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -709,7 +710,7 @@ pattern matching › tuple_match_deep6 (tuple.make (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_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -733,7 +734,7 @@ pattern matching › tuple_match_deep6 (i32.or (i32.shl (i32.eq - (local.get $0) + (local.get $2) (i32.const 1) ) (i32.const 31) @@ -752,7 +753,7 @@ pattern matching › tuple_match_deep6 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (local.get $0) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -783,15 +784,13 @@ pattern matching › tuple_match_deep6 ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -801,13 +800,10 @@ pattern matching › tuple_match_deep6 (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) - (local.get $2) + (local.get $1) ) ) ) @@ -815,24 +811,19 @@ pattern matching › tuple_match_deep6 (local.set $3 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $2) + (local.get $1) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $12) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -842,12 +833,10 @@ pattern matching › tuple_match_deep6 ) ) (br $switch.97_outer - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -857,22 +846,17 @@ pattern matching › tuple_match_deep6 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $13) ) - (i32.load offset=8 - (local.get $0) - ) ) ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -882,47 +866,37 @@ pattern matching › tuple_match_deep6 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $8) ) - (i32.load offset=8 - (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) ) ) ) ) (br $switch.97_outer - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $2) + (local.get $1) ) (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) - ) ) ) ) ) (br $switch.97_outer - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -932,9 +906,6 @@ pattern matching › tuple_match_deep6 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $6) ) - (i32.load offset=8 - (local.get $0) - ) ) ) ) @@ -1032,7 +1003,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 $1) + (local.get $0) ) ) (drop @@ -1044,7 +1015,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 $2) + (local.get $1) ) ) (drop @@ -1077,7 +1048,7 @@ pattern matching › tuple_match_deep6 (local.get $22) ) ) - (local.get $0) + (local.get $2) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/pattern_matching.79346fef.0.snapshot b/compiler/test/__snapshots__/pattern_matching.79346fef.0.snapshot index 24c021d466..c22ae92bf8 100644 --- a/compiler/test/__snapshots__/pattern_matching.79346fef.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.79346fef.0.snapshot @@ -1,11 +1,10 @@ pattern matching › tuple_match_deep3 (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$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 @@ pattern matching › tuple_match_deep3 (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)) @@ -42,7 +42,7 @@ pattern matching › tuple_match_deep3 (local $18 i32) (local $19 i32) (i32.store - (local.tee $1 + (local.tee $0 (call $wimport_GRAIN$MODULE$runtime/gc_malloc (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) (i32.const 16) @@ -51,15 +51,15 @@ pattern matching › tuple_match_deep3 (i32.const 7) ) (i32.store offset=4 - (local.get $1) + (local.get $0) (i32.const 2) ) (i32.store offset=8 - (local.get $1) + (local.get $0) (i32.const 3) ) (i32.store offset=12 - (local.get $1) + (local.get $0) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[]) @@ -68,7 +68,7 @@ pattern matching › tuple_match_deep3 (local.set $14 (tuple.extract 0 (tuple.make - (local.get $1) + (local.get $0) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) (i32.const 0) @@ -186,7 +186,7 @@ pattern matching › tuple_match_deep3 ) ) ) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -202,7 +202,7 @@ pattern matching › tuple_match_deep3 ) ) ) - (local.set $0 + (local.set $2 (block $switch.88_outer (result i32) (drop (block $switch.88_branch_1 (result i32) @@ -224,7 +224,7 @@ pattern matching › tuple_match_deep3 (i32.or (i32.shl (i32.eq - (local.tee $0 + (local.tee $2 (i32.load offset=12 (local.tee $15 (tuple.extract 0 @@ -253,7 +253,7 @@ pattern matching › tuple_match_deep3 (i32.const 31) ) (block (result i32) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -274,7 +274,7 @@ pattern matching › tuple_match_deep3 (i32.or (i32.shl (i32.eq - (local.tee $0 + (local.tee $2 (i32.load offset=12 (local.tee $3 (tuple.extract 0 @@ -324,7 +324,7 @@ pattern matching › tuple_match_deep3 (i32.or (i32.shl (i32.eq - (local.tee $0 + (local.tee $2 (i32.load offset=12 (local.tee $17 (tuple.extract 0 @@ -410,7 +410,7 @@ pattern matching › tuple_match_deep3 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (local.get $0) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -432,7 +432,7 @@ pattern matching › tuple_match_deep3 (tuple.make (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_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -499,7 +499,7 @@ pattern matching › tuple_match_deep3 (i32.or (i32.shl (i32.eq - (local.get $0) + (local.get $2) (i32.const 1) ) (i32.const 31) @@ -518,7 +518,7 @@ pattern matching › tuple_match_deep3 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (local.get $0) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -540,7 +540,7 @@ pattern matching › tuple_match_deep3 (tuple.make (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_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -586,7 +586,7 @@ pattern matching › tuple_match_deep3 (i32.or (i32.shl (i32.eq - (local.get $0) + (local.get $2) (i32.const 1) ) (i32.const 31) @@ -605,7 +605,7 @@ pattern matching › tuple_match_deep3 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (local.get $0) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -627,7 +627,7 @@ pattern matching › tuple_match_deep3 (tuple.make (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_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -651,7 +651,7 @@ pattern matching › tuple_match_deep3 (i32.or (i32.shl (i32.eq - (local.get $0) + (local.get $2) (i32.const 1) ) (i32.const 31) @@ -670,7 +670,7 @@ pattern matching › tuple_match_deep3 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (local.get $0) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -701,15 +701,13 @@ pattern matching › tuple_match_deep3 ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -719,13 +717,10 @@ pattern matching › tuple_match_deep3 (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) - (local.get $2) + (local.get $1) ) ) ) @@ -733,24 +728,19 @@ pattern matching › tuple_match_deep3 (local.set $3 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $2) + (local.get $1) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $12) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -760,12 +750,10 @@ pattern matching › tuple_match_deep3 ) ) (br $switch.88_outer - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -775,22 +763,17 @@ pattern matching › tuple_match_deep3 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $13) ) - (i32.load offset=8 - (local.get $0) - ) ) ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -800,47 +783,37 @@ pattern matching › tuple_match_deep3 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $8) ) - (i32.load offset=8 - (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) ) ) ) ) (br $switch.88_outer - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $2) + (local.get $1) ) (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) - ) ) ) ) ) (br $switch.88_outer - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -850,9 +823,6 @@ pattern matching › tuple_match_deep3 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $6) ) - (i32.load offset=8 - (local.get $0) - ) ) ) ) @@ -932,7 +902,7 @@ pattern matching › tuple_match_deep3 (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 @@ -944,7 +914,7 @@ pattern matching › tuple_match_deep3 (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 @@ -977,7 +947,7 @@ pattern matching › tuple_match_deep3 (local.get $19) ) ) - (local.get $0) + (local.get $2) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/pattern_matching.8c0dc67a.0.snapshot b/compiler/test/__snapshots__/pattern_matching.8c0dc67a.0.snapshot index 1aefce242c..d840881c29 100644 --- a/compiler/test/__snapshots__/pattern_matching.8c0dc67a.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.8c0dc67a.0.snapshot @@ -1,11 +1,10 @@ pattern matching › adt_match_1 (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 @@ pattern matching › adt_match_1 (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)) @@ -495,12 +495,10 @@ pattern matching › adt_match_1 (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -510,9 +508,6 @@ pattern matching › adt_match_1 (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) @@ -522,12 +517,10 @@ pattern matching › adt_match_1 ) ) (br $switch.69_outer - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -537,20 +530,15 @@ pattern matching › adt_match_1 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $7) ) - (i32.load offset=8 - (local.get $0) - ) ) ) ) ) (br $switch.69_outer - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -560,9 +548,6 @@ pattern matching › adt_match_1 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $4) ) - (i32.load offset=8 - (local.get $0) - ) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.9561763b.0.snapshot b/compiler/test/__snapshots__/pattern_matching.9561763b.0.snapshot index 1805bf3f91..d6091652bb 100644 --- a/compiler/test/__snapshots__/pattern_matching.9561763b.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.9561763b.0.snapshot @@ -1,11 +1,10 @@ pattern matching › tuple_match_deep2 (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$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,6 +13,7 @@ pattern matching › tuple_match_deep2 (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)) @@ -70,7 +70,7 @@ pattern matching › tuple_match_deep2 (local.get $0) (i32.const 15) ) - (local.set $18 + (local.set $12 (tuple.extract 0 (tuple.make (local.get $0) @@ -106,10 +106,10 @@ pattern matching › tuple_match_deep2 (local.get $0) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $18) + (local.get $12) ) ) - (local.set $19 + (local.set $13 (tuple.extract 0 (tuple.make (local.get $0) @@ -141,10 +141,10 @@ pattern matching › tuple_match_deep2 (local.get $0) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $19) + (local.get $13) ) ) - (local.set $20 + (local.set $14 (tuple.extract 0 (tuple.make (local.get $0) @@ -176,10 +176,10 @@ pattern matching › tuple_match_deep2 (local.get $0) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $20) + (local.get $14) ) ) - (local.set $21 + (local.set $15 (tuple.extract 0 (tuple.make (local.get $0) @@ -211,10 +211,10 @@ pattern matching › tuple_match_deep2 (local.get $0) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $21) + (local.get $15) ) ) - (local.set $13 + (local.set $8 (tuple.extract 0 (tuple.make (local.get $0) @@ -302,13 +302,13 @@ pattern matching › tuple_match_deep2 ) ) ) - (local.set $22 + (local.set $16 (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 $13) + (local.get $8) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -318,13 +318,13 @@ pattern matching › tuple_match_deep2 ) ) ) - (local.set $14 + (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 $13) + (local.get $8) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -334,13 +334,13 @@ pattern matching › tuple_match_deep2 ) ) ) - (local.set $23 + (local.set $17 (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 $14) + (local.get $9) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -350,13 +350,13 @@ pattern matching › tuple_match_deep2 ) ) ) - (local.set $15 + (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=12 - (local.get $14) + (local.get $9) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -366,13 +366,13 @@ pattern matching › tuple_match_deep2 ) ) ) - (local.set $24 + (local.set $18 (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 $15) + (local.get $10) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -388,7 +388,7 @@ pattern matching › tuple_match_deep2 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=12 - (local.get $15) + (local.get $10) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -398,7 +398,7 @@ pattern matching › tuple_match_deep2 ) ) ) - (local.set $25 + (local.set $19 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -414,7 +414,7 @@ pattern matching › tuple_match_deep2 ) ) ) - (local.set $26 + (local.set $20 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -430,7 +430,7 @@ pattern matching › tuple_match_deep2 ) ) ) - (local.set $16 + (local.set $11 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -446,13 +446,13 @@ pattern matching › tuple_match_deep2 ) ) ) - (local.set $27 + (local.set $21 (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 $16) + (local.get $11) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -462,13 +462,13 @@ pattern matching › tuple_match_deep2 ) ) ) - (local.set $28 + (local.set $22 (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 $16) + (local.get $11) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -487,7 +487,7 @@ pattern matching › tuple_match_deep2 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $22) + (local.get $16) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -509,7 +509,7 @@ pattern matching › tuple_match_deep2 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $23) + (local.get $17) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -531,7 +531,7 @@ pattern matching › tuple_match_deep2 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $24) + (local.get $18) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -553,7 +553,7 @@ pattern matching › tuple_match_deep2 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $25) + (local.get $19) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -575,7 +575,7 @@ pattern matching › tuple_match_deep2 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $26) + (local.get $20) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -597,7 +597,7 @@ pattern matching › tuple_match_deep2 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $28) + (local.get $22) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -619,7 +619,7 @@ pattern matching › tuple_match_deep2 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $27) + (local.get $21) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -632,15 +632,13 @@ pattern matching › tuple_match_deep2 ) ) ) - (local.set $8 + (local.set $23 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $8 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -650,9 +648,6 @@ pattern matching › tuple_match_deep2 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $2) ) - (i32.load offset=8 - (local.get $8) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -661,27 +656,22 @@ pattern matching › tuple_match_deep2 ) ) ) - (local.set $9 + (local.set $24 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $9 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $8) + (local.get $23) ) (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 $9) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -690,27 +680,22 @@ pattern matching › tuple_match_deep2 ) ) ) - (local.set $10 + (local.set $25 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $10 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $9) + (local.get $24) ) (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 $10) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -719,27 +704,22 @@ pattern matching › tuple_match_deep2 ) ) ) - (local.set $11 + (local.set $26 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $11 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $10) + (local.get $25) ) (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 $11) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -748,27 +728,22 @@ pattern matching › tuple_match_deep2 ) ) ) - (local.set $12 + (local.set $27 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $12 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $11) + (local.get $26) ) (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 $12) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -777,55 +752,50 @@ pattern matching › tuple_match_deep2 ) ) ) - (local.set $17 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $17 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (local.set $28 + (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 $12) + (local.get $27) ) (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 $17) - ) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $18) + (local.get $12) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $19) + (local.get $13) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $20) + (local.get $14) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $21) + (local.get $15) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $13) + (local.get $8) ) ) (drop @@ -873,31 +843,31 @@ pattern matching › tuple_match_deep2 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $22) + (local.get $16) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $14) + (local.get $9) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $23) + (local.get $17) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $15) + (local.get $10) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $24) + (local.get $18) ) ) (drop @@ -909,64 +879,64 @@ pattern matching › tuple_match_deep2 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $25) + (local.get $19) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $26) + (local.get $20) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $16) + (local.get $11) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $27) + (local.get $21) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $28) + (local.get $22) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $8) + (local.get $23) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $9) + (local.get $24) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $10) + (local.get $25) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $11) + (local.get $26) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $12) + (local.get $27) ) ) - (local.get $17) + (local.get $28) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/pattern_matching.aa8d2963.0.snapshot b/compiler/test/__snapshots__/pattern_matching.aa8d2963.0.snapshot index a140e33174..07785d5fe6 100644 --- a/compiler/test/__snapshots__/pattern_matching.aa8d2963.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.aa8d2963.0.snapshot @@ -1,11 +1,10 @@ pattern matching › guarded_match_4 (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))) @@ -14,6 +13,7 @@ pattern matching › guarded_match_4 (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)) @@ -64,7 +64,7 @@ pattern matching › guarded_match_4 ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (i32.const 0) @@ -75,7 +75,7 @@ pattern matching › guarded_match_4 ) ) ) - (local.set $4 + (local.set $3 (tuple.extract 0 (tuple.make (i32.const 0) @@ -86,7 +86,7 @@ pattern matching › guarded_match_4 ) ) ) - (local.set $3 + (local.set $2 (tuple.extract 0 (tuple.make (i32.const 0) @@ -97,7 +97,7 @@ pattern matching › guarded_match_4 ) ) ) - (local.set $5 + (local.set $4 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -113,7 +113,7 @@ pattern matching › guarded_match_4 ) ) ) - (local.set $6 + (local.set $5 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -129,7 +129,7 @@ pattern matching › guarded_match_4 ) ) ) - (local.set $7 + (local.set $6 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -149,16 +149,16 @@ pattern matching › guarded_match_4 (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) (block (result i32) - (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) - (local.get $7) + (local.get $6) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $2) ) ) ) @@ -171,16 +171,16 @@ pattern matching › guarded_match_4 (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) (block (result i32) - (local.set $4 + (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 $6) + (local.get $5) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $4) + (local.get $3) ) ) ) @@ -193,16 +193,16 @@ pattern matching › guarded_match_4 (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) (block (result i32) - (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) - (local.get $5) + (local.get $4) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) ) @@ -211,58 +211,48 @@ pattern matching › guarded_match_4 ) ) ) - (local.set $1 - (block $switch.34_outer (result i32) + (local.set $7 + (block $switch.32_outer (result i32) (drop - (block $switch.34_branch_1 (result i32) + (block $switch.32_branch_1 (result i32) (drop - (block $switch.34_branch_2 (result i32) + (block $switch.32_branch_2 (result i32) (drop - (block $switch.34_default (result i32) - (br_table $switch.34_branch_1 $switch.34_branch_2 $switch.34_default + (block $switch.32_default (result i32) + (br_table $switch.32_branch_1 $switch.32_branch_2 $switch.32_default (i32.const 0) (i32.shr_s (if (result i32) (i32.shr_u (if (result i32) (i32.shr_u - (local.tee $1 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) - ) + (local.tee $7 + (call $gimport_pervasives_== (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) + (global.get $gimport_pervasives_==) ) - (i32.const 5) - (i32.load offset=8 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $1) ) + (i32.const 5) ) ) (i32.const 31) ) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) + (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) + (local.get $2) ) (i32.const 7) - (i32.load offset=8 - (local.get $1) - ) ) - (local.get $1) + (local.get $7) ) (i32.const 31) ) @@ -271,16 +261,16 @@ pattern matching › guarded_match_4 (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) (block (result i32) - (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) - (local.get $7) + (local.get $6) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $2) ) ) ) @@ -293,16 +283,16 @@ pattern matching › guarded_match_4 (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) (block (result i32) - (local.set $4 + (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 $6) + (local.get $5) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $4) + (local.get $3) ) ) ) @@ -315,16 +305,16 @@ pattern matching › guarded_match_4 (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) (block (result i32) - (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) - (local.get $5) + (local.get $4) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) ) @@ -345,7 +335,7 @@ pattern matching › guarded_match_4 (unreachable) ) ) - (br $switch.34_outer + (br $switch.32_outer (i32.const 199) ) ) @@ -362,40 +352,40 @@ pattern matching › guarded_match_4 (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 $4) + (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 $2) ) ) (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) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $7) + (local.get $6) ) ) - (local.get $1) + (local.get $7) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/pattern_matching.ac58ffc3.0.snapshot b/compiler/test/__snapshots__/pattern_matching.ac58ffc3.0.snapshot index f8c8f601e3..042a7f78b1 100644 --- a/compiler/test/__snapshots__/pattern_matching.ac58ffc3.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.ac58ffc3.0.snapshot @@ -2,10 +2,9 @@ pattern matching › guarded_match_1 (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$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,6 +13,7 @@ pattern matching › guarded_match_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))) + (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)) @@ -212,33 +212,28 @@ pattern matching › guarded_match_1 ) ) (local.set $7 - (block $switch.29_outer (result i32) + (block $switch.28_outer (result i32) (drop - (block $switch.29_branch_1 (result i32) + (block $switch.28_branch_1 (result i32) (drop - (block $switch.29_branch_2 (result i32) + (block $switch.28_branch_2 (result i32) (drop - (block $switch.29_default (result i32) - (br_table $switch.29_branch_1 $switch.29_branch_2 $switch.29_default + (block $switch.28_default (result i32) + (br_table $switch.28_branch_1 $switch.28_branch_2 $switch.28_default (i32.const 0) (i32.shr_s (if (result i32) (i32.shr_u - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $7 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) + (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 3) - (i32.load offset=8 - (local.get $7) - ) ) (i32.const 31) ) @@ -321,7 +316,7 @@ pattern matching › guarded_match_1 (unreachable) ) ) - (br $switch.29_outer + (br $switch.28_outer (i32.const 199) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot b/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot index 467f7ffbf7..4462980e8d 100644 --- a/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot @@ -14,6 +14,7 @@ pattern matching › adt_match_2 (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)) @@ -523,12 +524,10 @@ pattern matching › adt_match_2 (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -538,9 +537,6 @@ pattern matching › adt_match_2 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $7) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -550,12 +546,10 @@ pattern matching › adt_match_2 ) ) (br $switch.72_outer - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -565,20 +559,15 @@ pattern matching › adt_match_2 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $8) ) - (i32.load offset=8 - (local.get $0) - ) ) ) ) ) (br $switch.72_outer - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -588,9 +577,6 @@ pattern matching › adt_match_2 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $5) ) - (i32.load offset=8 - (local.get $0) - ) ) ) ) diff --git a/compiler/test/__snapshots__/pattern_matching.b9db0dd9.0.snapshot b/compiler/test/__snapshots__/pattern_matching.b9db0dd9.0.snapshot index 9ae7d82b2c..8964000717 100644 --- a/compiler/test/__snapshots__/pattern_matching.b9db0dd9.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.b9db0dd9.0.snapshot @@ -1,11 +1,10 @@ pattern matching › guarded_match_3 (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))) @@ -14,6 +13,7 @@ pattern matching › guarded_match_3 (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)) @@ -64,7 +64,7 @@ pattern matching › guarded_match_3 ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (i32.const 0) @@ -75,7 +75,7 @@ pattern matching › guarded_match_3 ) ) ) - (local.set $4 + (local.set $3 (tuple.extract 0 (tuple.make (i32.const 0) @@ -86,7 +86,7 @@ pattern matching › guarded_match_3 ) ) ) - (local.set $3 + (local.set $2 (tuple.extract 0 (tuple.make (i32.const 0) @@ -97,7 +97,7 @@ pattern matching › guarded_match_3 ) ) ) - (local.set $5 + (local.set $4 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -113,7 +113,7 @@ pattern matching › guarded_match_3 ) ) ) - (local.set $6 + (local.set $5 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -129,7 +129,7 @@ pattern matching › guarded_match_3 ) ) ) - (local.set $7 + (local.set $6 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -149,16 +149,16 @@ pattern matching › guarded_match_3 (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) (block (result i32) - (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) - (local.get $7) + (local.get $6) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $2) ) ) ) @@ -171,16 +171,16 @@ pattern matching › guarded_match_3 (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) (block (result i32) - (local.set $4 + (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 $6) + (local.get $5) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $4) + (local.get $3) ) ) ) @@ -193,16 +193,16 @@ pattern matching › guarded_match_3 (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) (block (result i32) - (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) - (local.get $5) + (local.get $4) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) ) @@ -211,58 +211,48 @@ pattern matching › guarded_match_3 ) ) ) - (local.set $1 - (block $switch.34_outer (result i32) + (local.set $7 + (block $switch.32_outer (result i32) (drop - (block $switch.34_branch_1 (result i32) + (block $switch.32_branch_1 (result i32) (drop - (block $switch.34_branch_2 (result i32) + (block $switch.32_branch_2 (result i32) (drop - (block $switch.34_default (result i32) - (br_table $switch.34_branch_1 $switch.34_branch_2 $switch.34_default + (block $switch.32_default (result i32) + (br_table $switch.32_branch_1 $switch.32_branch_2 $switch.32_default (i32.const 0) (i32.shr_s (if (result i32) (i32.shr_u (if (result i32) (i32.shr_u - (local.tee $1 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) - ) + (local.tee $7 + (call $gimport_pervasives_== (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) + (global.get $gimport_pervasives_==) ) - (i32.const 5) - (i32.load offset=8 + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $1) ) + (i32.const 5) ) ) (i32.const 31) ) - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) + (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) + (local.get $2) ) (i32.const 7) - (i32.load offset=8 - (local.get $1) - ) ) - (local.get $1) + (local.get $7) ) (i32.const 31) ) @@ -271,16 +261,16 @@ pattern matching › guarded_match_3 (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) (block (result i32) - (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) - (local.get $7) + (local.get $6) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $2) ) ) ) @@ -293,16 +283,16 @@ pattern matching › guarded_match_3 (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) (block (result i32) - (local.set $4 + (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 $6) + (local.get $5) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $4) + (local.get $3) ) ) ) @@ -315,16 +305,16 @@ pattern matching › guarded_match_3 (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) (block (result i32) - (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) - (local.get $5) + (local.get $4) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $2) + (local.get $1) ) ) ) @@ -345,7 +335,7 @@ pattern matching › guarded_match_3 (unreachable) ) ) - (br $switch.34_outer + (br $switch.32_outer (i32.const 199) ) ) @@ -362,40 +352,40 @@ pattern matching › guarded_match_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 $4) + (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 $2) ) ) (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) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $7) + (local.get $6) ) ) - (local.get $1) + (local.get $7) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot b/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot index ba0472fb31..451a5c418f 100644 --- a/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot @@ -14,6 +14,7 @@ pattern matching › adt_match_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))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) @@ -39,7 +40,7 @@ pattern matching › adt_match_3 (tuple.extract 0 (tuple.make (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 + (local.tee $0 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[...]) @@ -51,7 +52,7 @@ pattern matching › adt_match_3 (global.get $gimport_pervasives_[]) ) (i32.load offset=8 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -61,11 +62,11 @@ pattern matching › adt_match_3 ) ) ) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 + (local.tee $0 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[...]) @@ -77,7 +78,7 @@ pattern matching › adt_match_3 (local.get $12) ) (i32.load offset=8 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -153,7 +154,7 @@ pattern matching › adt_match_3 ) ) ) - (local.set $0 + (local.set $1 (block $switch.75_outer (result i32) (drop (block $switch.75_branch_1 (result i32) @@ -175,9 +176,9 @@ pattern matching › adt_match_3 (i32.or (i32.shl (i32.eq - (local.tee $0 + (local.tee $1 (i32.load offset=12 - (local.get $1) + (local.get $0) ) ) (i32.const 3) @@ -195,7 +196,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 $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -210,7 +211,7 @@ pattern matching › adt_match_3 (i32.or (i32.shl (i32.eq - (local.tee $0 + (local.tee $1 (i32.load offset=12 (local.tee $9 (tuple.extract 0 @@ -218,7 +219,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 $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -260,7 +261,7 @@ pattern matching › adt_match_3 (i32.or (i32.shl (i32.eq - (local.tee $0 + (local.tee $1 (i32.load offset=12 (local.tee $11 (tuple.extract 0 @@ -413,7 +414,7 @@ pattern matching › adt_match_3 (i32.or (i32.shl (i32.eq - (local.get $0) + (local.get $1) (i32.const 1) ) (i32.const 31) @@ -478,7 +479,7 @@ pattern matching › adt_match_3 (i32.or (i32.shl (i32.eq - (local.get $0) + (local.get $1) (i32.const 1) ) (i32.const 31) @@ -521,7 +522,7 @@ pattern matching › adt_match_3 (i32.or (i32.shl (i32.eq - (local.get $0) + (local.get $1) (i32.const 1) ) (i32.const 31) @@ -550,12 +551,10 @@ pattern matching › adt_match_3 (local.set $2 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -565,9 +564,6 @@ pattern matching › adt_match_3 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $7) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -577,12 +573,10 @@ pattern matching › adt_match_3 ) ) (br $switch.75_outer - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -592,20 +586,15 @@ pattern matching › adt_match_3 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $8) ) - (i32.load offset=8 - (local.get $0) - ) ) ) ) ) (br $switch.75_outer - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -615,9 +604,6 @@ pattern matching › adt_match_3 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $5) ) - (i32.load offset=8 - (local.get $0) - ) ) ) ) @@ -642,7 +628,7 @@ 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 $1) + (local.get $0) ) ) (drop @@ -717,7 +703,7 @@ pattern matching › adt_match_3 (local.get $14) ) ) - (local.get $0) + (local.get $1) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot b/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot index a5881ac381..f0a270d4ee 100644 --- a/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot @@ -14,6 +14,7 @@ pattern matching › adt_match_5 (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)) @@ -41,7 +42,7 @@ pattern matching › adt_match_5 (tuple.extract 0 (tuple.make (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 + (local.tee $0 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[...]) @@ -53,7 +54,7 @@ pattern matching › adt_match_5 (global.get $gimport_pervasives_[]) ) (i32.load offset=8 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -67,7 +68,7 @@ pattern matching › adt_match_5 (tuple.extract 0 (tuple.make (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 + (local.tee $0 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[...]) @@ -79,7 +80,7 @@ pattern matching › adt_match_5 (local.get $12) ) (i32.load offset=8 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -93,7 +94,7 @@ pattern matching › adt_match_5 (tuple.extract 0 (tuple.make (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 + (local.tee $0 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[...]) @@ -105,7 +106,7 @@ pattern matching › adt_match_5 (local.get $13) ) (i32.load offset=8 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -115,11 +116,11 @@ pattern matching › adt_match_5 ) ) ) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 + (local.tee $0 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[...]) @@ -131,7 +132,7 @@ pattern matching › adt_match_5 (local.get $14) ) (i32.load offset=8 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -207,7 +208,7 @@ pattern matching › adt_match_5 ) ) ) - (local.set $0 + (local.set $1 (block $switch.81_outer (result i32) (drop (block $switch.81_branch_1 (result i32) @@ -229,9 +230,9 @@ pattern matching › adt_match_5 (i32.or (i32.shl (i32.eq - (local.tee $0 + (local.tee $1 (i32.load offset=12 - (local.get $1) + (local.get $0) ) ) (i32.const 3) @@ -249,7 +250,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 $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -264,7 +265,7 @@ pattern matching › adt_match_5 (i32.or (i32.shl (i32.eq - (local.tee $0 + (local.tee $1 (i32.load offset=12 (local.tee $9 (tuple.extract 0 @@ -272,7 +273,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 $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -314,7 +315,7 @@ pattern matching › adt_match_5 (i32.or (i32.shl (i32.eq - (local.tee $0 + (local.tee $1 (i32.load offset=12 (local.tee $11 (tuple.extract 0 @@ -467,7 +468,7 @@ pattern matching › adt_match_5 (i32.or (i32.shl (i32.eq - (local.get $0) + (local.get $1) (i32.const 1) ) (i32.const 31) @@ -532,7 +533,7 @@ pattern matching › adt_match_5 (i32.or (i32.shl (i32.eq - (local.get $0) + (local.get $1) (i32.const 1) ) (i32.const 31) @@ -575,7 +576,7 @@ pattern matching › adt_match_5 (i32.or (i32.shl (i32.eq - (local.get $0) + (local.get $1) (i32.const 1) ) (i32.const 31) @@ -604,12 +605,10 @@ pattern matching › adt_match_5 (local.set $2 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -619,9 +618,6 @@ pattern matching › adt_match_5 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $7) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -631,12 +627,10 @@ pattern matching › adt_match_5 ) ) (br $switch.81_outer - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -646,20 +640,15 @@ pattern matching › adt_match_5 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $8) ) - (i32.load offset=8 - (local.get $0) - ) ) ) ) ) (br $switch.81_outer - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -669,9 +658,6 @@ pattern matching › adt_match_5 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $5) ) - (i32.load offset=8 - (local.get $0) - ) ) ) ) @@ -708,7 +694,7 @@ 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 $1) + (local.get $0) ) ) (drop @@ -783,7 +769,7 @@ pattern matching › adt_match_5 (local.get $16) ) ) - (local.get $0) + (local.get $1) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot index 6282b438ec..dcd7cea9fe 100644 --- a/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot @@ -16,6 +16,7 @@ pattern matching › tuple_match_deep5 (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)) @@ -48,7 +49,7 @@ pattern matching › tuple_match_deep5 (tuple.extract 0 (tuple.make (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 + (local.tee $0 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[...]) @@ -60,7 +61,7 @@ pattern matching › tuple_match_deep5 (global.get $gimport_pervasives_[]) ) (i32.load offset=8 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -74,7 +75,7 @@ pattern matching › tuple_match_deep5 (tuple.extract 0 (tuple.make (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 + (local.tee $0 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[...]) @@ -86,7 +87,7 @@ pattern matching › tuple_match_deep5 (local.get $18) ) (i32.load offset=8 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -97,7 +98,7 @@ pattern matching › tuple_match_deep5 ) ) (i32.store - (local.tee $1 + (local.tee $0 (call $wimport_GRAIN$MODULE$runtime/gc_malloc (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) (i32.const 16) @@ -106,15 +107,15 @@ pattern matching › tuple_match_deep5 (i32.const 7) ) (i32.store offset=4 - (local.get $1) + (local.get $0) (i32.const 2) ) (i32.store offset=8 - (local.get $1) + (local.get $0) (i32.const 3) ) (i32.store offset=12 - (local.get $1) + (local.get $0) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $19) @@ -123,7 +124,7 @@ pattern matching › tuple_match_deep5 (local.set $14 (tuple.extract 0 (tuple.make - (local.get $1) + (local.get $0) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) (i32.const 0) @@ -241,7 +242,7 @@ pattern matching › tuple_match_deep5 ) ) ) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -257,7 +258,7 @@ pattern matching › tuple_match_deep5 ) ) ) - (local.set $0 + (local.set $2 (block $switch.94_outer (result i32) (drop (block $switch.94_branch_1 (result i32) @@ -279,7 +280,7 @@ pattern matching › tuple_match_deep5 (i32.or (i32.shl (i32.eq - (local.tee $0 + (local.tee $2 (i32.load offset=12 (local.tee $15 (tuple.extract 0 @@ -308,7 +309,7 @@ pattern matching › tuple_match_deep5 (i32.const 31) ) (block (result i32) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -329,7 +330,7 @@ pattern matching › tuple_match_deep5 (i32.or (i32.shl (i32.eq - (local.tee $0 + (local.tee $2 (i32.load offset=12 (local.tee $3 (tuple.extract 0 @@ -379,7 +380,7 @@ pattern matching › tuple_match_deep5 (i32.or (i32.shl (i32.eq - (local.tee $0 + (local.tee $2 (i32.load offset=12 (local.tee $17 (tuple.extract 0 @@ -465,7 +466,7 @@ pattern matching › tuple_match_deep5 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (local.get $0) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -487,7 +488,7 @@ pattern matching › tuple_match_deep5 (tuple.make (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_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -554,7 +555,7 @@ pattern matching › tuple_match_deep5 (i32.or (i32.shl (i32.eq - (local.get $0) + (local.get $2) (i32.const 1) ) (i32.const 31) @@ -573,7 +574,7 @@ pattern matching › tuple_match_deep5 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (local.get $0) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -595,7 +596,7 @@ pattern matching › tuple_match_deep5 (tuple.make (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_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -641,7 +642,7 @@ pattern matching › tuple_match_deep5 (i32.or (i32.shl (i32.eq - (local.get $0) + (local.get $2) (i32.const 1) ) (i32.const 31) @@ -660,7 +661,7 @@ pattern matching › tuple_match_deep5 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (local.get $0) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -682,7 +683,7 @@ pattern matching › tuple_match_deep5 (tuple.make (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_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -706,7 +707,7 @@ pattern matching › tuple_match_deep5 (i32.or (i32.shl (i32.eq - (local.get $0) + (local.get $2) (i32.const 1) ) (i32.const 31) @@ -725,7 +726,7 @@ pattern matching › tuple_match_deep5 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (local.get $0) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -756,15 +757,13 @@ pattern matching › tuple_match_deep5 ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -774,13 +773,10 @@ pattern matching › tuple_match_deep5 (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) - (local.get $2) + (local.get $1) ) ) ) @@ -788,24 +784,19 @@ pattern matching › tuple_match_deep5 (local.set $3 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $2) + (local.get $1) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $12) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -815,12 +806,10 @@ pattern matching › tuple_match_deep5 ) ) (br $switch.94_outer - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -830,22 +819,17 @@ pattern matching › tuple_match_deep5 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $13) ) - (i32.load offset=8 - (local.get $0) - ) ) ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -855,47 +839,37 @@ pattern matching › tuple_match_deep5 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $8) ) - (i32.load offset=8 - (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) ) ) ) ) (br $switch.94_outer - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $2) + (local.get $1) ) (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) - ) ) ) ) ) (br $switch.94_outer - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -905,9 +879,6 @@ pattern matching › tuple_match_deep5 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $6) ) - (i32.load offset=8 - (local.get $0) - ) ) ) ) @@ -999,7 +970,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 $1) + (local.get $0) ) ) (drop @@ -1011,7 +982,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 $2) + (local.get $1) ) ) (drop @@ -1044,7 +1015,7 @@ pattern matching › tuple_match_deep5 (local.get $21) ) ) - (local.get $0) + (local.get $2) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/pattern_matching.eb4334e1.0.snapshot b/compiler/test/__snapshots__/pattern_matching.eb4334e1.0.snapshot index f944d1af91..eac8837bed 100644 --- a/compiler/test/__snapshots__/pattern_matching.eb4334e1.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.eb4334e1.0.snapshot @@ -1,11 +1,10 @@ pattern matching › constant_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$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 @@ pattern matching › constant_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$runtime/equal\" \"equal\" (func $wimport_GRAIN$MODULE$runtime/equal_equal (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)) @@ -47,7 +47,7 @@ pattern matching › constant_match_4 (local.get $0) (i64.const 7303014) ) - (local.set $6 + (local.set $5 (tuple.extract 0 (tuple.make (local.get $0) @@ -75,14 +75,14 @@ pattern matching › constant_match_4 (local.get $0) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $6) + (local.get $5) ) ) (i32.store offset=12 (local.get $0) (i32.const 11) ) - (local.set $5 + (local.set $4 (tuple.extract 0 (tuple.make (local.get $0) @@ -115,13 +115,13 @@ pattern matching › constant_match_4 ) ) ) - (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=8 - (local.get $5) + (local.get $4) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -137,7 +137,7 @@ pattern matching › constant_match_4 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (i32.load offset=12 - (local.get $5) + (local.get $4) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -175,19 +175,19 @@ pattern matching › constant_match_4 ) ) ) - (local.set $4 - (block $switch.42_outer (result i32) + (local.set $7 + (block $switch.40_outer (result i32) (drop - (block $switch.42_branch_1 (result i32) + (block $switch.40_branch_1 (result i32) (drop - (block $switch.42_branch_2 (result i32) + (block $switch.40_branch_2 (result i32) (drop - (block $switch.42_branch_3 (result i32) + (block $switch.40_branch_3 (result i32) (drop - (block $switch.42_branch_4 (result i32) + (block $switch.40_branch_4 (result i32) (drop - (block $switch.42_default (result i32) - (br_table $switch.42_branch_1 $switch.42_branch_2 $switch.42_branch_3 $switch.42_branch_4 $switch.42_default + (block $switch.40_default (result i32) + (br_table $switch.40_branch_1 $switch.40_branch_2 $switch.40_branch_3 $switch.40_branch_4 $switch.40_default (i32.const 0) (i32.shr_s (if (result i32) @@ -199,7 +199,7 @@ pattern matching › constant_match_4 ) (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) @@ -233,21 +233,16 @@ pattern matching › constant_match_4 ) (if (result i32) (i32.shr_u - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $4 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) + (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 $0) ) (i32.const 15) - (i32.load offset=8 - (local.get $4) - ) ) (i32.const 31) ) @@ -317,21 +312,16 @@ pattern matching › constant_match_4 ) (if (result i32) (i32.shr_u - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $4 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) + (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 11) - (i32.load offset=8 - (local.get $4) - ) ) (i32.const 31) ) @@ -376,17 +366,17 @@ pattern matching › constant_match_4 (unreachable) ) ) - (br $switch.42_outer + (br $switch.40_outer (i32.const 2147483646) ) ) ) - (br $switch.42_outer + (br $switch.40_outer (i32.const -2) ) ) ) - (br $switch.42_outer + (br $switch.40_outer (i32.const 2147483646) ) ) @@ -397,13 +387,13 @@ pattern matching › constant_match_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) ) ) (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 @@ -421,7 +411,7 @@ pattern matching › constant_match_4 (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 @@ -436,7 +426,7 @@ pattern matching › constant_match_4 (local.get $3) ) ) - (local.get $4) + (local.get $7) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot b/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot index da59c233bf..d0a595b796 100644 --- a/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot @@ -16,6 +16,7 @@ pattern matching › tuple_match_deep7 (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)) @@ -50,7 +51,7 @@ pattern matching › tuple_match_deep7 (tuple.extract 0 (tuple.make (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 + (local.tee $0 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[...]) @@ -62,7 +63,7 @@ pattern matching › tuple_match_deep7 (global.get $gimport_pervasives_[]) ) (i32.load offset=8 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -76,7 +77,7 @@ pattern matching › tuple_match_deep7 (tuple.extract 0 (tuple.make (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 + (local.tee $0 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[...]) @@ -88,7 +89,7 @@ pattern matching › tuple_match_deep7 (local.get $18) ) (i32.load offset=8 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -102,7 +103,7 @@ pattern matching › tuple_match_deep7 (tuple.extract 0 (tuple.make (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 + (local.tee $0 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[...]) @@ -114,7 +115,7 @@ pattern matching › tuple_match_deep7 (local.get $19) ) (i32.load offset=8 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -128,7 +129,7 @@ pattern matching › tuple_match_deep7 (tuple.extract 0 (tuple.make (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 + (local.tee $0 (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $gimport_pervasives_[...]) @@ -140,7 +141,7 @@ pattern matching › tuple_match_deep7 (local.get $20) ) (i32.load offset=8 - (local.get $1) + (local.get $0) ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef @@ -151,7 +152,7 @@ pattern matching › tuple_match_deep7 ) ) (i32.store - (local.tee $1 + (local.tee $0 (call $wimport_GRAIN$MODULE$runtime/gc_malloc (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$malloc) (i32.const 16) @@ -160,15 +161,15 @@ pattern matching › tuple_match_deep7 (i32.const 7) ) (i32.store offset=4 - (local.get $1) + (local.get $0) (i32.const 2) ) (i32.store offset=8 - (local.get $1) + (local.get $0) (i32.const 3) ) (i32.store offset=12 - (local.get $1) + (local.get $0) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $21) @@ -177,7 +178,7 @@ pattern matching › tuple_match_deep7 (local.set $14 (tuple.extract 0 (tuple.make - (local.get $1) + (local.get $0) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) (i32.const 0) @@ -295,7 +296,7 @@ pattern matching › tuple_match_deep7 ) ) ) - (local.set $1 + (local.set $0 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -311,7 +312,7 @@ pattern matching › tuple_match_deep7 ) ) ) - (local.set $0 + (local.set $2 (block $switch.100_outer (result i32) (drop (block $switch.100_branch_1 (result i32) @@ -333,7 +334,7 @@ pattern matching › tuple_match_deep7 (i32.or (i32.shl (i32.eq - (local.tee $0 + (local.tee $2 (i32.load offset=12 (local.tee $15 (tuple.extract 0 @@ -362,7 +363,7 @@ pattern matching › tuple_match_deep7 (i32.const 31) ) (block (result i32) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -383,7 +384,7 @@ pattern matching › tuple_match_deep7 (i32.or (i32.shl (i32.eq - (local.tee $0 + (local.tee $2 (i32.load offset=12 (local.tee $3 (tuple.extract 0 @@ -433,7 +434,7 @@ pattern matching › tuple_match_deep7 (i32.or (i32.shl (i32.eq - (local.tee $0 + (local.tee $2 (i32.load offset=12 (local.tee $17 (tuple.extract 0 @@ -519,7 +520,7 @@ pattern matching › tuple_match_deep7 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (local.get $0) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -541,7 +542,7 @@ pattern matching › tuple_match_deep7 (tuple.make (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_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -608,7 +609,7 @@ pattern matching › tuple_match_deep7 (i32.or (i32.shl (i32.eq - (local.get $0) + (local.get $2) (i32.const 1) ) (i32.const 31) @@ -627,7 +628,7 @@ pattern matching › tuple_match_deep7 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (local.get $0) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -649,7 +650,7 @@ pattern matching › tuple_match_deep7 (tuple.make (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_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -695,7 +696,7 @@ pattern matching › tuple_match_deep7 (i32.or (i32.shl (i32.eq - (local.get $0) + (local.get $2) (i32.const 1) ) (i32.const 31) @@ -714,7 +715,7 @@ pattern matching › tuple_match_deep7 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (local.get $0) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -736,7 +737,7 @@ pattern matching › tuple_match_deep7 (tuple.make (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_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -760,7 +761,7 @@ pattern matching › tuple_match_deep7 (i32.or (i32.shl (i32.eq - (local.get $0) + (local.get $2) (i32.const 1) ) (i32.const 31) @@ -779,7 +780,7 @@ pattern matching › tuple_match_deep7 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $1) + (local.get $0) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -810,15 +811,13 @@ pattern matching › tuple_match_deep7 ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -828,13 +827,10 @@ pattern matching › tuple_match_deep7 (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) - (local.get $2) + (local.get $1) ) ) ) @@ -842,24 +838,19 @@ pattern matching › tuple_match_deep7 (local.set $3 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $2) + (local.get $1) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $12) ) - (i32.load offset=8 - (local.get $0) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -869,12 +860,10 @@ pattern matching › tuple_match_deep7 ) ) (br $switch.100_outer - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -884,22 +873,17 @@ pattern matching › tuple_match_deep7 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $13) ) - (i32.load offset=8 - (local.get $0) - ) ) ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -909,47 +893,37 @@ pattern matching › tuple_match_deep7 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $8) ) - (i32.load offset=8 - (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) ) ) ) ) (br $switch.100_outer - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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 $2) + (local.get $1) ) (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) - ) ) ) ) ) (br $switch.100_outer - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $0 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -959,9 +933,6 @@ pattern matching › tuple_match_deep7 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $6) ) - (i32.load offset=8 - (local.get $0) - ) ) ) ) @@ -1065,7 +1036,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 $1) + (local.get $0) ) ) (drop @@ -1077,7 +1048,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 $2) + (local.get $1) ) ) (drop @@ -1110,7 +1081,7 @@ pattern matching › tuple_match_deep7 (local.get $23) ) ) - (local.get $0) + (local.get $2) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/records.02742729.0.snapshot b/compiler/test/__snapshots__/records.02742729.0.snapshot index 4edd3ed8e6..7545fbe7aa 100644 --- a/compiler/test/__snapshots__/records.02742729.0.snapshot +++ b/compiler/test/__snapshots__/records.02742729.0.snapshot @@ -2,10 +2,9 @@ records › record_get_multiple (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))) @@ -15,6 +14,7 @@ records › record_get_multiple (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)) @@ -126,7 +126,7 @@ records › record_get_multiple ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -142,7 +142,7 @@ records › record_get_multiple ) ) ) - (local.set $3 + (local.set $2 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -158,25 +158,20 @@ records › record_get_multiple ) ) ) - (local.set $1 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) - ) + (local.set $3 + (call $gimport_pervasives_+ (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $2) + (global.get $gimport_pervasives_+) ) (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 $1) ) + (call $wimport_GRAIN$MODULE$runtime/gc_incRef + (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) + (local.get $2) + ) ) ) (drop @@ -188,16 +183,16 @@ records › record_get_multiple (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 $1) + (local.get $3) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/records.54f5977c.0.snapshot b/compiler/test/__snapshots__/records.54f5977c.0.snapshot index 9f90ae984d..755a01eccf 100644 --- a/compiler/test/__snapshots__/records.54f5977c.0.snapshot +++ b/compiler/test/__snapshots__/records.54f5977c.0.snapshot @@ -1,11 +1,10 @@ records › record_destruct_4 (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 \"_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_destruct_4 (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 (mut i32) (i32.const 0)) (global $global_0 (mut i32) (i32.const 0)) (global $global_2 (mut i32) (i32.const 0)) @@ -176,7 +176,7 @@ records › record_destruct_4 ) ) ) - (local.set $3 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -192,7 +192,7 @@ records › record_destruct_4 ) ) ) - (local.set $4 + (local.set $2 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -208,7 +208,7 @@ records › record_destruct_4 ) ) ) - (local.set $5 + (local.set $3 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -233,7 +233,7 @@ records › record_destruct_4 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $5) + (local.get $3) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -255,7 +255,7 @@ records › record_destruct_4 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $4) + (local.get $2) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -277,7 +277,7 @@ records › record_destruct_4 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $3) + (local.get $1) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -290,15 +290,13 @@ records › record_destruct_4 ) ) ) - (local.set $1 + (local.set $4 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -308,9 +306,6 @@ records › record_destruct_4 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $global_1) ) - (i32.load offset=8 - (local.get $1) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -319,25 +314,20 @@ records › record_destruct_4 ) ) ) - (local.set $2 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $2 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (local.set $5 + (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) + (local.get $4) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $global_2) ) - (i32.load offset=8 - (local.get $2) - ) ) ) (drop @@ -349,28 +339,28 @@ records › record_destruct_4 (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $1) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (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 $5) + (local.get $3) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $4) ) ) - (local.get $2) + (local.get $5) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/records.a3299dd2.0.snapshot b/compiler/test/__snapshots__/records.a3299dd2.0.snapshot index 7df4eb4ba4..c853fa39a6 100644 --- a/compiler/test/__snapshots__/records.a3299dd2.0.snapshot +++ b/compiler/test/__snapshots__/records.a3299dd2.0.snapshot @@ -2,10 +2,9 @@ records › record_destruct_3 (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))) @@ -15,6 +14,7 @@ records › record_destruct_3 (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 (mut i32) (i32.const 0)) (global $global_0 (mut i32) (i32.const 0)) (global $global_3 i32 (i32.const 0)) @@ -162,7 +162,7 @@ records › record_destruct_3 ) ) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -178,7 +178,7 @@ records › record_destruct_3 ) ) ) - (local.set $3 + (local.set $2 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -203,7 +203,7 @@ records › record_destruct_3 (tuple.make (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_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -225,7 +225,7 @@ records › record_destruct_3 (tuple.make (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_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -238,13 +238,11 @@ records › record_destruct_3 ) ) ) - (local.set $1 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (local.set $3 + (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) @@ -254,9 +252,6 @@ records › record_destruct_3 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $global_1) ) - (i32.load offset=8 - (local.get $1) - ) ) ) (drop @@ -268,16 +263,16 @@ records › record_destruct_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 $1) + (local.get $3) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/records.d393173c.0.snapshot b/compiler/test/__snapshots__/records.d393173c.0.snapshot index 9dd5a91958..5a41de1019 100644 --- a/compiler/test/__snapshots__/records.d393173c.0.snapshot +++ b/compiler/test/__snapshots__/records.d393173c.0.snapshot @@ -1,11 +1,10 @@ records › record_destruct_trailing (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 \"_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_destruct_trailing (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 (mut i32) (i32.const 0)) (global $global_0 (mut i32) (i32.const 0)) (global $global_2 (mut i32) (i32.const 0)) @@ -176,7 +176,7 @@ records › record_destruct_trailing ) ) ) - (local.set $3 + (local.set $1 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -192,7 +192,7 @@ records › record_destruct_trailing ) ) ) - (local.set $4 + (local.set $2 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -208,7 +208,7 @@ records › record_destruct_trailing ) ) ) - (local.set $5 + (local.set $3 (tuple.extract 0 (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef @@ -233,7 +233,7 @@ records › record_destruct_trailing (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $5) + (local.get $3) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -255,7 +255,7 @@ records › record_destruct_trailing (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $4) + (local.get $2) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -277,7 +277,7 @@ records › record_destruct_trailing (tuple.make (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (local.get $3) + (local.get $1) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -290,15 +290,13 @@ records › record_destruct_trailing ) ) ) - (local.set $1 + (local.set $4 (tuple.extract 0 (tuple.make - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (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) @@ -308,9 +306,6 @@ records › record_destruct_trailing (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $global_1) ) - (i32.load offset=8 - (local.get $1) - ) ) (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) @@ -319,25 +314,20 @@ records › record_destruct_trailing ) ) ) - (local.set $2 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $2 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_+) - ) + (local.set $5 + (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) + (local.get $4) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (global.get $global_2) ) - (i32.load offset=8 - (local.get $2) - ) ) ) (drop @@ -349,28 +339,28 @@ records › record_destruct_trailing (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $3) + (local.get $1) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (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 $5) + (local.get $3) ) ) (drop (call $wimport_GRAIN$MODULE$runtime/gc_decRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$decRef) - (local.get $1) + (local.get $4) ) ) - (local.get $2) + (local.get $5) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/stdlib.1c0b04b7.0.snapshot b/compiler/test/__snapshots__/stdlib.1c0b04b7.0.snapshot index 22cc3980ef..c78843fc46 100644 --- a/compiler/test/__snapshots__/stdlib.1c0b04b7.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.1c0b04b7.0.snapshot @@ -2,10 +2,9 @@ stdlib › stdlib_equal_20 (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))) @@ -15,6 +14,7 @@ stdlib › stdlib_equal_20 (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)) @@ -248,12 +248,10 @@ stdlib › stdlib_equal_20 ) ) (local.set $1 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) + (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) @@ -263,9 +261,6 @@ stdlib › stdlib_equal_20 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $0) ) - (i32.load offset=8 - (local.get $1) - ) ) ) (drop diff --git a/compiler/test/__snapshots__/stdlib.24cb9bbf.0.snapshot b/compiler/test/__snapshots__/stdlib.24cb9bbf.0.snapshot index c21f31cade..d81a1845d6 100644 --- a/compiler/test/__snapshots__/stdlib.24cb9bbf.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.24cb9bbf.0.snapshot @@ -2,10 +2,9 @@ stdlib › stdlib_equal_18 (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$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,6 +13,7 @@ stdlib › stdlib_equal_18 (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)) @@ -40,7 +40,7 @@ stdlib › stdlib_equal_18 (local.get $0) (i64.const -9036296798633758874) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (local.get $0) @@ -79,31 +79,26 @@ stdlib › stdlib_equal_18 ) ) ) - (local.set $1 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) + (local.set $2 + (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 $2) + (local.get $1) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $0) ) - (i32.load offset=8 - (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 $1) ) ) (drop @@ -112,7 +107,7 @@ stdlib › stdlib_equal_18 (local.get $0) ) ) - (local.get $1) + (local.get $2) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/stdlib.4a5061c2.0.snapshot b/compiler/test/__snapshots__/stdlib.4a5061c2.0.snapshot index c6e20ef8af..be379c6228 100644 --- a/compiler/test/__snapshots__/stdlib.4a5061c2.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.4a5061c2.0.snapshot @@ -2,10 +2,9 @@ stdlib › stdlib_equal_19 (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))) @@ -15,6 +14,7 @@ stdlib › stdlib_equal_19 (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)) @@ -248,12 +248,10 @@ stdlib › stdlib_equal_19 ) ) (local.set $1 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) + (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) @@ -263,9 +261,6 @@ stdlib › stdlib_equal_19 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $0) ) - (i32.load offset=8 - (local.get $1) - ) ) ) (drop diff --git a/compiler/test/__snapshots__/stdlib.5fe88631.0.snapshot b/compiler/test/__snapshots__/stdlib.5fe88631.0.snapshot index 2d04e3f329..3babaf5eea 100644 --- a/compiler/test/__snapshots__/stdlib.5fe88631.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.5fe88631.0.snapshot @@ -2,10 +2,9 @@ stdlib › stdlib_equal_16 (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$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,6 +13,7 @@ stdlib › stdlib_equal_16 (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)) @@ -40,7 +40,7 @@ stdlib › stdlib_equal_16 (local.get $0) (i64.const 7303014) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (local.get $0) @@ -79,31 +79,26 @@ stdlib › stdlib_equal_16 ) ) ) - (local.set $1 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) + (local.set $2 + (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 $2) + (local.get $1) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $0) ) - (i32.load offset=8 - (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 $1) ) ) (drop @@ -112,7 +107,7 @@ stdlib › stdlib_equal_16 (local.get $0) ) ) - (local.get $1) + (local.get $2) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/stdlib.648f406e.0.snapshot b/compiler/test/__snapshots__/stdlib.648f406e.0.snapshot index f9dc419789..c27cf8d74d 100644 --- a/compiler/test/__snapshots__/stdlib.648f406e.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.648f406e.0.snapshot @@ -2,10 +2,9 @@ stdlib › stdlib_equal_12 (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$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,6 +13,7 @@ stdlib › stdlib_equal_12 (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)) @@ -52,7 +52,7 @@ stdlib › stdlib_equal_12 (local.get $0) (i32.const 9) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (local.get $0) @@ -103,31 +103,26 @@ stdlib › stdlib_equal_12 ) ) ) - (local.set $1 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) + (local.set $2 + (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 $2) + (local.get $1) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $0) ) - (i32.load offset=8 - (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 $1) ) ) (drop @@ -136,7 +131,7 @@ stdlib › stdlib_equal_12 (local.get $0) ) ) - (local.get $1) + (local.get $2) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/stdlib.69635cff.0.snapshot b/compiler/test/__snapshots__/stdlib.69635cff.0.snapshot index 3d3ba98be5..09016eaa55 100644 --- a/compiler/test/__snapshots__/stdlib.69635cff.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.69635cff.0.snapshot @@ -2,10 +2,9 @@ stdlib › stdlib_equal_21 (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))) @@ -15,6 +14,7 @@ stdlib › stdlib_equal_21 (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)) @@ -248,12 +248,10 @@ stdlib › stdlib_equal_21 ) ) (local.set $1 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) + (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) @@ -263,9 +261,6 @@ stdlib › stdlib_equal_21 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $0) ) - (i32.load offset=8 - (local.get $1) - ) ) ) (drop diff --git a/compiler/test/__snapshots__/stdlib.6bf88430.0.snapshot b/compiler/test/__snapshots__/stdlib.6bf88430.0.snapshot index 653ffc4223..b29166c7e8 100644 --- a/compiler/test/__snapshots__/stdlib.6bf88430.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.6bf88430.0.snapshot @@ -2,10 +2,9 @@ stdlib › stdlib_equal_15 (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$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,6 +13,7 @@ stdlib › stdlib_equal_15 (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)) @@ -76,12 +76,10 @@ stdlib › stdlib_equal_15 ) ) (local.set $2 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $2 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) + (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) @@ -91,9 +89,6 @@ stdlib › stdlib_equal_15 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $1) ) - (i32.load offset=8 - (local.get $2) - ) ) ) (drop diff --git a/compiler/test/__snapshots__/stdlib.6de47be2.0.snapshot b/compiler/test/__snapshots__/stdlib.6de47be2.0.snapshot index c4a8e781df..c8598f6899 100644 --- a/compiler/test/__snapshots__/stdlib.6de47be2.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.6de47be2.0.snapshot @@ -2,10 +2,9 @@ stdlib › stdlib_equal_14 (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$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,6 +13,7 @@ stdlib › stdlib_equal_14 (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)) @@ -76,12 +76,10 @@ stdlib › stdlib_equal_14 ) ) (local.set $2 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $2 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) + (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) @@ -91,9 +89,6 @@ stdlib › stdlib_equal_14 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $1) ) - (i32.load offset=8 - (local.get $2) - ) ) ) (drop diff --git a/compiler/test/__snapshots__/stdlib.8300ad7c.0.snapshot b/compiler/test/__snapshots__/stdlib.8300ad7c.0.snapshot index bc8499b218..1fa79296a2 100644 --- a/compiler/test/__snapshots__/stdlib.8300ad7c.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.8300ad7c.0.snapshot @@ -14,6 +14,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))) (global $global_1 i32 (i32.const 0)) (export \"memory\" (memory $0)) (export \"_gmain\" (func $_gmain)) @@ -184,12 +185,10 @@ stdlib › stdlib_equal_3 ) ) (local.set $6 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $6 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) + (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) @@ -199,9 +198,6 @@ stdlib › stdlib_equal_3 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $5) ) - (i32.load offset=8 - (local.get $6) - ) ) ) (drop diff --git a/compiler/test/__snapshots__/stdlib.91a94037.0.snapshot b/compiler/test/__snapshots__/stdlib.91a94037.0.snapshot index 997e3bfd00..7d9240aba5 100644 --- a/compiler/test/__snapshots__/stdlib.91a94037.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.91a94037.0.snapshot @@ -2,10 +2,9 @@ stdlib › stdlib_equal_11 (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$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,6 +13,7 @@ stdlib › stdlib_equal_11 (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)) @@ -44,7 +44,7 @@ stdlib › stdlib_equal_11 (local.get $0) (i32.const 5) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (local.get $0) @@ -83,31 +83,26 @@ stdlib › stdlib_equal_11 ) ) ) - (local.set $1 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) + (local.set $2 + (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 $2) + (local.get $1) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $0) ) - (i32.load offset=8 - (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 $1) ) ) (drop @@ -116,7 +111,7 @@ stdlib › stdlib_equal_11 (local.get $0) ) ) - (local.get $1) + (local.get $2) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/stdlib.a70e79ca.0.snapshot b/compiler/test/__snapshots__/stdlib.a70e79ca.0.snapshot index ae5f5fb5d7..e6095bdba3 100644 --- a/compiler/test/__snapshots__/stdlib.a70e79ca.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.a70e79ca.0.snapshot @@ -2,10 +2,9 @@ stdlib › stdlib_equal_9 (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$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,6 +13,7 @@ stdlib › stdlib_equal_9 (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)) @@ -36,7 +36,7 @@ stdlib › stdlib_equal_9 (local.get $0) (i32.const 0) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (local.get $0) @@ -75,31 +75,26 @@ stdlib › stdlib_equal_9 ) ) ) - (local.set $1 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) + (local.set $2 + (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 $2) + (local.get $1) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $0) ) - (i32.load offset=8 - (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 $1) ) ) (drop @@ -108,7 +103,7 @@ stdlib › stdlib_equal_9 (local.get $0) ) ) - (local.get $1) + (local.get $2) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/stdlib.b30d7785.0.snapshot b/compiler/test/__snapshots__/stdlib.b30d7785.0.snapshot index 6f4783c948..44d1378ef9 100644 --- a/compiler/test/__snapshots__/stdlib.b30d7785.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.b30d7785.0.snapshot @@ -2,10 +2,9 @@ stdlib › stdlib_equal_2 (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$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,6 +13,7 @@ stdlib › stdlib_equal_2 (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)) @@ -44,7 +44,7 @@ stdlib › stdlib_equal_2 (local.get $0) (i32.const 5) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (local.get $0) @@ -87,31 +87,26 @@ stdlib › stdlib_equal_2 ) ) ) - (local.set $1 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) + (local.set $2 + (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 $2) + (local.get $1) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $0) ) - (i32.load offset=8 - (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 $1) ) ) (drop @@ -120,7 +115,7 @@ stdlib › stdlib_equal_2 (local.get $0) ) ) - (local.get $1) + (local.get $2) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/stdlib.cbf0318e.0.snapshot b/compiler/test/__snapshots__/stdlib.cbf0318e.0.snapshot index bdb9daa5a7..43de0e830a 100644 --- a/compiler/test/__snapshots__/stdlib.cbf0318e.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.cbf0318e.0.snapshot @@ -2,10 +2,9 @@ stdlib › stdlib_equal_22 (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))) @@ -15,6 +14,7 @@ stdlib › stdlib_equal_22 (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)) @@ -248,12 +248,10 @@ stdlib › stdlib_equal_22 ) ) (local.set $1 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) + (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) @@ -263,9 +261,6 @@ stdlib › stdlib_equal_22 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $0) ) - (i32.load offset=8 - (local.get $1) - ) ) ) (drop diff --git a/compiler/test/__snapshots__/stdlib.d28dee65.0.snapshot b/compiler/test/__snapshots__/stdlib.d28dee65.0.snapshot index 84f0d3b697..566eb82919 100644 --- a/compiler/test/__snapshots__/stdlib.d28dee65.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.d28dee65.0.snapshot @@ -2,10 +2,9 @@ stdlib › stdlib_equal_10 (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$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,6 +13,7 @@ stdlib › stdlib_equal_10 (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)) @@ -40,7 +40,7 @@ stdlib › stdlib_equal_10 (local.get $0) (i32.const 3) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (local.get $0) @@ -79,31 +79,26 @@ stdlib › stdlib_equal_10 ) ) ) - (local.set $1 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) + (local.set $2 + (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 $2) + (local.get $1) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $0) ) - (i32.load offset=8 - (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 $1) ) ) (drop @@ -112,7 +107,7 @@ stdlib › stdlib_equal_10 (local.get $0) ) ) - (local.get $1) + (local.get $2) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/stdlib.d4faa5bf.0.snapshot b/compiler/test/__snapshots__/stdlib.d4faa5bf.0.snapshot index 68ecd52b7f..bdb717f05e 100644 --- a/compiler/test/__snapshots__/stdlib.d4faa5bf.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.d4faa5bf.0.snapshot @@ -2,10 +2,9 @@ stdlib › stdlib_equal_13 (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$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,6 +13,7 @@ stdlib › stdlib_equal_13 (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)) @@ -72,12 +72,10 @@ stdlib › stdlib_equal_13 ) ) (local.set $2 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $2 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) + (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) @@ -87,9 +85,6 @@ stdlib › stdlib_equal_13 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $1) ) - (i32.load offset=8 - (local.get $2) - ) ) ) (drop diff --git a/compiler/test/__snapshots__/stdlib.e306600a.0.snapshot b/compiler/test/__snapshots__/stdlib.e306600a.0.snapshot index 5159511836..bd0aba1c06 100644 --- a/compiler/test/__snapshots__/stdlib.e306600a.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.e306600a.0.snapshot @@ -2,10 +2,9 @@ stdlib › stdlib_equal_8 (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$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,6 +13,7 @@ stdlib › stdlib_equal_8 (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)) @@ -72,12 +72,10 @@ stdlib › stdlib_equal_8 ) ) (local.set $2 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $2 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) + (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) @@ -87,9 +85,6 @@ stdlib › stdlib_equal_8 (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $1) ) - (i32.load offset=8 - (local.get $2) - ) ) ) (drop diff --git a/compiler/test/__snapshots__/stdlib.e6349872.0.snapshot b/compiler/test/__snapshots__/stdlib.e6349872.0.snapshot index 7b8e68ab1f..c1d70e93bf 100644 --- a/compiler/test/__snapshots__/stdlib.e6349872.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.e6349872.0.snapshot @@ -2,10 +2,9 @@ stdlib › stdlib_equal_17 (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$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,6 +13,7 @@ stdlib › stdlib_equal_17 (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)) @@ -40,7 +40,7 @@ stdlib › stdlib_equal_17 (local.get $0) (i64.const -9036296798633758874) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (local.get $0) @@ -79,31 +79,26 @@ stdlib › stdlib_equal_17 ) ) ) - (local.set $1 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_==) - ) + (local.set $2 + (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 $2) + (local.get $1) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $0) ) - (i32.load offset=8 - (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 $1) ) ) (drop @@ -112,7 +107,7 @@ stdlib › stdlib_equal_17 (local.get $0) ) ) - (local.get $1) + (local.get $2) ) (func $_start (; has Stack IR ;) (drop diff --git a/compiler/test/__snapshots__/strings.fb85549f.0.snapshot b/compiler/test/__snapshots__/strings.fb85549f.0.snapshot index 4a230c8699..a2a6e839b3 100644 --- a/compiler/test/__snapshots__/strings.fb85549f.0.snapshot +++ b/compiler/test/__snapshots__/strings.fb85549f.0.snapshot @@ -2,10 +2,9 @@ strings › concat (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$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,6 +13,7 @@ strings › concat (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)) @@ -40,7 +40,7 @@ strings › concat (local.get $0) (i64.const 7303014) ) - (local.set $2 + (local.set $1 (tuple.extract 0 (tuple.make (local.get $0) @@ -79,31 +79,26 @@ strings › concat ) ) ) - (local.set $1 - (call_indirect (type $i32_i32_i32_=>_i32) - (local.tee $1 - (call $wimport_GRAIN$MODULE$runtime/gc_incRef - (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) - (global.get $gimport_pervasives_++) - ) + (local.set $2 + (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 $2) + (local.get $1) ) (call $wimport_GRAIN$MODULE$runtime/gc_incRef (global.get $wimport_GRAIN$MODULE$runtime/gc_GRAIN$EXPORT$incRef) (local.get $0) ) - (i32.load offset=8 - (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 $1) ) ) (drop @@ -112,7 +107,7 @@ strings › concat (local.get $0) ) ) - (local.get $1) + (local.get $2) ) (func $_start (; has Stack IR ;) (drop From 1d268773bc3afc9bddf8670efa4fa6536dc41e38 Mon Sep 17 00:00:00 2001 From: Oscar Spencer Date: Thu, 21 Apr 2022 11:08:54 -0400 Subject: [PATCH 3/3] PR feedback --- compiler/src/codegen/transl_anf.re | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/compiler/src/codegen/transl_anf.re b/compiler/src/codegen/transl_anf.re index 3f20602a59..c5fdb6cf98 100644 --- a/compiler/src/codegen/transl_anf.re +++ b/compiler/src/codegen/transl_anf.re @@ -1235,7 +1235,7 @@ let lift_imports = (env, imports) => { (imports, setups, env); }; -let transl_signature = (functions, imports, signature) => { +let transl_signature = (~functions, ~imports, signature) => { open Types; let function_exports = ref([]); @@ -1261,7 +1261,7 @@ let transl_signature = (functions, imports, signature) => { switch (imp.imp_desc) { | GrainValue(mod_, name) => grain_import_name(mod_, name) | WasmFunction(mod_, name) => Ident.unique_name(imp.imp_use_id) - | _ => failwith("Wasm or js value had FunctionShape") + | _ => failwith("Impossible: Wasm or js value had FunctionShape") }; Ident_tbl.add(func_map, imp.imp_use_id, internal_name); | _ => () @@ -1345,7 +1345,11 @@ let transl_anf_program = compile_remaining_worklist(), ); let (signature, function_exports) = - transl_signature(functions, anf_prog.imports, anf_prog.signature); + transl_signature( + ~functions, + ~imports=anf_prog.imports, + anf_prog.signature, + ); let exports = function_exports @ global_exports(); {