diff --git a/.gitignore b/.gitignore index a104a34492..f7d6ddc499 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ _build/ .installed-pkgs notes.org node_modules/ +*.gro *.wasm *.wasm.map *.wat diff --git a/cli/bin/grain.js b/cli/bin/grain.js index 6b7683d148..d74fe28199 100755 --- a/cli/bin/grain.js +++ b/cli/bin/grain.js @@ -179,7 +179,7 @@ program .action(function (file, options, program) { const success = exec.grainc(file, options, program); if (success) { - const outFile = options.o ?? file.replace(/\.gr$/, ".gr.wasm"); + const outFile = options.o ?? file.replace(/\.gr$/, ".wasm"); exec.grainrun(unprocessedArgs, outFile, options, program); } }); diff --git a/compiler/grainc/grainc.re b/compiler/grainc/grainc.re index f903e0b11d..3555c0c83e 100644 --- a/compiler/grainc/grainc.re +++ b/compiler/grainc/grainc.re @@ -33,14 +33,14 @@ let compile_file = (name, outfile_arg) => { try({ let outfile = Option.value( - ~default=Compile.default_output_filename(name), + ~default=Compile.default_wasm_filename(name), outfile_arg, ); let hook = if (Grain_utils.Config.statically_link^) { Compile.stop_after_assembled; } else { - Compile.stop_after_object_file_emitted; + Compile.stop_after_object_emitted; }; ignore(Compile.compile_file(~is_root_file=true, ~hook, ~outfile, name)); }) { diff --git a/compiler/src/codegen/comp_utils.re b/compiler/src/codegen/comp_utils.re index 8f627eb02e..6091830416 100644 --- a/compiler/src/codegen/comp_utils.re +++ b/compiler/src/codegen/comp_utils.re @@ -79,8 +79,8 @@ let rec compile_const = (c): Literal.t => { | MConstU16(n) => Literal.int32(conv_short_int(n, Uint16Type)) | MConstU32(n) => Literal.int32(conv_uint32(n)) | MConstU64(n) => Literal.int64(conv_uint64(n)) - | MConstF32(n) => Literal.float32(conv_float32(n)) - | MConstF64(n) => Literal.float64(conv_float64(n)) + | MConstF32(n) => Literal.float32(conv_float32(Int64.float_of_bits(n))) + | MConstF64(n) => Literal.float64(conv_float64(Int64.float_of_bits(n))) | MConstChar(c) => Literal.int32(conv_char(c)) | MConstLiteral(MConstI8(n)) | MConstLiteral(MConstI16(n)) @@ -90,8 +90,8 @@ let rec compile_const = (c): Literal.t => { | MConstLiteral(MConstU16(n)) | MConstLiteral(MConstU32(n)) => Literal.int32(n) | MConstLiteral(MConstU64(n)) => Literal.int64(n) - | MConstLiteral(MConstF32(n)) => Literal.float32(n) - | MConstLiteral(MConstF64(n)) => Literal.float64(n) + | MConstLiteral(MConstF32(n)) => Literal.float32(Int64.float_of_bits(n)) + | MConstLiteral(MConstF64(n)) => Literal.float64(Int64.float_of_bits(n)) | MConstLiteral(MConstChar(c)) => Literal.int32(conv_char(c)) }; }; @@ -344,6 +344,3 @@ let write_universal_exports = ) ); }; - -let compiling_wasi_polyfill = name => - Option.is_some(Config.wasi_polyfill^) && Config.wasi_polyfill^ == name; diff --git a/compiler/src/codegen/comp_utils.rei b/compiler/src/codegen/comp_utils.rei index 427dd67b16..5dbefbabc1 100644 --- a/compiler/src/codegen/comp_utils.rei +++ b/compiler/src/codegen/comp_utils.rei @@ -65,5 +65,3 @@ let get_exported_names: let write_universal_exports: (Module.t, Cmi_format.cmi_infos, Hashtbl.t(string, string)) => unit; - -let compiling_wasi_polyfill: option(string) => bool; diff --git a/compiler/src/codegen/compcore.re b/compiler/src/codegen/compcore.re index a645ad5379..397346d504 100644 --- a/compiler/src/codegen/compcore.re +++ b/compiler/src/codegen/compcore.re @@ -1,5 +1,6 @@ open Grain_typed; open Mashtree; +open Linkedtree; open Value_tags; open Binaryen; open Concatlist; /* NOTE: This import shadows (@) and introduces (@+) and (+@) */ @@ -13,12 +14,17 @@ let sources: ref(list((Expression.t, Grain_parsing.Location.t))) = ref([]); type codegen_env = { name: option(string), + dep_id: int, + func_debug_idx: int, num_args: int, num_closure_args: int, stack_size, /* Allocated closures which need backpatching */ backpatches: ref(list((Expression.t, closure_data))), required_imports: list(import), + global_import_resolutions: Hashtbl.t(string, string), + func_import_resolutions: Hashtbl.t(string, string), + compilation_mode: Config.compilation_mode, }; let gensym_counter = ref(0); @@ -45,228 +51,34 @@ let swap_slots = swap_slots_f64, ]); -/** These are the bare-minimum imports needed for basic runtime support */ - /* The Grain environment */ let grain_env_mod = grain_env_name; -let module_runtime_id = Ident.create_persistent("moduleRuntimeId"); -let runtime_heap_start = Ident.create_persistent("runtimeHeapStart"); -let runtime_heap_next_ptr = Ident.create_persistent("runtimeHeapNextPtr"); -let metadata_ptr = Ident.create_persistent("metadataPtr"); -let reloc_base = Ident.create_persistent("relocBase"); -let table_size = Ident.create_persistent("GRAIN$TABLE_SIZE"); +let runtime_heap_start_name = + Ident.unique_name(Ident.create_persistent("runtimeHeapStart")); +let runtime_heap_next_ptr_name = + Ident.unique_name(Ident.create_persistent("runtimeHeapNextPtr")); +let metadata_ptr_name = + Ident.unique_name(Ident.create_persistent("metadataPtr")); /* Memory allocation */ -let malloc_mod = "GRAIN$MODULE$runtime/malloc.gr"; -let malloc_ident = Ident.create_persistent("malloc"); -let malloc_closure_ident = Ident.create_persistent("GRAIN$EXPORT$malloc"); +let malloc_name = Ident.unique_name(Ident.create_persistent("malloc")); /* Garbage collection */ -let gc_mod = "GRAIN$MODULE$runtime/gc.gr"; -let incref_ident = Ident.create_persistent("incRef"); -let incref_closure_ident = Ident.create_persistent("GRAIN$EXPORT$incRef"); -let decref_ident = Ident.create_persistent("decRef"); -let decref_closure_ident = Ident.create_persistent("GRAIN$EXPORT$decRef"); +let incref_name = Ident.unique_name(Ident.create_persistent("incRef")); +let decref_name = Ident.unique_name(Ident.create_persistent("decRef")); /* Exceptions */ -let exception_mod = "GRAIN$MODULE$runtime/exception.gr"; -let panic_with_exception_ident = - Ident.create_persistent("panicWithException"); -let panic_with_exception_closure_ident = - Ident.create_persistent("GRAIN$EXPORT$panicWithException"); +let panic_with_exception_name = + Ident.unique_name(Ident.create_persistent("panicWithException")); /* Equality checking */ -let equal_mod = "GRAIN$MODULE$runtime/equal.gr"; -let equal_ident = Ident.create_persistent("equal"); -let equal_closure_ident = Ident.create_persistent("GRAIN$EXPORT$equal"); - -let required_global_imports = [ - { - mimp_id: reloc_base, - mimp_mod: grain_env_mod, - mimp_name: Ident.name(reloc_base), - mimp_type: MGlobalImport(Types.Unmanaged(WasmI32), false), - mimp_kind: MImportWasm, - mimp_setup: MSetupNone, - mimp_used: true, - }, - { - mimp_id: module_runtime_id, - mimp_mod: grain_env_mod, - mimp_name: Ident.name(module_runtime_id), - mimp_type: MGlobalImport(Types.Unmanaged(WasmI32), false), - mimp_kind: MImportWasm, - mimp_setup: MSetupNone, - mimp_used: false, - }, - { - mimp_id: runtime_heap_start, - mimp_mod: grain_env_mod, - mimp_name: Ident.name(runtime_heap_start), - mimp_type: MGlobalImport(Types.Unmanaged(WasmI32), false), - mimp_kind: MImportWasm, - mimp_setup: MSetupNone, - mimp_used: false, - }, - { - mimp_id: runtime_heap_next_ptr, - mimp_mod: grain_env_mod, - mimp_name: Ident.name(runtime_heap_next_ptr), - mimp_type: MGlobalImport(Types.Unmanaged(WasmI32), true), - mimp_kind: MImportWasm, - mimp_setup: MSetupNone, - mimp_used: false, - }, - { - mimp_id: metadata_ptr, - mimp_mod: grain_env_mod, - mimp_name: Ident.name(metadata_ptr), - mimp_type: MGlobalImport(Types.Unmanaged(WasmI32), false), - mimp_kind: MImportWasm, - mimp_setup: MSetupNone, - mimp_used: false, - }, - { - mimp_id: panic_with_exception_closure_ident, - mimp_mod: exception_mod, - mimp_name: Ident.name(panic_with_exception_closure_ident), - mimp_type: MGlobalImport(Types.Unmanaged(WasmI32), true), - mimp_kind: MImportWasm, - mimp_setup: MSetupNone, - mimp_used: false, - }, -]; - -let grain_runtime_imports = [ - { - mimp_id: malloc_closure_ident, - mimp_mod: gc_mod, - mimp_name: Ident.name(malloc_closure_ident), - mimp_type: MGlobalImport(Types.Unmanaged(WasmI32), true), - mimp_kind: MImportWasm, - mimp_setup: MSetupNone, - mimp_used: false, - }, - { - mimp_id: incref_closure_ident, - mimp_mod: gc_mod, - mimp_name: Ident.name(incref_closure_ident), - mimp_type: MGlobalImport(Types.Unmanaged(WasmI32), true), - mimp_kind: MImportWasm, - mimp_setup: MSetupNone, - mimp_used: false, - }, - { - mimp_id: decref_closure_ident, - mimp_mod: gc_mod, - mimp_name: Ident.name(decref_closure_ident), - mimp_type: MGlobalImport(Types.Unmanaged(WasmI32), true), - mimp_kind: MImportWasm, - mimp_setup: MSetupNone, - mimp_used: false, - }, - { - mimp_id: equal_closure_ident, - mimp_mod: equal_mod, - mimp_name: Ident.name(equal_closure_ident), - mimp_type: MGlobalImport(Types.Unmanaged(WasmI32), true), - mimp_kind: MImportWasm, - mimp_setup: MSetupNone, - mimp_used: false, - }, -]; - -let runtime_global_imports = - List.append(required_global_imports, grain_runtime_imports); - -let required_function_imports = [ - { - mimp_id: panic_with_exception_ident, - mimp_mod: exception_mod, - mimp_name: Ident.name(panic_with_exception_ident), - mimp_type: - MFuncImport( - [Types.Unmanaged(WasmI32), Types.Unmanaged(WasmI32)], - [Types.Unmanaged(WasmI32)], - ), - mimp_kind: MImportWasm, - mimp_setup: MSetupNone, - mimp_used: false, - }, -]; - -let grain_function_imports = [ - { - mimp_id: malloc_ident, - mimp_mod: gc_mod, - mimp_name: Ident.name(malloc_ident), - mimp_type: - MFuncImport( - [Types.Unmanaged(WasmI32), Types.Unmanaged(WasmI32)], - [Types.Unmanaged(WasmI32)], - ), - mimp_kind: MImportWasm, - mimp_setup: MSetupNone, - mimp_used: false, - }, - { - mimp_id: incref_ident, - mimp_mod: gc_mod, - mimp_name: Ident.name(incref_ident), - mimp_type: - MFuncImport( - [Types.Unmanaged(WasmI32), Types.Unmanaged(WasmI32)], - [Types.Unmanaged(WasmI32)], - ), /* Returns same pointer as argument */ - mimp_kind: MImportWasm, - mimp_setup: MSetupNone, - mimp_used: false, - }, - { - mimp_id: decref_ident, - mimp_mod: gc_mod, - mimp_name: Ident.name(decref_ident), - mimp_type: - MFuncImport( - [Types.Unmanaged(WasmI32), Types.Unmanaged(WasmI32)], - [Types.Unmanaged(WasmI32)], - ), /* Returns same pointer as argument */ - mimp_kind: MImportWasm, - mimp_setup: MSetupNone, - mimp_used: false, - }, - { - mimp_id: equal_ident, - mimp_mod: equal_mod, - mimp_name: Ident.name(equal_ident), - mimp_type: - MFuncImport( - [Types.Managed, Types.Managed, Types.Managed], - [Types.Unmanaged(WasmI32)], - ), - mimp_kind: MImportWasm, - mimp_setup: MSetupNone, - mimp_used: false, - }, -]; - -let runtime_function_imports = - List.append(grain_function_imports, required_function_imports); - -let runtime_imports = - List.append(runtime_global_imports, runtime_function_imports); +let equal_name = Ident.unique_name(Ident.create_persistent("equal")); -let runtime_imports_tbl = { - let tbl = Ident_tbl.create(64); - List.iter( - ({mimp_id} as imp) => Ident_tbl.add(tbl, mimp_id, imp), - runtime_imports, - ); - tbl; -}; - -let init_codegen_env = name => { +let init_codegen_env = + (~global_import_resolutions, ~func_import_resolutions, name) => { name, + dep_id: 0, + func_debug_idx: 0, num_args: 0, num_closure_args: 0, stack_size: { @@ -278,38 +90,40 @@ let init_codegen_env = name => { }, backpatches: ref([]), required_imports: [], + global_import_resolutions, + func_import_resolutions, + compilation_mode: Normal, }; -let reset = () => { - reset_labels(); - List.iter( - imp => imp.mimp_used = imp.mimp_mod == grain_env_mod, - runtime_imports, - ); +// Generates the name for the linked symbol. Symbols are scoped using the +// dependency ID for that module. +let linked_name = (~env, id) => { + Printf.sprintf("%s_%d", id, env.dep_id); +}; + +let rec resolve_global = (~env, name) => { + switch (Hashtbl.find_opt(env.global_import_resolutions, name)) { + | Some(resolution) => resolve_global(~env, resolution) + | _ => name + }; }; -let get_wasm_imported_name = (~runtime_import=true, mod_, name) => { - if (runtime_import) { - // Mark runtime import as used - Ident_tbl.find(runtime_imports_tbl, name).mimp_used = - true; +let rec resolve_func = (~env, name) => { + switch (Hashtbl.find_opt(env.func_import_resolutions, name)) { + | Some(resolution) => resolve_func(~env, resolution) + | _ => name }; - Ident.unique_name(name); +}; + +let reset = () => { + reset_labels(); }; let get_runtime_heap_start = wasm_mod => - Expression.Global_get.make( - wasm_mod, - get_wasm_imported_name(grain_env_mod, runtime_heap_start), - Type.int32, - ); + Expression.Global_get.make(wasm_mod, runtime_heap_start_name, Type.int32); let get_metadata_ptr = wasm_mod => - Expression.Global_get.make( - wasm_mod, - get_wasm_imported_name(grain_env_mod, metadata_ptr), - Type.int32, - ); + Expression.Global_get.make(wasm_mod, metadata_ptr_name, Type.int32); let get_grain_imported_name = (mod_, name) => Ident.unique_name(name); @@ -317,17 +131,14 @@ let call_panic_handler = (wasm_mod, env, args) => { let args = [ Expression.Global_get.make( wasm_mod, - get_wasm_imported_name( - exception_mod, - panic_with_exception_closure_ident, - ), + resolve_global(~env, panic_with_exception_name), Type.int32, ), ...args, ]; Expression.Call.make( wasm_mod, - get_wasm_imported_name(exception_mod, panic_with_exception_ident), + resolve_func(~env, panic_with_exception_name), args, Type.int32, ); @@ -337,14 +148,14 @@ let call_malloc = (wasm_mod, env, args) => { let args = [ Expression.Global_get.make( wasm_mod, - get_wasm_imported_name(gc_mod, malloc_closure_ident), + resolve_global(~env, malloc_name), Type.int32, ), ...args, ]; Expression.Call.make( wasm_mod, - get_wasm_imported_name(gc_mod, malloc_ident), + resolve_func(~env, malloc_name), args, Type.int32, ); @@ -353,7 +164,7 @@ let call_incref = (wasm_mod, env, arg) => { let args = [ Expression.Global_get.make( wasm_mod, - get_wasm_imported_name(gc_mod, incref_closure_ident), + resolve_global(~env, incref_name), Type.int32, ), arg, @@ -363,7 +174,7 @@ let call_incref = (wasm_mod, env, arg) => { } else { Expression.Call.make( wasm_mod, - get_wasm_imported_name(gc_mod, incref_ident), + resolve_func(~env, incref_name), args, Type.int32, ); @@ -373,7 +184,7 @@ let call_decref = (wasm_mod, env, arg) => { let args = [ Expression.Global_get.make( wasm_mod, - get_wasm_imported_name(gc_mod, decref_closure_ident), + resolve_global(~env, decref_name), Type.int32, ), arg, @@ -383,7 +194,7 @@ let call_decref = (wasm_mod, env, arg) => { } else { Expression.Call.make( wasm_mod, - get_wasm_imported_name(gc_mod, decref_ident), + resolve_func(~env, decref_name), args, Type.int32, ); @@ -392,12 +203,12 @@ let call_decref = (wasm_mod, env, arg) => { let call_equal = (wasm_mod, env, args) => Expression.Call.make( wasm_mod, - get_wasm_imported_name(equal_mod, equal_ident), + resolve_func(~env, equal_name), [ call_incref(wasm_mod, env) @@ Expression.Global_get.make( wasm_mod, - get_wasm_imported_name(equal_mod, equal_closure_ident), + resolve_global(~env, equal_name), Type.int32, ), ...args, @@ -610,6 +421,7 @@ let compile_bind = | BindTee({value}) => tee_slot(slot, typ, value) }; | MGlobalBind(slot, wasm_ty) => + let slot = resolve_global(~env, linked_name(~env, slot)); let typ = wasm_type(wasm_ty); switch (action) { | BindGet => Expression.Global_get.make(wasm_mod, slot, typ) @@ -799,6 +611,8 @@ let rec compile_imm = (wasm_mod, env: codegen_env, i: immediate): Expression.t = call_incref(wasm_mod, env, compile_imm(wasm_mod, env, imm)) }; +let round_to_8 = n => Int.logand(n + 7, Int.lognot(7)); + /** Heap allocations. */ /** Rounds the given number of words to be aligned correctly */ @@ -810,14 +624,15 @@ let round_to_even = num_words => }; let heap_allocate = (wasm_mod, env, num_words: int) => - if (Env.is_runtime_mode()) { + switch (env.compilation_mode) { + | Runtime => let addition = Expression.Binary.make( wasm_mod, Op.add_int32, Expression.Global_get.make( wasm_mod, - get_wasm_imported_name(grain_env_mod, runtime_heap_next_ptr), + runtime_heap_next_ptr_name, Type.int32, ), Expression.Const.make( @@ -838,24 +653,19 @@ let heap_allocate = (wasm_mod, env, num_words: int) => wasm_mod, Expression.Global_get.make( wasm_mod, - get_wasm_imported_name( - grain_env_mod, - runtime_heap_next_ptr, - ), + runtime_heap_next_ptr_name, Type.int32, ), - // fake GC refcount of 1 - Expression.Const.make(wasm_mod, const_int32(1)), + // fake GC refcount of 2 + // this means objects (should) never drop to zero refcount + Expression.Const.make(wasm_mod, const_int32(2)), ), Expression.Binary.make( wasm_mod, Op.add_int32, Expression.Global_get.make( wasm_mod, - get_wasm_imported_name( - grain_env_mod, - runtime_heap_next_ptr, - ), + runtime_heap_next_ptr_name, Type.int32, ), Expression.Const.make(wasm_mod, const_int32(8)), @@ -868,7 +678,7 @@ let heap_allocate = (wasm_mod, env, num_words: int) => [ Expression.Global_set.make( wasm_mod, - get_wasm_imported_name(grain_env_mod, runtime_heap_next_ptr), + runtime_heap_next_ptr_name, addition, ), // Binaryen tuples must include a concrete value (and tuples are @@ -880,12 +690,12 @@ let heap_allocate = (wasm_mod, env, num_words: int) => ), 0, ); - } else { + | Normal => call_malloc( wasm_mod, env, [Expression.Const.make(wasm_mod, const_int32(4 * num_words))], - ); + ) }; type heap_allocation_type = @@ -1347,7 +1157,7 @@ let compile_record_op = (wasm_mod, env, rec_imm, op) => { let compile_closure_op = (wasm_mod, env, closure_imm, op) => { let closure = () => compile_imm(wasm_mod, env, closure_imm); switch (op) { - | MClosureSetPtr(idx) => + | MClosureSetPtr(global_offset, idx) => store( ~offset=8, wasm_mod, @@ -1357,7 +1167,7 @@ let compile_closure_op = (wasm_mod, env, closure_imm, op) => { Op.add_int32, Expression.Global_get.make( wasm_mod, - get_wasm_imported_name(grain_env_mod, reloc_base), + linked_name(~env, global_offset), Type.int32, ), Expression.Const.make(wasm_mod, wrap_int32(idx)), @@ -1387,6 +1197,7 @@ let call_lambda = let retty = Type.create @@ Array.map(wasm_type, Array.of_list(retty)); switch (known) { | Some(name) => + let name = resolve_func(~env, linked_name(~env, name)); let instr = if (tail) { if (Config.no_tail_call^) { @@ -1577,7 +1388,7 @@ let allocate_closure = env, ~lambda=?, ~skip_patching=false, - {func_idx, arity, variables} as closure_data, + {func_idx, global_offset, arity, variables} as closure_data, ) => { let num_free_vars = List.length(variables); let closure_size = num_free_vars + 4; @@ -1614,7 +1425,7 @@ let allocate_closure = Op.add_int32, Expression.Global_get.make( wasm_mod, - get_wasm_imported_name(grain_env_mod, reloc_base), + linked_name(~env, global_offset), Type.int32, ), Expression.Const.make(wasm_mod, wrap_int32(idx)), @@ -2648,13 +2459,19 @@ let compile_allocation = (wasm_mod, env, alloc_type) => allocate_float32( wasm_mod, env, - Expression.Const.make(wasm_mod, Literal.float32(i)), + Expression.Const.make( + wasm_mod, + Literal.float32(Int64.float_of_bits(i)), + ), ) | MFloat64(i) => allocate_float64( wasm_mod, env, - Expression.Const.make(wasm_mod, Literal.float64(i)), + Expression.Const.make( + wasm_mod, + Literal.float64(Int64.float_of_bits(i)), + ), ) | MBigInt({flags, limbs}) => allocate_big_int( @@ -2955,12 +2772,30 @@ and compile_instr = (wasm_mod, env, instr) => call_lambda(~tail=true, wasm_mod, env, func, func_type, args) | MCallRaw({func, func_type: (_, retty), args}) => let compiled_args = List.map(compile_imm(wasm_mod, env), args); - Expression.Call.make( - wasm_mod, - func, - compiled_args, - Type.create(Array.of_list(List.map(wasm_type, retty))), - ); + let func_name = linked_name(~env, func); + let resolved_name = resolve_func(~env, func_name); + if (resolved_name == func_name) { + // Name not resolved; call normally + Expression.Call.make( + wasm_mod, + func, + compiled_args, + Type.create(Array.of_list(List.map(wasm_type, retty))), + ); + } else { + // Raw function resolved to Grain function; inject closure argument + let closure_global = resolve_global(~env, func_name); + let closure_arg = + Expression.Global_get.make(wasm_mod, closure_global, Type.int32); + let compiled_args = [closure_arg, ...compiled_args]; + Expression.Call.make( + wasm_mod, + resolved_name, + compiled_args, + Type.create(Array.of_list(List.map(wasm_type, retty))), + ); + }; + | MIf(cond, thn, els) => let compiled_cond = compile_imm(wasm_mod, env, cond); let compiled_thn = compile_block(wasm_mod, env, thn); @@ -3137,6 +2972,7 @@ let compile_function = | Some(name) => name | None => Ident.unique_name(id) }; + let func_name = linked_name(~env, func_name); let body_env = { ...env, num_args: arity, @@ -3209,21 +3045,20 @@ let compile_function = if (Config.source_map^) { open Grain_parsing.Location; List.iter( - ((exp, loc)) => { + ((exp, loc)) => Function.set_debug_location( func_ref, exp, - 0, + env.func_debug_idx, loc.loc_start.pos_lnum, loc.loc_start.pos_cnum - loc.loc_start.pos_bol, - ) - }, + ), sources^, ); Function.set_debug_location( func_ref, body, - 0, + env.func_debug_idx, func_loc.loc_start.pos_lnum, func_loc.loc_start.pos_cnum - func_loc.loc_start.pos_bol, ); @@ -3253,8 +3088,7 @@ let compile_imports = (wasm_mod, env, {imports}) => { let internal_name = switch (mimp_kind) { | MImportGrain => get_grain_imported_name(mimp_mod, mimp_id) - | MImportWasm => - get_wasm_imported_name(~runtime_import=false, mimp_mod, mimp_id) + | MImportWasm => Ident.unique_name(mimp_id) }; switch (mimp_kind, mimp_type) { | (MImportGrain, MGlobalImport(ty, mut)) => @@ -3290,19 +3124,7 @@ let compile_imports = (wasm_mod, env, {imports}) => { }; }; - let imports = - List.append( - List.filter(({mimp_used}) => mimp_used, env.required_imports), - imports, - ); - List.iter(compile_import, imports); - Import.add_table_import( - wasm_mod, - grain_global_function_table, - grain_env_mod, - grain_global_function_table, - ); }; let compile_exports = (wasm_mod, env, {imports, exports, globals}) => { @@ -3310,19 +3132,15 @@ let compile_exports = (wasm_mod, env, {imports, exports, globals}) => { switch (export) { | WasmGlobalExport({ex_global_internal_name, ex_global_name}) => let ex_global_name = "GRAIN$EXPORT$" ++ ex_global_name; + let internal_name = linked_name(~env, ex_global_internal_name); + let resolved_name = resolve_global(~env, internal_name); ignore @@ - Export.add_global_export( - wasm_mod, - ex_global_internal_name, - ex_global_name, - ); + Export.add_global_export(wasm_mod, resolved_name, ex_global_name); | WasmFunctionExport({ex_function_internal_name, ex_function_name}) => + let internal_name = linked_name(~env, ex_function_internal_name); + let resolved_name = resolve_func(~env, internal_name); ignore @@ - Export.add_function_export( - wasm_mod, - ex_function_internal_name, - ex_function_name, - ) + Export.add_function_export(wasm_mod, resolved_name, ex_function_name); }; }; @@ -3352,33 +3170,33 @@ let compile_exports = (wasm_mod, env, {imports, exports, globals}) => { ); }; List.iteri(compile_export, exports); - ignore @@ Export.add_function_export(wasm_mod, grain_main, grain_main); - if (! Config.use_start_section^) { - ignore @@ Export.add_function_export(wasm_mod, grain_start, grain_start); - }; - ignore @@ - Export.add_global_export( - wasm_mod, - Ident.name(table_size), - Ident.name(table_size), - ); }; -let compile_tables = (wasm_mod, env, {function_table_elements}) => { +let compile_tables = + (wasm_mod, env, {function_table_elements, global_function_table_offset}) => { + let global_name = + linked_name(~env, Ident.unique_name(global_function_table_offset)); + let function_table_elements = + List.map( + elem => { + let name = linked_name(~env, elem); + resolve_func(~env, name); + }, + function_table_elements, + ); + let name = linked_name(~env, "elem"); + let global = Global.get_global(wasm_mod, global_name); + let offset = Global.get_init_expr(global); Table.add_active_element_segment( wasm_mod, grain_global_function_table, - "elem", + name, function_table_elements, - Expression.Global_get.make( - wasm_mod, - get_wasm_imported_name(grain_env_mod, reloc_base), - Type.int32, - ), + offset, ); }; -let compile_globals = (wasm_mod, env, {globals} as prog) => { +let compile_globals = (wasm_mod, env, {globals}) => { let initial_value = fun | Types.Managed @@ -3387,66 +3205,95 @@ let compile_globals = (wasm_mod, env, {globals} as prog) => { | Types.Unmanaged(WasmF32) => const_float32(0.) | Types.Unmanaged(WasmF64) => const_float64(0.); List.iter( - ((id, ty)) => + ({id, mutable_, allocation_type, initial_value: initial}) => { + let name = linked_name(~env, Ident.unique_name(id)); ignore @@ Global.add_global( wasm_mod, - Ident.unique_name(id), - wasm_type(ty), - true, - Expression.Const.make(wasm_mod, initial_value(ty)), - ), + name, + wasm_type(allocation_type), + mutable_, + switch (initial) { + | Some(initial) => + Expression.Const.make(wasm_mod, compile_const(initial)) + | None => + Expression.Const.make(wasm_mod, initial_value(allocation_type)) + }, + ); + }, globals, ); - ignore @@ - Global.add_global( - wasm_mod, - Ident.name(table_size), - Type.int32, - false, - Expression.Const.make( - wasm_mod, - const_int32(compute_table_size(env, prog)), - ), - ); }; let compile_main = (wasm_mod, env, prog) => { - ignore @@ - compile_function( - ~name=grain_main, - wasm_mod, - env, - { - id: Ident.create(grain_main), - name: Some(grain_main), - args: [], - return_type: [Types.Unmanaged(WasmI32)], - closure: None, - body: prog.main_body, - stack_size: prog.main_body_stack_size, - attrs: [], - func_loc: Grain_parsing.Location.dummy_loc, + let num_mains = List.length(prog.programs); + List.iteri( + (dep_id, {mash_code: prog}: mash_program) => { + let env = {...env, compilation_mode: prog.compilation_mode, dep_id}; + let compile = () => { + ignore @@ + compile_function( + ~name=grain_main, + wasm_mod, + env, + { + id: Ident.create(grain_main), + name: Some(grain_main), + args: [], + return_type: [Types.Unmanaged(WasmI32)], + closure: None, + body: prog.main_body, + stack_size: prog.main_body_stack_size, + attrs: [], + func_loc: Grain_parsing.Location.dummy_loc, + }, + ); + }; + switch (prog.compilation_mode) { + | Runtime => + Config.preserve_config(() => { + Config.no_gc := true; + compile(); + }) + | Normal => compile() + }; }, + prog.programs, ); - if (! Config.use_start_section^) { - ignore @@ + let starts = + List.init(num_mains, dep_id => + Expression.Drop.make( + wasm_mod, + Expression.Call.make( + wasm_mod, + Printf.sprintf("%s_%d", grain_main, dep_id), + [], + Type.int32, + ), + ) + ); + let start = Function.add_function( wasm_mod, grain_start, Type.none, Type.none, [||], - Expression.Drop.make( - wasm_mod, - Expression.Call.make(wasm_mod, grain_main, [], Type.int32), - ), + Expression.Block.make(wasm_mod, grain_start, starts), ); + if (Grain_utils.Config.use_start_section^) { + Function.set_start(wasm_mod, start); + } else { + ignore @@ + Export.add_function_export(wasm_mod, grain_start, Comp_utils.grain_start); }; }; -let compile_functions = (wasm_mod, env, {functions} as prog) => { - let handle_attrs = ({attrs} as func) => +let compile_functions = (wasm_mod, env, {functions, prog_loc}) => { + let func_debug_idx = + Module.add_debug_info_filename(wasm_mod, prog_loc.loc_start.pos_fname); + let handle_attrs = ({attrs, func_loc} as func) => { + let env = {...env, func_debug_idx}; if (List.exists( ({Grain_parsing.Location.txt}) => txt == Typedtree.Disable_gc, attrs, @@ -3458,8 +3305,116 @@ let compile_functions = (wasm_mod, env, {functions} as prog) => { } else { compile_function(wasm_mod, env, func); }; + }; ignore @@ List.map(handle_attrs, functions); - ignore @@ compile_main(wasm_mod, env, prog); +}; + +let compile_type_metadata = (wasm_mod, env, prog) => { + let metadata_tbl_data = + if (Config.elide_type_info^) { + None; + } else { + let metadata = + List.map( + prog => prog.Mashtree.signature.cmi_type_metadata, + prog.programs, + ); + Some(Type_metadata.construct_type_metadata_table(metadata)); + }; + let runtime_heap_ptr = + switch (Grain_utils.Config.memory_base^) { + | Some(x) => round_to_8(x) + | None => Grain_utils.Config.default_memory_base + }; + let metadata_heap_loc = runtime_heap_ptr + 8; + let metadata_size = + round_to_8( + Option.value(~default=0, Option.map(Bytes.length, metadata_tbl_data)), + ); + let runtime_heap_start = metadata_heap_loc + metadata_size; + + ignore @@ + Global.add_global( + wasm_mod, + runtime_heap_next_ptr_name, + Type.int32, + true, + Expression.Const.make( + wasm_mod, + Literal.int32(Int32.of_int(runtime_heap_start)), + ), + ); + + ignore @@ + Global.add_global( + wasm_mod, + runtime_heap_start_name, + Type.int32, + false, + Expression.Const.make( + wasm_mod, + Literal.int32(Int32.of_int(runtime_heap_start)), + ), + ); + + ignore @@ + Global.add_global( + wasm_mod, + metadata_ptr_name, + Type.int32, + false, + Expression.Const.make( + wasm_mod, + Literal.int32(Int32.of_int(metadata_heap_loc)), + ), + ); + + let (initial_memory, maximum_memory) = + switch (Config.initial_memory_pages^, Config.maximum_memory_pages^) { + | (initial_memory, Some(maximum_memory)) => ( + initial_memory, + maximum_memory, + ) + | (initial_memory, None) => (initial_memory, Memory.unlimited) + }; + + let data_segments = + switch (metadata_tbl_data) { + | Some(data) => [ + Memory.{ + data, + kind: + Active({ + offset: + Expression.Const.make( + wasm_mod, + Literal.int32(Int32.of_int(metadata_heap_loc)), + ), + }), + size: Bytes.length(data), + }, + ] + | None => [] + }; + Memory.set_memory( + wasm_mod, + initial_memory, + maximum_memory, + "memory", + data_segments, + false, + false, + Comp_utils.grain_memory, + ); + if (Config.import_memory^) { + Import.add_memory_import( + wasm_mod, + Comp_utils.grain_memory, + "env", + "memory", + false, + ); + }; }; exception WasmRunnerError(Module.t, option(string), string); @@ -3470,32 +3425,20 @@ let validate_module = (~name=?, wasm_mod: Module.t) => raise(WasmRunnerError(wasm_mod, name, "WARNING: Invalid module")) }; -let prepare = env => { - let required_imports = - if (Env.is_runtime_mode()) { - List.concat([required_global_imports, required_function_imports]); - } else { - runtime_imports; - }; - {...env, required_imports}; -}; - -let compile_wasm_module = (~env=?, ~name=?, prog) => { +let compile_wasm_module = + ( + ~name=?, + {global_import_resolutions, func_import_resolutions} as prog: Linkedtree.linked_program, + ) => { reset(); let env = - switch (env) { - | None => init_codegen_env(name) - | Some(e) => e - }; - let env = prepare(env); - let wasm_mod = Module.create(); - if (Config.source_map^) { - ignore @@ - Module.add_debug_info_filename( - wasm_mod, - Filepath.String.basename(Option.get(name)), + init_codegen_env( + ~global_import_resolutions, + ~func_import_resolutions, + name, ); - }; + let wasm_mod = Module.create(); + let default_features = [ Module.Feature.mvp, Module.Feature.multivalue, @@ -3517,19 +3460,20 @@ let compile_wasm_module = (~env=?, ~name=?, prog) => { Settings.set_low_memory_unused( Option.is_none(Grain_utils.Config.memory_base^), ); - let _ = - Memory.set_memory( - wasm_mod, - 0, - Memory.unlimited, - "memory", - [], - false, - false, - grain_memory, - ); - let compile_all = () => { + compile_type_metadata(wasm_mod, env, prog); + + ignore @@ + Table.add_table( + wasm_mod, + Comp_utils.grain_global_function_table, + prog.num_function_table_elements, + prog.num_function_table_elements, + Type.funcref, + ); + + let compile_one = (dep_id, prog: mash_code) => { + let env = {...env, dep_id, compilation_mode: prog.compilation_mode}; ignore @@ compile_globals(wasm_mod, env, prog); ignore @@ compile_functions(wasm_mod, env, prog); ignore @@ compile_exports(wasm_mod, env, prog); @@ -3537,29 +3481,22 @@ let compile_wasm_module = (~env=?, ~name=?, prog) => { ignore @@ compile_tables(wasm_mod, env, prog); }; - if (Env.is_runtime_mode()) { - Config.preserve_config(() => { - Config.no_gc := true; - compile_all(); - }); - } else { - compile_all(); - }; + List.iteri( + (dep_id, {mash_code: prog}) => { + switch (prog.compilation_mode) { + | Runtime => + Config.preserve_config(() => { + Config.no_gc := true; + compile_one(dep_id, prog); + }) + | Normal => compile_one(dep_id, prog) + } + }, + prog.programs, + ); - if (compiling_wasi_polyfill(name)) { - write_universal_exports( - wasm_mod, - prog.signature, - get_exported_names(wasm_mod), - ); - }; + ignore @@ compile_main(wasm_mod, env, prog); - let serialized_cmi = Cmi_format.serialize_cmi(prog.signature); - Module.add_custom_section( - wasm_mod, - "cmi", - Bytes.to_string(serialized_cmi), - ); validate_module(~name?, wasm_mod); switch (Config.profile^) { diff --git a/compiler/src/codegen/compcore.rei b/compiler/src/codegen/compcore.rei index 710e73680f..87f147b443 100644 --- a/compiler/src/codegen/compcore.rei +++ b/compiler/src/codegen/compcore.rei @@ -3,23 +3,11 @@ open Grain_middle_end; open Mashtree; open Binaryen; -type codegen_env = { - name: option(string), - num_args: int, - num_closure_args: int, - stack_size, - /* Allocated closures which need backpatching */ - backpatches: ref(list((Expression.t, closure_data))), - required_imports: list(import), -}; - -let init_codegen_env: option(string) => codegen_env; - exception WasmRunnerError(Module.t, option(string), string); let validate_module: (~name: string=?, Module.t) => unit; let compile_wasm_module: - (~env: codegen_env=?, ~name: string=?, Mashtree.mash_program) => Module.t; + (~name: string=?, Linkedtree.linked_program) => Module.t; let module_to_bytes: Module.t => bytes; diff --git a/compiler/src/codegen/compmod.re b/compiler/src/codegen/compmod.re index ec23619e5f..eefd0c2880 100644 --- a/compiler/src/codegen/compmod.re +++ b/compiler/src/codegen/compmod.re @@ -6,7 +6,7 @@ type compiled_program = { signature: Cmi_format.cmi_infos, }; -let compile_wasm_module = (~name=?, {Mashtree.signature} as mashprog) => { - let asm = Compcore.compile_wasm_module(~name?, mashprog); +let compile_wasm_module = (~name=?, {Linkedtree.signature} as linked_program) => { + let asm = Compcore.compile_wasm_module(~name?, linked_program); {asm, signature}; }; diff --git a/compiler/src/codegen/emitmod.re b/compiler/src/codegen/emitmod.re index c7e48d0c0f..d07d708987 100644 --- a/compiler/src/codegen/emitmod.re +++ b/compiler/src/codegen/emitmod.re @@ -1,8 +1,90 @@ open Grain_typed; open Grain_utils; -open Compmod; +open Mashtree; -let emit_module = ({asm, signature}, outfile) => { +/* + Grain object files follow this layout: + + | magic | version length | version | cmi length | cmi | mash_code | + | 0xF0 0x9F 0x8C 0xBE | 5 | 0.6.3 | 1024 | | | + */ + +type bad_object = + | InvalidMagic + | InvalidVersion + | Corrupted; + +exception BadObject(bad_object); + +let emit_object = (mashed: mash_program, outfile) => { + Grain_utils.Fs_access.ensure_parent_directory_exists(outfile); + if (Config.debug^) { + let mash_string = + Sexplib.Sexp.to_string_hum @@ Mashtree.sexp_of_mash_program(mashed); + let mashfile = Filepath.String.replace_extension(outfile, "mashtree"); + let oc = open_out(mashfile); + output_string(oc, mash_string); + close_out(oc); + }; + + let oc = open_out_bin(outfile); + + output_bytes(oc, Cmi_format.magic); + let version_length = String.length(Config.version); + output_binary_int(oc, version_length); + output_string(oc, Config.version); + let cmi = Marshal.to_bytes(mashed.signature, []); + output_binary_int(oc, Bytes.length(cmi)); + output_bytes(oc, cmi); + Marshal.to_channel(oc, mashed.mash_code, []); + + close_out(oc); +}; + +let load_object = (ic): mash_program => { + let read_magic = Bytes.create(4); + really_input(ic, read_magic, 0, 4); + if (read_magic != Cmi_format.magic) { + raise(BadObject(InvalidMagic)); + }; + let version_length = input_binary_int(ic); + let read_version = really_input_string(ic, version_length); + if (read_version != Config.version) { + raise(BadObject(InvalidVersion)); + }; + let cmi_length = input_binary_int(ic); + // JSOO messes up positioning when unmarshaling from a channel, so we read + // the CMI fully into memory to preserve the correct position for the code + let cmi_bytes = Bytes.create(cmi_length); + really_input(ic, cmi_bytes, 0, cmi_length); + let signature: Cmi_format.cmi_infos = + try(Marshal.from_bytes(cmi_bytes, 0)) { + | _ => raise(BadObject(Corrupted)) + }; + let mash_code: mash_code = + try(input_value(ic)) { + | _ => raise(BadObject(Corrupted)) + }; + + {signature, mash_code}; +}; +let load_object = object_file => { + let ic = open_in_bin(object_file); + let program = + try(load_object(ic)) { + | BadObject(_) as exn => + close_in(ic); + raise(exn); + | Failure(_) + | End_of_file => + close_in(ic); + raise(BadObject(Corrupted)); + }; + close_in(ic); + program; +}; + +let emit_binary = (asm, signature, outfile) => { Fs_access.ensure_parent_directory_exists(outfile); if (Config.debug^) { let sig_string = diff --git a/compiler/src/codegen/linkedtree.re b/compiler/src/codegen/linkedtree.re new file mode 100644 index 0000000000..1f9f005636 --- /dev/null +++ b/compiler/src/codegen/linkedtree.re @@ -0,0 +1,229 @@ +open Grain_typed; +open Grain_utils; +open Mashtree; + +type linked_program = { + programs: list(mash_program), + func_import_resolutions: Hashtbl.t(string, string), + global_import_resolutions: Hashtbl.t(string, string), + num_function_table_elements: int, + signature: Cmi_format.cmi_infos, +}; + +let stack_size_zero = { + stack_size_ptr: 0, + stack_size_i32: 0, + stack_size_i64: 0, + stack_size_f32: 0, + stack_size_f64: 0, +}; +let max_stack_size = (s1, s2) => { + { + stack_size_ptr: max(s1.stack_size_ptr, s2.stack_size_ptr), + stack_size_i32: max(s1.stack_size_i32, s2.stack_size_i32), + stack_size_i64: max(s1.stack_size_i64, s2.stack_size_i64), + stack_size_f32: max(s1.stack_size_f32, s2.stack_size_f32), + stack_size_f64: max(s1.stack_size_f64, s2.stack_size_f64), + }; +}; + +let wasi_module = "wasi_snapshot_preview1"; + +// Generates the name for the internal symbol. Symbols are scoped using the +// dependency ID for that module. +let internal_name = (id, dep_id) => { + Printf.sprintf("%s_%d", id, dep_id); +}; + +let link = main_mashtree => { + let main_module = Module_resolution.current_filename^(); + + let new_base_dir = Filepath.String.dirname; + + let resolve = (~base_dir=?, mod_name) => + Module_resolution.locate_unit_object_file(~base_dir?, mod_name); + + let wasi_polyfill = + Option.map( + Module_resolution.get_object_name, + Config.wasi_polyfill_path(), + ); + + let dependencies = Module_resolution.get_dependencies(); + let dependencies = + switch (wasi_polyfill) { + | Some(polyfill) => [polyfill, ...dependencies] + | None => dependencies + }; + + let rec resolve_implicit_modules = (acc, modules) => { + switch (modules) { + | [mod_, ...rest] => + switch (resolve(Config.get_implicit_filepath(mod_))) { + | file => resolve_implicit_modules([file, ...acc], rest) + | exception _ => resolve_implicit_modules(acc, rest) + } + | [] => acc + }; + }; + + let implicit_modules = + resolve_implicit_modules([], Config.all_implicit_opens); + + let func_import_resolutions = Hashtbl.create(2048); + let global_import_resolutions = Hashtbl.create(2048); + let func_export_resolutions = Hashtbl.create(2048); + let global_export_resolutions = Hashtbl.create(2048); + + let num_function_table_elements = ref(0); + + let dep_id = ref(0); + + let process_mashtree = (~main, dep, tree) => { + let table_offset_global = { + id: tree.mash_code.global_function_table_offset, + mutable_: false, + allocation_type: Types.Unmanaged(WasmI32), + initial_value: + Some( + MConstLiteral( + MConstI32(Int32.of_int(num_function_table_elements^)), + ), + ), + }; + + let globals = [table_offset_global, ...tree.mash_code.globals]; + + let imports = + List.fold_left( + (imports, import) => { + let process_import = resolved_module => { + let global = + Hashtbl.find_opt( + global_export_resolutions, + (resolved_module, import.mimp_name), + ); + let func = + Hashtbl.find_opt( + func_export_resolutions, + (resolved_module, import.mimp_name), + ); + let import_name = + Printf.sprintf( + "%s_%d", + Ident.unique_name(import.mimp_id), + dep_id^, + ); + Option.iter( + global => + Hashtbl.add(global_import_resolutions, import_name, global), + global, + ); + Option.iter( + func => Hashtbl.add(func_import_resolutions, import_name, func), + func, + ); + }; + + switch (import.mimp_kind) { + | MImportWasm => + switch (wasi_polyfill) { + | Some(polyfill) + when import.mimp_mod == wasi_module && dep != polyfill => + process_import(polyfill); + imports; + | _ => [import, ...imports] + } + | MImportGrain => + let resolved_module = + resolve(~base_dir=new_base_dir(dep), import.mimp_mod); + process_import(resolved_module); + imports; + }; + }, + [], + tree.mash_code.imports, + ); + + List.iter( + export => { + switch (export) { + | WasmFunctionExport({ex_function_name, ex_function_internal_name}) => + let internal_name = + internal_name(ex_function_internal_name, dep_id^); + Hashtbl.add( + func_export_resolutions, + (dep, ex_function_name), + internal_name, + ); + + if (List.mem(dep, implicit_modules)) { + Hashtbl.add( + func_import_resolutions, + Ident.unique_name(Ident.create_persistent(ex_function_name)), + internal_name, + ); + }; + | WasmGlobalExport({ex_global_name, ex_global_internal_name}) => + let internal_name = internal_name(ex_global_internal_name, dep_id^); + Hashtbl.add( + global_export_resolutions, + (dep, ex_global_name), + internal_name, + ); + + if (List.mem(dep, implicit_modules)) { + Hashtbl.add( + global_import_resolutions, + Ident.unique_name(Ident.create_persistent(ex_global_name)), + internal_name, + ); + }; + } + }, + tree.mash_code.exports, + ); + + let exports = + if (main) { + tree.mash_code.exports; + } else { + []; + }; + + num_function_table_elements := + num_function_table_elements^ + + List.length(tree.mash_code.function_table_elements); + + incr(dep_id); + + { + ...tree, + mash_code: { + ...tree.mash_code, + globals, + imports, + exports, + }, + }; + }; + + let programs = + List.rev_map( + dep => process_mashtree(~main=false, dep, Emitmod.load_object(dep)), + dependencies, + ); + + let main_program = process_mashtree(~main=true, main_module, main_mashtree); + let programs = List.rev([main_program, ...programs]); + let num_function_table_elements = num_function_table_elements^; + let signature = main_mashtree.signature; + + { + programs, + func_import_resolutions, + global_import_resolutions, + num_function_table_elements, + signature, + }; +}; diff --git a/compiler/src/codegen/mashtree.re b/compiler/src/codegen/mashtree.re index dd128ae416..3a208c927f 100644 --- a/compiler/src/codegen/mashtree.re +++ b/compiler/src/codegen/mashtree.re @@ -6,10 +6,7 @@ open Grain_typed; open Value_tags; open Runtime_errors; -/* OCaml floats are 64-bit - (see section 2.3: https://github.com/janestreet/janestreet.github.com/blob/009358427533b46ba2c66200779ea05a73ef0783/ocaml-perf-notes.md)*/ -type float32 = float; -type float64 = float; +let sexp_locs_disabled = _ => ! Grain_utils.Config.sexp_locs_enabled^; type tag_type = Value_tags.tag_type; type heap_tag_type = Value_tags.heap_tag_type; @@ -305,8 +302,12 @@ type constant = | MConstU16(int32) | MConstU32(int32) | MConstU64(int64) - | MConstF32(float) - | MConstF64(float) + /* + * jsoo cannot safely marshal floats into a consistent representation because + * of how JS numbers work; we work with the bits of the float instead. + */ + | MConstF32(int64) + | MConstF64(int64) | MConstChar(string) | MConstLiteral(constant); /* Special case for things which should not be encoded */ @@ -341,6 +342,7 @@ and last_usage = [@deriving sexp] type closure_data = { func_idx: option(int32), + global_offset: string, arity: int32, variables: list(immediate), }; @@ -359,8 +361,12 @@ type allocation_type = | MInt64(int64) | MUint32(int32) | MUint64(int64) - | MFloat32(float) - | MFloat64(float) + /* + * jsoo cannot safely marshal floats into a consistent representation because + * of how JS numbers work; we work with the bits of the float instead. + */ + | MFloat32(int64) + | MFloat64(int64) | MRational({ numerator_flags: list(Bigint_flags.t), numerator_limbs: array(int64), @@ -418,11 +424,12 @@ type record_op = [@deriving sexp] type closure_op = - | MClosureSetPtr(int32); + | MClosureSetPtr(string, int32); [@deriving sexp] type instr = { instr_desc, + [@sexp_drop_if sexp_locs_disabled] instr_loc: Location.t, } /* Optimized path for statically-known function names */ /* value, branches, default */ /* Items in the same list have their backpatching delayed until the end of that list */ /* Ignore the result of an expression. Used for sequences. */ /* Prints a message to the console; for compiler debugging */ [@deriving sexp] @@ -531,6 +538,7 @@ type mash_function = { body: block, stack_size, attrs: attributes, + [@sexp_drop_if sexp_locs_disabled] func_loc: Location.t, } and stack_size = { @@ -543,15 +551,30 @@ and stack_size = { [@deriving sexp] type mash_program = { + mash_code, + signature: [@sexp.opaque] Cmi_format.cmi_infos, +} + +and mash_code = { functions: list(mash_function), imports: list(import), exports: list(export), main_body: block, main_body_stack_size: stack_size, - globals: list((Ident.t, Types.allocation_type)), + globals: list(mash_global), function_table_elements: list(string), - signature: Cmi_format.cmi_infos, - type_metadata: list(Types.type_metadata), + global_function_table_offset: Ident.t, + compilation_mode: Grain_utils.Config.compilation_mode, + type_metadata: [@sexp.opaque] list(Types.type_metadata), + [@sexp_drop_if sexp_locs_disabled] + prog_loc: Location.t, +} + +and mash_global = { + id: Ident.t, + mutable_: bool, + allocation_type: Types.allocation_type, + initial_value: option(constant), }; let const_true = MConstLiteral(MConstI32(Int32.of_int(0xFFFFFFFE))); diff --git a/compiler/src/codegen/transl_anf.re b/compiler/src/codegen/transl_anf.re index c11356c85f..8ceab4a9a5 100644 --- a/compiler/src/codegen/transl_anf.re +++ b/compiler/src/codegen/transl_anf.re @@ -38,12 +38,17 @@ let compilation_worklist: Queue.t(worklist_elt) = Queue.create(); let function_table_index = ref(0); let function_table_idents = ref([]); +let function_table_global = ref(Ident.create("function_table_global")); let reset_function_table_info = () => { function_table_index := 0; function_table_idents := []; + function_table_global := Ident.create("function_table_global"); }; +let get_function_table_global_name = () => + Ident.unique_name(function_table_global^); + type function_ident = | FuncId(Ident.t) | FuncName(string); @@ -79,7 +84,15 @@ let set_global_imports = imports => { let global_table = ref(Ident.empty: Ident.tbl(Types.allocation_type)); let get_globals = () => { - Ident.fold_all((id, ty, acc) => [(id, ty), ...acc], global_table^, []); + Ident.fold_all( + (id, ty, acc) => + [ + {id, mutable_: true, allocation_type: ty, initial_value: None}, + ...acc, + ], + global_table^, + [], + ); }; let reset_global = () => { @@ -170,12 +183,12 @@ let compile_const = (c: Asttypes.constant) => | Const_uint16(u16) => MConstU16(u16) | Const_uint32(u32) => MConstU32(u32) | Const_uint64(u64) => MConstU64(u64) - | Const_float32(f) => MConstF32(f) - | Const_float64(f) => MConstF64(f) + | Const_float32(f) => MConstF32(Int64.bits_of_float(f)) + | Const_float64(f) => MConstF64(Int64.bits_of_float(f)) | Const_wasmi32(i32) => MConstLiteral(MConstI32(i32)) | Const_wasmi64(i64) => MConstLiteral(MConstI64(i64)) - | Const_wasmf32(f32) => MConstLiteral(MConstF32(f32)) - | Const_wasmf64(f64) => MConstLiteral(MConstF64(f64)) + | Const_wasmf32(f32) => MConstLiteral(MConstF32(Int64.bits_of_float(f32))) + | Const_wasmf64(f64) => MConstLiteral(MConstF64(Int64.bits_of_float(f64))) | Const_char(c) => MConstChar(c) | Const_bool(b) when b == true => const_true | Const_bool(_) => const_false @@ -297,6 +310,7 @@ let compile_lambda = if (Option.is_some(closure) || Analyze_function_calls.has_indirect_call(id)) { Some({ func_idx, + global_offset: get_function_table_global_name(), arity: Int32.of_int(arity), /* These variables should be in scope when the lambda is constructed. */ variables: @@ -373,7 +387,12 @@ let compile_wrapper = loc: Location.dummy_loc, }; worklist_enqueue(worklist_item); - {func_idx, arity: Int32.of_int(arity + 1), variables: []}; + { + func_idx, + global_offset: get_function_table_global_name(), + arity: Int32.of_int(arity + 1), + variables: [], + }; }; let get_global = (id, ty) => { @@ -489,7 +508,8 @@ let rec compile_comp = (~id=?, env, c) => { when n <= Literals.simple_number_max && n >= Literals.simple_number_min => MImmediate(imm(MImmConst(MConstI32(Int64.to_int32(n))))) | CNumber(Const_number_int(n)) => MAllocate(MInt64(n)) - | CNumber(Const_number_float(f)) => MAllocate(MFloat64(f)) + | CNumber(Const_number_float(f)) => + MAllocate(MFloat64(Int64.bits_of_float(f))) | CNumber( Const_number_rational({ rational_negative, @@ -527,8 +547,8 @@ let rec compile_comp = (~id=?, env, c) => { | CInt64(i) => MAllocate(MInt64(i)) | CUint32(i) => MAllocate(MUint32(i)) | CUint64(i) => MAllocate(MUint64(i)) - | CFloat32(f) => MAllocate(MFloat32(f)) - | CFloat64(f) => MAllocate(MFloat64(f)) + | CFloat32(f) => MAllocate(MFloat32(Int64.bits_of_float(f))) + | CFloat64(f) => MAllocate(MFloat64(Int64.bits_of_float(f))) | CGetTupleItem(idx, tup) => MTupleOp(MTupleGet(idx), compile_imm(env, tup)) | CSetTupleItem(idx, tup, value) => @@ -745,7 +765,10 @@ let lift_imports = (env, imports) => { { instr_desc: MClosureOp( - MClosureSetPtr(Int32.of_int(idx)), + MClosureSetPtr( + get_function_table_global_name(), + Int32.of_int(idx), + ), imm( MImmBinding( MGlobalBind( @@ -773,6 +796,8 @@ let lift_imports = (env, imports) => { MAllocate( MClosure({ func_idx: Some(Int32.of_int(idx)), + global_offset: + get_function_table_global_name(), arity: Int32.of_int(List.length(args)), variables: [], }), @@ -934,15 +959,11 @@ let transl_signature = (~functions, ~imports, signature) => { let func_map = Ident_tbl.create(30); List.iter( (func: mash_function) => - switch (func.name) { - | Some(name) => - Ident_tbl.add( - func_map, - func.id, - (Ident.unique_name(func.id), Option.is_some(func.closure)), - ) - | None => () - }, + Ident_tbl.add( + func_map, + func.id, + (Ident.unique_name(func.id), Option.is_some(func.closure)), + ), functions, ); List.iter( @@ -1093,16 +1114,23 @@ let transl_anf_program = ); let globals = get_globals(); let function_table_elements = get_function_table_idents(); + let global_function_table_offset = function_table_global^; + let compilation_mode = Config.compilation_mode^; { - functions, - imports, - exports, - main_body, - main_body_stack_size, - globals, - function_table_elements, signature, - type_metadata: anf_prog.type_metadata, + mash_code: { + functions, + imports, + exports, + main_body, + main_body_stack_size, + globals, + function_table_elements, + global_function_table_offset, + compilation_mode, + type_metadata: anf_prog.type_metadata, + prog_loc: anf_prog.prog_loc, + }, }; }; diff --git a/compiler/src/codegen/type_metadata.re b/compiler/src/codegen/type_metadata.re new file mode 100644 index 0000000000..7ad47eaacf --- /dev/null +++ b/compiler/src/codegen/type_metadata.re @@ -0,0 +1,101 @@ +open Grain_typed; +open Cmi_format; + +let construct_type_metadata_table = metas => { + // Create a hash table mapping "type hashes" unique to each Grain type to + // offsets in the metadata section + + // Structure: + // | Hash table: array of (offset into mappings data, bucket size) for each hash (type_hash % num_buckets) + // | Mappings: arrays of (type_hash, offset into actual metadata table) for each hash table bucket + // | Metadata: actual metadata content; appropriate offset for type metadata found through table data + let exceptions_buf = Buffer.create(256); + let exception_metas = List.map(m => m.ctm_exceptions, metas); + let exceptions_section_len = + List.fold_left((len, e) => String.length(e) + len, 0, exception_metas) + + 4; + Buffer.add_int32_le(exceptions_buf, Int32.of_int(exceptions_section_len)); + List.iter(Buffer.add_string(exceptions_buf), exception_metas); + + let exception_meta = (Buffer.contents(exceptions_buf), [(0, 0)]); + let non_exception_metas = + List.map(m => (m.ctm_metadata, m.ctm_offsets_tbl), metas); + let metas = [exception_meta, ...non_exception_metas]; + + let metadata_buf = Buffer.create(256); + let curr_offset = ref(0); + let hash_to_offset = + List.flatten( + List.map( + ((meta, offsets_tbl)) => { + Buffer.add_string(metadata_buf, meta); + let padding_bytes = String.length(meta) mod 8; + for (_ in 1 to padding_bytes) { + Buffer.add_int8(metadata_buf, 0); + }; + let hash_to_offset = + List.map( + ((hash, offset)) => (hash, offset + curr_offset^), + offsets_tbl, + ); + curr_offset := curr_offset^ + String.length(meta) + padding_bytes; + hash_to_offset; + }, + metas, + ), + ); + let rec next_pow_of_2 = (num, res) => + if (num <= 1) { + 1 lsl res; + } else { + next_pow_of_2(num lsr 1, res + 1); + }; + let num_entries = List.length(hash_to_offset); + // Choose number of buckets to be the greatest power of 2 <= # table entries + // (limit 4K) as a memory/lookup speed tradeoff (expect 1-2 entries/bucket) + let num_buckets = min(4096, next_pow_of_2(num_entries, 0)); + let buckets = Array.make(num_buckets, []); + List.iter( + ((hash, _) as hash_and_offset) => { + let hash_hash = hash mod num_buckets; + buckets[hash_hash] = [hash_and_offset, ...buckets[hash_hash]]; + }, + hash_to_offset, + ); + for (i in 0 to num_buckets - 1) { + buckets[i] = List.rev(buckets[i]); + }; + + let tbl_buckets_buf = Buffer.create(num_buckets * 8); + let tbl_vals_buf = Buffer.create(num_entries * 8); + // Store the number of buckets at the beginning of the metadata section + Buffer.add_int32_le(tbl_buckets_buf, Int32.of_int(num_buckets)); + // For 8-byte alignment + Buffer.add_int32_le(tbl_buckets_buf, 0l); + + // # buckets + buckets + data (2 i32s each) + let tbl_size = 8 + (num_buckets + num_entries) * 8; + // Initialize offset to point after the table buckets + let tbl_data_offset = ref(8 + num_buckets * 8); + Array.iter( + hash_to_offset => { + Buffer.add_int32_le(tbl_buckets_buf, Int32.of_int(tbl_data_offset^)); + Buffer.add_int32_le( + tbl_buckets_buf, + Int32.of_int(List.length(hash_to_offset)), + ); + List.iter( + ((hash, offset)) => { + Buffer.add_int32_le(tbl_vals_buf, Int32.of_int(hash)); + Buffer.add_int32_le(tbl_vals_buf, Int32.of_int(offset + tbl_size)); + tbl_data_offset := tbl_data_offset^ + 8; + }, + hash_to_offset, + ); + }, + buckets, + ); + Buffer.add_buffer(tbl_buckets_buf, tbl_vals_buf); + Buffer.add_buffer(tbl_buckets_buf, metadata_buf); + Buffer.to_bytes(tbl_buckets_buf); +}; diff --git a/compiler/src/compile.re b/compiler/src/compile.re index 14a1aed29f..e70dd5a949 100644 --- a/compiler/src/compile.re +++ b/compiler/src/compile.re @@ -2,7 +2,6 @@ open Grain_parsing; open Grain_typed; open Grain_middle_end; open Grain_codegen; -open Grain_linking; open Grain_utils; open Optimize; @@ -20,15 +19,16 @@ type compilation_state_desc = | Linearized(Anftree.anf_program) | Optimized(Anftree.anf_program) | Mashed(Mashtree.mash_program) + | ObjectEmitted(Mashtree.mash_program) + | ObjectsLinked(Linkedtree.linked_program) | Compiled(Compmod.compiled_program) - | ObjectFileEmitted(Compmod.compiled_program) - | Linked(Compmod.compiled_program) | Assembled; type compilation_state = { cstate_desc: compilation_state_desc, cstate_filename: option(string), - cstate_outfile: option(string), + cstate_object_outfile: option(string), + cstate_wasm_outfile: option(string), }; type compilation_action = @@ -41,13 +41,12 @@ type error = exception InlineFlagsError(Location.t, error); -let default_output_filename = name => name ++ ".wasm"; - +let default_wasm_filename = name => + Filepath.String.replace_extension(name, "wasm"); +let default_object_filename = name => + Filepath.String.replace_extension(name, "gro"); let default_mashtree_filename = name => - Filepath.String.remove_extension(name) ++ ".mashtree"; - -let compile_prog = p => - Compcore.module_to_bytes @@ Compcore.compile_wasm_module(p); + Filepath.String.replace_extension(name, "mashtree"); let save_mashed = (mashed, outfile) => { switch (outfile) { @@ -94,9 +93,11 @@ let log_state = state => | Mashed(mashed) => prerr_string("\nMashed program:\n"); prerr_sexp(Mashtree.sexp_of_mash_program, mashed); + | ObjectEmitted(mashed) => + prerr_string("\nMashfile emitted successfully") + | ObjectsLinked(linked) => + prerr_string("\nMashfiles linked successfully") | Compiled(compiled) => prerr_string("\nCompiled successfully") - | ObjectFileEmitted(compiled) => prerr_string("\nEmitted successfully") - | Linked(linked) => prerr_string("\nLinked successfully") | Assembled => prerr_string("\nAssembled successfully") }; prerr_string("\n\n"); @@ -148,6 +149,7 @@ let next_state = (~is_root_file=false, {cstate_desc, cstate_filename} as cs) => Grain_utils.Config.apply_attribute_flags( ~no_pervasives=has_attr("noPervasives"), ~runtime_mode=has_attr("runtimeMode"), + ~no_exception_mod=has_attr("noExceptions"), ); Well_formedness.check_well_formedness(p); @@ -171,22 +173,22 @@ let next_state = (~is_root_file=false, {cstate_desc, cstate_filename} as cs) => | Optimized(optimized) => let mashed = Transl_anf.transl_anf_program(optimized); if (Config.debug^) { - save_mashed(mashed, cs.cstate_outfile); + save_mashed(mashed, cs.cstate_object_outfile); }; Mashed(mashed); | Mashed(mashed) => - Compiled(Compmod.compile_wasm_module(~name=?cstate_filename, mashed)) - | Compiled(compiled) => - switch (cs.cstate_outfile) { - | Some(outfile) => Emitmod.emit_module(compiled, outfile) + switch (cs.cstate_object_outfile) { + | Some(outfile) => Emitmod.emit_object(mashed, outfile) | None => () }; - ObjectFileEmitted(compiled); - | ObjectFileEmitted(compiled) => - Linked(Linkmod.statically_link_wasm_module(compiled)) - | Linked(linked) => - switch (cs.cstate_outfile) { - | Some(outfile) => Emitmod.emit_module(linked, outfile) + ObjectEmitted(mashed); + | ObjectEmitted(mashed) => ObjectsLinked(Linkedtree.link(mashed)) + | ObjectsLinked(linked) => + Compiled(Compmod.compile_wasm_module(~name=?cstate_filename, linked)) + | Compiled(compiled) => + switch (cs.cstate_wasm_outfile) { + | Some(outfile) => + Emitmod.emit_binary(compiled.asm, compiled.signature, outfile) | None => () }; Assembled; @@ -250,18 +252,16 @@ let stop_after_mashed = | {cstate_desc: Mashed(_)} => Stop | s => Continue(s); -let stop_after_compiled = - fun - | {cstate_desc: Compiled(_)} => Stop - | s => Continue(s); -let stop_after_object_file_emitted = +let stop_after_object_emitted = fun - | {cstate_desc: ObjectFileEmitted(_)} => Stop + | {cstate_desc: ObjectEmitted(_)} => Stop | s => Continue(s); -let stop_after_linked = + +let stop_after_compiled = fun - | {cstate_desc: Linked(_)} => Stop + | {cstate_desc: Compiled(_)} => Stop | s => Continue(s); + let stop_after_assembled = fun | {cstate_desc: Assembled} => Stop @@ -275,12 +275,13 @@ let compile_wasi_polyfill = () => { let cstate = { cstate_desc: Initial(InputFile(file)), cstate_filename: Some(file), - cstate_outfile: Some(default_output_filename(file)), + cstate_wasm_outfile: Some(default_wasm_filename(file)), + cstate_object_outfile: Some(default_object_filename(file)), }; ignore( compile_resume( ~is_root_file=true, - ~hook=stop_after_object_file_emitted, + ~hook=stop_after_object_emitted, cstate, ), ); @@ -308,10 +309,12 @@ let compile_string = if (is_root_file) { Grain_utils.Config.set_root_config(); }; + Ident.setup(); let cstate = { cstate_desc: Initial(InputString(str)), cstate_filename: name, - cstate_outfile: outfile, + cstate_wasm_outfile: outfile, + cstate_object_outfile: Option.map(default_object_filename, outfile), }; Grain_utils.Config.preserve_all_configs(() => compile_resume(~is_root_file, ~hook?, cstate) @@ -327,10 +330,12 @@ let compile_file = if (is_root_file) { Grain_utils.Config.set_root_config(); }; + Ident.setup(); let cstate = { cstate_desc: Initial(InputFile(filename)), cstate_filename: Some(filename), - cstate_outfile: outfile, + cstate_wasm_outfile: outfile, + cstate_object_outfile: Option.map(default_object_filename, outfile), }; Grain_utils.Config.preserve_all_configs(() => compile_resume(~is_root_file, ~hook?, cstate) @@ -366,7 +371,7 @@ let () = ~is_root_file=false, ~outfile, ~reset=false, - ~hook=stop_after_object_file_emitted, + ~hook=stop_after_object_emitted, input, ), ) diff --git a/compiler/src/compile.rei b/compiler/src/compile.rei index 598ac3156e..0e1022af88 100644 --- a/compiler/src/compile.rei +++ b/compiler/src/compile.rei @@ -2,7 +2,6 @@ open Grain_parsing; open Grain_typed; open Grain_middle_end; open Grain_codegen; -open Grain_linking; type input_source = | InputString(string) @@ -18,15 +17,16 @@ type compilation_state_desc = | Linearized(Anftree.anf_program) | Optimized(Anftree.anf_program) | Mashed(Mashtree.mash_program) + | ObjectEmitted(Mashtree.mash_program) + | ObjectsLinked(Linkedtree.linked_program) | Compiled(Compmod.compiled_program) - | ObjectFileEmitted(Compmod.compiled_program) - | Linked(Compmod.compiled_program) | Assembled; type compilation_state = { cstate_desc: compilation_state_desc, cstate_filename: option(string), - cstate_outfile: option(string), + cstate_object_outfile: option(string), + cstate_wasm_outfile: option(string), }; type compilation_action = @@ -39,7 +39,8 @@ type error = exception InlineFlagsError(Location.t, error); -let default_output_filename: string => string; +let default_wasm_filename: string => string; +let default_object_filename: string => string; let stop_after_parse: compilation_state => compilation_action; @@ -55,11 +56,9 @@ let stop_after_optimization: compilation_state => compilation_action; let stop_after_mashed: compilation_state => compilation_action; -let stop_after_compiled: compilation_state => compilation_action; - -let stop_after_object_file_emitted: compilation_state => compilation_action; +let stop_after_object_emitted: compilation_state => compilation_action; -let stop_after_linked: compilation_state => compilation_action; +let stop_after_compiled: compilation_state => compilation_action; let stop_after_assembled: compilation_state => compilation_action; diff --git a/compiler/src/dune b/compiler/src/dune index 8a78f69fa7..38f06d2015 100644 --- a/compiler/src/dune +++ b/compiler/src/dune @@ -1,8 +1,8 @@ (library (name grain) (public_name grain) - (libraries cmdliner compiler-libs.common grain_codegen grain_linking - grain_middle_end grain_parsing grain_typed grain_utils grain_diagnostics + (libraries cmdliner compiler-libs.common grain_codegen grain_middle_end + grain_parsing grain_typed grain_utils grain_diagnostics ppx_sexp_conv.runtime-lib sexplib) (preprocess (pps ppx_sexp_conv))) diff --git a/compiler/src/linking/dune b/compiler/src/linking/dune deleted file mode 100644 index 14c09bc6c5..0000000000 --- a/compiler/src/linking/dune +++ /dev/null @@ -1,8 +0,0 @@ -(library - (name grain_linking) - (public_name grain_linking) - (synopsis "The Grain linker") - (libraries compiler-libs.common grain_codegen grain_utils - ppx_sexp_conv.runtime-lib sexplib ocamlgraph binaryen) - (preprocess - (pps ppx_sexp_conv))) diff --git a/compiler/src/linking/link.re b/compiler/src/linking/link.re deleted file mode 100644 index 15a008ba78..0000000000 --- a/compiler/src/linking/link.re +++ /dev/null @@ -1,824 +0,0 @@ -open Grain_codegen; -open Compmod; -open Grain_typed; -open Grain_utils; -open Cmi_format; -open Binaryen; - -let modules: Hashtbl.t(string, Module.t) = Hashtbl.create(10); -let hard_dependencies: Hashtbl.t(string, unit) = Hashtbl.create(10); - -let grain_module_name = mod_name => { - // Remove GRAIN$MODULE$ - Str.string_after(mod_name, 13); -}; - -let resolve = (~base_dir=?, mod_name) => { - let mod_name = grain_module_name(mod_name); - Module_resolution.locate_unit_object_file(~base_dir?, mod_name); -}; - -let load_module = fullpath => { - let ic = open_in_bin(fullpath); - let length = in_channel_length(ic); - let module_bytes = Bytes.create(length); - really_input(ic, module_bytes, 0, length); - close_in(ic); - Module.read(module_bytes); -}; - -let is_grain_module = mod_name => { - Str.string_match(Str.regexp_string("GRAIN$MODULE$"), mod_name, 0); -}; - -let wasi_polyfill_module = () => - Option.get(Config.wasi_polyfill_path()) ++ ".wasm"; - -let is_wasi_module = mod_name => { - mod_name == "wasi_snapshot_preview1"; -}; - -let is_wasi_polyfill_module = mod_path => { - mod_path == wasi_polyfill_module(); -}; - -let runtime_heap_next_ptr = "GRAIN$RUNTIME_HEAP_NEXT_PTR"; - -let new_base_dir = Filepath.String.dirname; - -let rec load_hard_dependencies = (~base_dir, mod_path) => { - let wasm_mod = Hashtbl.find(modules, mod_path); - let num_globals = Global.get_num_globals(wasm_mod); - for (i in 0 to num_globals - 1) { - let global = Global.get_global_by_index(wasm_mod, i); - let imported_module = Import.global_import_get_module(global); - if (is_grain_module(imported_module)) { - let resolved_import = resolve(~base_dir, imported_module); - Hashtbl.add(hard_dependencies, resolved_import, ()); - if (!Hashtbl.mem(modules, resolved_import)) { - Hashtbl.add(modules, resolved_import, load_module(resolved_import)); - load_hard_dependencies( - ~base_dir=new_base_dir(resolved_import), - resolved_import, - ); - }; - }; - }; - let num_funcs = Function.get_num_functions(wasm_mod); - let has_wasi_polyfill = Option.is_some(Config.wasi_polyfill^); - for (i in 0 to num_funcs - 1) { - let func = Function.get_function_by_index(wasm_mod, i); - let imported_module = Import.function_import_get_module(func); - if (is_grain_module(imported_module)) { - let resolved_import = resolve(~base_dir, imported_module); - Hashtbl.add(hard_dependencies, resolved_import, ()); - if (!Hashtbl.mem(modules, resolved_import)) { - Hashtbl.add(modules, resolved_import, load_module(resolved_import)); - load_hard_dependencies( - ~base_dir=new_base_dir(resolved_import), - resolved_import, - ); - }; - } else if (has_wasi_polyfill - && is_wasi_module(imported_module) - && !is_wasi_polyfill_module(mod_path)) { - // Perform any WASI polyfilling. Note that we skip this step if we are compiling the polyfill module itself. - let imported_module = wasi_polyfill_module(); - Hashtbl.add(hard_dependencies, imported_module, ()); - if (!Hashtbl.mem(modules, imported_module)) { - Hashtbl.add(modules, imported_module, load_module(imported_module)); - load_hard_dependencies( - ~base_dir=new_base_dir(imported_module), - imported_module, - ); - }; - }; - }; -}; - -let gensym_counter = ref(0); -let gensym = name => { - incr(gensym_counter); - Printf.sprintf("%s.linked.%d", name, gensym_counter^); -}; - -let exported_names: Hashtbl.t(string, Hashtbl.t(string, string)) = - Hashtbl.create(10); - -let is_global_imported = global => - Import.global_import_get_base(global) != ""; -let is_function_imported = func => - Import.function_import_get_base(func) != ""; - -// NOTE: A Not_found being raised in the below function likely means that there -// is more than one place in the Binaryen program which has the same -// subexpression (in an identity equality sense). The substitution -// probably succeeded the first time the subexpression was found, but, -// because this process is not idempotent, failed on the second time. The fix -// for this problem is to produce two separate expression instances when -// constructing the AST (either through constructing two separate instances or by -// using Expression.copy()) - -let rec globalize_names = (~function_names, ~global_names, ~label_names, expr) => { - let globalize_names = - globalize_names(~function_names, ~global_names, ~label_names); - - let add_label = Hashtbl.add(label_names); - - let find_function = Hashtbl.find(function_names); - let find_global = Hashtbl.find(global_names); - let find_label = Hashtbl.find(label_names); - - let kind = Expression.get_kind(expr); - switch (kind) { - | Invalid => failwith("Invalid expression") - | Nop => () - | Block => - let internal_name = Expression.Block.get_name(expr); - Option.iter( - internal_name => { - let new_name = gensym(internal_name); - add_label(internal_name, new_name); - - Expression.Block.set_name(expr, new_name); - }, - internal_name, - ); - - let num_children = Expression.Block.get_num_children(expr); - for (i in 0 to num_children - 1) { - globalize_names(Expression.Block.get_child_at(expr, i)); - }; - | If => - globalize_names(Expression.If.get_condition(expr)); - globalize_names(Expression.If.get_if_true(expr)); - Option.iter(globalize_names, Expression.If.get_if_false(expr)); - | Loop => - let internal_name = Expression.Loop.get_name(expr); - let new_name = gensym(internal_name); - add_label(internal_name, new_name); - - Expression.Loop.set_name(expr, new_name); - - globalize_names(Expression.Loop.get_body(expr)); - | Break => - let internal_name = Expression.Break.get_name(expr); - Expression.Break.set_name(expr, find_label(internal_name)); - - Option.iter(globalize_names, Expression.Break.get_condition(expr)); - Option.iter(globalize_names, Expression.Break.get_value(expr)); - | Switch => - let num_names = Expression.Switch.get_num_names(expr); - for (i in 0 to num_names - 1) { - let internal_name = Expression.Switch.get_name_at(expr, i); - Expression.Switch.set_name_at(expr, i, find_label(internal_name)); - }; - - let internal_default_name = Expression.Switch.get_default_name(expr); - Option.iter( - name => Expression.Switch.set_default_name(expr, find_label(name)), - internal_default_name, - ); - - globalize_names(Expression.Switch.get_condition(expr)); - Option.iter(globalize_names, Expression.Switch.get_value(expr)); - | Call => - let internal_name = Expression.Call.get_target(expr); - Expression.Call.set_target(expr, find_function(internal_name)); - - let num_operands = Expression.Call.get_num_operands(expr); - for (i in 0 to num_operands - 1) { - globalize_names(Expression.Call.get_operand_at(expr, i)); - }; - | CallIndirect => - globalize_names(Expression.Call_indirect.get_target(expr)); - - Expression.Call_indirect.set_table( - expr, - Comp_utils.grain_global_function_table, - ); - - let num_operands = Expression.Call_indirect.get_num_operands(expr); - for (i in 0 to num_operands - 1) { - globalize_names(Expression.Call_indirect.get_operand_at(expr, i)); - }; - | LocalGet => () - | LocalSet => globalize_names(Expression.Local_set.get_value(expr)) - | GlobalGet => - let internal_name = Expression.Global_get.get_name(expr); - Expression.Global_get.set_name(expr, find_global(internal_name)); - | GlobalSet => - let internal_name = Expression.Global_set.get_name(expr); - Expression.Global_set.set_name(expr, find_global(internal_name)); - globalize_names(Expression.Global_set.get_value(expr)); - | Load => globalize_names(Expression.Load.get_ptr(expr)) - | Store => - globalize_names(Expression.Store.get_ptr(expr)); - globalize_names(Expression.Store.get_value(expr)); - | MemoryCopy => - globalize_names(Expression.Memory_copy.get_dest(expr)); - globalize_names(Expression.Memory_copy.get_source(expr)); - globalize_names(Expression.Memory_copy.get_size(expr)); - | MemoryFill => - globalize_names(Expression.Memory_fill.get_dest(expr)); - globalize_names(Expression.Memory_fill.get_value(expr)); - globalize_names(Expression.Memory_fill.get_size(expr)); - | Const => () - | Unary => globalize_names(Expression.Unary.get_value(expr)) - | Binary => - globalize_names(Expression.Binary.get_left(expr)); - globalize_names(Expression.Binary.get_right(expr)); - | Select => - globalize_names(Expression.Select.get_if_true(expr)); - globalize_names(Expression.Select.get_if_false(expr)); - globalize_names(Expression.Select.get_condition(expr)); - | Drop => globalize_names(Expression.Drop.get_value(expr)) - | Return => Option.iter(globalize_names, Expression.Return.get_value(expr)) - | MemorySize => () - | MemoryGrow => globalize_names(Expression.Memory_grow.get_delta(expr)) - | Unreachable => () - | TupleMake => - let num_operands = Expression.Tuple_make.get_num_operands(expr); - for (i in 0 to num_operands - 1) { - globalize_names(Expression.Tuple_make.get_operand_at(expr, i)); - }; - | TupleExtract => globalize_names(Expression.Tuple_extract.get_tuple(expr)) - | AtomicRMW - | AtomicCmpxchg - | AtomicWait - | AtomicNotify - | AtomicFence - | SIMDExtract - | SIMDReplace - | SIMDShuffle - | SIMDTernary - | SIMDShift - | SIMDLoad - | SIMDLoadStoreLane - | MemoryInit - | DataDrop - | Pop - | RefNull - | RefIs - | RefFunc - | RefEq - | Try - | Throw - | Rethrow - | I31New - | I31Get - | CallRef - | RefTest - | RefCast - | BrOn - | StructNew - | StructGet - | StructSet - | ArrayNew - | ArrayGet - | ArraySet - | ArrayLen - | RefAs => failwith("Linking NYI for wasm instruction") - }; -}; - -let construct_type_metadata_table = metas => { - // Create a hash table mapping "type hashes" unique to each Grain type to - // offsets in the metadata section - - // Structure: - // | Hash table: array of (offset into mappings data, bucket size) for each hash (type_hash % num_buckets) - // | Mappings: arrays of (type_hash, offset into actual metadata table) for each hash table bucket - // | Metadata: actual metadata content; appropriate offset for type metadata found through table data - let exceptions_buf = Buffer.create(256); - let exception_metas = List.map(m => m.ctm_exceptions, metas); - let exceptions_section_len = - List.fold_left((len, e) => String.length(e) + len, 0, exception_metas) - + 4; - Buffer.add_int32_le(exceptions_buf, Int32.of_int(exceptions_section_len)); - List.iter(Buffer.add_string(exceptions_buf), exception_metas); - - let exception_meta = (Buffer.contents(exceptions_buf), [(0, 0)]); - let non_exception_metas = - List.map(m => (m.ctm_metadata, m.ctm_offsets_tbl), metas); - let metas = [exception_meta, ...non_exception_metas]; - - let metadata_buf = Buffer.create(256); - let curr_offset = ref(0); - let hash_to_offset = - List.flatten( - List.map( - ((meta, offsets_tbl)) => { - Buffer.add_string(metadata_buf, meta); - let padding_bytes = String.length(meta) mod 8; - for (_ in 1 to padding_bytes) { - Buffer.add_int8(metadata_buf, 0); - }; - let hash_to_offset = - List.map( - ((hash, offset)) => (hash, offset + curr_offset^), - offsets_tbl, - ); - curr_offset := curr_offset^ + String.length(meta) + padding_bytes; - hash_to_offset; - }, - metas, - ), - ); - let rec next_pow_of_2 = (num, res) => - if (num <= 1) { - 1 lsl res; - } else { - next_pow_of_2(num lsr 1, res + 1); - }; - let num_entries = List.length(hash_to_offset); - // Choose number of buckets to be the greatest power of 2 <= # table entries - // (limit 4K) as a memory/lookup speed tradeoff (expect 1-2 entries/bucket) - let num_buckets = min(4096, next_pow_of_2(num_entries, 0)); - let buckets = Array.make(num_buckets, []); - List.iter( - ((hash, _) as hash_and_offset) => { - let hash_hash = hash mod num_buckets; - buckets[hash_hash] = [hash_and_offset, ...buckets[hash_hash]]; - }, - hash_to_offset, - ); - for (i in 0 to num_buckets - 1) { - buckets[i] = List.rev(buckets[i]); - }; - - let tbl_buckets_buf = Buffer.create(num_buckets * 8); - let tbl_vals_buf = Buffer.create(num_entries * 8); - // Store the number of buckets at the beginning of the metadata section - Buffer.add_int32_le(tbl_buckets_buf, Int32.of_int(num_buckets)); - // For 8-byte alignment - Buffer.add_int32_le(tbl_buckets_buf, 0l); - - // # buckets + buckets + data (2 i32s each) - let tbl_size = 8 + (num_buckets + num_entries) * 8; - // Initialize offset to point after the table buckets - let tbl_data_offset = ref(8 + num_buckets * 8); - Array.iter( - hash_to_offset => { - Buffer.add_int32_le(tbl_buckets_buf, Int32.of_int(tbl_data_offset^)); - Buffer.add_int32_le( - tbl_buckets_buf, - Int32.of_int(List.length(hash_to_offset)), - ); - List.iter( - ((hash, offset)) => { - Buffer.add_int32_le(tbl_vals_buf, Int32.of_int(hash)); - Buffer.add_int32_le(tbl_vals_buf, Int32.of_int(offset + tbl_size)); - tbl_data_offset := tbl_data_offset^ + 8; - }, - hash_to_offset, - ); - }, - buckets, - ); - Buffer.add_buffer(tbl_buckets_buf, tbl_vals_buf); - Buffer.add_buffer(tbl_buckets_buf, metadata_buf); - Buffer.to_bytes(tbl_buckets_buf); -}; - -let table_offset = ref(0); -let module_id = ref(Comp_utils.encoded_int32(0)); - -let round_to_8 = n => Int.logand(n + 7, Int.lognot(7)); - -let link_all = (linked_mod, dependencies, signature) => { - gensym_counter := 0; - table_offset := 0; - module_id := Comp_utils.encoded_int32(0); - - let main = Module_resolution.current_filename^(); - let has_wasi_polyfill = Option.is_some(Config.wasi_polyfill^); - - let metadata_tbl_data = - if (Config.elide_type_info^) { - None; - } else { - let cmis = List.map(Cmi_format.read_cmi, dependencies) @ [signature]; - let mds = List.map(x => x.cmi_type_metadata, cmis); - Some(construct_type_metadata_table(mds)); - }; - let runtime_heap_ptr = - switch (Grain_utils.Config.memory_base^) { - | Some(x) => round_to_8(x) - | None => Grain_utils.Config.default_memory_base - }; - let metadata_heap_loc = runtime_heap_ptr + 8; - let metadata_size = - round_to_8( - Option.value(~default=0, Option.map(Bytes.length, metadata_tbl_data)), - ); - let runtime_heap_start = metadata_heap_loc + metadata_size; - - let link_one = dep => { - let function_names: Hashtbl.t(string, string) = Hashtbl.create(128); - let global_names: Hashtbl.t(string, string) = Hashtbl.create(128); - let label_names: Hashtbl.t(string, string) = Hashtbl.create(128); - - let wasm_mod = - switch (Hashtbl.find_opt(modules, dep)) { - | Some(mod_) => mod_ - | None => load_module(dep) - }; - - let num_globals = Global.get_num_globals(wasm_mod); - for (i in 0 to num_globals - 1) { - let global = Global.get_global_by_index(wasm_mod, i); - if (is_global_imported(global)) { - let imported_module = Import.global_import_get_module(global); - if (is_grain_module(imported_module)) { - let imported_name = Import.global_import_get_base(global); - let internal_name = Global.get_name(global); - let new_name = - Hashtbl.find( - Hashtbl.find( - exported_names, - resolve(~base_dir=new_base_dir(dep), imported_module), - ), - imported_name, - ); - Hashtbl.add(global_names, internal_name, new_name); - } else { - let imported_name = Import.global_import_get_base(global); - let internal_name = Global.get_name(global); - let new_name = gensym(internal_name); - Hashtbl.add(global_names, internal_name, new_name); - - if (Comp_utils.is_grain_env(imported_module)) { - let value = - switch (imported_name) { - | "relocBase" => - Some( - Expression.Const.make( - wasm_mod, - Literal.int32(Int32.of_int(table_offset^)), - ), - ) - | "moduleRuntimeId" => - // Module id is tagged; incrementing by 2 is the equivalent of an untagged increment by 1 - module_id := module_id^ + 2; - Some( - Expression.Const.make( - wasm_mod, - Literal.int32(Int32.of_int(module_id^)), - ), - ); - | "runtimeHeapStart" => - Some( - Expression.Const.make( - wasm_mod, - Literal.int32(Int32.of_int(runtime_heap_start)), - ), - ) - | "runtimeHeapNextPtr" => - Hashtbl.replace( - global_names, - internal_name, - runtime_heap_next_ptr, - ); - None; - | "metadataPtr" => - Some( - Expression.Const.make( - wasm_mod, - Literal.int32(Int32.of_int(metadata_heap_loc)), - ), - ) - | value => - failwith( - Printf.sprintf("Unknown Grain runtime value `%s`", value), - ) - }; - switch (value) { - | Some(value) => - ignore @@ - Global.add_global( - linked_mod, - new_name, - Type.int32, - false, - value, - ) - | None => () - }; - } else { - let ty = Global.get_type(global); - let mut = Global.is_mutable(global); - Import.add_global_import( - linked_mod, - new_name, - imported_module, - imported_name, - ty, - mut, - ); - }; - }; - } else { - let internal_name = Global.get_name(global); - let new_name = gensym(internal_name); - Hashtbl.add(global_names, internal_name, new_name); - - let ty = Global.get_type(global); - let mut = Global.is_mutable(global); - let init = Global.get_init_expr(global); - - globalize_names(~function_names, ~global_names, ~label_names, init); - ignore @@ Global.add_global(linked_mod, new_name, ty, mut, init); - }; - }; - - let num_functions = Function.get_num_functions(wasm_mod); - let funcs = - List.init(num_functions, Function.get_function_by_index(wasm_mod)); - let (imported_funcs, funcs) = - List.partition(is_function_imported, funcs); - - List.iter( - func => { - let imported_module = Import.function_import_get_module(func); - if (is_grain_module(imported_module)) { - let imported_name = Import.function_import_get_base(func); - let internal_name = Function.get_name(func); - let new_name = - Hashtbl.find( - Hashtbl.find( - exported_names, - resolve(~base_dir=new_base_dir(dep), imported_module), - ), - imported_name, - ); - Hashtbl.add(function_names, internal_name, new_name); - } else if (has_wasi_polyfill - && is_wasi_module(imported_module) - && !is_wasi_polyfill_module(dep)) { - // Perform any WASI polyfilling. Note that we skip this step if we are compiling the polyfill module itself. - // If we are importing a foreign from WASI, then we swap it out for the foreign from the polyfill. - let imported_name = Import.function_import_get_base(func); - let internal_name = Function.get_name(func); - let wasi_polyfill = wasi_polyfill_module(); - let new_name = - Hashtbl.find_opt( - Hashtbl.find(exported_names, wasi_polyfill), - imported_name, - ); - let new_name = - switch (new_name) { - | Some(new_name) => new_name - | None => - failwith( - Printf.sprintf( - "Unable to locate `%s` in your polyfill. Required by `%s`", - imported_name, - dep, - ), - ) - }; - Hashtbl.add(function_names, internal_name, new_name); - } else { - let imported_name = Import.function_import_get_base(func); - let internal_name = Function.get_name(func); - let new_name = gensym(internal_name); - Hashtbl.add(function_names, internal_name, new_name); - - let params = Function.get_params(func); - let results = Function.get_results(func); - Import.add_function_import( - linked_mod, - new_name, - imported_module, - imported_name, - params, - results, - ); - }; - }, - imported_funcs, - ); - - // Register all function names first as functions may be recursive - List.iter( - func => { - let internal_name = Function.get_name(func); - let new_name = gensym(internal_name); - Hashtbl.add(function_names, internal_name, new_name); - }, - funcs, - ); - - List.iter( - func => { - let internal_name = Function.get_name(func); - let new_name = Hashtbl.find(function_names, internal_name); - - let params = Function.get_params(func); - let results = Function.get_results(func); - let num_locals = Function.get_num_vars(func); - let locals = Array.init(num_locals, i => Function.get_var(func, i)); - let body = Function.get_body(func); - globalize_names(~function_names, ~global_names, ~label_names, body); - ignore @@ - Function.add_function( - linked_mod, - new_name, - params, - results, - locals, - body, - ); - }, - funcs, - ); - - let local_exported_names = - Comp_utils.get_exported_names(~function_names, ~global_names, wasm_mod); - Hashtbl.add(exported_names, dep, local_exported_names); - - let num_element_segments = Table.get_num_element_segments(wasm_mod); - for (i in 0 to num_element_segments - 1) { - let segment = Table.get_element_segment_by_index(wasm_mod, i); - let name = Element_segment.get_name(segment); - let new_name = gensym(name); - let size = Element_segment.get_length(segment); - let elems = - List.init(size, i => - Hashtbl.find(function_names, Element_segment.get_data(segment, i)) - ); - ignore @@ - Table.add_active_element_segment( - linked_mod, - Comp_utils.grain_global_function_table, - new_name, - elems, - Expression.Const.make( - wasm_mod, - Literal.int32(Int32.of_int(table_offset^)), - ), - ); - table_offset := table_offset^ + size; - }; - }; - - ignore @@ - Global.add_global( - linked_mod, - runtime_heap_next_ptr, - Type.int32, - true, - Expression.Const.make( - linked_mod, - Literal.int32(Int32.of_int(runtime_heap_start)), - ), - ); - - if (has_wasi_polyfill) { - link_one(wasi_polyfill_module()); - }; - List.iter(link_one, dependencies); - link_one(main); - - Comp_utils.write_universal_exports( - linked_mod, - signature, - Hashtbl.find(exported_names, main), - ); - - ignore @@ - Table.add_table( - linked_mod, - Comp_utils.grain_global_function_table, - table_offset^, - table_offset^, - Type.funcref, - ); - - let (initial_memory, maximum_memory) = - switch (Config.initial_memory_pages^, Config.maximum_memory_pages^) { - | (initial_memory, Some(maximum_memory)) => ( - initial_memory, - maximum_memory, - ) - | (initial_memory, None) => (initial_memory, Memory.unlimited) - }; - - let data_segments = - switch (metadata_tbl_data) { - | Some(data) => [ - Memory.{ - data, - kind: - Active({ - offset: - Expression.Const.make( - linked_mod, - Literal.int32(Int32.of_int(metadata_heap_loc)), - ), - }), - size: Bytes.length(data), - }, - ] - | None => [] - }; - Memory.set_memory( - linked_mod, - initial_memory, - maximum_memory, - "memory", - data_segments, - false, - false, - Comp_utils.grain_memory, - ); - if (Config.import_memory^) { - Import.add_memory_import( - linked_mod, - Comp_utils.grain_memory, - "env", - "memory", - false, - ); - }; - - let starts = - List.filter_map( - dep => - if (Hashtbl.mem(hard_dependencies, dep)) { - let call_main = - Expression.Drop.make( - linked_mod, - Expression.Call.make( - linked_mod, - Hashtbl.find( - Hashtbl.find(exported_names, dep), - Comp_utils.grain_main, - ), - [], - Type.int32, - ), - ); - Some(call_main); - } else { - None; - }, - dependencies @ [main], - ); - - let start_name = gensym(Comp_utils.grain_start); - let start = - Function.add_function( - linked_mod, - start_name, - Type.none, - Type.none, - [||], - Expression.Block.make(linked_mod, gensym("start"), starts), - ); - - if (Grain_utils.Config.use_start_section^) { - Function.set_start(linked_mod, start); - } else { - ignore @@ - Export.add_function_export(linked_mod, start_name, Comp_utils.grain_start); - }; -}; - -let link_modules = ({asm: wasm_mod, signature}) => { - Hashtbl.clear(modules); - Hashtbl.clear(hard_dependencies); - - let main_module = Module_resolution.current_filename^(); - Hashtbl.add(modules, main_module, wasm_mod); - Hashtbl.add(hard_dependencies, main_module, ()); - - load_hard_dependencies( - ~base_dir=Filepath.String.dirname(main_module), - main_module, - ); - - let dependencies = Module_resolution.get_dependencies(); - - let linked_mod = Module.create(); - link_all(linked_mod, dependencies, signature); - - let features = Module.get_features(wasm_mod); - let _ = Module.set_features(linked_mod, features); - // we set low_memory_unused := true iff the user has not specified a memory base. - // This is because in many use cases in which this is specified (e.g. wasm4), users - // will expect the static region of memory below the heap base to all be available. - let _ = - Settings.set_low_memory_unused( - Option.is_none(Grain_utils.Config.memory_base^), - ); - if (Module.validate(linked_mod) != 1) { - failwith("Generated invalid linked module"); - }; - switch (Config.profile^) { - | Some(Release) => Optimize_mod.optimize(linked_mod) - | None => () - }; - linked_mod; -}; diff --git a/compiler/src/linking/linkmod.re b/compiler/src/linking/linkmod.re deleted file mode 100644 index 3d7eba186d..0000000000 --- a/compiler/src/linking/linkmod.re +++ /dev/null @@ -1,6 +0,0 @@ -open Grain_codegen; - -let statically_link_wasm_module = prog => { - let linked_asm = Link.link_modules(prog); - {...prog, asm: linked_asm}; -}; diff --git a/compiler/src/middle_end/anftree.re b/compiler/src/middle_end/anftree.re index 4a03ce2124..c59aedb8f0 100644 --- a/compiler/src/middle_end/anftree.re +++ b/compiler/src/middle_end/anftree.re @@ -457,6 +457,7 @@ type anf_program = { signature: Cmi_format.cmi_infos, type_metadata: list(type_metadata), analyses: [@sexp.opaque] ref(list(analysis)), + prog_loc: Location.t, }; type anf_bind = diff --git a/compiler/src/middle_end/anftree.rei b/compiler/src/middle_end/anftree.rei index 02044ef413..76dd11f5de 100644 --- a/compiler/src/middle_end/anftree.rei +++ b/compiler/src/middle_end/anftree.rei @@ -436,6 +436,7 @@ type anf_program = { signature: Cmi_format.cmi_infos, type_metadata: list(type_metadata), analyses: ref(list(analysis)), + prog_loc: Location.t, }; type anf_bind = diff --git a/compiler/src/middle_end/linearize.re b/compiler/src/middle_end/linearize.re index 8e7624bd6d..588592ccc6 100644 --- a/compiler/src/middle_end/linearize.re +++ b/compiler/src/middle_end/linearize.re @@ -2227,7 +2227,7 @@ let construct_type_metadata_buffer = type_metadata => { }; let transl_anf_module = - ({statements, env, signature}: typed_program): anf_program => { + ({statements, env, signature, prog_loc}: typed_program): anf_program => { Path_tbl.clear(type_map); Path_tbl.clear(include_map); Path_tbl.clear(module_symbol_map); @@ -2265,6 +2265,7 @@ let transl_anf_module = }, type_metadata, analyses: ref([]), + prog_loc, }; }; diff --git a/compiler/src/parsing/driver.re b/compiler/src/parsing/driver.re index 33af6de1d4..35d8371197 100644 --- a/compiler/src/parsing/driver.re +++ b/compiler/src/parsing/driver.re @@ -157,16 +157,11 @@ let read_imports = (program: Parsetree.parsed_program) => { ); let implicit_opens = List.map( - o => { - switch (o) { - | Grain_utils.Config.Pervasives_mod => - Location.mknoloc("pervasives.gr") - | Grain_utils.Config.Gc_mod => Location.mknoloc("runtime/gc.gr") - } - }, + o => Location.mknoloc(Grain_utils.Config.get_implicit_filepath(o)), Grain_utils.Config.with_attribute_flags( ~no_pervasives=module_has_attr("noPervasives"), ~runtime_mode=module_has_attr("runtimeMode"), + ~no_exception_mod=module_has_attr("noExceptions"), Grain_utils.Config.get_implicit_opens, ), ); diff --git a/compiler/src/parsing/location.re b/compiler/src/parsing/location.re index b741042d9c..15c9e7cf8e 100644 --- a/compiler/src/parsing/location.re +++ b/compiler/src/parsing/location.re @@ -56,7 +56,7 @@ let position_of_sexp = (sexp: Sexplib.Sexp.t) => Sexplib.Sexp.( switch (sexp) { | Atom(str) => of_sexp_error("position_of_sexp: list needed", sexp) - | List([Atom("position"), List(sexp_fields)]) + | List([Atom("position"), ...sexp_fields]) when List.length(sexp_fields) == 4 => let fields = List.map( diff --git a/compiler/src/parsing/well_formedness.re b/compiler/src/parsing/well_formedness.re index 103edf6550..0843abdb74 100644 --- a/compiler/src/parsing/well_formedness.re +++ b/compiler/src/parsing/well_formedness.re @@ -402,6 +402,7 @@ let disallowed_attributes = (errs, super) => { let known_module_attributes = [ {name: "runtimeMode", arity: 0}, {name: "noPervasives", arity: 0}, + {name: "noExceptions", arity: 0}, ]; validate_against_known(attributes, known_module_attributes, "module"); super.enter_parsed_program(prog); diff --git a/compiler/src/typed/cmi_format.re b/compiler/src/typed/cmi_format.re index aad926f822..3331e995fc 100644 --- a/compiler/src/typed/cmi_format.re +++ b/compiler/src/typed/cmi_format.re @@ -87,6 +87,15 @@ type cmi_infos = { type config_opt = | Cmi_config_opt('a): config_opt; +let magic = { + let bytes = Bytes.create(4); + Bytes.set_uint8(bytes, 0, 0xF0); + Bytes.set_uint8(bytes, 1, 0x9F); + Bytes.set_uint8(bytes, 2, 0x8C); + Bytes.set_uint8(bytes, 3, 0xBE); + bytes; +}; + let config_sum = Config.get_root_config_digest; let build_crc = (~name: string, sign: Types.signature) => { @@ -103,12 +112,6 @@ let build_crc = (~name: string, sign: Types.signature) => { Digest.bytes(ns_sign); }; -let input_cmi = ic => - switch (cmi_infos_of_yojson @@ Yojson.Safe.from_channel(ic)) { - | Result.Ok(x) => x - | Result.Error(e) => raise(Invalid_argument(e)) - }; - let deserialize_cmi = (ic, size) => { let size = ref(size); let lexbuf = @@ -142,22 +145,33 @@ module CmiBinarySection = let accepts_version = ({major}) => major == 1; }); -let read_cmi = filename => { - let ic = open_in_bin(filename); - switch (CmiBinarySection.load(ic)) { - | Some(cmi) => - close_in(ic); - cmi; - | None - | exception End_of_file - | exception (Invalid_argument(_)) - | exception (Failure(_)) => - close_in(ic); +let read_cmi = (ic, filename): cmi_infos => { + let read_magic = Bytes.create(4); + really_input(ic, read_magic, 0, 4); + if (read_magic != magic) { raise(Error(Corrupted_interface(filename))); - | exception (Error(e)) => - close_in(ic); - raise(Error(e)); }; + let version_length = input_binary_int(ic); + let read_version = really_input_string(ic, version_length); + if (read_version != Config.version) { + raise(Error(Wrong_version_interface(filename, read_version))); + }; + let _ = input_binary_int(ic); + Marshal.from_channel(ic); +}; +let read_cmi = filename => { + let ic = open_in_bin(filename); + let cmi = + try(read_cmi(ic, filename)) { + | Error(_) as exn => + close_in(ic); + raise(exn); + | _ => + close_in(ic); + raise(Error(Corrupted_interface(filename))); + }; + close_in(ic); + cmi; }; let serialize_cmi = cmi => diff --git a/compiler/src/typed/cmi_format.rei b/compiler/src/typed/cmi_format.rei index 1967f36bf5..68930ff109 100644 --- a/compiler/src/typed/cmi_format.rei +++ b/compiler/src/typed/cmi_format.rei @@ -35,6 +35,8 @@ type cmi_infos = { cmi_config_sum: string, }; +let magic: bytes; + let config_sum: unit => string; let build_crc: (~name: string, Types.signature) => Digest.t; @@ -42,9 +44,6 @@ let build_crc: (~name: string, Types.signature) => Digest.t; /* write the magic + the cmi information */ let serialize_cmi: cmi_infos => bytes; -/* read the cmi information (the magic is supposed to have already been read) */ -let input_cmi: in_channel => cmi_infos; - /* read a cmi from a filename, checking the magic */ let read_cmi: string => cmi_infos; diff --git a/compiler/src/typed/env.re b/compiler/src/typed/env.re index 725bb8a456..4a7da30261 100644 --- a/compiler/src/typed/env.re +++ b/compiler/src/typed/env.re @@ -668,19 +668,12 @@ let get_components = c => | Some(c) => c }; -let current_unit = ref(("", "", Grain_utils.Config.Normal)); +let current_unit = ref(("", "")); let set_unit = unit => current_unit := unit; let get_unit = () => current_unit^; -let is_runtime_mode = () => { - switch (current_unit^) { - | (_, _, Runtime) => true - | (_, _, Normal) => false - }; -}; - /* Persistent structure descriptions */ type pers_flags = Cmi_format.pers_flags = | Opaque | Unsafe_string; @@ -798,7 +791,7 @@ let mark_in_progress = (~loc, unit_name, sourcefile) => { Cyclic_dependencies(unit_name, get_dependency_chain(~loc, unit_name)), ); }; - let (stored_name, _, _) = get_unit(); + let (stored_name, _) = get_unit(); Hashtbl.add( compilation_in_progress, sourcefile, @@ -820,7 +813,7 @@ module Persistent_signature = { let load = ref((~loc=Location.dummy_loc, unit_name) => { - switch (Module_resolution.locate_module_file(~loc, unit_name)) { + switch (Module_resolution.locate_object_file(~loc, unit_name)) { | filename => let ret = {filename, cmi: Module_resolution.read_file_cmi(filename)}; Some(ret); @@ -859,7 +852,7 @@ let acknowledge_pers_struct = (check, {Persistent_signature.filename, cmi}) => { fun | Unsafe_string => if (Config.safe_string^) { - let (unit_name, _, _) = get_unit(); + let (unit_name, _) = get_unit(); error(Depend_on_unsafe_string_unit(ps.ps_name, unit_name)); } | Opaque => add_imported_opaque(filename), @@ -960,7 +953,7 @@ let rec find_module_descr = (path, filename, env) => { | PIdent(id) => try(IdTbl.find_same(id, env.components)) { | Not_found => - let (_, unit_source, _) = get_unit(); + let (_, unit_source) = get_unit(); switch (filename) { | Some(filename) when Ident.persistent(id) && !(filename == unit_source) => @@ -1074,7 +1067,7 @@ let find_module = (path, filename, env) => EnvLazy.force(subst_modtype_maker, data); }) { | Not_found => - let (_, unit_source, _) = get_unit(); + let (_, unit_source) = get_unit(); let filename = Option.value(~default=Ident.name(id), filename); if (Ident.persistent(id) && !(filename == unit_source)) { let ps = find_pers_struct(~loc=Location.dummy_loc, filename); @@ -1250,7 +1243,7 @@ and lookup_module = (~loc=?, ~load, ~mark, id, filename, env): Path.t => p; }) { | Not_found => - let (_, unit_source, _) = get_unit(); + let (_, unit_source) = get_unit(); if (Option.value(~default=s, filename) == unit_source) { raise(Not_found); }; @@ -2324,7 +2317,7 @@ let build_signature_with_imports = ps_comps: comps, ps_crcs: cmi.cmi_crcs, ps_crc: cmi.cmi_crc, - ps_filename: Module_resolution.get_output_name(filename), + ps_filename: Module_resolution.get_object_name(filename), ps_flags: cmi.cmi_flags, }; @@ -2630,14 +2623,14 @@ let () = { Module_resolution.current_unit_name := ( () => { - let (uname, _, _) = get_unit(); + let (uname, _) = get_unit(); uname; } ); Module_resolution.current_filename := ( () => { - let (_, source, _) = get_unit(); + let (_, source) = get_unit(); source; } ); diff --git a/compiler/src/typed/env.rei b/compiler/src/typed/env.rei index 727dd560e9..4a7b65d9d8 100644 --- a/compiler/src/typed/env.rei +++ b/compiler/src/typed/env.rei @@ -162,9 +162,8 @@ let add_local_type: (Path.t, type_declaration, t) => t; let add_item: (signature_item, t) => t; let add_signature: (signature, t) => t; -let set_unit: ((string, string, Grain_utils.Config.compilation_mode)) => unit; -let get_unit: unit => (string, string, Grain_utils.Config.compilation_mode); -let is_runtime_mode: unit => bool; +let set_unit: ((string, string)) => unit; +let get_unit: unit => (string, string); /* Insertion of a module */ let include_module: (Identifier.t, include_declaration, t) => t; diff --git a/compiler/src/typed/module_resolution.re b/compiler/src/typed/module_resolution.re index 39b542cf31..fe171fbba0 100644 --- a/compiler/src/typed/module_resolution.re +++ b/compiler/src/typed/module_resolution.re @@ -12,7 +12,7 @@ let error = err => raise(Error(err)); type module_location_result = | GrainModule(string, option(string)) /* Grain Source file, Compiled object */ - | WasmModule(string); /* Compiled object */ + | ObjectFile(string); /* Compiled object */ let compile_module_dependency: ref((string, string) => unit) = ref((filename, output_file) => @@ -49,22 +49,27 @@ let read_file_cmi = f => { }; }; -let get_output_name = name => name ++ ".wasm"; +let get_object_name = name => Filepath.String.replace_extension(name, "gro"); let find_ext_in_dir = (dir, name) => { let fullname = Filepath.String.concat(dir, name); let rec process_ext = fun | [] => None - | [ext, ..._] when file_exists(fullname ++ ext) => - Some((fullname ++ ext, dir, name)) - | [_, ...tl] => process_ext(tl); + | [ext, ...tl] => { + let with_ext = Filepath.String.replace_extension(fullname, ext); + if (file_exists(with_ext)) { + Some((with_ext, dir, name)); + } else { + process_ext(tl); + }; + }; process_ext; }; let find_in_path_uncap = - (~check_src=false, ~check_wasm=false, base_dir, path, name) => { - let exts = (check_src ? [""] : []) @ (check_wasm ? [".wasm"] : []); + (~check_src=false, ~check_object=false, base_dir, path, name) => { + let exts = (check_src ? ["gr"] : []) @ (check_object ? ["gro"] : []); let rec try_dir = fun | [] => raise(Not_found) @@ -175,7 +180,7 @@ let resolve_unit = (~search_path=?, ~cache=true, ~base_dir=?, unit_name) => { let (_, dir, basename) = find_in_path_uncap( ~check_src=true, - ~check_wasm=true, + ~check_object=true, base_dir, path, unit_name, @@ -203,16 +208,18 @@ let locate_module = (~disable_relpath=false, base_dir, path, unit_name) => { | Some(m) => m | None => let (dir, m) = - switch (find_in_path_uncap(~check_wasm=true, base_dir, path, unit_name)) { + switch ( + find_in_path_uncap(~check_object=true, base_dir, path, unit_name) + ) { | (objpath, dir, basename) => ignore(log_resolution(unit_name, dir, basename)); - let file = find_ext_in_dir(dir, basename, [""]); + let file = find_ext_in_dir(dir, basename, ["gr"]); switch (file) { | Some((srcpath, _, _)) => ( dir, GrainModule(srcpath, Some(objpath)), ) - | None => (dir, WasmModule(objpath)) + | None => (dir, ObjectFile(objpath)) }; | exception Not_found => let (srcpath, dir, _) = @@ -273,12 +280,12 @@ type dependency_node = { dn_latest_resolution: ref(option(module_location_result)), }; -let located_to_out_file_name = (~base=?, located) => { +let located_to_object_file_name = (~base=?, located) => { let ret = switch (located) { - | GrainModule(srcpath, None) => get_output_name(srcpath) + | GrainModule(srcpath, None) => get_object_name(srcpath) | GrainModule(_, Some(outpath)) - | WasmModule(outpath) => outpath + | ObjectFile(outpath) => outpath }; Filepath.to_string(Filepath.String.derelativize(~base?, ret)); }; @@ -294,7 +301,7 @@ let locate_unit_object_file = (~path=?, ~base_dir=?, unit_name) => { | Some(p) => p | None => Config.module_search_path() }; - located_to_out_file_name(locate_module(base_dir, path, unit_name)); + located_to_object_file_name(locate_module(base_dir, path, unit_name)); }; module Dependency_graph = @@ -324,7 +331,7 @@ module Dependency_graph = name.Location.txt, name.Location.loc, ); - let out_file_name = located_to_out_file_name(located); + let out_file_name = located_to_object_file_name(located); let existing_dependency = lookup(out_file_name); switch (existing_dependency) { | Some(ed) => @@ -349,7 +356,7 @@ module Dependency_graph = // nothing uses --no-pervasives or --no-gc. switch (located) { | None => failwith("get_dependencies: Should be impossible") - | Some(WasmModule(_)) => [] + | Some(ObjectFile(_)) => [] | Some(GrainModule(srcpath, None)) => from_srcpath(srcpath) | Some(GrainModule(srcpath, Some(objpath))) => switch (read_file_cmi(objpath)) { @@ -364,7 +371,7 @@ module Dependency_graph = name, Location.in_file(dn.dn_file_name), ); - let out_file_name = located_to_out_file_name(located); + let out_file_name = located_to_object_file_name(located); let existing_dependency = lookup(out_file_name); switch (existing_dependency) { | Some(ed) => @@ -395,7 +402,7 @@ module Dependency_graph = | (false, Some(GrainModule(_, None))) => // File isn't compiled, so it's not up-to-date yet. dn.dn_up_to_date := false - | (false, Some(WasmModule(_))) => + | (false, Some(ObjectFile(_))) => // WASM modules are always up-to-date dn.dn_up_to_date := true | (false, Some(GrainModule(srcpath, Some(objpath)))) => @@ -414,10 +421,10 @@ module Dependency_graph = && List.for_all( ((name, crc)) => { let resolved = resolve_unit(~base_dir, name); - let out_file_name = get_output_name(resolved); - Fs_access.file_exists(out_file_name) + let object_name = get_object_name(resolved); + Fs_access.file_exists(object_name) && ( - try(read_file_cmi(out_file_name).cmi_crc == crc) { + try(read_file_cmi(object_name).cmi_crc == crc) { | _ => false } ); @@ -440,12 +447,12 @@ module Dependency_graph = let srcpath = switch (dn.dn_latest_resolution^) { | None => failwith("impossible: compile_module > None") - | Some(WasmModule(_)) => - failwith("impossible: compile_module > WasmModule") + | Some(ObjectFile(_)) => + failwith("impossible: compile_module > ObjectFile") | Some(GrainModule(srcpath, _)) => Filepath.to_string(Filepath.String.derelativize(srcpath)) }; - let outpath = get_output_name(srcpath); + let outpath = get_object_name(srcpath); let loc = Option.value(loc, ~default=Grain_parsing.Location.dummy_loc); let chosen_unit_name = switch (Hashtbl.to_seq(dn.dn_unit_name, ())) { @@ -469,21 +476,21 @@ module Dependency_graph = }; }); -let locate_module_file = (~loc, ~disable_relpath=false, unit_name) => { +let locate_object_file = (~loc, ~disable_relpath=false, unit_name) => { let base_dir = Filepath.String.dirname(current_filename^()); let path = Config.module_search_path(); let located = try_locate_module(~disable_relpath, base_dir, path, unit_name, loc); - located_to_out_file_name(located); + located_to_object_file_name(located); }; let process_dependency = (~loc, ~base_file, unit_name) => { let base_dir = Filepath.String.dirname(base_file); let path = Config.module_search_path(); let located = try_locate_module(base_dir, path, unit_name, loc); - let out_file = located_to_out_file_name(located); + let object_file = located_to_object_file_name(located); let current_dep_node = Dependency_graph.lookup_filename(base_file); - let existing_dependency = Dependency_graph.lookup_filename(out_file); + let existing_dependency = Dependency_graph.lookup_filename(object_file); let dn = switch (existing_dependency) { | Some(ed) => @@ -494,7 +501,7 @@ let process_dependency = (~loc, ~base_file, unit_name) => { Hashtbl.add(tbl, current_dep_node, unit_name); { dn_unit_name: tbl, - dn_file_name: out_file, + dn_file_name: object_file, dn_up_to_date: ref(false), // <- needs to be checked dn_latest_resolution: ref(Some(located)), }; diff --git a/compiler/src/typed/module_resolution.rei b/compiler/src/typed/module_resolution.rei index f82f1d2c34..22ff8105ed 100644 --- a/compiler/src/typed/module_resolution.rei +++ b/compiler/src/typed/module_resolution.rei @@ -1,6 +1,6 @@ -let get_output_name: string => string; +let get_object_name: string => string; -let locate_module_file: +let locate_object_file: (~loc: Grain_parsing.Location.t, ~disable_relpath: bool=?, string) => string; let locate_unit_object_file: diff --git a/compiler/src/typed/typedtree.re b/compiler/src/typed/typedtree.re index ba60e94c37..98ceaa24a1 100644 --- a/compiler/src/typed/typedtree.re +++ b/compiler/src/typed/typedtree.re @@ -630,6 +630,7 @@ type typed_program = { env: [@sexp.opaque] Env.t, signature: Cmi_format.cmi_infos, comments: list(comment), + prog_loc: Location.t, }; let iter_pattern_desc = (f, patt) => diff --git a/compiler/src/typed/typedtree.rei b/compiler/src/typed/typedtree.rei index c5556ff828..848cc99d08 100644 --- a/compiler/src/typed/typedtree.rei +++ b/compiler/src/typed/typedtree.rei @@ -590,6 +590,7 @@ type typed_program = { env: Env.t, signature: Cmi_format.cmi_infos, comments: list(comment), + prog_loc: Location.t, }; /* Auxiliary functions over the AST */ diff --git a/compiler/src/typed/typemod.re b/compiler/src/typed/typemod.re index 0816009c04..da7bb8d768 100644 --- a/compiler/src/typed/typemod.re +++ b/compiler/src/typed/typemod.re @@ -991,11 +991,7 @@ let type_module = type_module(None); let register_implicit_modules = modules => { List.iter( m => { - let filepath = - switch (m) { - | Grain_utils.Config.Pervasives_mod => "pervasives.gr" - | Grain_utils.Config.Gc_mod => "runtime/gc.gr" - }; + let filepath = Grain_utils.Config.get_implicit_filepath(m); Env.add_import(filepath); }, modules, @@ -1004,8 +1000,11 @@ let register_implicit_modules = modules => { let lookup_implicit_module_spec = m => switch (m) { - | Grain_utils.Config.Pervasives_mod => Some(("Pervasives", "pervasives.gr")) + | Grain_utils.Config.Pervasives_mod => + Some(("Pervasives", Grain_utils.Config.get_implicit_filepath(m))) | Grain_utils.Config.Gc_mod => None + | Grain_utils.Config.Exception_mod => None + | Grain_utils.Config.Equal_mod => None }; let get_current_used_implicit_modules = implicit_opens => @@ -1034,7 +1033,7 @@ let initial_env = () => { let env = initial; let implicit_modules = Grain_utils.Config.get_implicit_opens(); register_implicit_modules(implicit_modules); - let (unit_name, source, mode) = Env.get_unit(); + let (unit_name, source) = Env.get_unit(); List.fold_left( (env, m) => { let (modname, _) = m; @@ -1049,14 +1048,10 @@ let initial_env = () => { ); }; -let type_implementation = prog => { +let type_implementation = (prog: Parsetree.parsed_program) => { let sourcefile = prog.prog_loc.loc_start.pos_fname; let module_name = prog.module_name.txt; - Env.set_unit(( - module_name, - sourcefile, - Grain_utils.Config.compilation_mode^, - )); + Env.set_unit((module_name, sourcefile)); let initenv = initial_env(); let (statements, sg, finalenv) = type_module(initenv, prog.statements); let simple_sg = simplify_signature(sg); @@ -1075,6 +1070,7 @@ let type_implementation = prog => { env: finalenv, signature, comments: prog.comments, + prog_loc: prog.prog_loc, }; }; diff --git a/compiler/src/utils/config.re b/compiler/src/utils/config.re index d8a70df045..252e82221b 100644 --- a/compiler/src/utils/config.re +++ b/compiler/src/utils/config.re @@ -16,6 +16,12 @@ type digestible_opt = type config = list(saved_config_opt); +let version = + switch (Build_info.V1.version()) { + | None => "unknown" + | Some(v) => Build_info.V1.Version.to_string(v) + }; + let empty: config = []; /* Here we model the API provided by cmdliner without introducing @@ -398,12 +404,15 @@ let import_memory = false, ); +[@deriving sexp] type compilation_mode = | Normal /* Standard compilation with regular bells and whistles */ | Runtime /* GC doesn't exist yet, allocations happen in runtime heap */; let compilation_mode = internal_opt(Normal, NotDigestible); +let no_exception_mod = internal_opt(false, NotDigestible); + let statically_link = toggle_flag( ~names=["no-link"], @@ -559,7 +568,8 @@ let module_search_path = () => { }; }; -let apply_attribute_flags = (~no_pervasives as np, ~runtime_mode as rm) => { +let apply_attribute_flags = + (~no_pervasives as np, ~runtime_mode as rm, ~no_exception_mod as ne) => { // Only apply options if attributes were explicitly given so as to not // unintentionally override options set previously e.g. compiling a // wasi-polyfill file in non-runtime-mode if @runtimeMode is not specified @@ -569,18 +579,34 @@ let apply_attribute_flags = (~no_pervasives as np, ~runtime_mode as rm) => { if (rm) { compilation_mode := Runtime; }; + if (ne) { + no_exception_mod := true; + }; }; -let with_attribute_flags = (~no_pervasives, ~runtime_mode, thunk) => { +let with_attribute_flags = + (~no_pervasives, ~runtime_mode, ~no_exception_mod, thunk) => { preserve_config(() => { - apply_attribute_flags(~no_pervasives, ~runtime_mode); + apply_attribute_flags(~no_pervasives, ~runtime_mode, ~no_exception_mod); thunk(); }); }; type implicit_opens = | Pervasives_mod - | Gc_mod; + | Gc_mod + | Exception_mod + | Equal_mod; + +let all_implicit_opens = [Pervasives_mod, Gc_mod, Exception_mod, Equal_mod]; + +let get_implicit_filepath = m => + switch (m) { + | Pervasives_mod => "pervasives.gr" + | Gc_mod => "runtime/gc.gr" + | Exception_mod => "runtime/exception.gr" + | Equal_mod => "runtime/equal.gr" + }; let get_implicit_opens = () => { let ret = @@ -592,10 +618,13 @@ let get_implicit_opens = () => { if (compilation_mode^ == Runtime) { []; } else { + let ret = + if (no_exception_mod^) { + ret; + } else { + [Exception_mod, ...ret]; + }; // Pervasives goes first, just for good measure. - List.rev([ - Gc_mod, - ...ret, - ]); + List.rev([Gc_mod, ...ret]); }; }; diff --git a/compiler/src/utils/config.rei b/compiler/src/utils/config.rei index bab3999d17..c67c7ed79e 100644 --- a/compiler/src/utils/config.rei +++ b/compiler/src/utils/config.rei @@ -1,10 +1,14 @@ type profile = | Release; +[@deriving sexp] type compilation_mode = | Normal /* Standard compilation with regular bells and whistles */ | Runtime /* GC doesn't exist yet, allocations happen in runtime heap */; +/** The version of the Grain compiler */ +let version: string; + /** The Grain stdlib directory, based on the current configuration */ let stdlib_directory: unit => option(string); @@ -180,13 +184,24 @@ let with_cli_options: 'a => Cmdliner.Term.t('a); /** Applies compile flags provided as module attributes */ -let apply_attribute_flags: (~no_pervasives: bool, ~runtime_mode: bool) => unit; +let apply_attribute_flags: + (~no_pervasives: bool, ~runtime_mode: bool, ~no_exception_mod: bool) => unit; let with_attribute_flags: - (~no_pervasives: bool, ~runtime_mode: bool, unit => 'a) => 'a; + ( + ~no_pervasives: bool, + ~runtime_mode: bool, + ~no_exception_mod: bool, + unit => 'a + ) => + 'a; type implicit_opens = | Pervasives_mod - | Gc_mod; + | Gc_mod + | Exception_mod + | Equal_mod; +let all_implicit_opens: list(implicit_opens); +let get_implicit_filepath: implicit_opens => string; let get_implicit_opens: unit => list(implicit_opens); diff --git a/compiler/src/utils/dune b/compiler/src/utils/dune index a126a024cd..dbd0cfbb82 100644 --- a/compiler/src/utils/dune +++ b/compiler/src/utils/dune @@ -3,7 +3,7 @@ (public_name grain_utils) (synopsis "Utilities for the Grain compiler") (libraries fp fs.lib cmdliner compiler-libs.common ppx_sexp_conv.runtime-lib - sexplib str) + sexplib str dune-build-info) (preprocess (pps ppx_sexp_conv sedlex.ppx)) (js_of_ocaml diff --git a/compiler/test/TestFramework.re b/compiler/test/TestFramework.re index 1b2ea853a6..f9cfdeb208 100644 --- a/compiler/test/TestFramework.re +++ b/compiler/test/TestFramework.re @@ -38,9 +38,11 @@ let clean_grain_output = stdlib_dir => Array.iter( file => { let filename = Filepath.to_string(file); - if (Filepath.String.check_suffix(filename, ".gr.wasm") - || Filepath.String.check_suffix(filename, ".gr.wat") - || Filepath.String.check_suffix(filename, ".gr.modsig")) { + if (Filepath.String.check_suffix(filename, ".wasm") + || Filepath.String.check_suffix(filename, ".wat") + || Filepath.String.check_suffix(filename, ".gro") + || Filepath.String.check_suffix(filename, ".mashtree") + || Filepath.String.check_suffix(filename, ".modsig")) { Fs.rmExn(file); }; }, diff --git a/compiler/test/__snapshots__/arrays.0f9e7d37.0.snapshot b/compiler/test/__snapshots__/arrays.0f9e7d37.0.snapshot index e5c9a4010b..ff73c2b966 100644 --- a/compiler/test/__snapshots__/arrays.0f9e7d37.0.snapshot +++ b/compiler/test/__snapshots__/arrays.0f9e7d37.0.snapshot @@ -1,250 +1,33 @@ arrays › array_access -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"GRAIN$EXPORT$panicWithException\" (global $GRAIN$EXPORT$panicWithException_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"panicWithException\" (func $panicWithException_0 (param i32 i32) (result i32))) - (global $x_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.10 (result i32) - (block $compile_store.3 - (global.set $x_1113 - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $MArrayGet.9 (result i32) - (local.set $1 - (i32.const 1) - ) - (local.set $2 - (global.get $x_1113) - ) - (block $resolve_idx.8 - (if - (i32.eqz - (i32.and - (local.get $1) - (i32.const 1) - ) - ) - (block $IndexNotSimpleInteger.7 - (local.set $1 - (i32.load offset=4 - (local.get $1) - ) - ) - (drop - (if (result i32) - (i32.or - (i32.eq - (local.get $1) - (i32.const 2) - ) - (i32.eq - (local.get $1) - (i32.const 4) - ) - ) - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.6 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 67) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.5 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 69) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - ) - ) - ) - (local.set $1 - (i32.shr_s - (local.get $1) - (i32.const 1) - ) - ) - (if - (i32.lt_s - (local.get $1) - (i32.const 0) - ) - (local.set $1 - (i32.add - (local.get $1) - (i32.load offset=4 - (local.get $2) - ) - ) - ) - ) - (if - (i32.le_u - (i32.load offset=4 - (local.get $2) - ) - (local.get $1) - ) - (drop - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 67) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - ) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (i32.add - (i32.shl - (local.get $1) - (i32.const 2) - ) - (local.get $2) - ) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind x_1113 Managed) + ((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MArrayOp + (MArrayGet + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))) + ((immediate_desc (MImmBinding (MGlobalBind x_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name x))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/arrays.1deb7b51.0.snapshot b/compiler/test/__snapshots__/arrays.1deb7b51.0.snapshot index 43ccc57b0e..e4fac972ce 100644 --- a/compiler/test/__snapshots__/arrays.1deb7b51.0.snapshot +++ b/compiler/test/__snapshots__/arrays.1deb7b51.0.snapshot @@ -1,265 +1,34 @@ arrays › array_access5 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"GRAIN$EXPORT$panicWithException\" (global $GRAIN$EXPORT$panicWithException_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"panicWithException\" (func $panicWithException_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.11 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (tuple.extract 0 - (tuple.make - (block $MArrayGet.10 (result i32) - (local.set $1 - (i32.const -5) - ) - (local.set $2 - (local.get $6) - ) - (block $resolve_idx.9 - (if - (i32.eqz - (i32.and - (local.get $1) - (i32.const 1) - ) - ) - (block $IndexNotSimpleInteger.8 - (local.set $1 - (i32.load offset=4 - (local.get $1) - ) - ) - (drop - (if (result i32) - (i32.or - (i32.eq - (local.get $1) - (i32.const 2) - ) - (i32.eq - (local.get $1) - (i32.const 4) - ) - ) - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 67) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.6 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 69) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - ) - ) - ) - (local.set $1 - (i32.shr_s - (local.get $1) - (i32.const 1) - ) - ) - (if - (i32.lt_s - (local.get $1) - (i32.const 0) - ) - (local.set $1 - (i32.add - (local.get $1) - (i32.load offset=4 - (local.get $2) - ) - ) - ) - ) - (if - (i32.le_u - (i32.load offset=4 - (local.get $2) - ) - (local.get $1) - ) - (drop - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.5 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 67) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - ) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (i32.add - (i32.shl - (local.get $1) - (i32.const 2) - ) - (local.get $2) - ) - ) - ) - ) - (block $cleanup.4 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MArrayOp + (MArrayGet + ((immediate_desc (MImmConst (MConstI32 -3))) + (immediate_analyses ((last_usage Unknown))))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))) + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/arrays.24453e6e.0.snapshot b/compiler/test/__snapshots__/arrays.24453e6e.0.snapshot index 617668248f..04fd701692 100644 --- a/compiler/test/__snapshots__/arrays.24453e6e.0.snapshot +++ b/compiler/test/__snapshots__/arrays.24453e6e.0.snapshot @@ -1,65 +1,20 @@ arrays › array1_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/arrays.28fcc534.0.snapshot b/compiler/test/__snapshots__/arrays.28fcc534.0.snapshot index d6b32719c8..f0f421f443 100644 --- a/compiler/test/__snapshots__/arrays.28fcc534.0.snapshot +++ b/compiler/test/__snapshots__/arrays.28fcc534.0.snapshot @@ -1,250 +1,33 @@ arrays › array_access4 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"GRAIN$EXPORT$panicWithException\" (global $GRAIN$EXPORT$panicWithException_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"panicWithException\" (func $panicWithException_0 (param i32 i32) (result i32))) - (global $x_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.10 (result i32) - (block $compile_store.3 - (global.set $x_1113 - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $MArrayGet.9 (result i32) - (local.set $1 - (i32.const -3) - ) - (local.set $2 - (global.get $x_1113) - ) - (block $resolve_idx.8 - (if - (i32.eqz - (i32.and - (local.get $1) - (i32.const 1) - ) - ) - (block $IndexNotSimpleInteger.7 - (local.set $1 - (i32.load offset=4 - (local.get $1) - ) - ) - (drop - (if (result i32) - (i32.or - (i32.eq - (local.get $1) - (i32.const 2) - ) - (i32.eq - (local.get $1) - (i32.const 4) - ) - ) - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.6 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 67) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.5 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 69) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - ) - ) - ) - (local.set $1 - (i32.shr_s - (local.get $1) - (i32.const 1) - ) - ) - (if - (i32.lt_s - (local.get $1) - (i32.const 0) - ) - (local.set $1 - (i32.add - (local.get $1) - (i32.load offset=4 - (local.get $2) - ) - ) - ) - ) - (if - (i32.le_u - (i32.load offset=4 - (local.get $2) - ) - (local.get $1) - ) - (drop - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 67) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - ) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (i32.add - (i32.shl - (local.get $1) - (i32.const 2) - ) - (local.get $2) - ) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind x_1113 Managed) + ((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MArrayOp + (MArrayGet + ((immediate_desc (MImmConst (MConstI32 -2))) + (immediate_analyses ((last_usage Unknown))))) + ((immediate_desc (MImmBinding (MGlobalBind x_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name x))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/arrays.4c8c9f91.0.snapshot b/compiler/test/__snapshots__/arrays.4c8c9f91.0.snapshot index c660f7449e..46610c6406 100644 --- a/compiler/test/__snapshots__/arrays.4c8c9f91.0.snapshot +++ b/compiler/test/__snapshots__/arrays.4c8c9f91.0.snapshot @@ -1,250 +1,33 @@ arrays › array_access2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"GRAIN$EXPORT$panicWithException\" (global $GRAIN$EXPORT$panicWithException_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"panicWithException\" (func $panicWithException_0 (param i32 i32) (result i32))) - (global $x_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.10 (result i32) - (block $compile_store.3 - (global.set $x_1113 - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $MArrayGet.9 (result i32) - (local.set $1 - (i32.const 3) - ) - (local.set $2 - (global.get $x_1113) - ) - (block $resolve_idx.8 - (if - (i32.eqz - (i32.and - (local.get $1) - (i32.const 1) - ) - ) - (block $IndexNotSimpleInteger.7 - (local.set $1 - (i32.load offset=4 - (local.get $1) - ) - ) - (drop - (if (result i32) - (i32.or - (i32.eq - (local.get $1) - (i32.const 2) - ) - (i32.eq - (local.get $1) - (i32.const 4) - ) - ) - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.6 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 67) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.5 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 69) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - ) - ) - ) - (local.set $1 - (i32.shr_s - (local.get $1) - (i32.const 1) - ) - ) - (if - (i32.lt_s - (local.get $1) - (i32.const 0) - ) - (local.set $1 - (i32.add - (local.get $1) - (i32.load offset=4 - (local.get $2) - ) - ) - ) - ) - (if - (i32.le_u - (i32.load offset=4 - (local.get $2) - ) - (local.get $1) - ) - (drop - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 67) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - ) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (i32.add - (i32.shl - (local.get $1) - (i32.const 2) - ) - (local.get $2) - ) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind x_1113 Managed) + ((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MArrayOp + (MArrayGet + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))) + ((immediate_desc (MImmBinding (MGlobalBind x_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name x))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/arrays.6eac4e1f.0.snapshot b/compiler/test/__snapshots__/arrays.6eac4e1f.0.snapshot index f845fb6622..806c31c587 100644 --- a/compiler/test/__snapshots__/arrays.6eac4e1f.0.snapshot +++ b/compiler/test/__snapshots__/arrays.6eac4e1f.0.snapshot @@ -1,250 +1,33 @@ arrays › array_access3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"GRAIN$EXPORT$panicWithException\" (global $GRAIN$EXPORT$panicWithException_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"panicWithException\" (func $panicWithException_0 (param i32 i32) (result i32))) - (global $x_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.10 (result i32) - (block $compile_store.3 - (global.set $x_1113 - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $MArrayGet.9 (result i32) - (local.set $1 - (i32.const 5) - ) - (local.set $2 - (global.get $x_1113) - ) - (block $resolve_idx.8 - (if - (i32.eqz - (i32.and - (local.get $1) - (i32.const 1) - ) - ) - (block $IndexNotSimpleInteger.7 - (local.set $1 - (i32.load offset=4 - (local.get $1) - ) - ) - (drop - (if (result i32) - (i32.or - (i32.eq - (local.get $1) - (i32.const 2) - ) - (i32.eq - (local.get $1) - (i32.const 4) - ) - ) - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.6 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 67) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.5 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 69) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - ) - ) - ) - (local.set $1 - (i32.shr_s - (local.get $1) - (i32.const 1) - ) - ) - (if - (i32.lt_s - (local.get $1) - (i32.const 0) - ) - (local.set $1 - (i32.add - (local.get $1) - (i32.load offset=4 - (local.get $2) - ) - ) - ) - ) - (if - (i32.le_u - (i32.load offset=4 - (local.get $2) - ) - (local.get $1) - ) - (drop - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 67) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - ) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (i32.add - (i32.shl - (local.get $1) - (i32.const 2) - ) - (local.get $2) - ) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind x_1113 Managed) + ((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MArrayOp + (MArrayGet + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))) + ((immediate_desc (MImmBinding (MGlobalBind x_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name x))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/arrays.74d79181.0.snapshot b/compiler/test/__snapshots__/arrays.74d79181.0.snapshot index 11a9b199a9..0e898b2893 100644 --- a/compiler/test/__snapshots__/arrays.74d79181.0.snapshot +++ b/compiler/test/__snapshots__/arrays.74d79181.0.snapshot @@ -1,250 +1,33 @@ arrays › array_access5 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"GRAIN$EXPORT$panicWithException\" (global $GRAIN$EXPORT$panicWithException_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"panicWithException\" (func $panicWithException_0 (param i32 i32) (result i32))) - (global $x_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.10 (result i32) - (block $compile_store.3 - (global.set $x_1113 - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $MArrayGet.9 (result i32) - (local.set $1 - (i32.const -5) - ) - (local.set $2 - (global.get $x_1113) - ) - (block $resolve_idx.8 - (if - (i32.eqz - (i32.and - (local.get $1) - (i32.const 1) - ) - ) - (block $IndexNotSimpleInteger.7 - (local.set $1 - (i32.load offset=4 - (local.get $1) - ) - ) - (drop - (if (result i32) - (i32.or - (i32.eq - (local.get $1) - (i32.const 2) - ) - (i32.eq - (local.get $1) - (i32.const 4) - ) - ) - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.6 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 67) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.5 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 69) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - ) - ) - ) - (local.set $1 - (i32.shr_s - (local.get $1) - (i32.const 1) - ) - ) - (if - (i32.lt_s - (local.get $1) - (i32.const 0) - ) - (local.set $1 - (i32.add - (local.get $1) - (i32.load offset=4 - (local.get $2) - ) - ) - ) - ) - (if - (i32.le_u - (i32.load offset=4 - (local.get $2) - ) - (local.get $1) - ) - (drop - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 67) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - ) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (i32.add - (i32.shl - (local.get $1) - (i32.const 2) - ) - (local.get $2) - ) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind x_1113 Managed) + ((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MArrayOp + (MArrayGet + ((immediate_desc (MImmConst (MConstI32 -3))) + (immediate_analyses ((last_usage Unknown))))) + ((immediate_desc (MImmBinding (MGlobalBind x_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name x))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/arrays.9e17b4d1.0.snapshot b/compiler/test/__snapshots__/arrays.9e17b4d1.0.snapshot index 356b660f0c..571dee1c9f 100644 --- a/compiler/test/__snapshots__/arrays.9e17b4d1.0.snapshot +++ b/compiler/test/__snapshots__/arrays.9e17b4d1.0.snapshot @@ -1,65 +1,20 @@ arrays › array3 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/arrays.b85cb7fc.0.snapshot b/compiler/test/__snapshots__/arrays.b85cb7fc.0.snapshot index 4ec5675f0c..0f24a68542 100644 --- a/compiler/test/__snapshots__/arrays.b85cb7fc.0.snapshot +++ b/compiler/test/__snapshots__/arrays.b85cb7fc.0.snapshot @@ -1,65 +1,20 @@ arrays › array1_trailing_space -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.00bcbc39.0.snapshot b/compiler/test/__snapshots__/basic_functionality.00bcbc39.0.snapshot index 761bd6d9f3..ff2b2c35d7 100644 --- a/compiler/test/__snapshots__/basic_functionality.00bcbc39.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.00bcbc39.0.snapshot @@ -1,85 +1,58 @@ basic functionality › assignment1 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$*\" (global $*_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"*\" (func $*_1117 (param i32 i32 i32) (result i32))) - (global $t_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.6 (result i32) - (block $compile_store.2 - (global.set $t_1113 - (i32.const 5) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $*_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $*_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $t_1113) - ) - (i32.const 5) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_set.5 (result i32) - (global.set $t_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $t_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind t_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func *_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind *_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind t_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MSet (MGlobalBind t_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name t))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.00cfdb2e.0.snapshot b/compiler/test/__snapshots__/basic_functionality.00cfdb2e.0.snapshot index aa59bf5b19..a0ed58fc86 100644 --- a/compiler/test/__snapshots__/basic_functionality.00cfdb2e.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.00cfdb2e.0.snapshot @@ -1,35 +1,15 @@ basic functionality › binop2.4 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -3) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 -2))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.03de4778.0.snapshot b/compiler/test/__snapshots__/basic_functionality.03de4778.0.snapshot index 10e9abfad9..8269110388 100644 --- a/compiler/test/__snapshots__/basic_functionality.03de4778.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.03de4778.0.snapshot @@ -1,35 +1,15 @@ basic functionality › neg -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -79) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 -40))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.040643b3.0.snapshot b/compiler/test/__snapshots__/basic_functionality.040643b3.0.snapshot index 6235792196..42778382f2 100644 --- a/compiler/test/__snapshots__/basic_functionality.040643b3.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.040643b3.0.snapshot @@ -1,67 +1,50 @@ basic functionality › comp5 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$<\" (global $<_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"<\" (func $<_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.2 - (local.set $6 - (call $<_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $<_1114) - ) - (i32.const 5) - (i32.const 7) - ) - ) - (block $do_backpatches.1 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.3 (result i32) - (i32.const 9) - ) - (block $compile_block.4 (result i32) - (i32.const 11) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func <_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind <_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.06bd2a80.0.snapshot b/compiler/test/__snapshots__/basic_functionality.06bd2a80.0.snapshot index 7dcb135c25..3e45ab5b96 100644 --- a/compiler/test/__snapshots__/basic_functionality.06bd2a80.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.06bd2a80.0.snapshot @@ -1,64 +1,27 @@ basic functionality › assignment1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $t_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.4 (result i32) - (block $compile_store.2 - (global.set $t_1113 - (i32.const 5) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_set.3 (result i32) - (global.set $t_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.const 3) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $t_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind t_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MSet (MGlobalBind t_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name t))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.0996c5f7.0.snapshot b/compiler/test/__snapshots__/basic_functionality.0996c5f7.0.snapshot index cf6e106090..1ecad18ebd 100644 --- a/compiler/test/__snapshots__/basic_functionality.0996c5f7.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.0996c5f7.0.snapshot @@ -1,48 +1,35 @@ basic functionality › modulo4 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$%\" (global $%_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"%\" (func $%_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $%_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $%_1113) - ) - (i32.const -33) - (i32.const 35) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func %_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind %_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 -17))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 17))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.0a230f18.0.snapshot b/compiler/test/__snapshots__/basic_functionality.0a230f18.0.snapshot index bc8734bd25..a868528bbf 100644 --- a/compiler/test/__snapshots__/basic_functionality.0a230f18.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.0a230f18.0.snapshot @@ -1,48 +1,35 @@ basic functionality › land4 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$&\" (global $&_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"&\" (func $&_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $&_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $&_1113) - ) - (i32.const 1) - (i32.const 1) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name &))) (mimp_mod pervasives.gr) (mimp_name &) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name &))) (mimp_mod pervasives.gr) (mimp_name &) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func &_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind &_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.0a2e4afa.0.snapshot b/compiler/test/__snapshots__/basic_functionality.0a2e4afa.0.snapshot index dc2f4c8c0b..8bc8806c60 100644 --- a/compiler/test/__snapshots__/basic_functionality.0a2e4afa.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.0a2e4afa.0.snapshot @@ -1,48 +1,35 @@ basic functionality › lxor1 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$^\" (global $^_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"^\" (func $^_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $^_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $^_1113) - ) - (i32.const 3) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name ^))) (mimp_mod pervasives.gr) (mimp_name ^) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name ^))) (mimp_mod pervasives.gr) (mimp_name ^) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func ^_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ^_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.0c0b170b.0.snapshot b/compiler/test/__snapshots__/basic_functionality.0c0b170b.0.snapshot index 2381f4173a..c291df0772 100644 --- a/compiler/test/__snapshots__/basic_functionality.0c0b170b.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.0c0b170b.0.snapshot @@ -1,48 +1,35 @@ basic functionality › lor1 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$|\" (global $|_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"|\" (func $|_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $|_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $|_1113) - ) - (i32.const 3) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name |))) (mimp_mod pervasives.gr) (mimp_name |) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name |))) (mimp_mod pervasives.gr) (mimp_name |) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func |_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind |_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.0c400bde.0.snapshot b/compiler/test/__snapshots__/basic_functionality.0c400bde.0.snapshot index 1f2757e893..990fb85f5d 100644 --- a/compiler/test/__snapshots__/basic_functionality.0c400bde.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.0c400bde.0.snapshot @@ -1,48 +1,35 @@ basic functionality › modulo6 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$%\" (global $%_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"%\" (func $%_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $%_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $%_1113) - ) - (i32.const 35) - (i32.const 35) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func %_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind %_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 17))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 17))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.0e812a39.0.snapshot b/compiler/test/__snapshots__/basic_functionality.0e812a39.0.snapshot index ac5ef3233b..88510abd4a 100644 --- a/compiler/test/__snapshots__/basic_functionality.0e812a39.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.0e812a39.0.snapshot @@ -1,65 +1,60 @@ basic functionality › precedence1 -(module - (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 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$*\" (global $*_1116 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"*\" (func $*_1116 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.3 - (block $compile_store.2 - (local.set $6 - (call $*_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $*_1116) - ) - (i32.const 9) - (i32.const 13) - ) - ) - (block $do_backpatches.1 - ) - ) - (return_call $+_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1113) - ) - (i32.const 7) - (local.get $6) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func *_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind *_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func +_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.0f79ce35.0.snapshot b/compiler/test/__snapshots__/basic_functionality.0f79ce35.0.snapshot index 1ba18ed5d7..cec73d2f8b 100644 --- a/compiler/test/__snapshots__/basic_functionality.0f79ce35.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.0f79ce35.0.snapshot @@ -1,48 +1,38 @@ basic functionality › comp16 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (i32.const 2147483646) - (i32.const 2147483646) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type + (((Unmanaged WasmI32) (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.10dda088.0.snapshot b/compiler/test/__snapshots__/basic_functionality.10dda088.0.snapshot index ac8a9e2d25..aa2b2d96c6 100644 --- a/compiler/test/__snapshots__/basic_functionality.10dda088.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.10dda088.0.snapshot @@ -1,67 +1,51 @@ basic functionality › comp3 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$>=\" (global $>=_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \">=\" (func $>=_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.2 - (local.set $6 - (call $>=_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $>=_1114) - ) - (i32.const 5) - (i32.const 7) - ) - ) - (block $do_backpatches.1 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.3 (result i32) - (i32.const 9) - ) - (block $compile_block.4 (result i32) - (i32.const 11) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name >=))) (mimp_mod pervasives.gr) (mimp_name >=) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name >=))) (mimp_mod pervasives.gr) (mimp_name >=) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func >=_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind >=_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.122e74b0.0.snapshot b/compiler/test/__snapshots__/basic_functionality.122e74b0.0.snapshot index 86fd6579ef..58f96d8aa6 100644 --- a/compiler/test/__snapshots__/basic_functionality.122e74b0.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.122e74b0.0.snapshot @@ -1,112 +1,52 @@ basic functionality › print_line_ending1 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 8) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $print_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1113) - ) - (i32.const 3) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString \"\"))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MReturnCallKnown (func print_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind print_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.125626a9.0.snapshot b/compiler/test/__snapshots__/basic_functionality.125626a9.0.snapshot index e0f7a5415f..3b6a064392 100644 --- a/compiler/test/__snapshots__/basic_functionality.125626a9.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.125626a9.0.snapshot @@ -1,48 +1,35 @@ basic functionality › orshadow -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $+_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1114) - ) - (i32.const 3) - (i32.const 5) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func +_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.13335202.0.snapshot b/compiler/test/__snapshots__/basic_functionality.13335202.0.snapshot index da00cb8d1e..b1c87767c6 100644 --- a/compiler/test/__snapshots__/basic_functionality.13335202.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.13335202.0.snapshot @@ -1,65 +1,60 @@ basic functionality › precedence2 -(module - (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 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$*\" (global $*_1115 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"*\" (func $*_1115 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.3 - (block $compile_store.2 - (local.set $6 - (call $*_1115 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $*_1115) - ) - (i32.const 9) - (i32.const 13) - ) - ) - (block $do_backpatches.1 - ) - ) - (return_call $+_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1113) - ) - (local.get $6) - (i32.const 7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func *_1115) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind *_1115 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func +_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.1ad0f349.0.snapshot b/compiler/test/__snapshots__/basic_functionality.1ad0f349.0.snapshot index 5d0d6a8655..aafc3d5bda 100644 --- a/compiler/test/__snapshots__/basic_functionality.1ad0f349.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.1ad0f349.0.snapshot @@ -1,65 +1,60 @@ basic functionality › precedence3 -(module - (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 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$%\" (global $%_1116 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"%\" (func $%_1116 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.3 - (block $compile_store.2 - (local.set $6 - (call $%_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $%_1116) - ) - (i32.const 9) - (i32.const 13) - ) - ) - (block $do_backpatches.1 - ) - ) - (return_call $+_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1113) - ) - (i32.const 7) - (local.get $6) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func %_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind %_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func +_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.1ae16d82.0.snapshot b/compiler/test/__snapshots__/basic_functionality.1ae16d82.0.snapshot index c4ac6bdb5e..43cbf7b6b3 100644 --- a/compiler/test/__snapshots__/basic_functionality.1ae16d82.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.1ae16d82.0.snapshot @@ -1,48 +1,35 @@ basic functionality › binop4 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$*\" (global $*_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"*\" (func $*_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $*_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $*_1113) - ) - (i32.const 5) - (i32.const 7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func *_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind *_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.1b68c8db.0.snapshot b/compiler/test/__snapshots__/basic_functionality.1b68c8db.0.snapshot index 2754fe0c88..c4e606af15 100644 --- a/compiler/test/__snapshots__/basic_functionality.1b68c8db.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.1b68c8db.0.snapshot @@ -1,48 +1,35 @@ basic functionality › lsl1 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$<<\" (global $<<_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"<<\" (func $<<_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $<<_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $<<_1113) - ) - (i32.const 15) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name <<))) (mimp_mod pervasives.gr) (mimp_name <<) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name <<))) (mimp_mod pervasives.gr) (mimp_name <<) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func <<_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind <<_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 7))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.1bf5759c.0.snapshot b/compiler/test/__snapshots__/basic_functionality.1bf5759c.0.snapshot index 1b7cb1b034..88d0a89219 100644 --- a/compiler/test/__snapshots__/basic_functionality.1bf5759c.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.1bf5759c.0.snapshot @@ -1,72 +1,110 @@ basic functionality › unsafe_wasm_globals -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_f64_=>_i32 (func (param i32 f64) (result i32))) - (type $i32_f32_=>_i32 (func (param i32 f32) (result i32))) - (type $i32_i64_=>_i32 (func (param i32 i64) (result i32))) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$unsafeWasmGlobalsExports.gr\" \"GRAIN$EXPORT$_F64_VAL\" (global $_F64_VAL_1159 (mut f64))) - (import \"GRAIN$MODULE$runtime/debugPrint.gr\" \"GRAIN$EXPORT$printF64\" (global $printF64_1158 (mut i32))) - (import \"GRAIN$MODULE$unsafeWasmGlobalsExports.gr\" \"GRAIN$EXPORT$_F32_VAL\" (global $_F32_VAL_1157 (mut f32))) - (import \"GRAIN$MODULE$runtime/debugPrint.gr\" \"GRAIN$EXPORT$printF32\" (global $printF32_1156 (mut i32))) - (import \"GRAIN$MODULE$unsafeWasmGlobalsExports.gr\" \"GRAIN$EXPORT$_I64_VAL\" (global $_I64_VAL_1155 (mut i64))) - (import \"GRAIN$MODULE$runtime/debugPrint.gr\" \"GRAIN$EXPORT$printI64\" (global $printI64_1154 (mut i32))) - (import \"GRAIN$MODULE$unsafeWasmGlobalsExports.gr\" \"GRAIN$EXPORT$_I32_VAL\" (global $_I32_VAL_1153 (mut i32))) - (import \"GRAIN$MODULE$runtime/debugPrint.gr\" \"GRAIN$EXPORT$printI32\" (global $printI32_1152 (mut i32))) - (import \"GRAIN$MODULE$runtime/debugPrint.gr\" \"printF64\" (func $printF64_1158 (param i32 f64) (result i32))) - (import \"GRAIN$MODULE$runtime/debugPrint.gr\" \"printF32\" (func $printF32_1156 (param i32 f32) (result i32))) - (import \"GRAIN$MODULE$runtime/debugPrint.gr\" \"printI64\" (func $printI64_1154 (param i32 i64) (result i32))) - (import \"GRAIN$MODULE$runtime/debugPrint.gr\" \"printI32\" (func $printI32_1152 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (drop - (call $printI32_1152 - (global.get $printI32_1152) - (global.get $_I32_VAL_1153) - ) - ) - (drop - (call $printI64_1154 - (global.get $printI64_1154) - (global.get $_I64_VAL_1155) - ) - ) - (drop - (call $printF32_1156 - (global.get $printF32_1156) - (global.get $_F32_VAL_1157) - ) - ) - (return_call $printF64_1158 - (global.get $printF64_1158) - (global.get $_F64_VAL_1159) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 509 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name _F64_VAL))) (mimp_mod unsafeWasmGlobalsExports.gr) + (mimp_name _F64_VAL) + (mimp_type (MGlobalImport (Unmanaged WasmF64) true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name printF64))) (mimp_mod runtime/debugPrint.gr) + (mimp_name printF64) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmF64)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name printF64))) (mimp_mod runtime/debugPrint.gr) + (mimp_name printF64) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name _F32_VAL))) (mimp_mod unsafeWasmGlobalsExports.gr) + (mimp_name _F32_VAL) + (mimp_type (MGlobalImport (Unmanaged WasmF32) true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name printF32))) (mimp_mod runtime/debugPrint.gr) + (mimp_name printF32) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmF32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name printF32))) (mimp_mod runtime/debugPrint.gr) + (mimp_name printF32) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name _I64_VAL))) (mimp_mod unsafeWasmGlobalsExports.gr) + (mimp_name _I64_VAL) + (mimp_type (MGlobalImport (Unmanaged WasmI64) true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name printI64))) (mimp_mod runtime/debugPrint.gr) + (mimp_name printI64) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI64)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name printI64))) (mimp_mod runtime/debugPrint.gr) + (mimp_name printI64) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name _I32_VAL))) (mimp_mod unsafeWasmGlobalsExports.gr) + (mimp_name _I32_VAL) + (mimp_type (MGlobalImport (Unmanaged WasmI32) true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name printI32))) (mimp_mod runtime/debugPrint.gr) + (mimp_name printI32) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name printI32))) (mimp_mod runtime/debugPrint.gr) + (mimp_name printI32) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func printI32_1152) + (closure + ((immediate_desc + (MImmBinding (MGlobalBind printI32_1152 Managed))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (((Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MImmBinding (MGlobalBind _I32_VAL_1153 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func printI64_1154) + (closure + ((immediate_desc + (MImmBinding (MGlobalBind printI64_1154 Managed))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (((Unmanaged WasmI64)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MImmBinding (MGlobalBind _I64_VAL_1155 (Unmanaged WasmI64)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func printF32_1156) + (closure + ((immediate_desc + (MImmBinding (MGlobalBind printF32_1156 Managed))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (((Unmanaged WasmF32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MImmBinding (MGlobalBind _F32_VAL_1157 (Unmanaged WasmF32)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MReturnCallKnown (func printF64_1158) + (closure + ((immediate_desc (MImmBinding (MGlobalBind printF64_1158 Managed))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (((Unmanaged WasmF64)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MImmBinding (MGlobalBind _F64_VAL_1159 (Unmanaged WasmF64)))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.1d2ec323.0.snapshot b/compiler/test/__snapshots__/basic_functionality.1d2ec323.0.snapshot index 020c5a1280..e38c80bf47 100644 --- a/compiler/test/__snapshots__/basic_functionality.1d2ec323.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.1d2ec323.0.snapshot @@ -1,260 +1,109 @@ basic functionality › comp22 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$isnt\" (global $isnt_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"isnt\" (func $isnt_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (block $compile_block.19 - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_tuple.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.15 - (local.set $10 - (block $allocate_adt.13 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.18 - (local.set $11 - (block $allocate_adt.16 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (local.get $9) - ) - (i32.store offset=24 - (local.get $0) - (local.get $10) - ) - (local.get $0) - ) - ) - (block $do_backpatches.17 - ) - ) - (return_call $isnt_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $isnt_1113) - ) - (local.get $8) - (local.get $11) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name isnt))) (mimp_mod pervasives.gr) (mimp_name isnt) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name isnt))) (mimp_mod pervasives.gr) (mimp_name isnt) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MReturnCallKnown (func isnt_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind isnt_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 6) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.1e4b1f39.0.snapshot b/compiler/test/__snapshots__/basic_functionality.1e4b1f39.0.snapshot index 147bc96820..cb6a6e39a0 100644 --- a/compiler/test/__snapshots__/basic_functionality.1e4b1f39.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.1e4b1f39.0.snapshot @@ -1,48 +1,35 @@ basic functionality › land1 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$&\" (global $&_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"&\" (func $&_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $&_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $&_1113) - ) - (i32.const 3) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name &))) (mimp_mod pervasives.gr) (mimp_name &) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name &))) (mimp_mod pervasives.gr) (mimp_name &) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func &_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind &_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.1f787365.0.snapshot b/compiler/test/__snapshots__/basic_functionality.1f787365.0.snapshot index 6039c5a95b..8b43f4d367 100644 --- a/compiler/test/__snapshots__/basic_functionality.1f787365.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.1f787365.0.snapshot @@ -1,88 +1,55 @@ basic functionality › orshort2 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.4 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (drop - (call $print_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1113) - ) - (i32.const 3) - (local.get $6) - ) - ) - (i32.const 2147483646) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func print_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.20f7581b.0.snapshot b/compiler/test/__snapshots__/basic_functionality.20f7581b.0.snapshot index b793ef5c15..ecfefff71e 100644 --- a/compiler/test/__snapshots__/basic_functionality.20f7581b.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.20f7581b.0.snapshot @@ -1,35 +1,15 @@ basic functionality › simple_min -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -2147483647) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 -1073741824))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.240ef39e.0.snapshot b/compiler/test/__snapshots__/basic_functionality.240ef39e.0.snapshot index a37c84ec63..1f8d20465f 100644 --- a/compiler/test/__snapshots__/basic_functionality.240ef39e.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.240ef39e.0.snapshot @@ -1,67 +1,50 @@ basic functionality › comp4 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$>\" (global $>_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \">\" (func $>_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.2 - (local.set $6 - (call $>_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $>_1114) - ) - (i32.const 5) - (i32.const 7) - ) - ) - (block $do_backpatches.1 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.3 (result i32) - (i32.const 9) - ) - (block $compile_block.4 (result i32) - (i32.const 11) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name >))) (mimp_mod pervasives.gr) (mimp_name >) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name >))) (mimp_mod pervasives.gr) (mimp_name >) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func >_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind >_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.2756b429.0.snapshot b/compiler/test/__snapshots__/basic_functionality.2756b429.0.snapshot index 269bbdd8a1..6f5dc835d5 100644 --- a/compiler/test/__snapshots__/basic_functionality.2756b429.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.2756b429.0.snapshot @@ -1,35 +1,15 @@ basic functionality › forty -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 81) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 40))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.27a7e2f7.0.snapshot b/compiler/test/__snapshots__/basic_functionality.27a7e2f7.0.snapshot index cdd63deb09..432c141a10 100644 --- a/compiler/test/__snapshots__/basic_functionality.27a7e2f7.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.27a7e2f7.0.snapshot @@ -1,65 +1,11 @@ basic functionality › bigint_start_pos -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (i64.store offset=16 - (local.get $0) - (i64.const -1) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MBigInt (flags ()) (limbs (-1)))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.28405f1f.0.snapshot b/compiler/test/__snapshots__/basic_functionality.28405f1f.0.snapshot index e936146093..47a630d275 100644 --- a/compiler/test/__snapshots__/basic_functionality.28405f1f.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.28405f1f.0.snapshot @@ -1,65 +1,60 @@ basic functionality › precedence4 -(module - (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 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$%\" (global $%_1115 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"%\" (func $%_1115 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.3 - (block $compile_store.2 - (local.set $6 - (call $%_1115 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $%_1115) - ) - (i32.const 9) - (i32.const 13) - ) - ) - (block $do_backpatches.1 - ) - ) - (return_call $+_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1113) - ) - (local.get $6) - (i32.const 7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func %_1115) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind %_1115 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func +_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.28bf4c9e.0.snapshot b/compiler/test/__snapshots__/basic_functionality.28bf4c9e.0.snapshot index 0237f8d80b..f8d2b474c5 100644 --- a/compiler/test/__snapshots__/basic_functionality.28bf4c9e.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.28bf4c9e.0.snapshot @@ -1,48 +1,35 @@ basic functionality › binop2 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $-_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1113) - ) - (i32.const 5) - (i32.const 5) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func -_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.2bcc447b.0.snapshot b/compiler/test/__snapshots__/basic_functionality.2bcc447b.0.snapshot index 2096b8083b..0dc01ece7b 100644 --- a/compiler/test/__snapshots__/basic_functionality.2bcc447b.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.2bcc447b.0.snapshot @@ -1,186 +1,98 @@ basic functionality › assert2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"GRAIN$EXPORT$panicWithException\" (global $GRAIN$EXPORT$panicWithException_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1116 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/exception.gr\" \"panicWithException\" (func $panicWithException_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1116 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.14 (result i32) - (block $compile_store.2 - (local.set $6 - (call $+_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1116) - ) - (i32.const 7) - (i32.const 7) - ) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $9 - (call $==_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1114) - ) - (local.get $6) - (i32.const 13) - ) - ) - (block $do_backpatches.3 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $9) - (i32.const 31) - ) - (block $compile_block.5 (result i32) - (i32.const 1879048190) - ) - (block $compile_block.13 - (block $compile_store.8 - (local.set $7 - (block $allocate_string.6 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 64) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 51) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 8028075845441778497) - ) - (i64.store offset=16 - (local.get $0) - (i64.const 2322294380849939822) - ) - (i64.store offset=24 - (local.get $0) - (i64.const 8028075845441778497) - ) - (i64.store offset=32 - (local.get $0) - (i64.const 7234307576302018670) - ) - (i64.store offset=40 - (local.get $0) - (i64.const 7310313481145575712) - ) - (i64.store offset=48 - (local.get $0) - (i64.const 7956009102162949234) - ) - (i64.store offset=56 - (local.get $0) - (i64.const 3219557) - ) - (local.get $0) - ) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.11 - (local.set $8 - (block $allocate_adt.9 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 59) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 65) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=20 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $throw.12 - (drop - (call $panicWithException_0 - (global.get $GRAIN$EXPORT$panicWithException_0) - (local.get $8) - ) - ) - (unreachable) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func +_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func ==_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind ==_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MString + \"AssertionError: Assertion failed in assert2, line 1\"))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 29))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 32))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MPrim1 Throw + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + (main_body_stack_size + ((stack_size_ptr 3) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.2cb30a54.0.snapshot b/compiler/test/__snapshots__/basic_functionality.2cb30a54.0.snapshot index 8b73fb0d95..25fc9f055c 100644 --- a/compiler/test/__snapshots__/basic_functionality.2cb30a54.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.2cb30a54.0.snapshot @@ -1,65 +1,13 @@ basic functionality › bigint_start_neg -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i64.store offset=16 - (local.get $0) - (i64.const -1) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate (MBigInt (flags (BigIntNegative)) (limbs (-1)))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.2d7e34cf.0.snapshot b/compiler/test/__snapshots__/basic_functionality.2d7e34cf.0.snapshot index ae9e0d8841..99b6e76107 100644 --- a/compiler/test/__snapshots__/basic_functionality.2d7e34cf.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.2d7e34cf.0.snapshot @@ -1,35 +1,15 @@ basic functionality › and2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 2147483646) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.2f2f8795.0.snapshot b/compiler/test/__snapshots__/basic_functionality.2f2f8795.0.snapshot index 44f59ae1b2..c4fd01cc01 100644 --- a/compiler/test/__snapshots__/basic_functionality.2f2f8795.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.2f2f8795.0.snapshot @@ -1,48 +1,35 @@ basic functionality › lsl2 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$<<\" (global $<<_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"<<\" (func $<<_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $<<_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $<<_1113) - ) - (i32.const 1) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name <<))) (mimp_mod pervasives.gr) (mimp_name <<) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name <<))) (mimp_mod pervasives.gr) (mimp_name <<) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func <<_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind <<_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.2f53324c.0.snapshot b/compiler/test/__snapshots__/basic_functionality.2f53324c.0.snapshot index 64450037bd..2816887d20 100644 --- a/compiler/test/__snapshots__/basic_functionality.2f53324c.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.2f53324c.0.snapshot @@ -1,48 +1,37 @@ basic functionality › comp17 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$isnt\" (global $isnt_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"isnt\" (func $isnt_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $isnt_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $isnt_1113) - ) - (i32.const 2147483646) - (i32.const -2) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name isnt))) (mimp_mod pervasives.gr) (mimp_name isnt) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name isnt))) (mimp_mod pervasives.gr) (mimp_name isnt) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func isnt_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind isnt_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type + (((Unmanaged WasmI32) (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.2f65c8cf.0.snapshot b/compiler/test/__snapshots__/basic_functionality.2f65c8cf.0.snapshot index cf253a5373..e26d7c5c88 100644 --- a/compiler/test/__snapshots__/basic_functionality.2f65c8cf.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.2f65c8cf.0.snapshot @@ -1,35 +1,15 @@ basic functionality › fals -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 2147483646) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.304ca65f.0.snapshot b/compiler/test/__snapshots__/basic_functionality.304ca65f.0.snapshot index 857a37750a..73ac1cb3d8 100644 --- a/compiler/test/__snapshots__/basic_functionality.304ca65f.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.304ca65f.0.snapshot @@ -1,35 +1,15 @@ basic functionality › oct_neg -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -125) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 -63))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.31e0d562.0.snapshot b/compiler/test/__snapshots__/basic_functionality.31e0d562.0.snapshot index 0589e6612a..eaea29585b 100644 --- a/compiler/test/__snapshots__/basic_functionality.31e0d562.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.31e0d562.0.snapshot @@ -1,57 +1,11 @@ basic functionality › infinity -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (f64.store offset=8 - (local.get $0) - (f64.const inf) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MFloat64 9218868437227405312)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.32a8c452.0.snapshot b/compiler/test/__snapshots__/basic_functionality.32a8c452.0.snapshot index 030c9ebdb3..95fb7aec20 100644 --- a/compiler/test/__snapshots__/basic_functionality.32a8c452.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.32a8c452.0.snapshot @@ -1,102 +1,73 @@ basic functionality › complex2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1116 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1116 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.6 - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (call $+_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1116) - ) - (i32.const 5) - (i32.const 7) - ) - ) - (block $do_backpatches.4 - ) - ) - (return_call $print_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1113) - ) - (local.get $7) - (local.get $6) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func +_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func print_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind print_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.34dcfbdd.0.snapshot b/compiler/test/__snapshots__/basic_functionality.34dcfbdd.0.snapshot index 20ccce0ac1..59db7119e7 100644 --- a/compiler/test/__snapshots__/basic_functionality.34dcfbdd.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.34dcfbdd.0.snapshot @@ -1,57 +1,11 @@ basic functionality › int64_1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 99999999999999999) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MInt64 99999999999999999)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.3c2ba165.0.snapshot b/compiler/test/__snapshots__/basic_functionality.3c2ba165.0.snapshot index d38657bc3b..f3602a6b3a 100644 --- a/compiler/test/__snapshots__/basic_functionality.3c2ba165.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.3c2ba165.0.snapshot @@ -1,292 +1,125 @@ basic functionality › comp20 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$isnt\" (global $isnt_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"isnt\" (func $isnt_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (block $compile_block.19 - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_adt.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.15 - (local.set $10 - (block $allocate_adt.13 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.18 - (local.set $11 - (block $allocate_adt.16 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=24 - (local.get $0) - (local.get $10) - ) - (local.get $0) - ) - ) - (block $do_backpatches.17 - ) - ) - (return_call $isnt_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $isnt_1113) - ) - (local.get $8) - (local.get $11) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name isnt))) (mimp_mod pervasives.gr) (mimp_name isnt) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name isnt))) (mimp_mod pervasives.gr) (mimp_name isnt) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MReturnCallKnown (func isnt_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind isnt_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 6) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.3e5f990b.0.snapshot b/compiler/test/__snapshots__/basic_functionality.3e5f990b.0.snapshot index 5cceacca29..05f87b0761 100644 --- a/compiler/test/__snapshots__/basic_functionality.3e5f990b.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.3e5f990b.0.snapshot @@ -1,48 +1,35 @@ basic functionality › lor3 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$|\" (global $|_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"|\" (func $|_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $|_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $|_1113) - ) - (i32.const 1) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name |))) (mimp_mod pervasives.gr) (mimp_name |) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name |))) (mimp_mod pervasives.gr) (mimp_name |) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func |_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind |_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.3edefd23.0.snapshot b/compiler/test/__snapshots__/basic_functionality.3edefd23.0.snapshot index eb7bdd441e..06f4509914 100644 --- a/compiler/test/__snapshots__/basic_functionality.3edefd23.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.3edefd23.0.snapshot @@ -1,46 +1,32 @@ basic functionality › decr_3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$decr\" (global $decr_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"decr\" (func $decr_1113 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $decr_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $decr_1113) - ) - (i32.const 1) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name decr))) (mimp_mod pervasives.gr) (mimp_name decr) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name decr))) (mimp_mod pervasives.gr) (mimp_name decr) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func decr_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind decr_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.3ffd0bf3.0.snapshot b/compiler/test/__snapshots__/basic_functionality.3ffd0bf3.0.snapshot index b0e2e3dbcd..bedb9f830d 100644 --- a/compiler/test/__snapshots__/basic_functionality.3ffd0bf3.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.3ffd0bf3.0.snapshot @@ -1,35 +1,15 @@ basic functionality › orshort1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -2) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.427c6671.0.snapshot b/compiler/test/__snapshots__/basic_functionality.427c6671.0.snapshot index 552237e7d7..1e087eb3d3 100644 --- a/compiler/test/__snapshots__/basic_functionality.427c6671.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.427c6671.0.snapshot @@ -1,53 +1,11 @@ basic functionality › uint64_1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_uint64.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 12) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 99999999999999999) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MUint64 99999999999999999)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.448497ab.0.snapshot b/compiler/test/__snapshots__/basic_functionality.448497ab.0.snapshot index 547ac7c6c4..5cbb1df97b 100644 --- a/compiler/test/__snapshots__/basic_functionality.448497ab.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.448497ab.0.snapshot @@ -1,35 +1,15 @@ basic functionality › binop5 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 5) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.46348f36.0.snapshot b/compiler/test/__snapshots__/basic_functionality.46348f36.0.snapshot index 43c408598f..9ae9f34952 100644 --- a/compiler/test/__snapshots__/basic_functionality.46348f36.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.46348f36.0.snapshot @@ -1,76 +1,69 @@ basic functionality › precedence5 -(module - (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 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$<\" (global $<_1117 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$>\" (global $>_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"<\" (func $<_1117 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \">\" (func $>_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.2 - (local.set $6 - (call $>_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $>_1114) - ) - (i32.const 9) - (i32.const 7) - ) - ) - (block $do_backpatches.1 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.3 - (return_call $<_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $<_1117) - ) - (i32.const 19) - (i32.const 27) - ) - ) - (block $compile_block.4 (result i32) - (local.get $6) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name >))) (mimp_mod pervasives.gr) (mimp_name >) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name >))) (mimp_mod pervasives.gr) (mimp_name >) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func >_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind >_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + (((instr_desc + (MReturnCallKnown (func <_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind <_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 9))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 13))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last))))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.48db380c.0.snapshot b/compiler/test/__snapshots__/basic_functionality.48db380c.0.snapshot index cb94986b24..279a92c570 100644 --- a/compiler/test/__snapshots__/basic_functionality.48db380c.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.48db380c.0.snapshot @@ -1,35 +1,15 @@ basic functionality › if4 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 7) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.4d1501b9.0.snapshot b/compiler/test/__snapshots__/basic_functionality.4d1501b9.0.snapshot deleted file mode 100644 index 60072f874a..0000000000 --- a/compiler/test/__snapshots__/basic_functionality.4d1501b9.0.snapshot +++ /dev/null @@ -1,57 +0,0 @@ -basic functionality › nan -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (f64.store offset=8 - (local.get $0) - (f64.const nan:0x8000000000000) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) diff --git a/compiler/test/__snapshots__/basic_functionality.4d6f9417.0.snapshot b/compiler/test/__snapshots__/basic_functionality.4d6f9417.0.snapshot index a40b2ea9f4..3bccce3c18 100644 --- a/compiler/test/__snapshots__/basic_functionality.4d6f9417.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.4d6f9417.0.snapshot @@ -1,35 +1,15 @@ basic functionality › not1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 2147483646) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.4f5bd247.0.snapshot b/compiler/test/__snapshots__/basic_functionality.4f5bd247.0.snapshot index 7dac306da3..29538fd135 100644 --- a/compiler/test/__snapshots__/basic_functionality.4f5bd247.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.4f5bd247.0.snapshot @@ -1,57 +1,11 @@ basic functionality › heap_number_i64_wrapper -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 2147483648) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MInt64 2147483648)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.52ca8e0e.0.snapshot b/compiler/test/__snapshots__/basic_functionality.52ca8e0e.0.snapshot index d0364f37f0..11b09b26f0 100644 --- a/compiler/test/__snapshots__/basic_functionality.52ca8e0e.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.52ca8e0e.0.snapshot @@ -1,261 +1,145 @@ basic functionality › func_shadow -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1118 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1118 (param i32 i32 i32) (result i32))) - (global $foo_1115 (mut i32) (i32.const 0)) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1113 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (block $compile_block.3 (result i32) - (tuple.extract 0 - (tuple.make - (block $allocate_string.2 (result i32) - (i32.store - (local.tee $1 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $1) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $1) - (i64.const 7496034) - ) - (local.get $1) - ) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $foo_1115 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (block $compile_block.6 (result i32) - (tuple.extract 0 - (tuple.make - (block $allocate_string.5 (result i32) - (i32.store - (local.tee $1 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $1) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $1) - (i64.const 8020322) - ) - (local.get $1) - ) - (block $cleanup.4 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.21 - (block $compile_store.8 - (global.set $foo_1113 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.11 - (local.set $6 - (block $allocate_adt.9 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $7 - (call $foo_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1113) - ) - ) - ) - (block $do_backpatches.12 - ) - ) - (drop - (call $print_1118 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1118) - ) - (local.get $7) - (local.get $6) - ) - ) - (block $compile_store.15 - (global.set $foo_1115 - (i32.const 0) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.18 - (local.set $8 - (block $allocate_adt.16 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.20 - (local.set $9 - (call $foo_1115 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1115) - ) - ) - ) - (block $do_backpatches.19 - ) - ) - (return_call $print_1118 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1118) - ) - (local.get $9) - (local.get $8) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 374 -) +((mash_code + ((functions + (((id ((name foo))) (name (foo)) (args (Managed)) (return_type (Managed)) + (closure ()) + (body + (((instr_desc + (MCleanup (((instr_desc (MAllocate (MString bar))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())) + ((id ((name foo))) (name (foo)) (args (Managed)) (return_type (Managed)) + (closure ()) + (body + (((instr_desc + (MCleanup (((instr_desc (MAllocate (MString baz))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func foo_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind foo_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (() (Managed))) (args ()))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func print_1118) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1118 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind foo_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MCallKnown (func foo_1115) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind foo_1115 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (() (Managed))) (args ()))))))))) + ((instr_desc + (MReturnCallKnown (func print_1118) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind print_1118 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 4) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name foo))) (mutable_ true) (allocation_type Managed) + (initial_value ())) + ((id ((name foo))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.565dbeda.0.snapshot b/compiler/test/__snapshots__/basic_functionality.565dbeda.0.snapshot index f18cf7240f..c0a321c3e4 100644 --- a/compiler/test/__snapshots__/basic_functionality.565dbeda.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.565dbeda.0.snapshot @@ -1,35 +1,15 @@ basic functionality › hex_neg -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -509) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 -255))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.5705b20c.0.snapshot b/compiler/test/__snapshots__/basic_functionality.5705b20c.0.snapshot index c1004010ce..36656fdc9f 100644 --- a/compiler/test/__snapshots__/basic_functionality.5705b20c.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.5705b20c.0.snapshot @@ -1,48 +1,35 @@ basic functionality › modulo5 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$%\" (global $%_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"%\" (func $%_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $%_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $%_1113) - ) - (i32.const 35) - (i32.const -33) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func %_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind %_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 17))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 -17))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.593b8d63.0.snapshot b/compiler/test/__snapshots__/basic_functionality.593b8d63.0.snapshot index f451431079..3424e21c40 100644 --- a/compiler/test/__snapshots__/basic_functionality.593b8d63.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.593b8d63.0.snapshot @@ -1,113 +1,95 @@ basic functionality › if_one_sided6 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1121 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$<\" (global $<_1116 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1121 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"<\" (func $<_1116 (param i32 i32 i32) (result i32))) - (global $x_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.10 (result i32) - (block $compile_store.2 - (global.set $x_1113 - (i32.const 3) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $7 - (call $<_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $<_1116) - ) - (i32.const 7) - (i32.const 9) - ) - ) - (block $do_backpatches.3 - ) - ) - (drop - (if (result i32) - (i32.shr_u - (local.get $7) - (i32.const 31) - ) - (block $compile_block.8 (result i32) - (block $compile_store.6 - (local.set $6 - (call $+_1121 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1121) - ) - (i32.const 5) - (i32.const 7) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_set.7 (result i32) - (global.set $x_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $x_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_block.9 (result i32) - (i32.const 1879048190) - ) - ) - ) - (global.get $x_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind x_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func <_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind <_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func +_1121) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1121 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MSet (MGlobalBind x_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind x_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name x))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.5b56d472.0.snapshot b/compiler/test/__snapshots__/basic_functionality.5b56d472.0.snapshot index f18af66caa..15e3a2b9ea 100644 --- a/compiler/test/__snapshots__/basic_functionality.5b56d472.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.5b56d472.0.snapshot @@ -1,35 +1,15 @@ basic functionality › and3 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 2147483646) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.5cd54e52.0.snapshot b/compiler/test/__snapshots__/basic_functionality.5cd54e52.0.snapshot index 9fa9298045..449f836455 100644 --- a/compiler/test/__snapshots__/basic_functionality.5cd54e52.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.5cd54e52.0.snapshot @@ -1,35 +1,15 @@ basic functionality › or4 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 2147483646) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.5d973a3e.0.snapshot b/compiler/test/__snapshots__/basic_functionality.5d973a3e.0.snapshot index 213e0f4ea8..fb1de315ab 100644 --- a/compiler/test/__snapshots__/basic_functionality.5d973a3e.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.5d973a3e.0.snapshot @@ -1,48 +1,35 @@ basic functionality › binop6 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$%\" (global $%_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"%\" (func $%_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $%_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $%_1113) - ) - (i32.const 19) - (i32.const 11) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func %_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind %_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 9))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.61c58118.0.snapshot b/compiler/test/__snapshots__/basic_functionality.61c58118.0.snapshot index 4ea5c5a801..6c4d442e67 100644 --- a/compiler/test/__snapshots__/basic_functionality.61c58118.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.61c58118.0.snapshot @@ -1,78 +1,47 @@ basic functionality › block_no_expression -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $f_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $f_1113 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (block $compile_block.2 (result i32) - (tuple.extract 0 - (tuple.make - (i32.const 1879048190) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.5 - (block $compile_store.4 - (global.set $f_1113 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (return_call $f_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $f_1113) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions + (((id ((name f))) (name (f)) (args (Managed)) + (return_type ((Unmanaged WasmI32))) (closure ()) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown)))))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind f_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MReturnCallKnown (func f_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind f_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (() ((Unmanaged WasmI32)))) (args ())))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name f))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.626b2e44.0.snapshot b/compiler/test/__snapshots__/basic_functionality.626b2e44.0.snapshot index af8a0cb99c..3662d037ff 100644 --- a/compiler/test/__snapshots__/basic_functionality.626b2e44.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.626b2e44.0.snapshot @@ -1,110 +1,89 @@ basic functionality › if_one_sided5 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1121 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$<\" (global $<_1116 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1121 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"<\" (func $<_1116 (param i32 i32 i32) (result i32))) - (global $x_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.10 (result i32) - (block $compile_store.2 - (global.set $x_1113 - (i32.const 3) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $7 - (call $<_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $<_1116) - ) - (i32.const 7) - (i32.const 9) - ) - ) - (block $do_backpatches.3 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $7) - (i32.const 31) - ) - (block $compile_block.8 (result i32) - (block $compile_store.6 - (local.set $6 - (call $+_1121 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1121) - ) - (i32.const 5) - (i32.const 7) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_set.7 (result i32) - (global.set $x_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $x_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_block.9 (result i32) - (i32.const 1879048190) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind x_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func <_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind <_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func +_1121) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1121 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MSet (MGlobalBind x_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown))))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name x))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.65d36891.0.snapshot b/compiler/test/__snapshots__/basic_functionality.65d36891.0.snapshot index 3db36ae851..f9f841905d 100644 --- a/compiler/test/__snapshots__/basic_functionality.65d36891.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.65d36891.0.snapshot @@ -1,48 +1,35 @@ basic functionality › lor2 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$|\" (global $|_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"|\" (func $|_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $|_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $|_1113) - ) - (i32.const 3) - (i32.const 1) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name |))) (mimp_mod pervasives.gr) (mimp_name |) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name |))) (mimp_mod pervasives.gr) (mimp_name |) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func |_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind |_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.67d2cc45.0.snapshot b/compiler/test/__snapshots__/basic_functionality.67d2cc45.0.snapshot index 528e6e32c1..1e628e3985 100644 --- a/compiler/test/__snapshots__/basic_functionality.67d2cc45.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.67d2cc45.0.snapshot @@ -1,48 +1,35 @@ basic functionality › binop3 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $-_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1113) - ) - (i32.const 5) - (i32.const 9) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func -_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.684b6ecb.0.snapshot b/compiler/test/__snapshots__/basic_functionality.684b6ecb.0.snapshot index 2456fd12ac..7237c486b4 100644 --- a/compiler/test/__snapshots__/basic_functionality.684b6ecb.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.684b6ecb.0.snapshot @@ -1,48 +1,35 @@ basic functionality › binop2.2 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $-_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1113) - ) - (i32.const 5) - (i32.const 5) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func -_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.68d08483.0.snapshot b/compiler/test/__snapshots__/basic_functionality.68d08483.0.snapshot index 2ea4898657..dcadd29830 100644 --- a/compiler/test/__snapshots__/basic_functionality.68d08483.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.68d08483.0.snapshot @@ -1,48 +1,35 @@ basic functionality › land2 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$&\" (global $&_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"&\" (func $&_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $&_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $&_1113) - ) - (i32.const 3) - (i32.const 1) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name &))) (mimp_mod pervasives.gr) (mimp_name &) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name &))) (mimp_mod pervasives.gr) (mimp_name &) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func &_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind &_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.6f9706c2.0.snapshot b/compiler/test/__snapshots__/basic_functionality.6f9706c2.0.snapshot index d17a157cff..0cee1d39ad 100644 --- a/compiler/test/__snapshots__/basic_functionality.6f9706c2.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.6f9706c2.0.snapshot @@ -1,35 +1,15 @@ basic functionality › or1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -2) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.704872bc.0.snapshot b/compiler/test/__snapshots__/basic_functionality.704872bc.0.snapshot index 42f12e1f22..be84a1a89a 100644 --- a/compiler/test/__snapshots__/basic_functionality.704872bc.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.704872bc.0.snapshot @@ -1,35 +1,15 @@ basic functionality › assert1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 1879048190) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.711a4824.0.snapshot b/compiler/test/__snapshots__/basic_functionality.711a4824.0.snapshot index 2c5df87c49..0f5bced37e 100644 --- a/compiler/test/__snapshots__/basic_functionality.711a4824.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.711a4824.0.snapshot @@ -1,784 +1,530 @@ basic functionality › pattern_match_unsafe_wasm -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1125 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1125 (param i32 i32 i32) (result i32))) - (global $test_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $test_1113 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (local $7 i32) - (block $compile_block.4 - (block $compile_store.2 - (local.set $7 - (i32.const 0) - ) - (block $do_backpatches.1 - ) - ) - (drop - (call $foo_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (i32.const 0) - ) - ) - (drop - (call $foo_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (i32.const 1) - ) - ) - (drop - (call $foo_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (i32.const 5) - ) - ) - (drop - (call $foo_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (i32.const 8) - ) - ) - (block $cleanup.3 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $foo_1114 - (local.get $7) - (i32.const 42) - ) - ) - ) - (func $foo_1114 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (block $compile_block.72 (result i32) - (block $compile_store.6 - (local.set $16 - (i32.or - (i32.shl - (i32.eq - (local.get $1) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.30 - (local.set $17 - (if (result i32) - (i32.shr_u - (local.get $16) - (i32.const 31) - ) - (block $compile_block.7 (result i32) - (i32.const 1) - ) - (block $compile_block.28 (result i32) - (block $compile_store.9 - (local.set $18 - (i32.or - (i32.shl - (i32.eq - (local.get $1) - (i32.const 2) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.8 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $18) - (i32.const 31) - ) - (block $compile_block.10 (result i32) - (i32.const 3) - ) - (block $compile_block.27 (result i32) - (block $compile_store.12 - (local.set $19 - (i32.or - (i32.shl - (i32.eq - (local.get $1) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.11 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $19) - (i32.const 31) - ) - (block $compile_block.13 (result i32) - (i32.const 5) - ) - (block $compile_block.26 (result i32) - (block $compile_store.15 - (local.set $20 - (i32.or - (i32.shl - (i32.eq - (local.get $1) - (i32.const 4) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.14 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $20) - (i32.const 31) - ) - (block $compile_block.16 (result i32) - (i32.const 7) - ) - (block $compile_block.25 (result i32) - (block $compile_store.18 - (local.set $21 - (i32.or - (i32.shl - (i32.eq - (local.get $1) - (i32.const 5) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.17 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $21) - (i32.const 31) - ) - (block $compile_block.19 (result i32) - (i32.const 9) - ) - (block $compile_block.24 (result i32) - (block $compile_store.21 - (local.set $22 - (i32.or - (i32.shl - (i32.eq - (local.get $1) - (i32.const 6) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.20 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $22) - (i32.const 31) - ) - (block $compile_block.22 (result i32) - (i32.const 11) - ) - (block $compile_block.23 (result i32) - (i32.const 13) - ) - ) - ) - ) - ) - ) - ) - ) - ) - ) - ) - ) - ) - (block $do_backpatches.29 - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.32_outer (result i32) - (block $switch.32_branch_0 (result i32) - (drop - (block $switch.32_branch_1 (result i32) - (drop - (block $switch.32_branch_2 (result i32) - (drop - (block $switch.32_branch_3 (result i32) - (drop - (block $switch.32_branch_4 (result i32) - (drop - (block $switch.32_branch_5 (result i32) - (drop - (block $switch.32_branch_6 (result i32) - (drop - (block $switch.32_branch_7 (result i32) - (drop - (block $switch.32_default (result i32) - (br_table $switch.32_branch_1 $switch.32_branch_2 $switch.32_branch_3 $switch.32_branch_4 $switch.32_branch_5 $switch.32_branch_6 $switch.32_branch_7 $switch.32_default $switch.32_default - (i32.const 0) - (i32.shr_s - (local.get $17) - (i32.const 1) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.71 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.70 - (block $compile_store.65 - (local.set $14 - (block $allocate_adt.63 (result i32) - (i32.store - (local.tee $2 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $2) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $2) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $2) - (i32.const 0) - ) - (local.get $2) - ) - ) - (block $do_backpatches.64 - ) - ) - (block $compile_store.68 - (local.set $15 - (block $allocate_string.66 (result i32) - (i32.store - (local.tee $2 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 5) - ) - (i64.store offset=8 - (local.get $2) - (i64.const 491327616111) - ) - (local.get $2) - ) - ) - (block $do_backpatches.67 - ) - ) - (block $cleanup.69 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $print_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1125) - ) - (local.get $15) - (local.get $14) - ) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.62 - (block $compile_store.60 - (local.set $13 - (block $allocate_adt.58 (result i32) - (i32.store - (local.tee $2 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $2) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $2) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $2) - (i32.const 0) - ) - (local.get $2) - ) - ) - (block $do_backpatches.59 - ) - ) - (block $cleanup.61 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $print_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1125) - ) - (i32.const 13) - (local.get $13) - ) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.57 - (block $compile_store.55 - (local.set $12 - (block $allocate_adt.53 (result i32) - (i32.store - (local.tee $2 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $2) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $2) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $2) - (i32.const 0) - ) - (local.get $2) - ) - ) - (block $do_backpatches.54 - ) - ) - (block $cleanup.56 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $print_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1125) - ) - (i32.const 11) - (local.get $12) - ) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.52 - (block $compile_store.50 - (local.set $11 - (block $allocate_adt.48 (result i32) - (i32.store - (local.tee $2 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $2) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $2) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $2) - (i32.const 0) - ) - (local.get $2) - ) - ) - (block $do_backpatches.49 - ) - ) - (block $cleanup.51 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $print_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1125) - ) - (i32.const 9) - (local.get $11) - ) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.47 - (block $compile_store.45 - (local.set $10 - (block $allocate_adt.43 (result i32) - (i32.store - (local.tee $2 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $2) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $2) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $2) - (i32.const 0) - ) - (local.get $2) - ) - ) - (block $do_backpatches.44 - ) - ) - (block $cleanup.46 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $print_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1125) - ) - (i32.const 7) - (local.get $10) - ) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.42 - (block $compile_store.40 - (local.set $9 - (block $allocate_adt.38 (result i32) - (i32.store - (local.tee $2 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $2) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $2) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $2) - (i32.const 0) - ) - (local.get $2) - ) - ) - (block $do_backpatches.39 - ) - ) - (block $cleanup.41 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $print_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1125) - ) - (i32.const 5) - (local.get $9) - ) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.37 - (block $compile_store.35 - (local.set $8 - (block $allocate_adt.33 (result i32) - (i32.store - (local.tee $2 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $2) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $2) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $2) - (i32.const 0) - ) - (local.get $2) - ) - ) - (block $do_backpatches.34 - ) - ) - (block $cleanup.36 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $print_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1125) - ) - (i32.const 3) - (local.get $8) - ) - ) - ) - ) - ) - (block $cleanup.31 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.75 - (block $compile_store.74 - (global.set $test_1113 - (i32.const 0) - ) - (block $do_backpatches.73 - ) - ) - (return_call $test_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $test_1113) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 386 -) +((mash_code + ((functions + (((id ((name test))) (name (test)) (args (Managed)) + (return_type ((Unmanaged WasmI32))) (closure ()) + (body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func foo_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (((Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func foo_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (((Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstLiteral (MConstI32 1)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func foo_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (((Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstLiteral (MConstI32 5)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func foo_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (((Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstLiteral (MConstI32 8)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func foo_1114) + (closure + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + (func_type (((Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstLiteral (MConstI32 42)))) + (immediate_analyses ((last_usage Unknown))))))))))) + (stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs (((txt Unsafe))))) + ((id ((name foo))) (name ()) (args (Managed (Unmanaged WasmI32))) + (return_type ((Unmanaged WasmI32))) (closure ()) + (body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MArgBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 1)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MArgBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MArgBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 3)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MArgBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 4)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MArgBind 1 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Unknown)))) + ((immediate_desc + (MImmConst + (MConstLiteral (MConstI32 5)))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MArgBind 1 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + ((immediate_desc + (MImmConst + (MConstLiteral (MConstI32 6)))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 5))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 6))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))))))))))))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc + (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func print_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1125 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (1 + (((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc + (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func print_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1125 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (2 + (((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc + (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func print_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1125 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (3 + (((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc + (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func print_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1125 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (4 + (((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc + (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func print_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1125 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (5 + (((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc + (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func print_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1125 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (6 + (((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc + (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc (MAllocate (MString other))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func print_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1125 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + (Unmanaged WasmI32))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 8) (stack_size_i32 7) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs (((txt Unsafe))))))) + (imports + (((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind test_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MReturnCallKnown (func test_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind test_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (() ((Unmanaged WasmI32)))) (args ())))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name test))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.7222ab37.0.snapshot b/compiler/test/__snapshots__/basic_functionality.7222ab37.0.snapshot index 9e228c6485..ddcbb01c71 100644 --- a/compiler/test/__snapshots__/basic_functionality.7222ab37.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.7222ab37.0.snapshot @@ -1,35 +1,15 @@ basic functionality › tru -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -2) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.7287219f.0.snapshot b/compiler/test/__snapshots__/basic_functionality.7287219f.0.snapshot index 4362755621..22c86339ec 100644 --- a/compiler/test/__snapshots__/basic_functionality.7287219f.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.7287219f.0.snapshot @@ -1,48 +1,35 @@ basic functionality › asr1 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$>>\" (global $>>_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \">>\" (func $>>_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $>>_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $>>_1113) - ) - (i32.const 359) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name >>))) (mimp_mod pervasives.gr) (mimp_name >>) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name >>))) (mimp_mod pervasives.gr) (mimp_name >>) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func >>_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind >>_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 179))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.7599b5a6.0.snapshot b/compiler/test/__snapshots__/basic_functionality.7599b5a6.0.snapshot index 95c86e8bb7..d914f6a6ec 100644 --- a/compiler/test/__snapshots__/basic_functionality.7599b5a6.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.7599b5a6.0.snapshot @@ -1,85 +1,58 @@ basic functionality › assignment1 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1117 (param i32 i32 i32) (result i32))) - (global $t_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.6 (result i32) - (block $compile_store.2 - (global.set $t_1113 - (i32.const 3) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $+_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $t_1113) - ) - (i32.const 5) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_set.5 (result i32) - (global.set $t_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $t_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind t_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func +_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind t_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MSet (MGlobalBind t_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name t))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.7848308f.0.snapshot b/compiler/test/__snapshots__/basic_functionality.7848308f.0.snapshot index 42ffcc7678..a982d4d766 100644 --- a/compiler/test/__snapshots__/basic_functionality.7848308f.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.7848308f.0.snapshot @@ -1,35 +1,15 @@ basic functionality › or3 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -2) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.79ea1ccc.0.snapshot b/compiler/test/__snapshots__/basic_functionality.79ea1ccc.0.snapshot index 5ecd8659de..18c1b2e5db 100644 --- a/compiler/test/__snapshots__/basic_functionality.79ea1ccc.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.79ea1ccc.0.snapshot @@ -1,85 +1,58 @@ basic functionality › assignment1 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1117 (param i32 i32 i32) (result i32))) - (global $t_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.6 (result i32) - (block $compile_store.2 - (global.set $t_1113 - (i32.const 5) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $-_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $t_1113) - ) - (i32.const 5) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_set.5 (result i32) - (global.set $t_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $t_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind t_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func -_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind t_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MSet (MGlobalBind t_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name t))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.7b13e79a.0.snapshot b/compiler/test/__snapshots__/basic_functionality.7b13e79a.0.snapshot index cad7a59606..9b271d8917 100644 --- a/compiler/test/__snapshots__/basic_functionality.7b13e79a.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.7b13e79a.0.snapshot @@ -1,35 +1,15 @@ basic functionality › and4 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 2147483646) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.7bb7b0d4.0.snapshot b/compiler/test/__snapshots__/basic_functionality.7bb7b0d4.0.snapshot index 5f95dbf37e..ea8ad97f9a 100644 --- a/compiler/test/__snapshots__/basic_functionality.7bb7b0d4.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.7bb7b0d4.0.snapshot @@ -1,53 +1,11 @@ basic functionality › uint32_1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_uint32.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 8) - ) - ) - (i32.const 11) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 42) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MUint32 42)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.7beffe4d.0.snapshot b/compiler/test/__snapshots__/basic_functionality.7beffe4d.0.snapshot index 8a64f95e17..b3abe3f2e6 100644 --- a/compiler/test/__snapshots__/basic_functionality.7beffe4d.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.7beffe4d.0.snapshot @@ -1,57 +1,11 @@ basic functionality › hex_dec_exp5 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (f64.store offset=8 - (local.get $0) - (f64.const 841.25) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MFloat64 4650610929073913856)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.7ccc4940.0.snapshot b/compiler/test/__snapshots__/basic_functionality.7ccc4940.0.snapshot index 231d372984..210819e0aa 100644 --- a/compiler/test/__snapshots__/basic_functionality.7ccc4940.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.7ccc4940.0.snapshot @@ -1,115 +1,15 @@ basic functionality › division1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.4 (result i32) - (block $allocate_number.3 (result i32) - (i32.store - (local.tee $1 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $1) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $1) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (i64.store offset=16 - (local.get $0) - (i64.const 5) - ) - (local.get $0) - ) - ) - (i32.store offset=12 - (local.get $1) - (block $allocate_number.2 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (i64.store offset=16 - (local.get $0) - (i64.const 2) - ) - (local.get $0) - ) - ) - (local.get $1) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MRational (numerator_flags ()) (numerator_limbs (5)) + (denominator_flags ()) (denominator_limbs (2)))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.7d0640b4.0.snapshot b/compiler/test/__snapshots__/basic_functionality.7d0640b4.0.snapshot index 0257d5678c..a66208cba1 100644 --- a/compiler/test/__snapshots__/basic_functionality.7d0640b4.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.7d0640b4.0.snapshot @@ -1,113 +1,83 @@ basic functionality › if_one_sided2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1117 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$>\" (global $>_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1117 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \">\" (func $>_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.8 (result i32) - (block $compile_store.2 - (local.set $7 - (call $>_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $>_1114) - ) - (i32.const 7) - (i32.const 9) - ) - ) - (block $do_backpatches.1 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $7) - (i32.const 31) - ) - (block $compile_block.6 - (block $compile_store.5 - (local.set $6 - (block $allocate_adt.3 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.4 - ) - ) - (return_call $print_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1117) - ) - (i32.const 11) - (local.get $6) - ) - ) - (block $compile_block.7 (result i32) - (i32.const 1879048190) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name >))) (mimp_mod pervasives.gr) (mimp_name >) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name >))) (mimp_mod pervasives.gr) (mimp_name >) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func >_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind >_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MReturnCallKnown (func print_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown))))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.83f51526.0.snapshot b/compiler/test/__snapshots__/basic_functionality.83f51526.0.snapshot index d3f39fb416..f3408c549b 100644 --- a/compiler/test/__snapshots__/basic_functionality.83f51526.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.83f51526.0.snapshot @@ -1,57 +1,11 @@ basic functionality › hex_dec_exp3 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (f64.store offset=8 - (local.get $0) - (f64.const 0.03125) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MFloat64 4584664420663164928)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.86f332c6.0.snapshot b/compiler/test/__snapshots__/basic_functionality.86f332c6.0.snapshot index 635eebae02..2e522aa139 100644 --- a/compiler/test/__snapshots__/basic_functionality.86f332c6.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.86f332c6.0.snapshot @@ -1,35 +1,15 @@ basic functionality › bin_neg -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -19) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 -10))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.8c8313f3.0.snapshot b/compiler/test/__snapshots__/basic_functionality.8c8313f3.0.snapshot index b1dfe80c13..0140a89924 100644 --- a/compiler/test/__snapshots__/basic_functionality.8c8313f3.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.8c8313f3.0.snapshot @@ -1,57 +1,11 @@ basic functionality › hex_dec_exp2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (f64.store offset=8 - (local.get $0) - (f64.const 40) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MFloat64 4630826316843712512)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.8e01d666.0.snapshot b/compiler/test/__snapshots__/basic_functionality.8e01d666.0.snapshot index 9c26197c02..b1718e51ff 100644 --- a/compiler/test/__snapshots__/basic_functionality.8e01d666.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.8e01d666.0.snapshot @@ -1,57 +1,11 @@ basic functionality › infinity_neg -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (f64.store offset=8 - (local.get $0) - (f64.const -inf) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MFloat64 -4503599627370496)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.903ff701.0.snapshot b/compiler/test/__snapshots__/basic_functionality.903ff701.0.snapshot index c52ad996fa..e4be116cef 100644 --- a/compiler/test/__snapshots__/basic_functionality.903ff701.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.903ff701.0.snapshot @@ -1,57 +1,11 @@ basic functionality › hex_dec_exp4 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (f64.store offset=8 - (local.get $0) - (f64.const 832) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MFloat64 4650529565213458432)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.9110d0f5.0.snapshot b/compiler/test/__snapshots__/basic_functionality.9110d0f5.0.snapshot index 9414e71f43..9607462b53 100644 --- a/compiler/test/__snapshots__/basic_functionality.9110d0f5.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.9110d0f5.0.snapshot @@ -1,48 +1,36 @@ basic functionality › comp13 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (i32.const -2) - (i32.const -2) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type + (((Unmanaged WasmI32) (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.9157dba1.0.snapshot b/compiler/test/__snapshots__/basic_functionality.9157dba1.0.snapshot index adc57c3894..09b6725166 100644 --- a/compiler/test/__snapshots__/basic_functionality.9157dba1.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.9157dba1.0.snapshot @@ -1,48 +1,35 @@ basic functionality › andshadow -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $+_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1114) - ) - (i32.const 3) - (i32.const 5) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func +_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.9379df0d.0.snapshot b/compiler/test/__snapshots__/basic_functionality.9379df0d.0.snapshot index 35429d4b8f..39f78207c9 100644 --- a/compiler/test/__snapshots__/basic_functionality.9379df0d.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.9379df0d.0.snapshot @@ -1,278 +1,97 @@ basic functionality › comp21 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (block $compile_block.20 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_tuple.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.15 - (local.set $10 - (block $allocate_adt.13 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.18 - (local.set $11 - (block $allocate_adt.16 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (local.get $9) - ) - (i32.store offset=24 - (local.get $0) - (local.get $10) - ) - (local.get $0) - ) - ) - (block $do_backpatches.17 - ) - ) - (tuple.extract 0 - (tuple.make - (i32.or - (i32.shl - (i32.eq - (local.get $8) - (local.get $11) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - (block $cleanup.19 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MPrim2 Is + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))))) + (((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 6) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.950b8fda.0.snapshot b/compiler/test/__snapshots__/basic_functionality.950b8fda.0.snapshot index 69cf61785d..7146f733f8 100644 --- a/compiler/test/__snapshots__/basic_functionality.950b8fda.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.950b8fda.0.snapshot @@ -1,35 +1,15 @@ basic functionality › binop2.3 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -3) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 -2))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.970a2a2b.0.snapshot b/compiler/test/__snapshots__/basic_functionality.970a2a2b.0.snapshot index 92753c8388..2104f71139 100644 --- a/compiler/test/__snapshots__/basic_functionality.970a2a2b.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.970a2a2b.0.snapshot @@ -1,35 +1,15 @@ basic functionality › not2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -2) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.974b7936.0.snapshot b/compiler/test/__snapshots__/basic_functionality.974b7936.0.snapshot index 765ff01bb0..e2b194c10b 100644 --- a/compiler/test/__snapshots__/basic_functionality.974b7936.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.974b7936.0.snapshot @@ -1,48 +1,35 @@ basic functionality › lxor3 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$^\" (global $^_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"^\" (func $^_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $^_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $^_1113) - ) - (i32.const 1) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name ^))) (mimp_mod pervasives.gr) (mimp_name ^) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name ^))) (mimp_mod pervasives.gr) (mimp_name ^) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func ^_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ^_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.994117f8.0.snapshot b/compiler/test/__snapshots__/basic_functionality.994117f8.0.snapshot index c39ec95248..2ae1d81007 100644 --- a/compiler/test/__snapshots__/basic_functionality.994117f8.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.994117f8.0.snapshot @@ -1,46 +1,32 @@ basic functionality › incr_3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$incr\" (global $incr_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"incr\" (func $incr_1113 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $incr_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $incr_1113) - ) - (i32.const -1) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name incr))) (mimp_mod pervasives.gr) (mimp_name incr) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name incr))) (mimp_mod pervasives.gr) (mimp_name incr) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func incr_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind incr_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 -1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.9b9c7047.0.snapshot b/compiler/test/__snapshots__/basic_functionality.9b9c7047.0.snapshot index be05c133f3..0d3289b3e4 100644 --- a/compiler/test/__snapshots__/basic_functionality.9b9c7047.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.9b9c7047.0.snapshot @@ -1,57 +1,11 @@ basic functionality › void -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MString foo)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.9c18b19d.0.snapshot b/compiler/test/__snapshots__/basic_functionality.9c18b19d.0.snapshot index 4276db4d61..8d941657cb 100644 --- a/compiler/test/__snapshots__/basic_functionality.9c18b19d.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.9c18b19d.0.snapshot @@ -1,93 +1,63 @@ basic functionality › if_one_sided3 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$<\" (global $<_1116 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"<\" (func $<_1116 (param i32 i32 i32) (result i32))) - (global $x_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.8 (result i32) - (block $compile_store.2 - (global.set $x_1113 - (i32.const 3) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $<_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $<_1116) - ) - (i32.const 7) - (i32.const 9) - ) - ) - (block $do_backpatches.3 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.6 (result i32) - (block $compile_set.5 (result i32) - (global.set $x_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.const 5) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $x_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_block.7 (result i32) - (i32.const 1879048190) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind x_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func <_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind <_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MSet (MGlobalBind x_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown))))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name x))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.9df4a5e0.0.snapshot b/compiler/test/__snapshots__/basic_functionality.9df4a5e0.0.snapshot index 0b162d1e9d..096c5d3c8a 100644 --- a/compiler/test/__snapshots__/basic_functionality.9df4a5e0.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.9df4a5e0.0.snapshot @@ -1,35 +1,15 @@ basic functionality › and1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -2) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.9fb01eb5.0.snapshot b/compiler/test/__snapshots__/basic_functionality.9fb01eb5.0.snapshot index 0844291c77..0a534c7811 100644 --- a/compiler/test/__snapshots__/basic_functionality.9fb01eb5.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.9fb01eb5.0.snapshot @@ -1,35 +1,15 @@ basic functionality › simple_max -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 2147483647) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1073741823))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.a0045d1c.0.snapshot b/compiler/test/__snapshots__/basic_functionality.a0045d1c.0.snapshot index 0174f48439..d9dccfe7a3 100644 --- a/compiler/test/__snapshots__/basic_functionality.a0045d1c.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.a0045d1c.0.snapshot @@ -1,48 +1,35 @@ basic functionality › binop1 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $+_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1113) - ) - (i32.const 5) - (i32.const 5) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func +_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.a0747361.0.snapshot b/compiler/test/__snapshots__/basic_functionality.a0747361.0.snapshot index f9daffac27..0976b6a056 100644 --- a/compiler/test/__snapshots__/basic_functionality.a0747361.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.a0747361.0.snapshot @@ -1,35 +1,15 @@ basic functionality › hex -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 511) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 255))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.a2e63440.0.snapshot b/compiler/test/__snapshots__/basic_functionality.a2e63440.0.snapshot index bc63392a28..df301134b2 100644 --- a/compiler/test/__snapshots__/basic_functionality.a2e63440.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.a2e63440.0.snapshot @@ -1,67 +1,51 @@ basic functionality › comp9 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$>=\" (global $>=_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \">=\" (func $>=_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.2 - (local.set $6 - (call $>=_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $>=_1114) - ) - (i32.const 5) - (i32.const 5) - ) - ) - (block $do_backpatches.1 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.3 (result i32) - (i32.const 21) - ) - (block $compile_block.4 (result i32) - (i32.const 23) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name >=))) (mimp_mod pervasives.gr) (mimp_name >=) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name >=))) (mimp_mod pervasives.gr) (mimp_name >=) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func >=_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind >=_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 10))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 11))) + (immediate_analyses ((last_usage Unknown))))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.a3f7e180.0.snapshot b/compiler/test/__snapshots__/basic_functionality.a3f7e180.0.snapshot index 21b4ff882e..d59be4f6c7 100644 --- a/compiler/test/__snapshots__/basic_functionality.a3f7e180.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.a3f7e180.0.snapshot @@ -1,77 +1,39 @@ basic functionality › bigint_1 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.4 - (block $compile_store.3 - (local.set $6 - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 9223372036854775807) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (return_call $+_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1113) - ) - (local.get $6) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc (MAllocate (MInt64 9223372036854775807))))))))) + ((instr_desc + (MReturnCallKnown (func +_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.a4ec9fca.0.snapshot b/compiler/test/__snapshots__/basic_functionality.a4ec9fca.0.snapshot index 454c7501ab..033b41397e 100644 --- a/compiler/test/__snapshots__/basic_functionality.a4ec9fca.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.a4ec9fca.0.snapshot @@ -1,35 +1,15 @@ basic functionality › andshort2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 2147483646) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.a58a9361.0.snapshot b/compiler/test/__snapshots__/basic_functionality.a58a9361.0.snapshot index 4c82ef2406..f289c388b7 100644 --- a/compiler/test/__snapshots__/basic_functionality.a58a9361.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.a58a9361.0.snapshot @@ -1,48 +1,35 @@ basic functionality › lxor2 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$^\" (global $^_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"^\" (func $^_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $^_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $^_1113) - ) - (i32.const 3) - (i32.const 1) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name ^))) (mimp_mod pervasives.gr) (mimp_name ^) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name ^))) (mimp_mod pervasives.gr) (mimp_name ^) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func ^_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ^_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.a5d5182f.0.snapshot b/compiler/test/__snapshots__/basic_functionality.a5d5182f.0.snapshot index baecb81e8b..964fd4f60f 100644 --- a/compiler/test/__snapshots__/basic_functionality.a5d5182f.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.a5d5182f.0.snapshot @@ -1,67 +1,52 @@ basic functionality › comp2 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$<=\" (global $<=_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"<=\" (func $<=_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.2 - (local.set $6 - (call $<=_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $<=_1114) - ) - (i32.const 5) - (i32.const 7) - ) - ) - (block $do_backpatches.1 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.3 (result i32) - (i32.const -2) - ) - (block $compile_block.4 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name <=))) (mimp_mod pervasives.gr) (mimp_name <=) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name <=))) (mimp_mod pervasives.gr) (mimp_name <=) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func <=_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind <=_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.a72898d0.0.snapshot b/compiler/test/__snapshots__/basic_functionality.a72898d0.0.snapshot index 0c4539f63e..12d2161f51 100644 --- a/compiler/test/__snapshots__/basic_functionality.a72898d0.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.a72898d0.0.snapshot @@ -1,67 +1,51 @@ basic functionality › comp8 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$<=\" (global $<=_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"<=\" (func $<=_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.2 - (local.set $6 - (call $<=_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $<=_1114) - ) - (i32.const 5) - (i32.const 5) - ) - ) - (block $do_backpatches.1 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.3 (result i32) - (i32.const 21) - ) - (block $compile_block.4 (result i32) - (i32.const 23) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name <=))) (mimp_mod pervasives.gr) (mimp_name <=) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name <=))) (mimp_mod pervasives.gr) (mimp_name <=) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func <=_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind <=_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 10))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 11))) + (immediate_analyses ((last_usage Unknown))))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.abd9d13c.0.snapshot b/compiler/test/__snapshots__/basic_functionality.abd9d13c.0.snapshot index a6567f4015..fa6cdb1360 100644 --- a/compiler/test/__snapshots__/basic_functionality.abd9d13c.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.abd9d13c.0.snapshot @@ -1,67 +1,51 @@ basic functionality › comp7 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.2 - (local.set $6 - (call $==_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1114) - ) - (i32.const 5) - (i32.const 5) - ) - ) - (block $do_backpatches.1 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.3 (result i32) - (i32.const 17) - ) - (block $compile_block.4 (result i32) - (i32.const 19) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func ==_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind ==_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 8))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 9))) + (immediate_analyses ((last_usage Unknown))))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.b07cc734.0.snapshot b/compiler/test/__snapshots__/basic_functionality.b07cc734.0.snapshot index 1990822d62..87045debfa 100644 --- a/compiler/test/__snapshots__/basic_functionality.b07cc734.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.b07cc734.0.snapshot @@ -1,113 +1,83 @@ basic functionality › if_one_sided -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1117 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$<\" (global $<_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1117 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"<\" (func $<_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.8 (result i32) - (block $compile_store.2 - (local.set $7 - (call $<_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $<_1114) - ) - (i32.const 7) - (i32.const 9) - ) - ) - (block $do_backpatches.1 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $7) - (i32.const 31) - ) - (block $compile_block.6 - (block $compile_store.5 - (local.set $6 - (block $allocate_adt.3 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.4 - ) - ) - (return_call $print_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1117) - ) - (i32.const 11) - (local.get $6) - ) - ) - (block $compile_block.7 (result i32) - (i32.const 1879048190) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func <_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind <_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MReturnCallKnown (func print_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown))))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.b6a1b657.0.snapshot b/compiler/test/__snapshots__/basic_functionality.b6a1b657.0.snapshot index 8bb888f3a4..5060a0ee11 100644 --- a/compiler/test/__snapshots__/basic_functionality.b6a1b657.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.b6a1b657.0.snapshot @@ -1,48 +1,35 @@ basic functionality › lxor4 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$^\" (global $^_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"^\" (func $^_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $^_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $^_1113) - ) - (i32.const 1) - (i32.const 1) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name ^))) (mimp_mod pervasives.gr) (mimp_name ^) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name ^))) (mimp_mod pervasives.gr) (mimp_name ^) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func ^_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ^_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.b836b89a.0.snapshot b/compiler/test/__snapshots__/basic_functionality.b836b89a.0.snapshot index ffc3d6867d..1a26954158 100644 --- a/compiler/test/__snapshots__/basic_functionality.b836b89a.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.b836b89a.0.snapshot @@ -1,114 +1,98 @@ basic functionality › complex1 -(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)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1127 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1125 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1120 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1127 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1125 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1120 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.6 - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (drop - (call $print_1120 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1120) - ) - (i32.const 7) - (local.get $6) - ) - ) - (block $compile_store.5 - (local.set $7 - (call $+_1127 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1127) - ) - (i32.const 9) - (i32.const 5) - ) - ) - (block $do_backpatches.4 - ) - ) - (return_call $-_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1125) - ) - (i32.const 7) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func print_1120) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1120 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func +_1127) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1127 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func -_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1125 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.bb137371.0.snapshot b/compiler/test/__snapshots__/basic_functionality.bb137371.0.snapshot index f872336d95..c2d9ffaefa 100644 --- a/compiler/test/__snapshots__/basic_functionality.bb137371.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.bb137371.0.snapshot @@ -1,85 +1,58 @@ basic functionality › assignment1 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$/\" (global $/_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"/\" (func $/_1117 (param i32 i32 i32) (result i32))) - (global $t_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.6 (result i32) - (block $compile_store.2 - (global.set $t_1113 - (i32.const 5) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $/_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $/_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $t_1113) - ) - (i32.const 5) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_set.5 (result i32) - (global.set $t_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $t_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name /))) (mimp_mod pervasives.gr) (mimp_name /) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name /))) (mimp_mod pervasives.gr) (mimp_name /) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind t_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func /_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind /_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind t_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MSet (MGlobalBind t_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name t))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.bd891a1f.0.snapshot b/compiler/test/__snapshots__/basic_functionality.bd891a1f.0.snapshot index 72c8fd2a5b..6409360d80 100644 --- a/compiler/test/__snapshots__/basic_functionality.bd891a1f.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.bd891a1f.0.snapshot @@ -1,35 +1,15 @@ basic functionality › oct -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 127) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 63))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.bef9449e.0.snapshot b/compiler/test/__snapshots__/basic_functionality.bef9449e.0.snapshot index 29b7676c38..a972ebe465 100644 --- a/compiler/test/__snapshots__/basic_functionality.bef9449e.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.bef9449e.0.snapshot @@ -1,67 +1,51 @@ basic functionality › comp1 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$<\" (global $<_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"<\" (func $<_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.2 - (local.set $6 - (call $<_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $<_1114) - ) - (i32.const 5) - (i32.const 7) - ) - ) - (block $do_backpatches.1 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.3 (result i32) - (i32.const -2) - ) - (block $compile_block.4 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func <_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind <_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.c1554a92.0.snapshot b/compiler/test/__snapshots__/basic_functionality.c1554a92.0.snapshot index 18a423f3b9..9ba7cf16a5 100644 --- a/compiler/test/__snapshots__/basic_functionality.c1554a92.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.c1554a92.0.snapshot @@ -1,35 +1,15 @@ basic functionality › or2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const -2) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.c2c74be4.0.snapshot b/compiler/test/__snapshots__/basic_functionality.c2c74be4.0.snapshot index dea3ec445d..c09d426c69 100644 --- a/compiler/test/__snapshots__/basic_functionality.c2c74be4.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.c2c74be4.0.snapshot @@ -1,48 +1,35 @@ basic functionality › lsr2 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$>>>\" (global $>>>_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \">>>\" (func $>>>_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $>>>_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $>>>_1113) - ) - (i32.const 1) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name >>>))) (mimp_mod pervasives.gr) (mimp_name >>>) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name >>>))) (mimp_mod pervasives.gr) (mimp_name >>>) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func >>>_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind >>>_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.c4090bb1.0.snapshot b/compiler/test/__snapshots__/basic_functionality.c4090bb1.0.snapshot index 572ea64e70..a74fa23862 100644 --- a/compiler/test/__snapshots__/basic_functionality.c4090bb1.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.c4090bb1.0.snapshot @@ -1,307 +1,204 @@ basic functionality › toplevel_statements -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1126 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1120 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1126 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1120 (param i32 i32 i32) (result i32))) - (global $five_1117 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (block $compile_block.19 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (drop - (call $print_1120 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1120) - ) - (i32.const 3) - (local.get $6) - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (drop - (call $print_1120 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1120) - ) - (i32.const 5) - (local.get $7) - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (drop - (call $print_1120 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1120) - ) - (i32.const 7) - (local.get $8) - ) - ) - (block $compile_store.11 - (global.set $five_1117 - (call $+_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1126) - ) - (i32.const 5) - (i32.const 7) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.14 - (local.set $9 - (block $allocate_adt.12 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.13 - ) - ) - (drop - (call $print_1120 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1120) - ) - (i32.const 9) - (local.get $9) - ) - ) - (block $compile_store.17 - (local.set $10 - (block $allocate_adt.15 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.16 - ) - ) - (drop - (call $print_1120 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1120) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $five_1117) - ) - (local.get $10) - ) - ) - (block $allocate_string.18 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 382 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func print_1120) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1120 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func print_1120) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1120 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func print_1120) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1120 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind five_1117 Managed) + ((instr_desc + (MCallKnown (func +_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1126 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func print_1120) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1120 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func print_1120) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1120 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind five_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc (MAllocate (MString foo)))))) + (main_body_stack_size + ((stack_size_ptr 5) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name five))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.c49928a5.0.snapshot b/compiler/test/__snapshots__/basic_functionality.c49928a5.0.snapshot index 474d01aa2b..b16a3cd64e 100644 --- a/compiler/test/__snapshots__/basic_functionality.c49928a5.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.c49928a5.0.snapshot @@ -1,48 +1,35 @@ basic functionality › lsr1 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$>>>\" (global $>>>_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \">>>\" (func $>>>_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $>>>_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $>>>_1113) - ) - (i32.const 15) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name >>>))) (mimp_mod pervasives.gr) (mimp_name >>>) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name >>>))) (mimp_mod pervasives.gr) (mimp_name >>>) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func >>>_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind >>>_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 7))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.c55feb83.0.snapshot b/compiler/test/__snapshots__/basic_functionality.c55feb83.0.snapshot index 8446a1ca82..fb0089a2b8 100644 --- a/compiler/test/__snapshots__/basic_functionality.c55feb83.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.c55feb83.0.snapshot @@ -1,48 +1,37 @@ basic functionality › comp14 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (i32.const -2) - (i32.const 2147483646) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type + (((Unmanaged WasmI32) (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.c8095f7c.0.snapshot b/compiler/test/__snapshots__/basic_functionality.c8095f7c.0.snapshot index 35dfd430dd..f217719712 100644 --- a/compiler/test/__snapshots__/basic_functionality.c8095f7c.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.c8095f7c.0.snapshot @@ -1,46 +1,32 @@ basic functionality › incr_1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$incr\" (global $incr_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"incr\" (func $incr_1113 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $incr_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $incr_1113) - ) - (i32.const 5) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name incr))) (mimp_mod pervasives.gr) (mimp_name incr) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name incr))) (mimp_mod pervasives.gr) (mimp_name incr) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func incr_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind incr_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.c8144b17.0.snapshot b/compiler/test/__snapshots__/basic_functionality.c8144b17.0.snapshot index fdceacd95c..38389b5f14 100644 --- a/compiler/test/__snapshots__/basic_functionality.c8144b17.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.c8144b17.0.snapshot @@ -1,35 +1,15 @@ basic functionality › bin -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 21) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 10))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.cb9c6c66.0.snapshot b/compiler/test/__snapshots__/basic_functionality.cb9c6c66.0.snapshot index 0c6a4249bb..e087021ecb 100644 --- a/compiler/test/__snapshots__/basic_functionality.cb9c6c66.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.cb9c6c66.0.snapshot @@ -1,46 +1,32 @@ basic functionality › incr_2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$incr\" (global $incr_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"incr\" (func $incr_1113 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $incr_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $incr_1113) - ) - (i32.const 11) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name incr))) (mimp_mod pervasives.gr) (mimp_name incr) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name incr))) (mimp_mod pervasives.gr) (mimp_name incr) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func incr_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind incr_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.cdeddcd2.0.snapshot b/compiler/test/__snapshots__/basic_functionality.cdeddcd2.0.snapshot index bd5e3ee2f6..7f45e0e7ee 100644 --- a/compiler/test/__snapshots__/basic_functionality.cdeddcd2.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.cdeddcd2.0.snapshot @@ -1,48 +1,35 @@ basic functionality › modulo3 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$%\" (global $%_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"%\" (func $%_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $%_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $%_1113) - ) - (i32.const -33) - (i32.const -7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func %_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind %_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 -17))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 -4))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.cefeb364.0.snapshot b/compiler/test/__snapshots__/basic_functionality.cefeb364.0.snapshot index 46a2039c39..8d2fbe6e21 100644 --- a/compiler/test/__snapshots__/basic_functionality.cefeb364.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.cefeb364.0.snapshot @@ -1,48 +1,35 @@ basic functionality › lor4 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$|\" (global $|_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"|\" (func $|_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $|_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $|_1113) - ) - (i32.const 1) - (i32.const 1) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name |))) (mimp_mod pervasives.gr) (mimp_name |) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name |))) (mimp_mod pervasives.gr) (mimp_name |) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func |_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind |_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.d0c0c62b.0.snapshot b/compiler/test/__snapshots__/basic_functionality.d0c0c62b.0.snapshot index 4df627fd26..375c1bdd66 100644 --- a/compiler/test/__snapshots__/basic_functionality.d0c0c62b.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.d0c0c62b.0.snapshot @@ -1,48 +1,35 @@ basic functionality › int64_pun_1 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$*\" (global $*_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"*\" (func $*_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $*_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $*_1113) - ) - (i32.const 19999999) - (i32.const 199999999) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func *_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind *_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 9999999))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 99999999))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.d0cb4f44.0.snapshot b/compiler/test/__snapshots__/basic_functionality.d0cb4f44.0.snapshot index 907cb6ea2c..94439c2814 100644 --- a/compiler/test/__snapshots__/basic_functionality.d0cb4f44.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.d0cb4f44.0.snapshot @@ -1,46 +1,32 @@ basic functionality › decr_1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$decr\" (global $decr_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"decr\" (func $decr_1113 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $decr_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $decr_1113) - ) - (i32.const 5) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name decr))) (mimp_mod pervasives.gr) (mimp_name decr) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name decr))) (mimp_mod pervasives.gr) (mimp_name decr) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func decr_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind decr_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.d124f931.0.snapshot b/compiler/test/__snapshots__/basic_functionality.d124f931.0.snapshot index 032be440d9..21b15ac8bb 100644 --- a/compiler/test/__snapshots__/basic_functionality.d124f931.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.d124f931.0.snapshot @@ -1,35 +1,15 @@ basic functionality › nil -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 1879048190) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.d6ca4146.0.snapshot b/compiler/test/__snapshots__/basic_functionality.d6ca4146.0.snapshot index 41e3667f27..0bcdc9a233 100644 --- a/compiler/test/__snapshots__/basic_functionality.d6ca4146.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.d6ca4146.0.snapshot @@ -1,88 +1,55 @@ basic functionality › andshort1 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.4 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (drop - (call $print_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1113) - ) - (i32.const 3) - (local.get $6) - ) - ) - (i32.const 2147483646) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func print_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.d8a7dcf9.0.snapshot b/compiler/test/__snapshots__/basic_functionality.d8a7dcf9.0.snapshot index 071a69798b..30b4c8bc66 100644 --- a/compiler/test/__snapshots__/basic_functionality.d8a7dcf9.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.d8a7dcf9.0.snapshot @@ -1,48 +1,35 @@ basic functionality › modulo1 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$%\" (global $%_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"%\" (func $%_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $%_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $%_1113) - ) - (i32.const -33) - (i32.const 9) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func %_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind %_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 -17))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.d8f6f027.0.snapshot b/compiler/test/__snapshots__/basic_functionality.d8f6f027.0.snapshot index d7a97c55f4..8c14b8d703 100644 --- a/compiler/test/__snapshots__/basic_functionality.d8f6f027.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.d8f6f027.0.snapshot @@ -1,57 +1,11 @@ basic functionality › hex_dec_exp1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (f64.store offset=8 - (local.get $0) - (f64.const 32) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MFloat64 4629700416936869888)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.d9fc01df.0.snapshot b/compiler/test/__snapshots__/basic_functionality.d9fc01df.0.snapshot index a15bdbbe7a..b92471b26c 100644 --- a/compiler/test/__snapshots__/basic_functionality.d9fc01df.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.d9fc01df.0.snapshot @@ -1,48 +1,35 @@ basic functionality › land3 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$&\" (global $&_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"&\" (func $&_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $&_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $&_1113) - ) - (i32.const 1) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name &))) (mimp_mod pervasives.gr) (mimp_name &) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name &))) (mimp_mod pervasives.gr) (mimp_name &) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func &_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind &_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.dbf5d3ff.0.snapshot b/compiler/test/__snapshots__/basic_functionality.dbf5d3ff.0.snapshot index 935e4d858a..cbb46198f9 100644 --- a/compiler/test/__snapshots__/basic_functionality.dbf5d3ff.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.dbf5d3ff.0.snapshot @@ -1,48 +1,35 @@ basic functionality › comp18 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$isnt\" (global $isnt_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"isnt\" (func $isnt_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $isnt_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $isnt_1113) - ) - (i32.const 9) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name isnt))) (mimp_mod pervasives.gr) (mimp_name isnt) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name isnt))) (mimp_mod pervasives.gr) (mimp_name isnt) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func isnt_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind isnt_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.df4cd2bf.0.snapshot b/compiler/test/__snapshots__/basic_functionality.df4cd2bf.0.snapshot index a35d8162cc..7e2563d2bb 100644 --- a/compiler/test/__snapshots__/basic_functionality.df4cd2bf.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.df4cd2bf.0.snapshot @@ -1,48 +1,37 @@ basic functionality › comp15 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (i32.const 2147483646) - (i32.const -2) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type + (((Unmanaged WasmI32) (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.e2902464.0.snapshot b/compiler/test/__snapshots__/basic_functionality.e2902464.0.snapshot index 967fe61f2d..9409d51ad0 100644 --- a/compiler/test/__snapshots__/basic_functionality.e2902464.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.e2902464.0.snapshot @@ -1,65 +1,60 @@ basic functionality › comp10 -(module - (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 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1119 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1119 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1117 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.3 - (block $compile_store.2 - (local.set $6 - (call $-_1119 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1119) - ) - (i32.const 9) - (i32.const 5) - ) - ) - (block $do_backpatches.1 - ) - ) - (return_call $==_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1117) - ) - (local.get $6) - (i32.const 5) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func -_1119) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1119 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.e3995c7d.0.snapshot b/compiler/test/__snapshots__/basic_functionality.e3995c7d.0.snapshot index 3c5f193270..d40f3d39ac 100644 --- a/compiler/test/__snapshots__/basic_functionality.e3995c7d.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.e3995c7d.0.snapshot @@ -1,96 +1,69 @@ basic functionality › if_one_sided4 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$<\" (global $<_1116 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"<\" (func $<_1116 (param i32 i32 i32) (result i32))) - (global $x_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.8 (result i32) - (block $compile_store.2 - (global.set $x_1113 - (i32.const 3) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $<_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $<_1116) - ) - (i32.const 7) - (i32.const 9) - ) - ) - (block $do_backpatches.3 - ) - ) - (drop - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.6 (result i32) - (block $compile_set.5 (result i32) - (global.set $x_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.const 5) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $x_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_block.7 (result i32) - (i32.const 1879048190) - ) - ) - ) - (global.get $x_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name <))) (mimp_mod pervasives.gr) (mimp_name <) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind x_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func <_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind <_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MSet (MGlobalBind x_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind x_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name x))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.e56cd2a2.0.snapshot b/compiler/test/__snapshots__/basic_functionality.e56cd2a2.0.snapshot index 2e596f97f9..8388c68955 100644 --- a/compiler/test/__snapshots__/basic_functionality.e56cd2a2.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.e56cd2a2.0.snapshot @@ -1,67 +1,51 @@ basic functionality › comp6 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.2 - (local.set $6 - (call $==_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1114) - ) - (i32.const 5) - (i32.const 7) - ) - ) - (block $do_backpatches.1 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.3 (result i32) - (i32.const 17) - ) - (block $compile_block.4 (result i32) - (i32.const 19) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func ==_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind ==_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 8))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 9))) + (immediate_analyses ((last_usage Unknown))))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.e58c3266.0.snapshot b/compiler/test/__snapshots__/basic_functionality.e58c3266.0.snapshot index c5d698b87c..cafa3ae254 100644 --- a/compiler/test/__snapshots__/basic_functionality.e58c3266.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.e58c3266.0.snapshot @@ -1,48 +1,35 @@ basic functionality › asr2 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$>>\" (global $>>_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \">>\" (func $>>_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $>>_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $>>_1113) - ) - (i32.const 1) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name >>))) (mimp_mod pervasives.gr) (mimp_name >>) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name >>))) (mimp_mod pervasives.gr) (mimp_name >>) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func >>_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind >>_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.e6ea6b06.0.snapshot b/compiler/test/__snapshots__/basic_functionality.e6ea6b06.0.snapshot index 54e8fca915..3f17255425 100644 --- a/compiler/test/__snapshots__/basic_functionality.e6ea6b06.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.e6ea6b06.0.snapshot @@ -1,53 +1,11 @@ basic functionality › int32_1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_int32.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 8) - ) - ) - (i32.const 9) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 42) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MInt32 42)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.e811c1e1.0.snapshot b/compiler/test/__snapshots__/basic_functionality.e811c1e1.0.snapshot index 92723cfb85..0271065ebf 100644 --- a/compiler/test/__snapshots__/basic_functionality.e811c1e1.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.e811c1e1.0.snapshot @@ -1,48 +1,35 @@ basic functionality › binop2.1 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $-_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1113) - ) - (i32.const 5) - (i32.const 5) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func -_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.ee7c0ebc.0.snapshot b/compiler/test/__snapshots__/basic_functionality.ee7c0ebc.0.snapshot index 5475bd1031..35b4622b8e 100644 --- a/compiler/test/__snapshots__/basic_functionality.ee7c0ebc.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.ee7c0ebc.0.snapshot @@ -1,48 +1,35 @@ basic functionality › modulo2 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$%\" (global $%_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"%\" (func $%_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $%_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $%_1113) - ) - (i32.const 35) - (i32.const -7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name %))) (mimp_mod pervasives.gr) (mimp_name %) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func %_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind %_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 17))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 -4))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.f132ca8b.0.snapshot b/compiler/test/__snapshots__/basic_functionality.f132ca8b.0.snapshot index 40b0c7922b..bc5f9e86a7 100644 --- a/compiler/test/__snapshots__/basic_functionality.f132ca8b.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.f132ca8b.0.snapshot @@ -1,46 +1,32 @@ basic functionality › decr_2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$decr\" (global $decr_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"decr\" (func $decr_1113 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $decr_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $decr_1113) - ) - (i32.const 11) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name decr))) (mimp_mod pervasives.gr) (mimp_name decr) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name decr))) (mimp_mod pervasives.gr) (mimp_name decr) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func decr_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind decr_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.f47797ca.0.snapshot b/compiler/test/__snapshots__/basic_functionality.f47797ca.0.snapshot index f4ce8713ed..8f2c4f7796 100644 --- a/compiler/test/__snapshots__/basic_functionality.f47797ca.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.f47797ca.0.snapshot @@ -1,57 +1,11 @@ basic functionality › hex_dec_exp5 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (f64.store offset=8 - (local.get $0) - (f64.const 840) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MFloat64 4650599933957636096)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.f58be537.0.snapshot b/compiler/test/__snapshots__/basic_functionality.f58be537.0.snapshot index 0d283a38dd..faec0a0202 100644 --- a/compiler/test/__snapshots__/basic_functionality.f58be537.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.f58be537.0.snapshot @@ -1,310 +1,113 @@ basic functionality › comp19 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (block $compile_block.20 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_adt.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.15 - (local.set $10 - (block $allocate_adt.13 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.18 - (local.set $11 - (block $allocate_adt.16 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=24 - (local.get $0) - (local.get $10) - ) - (local.get $0) - ) - ) - (block $do_backpatches.17 - ) - ) - (tuple.extract 0 - (tuple.make - (i32.or - (i32.shl - (i32.eq - (local.get $8) - (local.get $11) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - (block $cleanup.19 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MPrim2 Is + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))))) + (((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 6) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.f90a3baa.0.snapshot b/compiler/test/__snapshots__/basic_functionality.f90a3baa.0.snapshot index 16c4487ae8..fc9dc064e5 100644 --- a/compiler/test/__snapshots__/basic_functionality.f90a3baa.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.f90a3baa.0.snapshot @@ -1,57 +1,11 @@ basic functionality › heap_number_i32_wrapper_max -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 2147483647) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MInt64 2147483647)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.f9743171.0.snapshot b/compiler/test/__snapshots__/basic_functionality.f9743171.0.snapshot index e5af6f2030..b61f66b91f 100644 --- a/compiler/test/__snapshots__/basic_functionality.f9743171.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.f9743171.0.snapshot @@ -1,57 +1,11 @@ basic functionality › heap_number_i32_wrapper -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 1073741824) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MInt64 1073741824)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.fd64a58f.0.snapshot b/compiler/test/__snapshots__/basic_functionality.fd64a58f.0.snapshot index 947273f86b..4a13750be9 100644 --- a/compiler/test/__snapshots__/basic_functionality.fd64a58f.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.fd64a58f.0.snapshot @@ -1,48 +1,35 @@ basic functionality › int64_pun_2 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $-_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1113) - ) - (i32.const -199999997) - (i32.const 1999999999) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func -_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 -99999999))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 999999999))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.fe19cffe.0.snapshot b/compiler/test/__snapshots__/basic_functionality.fe19cffe.0.snapshot index 84e0ed0270..396b820c9a 100644 --- a/compiler/test/__snapshots__/basic_functionality.fe19cffe.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.fe19cffe.0.snapshot @@ -1,69 +1,14 @@ basic functionality › bigint_2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 32) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (i64.store offset=16 - (local.get $0) - (i64.const -7851998425750883293) - ) - (i64.store offset=24 - (local.get $0) - (i64.const 1164749010670168) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MBigInt (flags ()) (limbs (-7851998425750883293 1164749010670168)))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/basic_functionality.fe88cb04.0.snapshot b/compiler/test/__snapshots__/basic_functionality.fe88cb04.0.snapshot index dfeb70294d..88f723aa4d 100644 --- a/compiler/test/__snapshots__/basic_functionality.fe88cb04.0.snapshot +++ b/compiler/test/__snapshots__/basic_functionality.fe88cb04.0.snapshot @@ -1,443 +1,239 @@ basic functionality › func_shadow_and_indirect_call -(module - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1121 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1121 (param i32 i32 i32) (result i32))) - (global $foo_1119 (mut i32) (i32.const 0)) - (global $foo_1117 (mut i32) (i32.const 0)) - (global $foo_1115 (mut i32) (i32.const 0)) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 1)) - (memory $0 0) - (elem $elem (global.get $relocBase_0) $func_1133) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1113 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (block $compile_block.3 (result i32) - (tuple.extract 0 - (tuple.make - (block $allocate_string.2 (result i32) - (i32.store - (local.tee $1 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $1) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $1) - (i64.const 7496034) - ) - (local.get $1) - ) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $foo_1115 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (block $compile_block.6 (result i32) - (tuple.extract 0 - (tuple.make - (block $allocate_string.5 (result i32) - (i32.store - (local.tee $1 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $1) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $1) - (i64.const 8020322) - ) - (local.get $1) - ) - (block $cleanup.4 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $foo_1117 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (block $compile_block.9 (result i32) - (tuple.extract 0 - (tuple.make - (block $allocate_closure.8 (result i32) - (i32.store - (local.tee $1 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 6) - ) - (i32.store offset=4 - (local.get $1) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $1) - (i32.add - (global.get $relocBase_0) - (i32.const 0) - ) - ) - (i32.store offset=12 - (local.get $1) - (i32.const 0) - ) - (local.get $1) - ) - (block $cleanup.7 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $func_1133 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (block $closure_elements.16 (result i32) - (block $compile_block.15 (result i32) - (tuple.extract 0 - (tuple.make - (block $allocate_string.14 (result i32) - (i32.store - (local.tee $1 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $1) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $1) - (i64.const 7894385) - ) - (local.get $1) - ) - (block $cleanup.13 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (block $compile_block.41 - (block $compile_store.18 - (global.set $foo_1113 - (i32.const 0) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.21 - (local.set $6 - (block $allocate_adt.19 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.23 - (local.set $7 - (call $foo_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1113) - ) - ) - ) - (block $do_backpatches.22 - ) - ) - (drop - (call $print_1121 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1121) - ) - (local.get $7) - (local.get $6) - ) - ) - (block $compile_store.25 - (global.set $foo_1115 - (i32.const 0) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.28 - (local.set $8 - (block $allocate_adt.26 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.27 - ) - ) - (block $compile_store.30 - (local.set $9 - (call $foo_1115 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1115) - ) - ) - ) - (block $do_backpatches.29 - ) - ) - (drop - (call $print_1121 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1121) - ) - (local.get $9) - (local.get $8) - ) - ) - (block $compile_store.32 - (global.set $foo_1117 - (i32.const 0) - ) - (block $do_backpatches.31 - ) - ) - (block $compile_store.34 - (global.set $foo_1119 - (call $foo_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1117) - ) - ) - ) - (block $do_backpatches.33 - ) - ) - (block $compile_store.37 - (local.set $10 - (block $allocate_adt.35 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.36 - ) - ) - (block $compile_store.40 - (local.set $11 - (block $call_lambda.38 (result i32) - (local.set $0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1119) - ) - ) - (call_indirect (type $i32_=>_i32) - (local.get $0) - (i32.load offset=8 - (local.get $0) - ) - ) - ) - ) - (block $do_backpatches.39 - ) - ) - (return_call $print_1121 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1121) - ) - (local.get $11) - (local.get $10) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 385 -) +((mash_code + ((functions + (((id ((name foo))) (name (foo)) (args (Managed)) (return_type (Managed)) + (closure ()) + (body + (((instr_desc + (MCleanup (((instr_desc (MAllocate (MString bar))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())) + ((id ((name foo))) (name (foo)) (args (Managed)) (return_type (Managed)) + (closure ()) + (body + (((instr_desc + (MCleanup (((instr_desc (MAllocate (MString baz))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())) + ((id ((name foo))) (name (foo)) (args (Managed)) (return_type (Managed)) + (closure ()) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MAllocate + (MClosure + ((func_idx (0)) (global_offset function_table_global_1130) + (arity 1) (variables ()))))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())) + ((id ((name func))) (name ()) (args (Managed)) (return_type (Managed)) + (closure (0)) + (body + (((instr_desc + (MCleanup (((instr_desc (MAllocate (MString qux))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func foo_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind foo_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (() (Managed))) (args ()))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func print_1121) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1121 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind foo_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MCallKnown (func foo_1115) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind foo_1115 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (() (Managed))) (args ()))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func print_1121) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1121 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind foo_1117 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind foo_1119 Managed) + ((instr_desc + (MCallKnown (func foo_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind foo_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (() (Managed))) (args ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MCallIndirect + (func + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind foo_1119 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (() (Managed))) (args ()))))))))) + ((instr_desc + (MReturnCallKnown (func print_1121) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind print_1121 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 6) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name foo))) (mutable_ true) (allocation_type Managed) + (initial_value ())) + ((id ((name foo))) (mutable_ true) (allocation_type Managed) + (initial_value ())) + ((id ((name foo))) (mutable_ true) (allocation_type Managed) + (initial_value ())) + ((id ((name foo))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements (func_1134)) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/boxes.08fca3f7.0.snapshot b/compiler/test/__snapshots__/boxes.08fca3f7.0.snapshot index 28c3e5a3ae..fd27c7f602 100644 --- a/compiler/test/__snapshots__/boxes.08fca3f7.0.snapshot +++ b/compiler/test/__snapshots__/boxes.08fca3f7.0.snapshot @@ -1,116 +1,63 @@ boxes › box_subtraction1 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.9 (result i32) - (block $compile_store.3 - (global.set $b_1113 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $6 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $7 - (call $-_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1117) - ) - (local.get $6) - (i32.const 39) - ) - ) - (block $do_backpatches.6 - ) - ) - (block $MTupleSet.8 (result i32) - (i32.store offset=8 - (global.get $b_1113) - (tuple.extract 0 - (tuple.make - (local.get $7) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func -_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MBoxOp + (MBoxUpdate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))) + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/boxes.0c59fc4e.0.snapshot b/compiler/test/__snapshots__/boxes.0c59fc4e.0.snapshot index 0fe2e435bf..8697d6fcd5 100644 --- a/compiler/test/__snapshots__/boxes.0c59fc4e.0.snapshot +++ b/compiler/test/__snapshots__/boxes.0c59fc4e.0.snapshot @@ -1,129 +1,70 @@ boxes › box_multiplication2 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$*\" (global $*_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"*\" (func $*_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.11 (result i32) - (block $compile_store.3 - (global.set $b_1113 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $6 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $7 - (call $*_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $*_1117) - ) - (local.get $6) - (i32.const 39) - ) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.10 - (local.set $8 - (block $MTupleSet.8 (result i32) - (i32.store offset=8 - (global.get $b_1113) - (tuple.extract 0 - (tuple.make - (local.get $7) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.9 - ) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func *_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind *_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MBoxOp + (MBoxUpdate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))) + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/boxes.17668725.0.snapshot b/compiler/test/__snapshots__/boxes.17668725.0.snapshot index 4734e61afc..7671e60053 100644 --- a/compiler/test/__snapshots__/boxes.17668725.0.snapshot +++ b/compiler/test/__snapshots__/boxes.17668725.0.snapshot @@ -1,129 +1,70 @@ boxes › box_division2 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$/\" (global $/_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"/\" (func $/_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.11 (result i32) - (block $compile_store.3 - (global.set $b_1113 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 153) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $6 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $7 - (call $/_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $/_1117) - ) - (local.get $6) - (i32.const 39) - ) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.10 - (local.set $8 - (block $MTupleSet.8 (result i32) - (i32.store offset=8 - (global.get $b_1113) - (tuple.extract 0 - (tuple.make - (local.get $7) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.9 - ) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name /))) (mimp_mod pervasives.gr) (mimp_name /) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name /))) (mimp_mod pervasives.gr) (mimp_name /) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 76))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func /_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind /_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MBoxOp + (MBoxUpdate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))) + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/boxes.2b56febf.0.snapshot b/compiler/test/__snapshots__/boxes.2b56febf.0.snapshot index f4831e6f97..5c8ebfef4f 100644 --- a/compiler/test/__snapshots__/boxes.2b56febf.0.snapshot +++ b/compiler/test/__snapshots__/boxes.2b56febf.0.snapshot @@ -1,129 +1,70 @@ boxes › box_addition2 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.11 (result i32) - (block $compile_store.3 - (global.set $b_1113 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $6 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $7 - (call $+_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1117) - ) - (local.get $6) - (i32.const 39) - ) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.10 - (local.set $8 - (block $MTupleSet.8 (result i32) - (i32.store offset=8 - (global.get $b_1113) - (tuple.extract 0 - (tuple.make - (local.get $7) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.9 - ) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func +_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MBoxOp + (MBoxUpdate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))) + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/boxes.7d564476.0.snapshot b/compiler/test/__snapshots__/boxes.7d564476.0.snapshot index 957fc0520a..c3e25e1adb 100644 --- a/compiler/test/__snapshots__/boxes.7d564476.0.snapshot +++ b/compiler/test/__snapshots__/boxes.7d564476.0.snapshot @@ -1,116 +1,63 @@ boxes › box_division1 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$/\" (global $/_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"/\" (func $/_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.9 (result i32) - (block $compile_store.3 - (global.set $b_1113 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 153) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $6 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $7 - (call $/_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $/_1117) - ) - (local.get $6) - (i32.const 39) - ) - ) - (block $do_backpatches.6 - ) - ) - (block $MTupleSet.8 (result i32) - (i32.store offset=8 - (global.get $b_1113) - (tuple.extract 0 - (tuple.make - (local.get $7) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name /))) (mimp_mod pervasives.gr) (mimp_name /) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name /))) (mimp_mod pervasives.gr) (mimp_name /) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 76))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func /_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind /_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MBoxOp + (MBoxUpdate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))) + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/boxes.9035923e.0.snapshot b/compiler/test/__snapshots__/boxes.9035923e.0.snapshot index f30ca37562..9e78a82620 100644 --- a/compiler/test/__snapshots__/boxes.9035923e.0.snapshot +++ b/compiler/test/__snapshots__/boxes.9035923e.0.snapshot @@ -1,129 +1,70 @@ boxes › box_subtraction2 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.11 (result i32) - (block $compile_store.3 - (global.set $b_1113 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $6 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $7 - (call $-_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1117) - ) - (local.get $6) - (i32.const 39) - ) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.10 - (local.set $8 - (block $MTupleSet.8 (result i32) - (i32.store offset=8 - (global.get $b_1113) - (tuple.extract 0 - (tuple.make - (local.get $7) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.9 - ) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func -_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MBoxOp + (MBoxUpdate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))) + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/boxes.adbe1660.0.snapshot b/compiler/test/__snapshots__/boxes.adbe1660.0.snapshot index 1f6ee78a0d..de2cebae2c 100644 --- a/compiler/test/__snapshots__/boxes.adbe1660.0.snapshot +++ b/compiler/test/__snapshots__/boxes.adbe1660.0.snapshot @@ -1,116 +1,63 @@ boxes › box_addition1 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.9 (result i32) - (block $compile_store.3 - (global.set $b_1113 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $6 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $7 - (call $+_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1117) - ) - (local.get $6) - (i32.const 39) - ) - ) - (block $do_backpatches.6 - ) - ) - (block $MTupleSet.8 (result i32) - (i32.store offset=8 - (global.get $b_1113) - (tuple.extract 0 - (tuple.make - (local.get $7) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func +_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MBoxOp + (MBoxUpdate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))) + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/boxes.bc258c1b.0.snapshot b/compiler/test/__snapshots__/boxes.bc258c1b.0.snapshot index 21ab39f1b4..6f80dd974a 100644 --- a/compiler/test/__snapshots__/boxes.bc258c1b.0.snapshot +++ b/compiler/test/__snapshots__/boxes.bc258c1b.0.snapshot @@ -1,116 +1,63 @@ boxes › box_multiplication1 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$*\" (global $*_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"*\" (func $*_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.9 (result i32) - (block $compile_store.3 - (global.set $b_1113 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $6 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $7 - (call $*_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $*_1117) - ) - (local.get $6) - (i32.const 39) - ) - ) - (block $do_backpatches.6 - ) - ) - (block $MTupleSet.8 (result i32) - (i32.store offset=8 - (global.get $b_1113) - (tuple.extract 0 - (tuple.make - (local.get $7) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func *_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind *_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MBoxOp + (MBoxUpdate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))) + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/boxes.eb81e542.0.snapshot b/compiler/test/__snapshots__/boxes.eb81e542.0.snapshot index 6bf1af481a..a1b1a73442 100644 --- a/compiler/test/__snapshots__/boxes.eb81e542.0.snapshot +++ b/compiler/test/__snapshots__/boxes.eb81e542.0.snapshot @@ -1,96 +1,30 @@ boxes › test_set_extra1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.6 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (tuple.extract 0 - (tuple.make - (block $MTupleSet.5 (result i32) - (i32.store offset=8 - (local.get $6) - (tuple.extract 0 - (tuple.make - (i32.const 5) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=8 - (local.get $6) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - (block $cleanup.4 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MBoxOp + (MBoxUpdate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))) + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/chars.200d9e1a.0.snapshot b/compiler/test/__snapshots__/chars.200d9e1a.0.snapshot index eacb069aee..04b8464a16 100644 --- a/compiler/test/__snapshots__/chars.200d9e1a.0.snapshot +++ b/compiler/test/__snapshots__/chars.200d9e1a.0.snapshot @@ -1,35 +1,15 @@ chars › char4 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 16642) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstChar A))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/chars.259e330c.0.snapshot b/compiler/test/__snapshots__/chars.259e330c.0.snapshot index e670892db7..ac5ebf3d0f 100644 --- a/compiler/test/__snapshots__/chars.259e330c.0.snapshot +++ b/compiler/test/__snapshots__/chars.259e330c.0.snapshot @@ -1,35 +1,15 @@ chars › char2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 16642) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstChar A))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/chars.27fb7f30.0.snapshot b/compiler/test/__snapshots__/chars.27fb7f30.0.snapshot index 4c88bebb84..865a3d1b7f 100644 --- a/compiler/test/__snapshots__/chars.27fb7f30.0.snapshot +++ b/compiler/test/__snapshots__/chars.27fb7f30.0.snapshot @@ -1,35 +1,15 @@ chars › char8 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 2566146) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstChar \"\\226\\156\\168\"))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/chars.51010573.0.snapshot b/compiler/test/__snapshots__/chars.51010573.0.snapshot index e0d2df47ca..e26b653074 100644 --- a/compiler/test/__snapshots__/chars.51010573.0.snapshot +++ b/compiler/test/__snapshots__/chars.51010573.0.snapshot @@ -1,35 +1,15 @@ chars › char7 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 32718338) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstChar \"\\240\\159\\140\\190\"))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/chars.7e0f68db.0.snapshot b/compiler/test/__snapshots__/chars.7e0f68db.0.snapshot index eedcc32939..000a131474 100644 --- a/compiler/test/__snapshots__/chars.7e0f68db.0.snapshot +++ b/compiler/test/__snapshots__/chars.7e0f68db.0.snapshot @@ -1,35 +1,15 @@ chars › char6 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 32812802) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstChar \"\\240\\159\\146\\175\"))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/chars.af4b3613.0.snapshot b/compiler/test/__snapshots__/chars.af4b3613.0.snapshot index fa01c9a34a..45f8980ea8 100644 --- a/compiler/test/__snapshots__/chars.af4b3613.0.snapshot +++ b/compiler/test/__snapshots__/chars.af4b3613.0.snapshot @@ -1,35 +1,15 @@ chars › char5 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 16642) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstChar A))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/chars.e1cac8cd.0.snapshot b/compiler/test/__snapshots__/chars.e1cac8cd.0.snapshot index 67af1fbcaf..5ba0493820 100644 --- a/compiler/test/__snapshots__/chars.e1cac8cd.0.snapshot +++ b/compiler/test/__snapshots__/chars.e1cac8cd.0.snapshot @@ -1,35 +1,15 @@ chars › char3 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 16642) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstChar A))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/comments.573e549e.0.snapshot b/compiler/test/__snapshots__/comments.573e549e.0.snapshot index 7fcc08f0b4..72acdee145 100644 --- a/compiler/test/__snapshots__/comments.573e549e.0.snapshot +++ b/compiler/test/__snapshots__/comments.573e549e.0.snapshot @@ -1,35 +1,15 @@ comments › comment_alone -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 21) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 10))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/comments.8f52e899.0.snapshot b/compiler/test/__snapshots__/comments.8f52e899.0.snapshot index 5a4e6e383c..8ff41a190b 100644 --- a/compiler/test/__snapshots__/comments.8f52e899.0.snapshot +++ b/compiler/test/__snapshots__/comments.8f52e899.0.snapshot @@ -1,35 +1,15 @@ comments › comment_block -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 21) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 10))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/comments.ccf5fcf4.0.snapshot b/compiler/test/__snapshots__/comments.ccf5fcf4.0.snapshot index 6cb5e597d4..060a4e7b1c 100644 --- a/compiler/test/__snapshots__/comments.ccf5fcf4.0.snapshot +++ b/compiler/test/__snapshots__/comments.ccf5fcf4.0.snapshot @@ -1,35 +1,15 @@ comments › comment_shebang -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 21) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 10))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/comments.fd91c233.0.snapshot b/compiler/test/__snapshots__/comments.fd91c233.0.snapshot index 832ff9cad7..5f4ba9f975 100644 --- a/compiler/test/__snapshots__/comments.fd91c233.0.snapshot +++ b/compiler/test/__snapshots__/comments.fd91c233.0.snapshot @@ -1,35 +1,15 @@ comments › comment_doc -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 21) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 10))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/early_return.1183a893.0.snapshot b/compiler/test/__snapshots__/early_return.1183a893.0.snapshot index 44bf4e8ece..1867d5bf4a 100644 --- a/compiler/test/__snapshots__/early_return.1183a893.0.snapshot +++ b/compiler/test/__snapshots__/early_return.1183a893.0.snapshot @@ -1,114 +1,95 @@ early return › early_return3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1116 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1116 (param i32 i32 i32) (result i32))) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"foo\" (func $foo_1113)) - (export \"GRAIN$EXPORT$foo\" (global $foo_1113)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1113 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.2 - (local.set $7 - (call $==_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1116) - ) - (i32.const 3) - (i32.const 1) - ) - ) - (block $do_backpatches.1 - ) - ) - (drop - (if (result i32) - (i32.shr_u - (local.get $7) - (i32.const 31) - ) - (block $compile_block.4 - (block $cleanup.3 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return - (i32.const -2) - ) - ) - (block $compile_block.5 (result i32) - (i32.const 1879048190) - ) - ) - ) - (block $cleanup.6 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return - (i32.const 2147483646) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.10 (result i32) - (block $compile_store.9 - (global.set $foo_1113 - (i32.const 0) - ) - (block $do_backpatches.8 - ) - ) - (i32.const 1879048190) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1000 -) +((mash_code + ((functions + (((id ((stamp 1113) (name foo))) (name (foo)) (args (Managed)) + (return_type ((Unmanaged WasmI32))) (closure ()) + (body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func ==_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind ==_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturn + (((immediate_desc + (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturn + (((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((stamp 1116) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1116) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports + ((WasmFunctionExport (ex_function_name foo) + (ex_function_internal_name foo_1113)) + (WasmGlobalExport (ex_global_name foo) + (ex_global_internal_name foo_1113)))) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((stamp 1113) (name foo))) (mutable_ true) + (allocation_type Managed) (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1119) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/enums.aa34084a.0.snapshot b/compiler/test/__snapshots__/enums.aa34084a.0.snapshot index b75fc2c0f9..038c86efcc 100644 --- a/compiler/test/__snapshots__/enums.aa34084a.0.snapshot +++ b/compiler/test/__snapshots__/enums.aa34084a.0.snapshot @@ -1,65 +1,21 @@ enums › adt_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 992856951) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 652 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 496428475))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ())))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/enums.ae26523b.0.snapshot b/compiler/test/__snapshots__/enums.ae26523b.0.snapshot index fc73935194..e2487b95d7 100644 --- a/compiler/test/__snapshots__/enums.ae26523b.0.snapshot +++ b/compiler/test/__snapshots__/enums.ae26523b.0.snapshot @@ -1,416 +1,159 @@ enums › enum_recursive_data_definition -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1129 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1129 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (block $compile_block.31 - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 6) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 54015209861748) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_string.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 6) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 55114721489524) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1215441249) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2229) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_adt.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1675317329) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (local.get $7) - ) - (i32.store offset=24 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.15 - (local.set $10 - (block $allocate_adt.13 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1215441249) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2229) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.18 - (local.set $11 - (block $allocate_adt.16 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1215441249) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2229) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (local.get $9) - ) - (i32.store offset=24 - (local.get $0) - (local.get $10) - ) - (local.get $0) - ) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.21 - (local.set $12 - (block $allocate_adt.19 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1675317329) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (local.get $11) - ) - (local.get $0) - ) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.24 - (local.set $13 - (block $allocate_adt.22 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1215441249) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2229) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.23 - ) - ) - (block $compile_store.27 - (local.set $14 - (block $allocate_adt.25 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1215441249) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2229) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (local.get $12) - ) - (i32.store offset=24 - (local.get $0) - (local.get $13) - ) - (local.get $0) - ) - ) - (block $do_backpatches.26 - ) - ) - (block $compile_store.30 - (local.set $15 - (block $allocate_adt.28 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.29 - ) - ) - (return_call $print_1129 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1129) - ) - (local.get $14) - (local.get $15) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 930 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc (MAllocate (MString \"tree 1\"))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc (MAllocate (MString \"tree 2\"))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 607720624))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1114))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 837658664))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 607720624))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1114))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 607720624))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1114))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 837658664))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 607720624))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1114))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 607720624))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1114))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MReturnCallKnown (func print_1129) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind print_1129 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 10) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/exceptions.a68ae348.0.snapshot b/compiler/test/__snapshots__/exceptions.a68ae348.0.snapshot index 1a9cefb890..25cb6db976 100644 --- a/compiler/test/__snapshots__/exceptions.a68ae348.0.snapshot +++ b/compiler/test/__snapshots__/exceptions.a68ae348.0.snapshot @@ -1,65 +1,21 @@ exceptions › exception_4 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 2229) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1760 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1114))) + (immediate_analyses ((last_usage Unknown)))) + ())))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/exceptions.ccac3e71.0.snapshot b/compiler/test/__snapshots__/exceptions.ccac3e71.0.snapshot index d62326d06a..8185c15646 100644 --- a/compiler/test/__snapshots__/exceptions.ccac3e71.0.snapshot +++ b/compiler/test/__snapshots__/exceptions.ccac3e71.0.snapshot @@ -1,65 +1,21 @@ exceptions › exception_2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 892 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + ())))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/functions.06134c8a.0.snapshot b/compiler/test/__snapshots__/functions.06134c8a.0.snapshot index 5c6a9cf856..02e7380726 100644 --- a/compiler/test/__snapshots__/functions.06134c8a.0.snapshot +++ b/compiler/test/__snapshots__/functions.06134c8a.0.snapshot @@ -1,78 +1,46 @@ functions › dup_func -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $foo_1117 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1117 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (block $compile_block.2 (result i32) - (tuple.extract 0 - (tuple.make - (i32.const 19) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.5 - (block $compile_store.4 - (global.set $foo_1117 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (return_call $foo_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1117) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions + (((id ((name foo))) (name (foo)) (args (Managed)) (return_type (Managed)) + (closure ()) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 9))) + (immediate_analyses ((last_usage Unknown)))))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1117 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MReturnCallKnown (func foo_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (() (Managed))) (args ())))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name foo))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/functions.0b8146ea.0.snapshot b/compiler/test/__snapshots__/functions.0b8146ea.0.snapshot index 0b5bf9f59d..d20dacc459 100644 --- a/compiler/test/__snapshots__/functions.0b8146ea.0.snapshot +++ b/compiler/test/__snapshots__/functions.0b8146ea.0.snapshot @@ -1,85 +1,53 @@ functions › regression_1725 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1113 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (local $7 i32) - (block $compile_block.4 - (block $compile_store.2 - (local.tee $7 - (return - (i32.const 11) - ) - ) - (block $do_backpatches.1 - ) - ) - (block $cleanup.3 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return - (i32.const 13) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.7 - (block $compile_store.6 - (global.set $foo_1113 - (i32.const 0) - ) - (block $do_backpatches.5 - ) - ) - (return_call $foo_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1113) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions + (((id ((name foo))) (name (foo)) (args (Managed)) (return_type (Managed)) + (closure ()) + (body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MReturn + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturn + (((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MReturnCallKnown (func foo_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (() (Managed))) (args ())))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name foo))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/functions.14922a92.0.snapshot b/compiler/test/__snapshots__/functions.14922a92.0.snapshot index 4e5fe1589d..1afb80d8e9 100644 --- a/compiler/test/__snapshots__/functions.14922a92.0.snapshot +++ b/compiler/test/__snapshots__/functions.14922a92.0.snapshot @@ -1,83 +1,68 @@ functions › shorthand_4 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1115 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1115 (param i32 i32 i32) (result i32))) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1113 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (block $compile_block.2 - (block $cleanup.1 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $+_1115 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1115) - ) - (local.get $1) - (i32.const 7) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.5 - (block $compile_store.4 - (global.set $foo_1113 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (return_call $foo_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1113) - ) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions + (((id ((name foo))) (name (foo)) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1115) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1115 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MReturnCallKnown (func foo_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name foo))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/functions.1be5ecd5.0.snapshot b/compiler/test/__snapshots__/functions.1be5ecd5.0.snapshot index 5e47989221..bc9eed8060 100644 --- a/compiler/test/__snapshots__/functions.1be5ecd5.0.snapshot +++ b/compiler/test/__snapshots__/functions.1be5ecd5.0.snapshot @@ -1,78 +1,49 @@ functions › shorthand_1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1113 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (block $compile_block.2 (result i32) - (tuple.extract 0 - (tuple.make - (local.get $1) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.5 - (block $compile_store.4 - (global.set $foo_1113 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (return_call $foo_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1113) - ) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions + (((id ((name foo))) (name (foo)) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MReturnCallKnown (func foo_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name foo))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/functions.23afd9c9.0.snapshot b/compiler/test/__snapshots__/functions.23afd9c9.0.snapshot index b1308be3c5..e0ad812abb 100644 --- a/compiler/test/__snapshots__/functions.23afd9c9.0.snapshot +++ b/compiler/test/__snapshots__/functions.23afd9c9.0.snapshot @@ -1,410 +1,258 @@ functions › lam_destructure_5 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1119 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1119 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $lam_lambda_1118 (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i64) - (local $7 f32) - (local $8 f64) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (block $compile_block.35 - (block $compile_store.2 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.6 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $1) - ) - ) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $13 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $1) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $14 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $1) - ) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $cleanup.13 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - ) - (drop - (block $compile_set.14 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $14) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.15 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.16 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.18 - (local.set $15 - (i32.const 0) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.20 - (local.set $16 - (i32.const 0) - ) - (block $do_backpatches.19 - ) - ) - (block $compile_store.22 - (local.set $17 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $2) - ) - ) - ) - (block $do_backpatches.21 - ) - ) - (block $compile_store.24 - (local.set $18 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $2) - ) - ) - ) - (block $do_backpatches.23 - ) - ) - (block $cleanup.25 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $2) - ) - ) - ) - (drop - (block $compile_set.26 (result i32) - (local.set $16 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $18) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.27 (result i32) - (local.set $15 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $17) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.29 - (local.set $19 - (call $+_1119 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1119) - ) - (local.get $9) - (local.get $10) - ) - ) - (block $do_backpatches.28 - ) - ) - (block $compile_store.31 - (local.set $20 - (call $+_1119 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1119) - ) - (local.get $19) - (local.get $11) - ) - ) - (block $do_backpatches.30 - ) - ) - (block $compile_store.33 - (local.set $21 - (call $+_1119 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1119) - ) - (local.get $20) - (local.get $15) - ) - ) - (block $do_backpatches.32 - ) - ) - (block $cleanup.34 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $+_1119 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1119) - ) - (local.get $21) - (local.get $16) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.44 - (block $compile_store.37 - (local.set $6 - (i32.const 0) - ) - (block $do_backpatches.36 - ) - ) - (block $compile_store.40 - (local.set $7 - (block $allocate_tuple.38 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.39 - ) - ) - (block $compile_store.43 - (local.set $8 - (block $allocate_tuple.41 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 11) - ) - (local.get $0) - ) - ) - (block $do_backpatches.42 - ) - ) - (return_call $lam_lambda_1118 - (local.get $6) - (local.get $7) - (local.get $8) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions + (((id ((name lam_lambda))) (name ()) (args (Managed Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MArgBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MArgBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MCallKnown (func +_1119) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1119 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MCallKnown (func +_1119) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1119 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MCallKnown (func +_1119) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1119 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1119) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1119 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (stack_size + ((stack_size_ptr 13) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func lam_lambda_1118) + (closure + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 3) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/functions.28e0f2b3.0.snapshot b/compiler/test/__snapshots__/functions.28e0f2b3.0.snapshot index 6a6bcd7116..b514e82626 100644 --- a/compiler/test/__snapshots__/functions.28e0f2b3.0.snapshot +++ b/compiler/test/__snapshots__/functions.28e0f2b3.0.snapshot @@ -1,113 +1,54 @@ functions › lambda_pat_any -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $x_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $x_1113 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (block $compile_block.2 (result i32) - (tuple.extract 0 - (tuple.make - (i32.const 11) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.8 - (block $compile_store.4 - (global.set $x_1113 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.7 - (local.set $6 - (block $allocate_string.5 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - (block $do_backpatches.6 - ) - ) - (return_call $x_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $x_1113) - ) - (local.get $6) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions + (((id ((name x))) (name (x)) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))) + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind x_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString foo))))))))) + ((instr_desc + (MReturnCallKnown (func x_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind x_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name x))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/functions.49ccab54.0.snapshot b/compiler/test/__snapshots__/functions.49ccab54.0.snapshot index 2683530eff..e3c2fc2b7a 100644 --- a/compiler/test/__snapshots__/functions.49ccab54.0.snapshot +++ b/compiler/test/__snapshots__/functions.49ccab54.0.snapshot @@ -1,169 +1,100 @@ functions › curried_func -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1116 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1116 (param i32 i32 i32) (result i32))) - (global $add_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 1)) - (memory $0 0) - (elem $elem (global.get $relocBase_0) $func_1123) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $add_1113 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (block $compile_block.3 (result i32) - (tuple.extract 0 - (tuple.make - (block $allocate_closure.2 (result i32) - (i32.store - (local.tee $2 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 6) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $2) - (i32.add - (global.get $relocBase_0) - (i32.const 0) - ) - ) - (i32.store offset=12 - (local.get $2) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $2) - (local.get $1) - ) - (local.get $2) - ) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $func_1123 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i64) - (local $7 f32) - (local $8 f64) - (block $closure_elements.8 - (local.set $2 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $0) - ) - ) - ) - (block $compile_block.7 - (block $cleanup.6 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $+_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1116) - ) - (local.get $2) - (local.get $1) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.14 - (block $compile_store.10 - (global.set $add_1113 - (i32.const 0) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $6 - (call $add_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $add_1113) - ) - (i32.const 5) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $call_lambda.13 - (local.set $0 - (local.get $6) - ) - (return_call_indirect (type $i32_i32_=>_i32) - (local.get $0) - (i32.const 7) - (i32.load offset=8 - (local.get $0) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions + (((id ((name add))) (name (add)) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MAllocate + (MClosure + ((func_idx (0)) (global_offset function_table_global_1122) + (arity 2) + (variables + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())) + ((id ((name func))) (name ()) (args (Managed Managed)) + (return_type (Managed)) (closure (1)) + (body + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MClosureBind 0))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind add_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func add_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind add_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallIndirect + (func + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name add))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements (func_1124)) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/functions.6eacded0.0.snapshot b/compiler/test/__snapshots__/functions.6eacded0.0.snapshot index ad915f5820..afa66ec675 100644 --- a/compiler/test/__snapshots__/functions.6eacded0.0.snapshot +++ b/compiler/test/__snapshots__/functions.6eacded0.0.snapshot @@ -1,481 +1,350 @@ functions › func_recursive_closure -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1137 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1132 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1122 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1137 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1132 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1122 (param i32 i32 i32) (result i32))) - (global $truc_1116 (mut i32) (i32.const 0)) - (global $makeAdder_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 1)) - (memory $0 0) - (elem $elem (global.get $relocBase_0) $func_1145) - (export \"memory\" (memory $0)) - (export \"truc\" (func $truc_1116)) - (export \"GRAIN$EXPORT$truc\" (global $truc_1116)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $makeAdder_1113 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (block $compile_block.3 (result i32) - (tuple.extract 0 - (tuple.make - (block $allocate_closure.2 (result i32) - (i32.store - (local.tee $2 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 6) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $2) - (i32.add - (global.get $relocBase_0) - (i32.const 0) - ) - ) - (i32.store offset=12 - (local.get $2) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $2) - (local.get $1) - ) - (local.get $2) - ) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $truc_1116 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.5 - (local.set $7 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $cleanup.6 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $foo_1117 - (local.get $7) - (i32.const 11) - ) - ) - ) - (func $func_1145 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i64) - (local $7 f32) - (local $8 f64) - (block $closure_elements.12 - (local.set $2 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $0) - ) - ) - ) - (block $compile_block.11 - (block $cleanup.10 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $+_1122 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1122) - ) - (local.get $1) - (local.get $2) - ) - ) - ) - ) - (func $foo_1117 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (block $compile_block.31 (result i32) - (block $compile_store.14 - (local.set $8 - (call $makeAdder_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $makeAdder_1113) - ) - (i32.const 3) - ) - ) - (block $do_backpatches.13 - ) - ) - (block $compile_store.17 - (local.set $9 - (block $allocate_closure.15 (result i32) - (i32.store - (local.tee $2 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 6) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $2) - (i32.const -1) - ) - (i32.store offset=12 - (local.get $2) - (i32.const 2) - ) - (local.get $2) - ) - ) - (block $do_backpatches.16 - (local.set $2 - (local.get $9) - ) - (i32.store offset=16 - (local.get $2) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $0) - ) - ) - (i32.store offset=20 - (local.get $2) - (local.get $8) - ) - ) - ) - (block $compile_store.19 - (local.set $11 - (call $==_1132 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1132) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $1) - ) - (i32.const 1) - ) - ) - (block $do_backpatches.18 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $11) - (i32.const 31) - ) - (block $compile_block.21 (result i32) - (i32.const 1) - ) - (block $compile_block.30 - (block $compile_store.23 - (local.set $12 - (call $==_1132 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1132) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $1) - ) - (i32.const 3) - ) - ) - (block $do_backpatches.22 - ) - ) - (if - (i32.shr_u - (local.get $12) - (i32.const 31) - ) - (block $compile_block.25 - (block $cleanup.24 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - ) - (return_call $bar_1120 - (local.get $9) - (i32.const 3) - ) - ) - (block $compile_block.29 - (block $compile_store.27 - (local.set $10 - (call $-_1137 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1137) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $1) - ) - (i32.const 3) - ) - ) - (block $do_backpatches.26 - ) - ) - (block $cleanup.28 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - (return_call $foo_1117 - (local.get $0) - (local.get $10) - ) - ) - ) - ) - ) - (block $cleanup.20 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $bar_1120 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i32) - (local $7 i64) - (local $8 f32) - (local $9 f64) - (local $10 i32) - (local $11 i32) - (block $closure_elements.46 - (local.set $3 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $0) - ) - ) - ) - (local.set $2 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $0) - ) - ) - ) - (block $compile_block.45 - (block $compile_store.40 - (local.set $10 - (call $foo_1117 - (local.get $2) - (i32.const 1) - ) - ) - (block $do_backpatches.39 - ) - ) - (block $compile_store.43 - (local.set $11 - (block $call_lambda.41 (result i32) - (local.set $4 - (local.get $3) - ) - (call_indirect (type $i32_i32_=>_i32) - (local.get $4) - (i32.const 3) - (i32.load offset=8 - (local.get $4) - ) - ) - ) - ) - (block $do_backpatches.42 - ) - ) - (block $cleanup.44 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - ) - (return_call $+_1122 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1122) - ) - (local.get $10) - (local.get $11) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.51 - (block $compile_store.48 - (global.set $makeAdder_1113 - (i32.const 0) - ) - (block $do_backpatches.47 - ) - ) - (block $compile_store.50 - (global.set $truc_1116 - (i32.const 0) - ) - (block $do_backpatches.49 - ) - ) - (return_call $truc_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $truc_1116) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1025 -) +((mash_code + ((functions + (((id ((name makeAdder))) (name (makeAdder)) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MAllocate + (MClosure + ((func_idx (0)) (global_offset function_table_global_1143) + (arity 2) + (variables + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())) + ((id ((name truc))) (name (truc)) (args (Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func foo_1117) + (closure + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))))))))) + (stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())) + ((id ((name func))) (name ()) (args (Managed Managed)) + (return_type (Managed)) (closure (1)) + (body + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1122) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1122 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MClosureBind 0))) + (immediate_analyses ((last_usage Last))))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())) + ((id ((name foo))) (name ()) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func makeAdder_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind makeAdder_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MClosure + ((func_idx ()) (global_offset function_table_global_1143) + (arity 2) + (variables + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func ==_1132) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind ==_1132 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func ==_1132) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind ==_1132 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func bar_1120) + (closure + ((immediate_desc + (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MCallKnown (func -_1137) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind -_1137 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc + (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func foo_1117) + (closure + ((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 3) (stack_size_i32 2) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())) + ((id ((name bar))) (name ()) (args (Managed Managed)) + (return_type (Managed)) (closure (2)) + (body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func foo_1117) + (closure + ((immediate_desc (MImmBinding (MClosureBind 0))) + (immediate_analyses ((last_usage Last))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallIndirect + (func + ((immediate_desc (MImmBinding (MClosureBind 1))) + (immediate_analyses ((last_usage Last))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1122) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1122 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name ==))) (mimp_mod pervasives.gr) (mimp_name ==) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports + ((WasmFunctionExport (ex_function_name truc) + (ex_function_internal_name truc_1116)) + (WasmGlobalExport (ex_global_name truc) + (ex_global_internal_name truc_1116)))) + (main_body + (((instr_desc + (MStore + (((MGlobalBind makeAdder_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind truc_1116 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MReturnCallKnown (func truc_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind truc_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type (() (Managed))) (args ())))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name truc))) (mutable_ true) (allocation_type Managed) + (initial_value ())) + ((id ((name makeAdder))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements (func_1146)) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/functions.7a8986a5.0.snapshot b/compiler/test/__snapshots__/functions.7a8986a5.0.snapshot index c1720ca673..61c695a112 100644 --- a/compiler/test/__snapshots__/functions.7a8986a5.0.snapshot +++ b/compiler/test/__snapshots__/functions.7a8986a5.0.snapshot @@ -1,73 +1,43 @@ functions › app_1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $lam_lambda_1114 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (block $compile_block.2 (result i32) - (tuple.extract 0 - (tuple.make - (local.get $1) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 - (block $compile_store.4 - (local.set $6 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (return_call $lam_lambda_1114 - (local.get $6) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions + (((id ((name lam_lambda))) (name ()) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MReturnCallKnown (func lam_lambda_1114) + (closure + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/functions.84b6e84b.0.snapshot b/compiler/test/__snapshots__/functions.84b6e84b.0.snapshot index 3a79d9bc68..469a2c69bb 100644 --- a/compiler/test/__snapshots__/functions.84b6e84b.0.snapshot +++ b/compiler/test/__snapshots__/functions.84b6e84b.0.snapshot @@ -1,78 +1,49 @@ functions › shorthand_3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1113 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (block $compile_block.2 (result i32) - (tuple.extract 0 - (tuple.make - (local.get $1) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.5 - (block $compile_store.4 - (global.set $foo_1113 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (return_call $foo_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1113) - ) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions + (((id ((name foo))) (name (foo)) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MReturnCallKnown (func foo_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name foo))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/functions.8baf471f.0.snapshot b/compiler/test/__snapshots__/functions.8baf471f.0.snapshot index 92c03b5086..4c2e7f15f7 100644 --- a/compiler/test/__snapshots__/functions.8baf471f.0.snapshot +++ b/compiler/test/__snapshots__/functions.8baf471f.0.snapshot @@ -1,260 +1,162 @@ functions › lam_destructure_3 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1117 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $lam_lambda_1116 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (block $compile_block.20 - (block $compile_store.2 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.6 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $1) - ) - ) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $1) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $13 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $1) - ) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $cleanup.13 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - ) - (drop - (block $compile_set.14 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.15 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.16 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.18 - (local.set $14 - (call $+_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1117) - ) - (local.get $8) - (local.get $9) - ) - ) - (block $do_backpatches.17 - ) - ) - (block $cleanup.19 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $+_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1117) - ) - (local.get $14) - (local.get $10) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.26 - (block $compile_store.22 - (local.set $6 - (i32.const 0) - ) - (block $do_backpatches.21 - ) - ) - (block $compile_store.25 - (local.set $7 - (block $allocate_tuple.23 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.24 - ) - ) - (return_call $lam_lambda_1116 - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions + (((id ((name lam_lambda))) (name ()) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MCallKnown (func +_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1117 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (stack_size + ((stack_size_ptr 7) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func lam_lambda_1116) + (closure + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/functions.9223245d.0.snapshot b/compiler/test/__snapshots__/functions.9223245d.0.snapshot index e5c7a08c5f..9ea77a55cf 100644 --- a/compiler/test/__snapshots__/functions.9223245d.0.snapshot +++ b/compiler/test/__snapshots__/functions.9223245d.0.snapshot @@ -1,367 +1,223 @@ functions › lam_destructure_7 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1118 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1118 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $lam_lambda_1117 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (block $compile_block.30 - (block $compile_store.2 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.6 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $1) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $13 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $1) - ) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.14 - (local.set $14 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $1) - ) - ) - ) - (block $do_backpatches.13 - ) - ) - (block $cleanup.15 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - ) - (block $compile_store.17 - (local.set $15 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $14) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.19 - (local.set $16 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $14) - ) - ) - ) - (block $do_backpatches.18 - ) - ) - (block $cleanup.20 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - (drop - (block $compile_set.21 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.22 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.23 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $16) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.24 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.26 - (local.set $17 - (call $+_1118 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1118) - ) - (local.get $8) - (local.get $9) - ) - ) - (block $do_backpatches.25 - ) - ) - (block $compile_store.28 - (local.set $18 - (call $+_1118 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1118) - ) - (local.get $17) - (local.get $10) - ) - ) - (block $do_backpatches.27 - ) - ) - (block $cleanup.29 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $+_1118 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1118) - ) - (local.get $18) - (local.get $11) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.39 - (block $compile_store.32 - (local.set $6 - (i32.const 0) - ) - (block $do_backpatches.31 - ) - ) - (block $compile_store.35 - (local.set $7 - (block $allocate_tuple.33 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.34 - ) - ) - (block $compile_store.38 - (local.set $8 - (block $allocate_tuple.36 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.37 - ) - ) - (return_call $lam_lambda_1117 - (local.get $6) - (local.get $8) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions + (((id ((name lam_lambda))) (name ()) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MCallKnown (func +_1118) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1118 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MCallKnown (func +_1118) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1118 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1118) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1118 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (stack_size + ((stack_size_ptr 11) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MReturnCallKnown (func lam_lambda_1117) + (closure + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 3) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/functions.9fd69835.0.snapshot b/compiler/test/__snapshots__/functions.9fd69835.0.snapshot index 4776b97204..e99c990cac 100644 --- a/compiler/test/__snapshots__/functions.9fd69835.0.snapshot +++ b/compiler/test/__snapshots__/functions.9fd69835.0.snapshot @@ -1,83 +1,68 @@ functions › shorthand_2 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1115 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1115 (param i32 i32 i32) (result i32))) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1113 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (block $compile_block.2 - (block $cleanup.1 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $+_1115 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1115) - ) - (local.get $1) - (i32.const 7) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.5 - (block $compile_store.4 - (global.set $foo_1113 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (return_call $foo_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1113) - ) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions + (((id ((name foo))) (name (foo)) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1115) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1115 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MReturnCallKnown (func foo_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name foo))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/functions.b37949b2.0.snapshot b/compiler/test/__snapshots__/functions.b37949b2.0.snapshot index f9da9683a2..e5652bfb4a 100644 --- a/compiler/test/__snapshots__/functions.b37949b2.0.snapshot +++ b/compiler/test/__snapshots__/functions.b37949b2.0.snapshot @@ -1,263 +1,168 @@ functions › lam_destructure_4 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1117 (param i32 i32 i32) (result i32))) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1113 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (block $compile_block.20 - (block $compile_store.2 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.6 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $1) - ) - ) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $1) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $13 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $1) - ) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $cleanup.13 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - ) - (drop - (block $compile_set.14 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.15 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.16 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.18 - (local.set $14 - (call $+_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1117) - ) - (local.get $8) - (local.get $9) - ) - ) - (block $do_backpatches.17 - ) - ) - (block $cleanup.19 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $+_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1117) - ) - (local.get $14) - (local.get $10) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.26 - (block $compile_store.22 - (global.set $foo_1113 - (i32.const 0) - ) - (block $do_backpatches.21 - ) - ) - (block $compile_store.25 - (local.set $6 - (block $allocate_tuple.23 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.24 - ) - ) - (return_call $foo_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1113) - ) - (local.get $6) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions + (((id ((name foo))) (name (foo)) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MCallKnown (func +_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1117 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (stack_size + ((stack_size_ptr 7) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func foo_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name foo))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/functions.b3a8d88b.0.snapshot b/compiler/test/__snapshots__/functions.b3a8d88b.0.snapshot index f53e729a68..6b61a20235 100644 --- a/compiler/test/__snapshots__/functions.b3a8d88b.0.snapshot +++ b/compiler/test/__snapshots__/functions.b3a8d88b.0.snapshot @@ -1,370 +1,229 @@ functions › lam_destructure_8 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1118 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1118 (param i32 i32 i32) (result i32))) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1113 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (block $compile_block.30 - (block $compile_store.2 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.6 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $1) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $13 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $1) - ) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.14 - (local.set $14 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $1) - ) - ) - ) - (block $do_backpatches.13 - ) - ) - (block $cleanup.15 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - ) - (block $compile_store.17 - (local.set $15 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $14) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.19 - (local.set $16 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $14) - ) - ) - ) - (block $do_backpatches.18 - ) - ) - (block $cleanup.20 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - (drop - (block $compile_set.21 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.22 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.23 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $16) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.24 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.26 - (local.set $17 - (call $+_1118 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1118) - ) - (local.get $8) - (local.get $9) - ) - ) - (block $do_backpatches.25 - ) - ) - (block $compile_store.28 - (local.set $18 - (call $+_1118 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1118) - ) - (local.get $17) - (local.get $10) - ) - ) - (block $do_backpatches.27 - ) - ) - (block $cleanup.29 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $+_1118 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1118) - ) - (local.get $18) - (local.get $11) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.39 - (block $compile_store.32 - (global.set $foo_1113 - (i32.const 0) - ) - (block $do_backpatches.31 - ) - ) - (block $compile_store.35 - (local.set $6 - (block $allocate_tuple.33 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.34 - ) - ) - (block $compile_store.38 - (local.set $7 - (block $allocate_tuple.36 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.37 - ) - ) - (return_call $foo_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1113) - ) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions + (((id ((name foo))) (name (foo)) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MCallKnown (func +_1118) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1118 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MCallKnown (func +_1118) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1118 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1118) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1118 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (stack_size + ((stack_size_ptr 11) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MReturnCallKnown (func foo_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name foo))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/functions.b632a2ab.0.snapshot b/compiler/test/__snapshots__/functions.b632a2ab.0.snapshot index b1e84ed43a..23ecb10b14 100644 --- a/compiler/test/__snapshots__/functions.b632a2ab.0.snapshot +++ b/compiler/test/__snapshots__/functions.b632a2ab.0.snapshot @@ -1,108 +1,48 @@ functions › lam_destructure_1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $lam_lambda_1113 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (block $compile_block.2 (result i32) - (tuple.extract 0 - (tuple.make - (i32.const 11) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.8 - (block $compile_store.4 - (local.set $6 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.7 - (local.set $7 - (block $allocate_string.5 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - (block $do_backpatches.6 - ) - ) - (return_call $lam_lambda_1113 - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions + (((id ((name lam_lambda))) (name ()) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))) + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) ((instr_desc (MAllocate (MString foo))))))))) + ((instr_desc + (MReturnCallKnown (func lam_lambda_1113) + (closure + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/functions.c6e8a9aa.0.snapshot b/compiler/test/__snapshots__/functions.c6e8a9aa.0.snapshot index ce918b7148..6d5447bfab 100644 --- a/compiler/test/__snapshots__/functions.c6e8a9aa.0.snapshot +++ b/compiler/test/__snapshots__/functions.c6e8a9aa.0.snapshot @@ -1,113 +1,54 @@ functions › lam_destructure_2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1113 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (block $compile_block.2 (result i32) - (tuple.extract 0 - (tuple.make - (i32.const 11) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.8 - (block $compile_store.4 - (global.set $foo_1113 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.7 - (local.set $6 - (block $allocate_string.5 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - (block $do_backpatches.6 - ) - ) - (return_call $foo_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1113) - ) - (local.get $6) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions + (((id ((name foo))) (name (foo)) (args (Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))) + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString foo))))))))) + ((instr_desc + (MReturnCallKnown (func foo_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name foo))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/functions.ce978f54.0.snapshot b/compiler/test/__snapshots__/functions.ce978f54.0.snapshot index 66f683d7f8..05adf50f75 100644 --- a/compiler/test/__snapshots__/functions.ce978f54.0.snapshot +++ b/compiler/test/__snapshots__/functions.ce978f54.0.snapshot @@ -1,35 +1,15 @@ functions › multi_bind2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 7) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/functions.d9466880.0.snapshot b/compiler/test/__snapshots__/functions.d9466880.0.snapshot index 8a6c3d20c9..d8cebaa692 100644 --- a/compiler/test/__snapshots__/functions.d9466880.0.snapshot +++ b/compiler/test/__snapshots__/functions.d9466880.0.snapshot @@ -1,239 +1,97 @@ functions › func_record_associativity2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 1)) - (memory $0 0) - (elem $elem (global.get $relocBase_0) $lam_lambda_1121) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $lam_lambda_1121 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (block $closure_elements.5 (result i32) - (block $compile_block.4 (result i32) - (tuple.extract 0 - (tuple.make - (i32.const 2147483646) - (block $cleanup.3 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (block $compile_block.24 (result i32) - (block $compile_store.8 - (local.set $6 - (block $allocate_closure.6 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 6) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.add - (global.get $relocBase_0) - (i32.const 0) - ) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.7 - (local.set $0 - (local.get $6) - ) - ) - ) - (block $compile_store.11 - (local.set $7 - (block $allocate_record.9 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1631403427) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.14 - (local.set $8 - (block $allocate_record.12 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 485893719) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2229) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.13 - ) - ) - (block $compile_store.16 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $8) - ) - ) - ) - (block $do_backpatches.15 - ) - ) - (block $cleanup.17 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - (block $compile_store.19 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $9) - ) - ) - ) - (block $do_backpatches.18 - ) - ) - (block $cleanup.20 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - (block $compile_store.23 - (local.set $11 - (block $call_lambda.21 (result i32) - (local.set $0 - (local.get $10) - ) - (call_indirect (type $i32_=>_i32) - (local.get $0) - (i32.load offset=8 - (local.get $0) - ) - ) - ) - ) - (block $do_backpatches.22 - ) - ) - (i32.xor - (local.get $11) - (i32.const -2147483648) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 626 -) +((mash_code + ((functions + (((id ((name lam_lambda))) (name ()) (args (Managed)) + (return_type ((Unmanaged WasmI32))) (closure (0)) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MClosure + ((func_idx (0)) (global_offset function_table_global_1125) + (arity 1) (variables ()))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 815701713))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((g) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 242946859))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1114))) + (immediate_analyses ((last_usage Unknown)))) + (((f) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallIndirect + (func + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))) + (func_type (() ((Unmanaged WasmI32)))) (args ()))))))))) + ((instr_desc + (MPrim1 Not + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 5) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements (lam_lambda_1121)) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/functions.e6c6212b.0.snapshot b/compiler/test/__snapshots__/functions.e6c6212b.0.snapshot index 99de1e8a5a..0172c3a5b5 100644 --- a/compiler/test/__snapshots__/functions.e6c6212b.0.snapshot +++ b/compiler/test/__snapshots__/functions.e6c6212b.0.snapshot @@ -1,84 +1,70 @@ functions › fn_trailing_comma -(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)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1116 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1116 (param i32 i32 i32) (result i32))) - (global $testFn_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $testFn_1113 (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i64) - (local $7 f32) - (local $8 f64) - (block $compile_block.2 - (block $cleanup.1 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $+_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1116) - ) - (local.get $1) - (local.get $2) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.5 - (block $compile_store.4 - (global.set $testFn_1113 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (return_call $testFn_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $testFn_1113) - ) - (i32.const 5) - (i32.const 7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions + (((id ((name testFn))) (name (testFn)) (args (Managed Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MArgBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind testFn_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MReturnCallKnown (func testFn_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind testFn_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name testFn))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/functions.f400bb7b.0.snapshot b/compiler/test/__snapshots__/functions.f400bb7b.0.snapshot index 5ae53c6b0c..aff242262e 100644 --- a/compiler/test/__snapshots__/functions.f400bb7b.0.snapshot +++ b/compiler/test/__snapshots__/functions.f400bb7b.0.snapshot @@ -1,413 +1,264 @@ functions › lam_destructure_6 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1119 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1119 (param i32 i32 i32) (result i32))) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1113 (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i64) - (local $7 f32) - (local $8 f64) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (block $compile_block.35 - (block $compile_store.2 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.6 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $1) - ) - ) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $13 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $1) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $14 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $1) - ) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $cleanup.13 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - ) - (drop - (block $compile_set.14 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $14) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.15 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.16 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.18 - (local.set $15 - (i32.const 0) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.20 - (local.set $16 - (i32.const 0) - ) - (block $do_backpatches.19 - ) - ) - (block $compile_store.22 - (local.set $17 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $2) - ) - ) - ) - (block $do_backpatches.21 - ) - ) - (block $compile_store.24 - (local.set $18 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $2) - ) - ) - ) - (block $do_backpatches.23 - ) - ) - (block $cleanup.25 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $2) - ) - ) - ) - (drop - (block $compile_set.26 (result i32) - (local.set $16 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $18) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.27 (result i32) - (local.set $15 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $17) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.29 - (local.set $19 - (call $+_1119 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1119) - ) - (local.get $9) - (local.get $10) - ) - ) - (block $do_backpatches.28 - ) - ) - (block $compile_store.31 - (local.set $20 - (call $+_1119 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1119) - ) - (local.get $19) - (local.get $11) - ) - ) - (block $do_backpatches.30 - ) - ) - (block $compile_store.33 - (local.set $21 - (call $+_1119 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1119) - ) - (local.get $20) - (local.get $15) - ) - ) - (block $do_backpatches.32 - ) - ) - (block $cleanup.34 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $+_1119 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1119) - ) - (local.get $21) - (local.get $16) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.44 - (block $compile_store.37 - (global.set $foo_1113 - (i32.const 0) - ) - (block $do_backpatches.36 - ) - ) - (block $compile_store.40 - (local.set $6 - (block $allocate_tuple.38 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.39 - ) - ) - (block $compile_store.43 - (local.set $7 - (block $allocate_tuple.41 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 11) - ) - (local.get $0) - ) - ) - (block $do_backpatches.42 - ) - ) - (return_call $foo_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions + (((id ((name foo))) (name (foo)) (args (Managed Managed Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 0 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MArgBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MArgBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MCallKnown (func +_1119) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1119 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MCallKnown (func +_1119) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1119 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MCallKnown (func +_1119) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1119 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1119) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1119 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (stack_size + ((stack_size_ptr 13) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func foo_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name foo))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/functions.f647681b.0.snapshot b/compiler/test/__snapshots__/functions.f647681b.0.snapshot index ef38b07655..702dd136aa 100644 --- a/compiler/test/__snapshots__/functions.f647681b.0.snapshot +++ b/compiler/test/__snapshots__/functions.f647681b.0.snapshot @@ -1,183 +1,73 @@ functions › func_record_associativity1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 1)) - (memory $0 0) - (elem $elem (global.get $relocBase_0) $lam_lambda_1118) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $lam_lambda_1118 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (block $closure_elements.5 (result i32) - (block $compile_block.4 (result i32) - (tuple.extract 0 - (tuple.make - (i32.const 2147483646) - (block $cleanup.3 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.18 (result i32) - (block $compile_store.8 - (local.set $6 - (block $allocate_closure.6 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 6) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.add - (global.get $relocBase_0) - (i32.const 0) - ) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.7 - (local.set $0 - (local.get $6) - ) - ) - ) - (block $compile_store.11 - (local.set $7 - (block $allocate_record.9 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 485893719) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $7) - ) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $cleanup.14 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (block $compile_store.17 - (local.set $9 - (block $call_lambda.15 (result i32) - (local.set $0 - (local.get $8) - ) - (call_indirect (type $i32_=>_i32) - (local.get $0) - (i32.load offset=8 - (local.get $0) - ) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (i32.xor - (local.get $9) - (i32.const -2147483648) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 496 -) +((mash_code + ((functions + (((id ((name lam_lambda))) (name ()) (args (Managed)) + (return_type ((Unmanaged WasmI32))) (closure (0)) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MClosure + ((func_idx (0)) (global_offset function_table_global_1121) + (arity 1) (variables ()))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 242946859))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((f) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallIndirect + (func + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))) + (func_type (() ((Unmanaged WasmI32)))) (args ()))))))))) + ((instr_desc + (MPrim1 Not + ((immediate_desc (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 3) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements (lam_lambda_1118)) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/includes.1d829099.0.snapshot b/compiler/test/__snapshots__/includes.1d829099.0.snapshot index 4731179f70..831b66860b 100644 --- a/compiler/test/__snapshots__/includes.1d829099.0.snapshot +++ b/compiler/test/__snapshots__/includes.1d829099.0.snapshot @@ -1,36 +1,20 @@ includes › include_relative_path2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$../../test/test-libs/provideAll.gr\" \"GRAIN$EXPORT$x\" (global $x_1122 (mut i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (global.get $x_1122) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 453 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name x))) (mimp_mod ../../test/test-libs/provideAll.gr) + (mimp_name x) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind x_1122 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/includes.46f78654.0.snapshot b/compiler/test/__snapshots__/includes.46f78654.0.snapshot index cfa601d016..3f5dcb00a5 100644 --- a/compiler/test/__snapshots__/includes.46f78654.0.snapshot +++ b/compiler/test/__snapshots__/includes.46f78654.0.snapshot @@ -1,50 +1,38 @@ includes › include_some_multiple -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$x\" (global $x_1123 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$y\" (global $y_1122 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"y\" (func $y_1122 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $y_1122 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $y_1122) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $x_1123) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 421 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name x))) (mimp_mod provideAll.gr) (mimp_name x) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name y))) (mimp_mod provideAll.gr) (mimp_name y) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name y))) (mimp_mod provideAll.gr) (mimp_name y) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func y_1122) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind y_1122 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind x_1123 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/includes.5dfba7dd.0.snapshot b/compiler/test/__snapshots__/includes.5dfba7dd.0.snapshot index 11a9fba19d..540ea8786c 100644 --- a/compiler/test/__snapshots__/includes.5dfba7dd.0.snapshot +++ b/compiler/test/__snapshots__/includes.5dfba7dd.0.snapshot @@ -1,36 +1,20 @@ includes › include_alias -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$x\" (global $x_1122 (mut i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (global.get $x_1122) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 421 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name x))) (mimp_mod provideAll.gr) (mimp_name x) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind x_1122 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/includes.6c8d23dc.0.snapshot b/compiler/test/__snapshots__/includes.6c8d23dc.0.snapshot index eac4043ae3..654ea48e22 100644 --- a/compiler/test/__snapshots__/includes.6c8d23dc.0.snapshot +++ b/compiler/test/__snapshots__/includes.6c8d23dc.0.snapshot @@ -1,50 +1,38 @@ includes › include_some_multiple_trailing2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$x\" (global $x_1123 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$y\" (global $y_1122 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"y\" (func $y_1122 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $y_1122 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $y_1122) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $x_1123) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 421 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name x))) (mimp_mod provideAll.gr) (mimp_name x) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name y))) (mimp_mod provideAll.gr) (mimp_name y) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name y))) (mimp_mod provideAll.gr) (mimp_name y) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func y_1122) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind y_1122 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind x_1123 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/includes.6e78c003.0.snapshot b/compiler/test/__snapshots__/includes.6e78c003.0.snapshot index 409acc60d0..8756b9aad3 100644 --- a/compiler/test/__snapshots__/includes.6e78c003.0.snapshot +++ b/compiler/test/__snapshots__/includes.6e78c003.0.snapshot @@ -1,50 +1,38 @@ includes › include_some_multiple_trailing -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$x\" (global $x_1123 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$y\" (global $y_1122 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"y\" (func $y_1122 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $y_1122 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $y_1122) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $x_1123) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 421 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name x))) (mimp_mod provideAll.gr) (mimp_name x) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name y))) (mimp_mod provideAll.gr) (mimp_name y) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name y))) (mimp_mod provideAll.gr) (mimp_name y) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func y_1122) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind y_1122 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind x_1123 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/includes.7afbe731.0.snapshot b/compiler/test/__snapshots__/includes.7afbe731.0.snapshot index 8a13625134..1d5bf3b156 100644 --- a/compiler/test/__snapshots__/includes.7afbe731.0.snapshot +++ b/compiler/test/__snapshots__/includes.7afbe731.0.snapshot @@ -1,36 +1,20 @@ includes › include_some -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$x\" (global $x_1122 (mut i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (global.get $x_1122) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 421 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name x))) (mimp_mod provideAll.gr) (mimp_name x) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind x_1122 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/includes.8222ee98.0.snapshot b/compiler/test/__snapshots__/includes.8222ee98.0.snapshot index 7027f8dcdc..97214d524f 100644 --- a/compiler/test/__snapshots__/includes.8222ee98.0.snapshot +++ b/compiler/test/__snapshots__/includes.8222ee98.0.snapshot @@ -1,36 +1,20 @@ includes › include_module -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$x\" (global $x_1122 (mut i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (global.get $x_1122) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 421 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name x))) (mimp_mod provideAll.gr) (mimp_name x) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind x_1122 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/includes.86ff4075.0.snapshot b/compiler/test/__snapshots__/includes.86ff4075.0.snapshot index 5fd1034367..231a2846ec 100644 --- a/compiler/test/__snapshots__/includes.86ff4075.0.snapshot +++ b/compiler/test/__snapshots__/includes.86ff4075.0.snapshot @@ -1,50 +1,38 @@ includes › include_alias_multiple -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$x\" (global $x_1123 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$y\" (global $y_1122 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"y\" (func $y_1122 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $y_1122 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $y_1122) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $x_1123) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 421 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name x))) (mimp_mod provideAll.gr) (mimp_name x) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name y))) (mimp_mod provideAll.gr) (mimp_name y) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name y))) (mimp_mod provideAll.gr) (mimp_name y) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func y_1122) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind y_1122 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind x_1123 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/includes.a3212bd0.0.snapshot b/compiler/test/__snapshots__/includes.a3212bd0.0.snapshot index 45a9450f9e..3b7728e794 100644 --- a/compiler/test/__snapshots__/includes.a3212bd0.0.snapshot +++ b/compiler/test/__snapshots__/includes.a3212bd0.0.snapshot @@ -1,36 +1,20 @@ includes › include_relative_path3 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$nested/nested.gr\" \"GRAIN$EXPORT$j\" (global $j_1116 (mut i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (global.get $j_1116) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 435 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name j))) (mimp_mod nested/nested.gr) (mimp_name j) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind j_1116 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/includes.b3434679.0.snapshot b/compiler/test/__snapshots__/includes.b3434679.0.snapshot index 981458dbf2..55424c9060 100644 --- a/compiler/test/__snapshots__/includes.b3434679.0.snapshot +++ b/compiler/test/__snapshots__/includes.b3434679.0.snapshot @@ -1,108 +1,37 @@ includes › include_some_constructor -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1218386633) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2243) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1218386633) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2243) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 417 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 609193316))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1121))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 609193316))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1121))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/includes.bd3eb3af.0.snapshot b/compiler/test/__snapshots__/includes.bd3eb3af.0.snapshot index c46804bb9a..d137749bcd 100644 --- a/compiler/test/__snapshots__/includes.bd3eb3af.0.snapshot +++ b/compiler/test/__snapshots__/includes.bd3eb3af.0.snapshot @@ -1,126 +1,61 @@ includes › include_some_mixed -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$tlists.gr\" \"GRAIN$EXPORT$sum\" (global $sum_1126 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$tlists.gr\" \"sum\" (func $sum_1126 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1218386633) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2243) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1218386633) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2243) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $sum_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $sum_1126) - ) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 417 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name sum))) (mimp_mod tlists.gr) (mimp_name sum) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name sum))) (mimp_mod tlists.gr) (mimp_name sum) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 609193316))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1121))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 609193316))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1121))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MReturnCallKnown (func sum_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind sum_1126 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/includes.beda767e.0.snapshot b/compiler/test/__snapshots__/includes.beda767e.0.snapshot index f7c605b7fa..3f8d487585 100644 --- a/compiler/test/__snapshots__/includes.beda767e.0.snapshot +++ b/compiler/test/__snapshots__/includes.beda767e.0.snapshot @@ -1,36 +1,20 @@ includes › include_relative_path1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$../test-libs/provideAll.gr\" \"GRAIN$EXPORT$x\" (global $x_1122 (mut i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (global.get $x_1122) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 446 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name x))) (mimp_mod ../test-libs/provideAll.gr) + (mimp_name x) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind x_1122 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/includes.c0c0d5ca.0.snapshot b/compiler/test/__snapshots__/includes.c0c0d5ca.0.snapshot index 92f4e5f892..b8ea19cba3 100644 --- a/compiler/test/__snapshots__/includes.c0c0d5ca.0.snapshot +++ b/compiler/test/__snapshots__/includes.c0c0d5ca.0.snapshot @@ -1,101 +1,71 @@ includes › include_relative_path4 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$./bar/bar.gr\" \"GRAIN$EXPORT$bar\" (global $bar_1119 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1116 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$./bar/bar.gr\" \"bar\" (func $bar_1119 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1116 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.6 - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (call $bar_1119 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $bar_1119) - ) - (i32.const 5) - ) - ) - (block $do_backpatches.4 - ) - ) - (return_call $print_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1116) - ) - (local.get $7) - (local.get $6) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 419 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name bar))) (mimp_mod ./bar/bar.gr) (mimp_name bar) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name bar))) (mimp_mod ./bar/bar.gr) (mimp_name bar) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name print))) (mimp_mod pervasives.gr) (mimp_name print) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func bar_1119) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind bar_1119 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func print_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind print_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/includes.c62f45f8.0.snapshot b/compiler/test/__snapshots__/includes.c62f45f8.0.snapshot index 1c43486098..5e2ac37e66 100644 --- a/compiler/test/__snapshots__/includes.c62f45f8.0.snapshot +++ b/compiler/test/__snapshots__/includes.c62f45f8.0.snapshot @@ -1,114 +1,45 @@ includes › include_muliple_modules -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$x\" (global $x_1136 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1218386633) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2243) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1218386633) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2243) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $x_1136) - ) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 470 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name x))) (mimp_mod provideAll.gr) (mimp_name x) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 609193316))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1121))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 609193316))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1121))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind x_1136 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/includes.cedde8e9.0.snapshot b/compiler/test/__snapshots__/includes.cedde8e9.0.snapshot index 706b117ef8..cefb2381ff 100644 --- a/compiler/test/__snapshots__/includes.cedde8e9.0.snapshot +++ b/compiler/test/__snapshots__/includes.cedde8e9.0.snapshot @@ -1,108 +1,37 @@ includes › include_same_module_unify -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1218386633) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2243) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1218386633) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2243) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 417 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 609193316))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1121))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 609193316))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1121))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/includes.de6b420f.0.snapshot b/compiler/test/__snapshots__/includes.de6b420f.0.snapshot index 37b3b08a0b..5321ebf138 100644 --- a/compiler/test/__snapshots__/includes.de6b420f.0.snapshot +++ b/compiler/test/__snapshots__/includes.de6b420f.0.snapshot @@ -1,65 +1,21 @@ includes › annotation_across_import -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1218386633) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2243) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 417 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 609193316))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1121))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ())))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/includes.f2bf866b.0.snapshot b/compiler/test/__snapshots__/includes.f2bf866b.0.snapshot index d10c38b449..fe3d0378d4 100644 --- a/compiler/test/__snapshots__/includes.f2bf866b.0.snapshot +++ b/compiler/test/__snapshots__/includes.f2bf866b.0.snapshot @@ -1,108 +1,37 @@ includes › include_all_constructor -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1218386633) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2243) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1218386633) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2243) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 417 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 609193316))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1121))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 609193316))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1121))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/includes.f4ba5583.0.snapshot b/compiler/test/__snapshots__/includes.f4ba5583.0.snapshot index 9e852f7236..f82fe0ed18 100644 --- a/compiler/test/__snapshots__/includes.f4ba5583.0.snapshot +++ b/compiler/test/__snapshots__/includes.f4ba5583.0.snapshot @@ -1,50 +1,38 @@ includes › include_module2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$x\" (global $x_1123 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$y\" (global $y_1122 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"y\" (func $y_1122 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $y_1122 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $y_1122) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $x_1123) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 421 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name x))) (mimp_mod provideAll.gr) (mimp_name x) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name y))) (mimp_mod provideAll.gr) (mimp_name y) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name y))) (mimp_mod provideAll.gr) (mimp_name y) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func y_1122) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind y_1122 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind x_1123 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/let_mut.00e05fe2.0.snapshot b/compiler/test/__snapshots__/let_mut.00e05fe2.0.snapshot index 8e8647a680..11d4b8aaa6 100644 --- a/compiler/test/__snapshots__/let_mut.00e05fe2.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.00e05fe2.0.snapshot @@ -1,85 +1,58 @@ let mut › let-mut_division1 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$/\" (global $/_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"/\" (func $/_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.6 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 153) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $/_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $/_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 39) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_set.5 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name /))) (mimp_mod pervasives.gr) (mimp_name /) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name /))) (mimp_mod pervasives.gr) (mimp_name /) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 76))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func /_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind /_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/let_mut.1176df90.0.snapshot b/compiler/test/__snapshots__/let_mut.1176df90.0.snapshot index 21f3c3cda8..91a396ca17 100644 --- a/compiler/test/__snapshots__/let_mut.1176df90.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.1176df90.0.snapshot @@ -1,93 +1,65 @@ let mut › let-mut_multiplication2 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$*\" (global $*_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"*\" (func $*_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.8 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 9) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $*_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $*_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 39) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.7 - (local.set $7 - (block $compile_set.5 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.6 - ) - ) - (global.get $b_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func *_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind *_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/let_mut.3307d5a7.0.snapshot b/compiler/test/__snapshots__/let_mut.3307d5a7.0.snapshot index d61ed4bbfb..46bed06049 100644 --- a/compiler/test/__snapshots__/let_mut.3307d5a7.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.3307d5a7.0.snapshot @@ -1,72 +1,26 @@ let mut › let-mut3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.4 (result i32) - (block $compile_store.3 - (global.set $b_1113 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/let_mut.43f6980c.0.snapshot b/compiler/test/__snapshots__/let_mut.43f6980c.0.snapshot index 087c385be3..2aa0237de8 100644 --- a/compiler/test/__snapshots__/let_mut.43f6980c.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.43f6980c.0.snapshot @@ -1,93 +1,65 @@ let mut › let-mut_division3 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$/\" (global $/_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"/\" (func $/_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.8 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 153) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $/_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $/_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 39) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.7 - (local.set $7 - (block $compile_set.5 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.6 - ) - ) - (global.get $b_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name /))) (mimp_mod pervasives.gr) (mimp_name /) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name /))) (mimp_mod pervasives.gr) (mimp_name /) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 76))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func /_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind /_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/let_mut.48249b50.0.snapshot b/compiler/test/__snapshots__/let_mut.48249b50.0.snapshot index 41325073ac..1bc3d0c245 100644 --- a/compiler/test/__snapshots__/let_mut.48249b50.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.48249b50.0.snapshot @@ -1,93 +1,65 @@ let mut › let-mut5 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.8 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 9) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $-_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 3) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.7 - (local.set $7 - (block $compile_set.5 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.6 - ) - ) - (global.get $b_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func -_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/let_mut.4c3f3b2b.0.snapshot b/compiler/test/__snapshots__/let_mut.4c3f3b2b.0.snapshot index cd74f4d8ed..d22b12de89 100644 --- a/compiler/test/__snapshots__/let_mut.4c3f3b2b.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.4c3f3b2b.0.snapshot @@ -1,100 +1,38 @@ let mut › let-mut2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.7 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 13) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (global.set $b_1113 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=12 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (global.get $b_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/let_mut.4c75261e.0.snapshot b/compiler/test/__snapshots__/let_mut.4c75261e.0.snapshot index 9e8b4d5e11..ccd3b7d5cf 100644 --- a/compiler/test/__snapshots__/let_mut.4c75261e.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.4c75261e.0.snapshot @@ -1,85 +1,58 @@ let mut › let-mut_multiplication1 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$*\" (global $*_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"*\" (func $*_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.6 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 9) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $*_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $*_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 39) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_set.5 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func *_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind *_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/let_mut.634331f0.0.snapshot b/compiler/test/__snapshots__/let_mut.634331f0.0.snapshot index b99c66a0f4..c12a543d48 100644 --- a/compiler/test/__snapshots__/let_mut.634331f0.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.634331f0.0.snapshot @@ -1,93 +1,65 @@ let mut › let-mut_multiplication3 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$*\" (global $*_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"*\" (func $*_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.8 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 9) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $*_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $*_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 39) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.7 - (local.set $7 - (block $compile_set.5 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.6 - ) - ) - (global.get $b_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name *))) (mimp_mod pervasives.gr) (mimp_name *) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func *_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind *_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/let_mut.63c16374.0.snapshot b/compiler/test/__snapshots__/let_mut.63c16374.0.snapshot index b4cc9a238f..975c707f00 100644 --- a/compiler/test/__snapshots__/let_mut.63c16374.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.63c16374.0.snapshot @@ -1,72 +1,34 @@ let mut › let-mut4 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.6 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 9) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.5 - (local.set $6 - (block $compile_set.3 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.const 7) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.4 - ) - ) - (global.get $b_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/let_mut.6796c72d.0.snapshot b/compiler/test/__snapshots__/let_mut.6796c72d.0.snapshot index 95ffb67ecc..0ce513433e 100644 --- a/compiler/test/__snapshots__/let_mut.6796c72d.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.6796c72d.0.snapshot @@ -1,85 +1,58 @@ let mut › let-mut_subtraction1 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.6 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 9) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $-_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 39) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_set.5 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func -_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/let_mut.baaea1d3.0.snapshot b/compiler/test/__snapshots__/let_mut.baaea1d3.0.snapshot index ea552860f0..f468af0398 100644 --- a/compiler/test/__snapshots__/let_mut.baaea1d3.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.baaea1d3.0.snapshot @@ -1,93 +1,65 @@ let mut › let-mut_subtraction2 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.8 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 9) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $-_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 39) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.7 - (local.set $7 - (block $compile_set.5 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.6 - ) - ) - (global.get $b_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func -_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/let_mut.cbbbaeb4.0.snapshot b/compiler/test/__snapshots__/let_mut.cbbbaeb4.0.snapshot index f77cfefd09..0e0d623369 100644 --- a/compiler/test/__snapshots__/let_mut.cbbbaeb4.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.cbbbaeb4.0.snapshot @@ -1,93 +1,65 @@ let mut › let-mut_addition2 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.8 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 9) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $+_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 39) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.7 - (local.set $7 - (block $compile_set.5 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.6 - ) - ) - (global.get $b_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func +_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/let_mut.d2de286b.0.snapshot b/compiler/test/__snapshots__/let_mut.d2de286b.0.snapshot index 97735a2e47..a9cffb8b71 100644 --- a/compiler/test/__snapshots__/let_mut.d2de286b.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.d2de286b.0.snapshot @@ -1,85 +1,58 @@ let mut › let-mut_addition1 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.6 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 9) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $+_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 39) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_set.5 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func +_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/let_mut.e90db621.0.snapshot b/compiler/test/__snapshots__/let_mut.e90db621.0.snapshot index 27bf2fafca..f8a24fdd37 100644 --- a/compiler/test/__snapshots__/let_mut.e90db621.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.e90db621.0.snapshot @@ -1,93 +1,65 @@ let mut › let-mut_subtraction3 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.8 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 9) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $-_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 39) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.7 - (local.set $7 - (block $compile_set.5 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.6 - ) - ) - (global.get $b_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func -_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind -_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/let_mut.f8f208a2.0.snapshot b/compiler/test/__snapshots__/let_mut.f8f208a2.0.snapshot index 42357fccf5..a658425342 100644 --- a/compiler/test/__snapshots__/let_mut.f8f208a2.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.f8f208a2.0.snapshot @@ -1,93 +1,65 @@ let mut › let-mut_addition3 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.8 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 9) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $+_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 39) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.7 - (local.set $7 - (block $compile_set.5 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.6 - ) - ) - (global.get $b_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func +_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/let_mut.f9e32f30.0.snapshot b/compiler/test/__snapshots__/let_mut.f9e32f30.0.snapshot index a57b08f22b..049bfde48c 100644 --- a/compiler/test/__snapshots__/let_mut.f9e32f30.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.f9e32f30.0.snapshot @@ -1,93 +1,65 @@ let mut › let-mut_division2 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$/\" (global $/_1117 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"/\" (func $/_1117 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.8 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 153) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $6 - (call $/_1117 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $/_1117) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 39) - ) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.7 - (local.set $7 - (block $compile_set.5 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.6 - ) - ) - (global.get $b_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name /))) (mimp_mod pervasives.gr) (mimp_name /) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name /))) (mimp_mod pervasives.gr) (mimp_name /) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 76))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func /_1117) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind /_1117 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/let_mut.fcc9c65d.0.snapshot b/compiler/test/__snapshots__/let_mut.fcc9c65d.0.snapshot index d6c372eeb9..fd27211dee 100644 --- a/compiler/test/__snapshots__/let_mut.fcc9c65d.0.snapshot +++ b/compiler/test/__snapshots__/let_mut.fcc9c65d.0.snapshot @@ -1,43 +1,25 @@ let mut › let-mut1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.3 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 9) - ) - (block $do_backpatches.1 - ) - ) - (global.get $b_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/lists.4cfe47d3.0.snapshot b/compiler/test/__snapshots__/lists.4cfe47d3.0.snapshot index 3ef6e1b8d7..96b2ae2725 100644 --- a/compiler/test/__snapshots__/lists.4cfe47d3.0.snapshot +++ b/compiler/test/__snapshots__/lists.4cfe47d3.0.snapshot @@ -1,4193 +1,1557 @@ lists › list_large1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (local $23 i32) - (local $24 i32) - (local $25 i32) - (local $26 i32) - (local $27 i32) - (local $28 i32) - (local $29 i32) - (local $30 i32) - (local $31 i32) - (local $32 i32) - (local $33 i32) - (local $34 i32) - (local $35 i32) - (local $36 i32) - (local $37 i32) - (local $38 i32) - (local $39 i32) - (local $40 i32) - (local $41 i32) - (local $42 i32) - (local $43 i32) - (local $44 i32) - (local $45 i32) - (local $46 i32) - (local $47 i32) - (local $48 i32) - (local $49 i32) - (local $50 i32) - (local $51 i32) - (local $52 i32) - (local $53 i32) - (local $54 i32) - (local $55 i32) - (local $56 i32) - (local $57 i32) - (local $58 i32) - (local $59 i32) - (local $60 i32) - (local $61 i32) - (local $62 i32) - (local $63 i32) - (local $64 i32) - (local $65 i32) - (local $66 i32) - (local $67 i32) - (local $68 i32) - (local $69 i32) - (local $70 i32) - (local $71 i32) - (local $72 i32) - (local $73 i32) - (local $74 i32) - (local $75 i32) - (local $76 i32) - (local $77 i32) - (local $78 i32) - (local $79 i32) - (local $80 i32) - (local $81 i32) - (local $82 i32) - (local $83 i32) - (local $84 i32) - (local $85 i32) - (local $86 i32) - (local $87 i32) - (local $88 i32) - (local $89 i32) - (local $90 i32) - (local $91 i32) - (local $92 i32) - (local $93 i32) - (local $94 i32) - (local $95 i32) - (local $96 i32) - (local $97 i32) - (local $98 i32) - (local $99 i32) - (local $100 i32) - (local $101 i32) - (block $compile_block.290 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 193) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 191) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_adt.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 189) - ) - (i32.store offset=24 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.15 - (local.set $10 - (block $allocate_adt.13 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 187) - ) - (i32.store offset=24 - (local.get $0) - (local.get $9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.18 - (local.set $11 - (block $allocate_adt.16 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 185) - ) - (i32.store offset=24 - (local.get $0) - (local.get $10) - ) - (local.get $0) - ) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.21 - (local.set $12 - (block $allocate_adt.19 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 183) - ) - (i32.store offset=24 - (local.get $0) - (local.get $11) - ) - (local.get $0) - ) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.24 - (local.set $13 - (block $allocate_adt.22 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 181) - ) - (i32.store offset=24 - (local.get $0) - (local.get $12) - ) - (local.get $0) - ) - ) - (block $do_backpatches.23 - ) - ) - (block $compile_store.27 - (local.set $14 - (block $allocate_adt.25 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 179) - ) - (i32.store offset=24 - (local.get $0) - (local.get $13) - ) - (local.get $0) - ) - ) - (block $do_backpatches.26 - ) - ) - (block $compile_store.30 - (local.set $15 - (block $allocate_adt.28 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 177) - ) - (i32.store offset=24 - (local.get $0) - (local.get $14) - ) - (local.get $0) - ) - ) - (block $do_backpatches.29 - ) - ) - (block $compile_store.33 - (local.set $16 - (block $allocate_adt.31 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 175) - ) - (i32.store offset=24 - (local.get $0) - (local.get $15) - ) - (local.get $0) - ) - ) - (block $do_backpatches.32 - ) - ) - (block $compile_store.36 - (local.set $17 - (block $allocate_adt.34 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 173) - ) - (i32.store offset=24 - (local.get $0) - (local.get $16) - ) - (local.get $0) - ) - ) - (block $do_backpatches.35 - ) - ) - (block $compile_store.39 - (local.set $18 - (block $allocate_adt.37 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 171) - ) - (i32.store offset=24 - (local.get $0) - (local.get $17) - ) - (local.get $0) - ) - ) - (block $do_backpatches.38 - ) - ) - (block $compile_store.42 - (local.set $19 - (block $allocate_adt.40 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 169) - ) - (i32.store offset=24 - (local.get $0) - (local.get $18) - ) - (local.get $0) - ) - ) - (block $do_backpatches.41 - ) - ) - (block $compile_store.45 - (local.set $20 - (block $allocate_adt.43 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 167) - ) - (i32.store offset=24 - (local.get $0) - (local.get $19) - ) - (local.get $0) - ) - ) - (block $do_backpatches.44 - ) - ) - (block $compile_store.48 - (local.set $21 - (block $allocate_adt.46 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 165) - ) - (i32.store offset=24 - (local.get $0) - (local.get $20) - ) - (local.get $0) - ) - ) - (block $do_backpatches.47 - ) - ) - (block $compile_store.51 - (local.set $22 - (block $allocate_adt.49 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 163) - ) - (i32.store offset=24 - (local.get $0) - (local.get $21) - ) - (local.get $0) - ) - ) - (block $do_backpatches.50 - ) - ) - (block $compile_store.54 - (local.set $23 - (block $allocate_adt.52 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 161) - ) - (i32.store offset=24 - (local.get $0) - (local.get $22) - ) - (local.get $0) - ) - ) - (block $do_backpatches.53 - ) - ) - (block $compile_store.57 - (local.set $24 - (block $allocate_adt.55 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 159) - ) - (i32.store offset=24 - (local.get $0) - (local.get $23) - ) - (local.get $0) - ) - ) - (block $do_backpatches.56 - ) - ) - (block $compile_store.60 - (local.set $25 - (block $allocate_adt.58 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 157) - ) - (i32.store offset=24 - (local.get $0) - (local.get $24) - ) - (local.get $0) - ) - ) - (block $do_backpatches.59 - ) - ) - (block $compile_store.63 - (local.set $26 - (block $allocate_adt.61 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 155) - ) - (i32.store offset=24 - (local.get $0) - (local.get $25) - ) - (local.get $0) - ) - ) - (block $do_backpatches.62 - ) - ) - (block $compile_store.66 - (local.set $27 - (block $allocate_adt.64 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 153) - ) - (i32.store offset=24 - (local.get $0) - (local.get $26) - ) - (local.get $0) - ) - ) - (block $do_backpatches.65 - ) - ) - (block $compile_store.69 - (local.set $28 - (block $allocate_adt.67 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 151) - ) - (i32.store offset=24 - (local.get $0) - (local.get $27) - ) - (local.get $0) - ) - ) - (block $do_backpatches.68 - ) - ) - (block $compile_store.72 - (local.set $29 - (block $allocate_adt.70 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 149) - ) - (i32.store offset=24 - (local.get $0) - (local.get $28) - ) - (local.get $0) - ) - ) - (block $do_backpatches.71 - ) - ) - (block $compile_store.75 - (local.set $30 - (block $allocate_adt.73 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 147) - ) - (i32.store offset=24 - (local.get $0) - (local.get $29) - ) - (local.get $0) - ) - ) - (block $do_backpatches.74 - ) - ) - (block $compile_store.78 - (local.set $31 - (block $allocate_adt.76 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 145) - ) - (i32.store offset=24 - (local.get $0) - (local.get $30) - ) - (local.get $0) - ) - ) - (block $do_backpatches.77 - ) - ) - (block $compile_store.81 - (local.set $32 - (block $allocate_adt.79 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 143) - ) - (i32.store offset=24 - (local.get $0) - (local.get $31) - ) - (local.get $0) - ) - ) - (block $do_backpatches.80 - ) - ) - (block $compile_store.84 - (local.set $33 - (block $allocate_adt.82 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 141) - ) - (i32.store offset=24 - (local.get $0) - (local.get $32) - ) - (local.get $0) - ) - ) - (block $do_backpatches.83 - ) - ) - (block $compile_store.87 - (local.set $34 - (block $allocate_adt.85 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 139) - ) - (i32.store offset=24 - (local.get $0) - (local.get $33) - ) - (local.get $0) - ) - ) - (block $do_backpatches.86 - ) - ) - (block $compile_store.90 - (local.set $35 - (block $allocate_adt.88 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 137) - ) - (i32.store offset=24 - (local.get $0) - (local.get $34) - ) - (local.get $0) - ) - ) - (block $do_backpatches.89 - ) - ) - (block $compile_store.93 - (local.set $36 - (block $allocate_adt.91 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 135) - ) - (i32.store offset=24 - (local.get $0) - (local.get $35) - ) - (local.get $0) - ) - ) - (block $do_backpatches.92 - ) - ) - (block $compile_store.96 - (local.set $37 - (block $allocate_adt.94 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 133) - ) - (i32.store offset=24 - (local.get $0) - (local.get $36) - ) - (local.get $0) - ) - ) - (block $do_backpatches.95 - ) - ) - (block $compile_store.99 - (local.set $38 - (block $allocate_adt.97 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 131) - ) - (i32.store offset=24 - (local.get $0) - (local.get $37) - ) - (local.get $0) - ) - ) - (block $do_backpatches.98 - ) - ) - (block $compile_store.102 - (local.set $39 - (block $allocate_adt.100 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 129) - ) - (i32.store offset=24 - (local.get $0) - (local.get $38) - ) - (local.get $0) - ) - ) - (block $do_backpatches.101 - ) - ) - (block $compile_store.105 - (local.set $40 - (block $allocate_adt.103 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 127) - ) - (i32.store offset=24 - (local.get $0) - (local.get $39) - ) - (local.get $0) - ) - ) - (block $do_backpatches.104 - ) - ) - (block $compile_store.108 - (local.set $41 - (block $allocate_adt.106 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 125) - ) - (i32.store offset=24 - (local.get $0) - (local.get $40) - ) - (local.get $0) - ) - ) - (block $do_backpatches.107 - ) - ) - (block $compile_store.111 - (local.set $42 - (block $allocate_adt.109 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 123) - ) - (i32.store offset=24 - (local.get $0) - (local.get $41) - ) - (local.get $0) - ) - ) - (block $do_backpatches.110 - ) - ) - (block $compile_store.114 - (local.set $43 - (block $allocate_adt.112 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 121) - ) - (i32.store offset=24 - (local.get $0) - (local.get $42) - ) - (local.get $0) - ) - ) - (block $do_backpatches.113 - ) - ) - (block $compile_store.117 - (local.set $44 - (block $allocate_adt.115 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 119) - ) - (i32.store offset=24 - (local.get $0) - (local.get $43) - ) - (local.get $0) - ) - ) - (block $do_backpatches.116 - ) - ) - (block $compile_store.120 - (local.set $45 - (block $allocate_adt.118 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 117) - ) - (i32.store offset=24 - (local.get $0) - (local.get $44) - ) - (local.get $0) - ) - ) - (block $do_backpatches.119 - ) - ) - (block $compile_store.123 - (local.set $46 - (block $allocate_adt.121 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 115) - ) - (i32.store offset=24 - (local.get $0) - (local.get $45) - ) - (local.get $0) - ) - ) - (block $do_backpatches.122 - ) - ) - (block $compile_store.126 - (local.set $47 - (block $allocate_adt.124 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 113) - ) - (i32.store offset=24 - (local.get $0) - (local.get $46) - ) - (local.get $0) - ) - ) - (block $do_backpatches.125 - ) - ) - (block $compile_store.129 - (local.set $48 - (block $allocate_adt.127 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 111) - ) - (i32.store offset=24 - (local.get $0) - (local.get $47) - ) - (local.get $0) - ) - ) - (block $do_backpatches.128 - ) - ) - (block $compile_store.132 - (local.set $49 - (block $allocate_adt.130 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 109) - ) - (i32.store offset=24 - (local.get $0) - (local.get $48) - ) - (local.get $0) - ) - ) - (block $do_backpatches.131 - ) - ) - (block $compile_store.135 - (local.set $50 - (block $allocate_adt.133 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 107) - ) - (i32.store offset=24 - (local.get $0) - (local.get $49) - ) - (local.get $0) - ) - ) - (block $do_backpatches.134 - ) - ) - (block $compile_store.138 - (local.set $51 - (block $allocate_adt.136 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 105) - ) - (i32.store offset=24 - (local.get $0) - (local.get $50) - ) - (local.get $0) - ) - ) - (block $do_backpatches.137 - ) - ) - (block $compile_store.141 - (local.set $52 - (block $allocate_adt.139 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 103) - ) - (i32.store offset=24 - (local.get $0) - (local.get $51) - ) - (local.get $0) - ) - ) - (block $do_backpatches.140 - ) - ) - (block $compile_store.144 - (local.set $53 - (block $allocate_adt.142 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 101) - ) - (i32.store offset=24 - (local.get $0) - (local.get $52) - ) - (local.get $0) - ) - ) - (block $do_backpatches.143 - ) - ) - (block $compile_store.147 - (local.set $54 - (block $allocate_adt.145 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 99) - ) - (i32.store offset=24 - (local.get $0) - (local.get $53) - ) - (local.get $0) - ) - ) - (block $do_backpatches.146 - ) - ) - (block $compile_store.150 - (local.set $55 - (block $allocate_adt.148 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 97) - ) - (i32.store offset=24 - (local.get $0) - (local.get $54) - ) - (local.get $0) - ) - ) - (block $do_backpatches.149 - ) - ) - (block $compile_store.153 - (local.set $56 - (block $allocate_adt.151 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 95) - ) - (i32.store offset=24 - (local.get $0) - (local.get $55) - ) - (local.get $0) - ) - ) - (block $do_backpatches.152 - ) - ) - (block $compile_store.156 - (local.set $57 - (block $allocate_adt.154 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 93) - ) - (i32.store offset=24 - (local.get $0) - (local.get $56) - ) - (local.get $0) - ) - ) - (block $do_backpatches.155 - ) - ) - (block $compile_store.159 - (local.set $58 - (block $allocate_adt.157 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 91) - ) - (i32.store offset=24 - (local.get $0) - (local.get $57) - ) - (local.get $0) - ) - ) - (block $do_backpatches.158 - ) - ) - (block $compile_store.162 - (local.set $59 - (block $allocate_adt.160 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 89) - ) - (i32.store offset=24 - (local.get $0) - (local.get $58) - ) - (local.get $0) - ) - ) - (block $do_backpatches.161 - ) - ) - (block $compile_store.165 - (local.set $60 - (block $allocate_adt.163 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 87) - ) - (i32.store offset=24 - (local.get $0) - (local.get $59) - ) - (local.get $0) - ) - ) - (block $do_backpatches.164 - ) - ) - (block $compile_store.168 - (local.set $61 - (block $allocate_adt.166 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 85) - ) - (i32.store offset=24 - (local.get $0) - (local.get $60) - ) - (local.get $0) - ) - ) - (block $do_backpatches.167 - ) - ) - (block $compile_store.171 - (local.set $62 - (block $allocate_adt.169 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 83) - ) - (i32.store offset=24 - (local.get $0) - (local.get $61) - ) - (local.get $0) - ) - ) - (block $do_backpatches.170 - ) - ) - (block $compile_store.174 - (local.set $63 - (block $allocate_adt.172 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 81) - ) - (i32.store offset=24 - (local.get $0) - (local.get $62) - ) - (local.get $0) - ) - ) - (block $do_backpatches.173 - ) - ) - (block $compile_store.177 - (local.set $64 - (block $allocate_adt.175 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 79) - ) - (i32.store offset=24 - (local.get $0) - (local.get $63) - ) - (local.get $0) - ) - ) - (block $do_backpatches.176 - ) - ) - (block $compile_store.180 - (local.set $65 - (block $allocate_adt.178 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 77) - ) - (i32.store offset=24 - (local.get $0) - (local.get $64) - ) - (local.get $0) - ) - ) - (block $do_backpatches.179 - ) - ) - (block $compile_store.183 - (local.set $66 - (block $allocate_adt.181 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 75) - ) - (i32.store offset=24 - (local.get $0) - (local.get $65) - ) - (local.get $0) - ) - ) - (block $do_backpatches.182 - ) - ) - (block $compile_store.186 - (local.set $67 - (block $allocate_adt.184 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 73) - ) - (i32.store offset=24 - (local.get $0) - (local.get $66) - ) - (local.get $0) - ) - ) - (block $do_backpatches.185 - ) - ) - (block $compile_store.189 - (local.set $68 - (block $allocate_adt.187 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 71) - ) - (i32.store offset=24 - (local.get $0) - (local.get $67) - ) - (local.get $0) - ) - ) - (block $do_backpatches.188 - ) - ) - (block $compile_store.192 - (local.set $69 - (block $allocate_adt.190 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 69) - ) - (i32.store offset=24 - (local.get $0) - (local.get $68) - ) - (local.get $0) - ) - ) - (block $do_backpatches.191 - ) - ) - (block $compile_store.195 - (local.set $70 - (block $allocate_adt.193 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 67) - ) - (i32.store offset=24 - (local.get $0) - (local.get $69) - ) - (local.get $0) - ) - ) - (block $do_backpatches.194 - ) - ) - (block $compile_store.198 - (local.set $71 - (block $allocate_adt.196 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 65) - ) - (i32.store offset=24 - (local.get $0) - (local.get $70) - ) - (local.get $0) - ) - ) - (block $do_backpatches.197 - ) - ) - (block $compile_store.201 - (local.set $72 - (block $allocate_adt.199 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 63) - ) - (i32.store offset=24 - (local.get $0) - (local.get $71) - ) - (local.get $0) - ) - ) - (block $do_backpatches.200 - ) - ) - (block $compile_store.204 - (local.set $73 - (block $allocate_adt.202 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 61) - ) - (i32.store offset=24 - (local.get $0) - (local.get $72) - ) - (local.get $0) - ) - ) - (block $do_backpatches.203 - ) - ) - (block $compile_store.207 - (local.set $74 - (block $allocate_adt.205 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 59) - ) - (i32.store offset=24 - (local.get $0) - (local.get $73) - ) - (local.get $0) - ) - ) - (block $do_backpatches.206 - ) - ) - (block $compile_store.210 - (local.set $75 - (block $allocate_adt.208 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 57) - ) - (i32.store offset=24 - (local.get $0) - (local.get $74) - ) - (local.get $0) - ) - ) - (block $do_backpatches.209 - ) - ) - (block $compile_store.213 - (local.set $76 - (block $allocate_adt.211 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 55) - ) - (i32.store offset=24 - (local.get $0) - (local.get $75) - ) - (local.get $0) - ) - ) - (block $do_backpatches.212 - ) - ) - (block $compile_store.216 - (local.set $77 - (block $allocate_adt.214 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 53) - ) - (i32.store offset=24 - (local.get $0) - (local.get $76) - ) - (local.get $0) - ) - ) - (block $do_backpatches.215 - ) - ) - (block $compile_store.219 - (local.set $78 - (block $allocate_adt.217 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 51) - ) - (i32.store offset=24 - (local.get $0) - (local.get $77) - ) - (local.get $0) - ) - ) - (block $do_backpatches.218 - ) - ) - (block $compile_store.222 - (local.set $79 - (block $allocate_adt.220 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 49) - ) - (i32.store offset=24 - (local.get $0) - (local.get $78) - ) - (local.get $0) - ) - ) - (block $do_backpatches.221 - ) - ) - (block $compile_store.225 - (local.set $80 - (block $allocate_adt.223 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 47) - ) - (i32.store offset=24 - (local.get $0) - (local.get $79) - ) - (local.get $0) - ) - ) - (block $do_backpatches.224 - ) - ) - (block $compile_store.228 - (local.set $81 - (block $allocate_adt.226 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 45) - ) - (i32.store offset=24 - (local.get $0) - (local.get $80) - ) - (local.get $0) - ) - ) - (block $do_backpatches.227 - ) - ) - (block $compile_store.231 - (local.set $82 - (block $allocate_adt.229 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 43) - ) - (i32.store offset=24 - (local.get $0) - (local.get $81) - ) - (local.get $0) - ) - ) - (block $do_backpatches.230 - ) - ) - (block $compile_store.234 - (local.set $83 - (block $allocate_adt.232 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 41) - ) - (i32.store offset=24 - (local.get $0) - (local.get $82) - ) - (local.get $0) - ) - ) - (block $do_backpatches.233 - ) - ) - (block $compile_store.237 - (local.set $84 - (block $allocate_adt.235 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 39) - ) - (i32.store offset=24 - (local.get $0) - (local.get $83) - ) - (local.get $0) - ) - ) - (block $do_backpatches.236 - ) - ) - (block $compile_store.240 - (local.set $85 - (block $allocate_adt.238 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 37) - ) - (i32.store offset=24 - (local.get $0) - (local.get $84) - ) - (local.get $0) - ) - ) - (block $do_backpatches.239 - ) - ) - (block $compile_store.243 - (local.set $86 - (block $allocate_adt.241 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 35) - ) - (i32.store offset=24 - (local.get $0) - (local.get $85) - ) - (local.get $0) - ) - ) - (block $do_backpatches.242 - ) - ) - (block $compile_store.246 - (local.set $87 - (block $allocate_adt.244 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 33) - ) - (i32.store offset=24 - (local.get $0) - (local.get $86) - ) - (local.get $0) - ) - ) - (block $do_backpatches.245 - ) - ) - (block $compile_store.249 - (local.set $88 - (block $allocate_adt.247 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 31) - ) - (i32.store offset=24 - (local.get $0) - (local.get $87) - ) - (local.get $0) - ) - ) - (block $do_backpatches.248 - ) - ) - (block $compile_store.252 - (local.set $89 - (block $allocate_adt.250 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 29) - ) - (i32.store offset=24 - (local.get $0) - (local.get $88) - ) - (local.get $0) - ) - ) - (block $do_backpatches.251 - ) - ) - (block $compile_store.255 - (local.set $90 - (block $allocate_adt.253 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 27) - ) - (i32.store offset=24 - (local.get $0) - (local.get $89) - ) - (local.get $0) - ) - ) - (block $do_backpatches.254 - ) - ) - (block $compile_store.258 - (local.set $91 - (block $allocate_adt.256 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 25) - ) - (i32.store offset=24 - (local.get $0) - (local.get $90) - ) - (local.get $0) - ) - ) - (block $do_backpatches.257 - ) - ) - (block $compile_store.261 - (local.set $92 - (block $allocate_adt.259 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 23) - ) - (i32.store offset=24 - (local.get $0) - (local.get $91) - ) - (local.get $0) - ) - ) - (block $do_backpatches.260 - ) - ) - (block $compile_store.264 - (local.set $93 - (block $allocate_adt.262 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 21) - ) - (i32.store offset=24 - (local.get $0) - (local.get $92) - ) - (local.get $0) - ) - ) - (block $do_backpatches.263 - ) - ) - (block $compile_store.267 - (local.set $94 - (block $allocate_adt.265 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 19) - ) - (i32.store offset=24 - (local.get $0) - (local.get $93) - ) - (local.get $0) - ) - ) - (block $do_backpatches.266 - ) - ) - (block $compile_store.270 - (local.set $95 - (block $allocate_adt.268 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 17) - ) - (i32.store offset=24 - (local.get $0) - (local.get $94) - ) - (local.get $0) - ) - ) - (block $do_backpatches.269 - ) - ) - (block $compile_store.273 - (local.set $96 - (block $allocate_adt.271 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 15) - ) - (i32.store offset=24 - (local.get $0) - (local.get $95) - ) - (local.get $0) - ) - ) - (block $do_backpatches.272 - ) - ) - (block $compile_store.276 - (local.set $97 - (block $allocate_adt.274 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 13) - ) - (i32.store offset=24 - (local.get $0) - (local.get $96) - ) - (local.get $0) - ) - ) - (block $do_backpatches.275 - ) - ) - (block $compile_store.279 - (local.set $98 - (block $allocate_adt.277 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (local.get $97) - ) - (local.get $0) - ) - ) - (block $do_backpatches.278 - ) - ) - (block $compile_store.282 - (local.set $99 - (block $allocate_adt.280 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=24 - (local.get $0) - (local.get $98) - ) - (local.get $0) - ) - ) - (block $do_backpatches.281 - ) - ) - (block $compile_store.285 - (local.set $100 - (block $allocate_adt.283 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=24 - (local.get $0) - (local.get $99) - ) - (local.get $0) - ) - ) - (block $do_backpatches.284 - ) - ) - (block $compile_store.288 - (local.set $101 - (block $allocate_adt.286 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $100) - ) - (local.get $0) - ) - ) - (block $do_backpatches.287 - ) - ) - (block $allocate_adt.289 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=24 - (local.get $0) - (local.get $101) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 96))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 95))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 94))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 93))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 92))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 91))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 90))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 89))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 88))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 87))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 86))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 85))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 13 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 84))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 14 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 83))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 15 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 82))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 16 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 81))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 17 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 80))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 18 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 79))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 19 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 78))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 20 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 77))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 21 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 76))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 20 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 22 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 75))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 21 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 23 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 74))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 22 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 24 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 73))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 23 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 25 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 72))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 24 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 26 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 71))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 25 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 27 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 70))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 26 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 28 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 69))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 27 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 29 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 68))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 28 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 30 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 67))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 29 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 31 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 66))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 30 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 32 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 65))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 31 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 33 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 64))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 32 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 34 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 63))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 33 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 35 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 62))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 34 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 36 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 61))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 35 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 37 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 60))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 36 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 38 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 59))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 37 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 39 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 58))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 38 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 40 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 57))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 39 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 41 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 56))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 40 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 42 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 55))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 41 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 43 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 54))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 42 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 44 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 53))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 43 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 45 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 52))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 44 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 46 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 51))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 45 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 47 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 50))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 46 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 48 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 49))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 47 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 49 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 48))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 48 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 50 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 47))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 49 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 51 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 46))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 50 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 52 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 45))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 51 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 53 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 44))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 52 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 54 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 43))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 53 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 55 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 42))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 54 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 56 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 41))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 55 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 57 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 40))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 56 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 58 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 39))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 57 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 59 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 38))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 58 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 60 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 37))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 59 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 61 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 36))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 60 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 62 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 35))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 61 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 63 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 34))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 62 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 64 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 33))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 63 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 65 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 32))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 64 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 66 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 31))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 65 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 67 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 30))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 66 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 68 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 29))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 67 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 69 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 28))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 68 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 70 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 27))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 69 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 71 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 26))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 70 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 72 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 25))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 71 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 73 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 24))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 72 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 74 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 23))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 73 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 75 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 22))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 74 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 76 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 21))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 75 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 77 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 20))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 76 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 78 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 19))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 77 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 79 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 18))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 78 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 80 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 17))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 79 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 81 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 16))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 80 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 82 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 15))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 81 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 83 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 14))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 82 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 84 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 13))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 83 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 85 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 12))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 84 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 86 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 11))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 85 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 87 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 10))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 86 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 88 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 9))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 87 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 89 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 8))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 88 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 90 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 7))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 89 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 91 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 90 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 92 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 91 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 93 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 92 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 94 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 93 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 95 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 94 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 95 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 96) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/lists.884ce894.0.snapshot b/compiler/test/__snapshots__/lists.884ce894.0.snapshot index 52e737b7e8..51e808de6e 100644 --- a/compiler/test/__snapshots__/lists.884ce894.0.snapshot +++ b/compiler/test/__snapshots__/lists.884ce894.0.snapshot @@ -1,237 +1,85 @@ lists › list_spread -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.14 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_adt.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $allocate_adt.13 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=24 - (local.get $0) - (local.get $9) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 4) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/lists.d9fd46fb.0.snapshot b/compiler/test/__snapshots__/lists.d9fd46fb.0.snapshot index 85cd722772..2152b1141b 100644 --- a/compiler/test/__snapshots__/lists.d9fd46fb.0.snapshot +++ b/compiler/test/__snapshots__/lists.d9fd46fb.0.snapshot @@ -1,194 +1,69 @@ lists › list1_trailing_space -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.11 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $allocate_adt.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=24 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 3) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/lists.e5378351.0.snapshot b/compiler/test/__snapshots__/lists.e5378351.0.snapshot index 5a371e9f30..220a861a8e 100644 --- a/compiler/test/__snapshots__/lists.e5378351.0.snapshot +++ b/compiler/test/__snapshots__/lists.e5378351.0.snapshot @@ -1,194 +1,69 @@ lists › list1_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.11 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $allocate_adt.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=24 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 3) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/loops.0a25def1.0.snapshot b/compiler/test/__snapshots__/loops.0a25def1.0.snapshot index 38725f2826..4ac9b0c1bd 100644 --- a/compiler/test/__snapshots__/loops.0a25def1.0.snapshot +++ b/compiler/test/__snapshots__/loops.0a25def1.0.snapshot @@ -1,261 +1,164 @@ loops › loop2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$>\" (global $>_1128 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1125 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1120 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \">\" (func $>_1128 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1125 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1120 (param i32 i32 i32) (result i32))) - (global $count_1114 (mut i32) (i32.const 0)) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (block $compile_block.29 (result i32) - (block $compile_store.3 - (global.set $b_1113 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 25) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (global.set $count_1114 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 1) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.28 - (local.set $11 - (block $MFor.7 (result i32) - (drop - (loop $MFor_loop.8 - (block $MFor_loop_body.26 - (drop - (br_if $MFor.7 - (i32.const 1879048190) - (i32.eqz - (i32.shr_u - (block $compile_block.12 (result i32) - (block $compile_store.11 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (call $>_1128 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $>_1128) - ) - (local.get $10) - (i32.const 1) - ) - ) - (i32.const 31) - ) - ) - ) - ) - (block $MFor_continue.9 - (drop - (block $compile_block.25 (result i32) - (block $compile_store.14 - (local.set $6 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - (block $do_backpatches.13 - ) - ) - (block $compile_store.16 - (local.set $7 - (call $-_1120 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1120) - ) - (local.get $6) - (i32.const 3) - ) - ) - (block $do_backpatches.15 - ) - ) - (block $compile_store.19 - (local.set $12 - (block $MTupleSet.17 (result i32) - (i32.store offset=8 - (global.get $b_1113) - (tuple.extract 0 - (tuple.make - (local.get $7) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=8 - (global.get $b_1113) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.18 - ) - ) - (block $compile_store.21 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $count_1114) - ) - ) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.23 - (local.set $9 - (call $+_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1125) - ) - (local.get $8) - (i32.const 3) - ) - ) - (block $do_backpatches.22 - ) - ) - (block $MTupleSet.24 (result i32) - (i32.store offset=8 - (global.get $count_1114) - (tuple.extract 0 - (tuple.make - (local.get $9) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=8 - (global.get $count_1114) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (br $MFor_loop.8) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.27 - ) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $count_1114) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name >))) (mimp_mod pervasives.gr) (mimp_name >) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name >))) (mimp_mod pervasives.gr) (mimp_name >) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 12))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind count_1114 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MFor + ((((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCallKnown (func >_1128) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind >_1128 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))))) + () + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func -_1120) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind -_1120 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MBoxOp + (MBoxUpdate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))) + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc + (MImmBinding (MGlobalBind count_1114 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MCallKnown (func +_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1125 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MBoxOp + (MBoxUpdate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))) + ((immediate_desc + (MImmBinding (MGlobalBind count_1114 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind count_1114 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 5) (stack_size_i32 2) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name count))) (mutable_ true) (allocation_type Managed) + (initial_value ())) + ((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/loops.0fafc5f0.0.snapshot b/compiler/test/__snapshots__/loops.0fafc5f0.0.snapshot index 19a0a186d8..0458ed9122 100644 --- a/compiler/test/__snapshots__/loops.0fafc5f0.0.snapshot +++ b/compiler/test/__snapshots__/loops.0fafc5f0.0.snapshot @@ -1,186 +1,145 @@ loops › loop5 -(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)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$>=\" (global $>=_1126 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1124 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1120 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \">=\" (func $>=_1126 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1124 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1120 (param i32 i32 i32) (result i32))) - (global $count_1114 (mut i32) (i32.const 0)) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.21 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 25) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (global.set $count_1114 - (i32.const 1) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.20 - (local.set $8 - (block $MFor.5 (result i32) - (drop - (loop $MFor_loop.6 - (block $MFor_loop_body.18 - (drop - (br_if $MFor.5 - (i32.const 1879048190) - (i32.eqz - (i32.shr_u - (block $compile_block.13 (result i32) - (block $compile_store.9 - (local.set $7 - (call $-_1124 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1124) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 3) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $compile_set.10 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.11 - ) - ) - (call $>=_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $>=_1126) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 1) - ) - ) - (i32.const 31) - ) - ) - ) - ) - (block $MFor_continue.7 - (drop - (block $compile_block.17 (result i32) - (block $compile_store.15 - (local.set $6 - (call $+_1120 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1120) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $count_1114) - ) - (i32.const 3) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_set.16 (result i32) - (global.set $count_1114 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $count_1114) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (br $MFor_loop.6) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.19 - ) - ) - (global.get $count_1114) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name >=))) (mimp_mod pervasives.gr) (mimp_name >=) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name >=))) (mimp_mod pervasives.gr) (mimp_name >=) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 12))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind count_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MFor + ((((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func -_1124) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind -_1124 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MCallKnown (func >=_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind >=_1126 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))))) + () + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func +_1120) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1120 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind count_1114 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MSet (MGlobalBind count_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind count_1114 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 2) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name count))) (mutable_ true) (allocation_type Managed) + (initial_value ())) + ((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/loops.c2b7bfc6.0.snapshot b/compiler/test/__snapshots__/loops.c2b7bfc6.0.snapshot index e5fe786174..15be696501 100644 --- a/compiler/test/__snapshots__/loops.c2b7bfc6.0.snapshot +++ b/compiler/test/__snapshots__/loops.c2b7bfc6.0.snapshot @@ -1,134 +1,96 @@ loops › loop3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$>\" (global $>_1120 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1118 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \">\" (func $>_1120 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1118 (param i32 i32 i32) (result i32))) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.14 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 7) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.13 - (local.set $7 - (block $MFor.3 (result i32) - (drop - (loop $MFor_loop.4 - (block $MFor_loop_body.11 - (drop - (br_if $MFor.3 - (i32.const 1879048190) - (i32.eqz - (i32.shr_u - (block $compile_block.6 (result i32) - (call $>_1120 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $>_1120) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 1) - ) - ) - (i32.const 31) - ) - ) - ) - ) - (block $MFor_continue.5 - (drop - (block $compile_block.10 (result i32) - (block $compile_store.8 - (local.set $6 - (call $-_1118 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1118) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 3) - ) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_set.9 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (br $MFor_loop.4) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.12 - ) - ) - (global.get $b_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name >))) (mimp_mod pervasives.gr) (mimp_name >) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name >))) (mimp_mod pervasives.gr) (mimp_name >) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MFor + ((((instr_desc + (MCallKnown (func >_1120) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind >_1120 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))))) + () + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func -_1118) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind -_1118 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/loops.f1c03b79.0.snapshot b/compiler/test/__snapshots__/loops.f1c03b79.0.snapshot index b2f373ac3a..48f71e5ed1 100644 --- a/compiler/test/__snapshots__/loops.f1c03b79.0.snapshot +++ b/compiler/test/__snapshots__/loops.f1c03b79.0.snapshot @@ -1,186 +1,145 @@ loops › loop4 -(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)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$>\" (global $>_1126 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1124 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$-\" (global $-_1120 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \">\" (func $>_1126 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1124 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"-\" (func $-_1120 (param i32 i32 i32) (result i32))) - (global $count_1114 (mut i32) (i32.const 0)) - (global $b_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.21 (result i32) - (block $compile_store.2 - (global.set $b_1113 - (i32.const 25) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (global.set $count_1114 - (i32.const 1) - ) - (block $do_backpatches.3 - ) - ) - (block $compile_store.20 - (local.set $8 - (block $MFor.5 (result i32) - (drop - (loop $MFor_loop.6 - (block $MFor_loop_body.18 - (drop - (br_if $MFor.5 - (i32.const 1879048190) - (i32.eqz - (i32.shr_u - (block $compile_block.8 (result i32) - (call $>_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $>_1126) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 1) - ) - ) - (i32.const 31) - ) - ) - ) - ) - (block $MFor_continue.7 - (drop - (block $compile_block.17 (result i32) - (block $compile_store.10 - (local.set $6 - (call $-_1120 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $-_1120) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1113) - ) - (i32.const 3) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.13 - (local.set $9 - (block $compile_set.11 (result i32) - (global.set $b_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $7 - (call $+_1124 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1124) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $count_1114) - ) - (i32.const 3) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_set.16 (result i32) - (global.set $count_1114 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $count_1114) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (br $MFor_loop.6) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.19 - ) - ) - (global.get $count_1114) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name >))) (mimp_mod pervasives.gr) (mimp_name >) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name >))) (mimp_mod pervasives.gr) (mimp_name >) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name -))) (mimp_mod pervasives.gr) (mimp_name -) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 12))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind count_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MFor + ((((instr_desc + (MCallKnown (func >_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind >_1126 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))))) + () + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func -_1120) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind -_1120 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind b_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MSet (MGlobalBind b_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MCallKnown (func +_1124) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1124 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind count_1114 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MSet (MGlobalBind count_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind count_1114 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 2) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name count))) (mutable_ true) (allocation_type Managed) + (initial_value ())) + ((id ((name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/modules.52d25a2f.0.snapshot b/compiler/test/__snapshots__/modules.52d25a2f.0.snapshot index 52fc1828b4..e8a535eee4 100644 --- a/compiler/test/__snapshots__/modules.52d25a2f.0.snapshot +++ b/compiler/test/__snapshots__/modules.52d25a2f.0.snapshot @@ -1,35 +1,15 @@ modules › smallest_submodule -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 1879048190) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/optimizations.d72b00c6.0.snapshot b/compiler/test/__snapshots__/optimizations.d72b00c6.0.snapshot index b3858414a8..93029dc6c1 100644 --- a/compiler/test/__snapshots__/optimizations.d72b00c6.0.snapshot +++ b/compiler/test/__snapshots__/optimizations.d72b00c6.0.snapshot @@ -1,86 +1,53 @@ optimizations › trs1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $f1_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $f1_1113 (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i64) - (local $7 f32) - (local $8 f64) - (block $compile_block.2 (result i32) - (tuple.extract 0 - (tuple.make - (local.get $1) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $2) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.5 - (block $compile_store.4 - (global.set $f1_1113 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (return_call $f1_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $f1_1113) - ) - (i32.const 3) - (i32.const 5) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions + (((id ((stamp 1113) (name f1))) (name (f1)) + (args (Managed Managed Managed)) (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))) + (((immediate_desc (MImmBinding (MArgBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind f1_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MReturnCallKnown (func f1_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind f1_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((stamp 1113) (name f1))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1125) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/optimizations.ff6d5bfb.0.snapshot b/compiler/test/__snapshots__/optimizations.ff6d5bfb.0.snapshot index 4181471b71..e5258ee982 100644 --- a/compiler/test/__snapshots__/optimizations.ff6d5bfb.0.snapshot +++ b/compiler/test/__snapshots__/optimizations.ff6d5bfb.0.snapshot @@ -1,180 +1,90 @@ optimizations › test_dead_branch_elimination_5 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1126 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1126 (param i32 i32 i32) (result i32))) - (global $y_1114 (mut i32) (i32.const 0)) - (global $x_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.17 - (block $compile_store.3 - (global.set $x_1113 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (global.set $y_1114 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $MTupleSet.7 (result i32) - (i32.store offset=8 - (global.get $x_1113) - (tuple.extract 0 - (tuple.make - (i32.const 7) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=8 - (global.get $x_1113) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $MTupleSet.10 (result i32) - (i32.store offset=8 - (global.get $y_1114) - (tuple.extract 0 - (tuple.make - (i32.const 9) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=8 - (global.get $y_1114) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.14 - (local.set $6 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $x_1113) - ) - ) - ) - (block $do_backpatches.13 - ) - ) - (block $compile_store.16 - (local.set $7 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (global.get $y_1114) - ) - ) - ) - (block $do_backpatches.15 - ) - ) - (return_call $+_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1126) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((name +))) (mimp_mod pervasives.gr) (mimp_name +) + (mimp_type (MGlobalImport Managed true)) (mimp_kind MImportGrain) + (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MGlobalBind x_1113 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind y_1114 Managed) + ((instr_desc + (MAllocate + (MBox + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MBoxOp + (MBoxUpdate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))) + ((immediate_desc (MImmBinding (MGlobalBind x_1113 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MBoxOp + (MBoxUpdate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((immediate_desc (MImmBinding (MGlobalBind y_1114 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind x_1113 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MBoxOp MBoxUnbox + ((immediate_desc (MImmBinding (MGlobalBind y_1114 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MReturnCallKnown (func +_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1126 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 2) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((name y))) (mutable_ true) (allocation_type Managed) + (initial_value ())) + ((id ((name x))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.0539d13e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.0539d13e.0.snapshot index f768a3ae70..243cb6ca80 100644 --- a/compiler/test/__snapshots__/pattern_matching.0539d13e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.0539d13e.0.snapshot @@ -1,230 +1,120 @@ pattern matching › record_match_3 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1125 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1125 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (block $compile_block.19 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (i32.const 13) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $6) - ) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $6) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $cleanup.12 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (drop - (block $compile_set.13 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.14 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.16_outer (result i32) - (block $switch.16_branch_0 (result i32) - (drop - (block $switch.16_branch_1 (result i32) - (drop - (block $switch.16_default (result i32) - (br_table $switch.16_branch_1 $switch.16_default $switch.16_default - (i32.const 0) - (i32.shr_s - (i32.const 1) - (i32.const 1) - ) - ) - ) - ) - (br $switch.16_outer - (block $compile_block.18 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.16_outer - (block $compile_block.17 - (return_call $+_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1125) - ) - (local.get $7) - (local.get $8) - ) - ) - ) - ) - ) - (block $cleanup.15 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 643 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1125) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1125) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))) + ((baz) + ((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MRecordOp (MRecordGet 1) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((0 + (((instr_desc + (MReturnCallKnown (func +_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1125 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 5) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1126) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.05b60a1e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.05b60a1e.0.snapshot index b0da5a7ecf..922deb732a 100644 --- a/compiler/test/__snapshots__/pattern_matching.05b60a1e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.05b60a1e.0.snapshot @@ -1,351 +1,169 @@ pattern matching › adt_match_deep -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (block $compile_block.36 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1047233621) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 11) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $12 - (i32.load offset=12 - (local.get $8) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $13 - (i32.or - (i32.shl - (i32.eq - (local.get $12) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.29 - (local.set $14 - (if (result i32) - (i32.shr_u - (local.get $13) - (i32.const 31) - ) - (block $compile_block.22 (result i32) - (block $compile_store.17 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $8) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.19 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $10) - ) - ) - ) - (block $do_backpatches.18 - ) - ) - (block $cleanup.20 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - (drop - (block $compile_set.21 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 3) - ) - (block $compile_block.27 (result i32) - (block $compile_store.24 - (local.set $15 - (i32.or - (i32.shl - (i32.eq - (local.get $12) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.23 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $15) - (i32.const 31) - ) - (block $compile_block.25 (result i32) - (i32.const 1) - ) - (block $compile_block.26 - (unreachable) - ) - ) - ) - ) - ) - (block $do_backpatches.28 - ) - ) - (block $cleanup.30 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.32_outer (result i32) - (block $switch.32_branch_0 (result i32) - (drop - (block $switch.32_branch_1 (result i32) - (drop - (block $switch.32_branch_2 (result i32) - (drop - (block $switch.32_default (result i32) - (br_table $switch.32_branch_1 $switch.32_branch_2 $switch.32_default $switch.32_default - (i32.const 0) - (i32.shr_s - (local.get $14) - (i32.const 1) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.35 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.34 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.33 (result i32) - (i32.const 1999) - ) - ) - ) - ) - (block $cleanup.31 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 486 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 523616810))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 999))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 6) (stack_size_i32 4) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1130) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot b/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot index 4c38937f6d..50913ffc17 100644 --- a/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.0ad4ac05.0.snapshot @@ -1,1260 +1,793 @@ pattern matching › tuple_match_deep4 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1153 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1153 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (local $23 i32) - (local $24 i32) - (local $25 i32) - (local $26 i32) - (local $27 i32) - (local $28 i32) - (local $29 i32) - (local $30 i32) - (local $31 i32) - (local $32 i32) - (local $33 i32) - (local $34 i32) - (local $35 i32) - (local $36 i32) - (local $37 i32) - (local $38 i32) - (local $39 i32) - (local $40 i32) - (local $41 i32) - (block $compile_block.117 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_tuple.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.17 - (local.set $12 - (i32.const 0) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.19 - (local.set $13 - (i32.const 0) - ) - (block $do_backpatches.18 - ) - ) - (block $compile_store.21 - (local.set $14 - (i32.const 0) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.23 - (local.set $15 - (i32.const 0) - ) - (block $do_backpatches.22 - ) - ) - (block $compile_store.25 - (local.set $16 - (i32.const 0) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.27 - (local.set $17 - (i32.const 0) - ) - (block $do_backpatches.26 - ) - ) - (block $compile_store.29 - (local.set $18 - (i32.const 0) - ) - (block $do_backpatches.28 - ) - ) - (block $compile_store.31 - (local.set $19 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $8) - ) - ) - ) - (block $do_backpatches.30 - ) - ) - (block $compile_store.33 - (local.set $20 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $8) - ) - ) - ) - (block $do_backpatches.32 - ) - ) - (block $cleanup.34 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - (block $compile_store.36 - (local.set $30 - (i32.load offset=12 - (local.get $20) - ) - ) - (block $do_backpatches.35 - ) - ) - (block $compile_store.38 - (local.set $31 - (i32.or - (i32.shl - (i32.eq - (local.get $30) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.37 - ) - ) - (block $compile_store.98 - (local.set $32 - (if (result i32) - (i32.shr_u - (local.get $31) - (i32.const 31) - ) - (block $compile_block.90 (result i32) - (block $compile_store.40 - (local.set $21 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $20) - ) - ) - ) - (block $do_backpatches.39 - ) - ) - (block $compile_store.42 - (local.set $22 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $20) - ) - ) - ) - (block $do_backpatches.41 - ) - ) - (block $compile_store.44 - (local.set $34 - (i32.load offset=12 - (local.get $22) - ) - ) - (block $do_backpatches.43 - ) - ) - (block $compile_store.46 - (local.set $35 - (i32.or - (i32.shl - (i32.eq - (local.get $34) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.45 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $35) - (i32.const 31) - ) - (block $compile_block.82 (result i32) - (block $compile_store.49 - (local.set $23 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $22) - ) - ) - ) - (block $do_backpatches.48 - ) - ) - (block $compile_store.51 - (local.set $24 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $22) - ) - ) - ) - (block $do_backpatches.50 - ) - ) - (block $compile_store.53 - (local.set $37 - (i32.load offset=12 - (local.get $24) - ) - ) - (block $do_backpatches.52 - ) - ) - (block $compile_store.55 - (local.set $38 - (i32.or - (i32.shl - (i32.eq - (local.get $37) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.54 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $38) - (i32.const 31) - ) - (block $compile_block.73 (result i32) - (block $compile_store.58 - (local.set $25 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $24) - ) - ) - ) - (block $do_backpatches.57 - ) - ) - (block $compile_store.60 - (local.set $26 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $24) - ) - ) - ) - (block $do_backpatches.59 - ) - ) - (block $compile_store.62 - (local.set $40 - (i32.load offset=12 - (local.get $26) - ) - ) - (block $do_backpatches.61 - ) - ) - (block $cleanup.63 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $26) - ) - ) - ) - (block $compile_store.65 - (local.set $41 - (i32.or - (i32.shl - (i32.eq - (local.get $40) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.64 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $41) - (i32.const 31) - ) - (block $compile_block.71 (result i32) - (drop - (block $compile_set.67 (result i32) - (local.set $15 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $19) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.68 (result i32) - (local.set $16 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $21) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.69 (result i32) - (local.set $17 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $23) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.70 (result i32) - (local.set $18 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $25) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 7) - ) - (block $compile_block.72 (result i32) - (i32.const 9) - ) - ) - (block $cleanup.66 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $25) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.81 (result i32) - (block $compile_store.75 - (local.set $39 - (i32.or - (i32.shl - (i32.eq - (local.get $37) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.74 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $39) - (i32.const 31) - ) - (block $compile_block.79 (result i32) - (drop - (block $compile_set.76 (result i32) - (local.set $12 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $19) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.77 (result i32) - (local.set $13 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $21) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.78 (result i32) - (local.set $14 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $23) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 5) - ) - (block $compile_block.80 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.56 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $23) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $24) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.89 (result i32) - (block $compile_store.84 - (local.set $36 - (i32.or - (i32.shl - (i32.eq - (local.get $34) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.83 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $36) - (i32.const 31) - ) - (block $compile_block.87 (result i32) - (drop - (block $compile_set.85 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $19) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.86 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $21) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 3) - ) - (block $compile_block.88 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.47 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $21) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $22) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.96 (result i32) - (block $compile_store.92 - (local.set $33 - (i32.or - (i32.shl - (i32.eq - (local.get $30) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.91 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $33) - (i32.const 31) - ) - (block $compile_block.94 (result i32) - (drop - (block $compile_set.93 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $19) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.95 - (unreachable) - ) - ) - ) - ) - ) - (block $do_backpatches.97 - ) - ) - (block $cleanup.99 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.101_outer (result i32) - (block $switch.101_branch_0 (result i32) - (drop - (block $switch.101_branch_1 (result i32) - (drop - (block $switch.101_branch_2 (result i32) - (drop - (block $switch.101_branch_3 (result i32) - (drop - (block $switch.101_branch_4 (result i32) - (drop - (block $switch.101_branch_5 (result i32) - (drop - (block $switch.101_default (result i32) - (br_table $switch.101_branch_1 $switch.101_branch_2 $switch.101_branch_3 $switch.101_branch_4 $switch.101_branch_5 $switch.101_default $switch.101_default - (i32.const 0) - (i32.shr_s - (local.get $32) - (i32.const 1) - ) - ) - ) - ) - (br $switch.101_outer - (block $compile_block.116 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.101_outer - (block $compile_block.115 (result i32) - (i32.const 1999) - ) - ) - ) - ) - (br $switch.101_outer - (block $compile_block.114 - (block $compile_store.110 - (local.set $28 - (call $+_1153 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1153) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $16) - ) - ) - ) - (block $do_backpatches.109 - ) - ) - (block $compile_store.112 - (local.set $29 - (call $+_1153 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1153) - ) - (local.get $28) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $17) - ) - ) - ) - (block $do_backpatches.111 - ) - ) - (block $cleanup.113 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - ) - (return_call $+_1153 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1153) - ) - (local.get $29) - (local.get $18) - ) - ) - ) - ) - ) - (br $switch.101_outer - (block $compile_block.108 - (block $compile_store.106 - (local.set $27 - (call $+_1153 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1153) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - ) - ) - (block $do_backpatches.105 - ) - ) - (block $cleanup.107 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - ) - (return_call $+_1153 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1153) - ) - (local.get $27) - (local.get $14) - ) - ) - ) - ) - ) - (br $switch.101_outer - (block $compile_block.104 - (block $cleanup.103 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - ) - (return_call $+_1153 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1153) - ) - (local.get $10) - (local.get $11) - ) - ) - ) - ) - ) - (br $switch.101_outer - (block $compile_block.102 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - ) - ) - ) - ) - (block $cleanup.100 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1153) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1153) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 13 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 14 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 15 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 16 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 17 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 18 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 8 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 19 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 20 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses + ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 20 Managed))) + (immediate_analyses + ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc + (MImmBinding (MLocalBind 20 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 11 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 10 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 11 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 13 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 15 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 11 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 17 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 12 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 19 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 3))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses + ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 9 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 9 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 13 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 15 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 17 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 2))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1153) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1153 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (2 + (((instr_desc + (MStore + (((MLocalBind 21 Managed) + ((instr_desc + (MCallKnown (func +_1153) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1153 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1153) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1153 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 21 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (3 + (((instr_desc + (MStore + (((MLocalBind 22 Managed) + ((instr_desc + (MCallKnown (func +_1153) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1153 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 23 Managed) + ((instr_desc + (MCallKnown (func +_1153) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1153 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 22 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1153) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1153 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 23 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (4 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 999))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 24) (stack_size_i32 12) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1158) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot index 19bd2aa073..b1c73a12e6 100644 --- a/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.0bb6923e.0.snapshot @@ -1,981 +1,607 @@ pattern matching › adt_match_4 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1149 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1149 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (local $23 i32) - (local $24 i32) - (local $25 i32) - (local $26 i32) - (local $27 i32) - (local $28 i32) - (local $29 i32) - (local $30 i32) - (local $31 i32) - (local $32 i32) - (local $33 i32) - (local $34 i32) - (block $compile_block.98 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 13) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_adt.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=24 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.14 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.13 - ) - ) - (block $compile_store.16 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.15 - ) - ) - (block $compile_store.18 - (local.set $12 - (i32.const 0) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.20 - (local.set $13 - (i32.const 0) - ) - (block $do_backpatches.19 - ) - ) - (block $compile_store.22 - (local.set $14 - (i32.const 0) - ) - (block $do_backpatches.21 - ) - ) - (block $compile_store.24 - (local.set $15 - (i32.const 0) - ) - (block $do_backpatches.23 - ) - ) - (block $compile_store.26 - (local.set $23 - (i32.load offset=12 - (local.get $9) - ) - ) - (block $do_backpatches.25 - ) - ) - (block $compile_store.28 - (local.set $24 - (i32.or - (i32.shl - (i32.eq - (local.get $23) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.27 - ) - ) - (block $compile_store.84 - (local.set $25 - (if (result i32) - (i32.shr_u - (local.get $24) - (i32.const 31) - ) - (block $compile_block.77 (result i32) - (block $compile_store.30 - (local.set $16 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $9) - ) - ) - ) - (block $do_backpatches.29 - ) - ) - (block $compile_store.32 - (local.set $17 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $9) - ) - ) - ) - (block $do_backpatches.31 - ) - ) - (block $compile_store.34 - (local.set $27 - (i32.load offset=12 - (local.get $17) - ) - ) - (block $do_backpatches.33 - ) - ) - (block $compile_store.36 - (local.set $28 - (i32.or - (i32.shl - (i32.eq - (local.get $27) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.35 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $28) - (i32.const 31) - ) - (block $compile_block.70 (result i32) - (block $compile_store.39 - (local.set $18 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $17) - ) - ) - ) - (block $do_backpatches.38 - ) - ) - (block $compile_store.41 - (local.set $19 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $17) - ) - ) - ) - (block $do_backpatches.40 - ) - ) - (block $compile_store.43 - (local.set $30 - (i32.load offset=12 - (local.get $19) - ) - ) - (block $do_backpatches.42 - ) - ) - (block $compile_store.45 - (local.set $31 - (i32.or - (i32.shl - (i32.eq - (local.get $30) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.44 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $31) - (i32.const 31) - ) - (block $compile_block.62 (result i32) - (block $compile_store.48 - (local.set $20 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $19) - ) - ) - ) - (block $do_backpatches.47 - ) - ) - (block $compile_store.50 - (local.set $21 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $19) - ) - ) - ) - (block $do_backpatches.49 - ) - ) - (block $compile_store.52 - (local.set $33 - (i32.load offset=12 - (local.get $21) - ) - ) - (block $do_backpatches.51 - ) - ) - (block $cleanup.53 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $21) - ) - ) - ) - (block $compile_store.55 - (local.set $34 - (i32.or - (i32.shl - (i32.eq - (local.get $33) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.54 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $34) - (i32.const 31) - ) - (block $compile_block.60 (result i32) - (drop - (block $compile_set.57 (result i32) - (local.set $13 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $16) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.58 (result i32) - (local.set $14 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $18) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.59 (result i32) - (local.set $15 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $20) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 7) - ) - (block $compile_block.61 (result i32) - (i32.const 9) - ) - ) - (block $cleanup.56 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.69 (result i32) - (block $compile_store.64 - (local.set $32 - (i32.or - (i32.shl - (i32.eq - (local.get $30) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.63 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $32) - (i32.const 31) - ) - (block $compile_block.67 (result i32) - (drop - (block $compile_set.65 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $16) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.66 (result i32) - (local.set $12 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $18) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 5) - ) - (block $compile_block.68 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.46 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.76 (result i32) - (block $compile_store.72 - (local.set $29 - (i32.or - (i32.shl - (i32.eq - (local.get $27) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.71 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $29) - (i32.const 31) - ) - (block $compile_block.74 (result i32) - (drop - (block $compile_set.73 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $16) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 3) - ) - (block $compile_block.75 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.37 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.82 (result i32) - (block $compile_store.79 - (local.set $26 - (i32.or - (i32.shl - (i32.eq - (local.get $23) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.78 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $26) - (i32.const 31) - ) - (block $compile_block.80 (result i32) - (i32.const 1) - ) - (block $compile_block.81 - (unreachable) - ) - ) - ) - ) - ) - (block $do_backpatches.83 - ) - ) - (block $cleanup.85 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.87_outer (result i32) - (block $switch.87_branch_0 (result i32) - (drop - (block $switch.87_branch_1 (result i32) - (drop - (block $switch.87_branch_2 (result i32) - (drop - (block $switch.87_branch_3 (result i32) - (drop - (block $switch.87_branch_4 (result i32) - (drop - (block $switch.87_branch_5 (result i32) - (drop - (block $switch.87_default (result i32) - (br_table $switch.87_branch_1 $switch.87_branch_2 $switch.87_branch_3 $switch.87_branch_4 $switch.87_branch_5 $switch.87_default $switch.87_default - (i32.const 0) - (i32.shr_s - (local.get $25) - (i32.const 1) - ) - ) - ) - ) - (br $switch.87_outer - (block $compile_block.97 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.87_outer - (block $compile_block.96 (result i32) - (i32.const 1999) - ) - ) - ) - ) - (br $switch.87_outer - (block $compile_block.95 - (block $compile_store.93 - (local.set $22 - (call $+_1149 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1149) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $14) - ) - ) - ) - (block $do_backpatches.92 - ) - ) - (block $cleanup.94 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - (return_call $+_1149 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1149) - ) - (local.get $22) - (local.get $15) - ) - ) - ) - ) - ) - (br $switch.87_outer - (block $compile_block.91 - (block $cleanup.90 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - ) - (return_call $+_1149 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1149) - ) - (local.get $11) - (local.get $12) - ) - ) - ) - ) - ) - (br $switch.87_outer - (block $compile_block.89 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - ) - ) - ) - ) - (br $switch.87_outer - (block $compile_block.88 (result i32) - (i32.const 1) - ) - ) - ) - ) - (block $cleanup.86 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1149) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1149) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 13 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 8 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 14 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 15 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses + ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses + ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc + (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 11 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 10 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 11 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 10 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 12 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 14 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 3))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses + ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 9 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 9 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 10 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 12 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 2))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1149) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1149 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (3 + (((instr_desc + (MStore + (((MLocalBind 16 Managed) + ((instr_desc + (MCallKnown (func +_1149) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1149 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1149) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1149 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (4 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 999))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 17) (stack_size_i32 12) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1152) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.0fa61137.0.snapshot b/compiler/test/__snapshots__/pattern_matching.0fa61137.0.snapshot index 5ca2c3fa14..f5d9a897da 100644 --- a/compiler/test/__snapshots__/pattern_matching.0fa61137.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.0fa61137.0.snapshot @@ -1,242 +1,169 @@ pattern matching › low_level_constant_match_2 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1116 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1116 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (block $compile_block.28 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (select - (i32.const -2) - (i32.const 2147483646) - (i64.eq - (i64.const 1) - (i64.const 0) - ) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.17 - (local.set $8 - (if (result i32) - (i32.shr_u - (local.get $7) - (i32.const 31) - ) - (block $compile_block.6 (result i32) - (i32.const 1) - ) - (block $compile_block.15 (result i32) - (block $compile_store.8 - (local.set $9 - (select - (i32.const -2) - (i32.const 2147483646) - (i64.eq - (i64.const 1) - (i64.const 1) - ) - ) - ) - (block $do_backpatches.7 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $9) - (i32.const 31) - ) - (block $compile_block.9 (result i32) - (i32.const 3) - ) - (block $compile_block.14 (result i32) - (block $compile_store.11 - (local.set $10 - (select - (i32.const -2) - (i32.const 2147483646) - (i64.eq - (i64.const 1) - (i64.const 2) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $10) - (i32.const 31) - ) - (block $compile_block.12 (result i32) - (i32.const 5) - ) - (block $compile_block.13 (result i32) - (i32.const 7) - ) - ) - ) - ) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.25 - (local.set $11 - (block $switch.18_outer (result i32) - (block $switch.18_branch_0 (result i32) - (drop - (block $switch.18_branch_1 (result i32) - (drop - (block $switch.18_branch_2 (result i32) - (drop - (block $switch.18_branch_3 (result i32) - (drop - (block $switch.18_branch_4 (result i32) - (drop - (block $switch.18_default (result i32) - (br_table $switch.18_branch_1 $switch.18_branch_2 $switch.18_branch_3 $switch.18_branch_4 $switch.18_default $switch.18_default - (i32.const 0) - (i32.shr_s - (local.get $8) - (i32.const 1) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.23 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.22 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.21 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.20 (result i32) - (i32.const -2) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.19 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.27 - (local.set $12 - (call $print_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1116) - ) - (local.get $11) - (local.get $6) - ) - ) - (block $do_backpatches.26 - ) - ) - (i32.const 1) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1116) (name print))) (mimp_mod pervasives.gr) + (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1116) (name print))) (mimp_mod pervasives.gr) + (mimp_name print) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 + (WasmBinaryI64 (wasm_op Op_eq_int64) + (arg_types (Wasm_int64 Wasm_int64)) (ret_type Grain_bool)) + ((immediate_desc (MImmConst (MConstLiteral (MConstI64 1)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstLiteral (MConstI64 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 + (WasmBinaryI64 (wasm_op Op_eq_int64) + (arg_types (Wasm_int64 Wasm_int64)) + (ret_type Grain_bool)) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI64 1)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI64 1)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 + (WasmBinaryI64 (wasm_op Op_eq_int64) + (arg_types (Wasm_int64 Wasm_int64)) + (ret_type Grain_bool)) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI64 1)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI64 2)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MSwitch + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (3 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + (Unmanaged WasmI32))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func print_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type + (((Unmanaged WasmI32) Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 6) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1125) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.14dc7554.0.snapshot b/compiler/test/__snapshots__/pattern_matching.14dc7554.0.snapshot index ccb644d83e..8b35e89f4a 100644 --- a/compiler/test/__snapshots__/pattern_matching.14dc7554.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.14dc7554.0.snapshot @@ -1,204 +1,80 @@ pattern matching › record_match_2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.17 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $7) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $cleanup.11 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (drop - (block $compile_set.12 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.14_outer (result i32) - (block $switch.14_branch_0 (result i32) - (drop - (block $switch.14_branch_1 (result i32) - (drop - (block $switch.14_default (result i32) - (br_table $switch.14_branch_1 $switch.14_default $switch.14_default - (i32.const 0) - (i32.shr_s - (i32.const 1) - (i32.const 1) - ) - ) - ) - ) - (br $switch.14_outer - (block $compile_block.16 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.14_outer - (block $compile_block.15 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - ) - ) - ) - ) - (block $cleanup.13 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 643 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MRecordOp (MRecordGet 1) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 4) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1124) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.16cd197e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.16cd197e.0.snapshot index e305b50368..6d3d3abc3b 100644 --- a/compiler/test/__snapshots__/pattern_matching.16cd197e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.16cd197e.0.snapshot @@ -1,177 +1,68 @@ pattern matching › constant_match_3 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"GRAIN$EXPORT$equal\" (global $GRAIN$EXPORT$equal_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"equal\" (func $equal_0 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.18 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_string.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $8 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (local.get $6) - (local.get $7) - ) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.12 - (local.set $9 - (if (result i32) - (i32.shr_u - (local.get $8) - (i32.const 31) - ) - (block $compile_block.9 (result i32) - (i32.const 3) - ) - (block $compile_block.10 (result i32) - (i32.const 5) - ) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $switch.13_outer (result i32) - (block $switch.13_branch_0 (result i32) - (drop - (block $switch.13_branch_1 (result i32) - (drop - (block $switch.13_branch_2 (result i32) - (drop - (block $switch.13_branch_3 (result i32) - (drop - (block $switch.13_default (result i32) - (br_table $switch.13_branch_1 $switch.13_branch_2 $switch.13_branch_3 $switch.13_default $switch.13_default - (i32.const 0) - (i32.shr_s - (local.get $9) - (i32.const 1) - ) - ) - ) - ) - (br $switch.13_outer - (block $compile_block.17 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.13_outer - (block $compile_block.16 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.13_outer - (block $compile_block.15 (result i32) - (i32.const -2) - ) - ) - ) - ) - (br $switch.13_outer - (block $compile_block.14 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString foo))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) ((instr_desc (MAllocate (MString foo))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + ((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + (Unmanaged WasmI32)))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 2) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1118) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.16eb3dbf.0.snapshot b/compiler/test/__snapshots__/pattern_matching.16eb3dbf.0.snapshot index 18b26529ab..beec7668a6 100644 --- a/compiler/test/__snapshots__/pattern_matching.16eb3dbf.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.16eb3dbf.0.snapshot @@ -1,402 +1,222 @@ pattern matching › guarded_match_2 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1125 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1125 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (block $compile_block.35 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $6) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $6) - ) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $6) - ) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $cleanup.16 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (drop - (block $compile_set.17 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.18 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.19 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.21 - (local.set $13 - (call $==_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1125) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (i32.const 3) - ) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.28 - (local.set $14 - (if (result i32) - (i32.shr_u - (local.get $13) - (i32.const 31) - ) - (block $compile_block.25 (result i32) - (drop - (block $compile_set.22 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.23 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.24 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.26 (result i32) - (i32.const 3) - ) - ) - ) - (block $do_backpatches.27 - ) - ) - (block $cleanup.29 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.31_outer (result i32) - (block $switch.31_branch_0 (result i32) - (drop - (block $switch.31_branch_1 (result i32) - (drop - (block $switch.31_branch_2 (result i32) - (drop - (block $switch.31_default (result i32) - (br_table $switch.31_branch_1 $switch.31_branch_2 $switch.31_default $switch.31_default - (i32.const 0) - (i32.shr_s - (local.get $14) - (i32.const 1) - ) - ) - ) - ) - (br $switch.31_outer - (block $compile_block.34 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.31_outer - (block $compile_block.33 (result i32) - (i32.const 199) - ) - ) - ) - ) - (br $switch.31_outer - (block $compile_block.32 (result i32) - (i32.const 85) - ) - ) - ) - ) - (block $cleanup.30 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1125) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1125) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func ==_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind ==_1125 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 42))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 99))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 7) (stack_size_i32 2) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1130) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.25930935.0.snapshot b/compiler/test/__snapshots__/pattern_matching.25930935.0.snapshot index 49b0de7576..d419e0314d 100644 --- a/compiler/test/__snapshots__/pattern_matching.25930935.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.25930935.0.snapshot @@ -1,242 +1,174 @@ pattern matching › low_level_constant_match_3 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1116 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1116 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (block $compile_block.28 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (select - (i32.const -2) - (i32.const 2147483646) - (f32.eq - (f32.const 1) - (f32.const 0) - ) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.17 - (local.set $8 - (if (result i32) - (i32.shr_u - (local.get $7) - (i32.const 31) - ) - (block $compile_block.6 (result i32) - (i32.const 1) - ) - (block $compile_block.15 (result i32) - (block $compile_store.8 - (local.set $9 - (select - (i32.const -2) - (i32.const 2147483646) - (f32.eq - (f32.const 1) - (f32.const 1) - ) - ) - ) - (block $do_backpatches.7 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $9) - (i32.const 31) - ) - (block $compile_block.9 (result i32) - (i32.const 3) - ) - (block $compile_block.14 (result i32) - (block $compile_store.11 - (local.set $10 - (select - (i32.const -2) - (i32.const 2147483646) - (f32.eq - (f32.const 1) - (f32.const 2) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $10) - (i32.const 31) - ) - (block $compile_block.12 (result i32) - (i32.const 5) - ) - (block $compile_block.13 (result i32) - (i32.const 7) - ) - ) - ) - ) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.25 - (local.set $11 - (block $switch.18_outer (result i32) - (block $switch.18_branch_0 (result i32) - (drop - (block $switch.18_branch_1 (result i32) - (drop - (block $switch.18_branch_2 (result i32) - (drop - (block $switch.18_branch_3 (result i32) - (drop - (block $switch.18_branch_4 (result i32) - (drop - (block $switch.18_default (result i32) - (br_table $switch.18_branch_1 $switch.18_branch_2 $switch.18_branch_3 $switch.18_branch_4 $switch.18_default $switch.18_default - (i32.const 0) - (i32.shr_s - (local.get $8) - (i32.const 1) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.23 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.22 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.21 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.20 (result i32) - (i32.const -2) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.19 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.27 - (local.set $12 - (call $print_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1116) - ) - (local.get $11) - (local.get $6) - ) - ) - (block $do_backpatches.26 - ) - ) - (i32.const 1) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1116) (name print))) (mimp_mod pervasives.gr) + (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1116) (name print))) (mimp_mod pervasives.gr) + (mimp_name print) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 + (WasmBinaryF32 (wasm_op Op_eq_float32) + (arg_types (Wasm_float32 Wasm_float32)) (ret_type Grain_bool)) + ((immediate_desc + (MImmConst (MConstLiteral (MConstF32 4607182418800017408)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstLiteral (MConstF32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 + (WasmBinaryF32 (wasm_op Op_eq_float32) + (arg_types (Wasm_float32 Wasm_float32)) + (ret_type Grain_bool)) + ((immediate_desc + (MImmConst + (MConstLiteral (MConstF32 4607182418800017408)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst + (MConstLiteral (MConstF32 4607182418800017408)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 + (WasmBinaryF32 (wasm_op Op_eq_float32) + (arg_types (Wasm_float32 Wasm_float32)) + (ret_type Grain_bool)) + ((immediate_desc + (MImmConst + (MConstLiteral (MConstF32 4607182418800017408)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst + (MConstLiteral (MConstF32 4611686018427387904)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MSwitch + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (3 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + (Unmanaged WasmI32))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func print_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type + (((Unmanaged WasmI32) Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 6) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1125) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.3722b060.0.snapshot b/compiler/test/__snapshots__/pattern_matching.3722b060.0.snapshot index 685a2a8748..f9157ffaaa 100644 --- a/compiler/test/__snapshots__/pattern_matching.3722b060.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.3722b060.0.snapshot @@ -1,425 +1,239 @@ pattern matching › tuple_match_deep -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1131 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1131 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (block $compile_block.40 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 11) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (local.get $6) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.14 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.13 - ) - ) - (block $compile_store.16 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $7) - ) - ) - ) - (block $do_backpatches.15 - ) - ) - (block $compile_store.18 - (local.set $13 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $7) - ) - ) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.20 - (local.set $14 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $7) - ) - ) - ) - (block $do_backpatches.19 - ) - ) - (block $cleanup.21 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (block $compile_store.23 - (local.set $15 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $13) - ) - ) - ) - (block $do_backpatches.22 - ) - ) - (block $compile_store.25 - (local.set $16 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $13) - ) - ) - ) - (block $do_backpatches.24 - ) - ) - (block $cleanup.26 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - (drop - (block $compile_set.27 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $14) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.28 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.29 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $16) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.30 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.32_outer (result i32) - (block $switch.32_branch_0 (result i32) - (drop - (block $switch.32_branch_1 (result i32) - (drop - (block $switch.32_default (result i32) - (br_table $switch.32_branch_1 $switch.32_default $switch.32_default - (i32.const 0) - (i32.shr_s - (i32.const 1) - (i32.const 1) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.39 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.38 - (block $compile_store.34 - (local.set $17 - (call $+_1131 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1131) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - ) - (block $do_backpatches.33 - ) - ) - (block $compile_store.36 - (local.set $18 - (call $+_1131 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1131) - ) - (local.get $17) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - ) - ) - (block $do_backpatches.35 - ) - ) - (block $cleanup.37 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - (return_call $+_1131 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1131) - ) - (local.get $18) - (local.get $10) - ) - ) - ) - ) - ) - (block $cleanup.31 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1131) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1131) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((0 + (((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MCallKnown (func +_1131) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1131 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MCallKnown (func +_1131) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1131 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1131) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1131 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 13) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1134) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.46f91987.0.snapshot b/compiler/test/__snapshots__/pattern_matching.46f91987.0.snapshot index 2ab39508f5..ffab51a22c 100644 --- a/compiler/test/__snapshots__/pattern_matching.46f91987.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.46f91987.0.snapshot @@ -1,204 +1,80 @@ pattern matching › record_match_1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.17 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $7) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $cleanup.11 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (drop - (block $compile_set.12 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.14_outer (result i32) - (block $switch.14_branch_0 (result i32) - (drop - (block $switch.14_branch_1 (result i32) - (drop - (block $switch.14_default (result i32) - (br_table $switch.14_branch_1 $switch.14_default $switch.14_default - (i32.const 0) - (i32.shr_s - (i32.const 1) - (i32.const 1) - ) - ) - ) - ) - (br $switch.14_outer - (block $compile_block.16 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.14_outer - (block $compile_block.15 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - ) - ) - ) - ) - (block $cleanup.13 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 643 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 4) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1124) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.5b158103.0.snapshot b/compiler/test/__snapshots__/pattern_matching.5b158103.0.snapshot index 3731854f3d..c31fe71698 100644 --- a/compiler/test/__snapshots__/pattern_matching.5b158103.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.5b158103.0.snapshot @@ -1,462 +1,233 @@ pattern matching › constant_match_2 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"GRAIN$EXPORT$equal\" (global $GRAIN$EXPORT$equal_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"equal\" (func $equal_0 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (block $compile_block.53 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (local.get $6) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2147483646) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $7) - ) - ) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $7) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $7) - ) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $cleanup.13 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (block $compile_store.16 - (local.set $11 - (block $allocate_string.14 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7496034) - ) - (local.get $0) - ) - ) - (block $do_backpatches.15 - ) - ) - (block $compile_store.18 - (local.set $13 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - (local.get $11) - ) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.45 - (local.set $14 - (if (result i32) - (i32.shr_u - (local.get $13) - (i32.const 31) - ) - (block $compile_block.27 (result i32) - (block $compile_store.20 - (local.set $18 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (i32.const 11) - ) - ) - (block $do_backpatches.19 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $18) - (i32.const 31) - ) - (block $compile_block.25 (result i32) - (block $compile_store.22 - (local.set $19 - (i32.or - (i32.shl - (i32.eq - (local.get $10) - (i32.const 2147483646) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.21 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $19) - (i32.const 31) - ) - (block $compile_block.23 (result i32) - (i32.const 1) - ) - (block $compile_block.24 (result i32) - (i32.const 7) - ) - ) - ) - (block $compile_block.26 (result i32) - (i32.const 7) - ) - ) - ) - (block $compile_block.43 (result i32) - (block $compile_store.30 - (local.set $12 - (block $allocate_string.28 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - (block $do_backpatches.29 - ) - ) - (block $compile_store.32 - (local.set $15 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - (local.get $12) - ) - ) - (block $do_backpatches.31 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $15) - (i32.const 31) - ) - (block $compile_block.41 (result i32) - (block $compile_store.34 - (local.set $16 - (i32.or - (i32.shl - (i32.eq - (local.get $10) - (i32.const 2147483646) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.33 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $16) - (i32.const 31) - ) - (block $compile_block.35 (result i32) - (i32.const 5) - ) - (block $compile_block.40 (result i32) - (block $compile_store.37 - (local.set $17 - (i32.or - (i32.shl - (i32.eq - (local.get $10) - (i32.const -2) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.36 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $17) - (i32.const 31) - ) - (block $compile_block.38 (result i32) - (i32.const 3) - ) - (block $compile_block.39 (result i32) - (i32.const 7) - ) - ) - ) - ) - ) - (block $compile_block.42 (result i32) - (i32.const 7) - ) - ) - ) - ) - ) - (block $do_backpatches.44 - ) - ) - (block $cleanup.46 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - (block $switch.47_outer (result i32) - (block $switch.47_branch_0 (result i32) - (drop - (block $switch.47_branch_1 (result i32) - (drop - (block $switch.47_branch_2 (result i32) - (drop - (block $switch.47_branch_3 (result i32) - (drop - (block $switch.47_branch_4 (result i32) - (drop - (block $switch.47_default (result i32) - (br_table $switch.47_branch_1 $switch.47_branch_2 $switch.47_branch_3 $switch.47_branch_4 $switch.47_default $switch.47_default - (i32.const 0) - (i32.shr_s - (local.get $14) - (i32.const 1) - ) - ) - ) - ) - (br $switch.47_outer - (block $compile_block.52 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.47_outer - (block $compile_block.51 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.47_outer - (block $compile_block.50 (result i32) - (i32.const -2) - ) - ) - ) - ) - (br $switch.47_outer - (block $compile_block.49 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.47_outer - (block $compile_block.48 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString foo))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) ((instr_desc (MAllocate (MString bar))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst + (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc (MAllocate (MString foo))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst + (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (3 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + (Unmanaged WasmI32)))))) + (main_body_stack_size + ((stack_size_ptr 7) (stack_size_i32 7) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1134) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.5b6ff2d3.0.snapshot b/compiler/test/__snapshots__/pattern_matching.5b6ff2d3.0.snapshot index 39d17adb63..e18d5086cd 100644 --- a/compiler/test/__snapshots__/pattern_matching.5b6ff2d3.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.5b6ff2d3.0.snapshot @@ -1,481 +1,286 @@ pattern matching › alias_match_5 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"GRAIN$EXPORT$equal\" (global $GRAIN$EXPORT$equal_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"equal\" (func $equal_0 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (block $compile_block.47 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (local.set $10 - (i32.load offset=12 - (local.get $6) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $11 - (i32.or - (i32.shl - (i32.eq - (local.get $10) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.38 - (local.set $12 - (if (result i32) - (i32.shr_u - (local.get $11) - (i32.const 31) - ) - (block $compile_block.13 (result i32) - (drop - (block $compile_set.12 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 3) - ) - (block $compile_block.36 (result i32) - (block $compile_store.15 - (local.set $13 - (i32.or - (i32.shl - (i32.eq - (local.get $10) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.14 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $13) - (i32.const 31) - ) - (block $compile_block.34 (result i32) - (block $compile_store.17 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $6) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.19 - (local.set $14 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (i32.const 7) - ) - ) - (block $do_backpatches.18 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $14) - (i32.const 31) - ) - (block $compile_block.22 (result i32) - (drop - (block $compile_set.21 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.33 (result i32) - (block $compile_store.24 - (local.set $15 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (i32.const 9) - ) - ) - (block $do_backpatches.23 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $15) - (i32.const 31) - ) - (block $compile_block.26 (result i32) - (drop - (block $compile_set.25 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.32 (result i32) - (block $compile_store.28 - (local.set $16 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (i32.const 11) - ) - ) - (block $do_backpatches.27 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $16) - (i32.const 31) - ) - (block $compile_block.30 (result i32) - (drop - (block $compile_set.29 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 3) - ) - (block $compile_block.31 (result i32) - (i32.const 5) - ) - ) - ) - ) - ) - ) - (block $cleanup.20 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.35 (result i32) - (i32.const 5) - ) - ) - ) - ) - ) - (block $do_backpatches.37 - ) - ) - (block $cleanup.39 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.41_outer (result i32) - (block $switch.41_branch_0 (result i32) - (drop - (block $switch.41_branch_1 (result i32) - (drop - (block $switch.41_branch_2 (result i32) - (drop - (block $switch.41_branch_3 (result i32) - (drop - (block $switch.41_default (result i32) - (br_table $switch.41_branch_1 $switch.41_branch_2 $switch.41_branch_3 $switch.41_default $switch.41_default - (i32.const 0) - (i32.shr_s - (local.get $12) - (i32.const 1) - ) - ) - ) - ) - (br $switch.41_outer - (block $compile_block.46 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.41_outer - (block $compile_block.45 (result i32) - (block $allocate_adt.44 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - ) - ) - ) - (br $switch.41_outer - (block $compile_block.43 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - ) - ) - ) - ) - (br $switch.41_outer - (block $compile_block.42 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - ) - ) - ) - ) - (block $cleanup.40 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 0 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 3 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstI32 5))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 0 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 2))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 4) (stack_size_i32 7) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1131) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.5ff49e44.0.snapshot b/compiler/test/__snapshots__/pattern_matching.5ff49e44.0.snapshot index 3f9a96e102..3d9fbfe82a 100644 --- a/compiler/test/__snapshots__/pattern_matching.5ff49e44.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.5ff49e44.0.snapshot @@ -1,311 +1,176 @@ pattern matching › record_match_4 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1126 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1126 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (block $compile_block.27 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (i32.const 13) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $6) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $6) - ) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $6) - ) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $cleanup.16 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (drop - (block $compile_set.17 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.18 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.19 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.21_outer (result i32) - (block $switch.21_branch_0 (result i32) - (drop - (block $switch.21_branch_1 (result i32) - (drop - (block $switch.21_default (result i32) - (br_table $switch.21_branch_1 $switch.21_default $switch.21_default - (i32.const 0) - (i32.shr_s - (i32.const 1) - (i32.const 1) - ) - ) - ) - ) - (br $switch.21_outer - (block $compile_block.26 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.21_outer - (block $compile_block.25 - (block $compile_store.23 - (local.set $13 - (call $+_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1126) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - ) - ) - (block $do_backpatches.22 - ) - ) - (block $cleanup.24 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - (return_call $+_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1126) - ) - (local.get $13) - (local.get $9) - ) - ) - ) - ) - ) - (block $cleanup.20 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 643 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1126) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1126) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))) + ((baz) + ((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MRecordOp (MRecordGet 1) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MRecordOp (MRecordGet 2) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((0 + (((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MCallKnown (func +_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1126 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1126 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 8) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1128) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.64686134.0.snapshot b/compiler/test/__snapshots__/pattern_matching.64686134.0.snapshot index 7d4ae7b590..0b7af63939 100644 --- a/compiler/test/__snapshots__/pattern_matching.64686134.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.64686134.0.snapshot @@ -1,335 +1,105 @@ pattern matching › constant_match_1 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"GRAIN$EXPORT$equal\" (global $GRAIN$EXPORT$equal_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"equal\" (func $equal_0 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (block $compile_block.27 (result i32) - (block $compile_store.5 - (local.set $6 - (block $allocate_number.3 (result i32) - (i32.store - (local.tee $1 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $1) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $1) - (block $allocate_number.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (i64.store offset=16 - (local.get $0) - (i64.const 1) - ) - (local.get $0) - ) - ) - (i32.store offset=12 - (local.get $1) - (block $allocate_number.2 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (i64.store offset=16 - (local.get $0) - (i64.const 3) - ) - (local.get $0) - ) - ) - (local.get $1) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $8 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (i32.const 11) - ) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.20 - (local.set $9 - (if (result i32) - (i32.shr_u - (local.get $8) - (i32.const 31) - ) - (block $compile_block.8 (result i32) - (i32.const 1) - ) - (block $compile_block.18 (result i32) - (block $compile_store.13 - (local.set $7 - (block $allocate_number.11 (result i32) - (i32.store - (local.tee $1 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $1) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $1) - (block $allocate_number.9 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (i64.store offset=16 - (local.get $0) - (i64.const 1) - ) - (local.get $0) - ) - ) - (i32.store offset=12 - (local.get $1) - (block $allocate_number.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 5) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (i64.store offset=16 - (local.get $0) - (i64.const 3) - ) - (local.get $0) - ) - ) - (local.get $1) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $10 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $6) - ) - (local.get $7) - ) - ) - (block $do_backpatches.14 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $10) - (i32.const 31) - ) - (block $compile_block.16 (result i32) - (i32.const 3) - ) - (block $compile_block.17 (result i32) - (i32.const 5) - ) - ) - ) - ) - ) - (block $do_backpatches.19 - ) - ) - (block $cleanup.21 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (block $switch.22_outer (result i32) - (block $switch.22_branch_0 (result i32) - (drop - (block $switch.22_branch_1 (result i32) - (drop - (block $switch.22_branch_2 (result i32) - (drop - (block $switch.22_branch_3 (result i32) - (drop - (block $switch.22_default (result i32) - (br_table $switch.22_branch_1 $switch.22_branch_2 $switch.22_branch_3 $switch.22_default $switch.22_default - (i32.const 0) - (i32.shr_s - (local.get $9) - (i32.const 1) - ) - ) - ) - ) - (br $switch.22_outer - (block $compile_block.26 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.22_outer - (block $compile_block.25 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.22_outer - (block $compile_block.24 (result i32) - (i32.const -2) - ) - ) - ) - ) - (br $switch.22_outer - (block $compile_block.23 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MRational (numerator_flags ()) (numerator_limbs (1)) + (denominator_flags ()) (denominator_limbs (3))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRational (numerator_flags ()) (numerator_limbs (1)) + (denominator_flags ()) (denominator_limbs (3))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + (Unmanaged WasmI32)))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 3) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1120) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot b/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot index b1799f2bd2..598c682fe5 100644 --- a/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.702ed9b0.0.snapshot @@ -1,1346 +1,825 @@ pattern matching › tuple_match_deep6 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1157 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1157 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (local $23 i32) - (local $24 i32) - (local $25 i32) - (local $26 i32) - (local $27 i32) - (local $28 i32) - (local $29 i32) - (local $30 i32) - (local $31 i32) - (local $32 i32) - (local $33 i32) - (local $34 i32) - (local $35 i32) - (local $36 i32) - (local $37 i32) - (local $38 i32) - (local $39 i32) - (local $40 i32) - (local $41 i32) - (local $42 i32) - (local $43 i32) - (block $compile_block.123 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 13) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_adt.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=24 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.15 - (local.set $10 - (block $allocate_tuple.13 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (local.get $9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.17 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.19 - (local.set $12 - (i32.const 0) - ) - (block $do_backpatches.18 - ) - ) - (block $compile_store.21 - (local.set $13 - (i32.const 0) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.23 - (local.set $14 - (i32.const 0) - ) - (block $do_backpatches.22 - ) - ) - (block $compile_store.25 - (local.set $15 - (i32.const 0) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.27 - (local.set $16 - (i32.const 0) - ) - (block $do_backpatches.26 - ) - ) - (block $compile_store.29 - (local.set $17 - (i32.const 0) - ) - (block $do_backpatches.28 - ) - ) - (block $compile_store.31 - (local.set $18 - (i32.const 0) - ) - (block $do_backpatches.30 - ) - ) - (block $compile_store.33 - (local.set $19 - (i32.const 0) - ) - (block $do_backpatches.32 - ) - ) - (block $compile_store.35 - (local.set $20 - (i32.const 0) - ) - (block $do_backpatches.34 - ) - ) - (block $compile_store.37 - (local.set $21 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $10) - ) - ) - ) - (block $do_backpatches.36 - ) - ) - (block $compile_store.39 - (local.set $22 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $10) - ) - ) - ) - (block $do_backpatches.38 - ) - ) - (block $cleanup.40 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - (block $compile_store.42 - (local.set $32 - (i32.load offset=12 - (local.get $22) - ) - ) - (block $do_backpatches.41 - ) - ) - (block $compile_store.44 - (local.set $33 - (i32.or - (i32.shl - (i32.eq - (local.get $32) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.43 - ) - ) - (block $compile_store.104 - (local.set $34 - (if (result i32) - (i32.shr_u - (local.get $33) - (i32.const 31) - ) - (block $compile_block.96 (result i32) - (block $compile_store.46 - (local.set $23 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $22) - ) - ) - ) - (block $do_backpatches.45 - ) - ) - (block $compile_store.48 - (local.set $24 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $22) - ) - ) - ) - (block $do_backpatches.47 - ) - ) - (block $compile_store.50 - (local.set $36 - (i32.load offset=12 - (local.get $24) - ) - ) - (block $do_backpatches.49 - ) - ) - (block $compile_store.52 - (local.set $37 - (i32.or - (i32.shl - (i32.eq - (local.get $36) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.51 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $37) - (i32.const 31) - ) - (block $compile_block.88 (result i32) - (block $compile_store.55 - (local.set $25 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $24) - ) - ) - ) - (block $do_backpatches.54 - ) - ) - (block $compile_store.57 - (local.set $26 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $24) - ) - ) - ) - (block $do_backpatches.56 - ) - ) - (block $compile_store.59 - (local.set $39 - (i32.load offset=12 - (local.get $26) - ) - ) - (block $do_backpatches.58 - ) - ) - (block $compile_store.61 - (local.set $40 - (i32.or - (i32.shl - (i32.eq - (local.get $39) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.60 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $40) - (i32.const 31) - ) - (block $compile_block.79 (result i32) - (block $compile_store.64 - (local.set $27 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $26) - ) - ) - ) - (block $do_backpatches.63 - ) - ) - (block $compile_store.66 - (local.set $28 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $26) - ) - ) - ) - (block $do_backpatches.65 - ) - ) - (block $compile_store.68 - (local.set $42 - (i32.load offset=12 - (local.get $28) - ) - ) - (block $do_backpatches.67 - ) - ) - (block $cleanup.69 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $28) - ) - ) - ) - (block $compile_store.71 - (local.set $43 - (i32.or - (i32.shl - (i32.eq - (local.get $42) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.70 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $43) - (i32.const 31) - ) - (block $compile_block.77 (result i32) - (drop - (block $compile_set.73 (result i32) - (local.set $17 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $21) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.74 (result i32) - (local.set $18 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $23) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.75 (result i32) - (local.set $19 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $25) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.76 (result i32) - (local.set $20 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $27) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 7) - ) - (block $compile_block.78 (result i32) - (i32.const 9) - ) - ) - (block $cleanup.72 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $27) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.87 (result i32) - (block $compile_store.81 - (local.set $41 - (i32.or - (i32.shl - (i32.eq - (local.get $39) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.80 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $41) - (i32.const 31) - ) - (block $compile_block.85 (result i32) - (drop - (block $compile_set.82 (result i32) - (local.set $14 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $21) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.83 (result i32) - (local.set $15 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $23) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.84 (result i32) - (local.set $16 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $25) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 5) - ) - (block $compile_block.86 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.62 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $25) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $26) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.95 (result i32) - (block $compile_store.90 - (local.set $38 - (i32.or - (i32.shl - (i32.eq - (local.get $36) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.89 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $38) - (i32.const 31) - ) - (block $compile_block.93 (result i32) - (drop - (block $compile_set.91 (result i32) - (local.set $12 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $21) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.92 (result i32) - (local.set $13 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $23) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 3) - ) - (block $compile_block.94 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.53 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $23) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $24) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.102 (result i32) - (block $compile_store.98 - (local.set $35 - (i32.or - (i32.shl - (i32.eq - (local.get $32) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.97 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $35) - (i32.const 31) - ) - (block $compile_block.100 (result i32) - (drop - (block $compile_set.99 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $21) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.101 - (unreachable) - ) - ) - ) - ) - ) - (block $do_backpatches.103 - ) - ) - (block $cleanup.105 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $21) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $22) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.107_outer (result i32) - (block $switch.107_branch_0 (result i32) - (drop - (block $switch.107_branch_1 (result i32) - (drop - (block $switch.107_branch_2 (result i32) - (drop - (block $switch.107_branch_3 (result i32) - (drop - (block $switch.107_branch_4 (result i32) - (drop - (block $switch.107_branch_5 (result i32) - (drop - (block $switch.107_default (result i32) - (br_table $switch.107_branch_1 $switch.107_branch_2 $switch.107_branch_3 $switch.107_branch_4 $switch.107_branch_5 $switch.107_default $switch.107_default - (i32.const 0) - (i32.shr_s - (local.get $34) - (i32.const 1) - ) - ) - ) - ) - (br $switch.107_outer - (block $compile_block.122 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.107_outer - (block $compile_block.121 (result i32) - (i32.const 1999) - ) - ) - ) - ) - (br $switch.107_outer - (block $compile_block.120 - (block $compile_store.116 - (local.set $30 - (call $+_1157 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1157) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $17) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $18) - ) - ) - ) - (block $do_backpatches.115 - ) - ) - (block $compile_store.118 - (local.set $31 - (call $+_1157 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1157) - ) - (local.get $30) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $19) - ) - ) - ) - (block $do_backpatches.117 - ) - ) - (block $cleanup.119 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - ) - (return_call $+_1157 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1157) - ) - (local.get $31) - (local.get $20) - ) - ) - ) - ) - ) - (br $switch.107_outer - (block $compile_block.114 - (block $compile_store.112 - (local.set $29 - (call $+_1157 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1157) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $14) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - ) - ) - (block $do_backpatches.111 - ) - ) - (block $cleanup.113 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - ) - (return_call $+_1157 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1157) - ) - (local.get $29) - (local.get $16) - ) - ) - ) - ) - ) - (br $switch.107_outer - (block $compile_block.110 - (block $cleanup.109 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - ) - (return_call $+_1157 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1157) - ) - (local.get $12) - (local.get $13) - ) - ) - ) - ) - ) - (br $switch.107_outer - (block $compile_block.108 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - ) - ) - ) - (block $cleanup.106 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1157) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1157) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 13 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 14 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 15 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 16 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 17 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 18 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 19 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 20 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 20 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 8 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 21 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 20 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 22 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 20 Managed))) + (immediate_analyses + ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 22 Managed))) + (immediate_analyses + ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc + (MImmBinding (MLocalBind 22 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 11 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 10 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 11 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 11 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 15 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 12 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 17 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 13 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 19 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 14 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 21 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 3))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 21 Managed))) + (immediate_analyses + ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 9 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 9 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 15 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 17 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 19 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 2))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 20 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1157) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1157 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (2 + (((instr_desc + (MStore + (((MLocalBind 23 Managed) + ((instr_desc + (MCallKnown (func +_1157) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1157 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1157) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1157 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 23 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (3 + (((instr_desc + (MStore + (((MLocalBind 24 Managed) + ((instr_desc + (MCallKnown (func +_1157) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1157 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 25 Managed) + ((instr_desc + (MCallKnown (func +_1157) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1157 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 24 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1157) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1157 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 25 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (4 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 999))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 26) (stack_size_i32 12) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1162) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.7082d3ca.0.snapshot b/compiler/test/__snapshots__/pattern_matching.7082d3ca.0.snapshot index 2d56c895dc..29442c951f 100644 --- a/compiler/test/__snapshots__/pattern_matching.7082d3ca.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.7082d3ca.0.snapshot @@ -1,301 +1,129 @@ pattern matching › tuple_match_3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (block $compile_block.28 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 1886351202) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (local.get $6) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2147483646) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $13 - (i32.const 0) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.14 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $7) - ) - ) - ) - (block $do_backpatches.13 - ) - ) - (block $compile_store.16 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $7) - ) - ) - ) - (block $do_backpatches.15 - ) - ) - (block $compile_store.18 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $7) - ) - ) - ) - (block $do_backpatches.17 - ) - ) - (block $cleanup.19 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (drop - (block $compile_set.20 (result i32) - (local.set $13 - (local.get $12) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.21 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.22 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.24_outer (result i32) - (block $switch.24_branch_0 (result i32) - (drop - (block $switch.24_branch_1 (result i32) - (drop - (block $switch.24_default (result i32) - (br_table $switch.24_branch_1 $switch.24_default $switch.24_default - (i32.const 0) - (i32.shr_s - (i32.const 1) - (i32.const 1) - ) - ) - ) - ) - (br $switch.24_outer - (block $compile_block.27 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.24_outer - (block $compile_block.26 (result i32) - (block $allocate_tuple.25 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - ) - (i32.store offset=12 - (local.get $0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - ) - (i32.store offset=16 - (local.get $0) - (local.get $13) - ) - (local.get $0) - ) - ) - ) - ) - ) - (block $cleanup.23 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString boop))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((0 + (((instr_desc + (MAllocate + (MTuple + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 7) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1124) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.79346fef.0.snapshot b/compiler/test/__snapshots__/pattern_matching.79346fef.0.snapshot index 1bce284be1..311dd00d83 100644 --- a/compiler/test/__snapshots__/pattern_matching.79346fef.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.79346fef.0.snapshot @@ -1,1217 +1,777 @@ pattern matching › tuple_match_deep3 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1151 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1151 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (local $23 i32) - (local $24 i32) - (local $25 i32) - (local $26 i32) - (local $27 i32) - (local $28 i32) - (local $29 i32) - (local $30 i32) - (local $31 i32) - (local $32 i32) - (local $33 i32) - (local $34 i32) - (local $35 i32) - (local $36 i32) - (local $37 i32) - (local $38 i32) - (local $39 i32) - (local $40 i32) - (block $compile_block.114 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.14 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.13 - ) - ) - (block $compile_store.16 - (local.set $12 - (i32.const 0) - ) - (block $do_backpatches.15 - ) - ) - (block $compile_store.18 - (local.set $13 - (i32.const 0) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.20 - (local.set $14 - (i32.const 0) - ) - (block $do_backpatches.19 - ) - ) - (block $compile_store.22 - (local.set $15 - (i32.const 0) - ) - (block $do_backpatches.21 - ) - ) - (block $compile_store.24 - (local.set $16 - (i32.const 0) - ) - (block $do_backpatches.23 - ) - ) - (block $compile_store.26 - (local.set $17 - (i32.const 0) - ) - (block $do_backpatches.25 - ) - ) - (block $compile_store.28 - (local.set $18 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $7) - ) - ) - ) - (block $do_backpatches.27 - ) - ) - (block $compile_store.30 - (local.set $19 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $7) - ) - ) - ) - (block $do_backpatches.29 - ) - ) - (block $cleanup.31 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (block $compile_store.33 - (local.set $29 - (i32.load offset=12 - (local.get $19) - ) - ) - (block $do_backpatches.32 - ) - ) - (block $compile_store.35 - (local.set $30 - (i32.or - (i32.shl - (i32.eq - (local.get $29) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.34 - ) - ) - (block $compile_store.95 - (local.set $31 - (if (result i32) - (i32.shr_u - (local.get $30) - (i32.const 31) - ) - (block $compile_block.87 (result i32) - (block $compile_store.37 - (local.set $20 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $19) - ) - ) - ) - (block $do_backpatches.36 - ) - ) - (block $compile_store.39 - (local.set $21 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $19) - ) - ) - ) - (block $do_backpatches.38 - ) - ) - (block $compile_store.41 - (local.set $33 - (i32.load offset=12 - (local.get $21) - ) - ) - (block $do_backpatches.40 - ) - ) - (block $compile_store.43 - (local.set $34 - (i32.or - (i32.shl - (i32.eq - (local.get $33) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.42 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $34) - (i32.const 31) - ) - (block $compile_block.79 (result i32) - (block $compile_store.46 - (local.set $22 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $21) - ) - ) - ) - (block $do_backpatches.45 - ) - ) - (block $compile_store.48 - (local.set $23 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $21) - ) - ) - ) - (block $do_backpatches.47 - ) - ) - (block $compile_store.50 - (local.set $36 - (i32.load offset=12 - (local.get $23) - ) - ) - (block $do_backpatches.49 - ) - ) - (block $compile_store.52 - (local.set $37 - (i32.or - (i32.shl - (i32.eq - (local.get $36) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.51 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $37) - (i32.const 31) - ) - (block $compile_block.70 (result i32) - (block $compile_store.55 - (local.set $24 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $23) - ) - ) - ) - (block $do_backpatches.54 - ) - ) - (block $compile_store.57 - (local.set $25 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $23) - ) - ) - ) - (block $do_backpatches.56 - ) - ) - (block $compile_store.59 - (local.set $39 - (i32.load offset=12 - (local.get $25) - ) - ) - (block $do_backpatches.58 - ) - ) - (block $cleanup.60 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $25) - ) - ) - ) - (block $compile_store.62 - (local.set $40 - (i32.or - (i32.shl - (i32.eq - (local.get $39) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.61 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $40) - (i32.const 31) - ) - (block $compile_block.68 (result i32) - (drop - (block $compile_set.64 (result i32) - (local.set $14 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $18) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.65 (result i32) - (local.set $15 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $20) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.66 (result i32) - (local.set $16 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $22) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.67 (result i32) - (local.set $17 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $24) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 7) - ) - (block $compile_block.69 (result i32) - (i32.const 9) - ) - ) - (block $cleanup.63 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $24) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.78 (result i32) - (block $compile_store.72 - (local.set $38 - (i32.or - (i32.shl - (i32.eq - (local.get $36) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.71 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $38) - (i32.const 31) - ) - (block $compile_block.76 (result i32) - (drop - (block $compile_set.73 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $18) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.74 (result i32) - (local.set $12 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $20) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.75 (result i32) - (local.set $13 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $22) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 5) - ) - (block $compile_block.77 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.53 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $22) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $23) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.86 (result i32) - (block $compile_store.81 - (local.set $35 - (i32.or - (i32.shl - (i32.eq - (local.get $33) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.80 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $35) - (i32.const 31) - ) - (block $compile_block.84 (result i32) - (drop - (block $compile_set.82 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $18) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.83 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $20) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 3) - ) - (block $compile_block.85 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.44 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $21) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.93 (result i32) - (block $compile_store.89 - (local.set $32 - (i32.or - (i32.shl - (i32.eq - (local.get $29) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.88 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $32) - (i32.const 31) - ) - (block $compile_block.91 (result i32) - (drop - (block $compile_set.90 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $18) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.92 - (unreachable) - ) - ) - ) - ) - ) - (block $do_backpatches.94 - ) - ) - (block $cleanup.96 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.98_outer (result i32) - (block $switch.98_branch_0 (result i32) - (drop - (block $switch.98_branch_1 (result i32) - (drop - (block $switch.98_branch_2 (result i32) - (drop - (block $switch.98_branch_3 (result i32) - (drop - (block $switch.98_branch_4 (result i32) - (drop - (block $switch.98_branch_5 (result i32) - (drop - (block $switch.98_default (result i32) - (br_table $switch.98_branch_1 $switch.98_branch_2 $switch.98_branch_3 $switch.98_branch_4 $switch.98_branch_5 $switch.98_default $switch.98_default - (i32.const 0) - (i32.shr_s - (local.get $31) - (i32.const 1) - ) - ) - ) - ) - (br $switch.98_outer - (block $compile_block.113 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.98_outer - (block $compile_block.112 (result i32) - (i32.const 1999) - ) - ) - ) - ) - (br $switch.98_outer - (block $compile_block.111 - (block $compile_store.107 - (local.set $27 - (call $+_1151 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $14) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - ) - ) - (block $do_backpatches.106 - ) - ) - (block $compile_store.109 - (local.set $28 - (call $+_1151 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) - ) - (local.get $27) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $16) - ) - ) - ) - (block $do_backpatches.108 - ) - ) - (block $cleanup.110 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - ) - (return_call $+_1151 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) - ) - (local.get $28) - (local.get $17) - ) - ) - ) - ) - ) - (br $switch.98_outer - (block $compile_block.105 - (block $compile_store.103 - (local.set $26 - (call $+_1151 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - ) - ) - (block $do_backpatches.102 - ) - ) - (block $cleanup.104 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - ) - (return_call $+_1151 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) - ) - (local.get $26) - (local.get $13) - ) - ) - ) - ) - ) - (br $switch.98_outer - (block $compile_block.101 - (block $cleanup.100 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - ) - (return_call $+_1151 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) - ) - (local.get $9) - (local.get $10) - ) - ) - ) - ) - ) - (br $switch.98_outer - (block $compile_block.99 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - ) - ) - ) - ) - (block $cleanup.97 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1151) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1151) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 13 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 14 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 15 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 16 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 17 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 8 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 18 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 19 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses + ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses + ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc + (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 11 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 10 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 11 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 12 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 14 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 16 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 11 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 18 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 3))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses + ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 9 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 9 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 12 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 14 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 16 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 2))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1151) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1151 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (2 + (((instr_desc + (MStore + (((MLocalBind 20 Managed) + ((instr_desc + (MCallKnown (func +_1151) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1151 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1151) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1151 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 20 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (3 + (((instr_desc + (MStore + (((MLocalBind 21 Managed) + ((instr_desc + (MCallKnown (func +_1151) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1151 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 22 Managed) + ((instr_desc + (MCallKnown (func +_1151) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1151 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 21 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1151) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1151 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 22 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (4 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 999))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 23) (stack_size_i32 12) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1156) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.7f7fe4ef.0.snapshot b/compiler/test/__snapshots__/pattern_matching.7f7fe4ef.0.snapshot index aaf65d1a7e..0783ca06c6 100644 --- a/compiler/test/__snapshots__/pattern_matching.7f7fe4ef.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.7f7fe4ef.0.snapshot @@ -1,79 +1,41 @@ pattern matching › alias_match_1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.7 (result i32) - (block $compile_store.2 - (local.set $6 - (i32.const 0) - ) - (block $do_backpatches.1 - ) - ) - (drop - (block $compile_set.3 (result i32) - (local.set $6 - (i32.const -2) - ) - (i32.const 1879048190) - ) - ) - (block $switch.4_outer (result i32) - (block $switch.4_branch_0 (result i32) - (drop - (block $switch.4_branch_1 (result i32) - (drop - (block $switch.4_default (result i32) - (br_table $switch.4_branch_1 $switch.4_default $switch.4_default - (i32.const 0) - (i32.shr_s - (i32.const 1) - (i32.const 1) - ) - ) - ) - ) - (br $switch.4_outer - (block $compile_block.6 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.4_outer - (block $compile_block.5 (result i32) - (local.get $6) - ) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MSwitch + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + (Unmanaged WasmI32)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1115) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.8614dff3.0.snapshot b/compiler/test/__snapshots__/pattern_matching.8614dff3.0.snapshot index dc72edb084..fd07d014d3 100644 --- a/compiler/test/__snapshots__/pattern_matching.8614dff3.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.8614dff3.0.snapshot @@ -1,106 +1,66 @@ pattern matching › alias_match_2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.12 (result i32) - (block $compile_store.2 - (local.set $6 - (i32.const 0) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.4 - (local.set $7 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (drop - (block $compile_set.5 (result i32) - (local.set $7 - (i32.const -2) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.6 (result i32) - (local.set $6 - (i32.const -2) - ) - (i32.const 1879048190) - ) - ) - (block $switch.7_outer (result i32) - (block $switch.7_branch_0 (result i32) - (drop - (block $switch.7_branch_1 (result i32) - (drop - (block $switch.7_default (result i32) - (br_table $switch.7_branch_1 $switch.7_default $switch.7_default - (i32.const 0) - (i32.shr_s - (i32.const 1) - (i32.const 1) - ) - ) - ) - ) - (br $switch.7_outer - (block $compile_block.11 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.7_outer - (block $compile_block.10 (result i32) - (if (result i32) - (i32.shr_u - (local.get $7) - (i32.const 31) - ) - (block $compile_block.8 (result i32) - (local.get $6) - ) - (block $compile_block.9 (result i32) - (local.get $7) - ) - ) - ) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MSwitch + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((0 + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + (Unmanaged WasmI32)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 2) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.8c0dc67a.0.snapshot b/compiler/test/__snapshots__/pattern_matching.8c0dc67a.0.snapshot index c7631c5004..e282a23134 100644 --- a/compiler/test/__snapshots__/pattern_matching.8c0dc67a.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.8c0dc67a.0.snapshot @@ -1,852 +1,559 @@ pattern matching › adt_match_1 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1143 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1143 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (local $23 i32) - (local $24 i32) - (local $25 i32) - (local $26 i32) - (local $27 i32) - (local $28 i32) - (local $29 i32) - (local $30 i32) - (local $31 i32) - (block $compile_block.89 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $12 - (i32.const 0) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.17 - (local.set $20 - (i32.load offset=12 - (local.get $6) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.19 - (local.set $21 - (i32.or - (i32.shl - (i32.eq - (local.get $20) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.18 - ) - ) - (block $compile_store.75 - (local.set $22 - (if (result i32) - (i32.shr_u - (local.get $21) - (i32.const 31) - ) - (block $compile_block.68 (result i32) - (block $compile_store.21 - (local.set $13 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $6) - ) - ) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.23 - (local.set $14 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $6) - ) - ) - ) - (block $do_backpatches.22 - ) - ) - (block $compile_store.25 - (local.set $24 - (i32.load offset=12 - (local.get $14) - ) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.27 - (local.set $25 - (i32.or - (i32.shl - (i32.eq - (local.get $24) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.26 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $25) - (i32.const 31) - ) - (block $compile_block.61 (result i32) - (block $compile_store.30 - (local.set $15 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $14) - ) - ) - ) - (block $do_backpatches.29 - ) - ) - (block $compile_store.32 - (local.set $16 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $14) - ) - ) - ) - (block $do_backpatches.31 - ) - ) - (block $compile_store.34 - (local.set $27 - (i32.load offset=12 - (local.get $16) - ) - ) - (block $do_backpatches.33 - ) - ) - (block $compile_store.36 - (local.set $28 - (i32.or - (i32.shl - (i32.eq - (local.get $27) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.35 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $28) - (i32.const 31) - ) - (block $compile_block.53 (result i32) - (block $compile_store.39 - (local.set $17 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $16) - ) - ) - ) - (block $do_backpatches.38 - ) - ) - (block $compile_store.41 - (local.set $18 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $16) - ) - ) - ) - (block $do_backpatches.40 - ) - ) - (block $compile_store.43 - (local.set $30 - (i32.load offset=12 - (local.get $18) - ) - ) - (block $do_backpatches.42 - ) - ) - (block $cleanup.44 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - ) - (block $compile_store.46 - (local.set $31 - (i32.or - (i32.shl - (i32.eq - (local.get $30) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.45 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $31) - (i32.const 31) - ) - (block $compile_block.51 (result i32) - (drop - (block $compile_set.48 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.49 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.50 (result i32) - (local.set $12 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $17) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 7) - ) - (block $compile_block.52 (result i32) - (i32.const 9) - ) - ) - (block $cleanup.47 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.60 (result i32) - (block $compile_store.55 - (local.set $29 - (i32.or - (i32.shl - (i32.eq - (local.get $27) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.54 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $29) - (i32.const 31) - ) - (block $compile_block.58 (result i32) - (drop - (block $compile_set.56 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.57 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 5) - ) - (block $compile_block.59 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.37 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.67 (result i32) - (block $compile_store.63 - (local.set $26 - (i32.or - (i32.shl - (i32.eq - (local.get $24) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.62 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $26) - (i32.const 31) - ) - (block $compile_block.65 (result i32) - (drop - (block $compile_set.64 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 3) - ) - (block $compile_block.66 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.28 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.73 (result i32) - (block $compile_store.70 - (local.set $23 - (i32.or - (i32.shl - (i32.eq - (local.get $20) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.69 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $23) - (i32.const 31) - ) - (block $compile_block.71 (result i32) - (i32.const 1) - ) - (block $compile_block.72 - (unreachable) - ) - ) - ) - ) - ) - (block $do_backpatches.74 - ) - ) - (block $cleanup.76 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.78_outer (result i32) - (block $switch.78_branch_0 (result i32) - (drop - (block $switch.78_branch_1 (result i32) - (drop - (block $switch.78_branch_2 (result i32) - (drop - (block $switch.78_branch_3 (result i32) - (drop - (block $switch.78_branch_4 (result i32) - (drop - (block $switch.78_branch_5 (result i32) - (drop - (block $switch.78_default (result i32) - (br_table $switch.78_branch_1 $switch.78_branch_2 $switch.78_branch_3 $switch.78_branch_4 $switch.78_branch_5 $switch.78_default $switch.78_default - (i32.const 0) - (i32.shr_s - (local.get $22) - (i32.const 1) - ) - ) - ) - ) - (br $switch.78_outer - (block $compile_block.88 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.78_outer - (block $compile_block.87 (result i32) - (i32.const 1999) - ) - ) - ) - ) - (br $switch.78_outer - (block $compile_block.86 - (block $compile_store.84 - (local.set $19 - (call $+_1143 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1143) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - ) - (block $do_backpatches.83 - ) - ) - (block $cleanup.85 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - (return_call $+_1143 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1143) - ) - (local.get $19) - (local.get $12) - ) - ) - ) - ) - ) - (br $switch.78_outer - (block $compile_block.82 - (block $cleanup.81 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - (return_call $+_1143 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1143) - ) - (local.get $8) - (local.get $9) - ) - ) - ) - ) - ) - (br $switch.78_outer - (block $compile_block.80 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - ) - ) - ) - ) - (br $switch.78_outer - (block $compile_block.79 (result i32) - (i32.const 1) - ) - ) - ) - ) - (block $cleanup.77 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1143) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1143) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 8 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses + ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses + ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 11 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 10 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 11 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 7 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 9 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 11 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 3))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses + ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 9 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 9 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 7 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 9 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 2))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1143) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1143 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (3 + (((instr_desc + (MStore + (((MLocalBind 13 Managed) + ((instr_desc + (MCallKnown (func +_1143) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1143 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1143) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1143 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (4 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 999))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 14) (stack_size_i32 12) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1146) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.9561763b.0.snapshot b/compiler/test/__snapshots__/pattern_matching.9561763b.0.snapshot index 6572cce0aa..f20e1de159 100644 --- a/compiler/test/__snapshots__/pattern_matching.9561763b.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.9561763b.0.snapshot @@ -1,791 +1,449 @@ pattern matching › tuple_match_deep2 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1149 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1149 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (local $23 i32) - (local $24 i32) - (local $25 i32) - (local $26 i32) - (local $27 i32) - (local $28 i32) - (local $29 i32) - (local $30 i32) - (local $31 i32) - (local $32 i32) - (local $33 i32) - (block $compile_block.79 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 13) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 15) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=16 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_tuple.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_tuple.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.15 - (local.set $10 - (block $allocate_tuple.13 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (local.get $9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.17 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.19 - (local.set $12 - (i32.const 0) - ) - (block $do_backpatches.18 - ) - ) - (block $compile_store.21 - (local.set $13 - (i32.const 0) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.23 - (local.set $14 - (i32.const 0) - ) - (block $do_backpatches.22 - ) - ) - (block $compile_store.25 - (local.set $15 - (i32.const 0) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.27 - (local.set $16 - (i32.const 0) - ) - (block $do_backpatches.26 - ) - ) - (block $compile_store.29 - (local.set $17 - (i32.const 0) - ) - (block $do_backpatches.28 - ) - ) - (block $compile_store.31 - (local.set $18 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $10) - ) - ) - ) - (block $do_backpatches.30 - ) - ) - (block $compile_store.33 - (local.set $19 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $10) - ) - ) - ) - (block $do_backpatches.32 - ) - ) - (block $cleanup.34 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - (block $compile_store.36 - (local.set $20 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $19) - ) - ) - ) - (block $do_backpatches.35 - ) - ) - (block $compile_store.38 - (local.set $21 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $19) - ) - ) - ) - (block $do_backpatches.37 - ) - ) - (block $cleanup.39 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - ) - (block $compile_store.41 - (local.set $22 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $21) - ) - ) - ) - (block $do_backpatches.40 - ) - ) - (block $compile_store.43 - (local.set $23 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $21) - ) - ) - ) - (block $do_backpatches.42 - ) - ) - (block $cleanup.44 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $21) - ) - ) - ) - (block $compile_store.46 - (local.set $24 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $23) - ) - ) - ) - (block $do_backpatches.45 - ) - ) - (block $compile_store.48 - (local.set $25 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $23) - ) - ) - ) - (block $do_backpatches.47 - ) - ) - (block $compile_store.50 - (local.set $26 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $23) - ) - ) - ) - (block $do_backpatches.49 - ) - ) - (block $cleanup.51 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $23) - ) - ) - ) - (block $compile_store.53 - (local.set $27 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $26) - ) - ) - ) - (block $do_backpatches.52 - ) - ) - (block $compile_store.55 - (local.set $28 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $26) - ) - ) - ) - (block $do_backpatches.54 - ) - ) - (block $cleanup.56 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $26) - ) - ) - ) - (drop - (block $compile_set.57 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $18) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.58 (result i32) - (local.set $12 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $20) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.59 (result i32) - (local.set $13 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $22) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.60 (result i32) - (local.set $14 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $24) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.61 (result i32) - (local.set $15 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $25) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.62 (result i32) - (local.set $17 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $28) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.63 (result i32) - (local.set $16 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $27) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.65_outer (result i32) - (block $switch.65_branch_0 (result i32) - (drop - (block $switch.65_branch_1 (result i32) - (drop - (block $switch.65_default (result i32) - (br_table $switch.65_branch_1 $switch.65_default $switch.65_default - (i32.const 0) - (i32.shr_s - (i32.const 1) - (i32.const 1) - ) - ) - ) - ) - (br $switch.65_outer - (block $compile_block.78 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.65_outer - (block $compile_block.77 - (block $compile_store.67 - (local.set $29 - (call $+_1149 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1149) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - ) - ) - (block $do_backpatches.66 - ) - ) - (block $compile_store.69 - (local.set $30 - (call $+_1149 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1149) - ) - (local.get $29) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - ) - ) - (block $do_backpatches.68 - ) - ) - (block $compile_store.71 - (local.set $31 - (call $+_1149 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1149) - ) - (local.get $30) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $14) - ) - ) - ) - (block $do_backpatches.70 - ) - ) - (block $compile_store.73 - (local.set $32 - (call $+_1149 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1149) - ) - (local.get $31) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - ) - ) - (block $do_backpatches.72 - ) - ) - (block $compile_store.75 - (local.set $33 - (call $+_1149 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1149) - ) - (local.get $32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $16) - ) - ) - ) - (block $do_backpatches.74 - ) - ) - (block $cleanup.76 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - ) - (return_call $+_1149 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1149) - ) - (local.get $33) - (local.get $17) - ) - ) - ) - ) - ) - (block $cleanup.64 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1149) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1149) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 7))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 13 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 14 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 15 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 16 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 17 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 18 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 19 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 20 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 21 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 20 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 22 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 20 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 20 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 11 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 22 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 21 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((0 + (((instr_desc + (MStore + (((MLocalBind 23 Managed) + ((instr_desc + (MCallKnown (func +_1149) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1149 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 24 Managed) + ((instr_desc + (MCallKnown (func +_1149) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1149 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 23 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 25 Managed) + ((instr_desc + (MCallKnown (func +_1149) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1149 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 24 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 26 Managed) + ((instr_desc + (MCallKnown (func +_1149) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1149 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 25 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 27 Managed) + ((instr_desc + (MCallKnown (func +_1149) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1149 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 26 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1149) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1149 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 27 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 28) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1155) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.98756c45.0.snapshot b/compiler/test/__snapshots__/pattern_matching.98756c45.0.snapshot index 46e6520039..bb56f97423 100644 --- a/compiler/test/__snapshots__/pattern_matching.98756c45.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.98756c45.0.snapshot @@ -1,225 +1,95 @@ pattern matching › record_match_deep -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (block $compile_block.20 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1047233621) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 610197211) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2229) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $7) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $cleanup.11 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (block $compile_store.13 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $9) - ) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $cleanup.14 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - (drop - (block $compile_set.15 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.17_outer (result i32) - (block $switch.17_branch_0 (result i32) - (drop - (block $switch.17_branch_1 (result i32) - (drop - (block $switch.17_default (result i32) - (br_table $switch.17_branch_1 $switch.17_default $switch.17_default - (i32.const 0) - (i32.shr_s - (i32.const 1) - (i32.const 1) - ) - ) - ) - ) - (br $switch.17_outer - (block $compile_block.19 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.17_outer - (block $compile_block.18 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - ) - ) - ) - ) - (block $cleanup.16 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 606 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 523616810))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 305098605))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1114))) + (immediate_analyses ((last_usage Unknown)))) + (((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 5) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1125) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.9ffaa7a7.0.snapshot b/compiler/test/__snapshots__/pattern_matching.9ffaa7a7.0.snapshot index fd6241d725..c012ef0848 100644 --- a/compiler/test/__snapshots__/pattern_matching.9ffaa7a7.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.9ffaa7a7.0.snapshot @@ -1,242 +1,174 @@ pattern matching › low_level_constant_match_4 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1116 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1116 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (block $compile_block.28 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (select - (i32.const -2) - (i32.const 2147483646) - (f64.eq - (f64.const 1) - (f64.const 0) - ) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.17 - (local.set $8 - (if (result i32) - (i32.shr_u - (local.get $7) - (i32.const 31) - ) - (block $compile_block.6 (result i32) - (i32.const 1) - ) - (block $compile_block.15 (result i32) - (block $compile_store.8 - (local.set $9 - (select - (i32.const -2) - (i32.const 2147483646) - (f64.eq - (f64.const 1) - (f64.const 1) - ) - ) - ) - (block $do_backpatches.7 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $9) - (i32.const 31) - ) - (block $compile_block.9 (result i32) - (i32.const 3) - ) - (block $compile_block.14 (result i32) - (block $compile_store.11 - (local.set $10 - (select - (i32.const -2) - (i32.const 2147483646) - (f64.eq - (f64.const 1) - (f64.const 2) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $10) - (i32.const 31) - ) - (block $compile_block.12 (result i32) - (i32.const 5) - ) - (block $compile_block.13 (result i32) - (i32.const 7) - ) - ) - ) - ) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.25 - (local.set $11 - (block $switch.18_outer (result i32) - (block $switch.18_branch_0 (result i32) - (drop - (block $switch.18_branch_1 (result i32) - (drop - (block $switch.18_branch_2 (result i32) - (drop - (block $switch.18_branch_3 (result i32) - (drop - (block $switch.18_branch_4 (result i32) - (drop - (block $switch.18_default (result i32) - (br_table $switch.18_branch_1 $switch.18_branch_2 $switch.18_branch_3 $switch.18_branch_4 $switch.18_default $switch.18_default - (i32.const 0) - (i32.shr_s - (local.get $8) - (i32.const 1) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.23 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.22 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.21 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.20 (result i32) - (i32.const -2) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.19 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.27 - (local.set $12 - (call $print_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1116) - ) - (local.get $11) - (local.get $6) - ) - ) - (block $do_backpatches.26 - ) - ) - (i32.const 1) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1116) (name print))) (mimp_mod pervasives.gr) + (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1116) (name print))) (mimp_mod pervasives.gr) + (mimp_name print) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 + (WasmBinaryF64 (wasm_op Op_eq_float64) + (arg_types (Wasm_float64 Wasm_float64)) (ret_type Grain_bool)) + ((immediate_desc + (MImmConst (MConstLiteral (MConstF64 4607182418800017408)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstLiteral (MConstF64 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 + (WasmBinaryF64 (wasm_op Op_eq_float64) + (arg_types (Wasm_float64 Wasm_float64)) + (ret_type Grain_bool)) + ((immediate_desc + (MImmConst + (MConstLiteral (MConstF64 4607182418800017408)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst + (MConstLiteral (MConstF64 4607182418800017408)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 + (WasmBinaryF64 (wasm_op Op_eq_float64) + (arg_types (Wasm_float64 Wasm_float64)) + (ret_type Grain_bool)) + ((immediate_desc + (MImmConst + (MConstLiteral (MConstF64 4607182418800017408)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst + (MConstLiteral (MConstF64 4611686018427387904)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MSwitch + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (3 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + (Unmanaged WasmI32))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func print_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type + (((Unmanaged WasmI32) Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 6) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1125) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.aa8d2963.0.snapshot b/compiler/test/__snapshots__/pattern_matching.aa8d2963.0.snapshot index 5a15c3c938..dd9f344a5e 100644 --- a/compiler/test/__snapshots__/pattern_matching.aa8d2963.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.aa8d2963.0.snapshot @@ -1,431 +1,253 @@ pattern matching › guarded_match_4 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1126 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1126 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (block $compile_block.39 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 17) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $6) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $6) - ) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $6) - ) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $cleanup.16 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (drop - (block $compile_set.17 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.18 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.19 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.21 - (local.set $13 - (call $==_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1126) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (i32.const 5) - ) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.25 - (local.set $14 - (if (result i32) - (i32.shr_u - (local.get $13) - (i32.const 31) - ) - (block $compile_block.22 (result i32) - (call $==_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1126) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (i32.const 7) - ) - ) - (block $compile_block.23 (result i32) - (local.get $13) - ) - ) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.32 - (local.set $15 - (if (result i32) - (i32.shr_u - (local.get $14) - (i32.const 31) - ) - (block $compile_block.29 (result i32) - (drop - (block $compile_set.26 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.27 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.28 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.30 (result i32) - (i32.const 3) - ) - ) - ) - (block $do_backpatches.31 - ) - ) - (block $cleanup.33 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.35_outer (result i32) - (block $switch.35_branch_0 (result i32) - (drop - (block $switch.35_branch_1 (result i32) - (drop - (block $switch.35_branch_2 (result i32) - (drop - (block $switch.35_default (result i32) - (br_table $switch.35_branch_1 $switch.35_branch_2 $switch.35_default $switch.35_default - (i32.const 0) - (i32.shr_s - (local.get $15) - (i32.const 1) - ) - ) - ) - ) - (br $switch.35_outer - (block $compile_block.38 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.35_outer - (block $compile_block.37 (result i32) - (i32.const 199) - ) - ) - ) - ) - (br $switch.35_outer - (block $compile_block.36 (result i32) - (i32.const 85) - ) - ) - ) - ) - (block $cleanup.34 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1126) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1126) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 8))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func ==_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind ==_1126 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + (((instr_desc + (MCallKnown (func ==_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind ==_1126 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 42))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 99))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 7) (stack_size_i32 3) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1132) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.ac58ffc3.0.snapshot b/compiler/test/__snapshots__/pattern_matching.ac58ffc3.0.snapshot index 4ee68d69f8..62efe44410 100644 --- a/compiler/test/__snapshots__/pattern_matching.ac58ffc3.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.ac58ffc3.0.snapshot @@ -1,402 +1,222 @@ pattern matching › guarded_match_1 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1125 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1125 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (block $compile_block.35 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $6) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $6) - ) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $6) - ) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $cleanup.16 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (drop - (block $compile_set.17 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.18 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.19 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.21 - (local.set $13 - (call $==_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1125) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (i32.const 3) - ) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.28 - (local.set $14 - (if (result i32) - (i32.shr_u - (local.get $13) - (i32.const 31) - ) - (block $compile_block.25 (result i32) - (drop - (block $compile_set.22 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.23 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.24 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.26 (result i32) - (i32.const 3) - ) - ) - ) - (block $do_backpatches.27 - ) - ) - (block $cleanup.29 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.31_outer (result i32) - (block $switch.31_branch_0 (result i32) - (drop - (block $switch.31_branch_1 (result i32) - (drop - (block $switch.31_branch_2 (result i32) - (drop - (block $switch.31_default (result i32) - (br_table $switch.31_branch_1 $switch.31_branch_2 $switch.31_default $switch.31_default - (i32.const 0) - (i32.shr_s - (local.get $14) - (i32.const 1) - ) - ) - ) - ) - (br $switch.31_outer - (block $compile_block.34 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.31_outer - (block $compile_block.33 (result i32) - (i32.const 199) - ) - ) - ) - ) - (br $switch.31_outer - (block $compile_block.32 (result i32) - (i32.const 85) - ) - ) - ) - ) - (block $cleanup.30 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1125) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1125) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func ==_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind ==_1125 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 42))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 99))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 7) (stack_size_i32 2) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1130) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot b/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot index 1bfcf1ba1a..53fbcc8cfe 100644 --- a/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.b1b060ad.0.snapshot @@ -1,895 +1,575 @@ pattern matching › adt_match_2 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1145 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1145 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (local $23 i32) - (local $24 i32) - (local $25 i32) - (local $26 i32) - (local $27 i32) - (local $28 i32) - (local $29 i32) - (local $30 i32) - (local $31 i32) - (local $32 i32) - (block $compile_block.92 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.14 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.13 - ) - ) - (block $compile_store.16 - (local.set $12 - (i32.const 0) - ) - (block $do_backpatches.15 - ) - ) - (block $compile_store.18 - (local.set $13 - (i32.const 0) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.20 - (local.set $21 - (i32.load offset=12 - (local.get $7) - ) - ) - (block $do_backpatches.19 - ) - ) - (block $compile_store.22 - (local.set $22 - (i32.or - (i32.shl - (i32.eq - (local.get $21) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.21 - ) - ) - (block $compile_store.78 - (local.set $23 - (if (result i32) - (i32.shr_u - (local.get $22) - (i32.const 31) - ) - (block $compile_block.71 (result i32) - (block $compile_store.24 - (local.set $14 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $7) - ) - ) - ) - (block $do_backpatches.23 - ) - ) - (block $compile_store.26 - (local.set $15 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $7) - ) - ) - ) - (block $do_backpatches.25 - ) - ) - (block $compile_store.28 - (local.set $25 - (i32.load offset=12 - (local.get $15) - ) - ) - (block $do_backpatches.27 - ) - ) - (block $compile_store.30 - (local.set $26 - (i32.or - (i32.shl - (i32.eq - (local.get $25) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.29 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $26) - (i32.const 31) - ) - (block $compile_block.64 (result i32) - (block $compile_store.33 - (local.set $16 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $15) - ) - ) - ) - (block $do_backpatches.32 - ) - ) - (block $compile_store.35 - (local.set $17 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $15) - ) - ) - ) - (block $do_backpatches.34 - ) - ) - (block $compile_store.37 - (local.set $28 - (i32.load offset=12 - (local.get $17) - ) - ) - (block $do_backpatches.36 - ) - ) - (block $compile_store.39 - (local.set $29 - (i32.or - (i32.shl - (i32.eq - (local.get $28) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.38 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $29) - (i32.const 31) - ) - (block $compile_block.56 (result i32) - (block $compile_store.42 - (local.set $18 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $17) - ) - ) - ) - (block $do_backpatches.41 - ) - ) - (block $compile_store.44 - (local.set $19 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $17) - ) - ) - ) - (block $do_backpatches.43 - ) - ) - (block $compile_store.46 - (local.set $31 - (i32.load offset=12 - (local.get $19) - ) - ) - (block $do_backpatches.45 - ) - ) - (block $cleanup.47 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - ) - (block $compile_store.49 - (local.set $32 - (i32.or - (i32.shl - (i32.eq - (local.get $31) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.48 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $32) - (i32.const 31) - ) - (block $compile_block.54 (result i32) - (drop - (block $compile_set.51 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $14) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.52 (result i32) - (local.set $12 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $16) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.53 (result i32) - (local.set $13 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $18) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 7) - ) - (block $compile_block.55 (result i32) - (i32.const 9) - ) - ) - (block $cleanup.50 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.63 (result i32) - (block $compile_store.58 - (local.set $30 - (i32.or - (i32.shl - (i32.eq - (local.get $28) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.57 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $30) - (i32.const 31) - ) - (block $compile_block.61 (result i32) - (drop - (block $compile_set.59 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $14) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.60 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $16) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 5) - ) - (block $compile_block.62 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.40 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.70 (result i32) - (block $compile_store.66 - (local.set $27 - (i32.or - (i32.shl - (i32.eq - (local.get $25) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.65 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $27) - (i32.const 31) - ) - (block $compile_block.68 (result i32) - (drop - (block $compile_set.67 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $14) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 3) - ) - (block $compile_block.69 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.31 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.76 (result i32) - (block $compile_store.73 - (local.set $24 - (i32.or - (i32.shl - (i32.eq - (local.get $21) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.72 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $24) - (i32.const 31) - ) - (block $compile_block.74 (result i32) - (i32.const 1) - ) - (block $compile_block.75 - (unreachable) - ) - ) - ) - ) - ) - (block $do_backpatches.77 - ) - ) - (block $cleanup.79 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.81_outer (result i32) - (block $switch.81_branch_0 (result i32) - (drop - (block $switch.81_branch_1 (result i32) - (drop - (block $switch.81_branch_2 (result i32) - (drop - (block $switch.81_branch_3 (result i32) - (drop - (block $switch.81_branch_4 (result i32) - (drop - (block $switch.81_branch_5 (result i32) - (drop - (block $switch.81_default (result i32) - (br_table $switch.81_branch_1 $switch.81_branch_2 $switch.81_branch_3 $switch.81_branch_4 $switch.81_branch_5 $switch.81_default $switch.81_default - (i32.const 0) - (i32.shr_s - (local.get $23) - (i32.const 1) - ) - ) - ) - ) - (br $switch.81_outer - (block $compile_block.91 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.81_outer - (block $compile_block.90 (result i32) - (i32.const 1999) - ) - ) - ) - ) - (br $switch.81_outer - (block $compile_block.89 - (block $compile_store.87 - (local.set $20 - (call $+_1145 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1145) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - ) - ) - (block $do_backpatches.86 - ) - ) - (block $cleanup.88 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - (return_call $+_1145 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1145) - ) - (local.get $20) - (local.get $13) - ) - ) - ) - ) - ) - (br $switch.81_outer - (block $compile_block.85 - (block $cleanup.84 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - (return_call $+_1145 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1145) - ) - (local.get $9) - (local.get $10) - ) - ) - ) - ) - ) - (br $switch.81_outer - (block $compile_block.83 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - ) - ) - ) - ) - (br $switch.81_outer - (block $compile_block.82 (result i32) - (i32.const 1) - ) - ) - ) - ) - (block $cleanup.80 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1145) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1145) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 8 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 13 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses + ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses + ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc + (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 11 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 10 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 11 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 8 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 10 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 12 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 3))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses + ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 9 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 9 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 8 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 10 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 2))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1145) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1145 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (3 + (((instr_desc + (MStore + (((MLocalBind 14 Managed) + ((instr_desc + (MCallKnown (func +_1145) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1145 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1145) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1145 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (4 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 999))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 15) (stack_size_i32 12) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1148) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.b9db0dd9.0.snapshot b/compiler/test/__snapshots__/pattern_matching.b9db0dd9.0.snapshot index 55e79a2aec..00cd673eca 100644 --- a/compiler/test/__snapshots__/pattern_matching.b9db0dd9.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.b9db0dd9.0.snapshot @@ -1,431 +1,253 @@ pattern matching › guarded_match_3 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1126 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1126 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (block $compile_block.39 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $6) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $6) - ) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $6) - ) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $cleanup.16 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (drop - (block $compile_set.17 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.18 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.19 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.21 - (local.set $13 - (call $==_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1126) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (i32.const 5) - ) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.25 - (local.set $14 - (if (result i32) - (i32.shr_u - (local.get $13) - (i32.const 31) - ) - (block $compile_block.22 (result i32) - (call $==_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1126) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (i32.const 7) - ) - ) - (block $compile_block.23 (result i32) - (local.get $13) - ) - ) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.32 - (local.set $15 - (if (result i32) - (i32.shr_u - (local.get $14) - (i32.const 31) - ) - (block $compile_block.29 (result i32) - (drop - (block $compile_set.26 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.27 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.28 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.30 (result i32) - (i32.const 3) - ) - ) - ) - (block $do_backpatches.31 - ) - ) - (block $cleanup.33 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.35_outer (result i32) - (block $switch.35_branch_0 (result i32) - (drop - (block $switch.35_branch_1 (result i32) - (drop - (block $switch.35_branch_2 (result i32) - (drop - (block $switch.35_default (result i32) - (br_table $switch.35_branch_1 $switch.35_branch_2 $switch.35_default $switch.35_default - (i32.const 0) - (i32.shr_s - (local.get $15) - (i32.const 1) - ) - ) - ) - ) - (br $switch.35_outer - (block $compile_block.38 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.35_outer - (block $compile_block.37 (result i32) - (i32.const 199) - ) - ) - ) - ) - (br $switch.35_outer - (block $compile_block.36 (result i32) - (i32.const 85) - ) - ) - ) - ) - (block $cleanup.34 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1126) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1126) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func ==_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind ==_1126 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + (((instr_desc + (MCallKnown (func ==_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind ==_1126 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 42))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 99))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 7) (stack_size_i32 3) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1132) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.be46eb0e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.be46eb0e.0.snapshot index 5bd625281e..f633dbaa05 100644 --- a/compiler/test/__snapshots__/pattern_matching.be46eb0e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.be46eb0e.0.snapshot @@ -1,248 +1,161 @@ pattern matching › low_level_constant_match_1 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1116 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1116 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (block $compile_block.28 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (i32.or - (i32.shl - (i32.eq - (i32.const 1) - (i32.const 0) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.17 - (local.set $8 - (if (result i32) - (i32.shr_u - (local.get $7) - (i32.const 31) - ) - (block $compile_block.6 (result i32) - (i32.const 1) - ) - (block $compile_block.15 (result i32) - (block $compile_store.8 - (local.set $9 - (i32.or - (i32.shl - (i32.eq - (i32.const 1) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.7 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $9) - (i32.const 31) - ) - (block $compile_block.9 (result i32) - (i32.const 3) - ) - (block $compile_block.14 (result i32) - (block $compile_store.11 - (local.set $10 - (i32.or - (i32.shl - (i32.eq - (i32.const 1) - (i32.const 2) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.10 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $10) - (i32.const 31) - ) - (block $compile_block.12 (result i32) - (i32.const 5) - ) - (block $compile_block.13 (result i32) - (i32.const 7) - ) - ) - ) - ) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.25 - (local.set $11 - (block $switch.18_outer (result i32) - (block $switch.18_branch_0 (result i32) - (drop - (block $switch.18_branch_1 (result i32) - (drop - (block $switch.18_branch_2 (result i32) - (drop - (block $switch.18_branch_3 (result i32) - (drop - (block $switch.18_branch_4 (result i32) - (drop - (block $switch.18_default (result i32) - (br_table $switch.18_branch_1 $switch.18_branch_2 $switch.18_branch_3 $switch.18_branch_4 $switch.18_default $switch.18_default - (i32.const 0) - (i32.shr_s - (local.get $8) - (i32.const 1) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.23 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.22 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.21 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.20 (result i32) - (i32.const -2) - ) - ) - ) - ) - (br $switch.18_outer - (block $compile_block.19 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.27 - (local.set $12 - (call $print_1116 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1116) - ) - (local.get $11) - (local.get $6) - ) - ) - (block $do_backpatches.26 - ) - ) - (i32.const 1) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1116) (name print))) (mimp_mod pervasives.gr) + (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1116) (name print))) (mimp_mod pervasives.gr) + (mimp_name print) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 1)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 1)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 1)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 1)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MSwitch + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (3 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + (Unmanaged WasmI32))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func print_1116) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type + (((Unmanaged WasmI32) Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 6) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1125) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot b/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot index 84517d7d64..ae0a1a1ed3 100644 --- a/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.c91eac29.0.snapshot @@ -1,938 +1,591 @@ pattern matching › adt_match_3 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1147 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1147 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (local $23 i32) - (local $24 i32) - (local $25 i32) - (local $26 i32) - (local $27 i32) - (local $28 i32) - (local $29 i32) - (local $30 i32) - (local $31 i32) - (local $32 i32) - (local $33 i32) - (block $compile_block.95 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.17 - (local.set $12 - (i32.const 0) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.19 - (local.set $13 - (i32.const 0) - ) - (block $do_backpatches.18 - ) - ) - (block $compile_store.21 - (local.set $14 - (i32.const 0) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.23 - (local.set $22 - (i32.load offset=12 - (local.get $8) - ) - ) - (block $do_backpatches.22 - ) - ) - (block $compile_store.25 - (local.set $23 - (i32.or - (i32.shl - (i32.eq - (local.get $22) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.81 - (local.set $24 - (if (result i32) - (i32.shr_u - (local.get $23) - (i32.const 31) - ) - (block $compile_block.74 (result i32) - (block $compile_store.27 - (local.set $15 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $8) - ) - ) - ) - (block $do_backpatches.26 - ) - ) - (block $compile_store.29 - (local.set $16 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $8) - ) - ) - ) - (block $do_backpatches.28 - ) - ) - (block $compile_store.31 - (local.set $26 - (i32.load offset=12 - (local.get $16) - ) - ) - (block $do_backpatches.30 - ) - ) - (block $compile_store.33 - (local.set $27 - (i32.or - (i32.shl - (i32.eq - (local.get $26) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.32 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $27) - (i32.const 31) - ) - (block $compile_block.67 (result i32) - (block $compile_store.36 - (local.set $17 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $16) - ) - ) - ) - (block $do_backpatches.35 - ) - ) - (block $compile_store.38 - (local.set $18 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $16) - ) - ) - ) - (block $do_backpatches.37 - ) - ) - (block $compile_store.40 - (local.set $29 - (i32.load offset=12 - (local.get $18) - ) - ) - (block $do_backpatches.39 - ) - ) - (block $compile_store.42 - (local.set $30 - (i32.or - (i32.shl - (i32.eq - (local.get $29) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.41 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $30) - (i32.const 31) - ) - (block $compile_block.59 (result i32) - (block $compile_store.45 - (local.set $19 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $18) - ) - ) - ) - (block $do_backpatches.44 - ) - ) - (block $compile_store.47 - (local.set $20 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $18) - ) - ) - ) - (block $do_backpatches.46 - ) - ) - (block $compile_store.49 - (local.set $32 - (i32.load offset=12 - (local.get $20) - ) - ) - (block $do_backpatches.48 - ) - ) - (block $cleanup.50 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - ) - (block $compile_store.52 - (local.set $33 - (i32.or - (i32.shl - (i32.eq - (local.get $32) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.51 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $33) - (i32.const 31) - ) - (block $compile_block.57 (result i32) - (drop - (block $compile_set.54 (result i32) - (local.set $12 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.55 (result i32) - (local.set $13 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $17) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.56 (result i32) - (local.set $14 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $19) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 7) - ) - (block $compile_block.58 (result i32) - (i32.const 9) - ) - ) - (block $cleanup.53 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.66 (result i32) - (block $compile_store.61 - (local.set $31 - (i32.or - (i32.shl - (i32.eq - (local.get $29) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.60 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $31) - (i32.const 31) - ) - (block $compile_block.64 (result i32) - (drop - (block $compile_set.62 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.63 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $17) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 5) - ) - (block $compile_block.65 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.43 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.73 (result i32) - (block $compile_store.69 - (local.set $28 - (i32.or - (i32.shl - (i32.eq - (local.get $26) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.68 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $28) - (i32.const 31) - ) - (block $compile_block.71 (result i32) - (drop - (block $compile_set.70 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 3) - ) - (block $compile_block.72 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.34 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.79 (result i32) - (block $compile_store.76 - (local.set $25 - (i32.or - (i32.shl - (i32.eq - (local.get $22) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.75 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $25) - (i32.const 31) - ) - (block $compile_block.77 (result i32) - (i32.const 1) - ) - (block $compile_block.78 - (unreachable) - ) - ) - ) - ) - ) - (block $do_backpatches.80 - ) - ) - (block $cleanup.82 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.84_outer (result i32) - (block $switch.84_branch_0 (result i32) - (drop - (block $switch.84_branch_1 (result i32) - (drop - (block $switch.84_branch_2 (result i32) - (drop - (block $switch.84_branch_3 (result i32) - (drop - (block $switch.84_branch_4 (result i32) - (drop - (block $switch.84_branch_5 (result i32) - (drop - (block $switch.84_default (result i32) - (br_table $switch.84_branch_1 $switch.84_branch_2 $switch.84_branch_3 $switch.84_branch_4 $switch.84_branch_5 $switch.84_default $switch.84_default - (i32.const 0) - (i32.shr_s - (local.get $24) - (i32.const 1) - ) - ) - ) - ) - (br $switch.84_outer - (block $compile_block.94 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.84_outer - (block $compile_block.93 (result i32) - (i32.const 1999) - ) - ) - ) - ) - (br $switch.84_outer - (block $compile_block.92 - (block $compile_store.90 - (local.set $21 - (call $+_1147 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1147) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - ) - ) - (block $do_backpatches.89 - ) - ) - (block $cleanup.91 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - (return_call $+_1147 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1147) - ) - (local.get $21) - (local.get $14) - ) - ) - ) - ) - ) - (br $switch.84_outer - (block $compile_block.88 - (block $cleanup.87 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - (return_call $+_1147 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1147) - ) - (local.get $10) - (local.get $11) - ) - ) - ) - ) - ) - (br $switch.84_outer - (block $compile_block.86 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - ) - ) - ) - ) - (br $switch.84_outer - (block $compile_block.85 (result i32) - (i32.const 1) - ) - ) - ) - ) - (block $cleanup.83 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1147) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1147) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 8 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 13 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 14 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses + ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses + ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc + (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 11 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 10 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 11 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 9 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 11 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 13 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 3))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses + ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 9 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 9 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 9 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 11 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 2))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1147) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1147 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (3 + (((instr_desc + (MStore + (((MLocalBind 15 Managed) + ((instr_desc + (MCallKnown (func +_1147) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1147 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1147) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1147 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (4 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 999))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 16) (stack_size_i32 12) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1150) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.c9582b6d.0.snapshot b/compiler/test/__snapshots__/pattern_matching.c9582b6d.0.snapshot index 7c85f281a0..18157d1e7e 100644 --- a/compiler/test/__snapshots__/pattern_matching.c9582b6d.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.c9582b6d.0.snapshot @@ -1,364 +1,209 @@ pattern matching › alias_match_4 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"GRAIN$EXPORT$equal\" (global $GRAIN$EXPORT$equal_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"equal\" (func $equal_0 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (block $compile_block.38 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $9 - (i32.load offset=12 - (local.get $6) - ) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (local.set $10 - (i32.or - (i32.shl - (i32.eq - (local.get $9) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.30 - (local.set $11 - (if (result i32) - (i32.shr_u - (local.get $10) - (i32.const 31) - ) - (block $compile_block.10 (result i32) - (i32.const 3) - ) - (block $compile_block.28 (result i32) - (block $compile_store.12 - (local.set $12 - (i32.or - (i32.shl - (i32.eq - (local.get $9) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.11 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $12) - (i32.const 31) - ) - (block $compile_block.26 (result i32) - (block $compile_store.14 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $6) - ) - ) - ) - (block $do_backpatches.13 - ) - ) - (block $compile_store.16 - (local.set $13 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - (i32.const 7) - ) - ) - (block $do_backpatches.15 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $13) - (i32.const 31) - ) - (block $compile_block.19 (result i32) - (drop - (block $compile_set.18 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.25 (result i32) - (block $compile_store.21 - (local.set $14 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - (i32.const 9) - ) - ) - (block $do_backpatches.20 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $14) - (i32.const 31) - ) - (block $compile_block.23 (result i32) - (drop - (block $compile_set.22 (result i32) - (local.set $7 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.24 (result i32) - (i32.const 3) - ) - ) - ) - ) - (block $cleanup.17 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.27 (result i32) - (i32.const 5) - ) - ) - ) - ) - ) - (block $do_backpatches.29 - ) - ) - (block $cleanup.31 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.33_outer (result i32) - (block $switch.33_branch_0 (result i32) - (drop - (block $switch.33_branch_1 (result i32) - (drop - (block $switch.33_branch_2 (result i32) - (drop - (block $switch.33_branch_3 (result i32) - (drop - (block $switch.33_default (result i32) - (br_table $switch.33_branch_1 $switch.33_branch_2 $switch.33_branch_3 $switch.33_default $switch.33_default - (i32.const 0) - (i32.shr_s - (local.get $11) - (i32.const 1) - ) - ) - ) - ) - (br $switch.33_outer - (block $compile_block.37 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.33_outer - (block $compile_block.36 (result i32) - (i32.const 13) - ) - ) - ) - ) - (br $switch.33_outer - (block $compile_block.35 (result i32) - (i32.const 11) - ) - ) - ) - ) - (br $switch.33_outer - (block $compile_block.34 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - ) - ) - ) - ) - (block $cleanup.32 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 1 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 2 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 3) (stack_size_i32 6) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1129) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot b/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot index 95070d1379..c13fe6c722 100644 --- a/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.d048ece0.0.snapshot @@ -1,1024 +1,623 @@ pattern matching › adt_match_5 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1151 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1151 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (local $23 i32) - (local $24 i32) - (local $25 i32) - (local $26 i32) - (local $27 i32) - (local $28 i32) - (local $29 i32) - (local $30 i32) - (local $31 i32) - (local $32 i32) - (local $33 i32) - (local $34 i32) - (local $35 i32) - (block $compile_block.101 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 15) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 13) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_adt.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.15 - (local.set $10 - (block $allocate_adt.13 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=24 - (local.get $0) - (local.get $9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.17 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.19 - (local.set $12 - (i32.const 0) - ) - (block $do_backpatches.18 - ) - ) - (block $compile_store.21 - (local.set $13 - (i32.const 0) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.23 - (local.set $14 - (i32.const 0) - ) - (block $do_backpatches.22 - ) - ) - (block $compile_store.25 - (local.set $15 - (i32.const 0) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.27 - (local.set $16 - (i32.const 0) - ) - (block $do_backpatches.26 - ) - ) - (block $compile_store.29 - (local.set $24 - (i32.load offset=12 - (local.get $10) - ) - ) - (block $do_backpatches.28 - ) - ) - (block $compile_store.31 - (local.set $25 - (i32.or - (i32.shl - (i32.eq - (local.get $24) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.30 - ) - ) - (block $compile_store.87 - (local.set $26 - (if (result i32) - (i32.shr_u - (local.get $25) - (i32.const 31) - ) - (block $compile_block.80 (result i32) - (block $compile_store.33 - (local.set $17 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $10) - ) - ) - ) - (block $do_backpatches.32 - ) - ) - (block $compile_store.35 - (local.set $18 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $10) - ) - ) - ) - (block $do_backpatches.34 - ) - ) - (block $compile_store.37 - (local.set $28 - (i32.load offset=12 - (local.get $18) - ) - ) - (block $do_backpatches.36 - ) - ) - (block $compile_store.39 - (local.set $29 - (i32.or - (i32.shl - (i32.eq - (local.get $28) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.38 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $29) - (i32.const 31) - ) - (block $compile_block.73 (result i32) - (block $compile_store.42 - (local.set $19 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $18) - ) - ) - ) - (block $do_backpatches.41 - ) - ) - (block $compile_store.44 - (local.set $20 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $18) - ) - ) - ) - (block $do_backpatches.43 - ) - ) - (block $compile_store.46 - (local.set $31 - (i32.load offset=12 - (local.get $20) - ) - ) - (block $do_backpatches.45 - ) - ) - (block $compile_store.48 - (local.set $32 - (i32.or - (i32.shl - (i32.eq - (local.get $31) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.47 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $32) - (i32.const 31) - ) - (block $compile_block.65 (result i32) - (block $compile_store.51 - (local.set $21 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $20) - ) - ) - ) - (block $do_backpatches.50 - ) - ) - (block $compile_store.53 - (local.set $22 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $20) - ) - ) - ) - (block $do_backpatches.52 - ) - ) - (block $compile_store.55 - (local.set $34 - (i32.load offset=12 - (local.get $22) - ) - ) - (block $do_backpatches.54 - ) - ) - (block $cleanup.56 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $22) - ) - ) - ) - (block $compile_store.58 - (local.set $35 - (i32.or - (i32.shl - (i32.eq - (local.get $34) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.57 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $35) - (i32.const 31) - ) - (block $compile_block.63 (result i32) - (drop - (block $compile_set.60 (result i32) - (local.set $14 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $17) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.61 (result i32) - (local.set $15 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $19) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.62 (result i32) - (local.set $16 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $21) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 7) - ) - (block $compile_block.64 (result i32) - (i32.const 9) - ) - ) - (block $cleanup.59 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $21) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.72 (result i32) - (block $compile_store.67 - (local.set $33 - (i32.or - (i32.shl - (i32.eq - (local.get $31) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.66 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $33) - (i32.const 31) - ) - (block $compile_block.70 (result i32) - (drop - (block $compile_set.68 (result i32) - (local.set $12 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $17) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.69 (result i32) - (local.set $13 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $19) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 5) - ) - (block $compile_block.71 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.49 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.79 (result i32) - (block $compile_store.75 - (local.set $30 - (i32.or - (i32.shl - (i32.eq - (local.get $28) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.74 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $30) - (i32.const 31) - ) - (block $compile_block.77 (result i32) - (drop - (block $compile_set.76 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $17) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 3) - ) - (block $compile_block.78 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.40 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.85 (result i32) - (block $compile_store.82 - (local.set $27 - (i32.or - (i32.shl - (i32.eq - (local.get $24) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.81 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $27) - (i32.const 31) - ) - (block $compile_block.83 (result i32) - (i32.const 1) - ) - (block $compile_block.84 - (unreachable) - ) - ) - ) - ) - ) - (block $do_backpatches.86 - ) - ) - (block $cleanup.88 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.90_outer (result i32) - (block $switch.90_branch_0 (result i32) - (drop - (block $switch.90_branch_1 (result i32) - (drop - (block $switch.90_branch_2 (result i32) - (drop - (block $switch.90_branch_3 (result i32) - (drop - (block $switch.90_branch_4 (result i32) - (drop - (block $switch.90_branch_5 (result i32) - (drop - (block $switch.90_default (result i32) - (br_table $switch.90_branch_1 $switch.90_branch_2 $switch.90_branch_3 $switch.90_branch_4 $switch.90_branch_5 $switch.90_default $switch.90_default - (i32.const 0) - (i32.shr_s - (local.get $26) - (i32.const 1) - ) - ) - ) - ) - (br $switch.90_outer - (block $compile_block.100 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.90_outer - (block $compile_block.99 (result i32) - (i32.const 1999) - ) - ) - ) - ) - (br $switch.90_outer - (block $compile_block.98 - (block $compile_store.96 - (local.set $23 - (call $+_1151 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $14) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - ) - ) - (block $do_backpatches.95 - ) - ) - (block $cleanup.97 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - ) - (return_call $+_1151 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) - ) - (local.get $23) - (local.get $16) - ) - ) - ) - ) - ) - (br $switch.90_outer - (block $compile_block.94 - (block $cleanup.93 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - ) - (return_call $+_1151 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1151) - ) - (local.get $12) - (local.get $13) - ) - ) - ) - ) - ) - (br $switch.90_outer - (block $compile_block.92 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - ) - ) - ) - (br $switch.90_outer - (block $compile_block.91 (result i32) - (i32.const 1) - ) - ) - ) - ) - (block $cleanup.89 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1151) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1151) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 7))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 13 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 14 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 8 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 15 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 16 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses + ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses + ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc + (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 11 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 10 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 11 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 11 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 13 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 15 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 3))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses + ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 9 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 9 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 11 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 13 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 2))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1151) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1151 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (3 + (((instr_desc + (MStore + (((MLocalBind 17 Managed) + ((instr_desc + (MCallKnown (func +_1151) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1151 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1151) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1151 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (4 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 999))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 18) (stack_size_i32 12) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1154) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.e17bcd61.0.snapshot b/compiler/test/__snapshots__/pattern_matching.e17bcd61.0.snapshot index 36b12463de..a310c53fa1 100644 --- a/compiler/test/__snapshots__/pattern_matching.e17bcd61.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.e17bcd61.0.snapshot @@ -1,127 +1,71 @@ pattern matching › or_match_4 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.14 (result i32) - (block $compile_store.2 - (local.set $6 - (i32.or - (i32.shl - (i32.eq - (i32.const -2) - (i32.const 2147483646) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.10 - (local.set $7 - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.3 (result i32) - (i32.const 1) - ) - (block $compile_block.8 (result i32) - (block $compile_store.5 - (local.set $8 - (i32.or - (i32.shl - (i32.eq - (i32.const -2) - (i32.const -2) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.4 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $8) - (i32.const 31) - ) - (block $compile_block.6 (result i32) - (i32.const 1) - ) - (block $compile_block.7 - (unreachable) - ) - ) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $switch.11_outer (result i32) - (block $switch.11_branch_0 (result i32) - (drop - (block $switch.11_branch_1 (result i32) - (drop - (block $switch.11_default (result i32) - (br_table $switch.11_branch_1 $switch.11_default $switch.11_default - (i32.const 0) - (i32.shr_s - (local.get $7) - (i32.const 1) - ) - ) - ) - ) - (br $switch.11_outer - (block $compile_block.13 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.11_outer - (block $compile_block.12 (result i32) - (i32.const 7) - ) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 3) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1118) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot index 8d2cd1933f..e2f43d7817 100644 --- a/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.e41ad64e.0.snapshot @@ -1,1303 +1,809 @@ pattern matching › tuple_match_deep5 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1155 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1155 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (local $23 i32) - (local $24 i32) - (local $25 i32) - (local $26 i32) - (local $27 i32) - (local $28 i32) - (local $29 i32) - (local $30 i32) - (local $31 i32) - (local $32 i32) - (local $33 i32) - (local $34 i32) - (local $35 i32) - (local $36 i32) - (local $37 i32) - (local $38 i32) - (local $39 i32) - (local $40 i32) - (local $41 i32) - (local $42 i32) - (block $compile_block.120 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_tuple.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.14 - (local.set $10 - (i32.const 0) - ) - (block $do_backpatches.13 - ) - ) - (block $compile_store.16 - (local.set $11 - (i32.const 0) - ) - (block $do_backpatches.15 - ) - ) - (block $compile_store.18 - (local.set $12 - (i32.const 0) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.20 - (local.set $13 - (i32.const 0) - ) - (block $do_backpatches.19 - ) - ) - (block $compile_store.22 - (local.set $14 - (i32.const 0) - ) - (block $do_backpatches.21 - ) - ) - (block $compile_store.24 - (local.set $15 - (i32.const 0) - ) - (block $do_backpatches.23 - ) - ) - (block $compile_store.26 - (local.set $16 - (i32.const 0) - ) - (block $do_backpatches.25 - ) - ) - (block $compile_store.28 - (local.set $17 - (i32.const 0) - ) - (block $do_backpatches.27 - ) - ) - (block $compile_store.30 - (local.set $18 - (i32.const 0) - ) - (block $do_backpatches.29 - ) - ) - (block $compile_store.32 - (local.set $19 - (i32.const 0) - ) - (block $do_backpatches.31 - ) - ) - (block $compile_store.34 - (local.set $20 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $9) - ) - ) - ) - (block $do_backpatches.33 - ) - ) - (block $compile_store.36 - (local.set $21 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $9) - ) - ) - ) - (block $do_backpatches.35 - ) - ) - (block $cleanup.37 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - (block $compile_store.39 - (local.set $31 - (i32.load offset=12 - (local.get $21) - ) - ) - (block $do_backpatches.38 - ) - ) - (block $compile_store.41 - (local.set $32 - (i32.or - (i32.shl - (i32.eq - (local.get $31) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.40 - ) - ) - (block $compile_store.101 - (local.set $33 - (if (result i32) - (i32.shr_u - (local.get $32) - (i32.const 31) - ) - (block $compile_block.93 (result i32) - (block $compile_store.43 - (local.set $22 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $21) - ) - ) - ) - (block $do_backpatches.42 - ) - ) - (block $compile_store.45 - (local.set $23 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $21) - ) - ) - ) - (block $do_backpatches.44 - ) - ) - (block $compile_store.47 - (local.set $35 - (i32.load offset=12 - (local.get $23) - ) - ) - (block $do_backpatches.46 - ) - ) - (block $compile_store.49 - (local.set $36 - (i32.or - (i32.shl - (i32.eq - (local.get $35) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.48 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $36) - (i32.const 31) - ) - (block $compile_block.85 (result i32) - (block $compile_store.52 - (local.set $24 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $23) - ) - ) - ) - (block $do_backpatches.51 - ) - ) - (block $compile_store.54 - (local.set $25 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $23) - ) - ) - ) - (block $do_backpatches.53 - ) - ) - (block $compile_store.56 - (local.set $38 - (i32.load offset=12 - (local.get $25) - ) - ) - (block $do_backpatches.55 - ) - ) - (block $compile_store.58 - (local.set $39 - (i32.or - (i32.shl - (i32.eq - (local.get $38) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.57 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $39) - (i32.const 31) - ) - (block $compile_block.76 (result i32) - (block $compile_store.61 - (local.set $26 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $25) - ) - ) - ) - (block $do_backpatches.60 - ) - ) - (block $compile_store.63 - (local.set $27 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $25) - ) - ) - ) - (block $do_backpatches.62 - ) - ) - (block $compile_store.65 - (local.set $41 - (i32.load offset=12 - (local.get $27) - ) - ) - (block $do_backpatches.64 - ) - ) - (block $cleanup.66 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $27) - ) - ) - ) - (block $compile_store.68 - (local.set $42 - (i32.or - (i32.shl - (i32.eq - (local.get $41) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.67 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $42) - (i32.const 31) - ) - (block $compile_block.74 (result i32) - (drop - (block $compile_set.70 (result i32) - (local.set $16 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $20) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.71 (result i32) - (local.set $17 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $22) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.72 (result i32) - (local.set $18 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $24) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.73 (result i32) - (local.set $19 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $26) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 7) - ) - (block $compile_block.75 (result i32) - (i32.const 9) - ) - ) - (block $cleanup.69 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $26) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.84 (result i32) - (block $compile_store.78 - (local.set $40 - (i32.or - (i32.shl - (i32.eq - (local.get $38) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.77 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $40) - (i32.const 31) - ) - (block $compile_block.82 (result i32) - (drop - (block $compile_set.79 (result i32) - (local.set $13 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $20) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.80 (result i32) - (local.set $14 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $22) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.81 (result i32) - (local.set $15 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $24) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 5) - ) - (block $compile_block.83 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.59 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $24) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $25) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.92 (result i32) - (block $compile_store.87 - (local.set $37 - (i32.or - (i32.shl - (i32.eq - (local.get $35) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.86 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $37) - (i32.const 31) - ) - (block $compile_block.90 (result i32) - (drop - (block $compile_set.88 (result i32) - (local.set $11 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $20) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.89 (result i32) - (local.set $12 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $22) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 3) - ) - (block $compile_block.91 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.50 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $22) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $23) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.99 (result i32) - (block $compile_store.95 - (local.set $34 - (i32.or - (i32.shl - (i32.eq - (local.get $31) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.94 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $34) - (i32.const 31) - ) - (block $compile_block.97 (result i32) - (drop - (block $compile_set.96 (result i32) - (local.set $10 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $20) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.98 - (unreachable) - ) - ) - ) - ) - ) - (block $do_backpatches.100 - ) - ) - (block $cleanup.102 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $21) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.104_outer (result i32) - (block $switch.104_branch_0 (result i32) - (drop - (block $switch.104_branch_1 (result i32) - (drop - (block $switch.104_branch_2 (result i32) - (drop - (block $switch.104_branch_3 (result i32) - (drop - (block $switch.104_branch_4 (result i32) - (drop - (block $switch.104_branch_5 (result i32) - (drop - (block $switch.104_default (result i32) - (br_table $switch.104_branch_1 $switch.104_branch_2 $switch.104_branch_3 $switch.104_branch_4 $switch.104_branch_5 $switch.104_default $switch.104_default - (i32.const 0) - (i32.shr_s - (local.get $33) - (i32.const 1) - ) - ) - ) - ) - (br $switch.104_outer - (block $compile_block.119 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.104_outer - (block $compile_block.118 (result i32) - (i32.const 1999) - ) - ) - ) - ) - (br $switch.104_outer - (block $compile_block.117 - (block $compile_store.113 - (local.set $29 - (call $+_1155 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $16) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $17) - ) - ) - ) - (block $do_backpatches.112 - ) - ) - (block $compile_store.115 - (local.set $30 - (call $+_1155 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) - ) - (local.get $29) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $18) - ) - ) - ) - (block $do_backpatches.114 - ) - ) - (block $cleanup.116 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - ) - (return_call $+_1155 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) - ) - (local.get $30) - (local.get $19) - ) - ) - ) - ) - ) - (br $switch.104_outer - (block $compile_block.111 - (block $compile_store.109 - (local.set $28 - (call $+_1155 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $14) - ) - ) - ) - (block $do_backpatches.108 - ) - ) - (block $cleanup.110 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - ) - (return_call $+_1155 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) - ) - (local.get $28) - (local.get $15) - ) - ) - ) - ) - ) - (br $switch.104_outer - (block $compile_block.107 - (block $cleanup.106 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - ) - (return_call $+_1155 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1155) - ) - (local.get $11) - (local.get $12) - ) - ) - ) - ) - ) - (br $switch.104_outer - (block $compile_block.105 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - ) - ) - ) - ) - (block $cleanup.103 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1155) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1155) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 13 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 14 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 15 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 16 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 17 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 18 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 19 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 8 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 20 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 21 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses + ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 21 Managed))) + (immediate_analyses + ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc + (MImmBinding (MLocalBind 21 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 11 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 10 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 11 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 14 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 11 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 16 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 12 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 18 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 13 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 20 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 3))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 20 Managed))) + (immediate_analyses + ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 9 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 9 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 14 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 16 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 18 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 2))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 4 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1155) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1155 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (2 + (((instr_desc + (MStore + (((MLocalBind 22 Managed) + ((instr_desc + (MCallKnown (func +_1155) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1155 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1155) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1155 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 22 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (3 + (((instr_desc + (MStore + (((MLocalBind 23 Managed) + ((instr_desc + (MCallKnown (func +_1155) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1155 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 24 Managed) + ((instr_desc + (MCallKnown (func +_1155) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1155 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 23 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1155) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1155 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 24 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (4 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 999))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 25) (stack_size_i32 12) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1160) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.eb4334e1.0.snapshot b/compiler/test/__snapshots__/pattern_matching.eb4334e1.0.snapshot index 5904371f3e..1980cf68ab 100644 --- a/compiler/test/__snapshots__/pattern_matching.eb4334e1.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.eb4334e1.0.snapshot @@ -1,473 +1,277 @@ pattern matching › constant_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)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"GRAIN$EXPORT$equal\" (global $GRAIN$EXPORT$equal_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1126 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"equal\" (func $equal_0 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1126 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (block $compile_block.49 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (local.get $6) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 11) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $9 - (i32.const 0) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $7) - ) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.14 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $7) - ) - ) - ) - (block $do_backpatches.13 - ) - ) - (block $cleanup.15 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (block $compile_store.18 - (local.set $12 - (block $allocate_string.16 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.20 - (local.set $13 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (local.get $10) - (local.get $12) - ) - ) - (block $do_backpatches.19 - ) - ) - (block $compile_store.40 - (local.set $14 - (if (result i32) - (i32.shr_u - (local.get $13) - (i32.const 31) - ) - (block $compile_block.37 (result i32) - (drop - (block $compile_set.21 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.23 - (local.set $15 - (call $==_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1126) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - (i32.const 15) - ) - ) - (block $do_backpatches.22 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $15) - (i32.const 31) - ) - (block $compile_block.25 (result i32) - (drop - (block $compile_set.24 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.36 (result i32) - (block $compile_store.27 - (local.set $16 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - (i32.const 19) - ) - ) - (block $do_backpatches.26 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $16) - (i32.const 31) - ) - (block $compile_block.28 (result i32) - (i32.const 3) - ) - (block $compile_block.35 (result i32) - (drop - (block $compile_set.29 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.31 - (local.set $17 - (call $==_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1126) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (i32.const 11) - ) - ) - (block $do_backpatches.30 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $17) - (i32.const 31) - ) - (block $compile_block.33 (result i32) - (drop - (block $compile_set.32 (result i32) - (local.set $9 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 5) - ) - (block $compile_block.34 (result i32) - (i32.const 7) - ) - ) - ) - ) - ) - ) - ) - (block $compile_block.38 (result i32) - (i32.const 7) - ) - ) - ) - (block $do_backpatches.39 - ) - ) - (block $cleanup.41 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.43_outer (result i32) - (block $switch.43_branch_0 (result i32) - (drop - (block $switch.43_branch_1 (result i32) - (drop - (block $switch.43_branch_2 (result i32) - (drop - (block $switch.43_branch_3 (result i32) - (drop - (block $switch.43_branch_4 (result i32) - (drop - (block $switch.43_default (result i32) - (br_table $switch.43_branch_1 $switch.43_branch_2 $switch.43_branch_3 $switch.43_branch_4 $switch.43_default $switch.43_default - (i32.const 0) - (i32.shr_s - (local.get $14) - (i32.const 1) - ) - ) - ) - ) - (br $switch.43_outer - (block $compile_block.48 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.43_outer - (block $compile_block.47 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.43_outer - (block $compile_block.46 (result i32) - (i32.const -2) - ) - ) - ) - ) - (br $switch.43_outer - (block $compile_block.45 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.43_outer - (block $compile_block.44 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (block $cleanup.42 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1126) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1126) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString foo))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) ((instr_desc (MAllocate (MString foo))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func ==_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind ==_1126 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 7))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 9))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MCallKnown (func ==_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MGlobalBind ==_1126 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type + ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 3 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (3 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + (Unmanaged WasmI32))))) + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 7) (stack_size_i32 5) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1135) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot b/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot index 2a8dc8d2f8..8e6d5272a4 100644 --- a/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.f0c08ea4.0.snapshot @@ -1,1389 +1,841 @@ pattern matching › tuple_match_deep7 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1159 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1159 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (local $23 i32) - (local $24 i32) - (local $25 i32) - (local $26 i32) - (local $27 i32) - (local $28 i32) - (local $29 i32) - (local $30 i32) - (local $31 i32) - (local $32 i32) - (local $33 i32) - (local $34 i32) - (local $35 i32) - (local $36 i32) - (local $37 i32) - (local $38 i32) - (local $39 i32) - (local $40 i32) - (local $41 i32) - (local $42 i32) - (local $43 i32) - (local $44 i32) - (block $compile_block.126 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 15) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 13) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_adt.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.15 - (local.set $10 - (block $allocate_adt.13 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=24 - (local.get $0) - (local.get $9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.18 - (local.set $11 - (block $allocate_tuple.16 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (local.get $10) - ) - (local.get $0) - ) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.20 - (local.set $12 - (i32.const 0) - ) - (block $do_backpatches.19 - ) - ) - (block $compile_store.22 - (local.set $13 - (i32.const 0) - ) - (block $do_backpatches.21 - ) - ) - (block $compile_store.24 - (local.set $14 - (i32.const 0) - ) - (block $do_backpatches.23 - ) - ) - (block $compile_store.26 - (local.set $15 - (i32.const 0) - ) - (block $do_backpatches.25 - ) - ) - (block $compile_store.28 - (local.set $16 - (i32.const 0) - ) - (block $do_backpatches.27 - ) - ) - (block $compile_store.30 - (local.set $17 - (i32.const 0) - ) - (block $do_backpatches.29 - ) - ) - (block $compile_store.32 - (local.set $18 - (i32.const 0) - ) - (block $do_backpatches.31 - ) - ) - (block $compile_store.34 - (local.set $19 - (i32.const 0) - ) - (block $do_backpatches.33 - ) - ) - (block $compile_store.36 - (local.set $20 - (i32.const 0) - ) - (block $do_backpatches.35 - ) - ) - (block $compile_store.38 - (local.set $21 - (i32.const 0) - ) - (block $do_backpatches.37 - ) - ) - (block $compile_store.40 - (local.set $22 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $11) - ) - ) - ) - (block $do_backpatches.39 - ) - ) - (block $compile_store.42 - (local.set $23 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $11) - ) - ) - ) - (block $do_backpatches.41 - ) - ) - (block $cleanup.43 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - (block $compile_store.45 - (local.set $33 - (i32.load offset=12 - (local.get $23) - ) - ) - (block $do_backpatches.44 - ) - ) - (block $compile_store.47 - (local.set $34 - (i32.or - (i32.shl - (i32.eq - (local.get $33) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.46 - ) - ) - (block $compile_store.107 - (local.set $35 - (if (result i32) - (i32.shr_u - (local.get $34) - (i32.const 31) - ) - (block $compile_block.99 (result i32) - (block $compile_store.49 - (local.set $24 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $23) - ) - ) - ) - (block $do_backpatches.48 - ) - ) - (block $compile_store.51 - (local.set $25 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $23) - ) - ) - ) - (block $do_backpatches.50 - ) - ) - (block $compile_store.53 - (local.set $37 - (i32.load offset=12 - (local.get $25) - ) - ) - (block $do_backpatches.52 - ) - ) - (block $compile_store.55 - (local.set $38 - (i32.or - (i32.shl - (i32.eq - (local.get $37) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.54 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $38) - (i32.const 31) - ) - (block $compile_block.91 (result i32) - (block $compile_store.58 - (local.set $26 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $25) - ) - ) - ) - (block $do_backpatches.57 - ) - ) - (block $compile_store.60 - (local.set $27 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $25) - ) - ) - ) - (block $do_backpatches.59 - ) - ) - (block $compile_store.62 - (local.set $40 - (i32.load offset=12 - (local.get $27) - ) - ) - (block $do_backpatches.61 - ) - ) - (block $compile_store.64 - (local.set $41 - (i32.or - (i32.shl - (i32.eq - (local.get $40) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.63 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $41) - (i32.const 31) - ) - (block $compile_block.82 (result i32) - (block $compile_store.67 - (local.set $28 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $27) - ) - ) - ) - (block $do_backpatches.66 - ) - ) - (block $compile_store.69 - (local.set $29 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $27) - ) - ) - ) - (block $do_backpatches.68 - ) - ) - (block $compile_store.71 - (local.set $43 - (i32.load offset=12 - (local.get $29) - ) - ) - (block $do_backpatches.70 - ) - ) - (block $cleanup.72 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $29) - ) - ) - ) - (block $compile_store.74 - (local.set $44 - (i32.or - (i32.shl - (i32.eq - (local.get $43) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.73 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $44) - (i32.const 31) - ) - (block $compile_block.80 (result i32) - (drop - (block $compile_set.76 (result i32) - (local.set $18 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $22) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.77 (result i32) - (local.set $19 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $24) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.78 (result i32) - (local.set $20 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $26) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.79 (result i32) - (local.set $21 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $28) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $21) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 7) - ) - (block $compile_block.81 (result i32) - (i32.const 9) - ) - ) - (block $cleanup.75 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $28) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.90 (result i32) - (block $compile_store.84 - (local.set $42 - (i32.or - (i32.shl - (i32.eq - (local.get $40) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.83 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $42) - (i32.const 31) - ) - (block $compile_block.88 (result i32) - (drop - (block $compile_set.85 (result i32) - (local.set $15 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $22) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.86 (result i32) - (local.set $16 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $24) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.87 (result i32) - (local.set $17 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $26) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 5) - ) - (block $compile_block.89 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.65 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $26) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $27) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.98 (result i32) - (block $compile_store.93 - (local.set $39 - (i32.or - (i32.shl - (i32.eq - (local.get $37) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.92 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $39) - (i32.const 31) - ) - (block $compile_block.96 (result i32) - (drop - (block $compile_set.94 (result i32) - (local.set $13 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $22) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.95 (result i32) - (local.set $14 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $24) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 3) - ) - (block $compile_block.97 (result i32) - (i32.const 9) - ) - ) - ) - ) - (block $cleanup.56 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $24) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $25) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.105 (result i32) - (block $compile_store.101 - (local.set $36 - (i32.or - (i32.shl - (i32.eq - (local.get $33) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.100 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $36) - (i32.const 31) - ) - (block $compile_block.103 (result i32) - (drop - (block $compile_set.102 (result i32) - (local.set $12 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $22) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.104 - (unreachable) - ) - ) - ) - ) - ) - (block $do_backpatches.106 - ) - ) - (block $cleanup.108 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $22) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $23) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.110_outer (result i32) - (block $switch.110_branch_0 (result i32) - (drop - (block $switch.110_branch_1 (result i32) - (drop - (block $switch.110_branch_2 (result i32) - (drop - (block $switch.110_branch_3 (result i32) - (drop - (block $switch.110_branch_4 (result i32) - (drop - (block $switch.110_branch_5 (result i32) - (drop - (block $switch.110_default (result i32) - (br_table $switch.110_branch_1 $switch.110_branch_2 $switch.110_branch_3 $switch.110_branch_4 $switch.110_branch_5 $switch.110_default $switch.110_default - (i32.const 0) - (i32.shr_s - (local.get $35) - (i32.const 1) - ) - ) - ) - ) - (br $switch.110_outer - (block $compile_block.125 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.110_outer - (block $compile_block.124 (result i32) - (i32.const 1999) - ) - ) - ) - ) - (br $switch.110_outer - (block $compile_block.123 - (block $compile_store.119 - (local.set $31 - (call $+_1159 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1159) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $18) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $19) - ) - ) - ) - (block $do_backpatches.118 - ) - ) - (block $compile_store.121 - (local.set $32 - (call $+_1159 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1159) - ) - (local.get $31) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $20) - ) - ) - ) - (block $do_backpatches.120 - ) - ) - (block $cleanup.122 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - ) - (return_call $+_1159 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1159) - ) - (local.get $32) - (local.get $21) - ) - ) - ) - ) - ) - (br $switch.110_outer - (block $compile_block.117 - (block $compile_store.115 - (local.set $30 - (call $+_1159 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1159) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $15) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $16) - ) - ) - ) - (block $do_backpatches.114 - ) - ) - (block $cleanup.116 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $21) - ) - ) - ) - (return_call $+_1159 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1159) - ) - (local.get $30) - (local.get $17) - ) - ) - ) - ) - ) - (br $switch.110_outer - (block $compile_block.113 - (block $cleanup.112 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $21) - ) - ) - ) - (return_call $+_1159 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1159) - ) - (local.get $13) - (local.get $14) - ) - ) - ) - ) - ) - (br $switch.110_outer - (block $compile_block.111 (result i32) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - ) - ) - ) - ) - (block $cleanup.109 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $14) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $15) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $16) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $17) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $18) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $19) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $20) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $21) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1159) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1159) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 7))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 11 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 12 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 13 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 14 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 15 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 16 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 17 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 18 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 19 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 20 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 21 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 21 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 8 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 8 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 22 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 21 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 23 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 21 Managed))) + (immediate_analyses + ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 10 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 23 Managed))) + (immediate_analyses + ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc + (MImmBinding (MLocalBind 23 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 11 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 10 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 11 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 12 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 16 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 13 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 18 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 14 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 20 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 15 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 22 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 3))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 22 Managed))) + (immediate_analyses + ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 9 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 9 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 9 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 16 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 10 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 18 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 11 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 20 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 2))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 21 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmBinding (MLocalBind 20 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 7 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 8 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 19 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 18 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 6 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 17 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 16 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1159) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1159 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (2 + (((instr_desc + (MStore + (((MLocalBind 24 Managed) + ((instr_desc + (MCallKnown (func +_1159) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1159 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1159) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1159 Managed))) + (immediate_analyses ((last_usage TailCallLast)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 24 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (3 + (((instr_desc + (MStore + (((MLocalBind 25 Managed) + ((instr_desc + (MCallKnown (func +_1159) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1159 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 26 Managed) + ((instr_desc + (MCallKnown (func +_1159) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1159 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MImmBinding (MLocalBind 25 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1159) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind +_1159 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 26 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (4 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 999))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed)))) + (((immediate_desc (MImmBinding (MLocalBind 15 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 14 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 13 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 12 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 11 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 10 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 9 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 8 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 27) (stack_size_i32 12) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1164) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.f25e0163.0.snapshot b/compiler/test/__snapshots__/pattern_matching.f25e0163.0.snapshot index efc203dd12..384d943bbc 100644 --- a/compiler/test/__snapshots__/pattern_matching.f25e0163.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.f25e0163.0.snapshot @@ -1,579 +1,353 @@ pattern matching › or_match_3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (local $23 i32) - (local $24 i32) - (block $compile_block.65 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $8 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $14 - (i32.load offset=12 - (local.get $7) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $compile_store.12 - (local.set $15 - (i32.or - (i32.shl - (i32.eq - (local.get $14) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.58 - (local.set $16 - (if (result i32) - (i32.shr_u - (local.get $15) - (i32.const 31) - ) - (block $compile_block.55 (result i32) - (block $compile_store.14 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $7) - ) - ) - ) - (block $do_backpatches.13 - ) - ) - (block $compile_store.16 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $7) - ) - ) - ) - (block $do_backpatches.15 - ) - ) - (block $compile_store.18 - (local.set $17 - (i32.load offset=12 - (local.get $10) - ) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.20 - (local.set $18 - (i32.or - (i32.shl - (i32.eq - (local.get $17) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.19 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $18) - (i32.const 31) - ) - (block $compile_block.48 (result i32) - (block $compile_store.23 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $10) - ) - ) - ) - (block $do_backpatches.22 - ) - ) - (block $compile_store.25 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $10) - ) - ) - ) - (block $do_backpatches.24 - ) - ) - (block $compile_store.27 - (local.set $20 - (i32.load offset=12 - (local.get $12) - ) - ) - (block $do_backpatches.26 - ) - ) - (block $compile_store.29 - (local.set $21 - (i32.or - (i32.shl - (i32.eq - (local.get $20) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.28 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $21) - (i32.const 31) - ) - (block $compile_block.41 (result i32) - (block $compile_store.32 - (local.set $13 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $12) - ) - ) - ) - (block $do_backpatches.31 - ) - ) - (block $compile_store.34 - (local.set $23 - (i32.load offset=12 - (local.get $13) - ) - ) - (block $do_backpatches.33 - ) - ) - (block $cleanup.35 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $13) - ) - ) - ) - (block $compile_store.37 - (local.set $24 - (i32.or - (i32.shl - (i32.eq - (local.get $23) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.36 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $24) - (i32.const 31) - ) - (block $compile_block.39 (result i32) - (drop - (block $compile_set.38 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $11) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.40 (result i32) - (i32.const 3) - ) - ) - ) - (block $compile_block.47 (result i32) - (block $compile_store.43 - (local.set $22 - (i32.or - (i32.shl - (i32.eq - (local.get $20) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.42 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $22) - (i32.const 31) - ) - (block $compile_block.45 (result i32) - (drop - (block $compile_set.44 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.46 (result i32) - (i32.const 3) - ) - ) - ) - ) - (block $cleanup.30 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $12) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.54 (result i32) - (block $compile_store.50 - (local.set $19 - (i32.or - (i32.shl - (i32.eq - (local.get $17) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.49 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $19) - (i32.const 31) - ) - (block $compile_block.52 (result i32) - (drop - (block $compile_set.51 (result i32) - (local.set $8 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - (block $compile_block.53 (result i32) - (i32.const 3) - ) - ) - ) - ) - (block $cleanup.21 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $10) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.56 (result i32) - (i32.const 3) - ) - ) - ) - (block $do_backpatches.57 - ) - ) - (block $cleanup.59 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (block $switch.61_outer (result i32) - (block $switch.61_branch_0 (result i32) - (drop - (block $switch.61_branch_1 (result i32) - (drop - (block $switch.61_branch_2 (result i32) - (drop - (block $switch.61_default (result i32) - (br_table $switch.61_branch_1 $switch.61_branch_2 $switch.61_default $switch.61_default - (i32.const 0) - (i32.shr_s - (local.get $16) - (i32.const 1) - ) - ) - ) - ) - (br $switch.61_outer - (block $compile_block.64 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.61_outer - (block $compile_block.63 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.61_outer - (block $compile_block.62 (result i32) - (i32.const -2) - ) - ) - ) - ) - (block $cleanup.60 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 7 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MAdtOp (MAdtGet 1) + ((immediate_desc + (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses + ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 9 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc + (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses + ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc + (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses + ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 10 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 9 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 10 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 5 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 0))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + (((instr_desc + (MStore + (((MLocalBind 8 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses + ((last_usage Last)))) + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 8 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 3 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 0))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))) + (((immediate_desc + (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding + (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MDrop + ((instr_desc + (MSet (MLocalBind 2 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MSwitch + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + (Unmanaged WasmI32))))) + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 8) (stack_size_i32 11) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1140) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.f3d48b0e.0.snapshot b/compiler/test/__snapshots__/pattern_matching.f3d48b0e.0.snapshot index a84858cc74..cac7a6b370 100644 --- a/compiler/test/__snapshots__/pattern_matching.f3d48b0e.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.f3d48b0e.0.snapshot @@ -1,127 +1,71 @@ pattern matching › or_match_1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.14 (result i32) - (block $compile_store.2 - (local.set $6 - (i32.or - (i32.shl - (i32.eq - (i32.const -2) - (i32.const 2147483646) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.1 - ) - ) - (block $compile_store.10 - (local.set $7 - (if (result i32) - (i32.shr_u - (local.get $6) - (i32.const 31) - ) - (block $compile_block.3 (result i32) - (i32.const 1) - ) - (block $compile_block.8 (result i32) - (block $compile_store.5 - (local.set $8 - (i32.or - (i32.shl - (i32.eq - (i32.const -2) - (i32.const -2) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.4 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $8) - (i32.const 31) - ) - (block $compile_block.6 (result i32) - (i32.const 1) - ) - (block $compile_block.7 - (unreachable) - ) - ) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $switch.11_outer (result i32) - (block $switch.11_branch_0 (result i32) - (drop - (block $switch.11_branch_1 (result i32) - (drop - (block $switch.11_default (result i32) - (br_table $switch.11_branch_1 $switch.11_default $switch.11_default - (i32.const 0) - (i32.shr_s - (local.get $7) - (i32.const 1) - ) - ) - ) - ) - (br $switch.11_outer - (block $compile_block.13 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.11_outer - (block $compile_block.12 (result i32) - (i32.const 7) - ) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + Managed))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 3) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1118) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/pattern_matching.f6c9c89c.0.snapshot b/compiler/test/__snapshots__/pattern_matching.f6c9c89c.0.snapshot index d8eaa83cbf..19495acb67 100644 --- a/compiler/test/__snapshots__/pattern_matching.f6c9c89c.0.snapshot +++ b/compiler/test/__snapshots__/pattern_matching.f6c9c89c.0.snapshot @@ -1,325 +1,199 @@ pattern matching › or_match_2 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"GRAIN$EXPORT$equal\" (global $GRAIN$EXPORT$equal_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/equal.gr\" \"equal\" (func $equal_0 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (block $compile_block.37 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $8 - (i32.load offset=12 - (local.get $6) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $9 - (i32.or - (i32.shl - (i32.eq - (local.get $8) - (i32.const 3) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.30 - (local.set $10 - (if (result i32) - (i32.shr_u - (local.get $9) - (i32.const 31) - ) - (block $compile_block.8 (result i32) - (i32.const 3) - ) - (block $compile_block.28 (result i32) - (block $compile_store.10 - (local.set $11 - (i32.or - (i32.shl - (i32.eq - (local.get $8) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - ) - (block $do_backpatches.9 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $11) - (i32.const 31) - ) - (block $compile_block.26 (result i32) - (block $compile_store.12 - (local.set $7 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $6) - ) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.14 - (local.set $12 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (i32.const 7) - ) - ) - (block $do_backpatches.13 - ) - ) - (tuple.extract 0 - (tuple.make - (if (result i32) - (i32.shr_u - (local.get $12) - (i32.const 31) - ) - (block $compile_block.16 (result i32) - (i32.const 1) - ) - (block $compile_block.25 (result i32) - (block $compile_store.18 - (local.set $13 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (i32.const 9) - ) - ) - (block $do_backpatches.17 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $13) - (i32.const 31) - ) - (block $compile_block.19 (result i32) - (i32.const 1) - ) - (block $compile_block.24 (result i32) - (block $compile_store.21 - (local.set $14 - (call $equal_0 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $GRAIN$EXPORT$equal_0) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (i32.const 11) - ) - ) - (block $do_backpatches.20 - ) - ) - (if (result i32) - (i32.shr_u - (local.get $14) - (i32.const 31) - ) - (block $compile_block.22 (result i32) - (i32.const 3) - ) - (block $compile_block.23 (result i32) - (i32.const 5) - ) - ) - ) - ) - ) - ) - (block $cleanup.15 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - (block $compile_block.27 (result i32) - (i32.const 5) - ) - ) - ) - ) - ) - (block $do_backpatches.29 - ) - ) - (block $cleanup.31 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (block $switch.32_outer (result i32) - (block $switch.32_branch_0 (result i32) - (drop - (block $switch.32_branch_1 (result i32) - (drop - (block $switch.32_branch_2 (result i32) - (drop - (block $switch.32_branch_3 (result i32) - (drop - (block $switch.32_default (result i32) - (br_table $switch.32_branch_1 $switch.32_branch_2 $switch.32_branch_3 $switch.32_default $switch.32_default - (i32.const 0) - (i32.shr_s - (local.get $10) - (i32.const 1) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.36 (result i32) - (unreachable) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.35 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.34 (result i32) - (i32.const -2) - ) - ) - ) - ) - (br $switch.32_outer - (block $compile_block.33 (result i32) - (i32.const 2147483646) - ) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MAdtOp MAdtGetTag + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 (Unmanaged WasmI32)) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 1 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 3 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Is + ((immediate_desc + (MImmBinding (MLocalBind 0 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 3 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAdtOp (MAdtGet 0) + ((immediate_desc + (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MIf + ((immediate_desc + (MImmBinding (MLocalBind 4 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 5 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses + ((last_usage Unknown)))))) + (immediate_analyses + ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 5 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))))))) + (((instr_desc + (MStore + (((MLocalBind 6 (Unmanaged WasmI32)) + ((instr_desc + (MPrim2 Eq + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding + (MLocalBind 1 Managed))) + (immediate_analyses + ((last_usage Last)))))) + (immediate_analyses + ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstI32 5))) + (immediate_analyses + ((last_usage Unknown)))))))))))) + ((instr_desc + (MIf + ((immediate_desc + (MImmBinding + (MLocalBind 6 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 1))) + (immediate_analyses + ((last_usage Unknown)))))))) + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstI32 2))) + (immediate_analyses + ((last_usage Unknown)))))))))))))))))))) + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown))))))))) + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MSwitch + ((immediate_desc (MImmBinding (MLocalBind 2 (Unmanaged WasmI32)))) + (immediate_analyses ((last_usage Last)))) + ((0 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))) + (1 + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))) + (2 + (((instr_desc + (MImmediate + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))) + (((instr_desc + (MImmediate + ((immediate_desc MImmTrap) + (immediate_analyses ((last_usage Unknown)))))))) + (Unmanaged WasmI32)))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 7) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1128) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/provides.0ef7e7b3.0.snapshot b/compiler/test/__snapshots__/provides.0ef7e7b3.0.snapshot index abec48340f..69979171ff 100644 --- a/compiler/test/__snapshots__/provides.0ef7e7b3.0.snapshot +++ b/compiler/test/__snapshots__/provides.0ef7e7b3.0.snapshot @@ -1,36 +1,20 @@ provides › provide7 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$x\" (global $x_1122 (mut i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (global.get $x_1122) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 421 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1122) (name x))) (mimp_mod provideAll.gr) + (mimp_name x) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind x_1122 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1123) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/provides.10f4f118.0.snapshot b/compiler/test/__snapshots__/provides.10f4f118.0.snapshot index 15e820e4fa..949e63e696 100644 --- a/compiler/test/__snapshots__/provides.10f4f118.0.snapshot +++ b/compiler/test/__snapshots__/provides.10f4f118.0.snapshot @@ -1,50 +1,39 @@ provides › provide9 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$z\" (global $z_1123 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$y\" (global $y_1122 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"y\" (func $y_1122 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $y_1122 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $y_1122) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $z_1123) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 421 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1123) (name z))) (mimp_mod provideAll.gr) + (mimp_name z) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((stamp 1122) (name y))) (mimp_mod provideAll.gr) + (mimp_name y) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1122) (name y))) (mimp_mod provideAll.gr) + (mimp_name y) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func y_1122) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind y_1122 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind z_1123 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1124) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/provides.2a5f527b.0.snapshot b/compiler/test/__snapshots__/provides.2a5f527b.0.snapshot index ce34cf02ec..1b1f9d048c 100644 --- a/compiler/test/__snapshots__/provides.2a5f527b.0.snapshot +++ b/compiler/test/__snapshots__/provides.2a5f527b.0.snapshot @@ -1,45 +1,30 @@ provides › multiple_provides_8 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"GRAIN$EXPORT$bar\" (global $foo_1113)) - (export \"GRAIN$EXPORT$foo\" (global $foo_1113)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.3 (result i32) - (block $compile_store.2 - (global.set $foo_1113 - (i32.const 3) - ) - (block $do_backpatches.1 - ) - ) - (i32.const 1879048190) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1435 -) +((mash_code + ((functions ()) (imports ()) + (exports + ((WasmGlobalExport (ex_global_name bar) + (ex_global_internal_name foo_1113)) + (WasmGlobalExport (ex_global_name foo) + (ex_global_internal_name foo_1113)))) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((stamp 1113) (name foo))) (mutable_ true) + (allocation_type Managed) (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1117) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/provides.30cbc409.0.snapshot b/compiler/test/__snapshots__/provides.30cbc409.0.snapshot index 2da57f3f21..f0df44a129 100644 --- a/compiler/test/__snapshots__/provides.30cbc409.0.snapshot +++ b/compiler/test/__snapshots__/provides.30cbc409.0.snapshot @@ -1,213 +1,116 @@ provides › provide_start_function -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1115 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1115 (param i32 i32 i32) (result i32))) - (global $_start_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_start\" (func $_start_1113)) - (export \"GRAIN$EXPORT$_start\" (global $_start_1113)) - (export \"_gmain\" (func $_gmain)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_start_1113 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (local $7 i32) - (local $8 i32) - (block $compile_block.8 - (block $compile_store.3 - (local.set $7 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $1 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $1) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $1) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $1) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $1) - (i32.const 0) - ) - (local.get $1) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $8 - (block $allocate_string.4 (result i32) - (i32.store - (local.tee $1 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $1) - (i32.const 11) - ) - (i64.store offset=8 - (local.get $1) - (i64.const 7453010382200861811) - ) - (i64.store offset=16 - (local.get $1) - (i64.const 7370016) - ) - (local.get $1) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $cleanup.7 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - ) - (return_call $print_1115 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1115) - ) - (local.get $8) - (local.get $7) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.17 (result i32) - (block $compile_store.11 - (local.set $6 - (block $allocate_adt.9 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.14 - (local.set $7 - (block $allocate_string.12 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 1953066601) - ) - (local.get $0) - ) - ) - (block $do_backpatches.13 - ) - ) - (drop - (call $print_1115 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1115) - ) - (local.get $7) - (local.get $6) - ) - ) - (block $compile_store.16 - (global.set $_start_1113 - (i32.const 0) - ) - (block $do_backpatches.15 - ) - ) - (i32.const 1879048190) - ) - ) - ;; custom section \"cmi\", size 1021 -) +((mash_code + ((functions + (((id ((stamp 1113) (name _start))) (name (_start)) (args (Managed)) + (return_type ((Unmanaged WasmI32))) (closure ()) + (body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc (MAllocate (MString \"starting up\"))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func print_1115) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1115 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((stamp 1115) (name print))) (mimp_mod pervasives.gr) + (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1115) (name print))) (mimp_mod pervasives.gr) + (mimp_name print) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports + ((WasmFunctionExport (ex_function_name _start) + (ex_function_internal_name _start_1113)) + (WasmGlobalExport (ex_global_name _start) + (ex_global_internal_name _start_1113)))) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) ((instr_desc (MAllocate (MString init))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MCallKnown (func print_1115) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1115 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind _start_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((stamp 1113) (name _start))) (mutable_ true) + (allocation_type Managed) (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1120) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/provides.82c10ab4.0.snapshot b/compiler/test/__snapshots__/provides.82c10ab4.0.snapshot index 10189488d5..e750ee32c8 100644 --- a/compiler/test/__snapshots__/provides.82c10ab4.0.snapshot +++ b/compiler/test/__snapshots__/provides.82c10ab4.0.snapshot @@ -1,186 +1,95 @@ provides › provide12 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$print\" (global $print_1203 (mut i32))) - (import \"GRAIN$MODULE$providedType.gr\" \"GRAIN$EXPORT$apply\" (global $apply_1201 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"print\" (func $print_1203 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$providedType.gr\" \"apply\" (func $apply_1201 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 1)) - (memory $0 0) - (elem $elem (global.get $relocBase_0) $lam_lambda_1202) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $lam_lambda_1202 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - (local $6 f32) - (local $7 f64) - (local $8 i32) - (local $9 i32) - (block $closure_elements.17 - (block $compile_block.16 - (block $compile_store.11 - (local.set $8 - (block $allocate_adt.9 (result i32) - (i32.store - (local.tee $2 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $2) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $2) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $2) - (i32.const 0) - ) - (local.get $2) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.14 - (local.set $9 - (block $allocate_string.12 (result i32) - (i32.store - (local.tee $2 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $2) - (i32.const 2) - ) - (i64.store offset=8 - (local.get $2) - (i64.const 27503) - ) - (local.get $2) - ) - ) - (block $do_backpatches.13 - ) - ) - (block $cleanup.15 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $1) - ) - ) - ) - (return_call $print_1203 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $print_1203) - ) - (local.get $9) - (local.get $8) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.21 - (block $compile_store.20 - (local.set $6 - (block $allocate_closure.18 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 6) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.add - (global.get $relocBase_0) - (i32.const 0) - ) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.19 - (local.set $0 - (local.get $6) - ) - ) - ) - (return_call $apply_1201 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $apply_1201) - ) - (local.get $6) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 423 -) +((mash_code + ((functions + (((id ((stamp 1202) (name lam_lambda))) (name ()) + (args (Managed Managed)) (return_type ((Unmanaged WasmI32))) + (closure (0)) + (body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) ((instr_desc (MAllocate (MString ok))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MArgBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func print_1203) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind print_1203 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports + (((mimp_id ((stamp 1203) (name print))) (mimp_mod pervasives.gr) + (mimp_name print) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1203) (name print))) (mimp_mod pervasives.gr) + (mimp_name print) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((stamp 1201) (name apply))) (mimp_mod providedType.gr) + (mimp_name apply) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1201) (name apply))) (mimp_mod providedType.gr) + (mimp_name apply) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MClosure + ((func_idx (0)) (global_offset function_table_global_1207) + (arity 2) (variables ()))))))))))) + ((instr_desc + (MReturnCallKnown (func apply_1201) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind apply_1201 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements (lam_lambda_1202)) + (global_function_table_offset ((stamp 1207) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/provides.c3bb4eff.0.snapshot b/compiler/test/__snapshots__/provides.c3bb4eff.0.snapshot index bb49a490ea..2fc5cbb238 100644 --- a/compiler/test/__snapshots__/provides.c3bb4eff.0.snapshot +++ b/compiler/test/__snapshots__/provides.c3bb4eff.0.snapshot @@ -1,68 +1,65 @@ provides › provide8 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$y\" (global $y_1125 (mut i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"GRAIN$EXPORT$x\" (global $x_1123 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1122 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$provideAll.gr\" \"y\" (func $y_1125 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1122 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.3 - (block $compile_store.2 - (local.set $6 - (call $y_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $y_1125) - ) - (i32.const 9) - ) - ) - (block $do_backpatches.1 - ) - ) - (return_call $+_1122 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1122) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $x_1123) - ) - (local.get $6) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 421 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1125) (name y))) (mimp_mod provideAll.gr) + (mimp_name y) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1125) (name y))) (mimp_mod provideAll.gr) + (mimp_name y) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((stamp 1123) (name x))) (mimp_mod provideAll.gr) + (mimp_name x) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)) + ((mimp_id ((stamp 1122) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1122) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MCallKnown (func y_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind y_1125 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed) (Managed))) + (args + (((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func +_1122) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1122 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind x_1123 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1127) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/provides.c6bf4567.0.snapshot b/compiler/test/__snapshots__/provides.c6bf4567.0.snapshot index 69c76d9996..3ea3513962 100644 --- a/compiler/test/__snapshots__/provides.c6bf4567.0.snapshot +++ b/compiler/test/__snapshots__/provides.c6bf4567.0.snapshot @@ -1,73 +1,46 @@ provides › let_rec_provide -(module - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $foo_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"foo\" (func $foo_1113)) - (export \"GRAIN$EXPORT$foo\" (global $foo_1113)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $foo_1113 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 f32) - (local $6 f64) - (block $compile_block.2 (result i32) - (tuple.extract 0 - (tuple.make - (i32.const 11) - (block $cleanup.1 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $0) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.5 (result i32) - (block $compile_store.4 - (global.set $foo_1113 - (i32.const 0) - ) - (block $do_backpatches.3 - ) - ) - (i32.const 1879048190) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1005 -) +((mash_code + ((functions + (((id ((stamp 1113) (name foo))) (name (foo)) (args (Managed)) + (return_type (Managed)) (closure ()) + (body + (((instr_desc + (MCleanup + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))))))) + (((immediate_desc (MImmBinding (MArgBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (attrs ())))) + (imports ()) + (exports + ((WasmFunctionExport (ex_function_name foo) + (ex_function_internal_name foo_1113)) + (WasmGlobalExport (ex_global_name foo) + (ex_global_internal_name foo_1113)))) + (main_body + (((instr_desc + (MStore + (((MGlobalBind foo_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((stamp 1113) (name foo))) (mutable_ true) + (allocation_type Managed) (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/provides.f378d570.0.snapshot b/compiler/test/__snapshots__/provides.f378d570.0.snapshot index 13ab88e83f..976f93266e 100644 --- a/compiler/test/__snapshots__/provides.f378d570.0.snapshot +++ b/compiler/test/__snapshots__/provides.f378d570.0.snapshot @@ -1,36 +1,20 @@ provides › provide4 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$onlyXProvided.gr\" \"GRAIN$EXPORT$x\" (global $x_1116 (mut i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (global.get $x_1116) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 424 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1116) (name x))) (mimp_mod onlyXProvided.gr) + (mimp_name x) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind x_1116 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1117) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/records.012b017b.0.snapshot b/compiler/test/__snapshots__/records.012b017b.0.snapshot index 789b61a653..32e65395a6 100644 --- a/compiler/test/__snapshots__/records.012b017b.0.snapshot +++ b/compiler/test/__snapshots__/records.012b017b.0.snapshot @@ -1,35 +1,15 @@ records › record_spread_2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 1879048190) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 562 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 1879048190)))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1122) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/records.02742729.0.snapshot b/compiler/test/__snapshots__/records.02742729.0.snapshot index 55c1d7fc9f..1cf2961150 100644 --- a/compiler/test/__snapshots__/records.02742729.0.snapshot +++ b/compiler/test/__snapshots__/records.02742729.0.snapshot @@ -1,125 +1,70 @@ records › record_get_multiple -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1118 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1118 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.9 - (block $compile_store.3 - (local.set $6 - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 447924047) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 19) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (local.set $7 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $6) - ) - ) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $6) - ) - ) - ) - (block $do_backpatches.6 - ) - ) - (block $cleanup.8 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (return_call $+_1118 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1118) - ) - (local.get $7) - (local.get $8) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 562 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1118) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1118) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 223962023))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmConst (MConstI32 9))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MRecordOp (MRecordGet 1) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MReturnCallKnown (func +_1118) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1118 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 3) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1121) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/records.02af5946.0.snapshot b/compiler/test/__snapshots__/records.02af5946.0.snapshot index e3087d5ed5..f66d2ec989 100644 --- a/compiler/test/__snapshots__/records.02af5946.0.snapshot +++ b/compiler/test/__snapshots__/records.02af5946.0.snapshot @@ -1,65 +1,21 @@ records › record_definition_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1047233621) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1272 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 523616810))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/records.2dc39420.0.snapshot b/compiler/test/__snapshots__/records.2dc39420.0.snapshot index 2e4b2a5e8c..a6f63c6bb1 100644 --- a/compiler/test/__snapshots__/records.2dc39420.0.snapshot +++ b/compiler/test/__snapshots__/records.2dc39420.0.snapshot @@ -1,65 +1,21 @@ records › record_pun -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1047233621) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1208 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 523616810))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1117) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/records.49dfc6ff.0.snapshot b/compiler/test/__snapshots__/records.49dfc6ff.0.snapshot index beda98bf05..f74ca3741c 100644 --- a/compiler/test/__snapshots__/records.49dfc6ff.0.snapshot +++ b/compiler/test/__snapshots__/records.49dfc6ff.0.snapshot @@ -1,160 +1,66 @@ records › record_destruct_1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $foo_1114 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.13 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (global.set $foo_1114 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $7) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $cleanup.11 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (drop - (block $compile_set.12 (result i32) - (global.set $foo_1114 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $foo_1114) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (global.get $foo_1114) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 643 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind foo_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind foo_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind foo_1114 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 3) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((stamp 1114) (name foo))) (mutable_ true) + (allocation_type Managed) (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1123) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/records.54f5977c.0.snapshot b/compiler/test/__snapshots__/records.54f5977c.0.snapshot index 8c1a0c3d55..9877f4dbda 100644 --- a/compiler/test/__snapshots__/records.54f5977c.0.snapshot +++ b/compiler/test/__snapshots__/records.54f5977c.0.snapshot @@ -1,247 +1,160 @@ records › record_destruct_4 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1126 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1126 (param i32 i32 i32) (result i32))) - (global $bar_1115 (mut i32) (i32.const 0)) - (global $foo_1114 (mut i32) (i32.const 0)) - (global $baz_1116 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (block $compile_block.22 - (block $compile_store.3 - (local.set $6 - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (i32.const 13) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (global.set $foo_1114 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (global.set $bar_1115 - (i32.const 0) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (global.set $baz_1116 - (i32.const 0) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $7 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $6) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $6) - ) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $6) - ) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $cleanup.16 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (drop - (block $compile_set.17 (result i32) - (global.set $baz_1116 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $baz_1116) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.18 (result i32) - (global.set $bar_1115 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $bar_1115) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.19 (result i32) - (global.set $foo_1114 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $foo_1114) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.21 - (local.set $10 - (call $+_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1126) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1114) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $bar_1115) - ) - ) - ) - (block $do_backpatches.20 - ) - ) - (return_call $+_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1126) - ) - (local.get $10) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $baz_1116) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 643 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1126) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1126) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))) + ((baz) + ((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind foo_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind bar_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind baz_1116 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MRecordOp (MRecordGet 1) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MRecordOp (MRecordGet 2) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind baz_1116 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind bar_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind foo_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MCallKnown (func +_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1126 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind foo_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind bar_1115 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func +_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1126 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind baz_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 5) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((stamp 1115) (name bar))) (mutable_ true) + (allocation_type Managed) (initial_value ())) + ((id ((stamp 1114) (name foo))) (mutable_ true) + (allocation_type Managed) (initial_value ())) + ((id ((stamp 1116) (name baz))) (mutable_ true) + (allocation_type Managed) (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1128) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/records.5f340064.0.snapshot b/compiler/test/__snapshots__/records.5f340064.0.snapshot index 0d2e67f599..a1f9a8f945 100644 --- a/compiler/test/__snapshots__/records.5f340064.0.snapshot +++ b/compiler/test/__snapshots__/records.5f340064.0.snapshot @@ -1,65 +1,21 @@ records › record_value_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1047233621) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1252 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 523616810))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/records.60c0a141.0.snapshot b/compiler/test/__snapshots__/records.60c0a141.0.snapshot index 7c405aa26b..54fafc20c1 100644 --- a/compiler/test/__snapshots__/records.60c0a141.0.snapshot +++ b/compiler/test/__snapshots__/records.60c0a141.0.snapshot @@ -1,316 +1,115 @@ records › record_recursive_data_definition -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (block $compile_block.24 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 610197211) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2229) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_record.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1047233621) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.15 - (local.set $10 - (block $allocate_adt.13 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=20 - (local.get $0) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - ) - (local.get $0) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.18 - (local.set $12 - (block $record_set.16 (result i32) - (i32.store offset=16 - (local.get $7) - (tuple.extract 0 - (tuple.make - (local.get $10) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=16 - (local.get $7) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.21 - (local.set $11 - (block $allocate_adt.19 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 501102191) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=20 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.20 - ) - ) - (tuple.extract 0 - (tuple.make - (block $record_set.23 (result i32) - (i32.store offset=16 - (local.get $9) - (tuple.extract 0 - (tuple.make - (local.get $11) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (i32.load offset=16 - (local.get $9) - ) - ) - ) - ) - ) - (i32.const 1879048190) - ) - (block $cleanup.22 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $9) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 606 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 305098605))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1114))) + (immediate_analyses ((last_usage Unknown)))) + (((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 523616810))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 0 (Unmanaged WasmI32)) + ((instr_desc + (MRecordOp + (MRecordSet 0 + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 250551095))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MRecordOp + (MRecordSet 0 + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last))))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))))))) + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 6) (stack_size_i32 1) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1125) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/records.60c7acc4.0.snapshot b/compiler/test/__snapshots__/records.60c7acc4.0.snapshot index 2652845e5b..f15c8efe59 100644 --- a/compiler/test/__snapshots__/records.60c7acc4.0.snapshot +++ b/compiler/test/__snapshots__/records.60c7acc4.0.snapshot @@ -1,69 +1,25 @@ records › record_pun_mixed_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 447924047) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 2147483646) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1702 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 223962023))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1117) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/records.63a951b8.0.snapshot b/compiler/test/__snapshots__/records.63a951b8.0.snapshot index b55a5d8210..07948f629f 100644 --- a/compiler/test/__snapshots__/records.63a951b8.0.snapshot +++ b/compiler/test/__snapshots__/records.63a951b8.0.snapshot @@ -1,160 +1,66 @@ records › record_destruct_2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $bar_1114 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.13 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (global.set $bar_1114 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $7) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $cleanup.11 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (drop - (block $compile_set.12 (result i32) - (global.set $bar_1114 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $bar_1114) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (global.get $bar_1114) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 643 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind bar_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MRecordOp (MRecordGet 1) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind bar_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind bar_1114 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 3) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((stamp 1114) (name bar))) (mutable_ true) + (allocation_type Managed) (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1123) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/records.89d08e01.0.snapshot b/compiler/test/__snapshots__/records.89d08e01.0.snapshot index 6d79ebb27f..76ff5f4536 100644 --- a/compiler/test/__snapshots__/records.89d08e01.0.snapshot +++ b/compiler/test/__snapshots__/records.89d08e01.0.snapshot @@ -1,65 +1,21 @@ records › record_pun_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1047233621) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1244 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 523616810))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1117) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/records.98824516.0.snapshot b/compiler/test/__snapshots__/records.98824516.0.snapshot index b5995c0442..38e5614eec 100644 --- a/compiler/test/__snapshots__/records.98824516.0.snapshot +++ b/compiler/test/__snapshots__/records.98824516.0.snapshot @@ -1,181 +1,81 @@ records › record_destruct_deep -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $foo_1115 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.16 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1047233621) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 610197211) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2229) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (global.set $foo_1115 - (i32.const 0) - ) - (block $do_backpatches.7 - ) - ) - (block $compile_store.10 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $7) - ) - ) - ) - (block $do_backpatches.9 - ) - ) - (block $cleanup.11 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (block $compile_store.13 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $8) - ) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $cleanup.14 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - (drop - (block $compile_set.15 (result i32) - (global.set $foo_1115 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $foo_1115) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (global.get $foo_1115) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 606 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 523616810))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 305098605))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1114))) + (immediate_analyses ((last_usage Unknown)))) + (((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind foo_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind foo_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind foo_1115 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 4) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((stamp 1115) (name foo))) (mutable_ true) + (allocation_type Managed) (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1124) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/records.a3299dd2.0.snapshot b/compiler/test/__snapshots__/records.a3299dd2.0.snapshot index 5fd798c84c..607363a351 100644 --- a/compiler/test/__snapshots__/records.a3299dd2.0.snapshot +++ b/compiler/test/__snapshots__/records.a3299dd2.0.snapshot @@ -1,189 +1,114 @@ records › record_destruct_3 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1125 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1125 (param i32 i32 i32) (result i32))) - (global $bar_1115 (mut i32) (i32.const 0)) - (global $foo_1114 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.15 - (block $compile_store.3 - (local.set $6 - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (i32.const 13) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (global.set $foo_1114 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (global.set $bar_1115 - (i32.const 0) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (local.set $7 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $6) - ) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $6) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $cleanup.12 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (drop - (block $compile_set.13 (result i32) - (global.set $bar_1115 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $bar_1115) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.14 (result i32) - (global.set $foo_1114 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $foo_1114) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (return_call $+_1125 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1125) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1114) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $bar_1115) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 643 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1125) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1125) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))) + ((baz) + ((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind foo_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind bar_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MRecordOp (MRecordGet 1) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind bar_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind foo_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MReturnCallKnown (func +_1125) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1125 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind foo_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind bar_1115 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 3) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((stamp 1115) (name bar))) (mutable_ true) + (allocation_type Managed) (initial_value ())) + ((id ((stamp 1114) (name foo))) (mutable_ true) + (allocation_type Managed) (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1126) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/records.a702778a.0.snapshot b/compiler/test/__snapshots__/records.a702778a.0.snapshot index 2da4a3d91b..496abf3f69 100644 --- a/compiler/test/__snapshots__/records.a702778a.0.snapshot +++ b/compiler/test/__snapshots__/records.a702778a.0.snapshot @@ -1,155 +1,59 @@ records › record_get_multilevel -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.11 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 447924047) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 19) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1956346849) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2229) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.8 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $7) - ) - ) - ) - (block $do_backpatches.7 - ) - ) - (block $cleanup.9 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - ) - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $8) - ) - ) - (block $cleanup.10 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 682 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 223962023))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmConst (MConstI32 9))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 978173424))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1114))) + (immediate_analyses ((last_usage Unknown)))) + (((baz) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MRecordOp (MRecordGet 1) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))) + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 3) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1122) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/records.a9c472b1.0.snapshot b/compiler/test/__snapshots__/records.a9c472b1.0.snapshot index 4cc32e7113..af29c0e7b5 100644 --- a/compiler/test/__snapshots__/records.a9c472b1.0.snapshot +++ b/compiler/test/__snapshots__/records.a9c472b1.0.snapshot @@ -1,100 +1,30 @@ records › record_multiple_fields_definition_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 2279 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1117) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/records.b50d234d.0.snapshot b/compiler/test/__snapshots__/records.b50d234d.0.snapshot index debc2f64ea..a82c97b8c5 100644 --- a/compiler/test/__snapshots__/records.b50d234d.0.snapshot +++ b/compiler/test/__snapshots__/records.b50d234d.0.snapshot @@ -1,95 +1,32 @@ records › record_get_2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1047233621) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $6) - ) - ) - (block $cleanup.4 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 486 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 523616810))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))) + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1117) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/records.d34c4740.0.snapshot b/compiler/test/__snapshots__/records.d34c4740.0.snapshot index 1dbe4be57c..bb83cea892 100644 --- a/compiler/test/__snapshots__/records.d34c4740.0.snapshot +++ b/compiler/test/__snapshots__/records.d34c4740.0.snapshot @@ -1,69 +1,25 @@ records › record_pun_mixed -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 447924047) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 2147483646) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1648 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 223962023))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1117) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/records.d393173c.0.snapshot b/compiler/test/__snapshots__/records.d393173c.0.snapshot index 983becb252..ca55992fc2 100644 --- a/compiler/test/__snapshots__/records.d393173c.0.snapshot +++ b/compiler/test/__snapshots__/records.d393173c.0.snapshot @@ -1,247 +1,160 @@ records › record_destruct_trailing -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$+\" (global $+_1126 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"+\" (func $+_1126 (param i32 i32 i32) (result i32))) - (global $bar_1115 (mut i32) (i32.const 0)) - (global $foo_1114 (mut i32) (i32.const 0)) - (global $baz_1116 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (block $compile_block.22 - (block $compile_store.3 - (local.set $6 - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=24 - (local.get $0) - (i32.const 13) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (global.set $foo_1114 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (global.set $bar_1115 - (i32.const 0) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (global.set $baz_1116 - (i32.const 0) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $7 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $6) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $6) - ) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=24 - (local.get $6) - ) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $cleanup.16 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (drop - (block $compile_set.17 (result i32) - (global.set $baz_1116 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $baz_1116) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.18 (result i32) - (global.set $bar_1115 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $bar_1115) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.19 (result i32) - (global.set $foo_1114 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $foo_1114) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.21 - (local.set $10 - (call $+_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1126) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $foo_1114) - ) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $bar_1115) - ) - ) - ) - (block $do_backpatches.20 - ) - ) - (return_call $+_1126 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $+_1126) - ) - (local.get $10) - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $baz_1116) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 643 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1126) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1126) (name +))) (mimp_mod pervasives.gr) + (mimp_name +) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown))))) + ((baz) + ((immediate_desc (MImmConst (MConstI32 6))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind foo_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind bar_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind baz_1116 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MRecordOp (MRecordGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MRecordOp (MRecordGet 1) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MRecordOp (MRecordGet 2) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind baz_1116 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind bar_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind foo_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MCallKnown (func +_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1126 Managed))) + (immediate_analyses ((last_usage Unknown)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind foo_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MIncRef + ((immediate_desc + (MImmBinding (MGlobalBind bar_1115 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func +_1126) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind +_1126 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind baz_1116 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 5) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((stamp 1115) (name bar))) (mutable_ true) + (allocation_type Managed) (initial_value ())) + ((id ((stamp 1114) (name foo))) (mutable_ true) + (allocation_type Managed) (initial_value ())) + ((id ((stamp 1116) (name baz))) (mutable_ true) + (allocation_type Managed) (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1128) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/records.d44e8007.0.snapshot b/compiler/test/__snapshots__/records.d44e8007.0.snapshot index e58a07ab56..2f483f7ca9 100644 --- a/compiler/test/__snapshots__/records.d44e8007.0.snapshot +++ b/compiler/test/__snapshots__/records.d44e8007.0.snapshot @@ -1,69 +1,25 @@ records › record_pun_mixed_2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 447924047) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 2147483646) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1660 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 223962023))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1117) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/records.e4326567.0.snapshot b/compiler/test/__snapshots__/records.e4326567.0.snapshot index edabd34e98..ff2892856f 100644 --- a/compiler/test/__snapshots__/records.e4326567.0.snapshot +++ b/compiler/test/__snapshots__/records.e4326567.0.snapshot @@ -1,100 +1,30 @@ records › record_multiple_fields_both_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 2231 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1117) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/records.e5b56da8.0.snapshot b/compiler/test/__snapshots__/records.e5b56da8.0.snapshot index 312fe16b26..2dc5cdbe97 100644 --- a/compiler/test/__snapshots__/records.e5b56da8.0.snapshot +++ b/compiler/test/__snapshots__/records.e5b56da8.0.snapshot @@ -1,65 +1,21 @@ records › record_both_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1047233621) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1248 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 523616810))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/records.e705a980.0.snapshot b/compiler/test/__snapshots__/records.e705a980.0.snapshot index 932be85286..49cadf844d 100644 --- a/compiler/test/__snapshots__/records.e705a980.0.snapshot +++ b/compiler/test/__snapshots__/records.e705a980.0.snapshot @@ -1,69 +1,25 @@ records › record_pun_multiple -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 447924047) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 2147483646) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1666 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 223962023))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1118) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/records.f6e43cdb.0.snapshot b/compiler/test/__snapshots__/records.f6e43cdb.0.snapshot index 8a6e10a22d..f05c08c997 100644 --- a/compiler/test/__snapshots__/records.f6e43cdb.0.snapshot +++ b/compiler/test/__snapshots__/records.f6e43cdb.0.snapshot @@ -1,69 +1,25 @@ records › record_pun_multiple_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 447924047) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 2147483646) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1720 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 223962023))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1118) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/records.f6feee77.0.snapshot b/compiler/test/__snapshots__/records.f6feee77.0.snapshot index ed098ed639..3022fa87be 100644 --- a/compiler/test/__snapshots__/records.f6feee77.0.snapshot +++ b/compiler/test/__snapshots__/records.f6feee77.0.snapshot @@ -1,100 +1,30 @@ records › record_multiple_fields_value_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (block $compile_block.5 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 2239 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 1) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1117) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/records.fae50a8e.0.snapshot b/compiler/test/__snapshots__/records.fae50a8e.0.snapshot index 05099a271f..65ec8309ee 100644 --- a/compiler/test/__snapshots__/records.fae50a8e.0.snapshot +++ b/compiler/test/__snapshots__/records.fae50a8e.0.snapshot @@ -1,69 +1,25 @@ records › record_pun_mixed_2_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_record.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 447924047) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 2147483646) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 1714 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 223962023))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1117) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/stdlib.179d20b9.0.snapshot b/compiler/test/__snapshots__/stdlib.179d20b9.0.snapshot index 66b90f4c43..4adb5e58a8 100644 --- a/compiler/test/__snapshots__/stdlib.179d20b9.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.179d20b9.0.snapshot @@ -1,48 +1,36 @@ stdlib › stdlib_equal_4 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (i32.const 3) - (i32.const 3) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/stdlib.1c0b04b7.0.snapshot b/compiler/test/__snapshots__/stdlib.1c0b04b7.0.snapshot index cedd34bb2a..bb5acc1877 100644 --- a/compiler/test/__snapshots__/stdlib.1c0b04b7.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.1c0b04b7.0.snapshot @@ -1,190 +1,80 @@ stdlib › stdlib_equal_20 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.13 - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_string.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7496034) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_record.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $8) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (return_call $==_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1114) - ) - (local.get $7) - (local.get $9) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 643 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1114) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1114) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) ((instr_desc (MAllocate (MString bar))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 4) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1121) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/stdlib.24cb9bbf.0.snapshot b/compiler/test/__snapshots__/stdlib.24cb9bbf.0.snapshot index ec38f730b4..b0864992a2 100644 --- a/compiler/test/__snapshots__/stdlib.24cb9bbf.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.24cb9bbf.0.snapshot @@ -1,104 +1,44 @@ stdlib › stdlib_equal_18 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 8) - ) - (i64.store offset=8 - (local.get $0) - (i64.const -9036296798633758874) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_string.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 8) - ) - (i64.store offset=8 - (local.get $0) - (i64.const -8891900135581192346) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc (MAllocate (MString \"foo \\240\\159\\152\\130\"))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc (MAllocate (MString \"foo \\240\\159\\153\\132\"))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/stdlib.323e410a.0.snapshot b/compiler/test/__snapshots__/stdlib.323e410a.0.snapshot index 09a369e7e7..b190228191 100644 --- a/compiler/test/__snapshots__/stdlib.323e410a.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.323e410a.0.snapshot @@ -1,130 +1,43 @@ stdlib › stdlib_equal_1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.8 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (tuple.extract 0 - (tuple.make - (i32.or - (i32.shl - (i32.eq - (local.get $6) - (local.get $7) - ) - (i32.const 31) - ) - (i32.const 2147483646) - ) - (block $cleanup.7 (result i32) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $7) - ) - ) - (i32.const 1879048190) - ) - ) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MCleanup + (((instr_desc + (MPrim2 Is + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))) + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1119) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/stdlib.37483d2d.0.snapshot b/compiler/test/__snapshots__/stdlib.37483d2d.0.snapshot index 2581e25af8..2e60aabbf8 100644 --- a/compiler/test/__snapshots__/stdlib.37483d2d.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.37483d2d.0.snapshot @@ -1,194 +1,69 @@ stdlib › stdlib_cons -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (block $compile_block.11 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $allocate_adt.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=24 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 3) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1120) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/stdlib.4a5061c2.0.snapshot b/compiler/test/__snapshots__/stdlib.4a5061c2.0.snapshot index f83220a0c8..c3cbf264b5 100644 --- a/compiler/test/__snapshots__/stdlib.4a5061c2.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.4a5061c2.0.snapshot @@ -1,190 +1,80 @@ stdlib › stdlib_equal_19 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.13 - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_string.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_record.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $8) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (return_call $==_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1114) - ) - (local.get $7) - (local.get $9) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 643 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1114) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1114) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 4) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1121) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/stdlib.5fe88631.0.snapshot b/compiler/test/__snapshots__/stdlib.5fe88631.0.snapshot index 9c9c5dea1e..7aaf49117d 100644 --- a/compiler/test/__snapshots__/stdlib.5fe88631.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.5fe88631.0.snapshot @@ -1,104 +1,42 @@ stdlib › stdlib_equal_16 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_string.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString foo))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) ((instr_desc (MAllocate (MString foo))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/stdlib.648f406e.0.snapshot b/compiler/test/__snapshots__/stdlib.648f406e.0.snapshot index 44eb181a1a..5e3483c251 100644 --- a/compiler/test/__snapshots__/stdlib.648f406e.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.648f406e.0.snapshot @@ -1,128 +1,64 @@ stdlib › stdlib_equal_12 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_array.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1124) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/stdlib.69635cff.0.snapshot b/compiler/test/__snapshots__/stdlib.69635cff.0.snapshot index 51ead1b95c..379b867130 100644 --- a/compiler/test/__snapshots__/stdlib.69635cff.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.69635cff.0.snapshot @@ -1,190 +1,80 @@ stdlib › stdlib_equal_21 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.13 - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_string.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_record.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 157) - ) - (i32.store offset=20 - (local.get $0) - (local.get $8) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (return_call $==_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1114) - ) - (local.get $7) - (local.get $9) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 643 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1114) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1114) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 78))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 4) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1121) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/stdlib.6bf88430.0.snapshot b/compiler/test/__snapshots__/stdlib.6bf88430.0.snapshot index 9fc3d8c016..f5c0978d4f 100644 --- a/compiler/test/__snapshots__/stdlib.6bf88430.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.6bf88430.0.snapshot @@ -1,100 +1,42 @@ stdlib › stdlib_equal_15 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 102) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_string.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 8) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString f))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) ((instr_desc (MAllocate (MString \"\"))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/stdlib.6de47be2.0.snapshot b/compiler/test/__snapshots__/stdlib.6de47be2.0.snapshot index d157d5d81b..bb3f3b78f8 100644 --- a/compiler/test/__snapshots__/stdlib.6de47be2.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.6de47be2.0.snapshot @@ -1,100 +1,42 @@ stdlib › stdlib_equal_14 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 32) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_string.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 8) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString \" \"))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) ((instr_desc (MAllocate (MString \"\"))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/stdlib.8300ad7c.0.snapshot b/compiler/test/__snapshots__/stdlib.8300ad7c.0.snapshot index cccebc51b1..e51cfae7b2 100644 --- a/compiler/test/__snapshots__/stdlib.8300ad7c.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.8300ad7c.0.snapshot @@ -1,378 +1,158 @@ stdlib › stdlib_equal_3 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (block $compile_block.25 - (block $compile_store.3 - (local.set $6 - (block $allocate_adt.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_adt.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=24 - (local.get $0) - (local.get $6) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_adt.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_adt.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=24 - (local.get $0) - (local.get $8) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (block $compile_store.15 - (local.set $10 - (block $allocate_adt.13 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.18 - (local.set $11 - (block $allocate_adt.16 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=24 - (local.get $0) - (local.get $10) - ) - (local.get $0) - ) - ) - (block $do_backpatches.17 - ) - ) - (block $compile_store.21 - (local.set $12 - (block $allocate_adt.19 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=24 - (local.get $0) - (local.get $11) - ) - (local.get $0) - ) - ) - (block $do_backpatches.20 - ) - ) - (block $compile_store.24 - (local.set $13 - (block $allocate_adt.22 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 2) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1638603609) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 11) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=24 - (local.get $0) - (local.get $12) - ) - (local.get $0) - ) - ) - (block $do_backpatches.23 - ) - ) - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (local.get $9) - (local.get $13) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MAllocate + (MADT + ((immediate_desc (MImmConst (MConstI32 819301804))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 5))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown)))) + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 8) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1128) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/stdlib.91a94037.0.snapshot b/compiler/test/__snapshots__/stdlib.91a94037.0.snapshot index cdbdfc76a7..a3a7fe5e84 100644 --- a/compiler/test/__snapshots__/stdlib.91a94037.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.91a94037.0.snapshot @@ -1,108 +1,54 @@ stdlib › stdlib_equal_11 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_array.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1119) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/stdlib.a70e79ca.0.snapshot b/compiler/test/__snapshots__/stdlib.a70e79ca.0.snapshot index a11b7ab880..56c3820553 100644 --- a/compiler/test/__snapshots__/stdlib.a70e79ca.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.a70e79ca.0.snapshot @@ -1,100 +1,47 @@ stdlib › stdlib_equal_9 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 8) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_array.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MArray ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1117) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/stdlib.b30d7785.0.snapshot b/compiler/test/__snapshots__/stdlib.b30d7785.0.snapshot index 3ccae1ee78..40683c0553 100644 --- a/compiler/test/__snapshots__/stdlib.b30d7785.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.b30d7785.0.snapshot @@ -1,112 +1,56 @@ stdlib › stdlib_equal_2 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1120) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/stdlib.c09a513a.0.snapshot b/compiler/test/__snapshots__/stdlib.c09a513a.0.snapshot index 90c01a2a84..3803044572 100644 --- a/compiler/test/__snapshots__/stdlib.c09a513a.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.c09a513a.0.snapshot @@ -1,48 +1,37 @@ stdlib › stdlib_equal_6 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (i32.const -2) - (i32.const -2) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type + (((Unmanaged WasmI32) (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1114) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/stdlib.cbf0318e.0.snapshot b/compiler/test/__snapshots__/stdlib.cbf0318e.0.snapshot index eacd026e89..b9679a6381 100644 --- a/compiler/test/__snapshots__/stdlib.cbf0318e.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.cbf0318e.0.snapshot @@ -1,190 +1,81 @@ stdlib › stdlib_equal_22 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1114 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1114 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.13 - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_record.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $6) - ) - (i32.store offset=24 - (local.get $0) - (i32.const -2) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_string.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303010) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.12 - (local.set $9 - (block $allocate_record.10 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 28) - ) - ) - (i32.const 3) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 656589387) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 2227) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 9) - ) - (i32.store offset=20 - (local.get $0) - (local.get $8) - ) - (i32.store offset=24 - (local.get $0) - (i32.const 2147483646) - ) - (local.get $0) - ) - ) - (block $do_backpatches.11 - ) - ) - (return_call $==_1114 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1114) - ) - (local.get $7) - (local.get $9) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 643 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1114) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1114) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) ((instr_desc (MAllocate (MString boo))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MAllocate + (MRecord + ((immediate_desc (MImmConst (MConstI32 328294693))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 1113))) + (immediate_analyses ((last_usage Unknown)))) + (((foo) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown))))) + ((bar) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))) + ((baz) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1114) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 4) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1121) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/stdlib.d28dee65.0.snapshot b/compiler/test/__snapshots__/stdlib.d28dee65.0.snapshot index 3f42a7ba6b..7e9c2e036a 100644 --- a/compiler/test/__snapshots__/stdlib.d28dee65.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.d28dee65.0.snapshot @@ -1,104 +1,52 @@ stdlib › stdlib_equal_10 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_array.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 12) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 1) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MArray + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1118) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/stdlib.d4faa5bf.0.snapshot b/compiler/test/__snapshots__/stdlib.d4faa5bf.0.snapshot index 7791c712be..d2023beb96 100644 --- a/compiler/test/__snapshots__/stdlib.d4faa5bf.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.d4faa5bf.0.snapshot @@ -1,96 +1,42 @@ stdlib › stdlib_equal_13 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 8) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_string.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 8) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString \"\"))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) ((instr_desc (MAllocate (MString \"\"))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/stdlib.d887bb04.0.snapshot b/compiler/test/__snapshots__/stdlib.d887bb04.0.snapshot index 4b35e05810..0c2ad74222 100644 --- a/compiler/test/__snapshots__/stdlib.d887bb04.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.d887bb04.0.snapshot @@ -1,48 +1,38 @@ stdlib › stdlib_equal_7 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (i32.const -2) - (i32.const 2147483646) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type + (((Unmanaged WasmI32) (Unmanaged WasmI32)) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstLiteral (MConstI32 -2)))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc + (MImmConst (MConstLiteral (MConstI32 2147483646)))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1114) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/stdlib.dae8b12a.0.snapshot b/compiler/test/__snapshots__/stdlib.dae8b12a.0.snapshot index 182200a619..79e2b0c6a2 100644 --- a/compiler/test/__snapshots__/stdlib.dae8b12a.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.dae8b12a.0.snapshot @@ -1,48 +1,36 @@ stdlib › stdlib_equal_5 -(module - (type $none_=>_i32 (func (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (i32.const 3) - (i32.const 5) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/stdlib.e306600a.0.snapshot b/compiler/test/__snapshots__/stdlib.e306600a.0.snapshot index b78f955ff5..31861ddf81 100644 --- a/compiler/test/__snapshots__/stdlib.e306600a.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.e306600a.0.snapshot @@ -1,96 +1,42 @@ stdlib › stdlib_equal_8 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_array.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 8) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_array.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 8) - ) - ) - (i32.const 4) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 0) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MArray ()))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) ((instr_desc (MAllocate (MArray ()))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/stdlib.e6349872.0.snapshot b/compiler/test/__snapshots__/stdlib.e6349872.0.snapshot index 106abb6422..2158b79f32 100644 --- a/compiler/test/__snapshots__/stdlib.e6349872.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.e6349872.0.snapshot @@ -1,104 +1,44 @@ stdlib › stdlib_equal_17 -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$==\" (global $==_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"==\" (func $==_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 8) - ) - (i64.store offset=8 - (local.get $0) - (i64.const -9036296798633758874) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_string.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 8) - ) - (i64.store offset=8 - (local.get $0) - (i64.const -9036296798633758874) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $==_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ==))) (mimp_mod pervasives.gr) + (mimp_name ==) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc (MAllocate (MString \"foo \\240\\159\\152\\130\"))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc (MAllocate (MString \"foo \\240\\159\\152\\130\"))))))))) + ((instr_desc + (MReturnCallKnown (func ==_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ==_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) ((Unmanaged WasmI32)))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/strings.434adad0.0.snapshot b/compiler/test/__snapshots__/strings.434adad0.0.snapshot index 7cd70f8531..014ceebe71 100644 --- a/compiler/test/__snapshots__/strings.434adad0.0.snapshot +++ b/compiler/test/__snapshots__/strings.434adad0.0.snapshot @@ -1,57 +1,11 @@ strings › string2 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 2945622000) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MString \"\\240\\159\\146\\175\")))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1114) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/strings.a67428df.0.snapshot b/compiler/test/__snapshots__/strings.a67428df.0.snapshot index efb0c5357d..b57edd424c 100644 --- a/compiler/test/__snapshots__/strings.a67428df.0.snapshot +++ b/compiler/test/__snapshots__/strings.a67428df.0.snapshot @@ -1,57 +1,11 @@ strings › string1 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body (((instr_desc (MAllocate (MString foo)))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1114) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/strings.b2ad5a89.0.snapshot b/compiler/test/__snapshots__/strings.b2ad5a89.0.snapshot index 40504cc52d..75c95f2c88 100644 --- a/compiler/test/__snapshots__/strings.b2ad5a89.0.snapshot +++ b/compiler/test/__snapshots__/strings.b2ad5a89.0.snapshot @@ -1,73 +1,13 @@ strings › string3 -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 48) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 36) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7863398673301594477) - ) - (i64.store offset=16 - (local.get $0) - (i64.const 8026576141579395193) - ) - (i64.store offset=24 - (local.get $0) - (i64.const 2318349367439027831) - ) - (i64.store offset=32 - (local.get $0) - (i64.const 2334956330867777911) - ) - (i64.store offset=40 - (local.get $0) - (i64.const 1953718630) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate (MString \"making my way downtown, walking fast\")))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1114) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/strings.fb85549f.0.snapshot b/compiler/test/__snapshots__/strings.fb85549f.0.snapshot index 53992937e5..eecffe2301 100644 --- a/compiler/test/__snapshots__/strings.fb85549f.0.snapshot +++ b/compiler/test/__snapshots__/strings.fb85549f.0.snapshot @@ -1,104 +1,42 @@ strings › concat -(module - (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 \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"GRAIN$EXPORT$++\" (global $++_1113 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives.gr\" \"++\" (func $++_1113 (param i32 i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (block $compile_block.7 - (block $compile_store.3 - (local.set $6 - (block $allocate_string.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7303014) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_string.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 1) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i64.store offset=8 - (local.get $0) - (i64.const 7496034) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (return_call $++_1113 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $++_1113) - ) - (local.get $6) - (local.get $7) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) + (imports + (((mimp_id ((stamp 1113) (name ++))) (mimp_mod pervasives.gr) + (mimp_name ++) + (mimp_type + (MFuncImport (Managed (Unmanaged WasmI32) (Unmanaged WasmI32)) + ((Unmanaged WasmI32)))) + (mimp_kind MImportGrain) (mimp_setup MSetupNone) (mimp_used true)) + ((mimp_id ((stamp 1113) (name ++))) (mimp_mod pervasives.gr) + (mimp_name ++) (mimp_type (MGlobalImport Managed true)) + (mimp_kind MImportGrain) (mimp_setup MCallGetter) (mimp_used true)))) + (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) ((instr_desc (MAllocate (MString foo))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) ((instr_desc (MAllocate (MString bar))))))))) + ((instr_desc + (MReturnCallKnown (func ++_1113) + (closure + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind ++_1113 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown))))) + (func_type ((Managed Managed) (Managed))) + (args + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))) + (main_body_stack_size + ((stack_size_ptr 2) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/tuples.1451773e.0.snapshot b/compiler/test/__snapshots__/tuples.1451773e.0.snapshot index a614ea7825..16e02fa686 100644 --- a/compiler/test/__snapshots__/tuples.1451773e.0.snapshot +++ b/compiler/test/__snapshots__/tuples.1451773e.0.snapshot @@ -1,322 +1,160 @@ tuples › nested_tup_3 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $b_1116 (mut i32) (i32.const 0)) - (global $a_1115 (mut i32) (i32.const 0)) - (global $y_1114 (mut i32) (i32.const 0)) - (global $x_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (block $compile_block.34 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_tuple.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (local.get $6) - ) - (i32.store offset=12 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (global.set $x_1113 - (i32.const 0) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (global.set $y_1114 - (i32.const 0) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $8) - ) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.17 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $8) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $cleanup.18 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - (drop - (block $compile_set.19 (result i32) - (global.set $y_1114 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $y_1114) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.20 (result i32) - (global.set $x_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $x_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.22 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $y_1114) - ) - ) - (block $do_backpatches.21 - ) - ) - (block $compile_store.24 - (global.set $a_1115 - (i32.const 0) - ) - (block $do_backpatches.23 - ) - ) - (block $compile_store.26 - (global.set $b_1116 - (i32.const 0) - ) - (block $do_backpatches.25 - ) - ) - (block $compile_store.28 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $11) - ) - ) - ) - (block $do_backpatches.27 - ) - ) - (block $compile_store.30 - (local.set $13 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $11) - ) - ) - ) - (block $do_backpatches.29 - ) - ) - (block $cleanup.31 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - (drop - (block $compile_set.32 (result i32) - (global.set $b_1116 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1116) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.33 (result i32) - (global.set $a_1115 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $a_1115) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (global.get $a_1115) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind x_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind y_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind y_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind x_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind y_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind a_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind b_1116 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind b_1116 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind a_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind a_1115 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 8) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((stamp 1116) (name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())) + ((id ((stamp 1115) (name a))) (mutable_ true) (allocation_type Managed) + (initial_value ())) + ((id ((stamp 1114) (name y))) (mutable_ true) (allocation_type Managed) + (initial_value ())) + ((id ((stamp 1113) (name x))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1131) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/tuples.1d60b40c.0.snapshot b/compiler/test/__snapshots__/tuples.1d60b40c.0.snapshot index 5119175418..191e954642 100644 --- a/compiler/test/__snapshots__/tuples.1d60b40c.0.snapshot +++ b/compiler/test/__snapshots__/tuples.1d60b40c.0.snapshot @@ -1,223 +1,98 @@ tuples › nested_tup_1 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $b_1114 (mut i32) (i32.const 0)) - (global $a_1113 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (block $compile_block.21 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_tuple.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (local.get $6) - ) - (i32.store offset=12 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (global.set $a_1113 - (i32.const 0) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (global.set $b_1114 - (i32.const 0) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $8) - ) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.17 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $8) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $cleanup.18 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - (drop - (block $compile_set.19 (result i32) - (global.set $b_1114 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1114) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.20 (result i32) - (global.set $a_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $a_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (global.get $a_1113) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind a_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind b_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind b_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind a_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind a_1113 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 5) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((stamp 1114) (name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())) + ((id ((stamp 1113) (name a))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1125) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/tuples.2c91b91d.0.snapshot b/compiler/test/__snapshots__/tuples.2c91b91d.0.snapshot index 2de95ddb65..7ff16ace95 100644 --- a/compiler/test/__snapshots__/tuples.2c91b91d.0.snapshot +++ b/compiler/test/__snapshots__/tuples.2c91b91d.0.snapshot @@ -1,205 +1,104 @@ tuples › tup1_destruct_trailing -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $a_1113 (mut i32) (i32.const 0)) - (global $c_1115 (mut i32) (i32.const 0)) - (global $b_1114 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (block $compile_block.20 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (global.set $a_1113 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (global.set $b_1114 - (i32.const 0) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (global.set $c_1115 - (i32.const 0) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (local.set $7 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $6) - ) - ) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $6) - ) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $6) - ) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $cleanup.16 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (drop - (block $compile_set.17 (result i32) - (global.set $c_1115 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $c_1115) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.18 (result i32) - (global.set $b_1114 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1114) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.19 (result i32) - (global.set $a_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $a_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (i32.const 1) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind a_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind b_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind c_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind c_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind b_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind a_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 0))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 4) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((stamp 1113) (name a))) (mutable_ true) (allocation_type Managed) + (initial_value ())) + ((id ((stamp 1115) (name c))) (mutable_ true) (allocation_type Managed) + (initial_value ())) + ((id ((stamp 1114) (name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1124) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/tuples.8d1f0463.0.snapshot b/compiler/test/__snapshots__/tuples.8d1f0463.0.snapshot index 93890627ef..4d608f9b1a 100644 --- a/compiler/test/__snapshots__/tuples.8d1f0463.0.snapshot +++ b/compiler/test/__snapshots__/tuples.8d1f0463.0.snapshot @@ -1,65 +1,20 @@ tuples › tup1_trailing -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/tuples.a34621a0.0.snapshot b/compiler/test/__snapshots__/tuples.a34621a0.0.snapshot index fa6830fdae..8e68001253 100644 --- a/compiler/test/__snapshots__/tuples.a34621a0.0.snapshot +++ b/compiler/test/__snapshots__/tuples.a34621a0.0.snapshot @@ -1,249 +1,130 @@ tuples › big_tup_access -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $a_1113 (mut i32) (i32.const 0)) - (global $d_1116 (mut i32) (i32.const 0)) - (global $c_1115 (mut i32) (i32.const 0)) - (global $b_1114 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (block $compile_block.25 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 24) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 4) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=20 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.5 - (global.set $a_1113 - (i32.const 0) - ) - (block $do_backpatches.4 - ) - ) - (block $compile_store.7 - (global.set $b_1114 - (i32.const 0) - ) - (block $do_backpatches.6 - ) - ) - (block $compile_store.9 - (global.set $c_1115 - (i32.const 0) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (global.set $d_1116 - (i32.const 0) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (local.set $7 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $6) - ) - ) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $8 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $6) - ) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.17 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=16 - (local.get $6) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $compile_store.19 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=20 - (local.get $6) - ) - ) - ) - (block $do_backpatches.18 - ) - ) - (block $cleanup.20 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $6) - ) - ) - ) - (drop - (block $compile_set.21 (result i32) - (global.set $d_1116 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $d_1116) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.22 (result i32) - (global.set $c_1115 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $c_1115) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.23 (result i32) - (global.set $b_1114 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $8) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1114) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.24 (result i32) - (global.set $a_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $7) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $a_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (global.get $c_1115) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind a_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind b_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind c_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind d_1116 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MTupleOp (MTupleGet 2) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 3) + ((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind d_1116 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind c_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind b_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind a_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind c_1115 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 5) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((stamp 1113) (name a))) (mutable_ true) (allocation_type Managed) + (initial_value ())) + ((id ((stamp 1116) (name d))) (mutable_ true) (allocation_type Managed) + (initial_value ())) + ((id ((stamp 1115) (name c))) (mutable_ true) (allocation_type Managed) + (initial_value ())) + ((id ((stamp 1114) (name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1127) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/tuples.b4f702d8.0.snapshot b/compiler/test/__snapshots__/tuples.b4f702d8.0.snapshot index 332d91f8ed..b0f3f0f7a8 100644 --- a/compiler/test/__snapshots__/tuples.b4f702d8.0.snapshot +++ b/compiler/test/__snapshots__/tuples.b4f702d8.0.snapshot @@ -1,35 +1,15 @@ tuples › no_non_trailing_comma_singleton_tup -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.1 (result i32) - (i32.const 3) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1114) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/tuples.c1eb0a50.0.snapshot b/compiler/test/__snapshots__/tuples.c1eb0a50.0.snapshot index 29f8fc8d68..e79184448c 100644 --- a/compiler/test/__snapshots__/tuples.c1eb0a50.0.snapshot +++ b/compiler/test/__snapshots__/tuples.c1eb0a50.0.snapshot @@ -1,322 +1,160 @@ tuples › nested_tup_2 -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (global $a_1113 (mut i32) (i32.const 0)) - (global $d_1116 (mut i32) (i32.const 0)) - (global $c_1115 (mut i32) (i32.const 0)) - (global $b_1114 (mut i32) (i32.const 0)) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (block $compile_block.34 (result i32) - (block $compile_store.3 - (local.set $6 - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (local.get $0) - ) - ) - (block $do_backpatches.2 - ) - ) - (block $compile_store.6 - (local.set $7 - (block $allocate_tuple.4 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 7) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 9) - ) - (local.get $0) - ) - ) - (block $do_backpatches.5 - ) - ) - (block $compile_store.9 - (local.set $8 - (block $allocate_tuple.7 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 16) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 2) - ) - (i32.store offset=8 - (local.get $0) - (local.get $6) - ) - (i32.store offset=12 - (local.get $0) - (local.get $7) - ) - (local.get $0) - ) - ) - (block $do_backpatches.8 - ) - ) - (block $compile_store.11 - (global.set $a_1113 - (i32.const 0) - ) - (block $do_backpatches.10 - ) - ) - (block $compile_store.13 - (global.set $b_1114 - (i32.const 0) - ) - (block $do_backpatches.12 - ) - ) - (block $compile_store.15 - (local.set $9 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $8) - ) - ) - ) - (block $do_backpatches.14 - ) - ) - (block $compile_store.17 - (local.set $10 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $8) - ) - ) - ) - (block $do_backpatches.16 - ) - ) - (block $cleanup.18 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $8) - ) - ) - ) - (drop - (block $compile_set.19 (result i32) - (global.set $b_1114 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $10) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $b_1114) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.20 (result i32) - (global.set $a_1113 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $9) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $a_1113) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (block $compile_store.22 - (local.set $11 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (global.get $b_1114) - ) - ) - (block $do_backpatches.21 - ) - ) - (block $compile_store.24 - (global.set $c_1115 - (i32.const 0) - ) - (block $do_backpatches.23 - ) - ) - (block $compile_store.26 - (global.set $d_1116 - (i32.const 0) - ) - (block $do_backpatches.25 - ) - ) - (block $compile_store.28 - (local.set $12 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=8 - (local.get $11) - ) - ) - ) - (block $do_backpatches.27 - ) - ) - (block $compile_store.30 - (local.set $13 - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (i32.load offset=12 - (local.get $11) - ) - ) - ) - (block $do_backpatches.29 - ) - ) - (block $cleanup.31 - (drop - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (local.get $11) - ) - ) - ) - (drop - (block $compile_set.32 (result i32) - (global.set $d_1116 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $13) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $d_1116) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (drop - (block $compile_set.33 (result i32) - (global.set $c_1115 - (tuple.extract 0 - (tuple.make - (call $incRef_0 - (global.get $GRAIN$EXPORT$incRef_0) - (local.get $12) - ) - (call $decRef_0 - (global.get $GRAIN$EXPORT$decRef_0) - (global.get $c_1115) - ) - ) - ) - ) - (i32.const 1879048190) - ) - ) - (global.get $d_1116) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MStore + (((MLocalBind 0 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 1 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 4))) + (immediate_analyses ((last_usage Unknown)))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 2 Managed) + ((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmBinding (MLocalBind 0 Managed))) + (immediate_analyses ((last_usage Last)))) + ((immediate_desc (MImmBinding (MLocalBind 1 Managed))) + (immediate_analyses ((last_usage Last)))))))))))))) + ((instr_desc + (MStore + (((MGlobalBind a_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind b_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 3 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 4 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 2 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind b_1114 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 4 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind a_1113 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 3 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MStore + (((MLocalBind 5 Managed) + ((instr_desc + (MImmediate + ((immediate_desc + (MIncRef + ((immediate_desc (MImmBinding (MGlobalBind b_1114 Managed))) + (immediate_analyses ((last_usage Last)))))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind c_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MGlobalBind d_1116 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmConst (MConstLiteral (MConstI32 0)))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 6 Managed) + ((instr_desc + (MTupleOp (MTupleGet 0) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))))))) + ((instr_desc + (MStore + (((MLocalBind 7 Managed) + ((instr_desc + (MTupleOp (MTupleGet 1) + ((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Last)))))))))))) + ((instr_desc + (MCleanup () + (((immediate_desc (MImmBinding (MLocalBind 5 Managed))) + (immediate_analyses ((last_usage Unknown)))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind d_1116 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 7 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MDrop + ((instr_desc + (MSet (MGlobalBind c_1115 Managed) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MLocalBind 6 Managed))) + (immediate_analyses ((last_usage Last))))))))))))) + ((instr_desc + (MImmediate + ((immediate_desc (MImmBinding (MGlobalBind d_1116 Managed))) + (immediate_analyses ((last_usage Last))))))))) + (main_body_stack_size + ((stack_size_ptr 8) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals + (((id ((stamp 1113) (name a))) (mutable_ true) (allocation_type Managed) + (initial_value ())) + ((id ((stamp 1116) (name d))) (mutable_ true) (allocation_type Managed) + (initial_value ())) + ((id ((stamp 1115) (name c))) (mutable_ true) (allocation_type Managed) + (initial_value ())) + ((id ((stamp 1114) (name b))) (mutable_ true) (allocation_type Managed) + (initial_value ())))) + (function_table_elements ()) + (global_function_table_offset ((stamp 1131) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/__snapshots__/tuples.f206002b.0.snapshot b/compiler/test/__snapshots__/tuples.f206002b.0.snapshot index 714f171f66..9ecb99a7da 100644 --- a/compiler/test/__snapshots__/tuples.f206002b.0.snapshot +++ b/compiler/test/__snapshots__/tuples.f206002b.0.snapshot @@ -1,65 +1,20 @@ tuples › tup1_trailing_space -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import \"_genv\" \"tbl\" (table $tbl 0 funcref)) - (import \"_genv\" \"relocBase\" (global $relocBase_0 i32)) - (import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) - (import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32)) - (import \"_genv\" \"runtimeHeapNextPtr\" (global $runtimeHeapNextPtr_0 (mut i32))) - (import \"_genv\" \"metadataPtr\" (global $metadataPtr_0 i32)) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) - (import \"GRAIN$MODULE$runtime/gc.gr\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) - (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) - (memory $0 0) - (elem $elem (global.get $relocBase_0)) - (export \"memory\" (memory $0)) - (export \"_gmain\" (func $_gmain)) - (export \"_start\" (func $_start)) - (export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) - (func $_gmain (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i64) - (local $4 f32) - (local $5 f64) - (block $compile_block.2 (result i32) - (block $allocate_tuple.1 (result i32) - (i32.store - (local.tee $0 - (call $malloc_0 - (global.get $GRAIN$EXPORT$malloc_0) - (i32.const 20) - ) - ) - (i32.const 7) - ) - (i32.store offset=4 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=8 - (local.get $0) - (i32.const 3) - ) - (i32.store offset=12 - (local.get $0) - (i32.const 5) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 7) - ) - (local.get $0) - ) - ) - ) - (func $_start - (drop - (call $_gmain) - ) - ) - ;; custom section \"cmi\", size 368 -) +((mash_code + ((functions ()) (imports ()) (exports ()) + (main_body + (((instr_desc + (MAllocate + (MTuple + (((immediate_desc (MImmConst (MConstI32 1))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 2))) + (immediate_analyses ((last_usage Unknown)))) + ((immediate_desc (MImmConst (MConstI32 3))) + (immediate_analyses ((last_usage Unknown))))))))))) + (main_body_stack_size + ((stack_size_ptr 0) (stack_size_i32 0) (stack_size_i64 0) + (stack_size_f32 0) (stack_size_f64 0))) + (globals ()) (function_table_elements ()) + (global_function_table_offset ((stamp 1116) (name function_table_global))) + (compilation_mode Normal) (type_metadata ))) + (signature )) diff --git a/compiler/test/runner.re b/compiler/test/runner.re index de1b3d3c60..c52fbc9a53 100644 --- a/compiler/test/runner.re +++ b/compiler/test/runner.re @@ -23,9 +23,9 @@ let stdlibfile = name => let runtimefile = name => Filepath.to_string(Fp.At.(test_runtime_dir / (name ++ ".gr"))); let wasmfile = name => - Filepath.to_string(Fp.At.(test_output_dir / (name ++ ".gr.wasm"))); -let watfile = name => - Filepath.to_string(Fp.At.(test_output_dir / (name ++ ".gr.wat"))); + Filepath.to_string(Fp.At.(test_output_dir / (name ++ ".wasm"))); +let mashfile = name => + Filepath.to_string(Fp.At.(test_output_dir / (name ++ ".mashtree"))); let grainfmt_out_file = name => Filepath.to_string(Fp.At.(test_grainfmt_dir / (name ++ ".expected.gr"))); @@ -221,14 +221,15 @@ let makeSnapshotRunner = (~config_fn=?, test, ~module_header=module_header, name, prog) => { test(name, ({expect}) => { Config.preserve_all_configs(() => { + Config.sexp_locs_enabled := false; ignore @@ compile( - ~hook=stop_after_object_file_emitted, + ~hook=stop_after_object_emitted, ~config_fn?, name, module_header ++ prog, ); - expect.file(watfile(name)).toMatchSnapshot(); + expect.file(mashfile(name)).toMatchSnapshot(); }) }); }; @@ -249,17 +250,17 @@ let makeFilesizeRunner = let makeSnapshotFileRunner = (test, ~config_fn=?, name, filename) => { test(name, ({expect}) => { Config.preserve_all_configs(() => { + Config.sexp_locs_enabled := false; let infile = grainfile(filename); let outfile = wasmfile(name); ignore @@ compile_file( - ~hook=stop_after_object_file_emitted, + ~hook=stop_after_object_emitted, ~config_fn?, infile, outfile, ); - let file = watfile(name); - expect.file(file).toMatchSnapshot(); + expect.file(mashfile(name)).toMatchSnapshot(); }) }); }; @@ -288,7 +289,8 @@ let makeWarningRunner = test(name, ({expect}) => { Config.preserve_all_configs(() => { Config.print_warnings := false; - ignore @@ compile(name, module_header ++ prog); + ignore @@ + compile(~hook=stop_after_typed_well_formed, name, module_header ++ prog); expect.ext.warning.toHaveTriggered(warning); }) }); @@ -298,7 +300,8 @@ let makeNoWarningRunner = (test, ~module_header=module_header, name, prog) => { test(name, ({expect}) => { Config.preserve_all_configs(() => { Config.print_warnings := false; - ignore @@ compile(name, module_header ++ prog); + ignore @@ + compile(~hook=stop_after_typed_well_formed, name, module_header ++ prog); expect.ext.warning.toHaveTriggeredNoWarnings(); }) }); diff --git a/compiler/test/suites/basic_functionality.re b/compiler/test/suites/basic_functionality.re index dd75d71186..83e3d05753 100644 --- a/compiler/test/suites/basic_functionality.re +++ b/compiler/test/suites/basic_functionality.re @@ -48,7 +48,7 @@ describe("basic functionality", ({test, testSkip}) => { assertSnapshot("infinity_neg", "let x = -Infinity; x"); assertRun("infinity_neg_2", "assert -Infinity == -1.0 / 0.0", ""); assertRun("infinity_neg_3", "assert -Infinity == -Infinity", ""); - assertSnapshot("nan", "let x = NaN; x"); + assertRun("nan", "print(NaN)", "NaN\n"); assertRun("nan_2", "assert NaN != NaN", ""); assertSnapshot("print_line_ending1", "print(1, suffix=\"\")"); @@ -377,6 +377,6 @@ describe("basic functionality", ({test, testSkip}) => { ~config_fn=smallestFileConfig, "smallest_grain_program", "", - 4750, + 6507, ); }); diff --git a/compiler/test/suites/modules.re b/compiler/test/suites/modules.re index 475a4d1d71..ef4102b413 100644 --- a/compiler/test/suites/modules.re +++ b/compiler/test/suites/modules.re @@ -131,7 +131,7 @@ describe("modules", ({test, testSkip}) => { let outfile = wasmfile(name); ignore @@ compile( - ~hook=Grain.Compile.stop_after_object_file_emitted, + ~hook=Grain.Compile.stop_after_assembled, name, {| module ReprovidedSimple diff --git a/compiler/test/suites/provides.re b/compiler/test/suites/provides.re index e91797a3b0..59938b7cd5 100644 --- a/compiler/test/suites/provides.re +++ b/compiler/test/suites/provides.re @@ -20,14 +20,10 @@ describe("provides", ({test, testSkip}) => { name, ({expect}) => { let state = - compile( - ~hook=Grain.Compile.stop_after_object_file_emitted, - name, - prog, - ); + compile(~hook=Grain.Compile.stop_after_compiled, name, prog); (); switch (state.Grain.Compile.cstate_desc) { - | ObjectFileEmitted({asm}) => + | Compiled({asm}) => let num_exports = Binaryen.Export.get_num_exports(asm); let exports = List.init( diff --git a/docs/contributor/compiler_walkthrough.md b/docs/contributor/compiler_walkthrough.md index 02d2c5d4e1..78311303da 100644 --- a/docs/contributor/compiler_walkthrough.md +++ b/docs/contributor/compiler_walkthrough.md @@ -9,15 +9,17 @@ We'll largely be following the `next_state` function in [compile.re](https://git The Grain compiler is a [multi-stage](https://en.wikipedia.org/wiki/Multi-pass_compiler) compiler, which means instead of converting directly from Grain syntax into `wasm` code, we send the input program through multiple phases, transforming from one intermediate representation to the next until we get to the final output. This approach allows us to have a more maintainable compiler and perform deeper analysis of the source code, which lets us provide better errors and better code output. ## File Structure + All files directly related to the compiler can be found in `compiler/src` with a map of the sub-folders found below: -* `src/parsing` - all code related to parsing and lexing -* `src/typed` - all code related to typechecking and the typed phases of the compiler -* `src/codegen` - all code related to generating both the mashtree and final wasm output which is the last two compilation steps before linking -* `src/linking` - the grain linker and code responsible for linking the intermediate wasm modules into the final wasm output -* `src/diagnostics` - all code related to parsing and handling comments for `graindoc` -* `src/formatting` - all the relevant code to the grain formatter -* `src/language_server` - all relevant code to the language server -* `src/utils` - all of our common helpers used in various places throughout the compiler + +- `src/parsing` - all code related to parsing and lexing +- `src/typed` - all code related to typechecking and the typed phases of the compiler +- `src/codegen` - all code related to generating both the mashtree and final wasm output which is the last two compilation steps before linking +- `src/linking` - the grain linker and code responsible for linking the intermediate wasm modules into the final wasm output +- `src/diagnostics` - all code related to parsing and handling comments for `graindoc` +- `src/formatting` - all the relevant code to the grain formatter +- `src/language_server` - all relevant code to the language server +- `src/utils` - all of our common helpers used in various places throughout the compiler ## Lexing @@ -140,16 +142,16 @@ You can find the entrypoints into optimization in [middle_end/optimize.re](https We couldn't think of a better name for this stage, but it's (mostly) the last representation before outputting the actual WebAssembly instructions. It's here that we decide what actually gets allocated in memory and how we retrieve and change things in memory. You can find the mashtree [here](https://github.com/grain-lang/grain/blob/main/compiler/src/codegen/mashtree.re) and the conversion process from ANF in [codegen/transl_anf.re](https://github.com/grain-lang/grain/blob/main/compiler/src/codegen/transl_anf.re). +## Linking + +Each Grain source file is compiled to a Grain-specific object file containing the program signature and mashtree. To create the final program, we merge all of the programs together in a step known as linking. This takes place in [codegen/linkedtree.re](https://github.com/grain-lang/grain/blob/main/compiler/src/codegen/linkedtree.re) + ## Code generation The code generation (or codegen) step is where we generate the actual WebAssembly code for the program. By this point, we should have reduced the complexity of the original program down enough that there is a straightforward set of WebAssembly instructions for each action that needs to happen. We use a project called [Binaryen](https://github.com/WebAssembly/binaryen) to generate our wasm code, via [Binaryen.ml](https://github.com/grain-lang/binaryen.ml). You can get a general idea of how Binaryen works from the example in the [Binaryen.ml README](https://github.com/grain-lang/binaryen.ml/blob/main/README.md). You can then see how we use it in Grain in [codegen/compcore.re](https://github.com/grain-lang/grain/blob/main/compiler/src/codegen/compcore.re). If you're curious about the wasm spec in general, you can check it out [here](https://webassembly.github.io/spec/core/index.html). -## Linking - -Each Grain source file is compiled to a Grain-specific wasm file. To create the final program, we merge all of the files together in a step known as linking. This takes place in [linking/link.re](https://github.com/grain-lang/grain/blob/main/compiler/src/linking/link.re) - ## Emission Lastly, we write the wasm to a file. And that's it! If you want an in-depth dive into any of the stages of the compiler, feel free to ask in the Discord and someone will be more than happy to walk you through it. diff --git a/stdlib/exception.gr b/stdlib/exception.gr index bdd9a4958b..da33b86636 100644 --- a/stdlib/exception.gr +++ b/stdlib/exception.gr @@ -12,8 +12,6 @@ */ module Exception -from "runtime/unsafe/wasmi32" include WasmI32 -from "runtime/unsafe/memory" include Memory from "runtime/exception" include Exception /** diff --git a/stdlib/package.json b/stdlib/package.json index b2757c3ee2..4092183f22 100644 --- a/stdlib/package.json +++ b/stdlib/package.json @@ -27,7 +27,7 @@ "index.js" ], "scripts": { - "clean": "del-cli \"**/*.wasm\" \"**/*.wat\" \"**/*.modsig\"" + "clean": "del-cli \"**/*.wasm\" \"**/*.wat\" \"**/*.gro\" \"**/*.modsig\"" }, "dependencies": {}, "devDependencies": { diff --git a/stdlib/runtime/exception.gr b/stdlib/runtime/exception.gr index 483d957bab..eaf95a8baf 100644 --- a/stdlib/runtime/exception.gr +++ b/stdlib/runtime/exception.gr @@ -1,4 +1,5 @@ @noPervasives +@noExceptions module Exception from "runtime/unsafe/panic" include Panic