diff --git a/src/passes/wasm/compile_package.rs b/src/passes/wasm/compile_package.rs index cd62c6e..0e158a6 100644 --- a/src/passes/wasm/compile_package.rs +++ b/src/passes/wasm/compile_package.rs @@ -233,8 +233,7 @@ fn compile_one( })?; let marks = crate::passes::debug_marks::analyse(&lifted, &desugared); let fqn_prefix = format!("{canonical_url}:"); - let mut frag = super::lower::lower(&lifted.result, &desugared.ast, &fqn_prefix); - frag.module_id = module_id; + let mut frag = super::lower::lower(&lifted.result, &desugared.ast, &fqn_prefix, module_id); // module_imports stays as raw-URL → ModuleId. The package compiler // resolves URLs at the call site; the lower pass populates this // field by walking `cps.module_imports` keys and mapping each raw @@ -340,6 +339,7 @@ pub const MIGRATED_STDLIB_FNK: &[&str] = &[ "std/testing.fnk", "std/io.fnk", "std/iter.fnk", + "std/trace.fnk", ]; #[cfg(feature = "compile")] diff --git a/src/passes/wasm/emit.rs b/src/passes/wasm/emit.rs index d9a16d9..c5a0766 100644 --- a/src/passes/wasm/emit.rs +++ b/src/passes/wasm/emit.rs @@ -53,6 +53,31 @@ use wasm_encoder::{ use super::ir::*; use super::runtime_contract::import_key; +// ── linear-memory map ──────────────────────────────────────────── +// +// emit is the single owner of linear-memory byte layout. The linker +// remaps symbol *indices* (which global, which data segment); the +// *byte offsets* of everything in linear memory are assigned here. +// +// Layout of the single memory page (64 KiB): +// +// [0, TRACE_BYTES) trace activation-stack region (reserved) +// [TRACE_BYTES, SCRATCH_BASE) literal data pool (grows up at compile time) +// [SCRATCH_BASE, 64 KiB) host-IO scratch window +// +// SCRATCH_BASE is the host-exchange window the JS interop bounces +// bytes through. It is declared in the runtime WAT today; this constant +// is the layout authority's copy used to bound the data pool. + +/// Trace activation-stack region at the bottom of memory. Must match +/// rt/trace.wat's window: TRACE_CAP (64) frames x FRAME_BYTES (16, four +/// i32s `{fn_mid, fn_cid, call_mid, call_cid}`) = 1024 bytes. +const RING_BYTES: u32 = 64 * 16; + +/// Host-IO scratch window base. Must match the runtime WAT's +/// `SCRATCH_BASE` global (`interop/js/interop.wat`). +const SCRATCH_BASE: u32 = 0xC000; + /// Output of `emit::emit`. The binary plus a per-InstrId map of absolute /// byte offsets in the binary. Only InstrIds that were tagged with a /// `cps_id` in lower (and thus need to participate in mark finalisation) @@ -160,6 +185,7 @@ fn linked_runtime(interop: Interop) -> &'static LinkedRuntime { let modules: &[(&str, &str)] = &[ ("interop.wat", interop_src), ("rt/apply.wat", include_str!("../../runtime/rt/apply.wat")), + ("rt/trace.wat", include_str!("../../runtime/rt/trace.wat")), ("rt/opaque.wat", include_str!("../../runtime/rt/opaque.wat")), ("rt/modules.wat", include_str!("../../runtime/rt/modules.wat")), ("rt/protocols.wat", include_str!("../../runtime/rt/protocols.wat")), @@ -713,15 +739,26 @@ pub fn emit_with_offsets(frag: &Fragment, interop: Interop) -> EmitOutput { }; // Data: lay out user fragment's `frag.data` blobs sequentially in - // memory starting at offset 0. Each `DataSym(i)` resolves to the - // running offset, used by `Operand::DataRef` at emit time. + // memory starting at `RING_BYTES` (the bottom region is reserved for + // the trace ring). Each `DataSym(i)` resolves to its absolute byte + // offset, used by `Operand::DataRef` at emit time. let mut data_offsets: Vec = Vec::with_capacity(frag.data.len()); let mut data_blob: Vec = Vec::new(); for d in &frag.data { - data_offsets.push(data_blob.len() as u32); + data_offsets.push(RING_BYTES + data_blob.len() as u32); data_blob.extend_from_slice(&d.bytes); } + // The data pool must not grow into the host-IO scratch window. Data + // size is fully known here, so this is a hard compile-time invariant. + let data_top = RING_BYTES + data_blob.len() as u32; + assert!( + data_top <= SCRATCH_BASE, + "literal data pool ({} bytes ending at {data_top:#x}) overflows into \ + the host-IO scratch window at {SCRATCH_BASE:#x}", + data_blob.len(), + ); + // Code: runtime's bodies raw, then user's bodies encoded. let mut code_sec = CodeSection::new(); for body in &rt.code_bodies_raw { @@ -738,16 +775,16 @@ pub fn emit_with_offsets(frag: &Fragment, interop: Interop) -> EmitOutput { user_body_offsets.push((final_idx, body_offsets)); } - // Data section: one active segment at offset 0 in memory 0 holding - // the concatenated blobs. Skip if there's no data. + // Data section: one active segment at `RING_BYTES` in memory 0 + // holding the concatenated blobs. Skip if there's no data. let data_sec = if data_blob.is_empty() { None } else { let mut sec = wasm_encoder::DataSection::new(); sec.active( - 0, // memory index - &ConstExpr::i32_const(0), // offset - data_blob.iter().copied(), // bytes + 0, // memory index + &ConstExpr::i32_const(RING_BYTES as i32), // offset + data_blob.iter().copied(), // bytes ); Some(sec) }; @@ -1186,6 +1223,54 @@ mod tests { assert!(!lr.bytes.is_empty(), "JS runtime should link to non-empty bytes"); } + /// The linear-memory map reserves a RING region at the bottom of + /// memory; the literal data pool must start at `RING_BYTES`, not at + /// offset 0. Asserted via the emitted data section's active-segment + /// offset. + #[test] + fn data_pool_starts_above_ring_region() { + let mut frag = Fragment::default(); + frag.data.push(DataDecl { bytes: b"hi".to_vec(), display: None }); + + let bytes = emit(&frag, Interop::Js); + + let mut seg_offset: Option = None; + let parser = wasmparser::Parser::new(0); + for payload in parser.parse_all(&bytes) { + if let Ok(wasmparser::Payload::DataSection(reader)) = payload { + for data in reader.into_iter().flatten() { + if let wasmparser::DataKind::Active { offset_expr, .. } = data.kind { + let mut ops = offset_expr.get_operators_reader(); + if let Ok(wasmparser::Operator::I32Const { value }) = ops.read() { + seg_offset = Some(value as u32 as u64); + } + } + } + } + } + + assert_eq!( + seg_offset, + Some(RING_BYTES as u64), + "data active segment should start at RING_BYTES ({RING_BYTES}), \ + leaving [0, RING_BYTES) reserved for the trace ring" + ); + } + + /// The data pool growing into the scratch window is a hard compile- + /// time error, not silent corruption. + #[test] + #[should_panic(expected = "overflows into the host-IO scratch window")] + fn data_pool_overflowing_scratch_window_panics() { + let mut frag = Fragment::default(); + // One blob large enough that RING_BYTES + len exceeds SCRATCH_BASE. + frag.data.push(DataDecl { + bytes: vec![0u8; SCRATCH_BASE as usize], + display: None, + }); + emit(&frag, Interop::Js); + } + #[test] fn js_runtime_exports_i31_helpers() { let lr = linked_runtime(Interop::Js); diff --git a/src/passes/wasm/lower.rs b/src/passes/wasm/lower.rs index 05215e7..172e183 100644 --- a/src/passes/wasm/lower.rs +++ b/src/passes/wasm/lower.rs @@ -50,6 +50,29 @@ fn origin_of(cps: &CpsResult, ast: &Ast<'_>, id: CpsId) -> Option { Some(ByteRange::new(loc.start.idx, loc.end.idx)) } +/// True iff this CpsId's source origin is an `Apply` AST node — i.e. a +/// call the user actually wrote, not a desugar-synthesised apply (pipe +/// expansion, partial application, etc.) whose origin is the surrounding +/// `InfixOp`/`Pipe`/lambda node. Used to gate trace instrumentation so +/// the trace reflects source-level calls. +fn is_source_apply(cps: &CpsResult, ast: &Ast<'_>, id: CpsId) -> bool { + let Some(Some(ast_id)) = cps.origin.try_get(id) else { return false }; + matches!(ast.nodes.get(*ast_id).kind, crate::ast::NodeKind::Apply { .. }) +} + +/// True iff this CpsId's source origin is a `Fn` AST node — i.e. a +/// function the user actually wrote, not a desugar-synthesised +/// `CpsFunction` (e.g. the `m_0`/`mp_N` match-block wrappers, whose +/// origin is the surrounding `Match` node). Used to gate trace-frame +/// pushes so the activation stack reflects only source-level functions; +/// synth `CpsFunction`s route through the no-push/inherit path like a +/// `CpsClosure`, keeping push/pop balanced and the trace free of `:0` +/// synth frames. +fn is_source_fn(cps: &CpsResult, ast: &Ast<'_>, id: CpsId) -> bool { + let Some(Some(ast_id)) = cps.origin.try_get(id) else { return false }; + matches!(ast.nodes.get(*ast_id).kind, crate::ast::NodeKind::Fn { .. }) +} + /// Lower a lifted CPS result to an unlinked wasm IR `Fragment`. /// /// `fqn_prefix` is the module's fully-qualified URL prefix (e.g. @@ -62,7 +85,7 @@ fn origin_of(cps: &CpsResult, ast: &Ast<'_>, id: CpsId) -> Option { /// Phase-4A: prefix is purely a cosmetic / naming concern. The entry /// function's export name still stays `"fink_module"`; rewiring the /// body to the `import_module` init-guard shape lands in 4D. -pub fn lower(cps: &CpsResult, ast: &Ast<'_>, fqn_prefix: &str) -> Fragment { +pub fn lower(cps: &CpsResult, ast: &Ast<'_>, fqn_prefix: &str, module_id: ModuleId) -> Fragment { let mut usage = runtime_contract::scan(cps); // Fn3 / ctx-aware lowering routes user-fn calls through `apply_3` // instead of `apply`. Mark the Apply3 runtime symbol so `declare()` @@ -70,6 +93,15 @@ pub fn lower(cps: &CpsResult, ast: &Ast<'_>, fqn_prefix: &str) -> Fragment { // harmless here; lower_ctx never emits a call to it. usage.mark(runtime_contract::Sym::Apply3); usage.mark(runtime_contract::Sym::Fn3); + // Trace instrumentation (rt/trace.wat): each userland fn body pushes a + // frame on entry and pops on return; each userland call site marks the + // current frame's call site. + usage.mark(runtime_contract::Sym::TracePush); + usage.mark(runtime_contract::Sym::TraceMark); + usage.mark(runtime_contract::Sym::TracePop); + // Each fink_module self-registers its (module_id, url) so trace frames + // resolve to a source url (rt/modules.wat). + usage.mark(runtime_contract::Sym::RegisterModule); // Per-module wrapper synthesised below uses init_module and the // closure/captures/str primitives. usage.mark(runtime_contract::Sym::ModulesInitModule); @@ -77,7 +109,11 @@ pub fn lower(cps: &CpsResult, ast: &Ast<'_>, fqn_prefix: &str) -> Fragment { usage.mark(runtime_contract::Sym::Captures); usage.mark(runtime_contract::Sym::Cell); usage.mark(runtime_contract::Sym::StrFromData); - let mut frag = Fragment::default(); + // module_id set here (not after lowering): trace_push / register_module + // bake the module id as a constant at emit time, so it must be correct + // during lowering. (compile_package used to set frag.module_id after + // lower returned, which was too late for those emitted constants.) + let mut frag = Fragment { module_id, ..Default::default() }; let rt = runtime_contract::declare(&mut frag, &usage); // CPS root shape: App(FinkModule, [Cont::Expr { args: [ƒctx, ƒret], body }]). @@ -172,7 +208,7 @@ pub fn lower(cps: &CpsResult, ast: &Ast<'_>, fqn_prefix: &str) -> Fragment { // CpsId. We walk the chain pre-order: outer LetFn first. let mut top_fn_syms: HashMap = HashMap::new(); let mut node = &lcx.cps.root; - while let ExprKind::LetFn { name, params, fn_body, cont, .. } = &node.kind { + while let ExprKind::LetFn { name, params, fn_body, cont, fn_kind, .. } = &node.kind { let mut cap_ids: Vec = Vec::new(); let mut user_ids: Vec<(CpsId, bool)> = Vec::new(); for p in params { @@ -188,10 +224,17 @@ pub fn lower(cps: &CpsResult, ast: &Ast<'_>, fqn_prefix: &str) -> Fragment { } let raw_display = cps_ident_for_bind(lcx.cps, lcx.ast, name); let display = format!("{}{}", lcx.fqn_prefix, raw_display); + use crate::passes::cps::ir::CpsFnKind; + let trace = match fn_kind { + CpsFnKind::CpsFunction if is_source_fn(lcx.cps, lcx.ast, name.id) => + TraceFrame::entry(name.id), + _ => TraceFrame::cont(None), // synth/closure: no frame, no enclosing + }; let fn_sym = lower_fn( &mut lcx, &cap_ids, &user_ids, fn_body, &display, &top_fn_syms, + trace, ); top_fn_syms.insert(name.id, fn_sym); node = match cont { @@ -207,6 +250,7 @@ pub fn lower(cps: &CpsResult, ast: &Ast<'_>, fqn_prefix: &str) -> Fragment { module_body, &module_display, &top_fn_syms, + TraceFrame::cont(None), // module body is synth: no frame, no enclosing ); let FuncSym::Local(_) = fink_module else { panic!("lower: fink_module must be Local"); }; // No WASM-level export for fink_module — host accesses the module @@ -214,6 +258,10 @@ pub fn lower(cps: &CpsResult, ast: &Ast<'_>, fqn_prefix: &str) -> Fragment { // canonical FQN. fink_module stays as a bare internal func; the // wrapper holds a no-capture closure over it. + // Self-register (module_id, url) at the top of fink_module so trace + // frames (which carry module_id) can resolve back to a source url. + prepend_module_registration(&mut lcx, fink_module); + // Per-module host-facing wrapper. Exported under the module's // canonical FQN so the host can call any module by URL string // (`instance.get_func(canonical_url)`). The wrapper composes the @@ -250,6 +298,47 @@ pub fn lower(cps: &CpsResult, ast: &Ast<'_>, fqn_prefix: &str) -> Fragment { /// synthesises a placeholder ctx (ref.i31 42) and tail-calls the /// body's Fn3 entry. Once the substrate lands, host-provided ctx /// flows in through the same channel. +/// Prepend a `register_module(module_id, url)` call to the top of the +/// module's `fink_module` body. `module_id` is the fragment's own id (a +/// compile-time constant); `url` is the canonical url materialised as a +/// `$Str`. This is how the runtime learns module_id → url for resolving +/// trace frames. +fn prepend_module_registration(lcx: &mut LowerCtx<'_>, fink_module: FuncSym) { + let FuncSym::Local(fi) = fink_module else { + panic!("prepend_module_registration: fink_module must be Local"); + }; + let fi = fi as usize; + + let canonical_url = lcx.fqn_prefix.trim_end_matches(':').to_string(); + let mid = lit_i32(lcx.frag.module_id.0 as i32); + + // Allocate a fresh local on fink_module for the url $Str. New locals + // index after params + existing locals. + let url_idx = LocalIdx( + (lcx.frag.funcs[fi].params.len() + lcx.frag.funcs[fi].locals.len()) as u32, + ); + lcx.frag.funcs[fi].locals.push(LocalDecl { + ty: val_anyref(true), + display: Some(":mod_reg_url".to_string()), + }); + + // url = from_data(intern(canonical_url)) — same materialisation the + // host wrapper uses for the registry key. + let sym = intern_data(lcx.frag, canonical_url.as_bytes()); + let len = canonical_url.len() as u32; + let i_url = push_call(lcx.frag, lcx.rt.str_from_data(), + vec![Operand::DataRef { sym, len }], Some(url_idx)); + + // register_module(mid, url) + let i_reg = push_call(lcx.frag, lcx.rt.register_module(), + vec![mid, op_local(url_idx)], None); + + // Prepend both, url-const first, before the existing body. + let body = &mut lcx.frag.funcs[fi].body; + body.insert(0, i_reg); + body.insert(0, i_url); +} + fn synth_host_wrapper( lcx: &mut LowerCtx<'_>, fink_module: FuncSym, @@ -367,6 +456,24 @@ struct LowerCtx<'a> { /// Lower a CPS function — either the module body or a LetFn'd helper. /// +/// Trace identity for a lowered function. `entry = Some(id)` means this +/// is a real userland function entry: push a frame for `id` at the +/// prologue and pops inside it target `id`. `entry = None` means a lifted +/// continuation (CpsClosure) - no push; its ret-cont pops target the +/// *enclosing* userland fn in `enclosing`. +#[derive(Clone, Copy, Default)] +struct TraceFrame { + entry: Option, + enclosing: Option, +} + +impl TraceFrame { + /// A real userland function entry, traced under its own id. + fn entry(id: CpsId) -> Self { Self { entry: Some(id), enclosing: None } } + /// A lifted continuation: no frame; ret-cont pops target `enclosing`. + fn cont(enclosing: Option) -> Self { Self { entry: None, enclosing } } +} + /// `cap_params` and `user_params` are the CpsIds of the function's /// cap-params (read from `$_caps` via `array.get`) and user-params /// (unpacked from `$_args` via successive `args_head`/`args_tail`). @@ -379,6 +486,7 @@ fn lower_fn( body: &Expr, display: &str, fn_syms: &HashMap, + trace: TraceFrame, ) -> FuncSym { // CRITICAL: `fn_syms` is cloned (not shared) into the child FnCtx. // Sibling and ancestor LetFn FuncSyms must be visible to this fn's @@ -449,6 +557,20 @@ fn lower_fn( } } + // Trace: a real userland function entry pushes an activation frame + // stamped with its own identity; pops inside it (when it invokes its + // return cont) target that frame. A lifted continuation (CpsClosure) + // does NOT push - it is part of the enclosing function - but its + // ret-cont invocations must pop the enclosing function's frame, so it + // inherits the enclosing fn's id for pop targeting. + ctx.trace_fn_id = trace.entry.or(trace.enclosing); + if let Some(fn_id) = trace.entry { + let mid = lit_i32(lcx.frag.module_id.0 as i32); + let cid = lit_i32(fn_id.0 as i32); + let i = push_call(lcx.frag, lcx.rt.trace_push(), vec![mid, cid], None); + ctx.instrs.push(i); + } + // Walk the body. lower_expr(lcx, &mut ctx, body); @@ -493,6 +615,12 @@ struct FnCtx { /// every "fresh" ctx CpsId at thread_ctx time aliases to the same /// wasm value at runtime. ctx_local: Option, + /// This function's own identity for trace instrumentation: the + /// defining LetFn's CpsId. `Some` for userland source functions (which + /// push/pop an activation frame); `None` for synth/runtime functions + /// (module body, host wrapper) which are not traced. Read by the + /// ret-cont arm to emit `trace_pop(module_id, fn_id)`. + trace_fn_id: Option, } impl FnCtx { @@ -505,6 +633,7 @@ impl FnCtx { next_local_idx: 0, fn_syms, ctx_local: None, + trace_fn_id: None, } } @@ -662,7 +791,7 @@ fn lower_expr( lower_cont(lcx, ctx, cont); } - ExprKind::LetFn { name, params, fn_body, cont, .. } => { + ExprKind::LetFn { name, params, fn_body, cont, fn_kind, .. } => { // Collect cap + user params by role. The `Bind::Caps` param is // the ƒcaps record (post closure-conversion); everything else is // a user param. User params carry their spread flag so the @@ -685,10 +814,22 @@ fn lower_expr( // module's FQN prefix so cross-fragment merges stay collision-free. let raw_display = cps_ident_for_bind(lcx.cps, lcx.ast, name); let display = format!("{}{}", lcx.fqn_prefix, raw_display); + // A source-level CpsFunction is a real userland fn (push its own + // frame); a CpsClosure is a lifted continuation (no push; its + // ret-cont pops the enclosing fn, inherited via ctx.trace_fn_id). + // Synth CpsFunctions (e.g. the m_0/mp_N match-block wrappers) + // inherit too — they are not source-level activations. + use crate::passes::cps::ir::CpsFnKind; + let trace = match fn_kind { + CpsFnKind::CpsFunction if is_source_fn(lcx.cps, lcx.ast, name.id) => + TraceFrame::entry(name.id), + _ => TraceFrame::cont(ctx.trace_fn_id), + }; let fn_sym = lower_fn( lcx, &cap_ids, &user_ids, fn_body, &display, &ctx.fn_syms, + trace, ); // The LetFn binds `name.id` to a funcref-valued local; we model // it as an anyref local holding a `ref.func` funcref. Actual @@ -1041,6 +1182,20 @@ fn lower_expr( } }; + // Trace pop: invoking this fn's return cont is the fn returning - + // pop its activation frame. Only for userland fns (trace_fn_id Some) + // and only when the cont being applied is this fn's Ret-kind cont. + if let Some(fn_id) = ctx.trace_fn_id + && matches!( + lcx.bind_kinds.try_get(cont_id).and_then(|b| *b), + Some(Bind::Cont(crate::passes::cps::ir::ContKind::Ret))) + { + let mid = lit_i32(lcx.frag.module_id.0 as i32); + let cid = lit_i32(fn_id.0 as i32); + let i = push_call(lcx.frag, lcx.rt.trace_pop(), vec![mid, cid], None); + ctx.instrs.push(i); + } + let (ctx_op, rest_args) = split_ctx_arg(lcx, ctx, args); let l_args_list = build_args_list(lcx, ctx, rest_args); let i_app = push_return_call(lcx.frag, lcx.rt.apply_3(), @@ -1069,6 +1224,7 @@ fn lower_expr( let (ctx_op, rest_args) = split_ctx_arg(lcx, ctx, args); let l_args_list = build_args_list(lcx, ctx, rest_args); + mark_call_site(lcx, ctx, expr.id); let i_app = push_return_call(lcx.frag, lcx.rt.apply_3(), vec![op_local(l_args_list), ctx_op, op_local(callee)]); set_cps_id(lcx.frag, i_app, expr.id); @@ -1328,6 +1484,25 @@ fn unbox_anyref( /// `done`) or a Cont::Expr (lifted into a closure — not handled here /// since the lifting pass already produces that as App(FnClosure) /// ahead of the tail call). +/// Emit `trace_mark(module_id, cps_id)` recording this call site into the +/// current (top) activation frame, immediately before the user-fn dispatch. +/// `cps_id` is the Apply node's id (the call site); `module_id` is the +/// fragment's own id. Updates "where in the current function we are". +/// +/// Only userland calls are marked: an Apply is marked iff it has a source +/// origin. Desugar-synthesised applies (pipe expansion, partial +/// application, etc.) have no origin and are skipped, so the trace +/// reflects source-level calls, not the finer post-desugar CPS structure. +fn mark_call_site(lcx: &mut LowerCtx<'_>, ctx: &mut FnCtx, call_site: CpsId) { + if !is_source_apply(lcx.cps, lcx.ast, call_site) { + return; + } + let module_id = lit_i32(lcx.frag.module_id.0 as i32); + let cps_id = lit_i32(call_site.0 as i32); + let i = push_call(lcx.frag, lcx.rt.trace_mark(), vec![module_id, cps_id], None); + ctx.instrs.push(i); +} + /// Build the `apply_3` args list from a heterogeneous arg sequence. /// /// Two-phase to keep the locals/instr order stable across changes: diff --git a/src/passes/wasm/mod.rs b/src/passes/wasm/mod.rs index db91801..cf18d15 100644 --- a/src/passes/wasm/mod.rs +++ b/src/passes/wasm/mod.rs @@ -204,7 +204,7 @@ mod tests { // Generic synthetic FQN — every fragment in the IR must have a // non-empty fqn_prefix; tests use `test:` so emitted exports // (per-module wrapper, etc.) are addressable by a stable name. - let user_frag = super::lower::lower(&lifted.result, &desugared.ast, "test:"); + let user_frag = super::lower::lower(&lifted.result, &desugared.ast, "test:", crate::passes::wasm::ir::ModuleId(0)); // Single-module programs today: the link step is a passthrough, // but routing through it keeps the tracer test surface honest // when multi-fragment merge arrives. @@ -292,7 +292,7 @@ mod tests { #[cfg(test)] fn emit_for(src: &str) -> Vec { let (lifted, desugared) = crate::to_lifted(src, "test").unwrap_or_else(|e| panic!("{e}")); - let user_frag = super::lower::lower(&lifted.result, &desugared.ast, "test:"); + let user_frag = super::lower::lower(&lifted.result, &desugared.ast, "test:", crate::passes::wasm::ir::ModuleId(0)); let linked = super::link::link(&[user_frag]); super::emit::emit(&linked, super::emit::Interop::Rust) } @@ -306,6 +306,35 @@ mod tests { /// helpers (args_empty + args_prepend) to construct. That full /// execution handshake is exercised by emit_executes_42 below. #[cfg(feature = "run")] + /// A user-function call site emits a `trace_push` recording the + /// call-site `(module_id, cps_id)` into the trace buffer, before the + /// `apply_3` dispatch. Builtin/runtime calls do NOT push. + #[test] + fn user_call_emits_trace_push() { + let out = wat("\ +add = fn a, b: + a + b +add 3, 4 +"); + assert!( + out.contains("rt/trace.wat:trace_push"), + "user-fn call should emit a trace_push at the call site; got:\n{out}" + ); + } + + /// Every module's `fink_module` self-registers its `(module_id, url)` + /// so `get_module_url` can resolve a trace frame's module id back to a + /// source url. The id is a compile-time constant; the url is the + /// module's canonical url string. + #[test] + fn fink_module_registers_its_url() { + let out = wat("42"); + assert!( + out.contains("rt/modules.wat:register_module"), + "fink_module should call register_module(mod_id, url); got:\n{out}" + ); + } + #[test] fn emit_instantiates_in_wasmtime() { use wasmtime::{Config, Engine, Module, Store, Linker, Error, ExternType}; diff --git a/src/passes/wasm/runtime_contract.rs b/src/passes/wasm/runtime_contract.rs index 0088a4a..52839f3 100644 --- a/src/passes/wasm/runtime_contract.rs +++ b/src/passes/wasm/runtime_contract.rs @@ -99,6 +99,18 @@ pub enum Sym { // 2c-B; until then, references are emitted as imports that will // remain unresolved (Phase A is shape-only, not runnable). Apply3, + // The trace primitives maintain a bounded activation stack in linear + // memory (rt/trace.wat). All `(i32, i32) -> ()`. + // TracePush(fn_mid, fn_cid) -- enter a userland fn body. + // TraceMark(call_mid, call_cid) -- a call site within the current fn. + // TracePop(fn_mid, fn_cid) -- leave a userland fn body. + TracePush, + TraceMark, + TracePop, + // RegisterModule records module_id → url so trace frames can resolve + // to a source url. Signature `(i32, anyref) -> ()`. Each fink_module + // self-registers. Defined in rt/modules.wat. + RegisterModule, // ── polymorphic protocol operators (rt/protocols.wat) ───────── // All binary operators share the shape (anyref, anyref, anyref) @@ -333,6 +345,10 @@ pub struct Runtime { args_concat: Option, apply: Option, apply_3: Option, + trace_push: Option, + trace_mark: Option, + trace_pop: Option, + register_module: Option, // polymorphic protocol operators op_plus: Option, op_minus: Option, @@ -427,6 +443,10 @@ impl Runtime { pub fn str_match(&self) -> FuncSym { self.str_match.expect("rt: str_match not declared") } pub fn apply(&self) -> FuncSym { self.apply.expect("rt: _apply not declared") } pub fn apply_3(&self) -> FuncSym { self.apply_3.expect("rt: apply_3 not declared") } + pub fn trace_push(&self) -> FuncSym { self.trace_push.expect("rt: trace_push not declared") } + pub fn trace_mark(&self) -> FuncSym { self.trace_mark.expect("rt: trace_mark not declared") } + pub fn trace_pop(&self) -> FuncSym { self.trace_pop.expect("rt: trace_pop not declared") } + pub fn register_module(&self) -> FuncSym { self.register_module.expect("rt: register_module not declared") } pub fn fn3(&self) -> TypeSym { self.fn3.expect("rt: Fn3 not declared") } /// Look up the runtime func for a protocol operator `Sym`. Panics @@ -511,6 +531,10 @@ pub(super) fn import_key(sym: Sym) -> &'static str { Sym::VarArgs => "rt/apply.wat:VarArgs", Sym::Apply => "rt/apply.wat:apply", Sym::Apply3 => "rt/apply.wat:apply_3", + Sym::TracePush => "rt/trace.wat:trace_push", + Sym::TraceMark => "rt/trace.wat:trace_mark", + Sym::TracePop => "rt/trace.wat:trace_pop", + Sym::RegisterModule => "rt/modules.wat:register_module", Sym::ArgsHead => "rt/apply.wat:args_head", Sym::ArgsTail => "rt/apply.wat:args_tail", @@ -663,6 +687,10 @@ pub fn declare(frag: &mut Fragment, usage: &RuntimeUsage) -> Runtime { if needed.contains(&Sym::ArgsConcat) { rt.args_concat = Some(FuncSym::Runtime(Sym::ArgsConcat)); } if needed.contains(&Sym::Apply) { rt.apply = Some(FuncSym::Runtime(Sym::Apply)); } if needed.contains(&Sym::Apply3) { rt.apply_3 = Some(FuncSym::Runtime(Sym::Apply3)); } + if needed.contains(&Sym::TracePush) { rt.trace_push = Some(FuncSym::Runtime(Sym::TracePush)); } + if needed.contains(&Sym::TraceMark) { rt.trace_mark = Some(FuncSym::Runtime(Sym::TraceMark)); } + if needed.contains(&Sym::TracePop) { rt.trace_pop = Some(FuncSym::Runtime(Sym::TracePop)); } + if needed.contains(&Sym::RegisterModule) { rt.register_module = Some(FuncSym::Runtime(Sym::RegisterModule)); } for sym in BINARY_OPS { if needed.contains(sym) { diff --git a/src/passes/wasm/test_bindings.fnk b/src/passes/wasm/test_bindings.fnk index 603523a..db6d827 100644 --- a/src/passes/wasm/test_bindings.fnk +++ b/src/passes/wasm/test_bindings.fnk @@ -19,6 +19,9 @@ test 'single binding export', fn: (local $:pub_name (ref null any)) (local $:unwrap_foo_0 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_1 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_foo_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:foo (local.get $:cell_foo_0)) @@ -46,7 +49,7 @@ test 'single binding export', fn: (data $d_0 "test") (data $d_1 "foo") ) - ;; sm:EbQIAJgBAJgBAGgBAAOGAQCgAQCqAQCUAQCWAQDKAQCwAQBuAM4BAKYFAHoA5gEAjAEA + ;; sm:E4YJAJwBAKYBAJgBAJgBAGgBAAOGAQCgAQCqAQCUAQCWAQDKAQCwAQBuAM4BAKYFAHoA5gEAjAEA @@ -66,6 +69,9 @@ test 'let binding', fn: (local $:pub_name (ref null any)) (local $:unwrap_x_0 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_1 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_x_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:x (local.get $:cell_x_0)) @@ -93,7 +99,7 @@ test 'let binding', fn: (data $d_0 "test") (data $d_1 "x") ) - ;; sm:EaQIAJgBAJQBAGABAAGEAQCYAQCiAQCUAQCWAQDGAQCoAQBuAMoBAKYFAHoA5gEAjAEA + ;; sm:E_YIAJwBAKYBAJgBAJQBAGABAAGEAQCYAQCiAQCUAQCWAQDGAQCoAQBuAMoBAKYFAHoA5gEAjAEA @@ -119,6 +125,9 @@ test 'multiple let bindings used', fn: (local $:pub_name (ref null any)) (local $:unwrap_x_0 (ref null any)) (local $:unwrap_y_1 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_2 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_x_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:x (local.get $:cell_x_0)) @@ -155,7 +164,7 @@ test 'multiple let bindings used', fn: (data $d_1 "x") (data $d_2 "y") ) - ;; sm:GMQLAJgBAJQBAGAAlAEAYAEAAYIBAJgBAKIBAJQBAJYBAMYBAQwBggEAmAEAogEAlAEAlgEAxgEAqAEAqAEBDAXuBQB6AOYBAIwBAA + ;; sm:GpYMAJwBAKYBAJgBAJQBAGAAlAEAYAEAAYIBAJgBAKIBAJQBAJYBAMYBAQwBggEAmAEAogEAlAEAlgEAxgEAqAEAqAEBDAXuBQB6AOYBAIwBAA @@ -176,6 +185,7 @@ test 'binding rhs is a call', fn: (local.set $a_2 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:params (call $rt/apply.wat:args_tail (local.get $:params))) (local.set $b_3 (call $rt/apply.wat:args_head (local.get $:params))) + (call $rt/trace.wat:trace_push (i32.const 0) (i32.const 61)) (return_call $std/operators.fnk:op_plus (local.get $:ctx_param) (local.get $a_2) (local.get $b_3) (local.get $:ret_6)) ) (func $test::v_55 (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) @@ -219,6 +229,9 @@ test 'binding rhs is a call', fn: (local $:lit_14 (ref null any)) (local $:lit_15 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_4 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_add_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:add (local.get $:cell_add_0)) @@ -240,6 +253,7 @@ test 'binding rhs is a call', fn: (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:lit_15) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:lit_14) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:v_45) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 21)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $:unwrap_add_0)) ) (func $test::host_wrapper (export "test") (type $test::Fn_host_wrapper) (param $:cont (ref null any)) @@ -258,7 +272,7 @@ test 'binding rhs is a call', fn: (data $d_1 "x") (data $d_2 "add") ) - ;; sm:LoIFAJgBAJoBAJIBAJoBAJIBAR4FwgoAlgEAugEAzgEAugEAxAEAngEAogEAlAEAlgEAxgEArAEAbgDMAQCYDQCYAQCYAQBoAJQBAGAAegDOAQCeAQCqAQCUAQCWAQDKAQDeAQDQAQCwAQEcAYoBAQYBigEAbgDCAQDCAQC-AQC0BQB6AOYBAIwBAA + ;; sm:MoIFAJgBAJoBAJIBAJoBAJIBAIIBAR4FwgoAlgEAugEAzgEAugEAxAEAngEAogEAlAEAlgEAxgEArAEAbgDMAQDqDQCcAQCmAQCYAQCYAQBoAJQBAGAAegDOAQCeAQCqAQCUAQCWAQDKAQDeAQDQAQCwAQEcAYoBAQYBigEAbgDCAQDCAQC-AQCCAQC0BQB6AOYBAIwBAA @@ -280,6 +294,7 @@ test 'top-level rec destructure then fn using binding', fn: (local.set $:ret_30 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:params (call $rt/apply.wat:args_tail (local.get $:params))) (local.set $a_2 (call $rt/apply.wat:args_head (local.get $:params))) + (call $rt/trace.wat:trace_push (i32.const 0) (i32.const 100)) (local.set $:caps_cast (ref.cast (ref $rt/apply.wat:Captures) (local.get $:caps_param))) (local.set $:slot_95_raw (array.get $rt/apply.wat:Captures (local.get $:caps_cast) (i32.const 0))) (local.set $:slot_95 (ref.cast (ref null $rt/apply.wat:Cell) (local.get $:slot_95_raw))) @@ -412,6 +427,9 @@ test 'top-level rec destructure then fn using binding', fn: (local $:lit_4 (ref null any)) (local $:lit_5 (ref null any)) (local $:lit_6 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_3 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_x_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test::x_0 (local.get $:cell_x_0)) @@ -440,6 +458,6 @@ test 'top-level rec destructure then fn using binding', fn: (data $d_1 "foo") (data $d_2 "x") ) - ;; sm:VL4IAJoBAJoBAJIBALoBAM4BALoBAKwBATQF3AoAlgEAugEAxgEAogEAvAEA0gEAoAEAqgEAlAEAlgEAygEAsAEAbgDOAQD8BgCWAQCaAQCWAQC6AQDIAQBuAL4BAMoIAJYBALoBAMgBAMgBALoBANIBATMNkgEBAA28BgC6AQDIAQBuAMgIAJwBAJoBAJwBAJoBAJQBAOQBANIBALgBANIBAQANtAQAWACkCQCUAQC6AQDGAQC4AQDSAQB6ANIBAHoA0gEAbgC8AQC-AQC-AQCwCQCYAQCUAQBmAJgBAGgAtAEA0gEBDAdgAQIBkAEBBgKKAQEFBewFAHoA5gEAjAEA + ;; sm:V74IAJoBAJoBAJIBAIQBALoBAM4BALoBAKwBATQF3AoAlgEAugEAxgEAogEAvAEA0gEAoAEAqgEAlAEAlgEAygEAsAEAbgDOAQD8BgCWAQCaAQCWAQC6AQDIAQBuAL4BAMoIAJYBALoBAMgBAMgBALoBANIBATMNkgEBAA28BgC6AQDIAQBuAMgIAJwBAJoBAJwBAJoBAJQBAOQBANIBALgBANIBAQANtAQAWACkCQCUAQC6AQDGAQC4AQDSAQB6ANIBAHoA0gEAbgC8AQC-AQC-AQCCCgCcAQCmAQCYAQCUAQBmAJgBAGgAtAEA0gEBDAdgAQIBkAEBBgKKAQEFBewFAHoA5gEAjAEA diff --git a/src/passes/wasm/test_collections.fnk b/src/passes/wasm/test_collections.fnk index c5bb608..7dc119f 100644 --- a/src/passes/wasm/test_collections.fnk +++ b/src/passes/wasm/test_collections.fnk @@ -84,6 +84,9 @@ test 'list with spread at tail', fn: (local $:caps_arg (ref null $rt/apply.wat:Captures)) (local $:lit_3 (ref null any)) (local $:lit_4 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_1 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_xs_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:xs (local.get $:cell_xs_0)) @@ -109,7 +112,7 @@ test 'list with spread at tail', fn: (data $d_0 "test") (data $d_1 "xs") ) - ;; sm:K8AHAJYBALoBAM4BALoBAMQBAK4BARoEiAwAlAEAugEAzgEAugEAxAEAnAEApgEAlAEAlgEAyAEA4gEA0AEBDAGKAQENCXIBDgHSCQCUAQC6AQDOAQC6AQDEAQDiAQDQAQEZAYgBAQABoggAmAEAlgEAZADgAQDQAQEGAYgBAQcGcAEIAcwFAHoA5gEAjAEA + ;; sm:LcAHAJYBALoBAM4BALoBAMQBAK4BARoEiAwAlAEAugEAzgEAugEAxAEAnAEApgEAlAEAlgEAyAEA4gEA0AEBDAGKAQENCXIBDgHSCQCUAQC6AQDOAQC6AQDEAQDiAQDQAQEZAYgBAQAB9AgAnAEApgEAmAEAlgEAZADgAQDQAQEGAYgBAQcGcAEIAcwFAHoA5gEAjAEA test 'list with spread at head', fn: @@ -185,6 +188,9 @@ test 'list with spread at head', fn: (local $:caps_arg (ref null $rt/apply.wat:Captures)) (local $:lit_3 (ref null any)) (local $:lit_4 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_1 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_xs_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:xs (local.get $:cell_xs_0)) @@ -209,7 +215,7 @@ test 'list with spread at head', fn: (data $d_0 "test") (data $d_1 "xs") ) - ;; sm:KfgFAJYBALoBAMQBARoBiAEBAAGIDACUAQC6AQDOAQC6AQDEAQCcAQCmAQCUAQCWAQDIAQC2AQDQAQCuAQEBCXIBCATcCQCUAQC6AQDOAQC6AQDEAQDiAQDQAQETAYgBAQABoggAmAEAlgEAZADgAQDQAQEGAYgBAQcGcAEIAcwFAHoA5gEAjAEA + ;; sm:K_gFAJYBALoBAMQBARoBiAEBAAGIDACUAQC6AQDOAQC6AQDEAQCcAQCmAQCUAQCWAQDIAQC2AQDQAQCuAQEBCXIBCATcCQCUAQC6AQDOAQC6AQDEAQDiAQDQAQETAYgBAQAB9AgAnAEApgEAmAEAlgEAZADgAQDQAQEGAYgBAQcGcAEIAcwFAHoA5gEAjAEA test 'list with two spreads', fn: @@ -355,6 +361,9 @@ test 'list with two spreads', fn: (local $:caps_arg (ref null $rt/apply.wat:Captures)) (local $:lit_4 (ref null any)) (local $:lit_5 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_2 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_a_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:a (local.get $:cell_a_0)) @@ -390,4 +399,4 @@ test 'list with two spreads', fn: (data $d_1 "b") (data $d_2 "a") ) - ;; sm:Tb4HAJYBALoBAM4BALoBAMQBAKwBAS4Dyg0AlgEAugEAzgEAugEAzgEAugEAxAEAngEAogEAlAEAlgEAxgEA4gEA0AEArAEBAQpyAQwDnAsAlgEAugEAzgEAugEAzgEAugEAxgEAkAIA0AEBFwGKAQEAAb4NAJQBALoBANABAL4BANABAL4BAMYBAJ4BAKIBAJQBAJYBAMYBAJQCANIBAQYBigEBBwZyAQgBmAsAlAEAugEA0AEAvgEA0AEAvgEAxgEAlAIA0gEBGwGIAQEAAYoJAJgBAJQBAGAAlAEAYACIAgDSAQEGAYgBAQcGcAEIAcwFAHoA5gEAjAEA + ;; sm:T74HAJYBALoBAM4BALoBAMQBAKwBAS4Dyg0AlgEAugEAzgEAugEAzgEAugEAxAEAngEAogEAlAEAlgEAxgEA4gEA0AEArAEBAQpyAQwDnAsAlgEAugEAzgEAugEAzgEAugEAxgEAkAIA0AEBFwGKAQEAAb4NAJQBALoBANABAL4BANABAL4BAMYBAJ4BAKIBAJQBAJYBAMYBAJQCANIBAQYBigEBBwZyAQgBmAsAlAEAugEA0AEAvgEA0AEAvgEAxgEAlAIA0gEBGwGIAQEAAdwJAJwBAKYBAJgBAJQBAGAAlAEAYACIAgDSAQEGAYgBAQcGcAEIAcwFAHoA5gEAjAEA diff --git a/src/passes/wasm/test_effects.fnk b/src/passes/wasm/test_effects.fnk index 741bc8f..2628f89 100644 --- a/src/passes/wasm/test_effects.fnk +++ b/src/passes/wasm/test_effects.fnk @@ -32,6 +32,7 @@ test 'set_ctx import + call', fn: (local.set $:args (call $rt/apply.wat:args_empty)) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:lit_28) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:ret_114) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 31)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $set_ctx_0)) ) (func $test::v_81 (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) @@ -133,6 +134,9 @@ test 'set_ctx import + call', fn: (local $:imp_val_set_ctx (ref null any)) (local $:imp_key_set_ctx (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_2 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_2 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:caps_arg (array.new_fixed $rt/apply.wat:Captures 1 (local.get $:ret_2))) (local.set $:v_73 (struct.new $rt/apply.wat:Closure (ref.func $test::v_127) (local.get $:caps_arg))) @@ -157,4 +161,4 @@ test 'set_ctx import + call', fn: (data $d_1 "set_ctx") (data $d_2 "test") ) - ;; sm:RYYIAJYBALoBAMYBAQIHXAFSBZIBAG4AwgEAxAEA-gYAlgEAmgEAlgEAugEAxgEAbgC-AQDCCACWAQC6AQDGAQDGAQC4AQDQAQFTIZIBAQAhtgYAugEAxgEAbgDCCACaAQCaAQCaAQCaAQCUAQDgAQDQAQC2AQDQAQEAIbQEAFgApAkAlAEAugEAxgEAuAEA0gEAegDSAQB6ANIBAG4AvAEAvgEAvgEAgAoAmAEAtAEA0gEAZAB-AKQBAJYCAG4AxAEApAUAegDmAQCMAQA + ;; sm:SIYIAJYBALoBAMYBAQIHXAFSBZIBAG4AwgEAxAEAggEA-gYAlgEAmgEAlgEAugEAxgEAbgC-AQDCCACWAQC6AQDGAQDGAQC4AQDQAQFTIZIBAQAhtgYAugEAxgEAbgDCCACaAQCaAQCaAQCaAQCUAQDgAQDQAQC2AQDQAQEAIbQEAFgApAkAlAEAugEAxgEAuAEA0gEAegDSAQB6ANIBAG4AvAEAvgEAvgEA0goAnAEApgEAmAEAtAEA0gEAZAB-AKQBAJYCAG4AxAEApAUAegDmAQCMAQA diff --git a/src/passes/wasm/test_functions.fnk b/src/passes/wasm/test_functions.fnk index 35412e7..b38d861 100644 --- a/src/passes/wasm/test_functions.fnk +++ b/src/passes/wasm/test_functions.fnk @@ -19,6 +19,7 @@ test 'user fn call', fn: (local.set $a_1 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:params (call $rt/apply.wat:args_tail (local.get $:params))) (local.set $b_2 (call $rt/apply.wat:args_head (local.get $:params))) + (call $rt/trace.wat:trace_push (i32.const 0) (i32.const 35)) (return_call $std/operators.fnk:op_plus (local.get $:ctx_param) (local.get $a_1) (local.get $b_2) (local.get $:ret_5)) ) (func $test::fink_module (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) @@ -33,6 +34,9 @@ test 'user fn call', fn: (local $:lit_13 (ref null any)) (local $:lit_14 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_3 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_add_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:add (local.get $:cell_add_0)) @@ -50,6 +54,7 @@ test 'user fn call', fn: (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:lit_14) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:lit_13) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:ret_3) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 17)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $:unwrap_add_0)) ) (func $test::host_wrapper (export "test") (type $test::Fn_host_wrapper) (param $:cont (ref null any)) @@ -65,7 +70,7 @@ test 'user fn call', fn: (data $d_0 "test") (data $d_1 "add") ) - ;; sm:HIIFAJgBAJoBAJIBAJoBAJIBASIFngsAmAEAmAEAaAB6AM4BAJ4BAKoBAJQBAJYBAMoBALABARQBigEBBgGKAQBuAMIBAMIBAMABALQFAHoA5gEAjAEA + ;; sm:IIIFAJgBAJoBAJIBAJoBAJIBAIIBASIF8AsAnAEApgEAmAEAmAEAaAB6AM4BAJ4BAKoBAJQBAJYBAMoBALABARQBigEBBgGKAQBuAMIBAMIBAMABAIIBALQFAHoA5gEAjAEA test 'chained fn calls', fn: @@ -87,6 +92,7 @@ test 'chained fn calls', fn: (local.set $:ret_7 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:params (call $rt/apply.wat:args_tail (local.get $:params))) (local.set $x_3 (call $rt/apply.wat:args_head (local.get $:params))) + (call $rt/trace.wat:trace_push (i32.const 0) (i32.const 89)) (local.set $:lit_9 (struct.new $std/int.wat:I64 (i64.const 2))) (return_call $std/operators.fnk:op_mul (local.get $:ctx_param) (local.get $x_3) (local.get $:lit_9) (local.get $:ret_7)) ) @@ -97,6 +103,7 @@ test 'chained fn calls', fn: (local.set $:ret_15 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:params (call $rt/apply.wat:args_tail (local.get $:params))) (local.set $x_4 (call $rt/apply.wat:args_head (local.get $:params))) + (call $rt/trace.wat:trace_push (i32.const 0) (i32.const 83)) (local.set $:lit_17 (struct.new $std/int.wat:I64 (i64.const 1))) (return_call $std/operators.fnk:op_plus (local.get $:ctx_param) (local.get $x_4) (local.get $:lit_17) (local.get $:ret_15)) ) @@ -131,6 +138,7 @@ test 'chained fn calls', fn: (local.set $:args (call $rt/apply.wat:args_empty)) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:unwrap_x_68) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:ret_70) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 30)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $:unwrap_inc_69)) ) (func $test::fink_module (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) @@ -153,6 +161,9 @@ test 'chained fn calls', fn: (local $:unwrap_double_0 (ref null any)) (local $:lit_23 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_5 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_double_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:double (local.get $:cell_double_0)) @@ -181,6 +192,7 @@ test 'chained fn calls', fn: (local.set $:args (call $rt/apply.wat:args_empty)) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:lit_23) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:v_65) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 34)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $:unwrap_double_0)) ) (func $test::host_wrapper (export "test") (type $test::Fn_host_wrapper) (param $:cont (ref null any)) @@ -202,7 +214,7 @@ test 'chained fn calls', fn: (data $d_2 "double") (data $d_3 "inc") ) - ;; sm:PYgFAJgBAJoBAJIBASoBiAEBBwX6BQCaAQCaAQCSAQEwAYoBAQcF3AwAlgEAugEAzgEAugEAzgEAugEAxAEAngEAogEAlAEAlgEAxgEAsAEArAEAbgDMAQDCAQD4EACYAQCeAQB0AJgBAGgAlAEAYAB6AM4BAKQBALYBAJQBAJYBANABAHoA0AEAoAEAqgEAlAEAlgEAygEAjAIA0AEAvAEBJAGKAQBuAMIBAL4BALoFAHoA5gEAjAEA + ;; sm:Q4gFAJgBAJoBAJIBAIIBASoBiAEBBwX6BQCaAQCaAQCSAQCCAQEwAYoBAQcF3AwAlgEAugEAzgEAugEAzgEAugEAxAEAngEAogEAlAEAlgEAxgEAsAEArAEAbgDMAQDCAQCCAQDKEQCcAQCmAQCYAQCeAQB0AJgBAGgAlAEAYAB6AM4BAKQBALYBAJQBAJYBANABAHoA0AEAoAEAqgEAlAEAlgEAygEAjAIA0AEAvAEBJAGKAQBuAMIBAL4BAIIBALoFAHoA5gEAjAEA test 'pipe unary', fn: @@ -223,6 +235,7 @@ test 'pipe unary', fn: (local.set $:ret_6 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:params (call $rt/apply.wat:args_tail (local.get $:params))) (local.set $x_2 (call $rt/apply.wat:args_head (local.get $:params))) + (call $rt/trace.wat:trace_push (i32.const 0) (i32.const 79)) (local.set $:lit_8 (struct.new $std/int.wat:I64 (i64.const 2))) (return_call $std/operators.fnk:op_mul (local.get $:ctx_param) (local.get $x_2) (local.get $:lit_8) (local.get $:ret_6)) ) @@ -233,6 +246,7 @@ test 'pipe unary', fn: (local.set $:ret_14 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:params (call $rt/apply.wat:args_tail (local.get $:params))) (local.set $x_3 (call $rt/apply.wat:args_head (local.get $:params))) + (call $rt/trace.wat:trace_push (i32.const 0) (i32.const 73)) (local.set $:lit_16 (struct.new $std/int.wat:I64 (i64.const 1))) (return_call $std/operators.fnk:op_plus (local.get $:ctx_param) (local.get $x_3) (local.get $:lit_16) (local.get $:ret_14)) ) @@ -274,6 +288,9 @@ test 'pipe unary', fn: (local $:unwrap_double_0 (ref null any)) (local $:lit_21 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_4 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_double_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:double (local.get $:cell_double_0)) @@ -318,7 +335,7 @@ test 'pipe unary', fn: (data $d_1 "double") (data $d_2 "inc") ) - ;; sm:M4gFAJgBAJoBAJIBASoBiAEBBwX6BQCaAQCaAQCSAQEwAYoBAQcF8AgAlgEAugEAzgEAugEAxAEAsAEAbgC-AQDCAQCOEACYAQCeAQB0AJgBAGgAegDOAQCkAQC2AQCUAQCWAQDQAQB6ANABAKABAKoBAJQBAJYBAMoBAOIBANABALwBAQ4BigEAbgDCAQC-AQC6BQB6AOYBAIwBAA + ;; sm:N4gFAJgBAJoBAJIBAIIBASoBiAEBBwX6BQCaAQCaAQCSAQCCAQEwAYoBAQcF8AgAlgEAugEAzgEAugEAxAEAsAEAbgC-AQDCAQDgEACcAQCmAQCYAQCeAQB0AJgBAGgAegDOAQCkAQC2AQCUAQCWAQDQAQB6ANABAKABAKoBAJQBAJYBAMoBAOIBANABALwBAQ4BigEAbgDCAQC-AQC6BQB6AOYBAIwBAA test 'match literal first arm', fn: @@ -511,6 +528,9 @@ test 'match literal first arm', fn: (local $:caps_arg (ref null $rt/apply.wat:Captures)) (local $:lit_1 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:caps_arg (ref.null $rt/apply.wat:Captures)) (local.set $:v_25 (struct.new $rt/apply.wat:Closure (ref.func $test::v_190) (local.get $:caps_arg))) @@ -539,7 +559,7 @@ test 'match literal first arm', fn: ) (data $d_0 "test") ) - ;; sm:aIgFAJoBARwCjAEAbgDCAQC4BgC6AQDCAQDIAQBuAMYBALIIAJYBALoBAMgBAMgBAIYBAHwAwgwAmgEAmgEAmgEAmgEAlAEA4AEA1AEBBQGKAQEAAdYKAJoBAJoBAJoBAJoBAJQBALoBAMIBAN4BANIBAHoA0gEAbgC8AQDCAQC-AQDIBQCaAQEWAowBAG4AwgEAxAcAnAEAmgEAnAEAmgEAlgEAugEAwgEAbgDEAQCABABYAIQHALoBAMIBAMYBAMIBAHoA1AEAbgDAAQDAAQDEAQD0CACaAQCaAQCWAQC6AQDCAQDCAQCEAgDUAQBuAL4BAMABAMIBAOAMAJgBAHoA0gEAsgEA0gEAegDSAQCyAQDSAQDYAQDSAQEfAYgBAG4AwAEAwAEApAUAegDmAQCMAQA + ;; sm:aogFAJoBARwCjAEAbgDCAQC4BgC6AQDCAQDIAQBuAMYBALIIAJYBALoBAMgBAMgBAIYBAHwAwgwAmgEAmgEAmgEAmgEAlAEA4AEA1AEBBQGKAQEAAdYKAJoBAJoBAJoBAJoBAJQBALoBAMIBAN4BANIBAHoA0gEAbgC8AQDCAQC-AQDIBQCaAQEWAowBAG4AwgEAxAcAnAEAmgEAnAEAmgEAlgEAugEAwgEAbgDEAQCABABYAIQHALoBAMIBAMYBAMIBAHoA1AEAbgDAAQDAAQDEAQD0CACaAQCaAQCWAQC6AQDCAQDCAQCEAgDUAQBuAL4BAMABAMIBALINAJwBAKYBAJgBAHoA0gEAsgEA0gEAegDSAQCyAQDSAQDYAQDSAQEfAYgBAG4AwAEAwAEApAUAegDmAQCMAQA test 'match with binding', fn: @@ -743,6 +763,9 @@ test 'match with binding', fn: (local $:caps_arg (ref null $rt/apply.wat:Captures)) (local $:unwrap_x_0 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_1 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_x_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:x (local.get $:cell_x_0)) @@ -782,7 +805,7 @@ test 'match with binding', fn: (data $d_0 "test") (data $d_1 "x") ) - ;; sm:cogFAJoBASgBigEAbgDCAQC4BgC6AQDCAQDIAQBuAMYBALIIAJYBALoBAMgBAMgBAIYBAHwAxAwAmgEAmgEAnAEAmgEAlAEA4gEA1AEBBQGKAQEAAdYKAJoBAJoBAJoBAJoBAJQBALoBAMIBAN4BANIBAHoA0gEAbgC8AQDCAQC-AQCKCACaAQC6AQDQAQC-AQCwAQEcAYoBAQcFiAgAnAEAmgEAnAEAmgEAlgEAugEAwgEAbgDEAQCABABYAIQHALoBAMIBAMYBAMIBAHoA1AEAbgDAAQDAAQDEAQD0CACaAQCaAQCWAQC6AQDCAQDCAQCEAgDUAQBuAL4BAMABAMIBAPQPAJgBAJQBAGABNQGCAQCYAQCiAQCUAQCWAQDGAQB6ANIBALIBANIBALYBANIBALIBANIBANgBANIBAKgBAG4AygEAwAEApAUAegDmAQCMAQA + ;; sm:dIgFAJoBASgBigEAbgDCAQC4BgC6AQDCAQDIAQBuAMYBALIIAJYBALoBAMgBAMgBAIYBAHwAxAwAmgEAmgEAnAEAmgEAlAEA4gEA1AEBBQGKAQEAAdYKAJoBAJoBAJoBAJoBAJQBALoBAMIBAN4BANIBAHoA0gEAbgC8AQDCAQC-AQCKCACaAQC6AQDQAQC-AQCwAQEcAYoBAQcFiAgAnAEAmgEAnAEAmgEAlgEAugEAwgEAbgDEAQCABABYAIQHALoBAMIBAMYBAMIBAHoA1AEAbgDAAQDAAQDEAQD0CACaAQCaAQCWAQC6AQDCAQDCAQCEAgDUAQBuAL4BAMABAMIBAMYQAJwBAKYBAJgBAJQBAGABNQGCAQCYAQCiAQCUAQCWAQDGAQB6ANIBALIBANIBALYBANIBALIBANIBANgBANIBAKgBAG4AygEAwAEApAUAegDmAQCMAQA test 'simple recursion', fn: @@ -906,6 +929,7 @@ test 'simple recursion', fn: (local.set $:args (call $rt/apply.wat:args_empty)) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:v_50) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:ret_171) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 54)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $:unwrap_recurse_170)) ) (func $test::v_223 (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) @@ -1012,6 +1036,7 @@ test 'simple recursion', fn: (local.set $:ret_4 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:params (call $rt/apply.wat:args_tail (local.get $:params))) (local.set $n_1 (call $rt/apply.wat:args_head (local.get $:params))) + (call $rt/trace.wat:trace_push (i32.const 0) (i32.const 245)) (local.set $:caps_cast (ref.cast (ref $rt/apply.wat:Captures) (local.get $:caps_param))) (local.set $:slot_240_raw (array.get $rt/apply.wat:Captures (local.get $:caps_cast) (i32.const 0))) (local.set $:slot_240 (ref.cast (ref null $rt/apply.wat:Cell) (local.get $:slot_240_raw))) @@ -1041,6 +1066,9 @@ test 'simple recursion', fn: (local $:unwrap_recurse_0 (ref null any)) (local $:lit_91 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_2 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_recurse_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:recurse (local.get $:cell_recurse_0)) @@ -1056,6 +1084,7 @@ test 'simple recursion', fn: (local.set $:args (call $rt/apply.wat:args_empty)) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:lit_91) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:ret_2) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 94)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $:unwrap_recurse_0)) ) (func $test::host_wrapper (export "test") (type $test::Fn_host_wrapper) (param $:cont (ref null any)) @@ -1074,7 +1103,7 @@ test 'simple recursion', fn: (data $d_0 "test") (data $d_1 "recurse") ) - ;; sm:igGIBQCaAQFEAowBAG4AwgEAuAYAugEAwgEAyAEAbgDGAQCyCACWAQC6AQDIAQDIAQCGAQB8AMgMAJwBAJoBAJwBAJoBAJYBAOQBANQBAQUBigEBAAHYCgCaAQCaAQCaAQCaAQCUAQC6AQDCAQDeAQDSAQB6ANIBAG4AvAEAwgEAvgEAzggAlgEAugEA0AEAvgEAxgEAvAEAbgC-AQDEAQDOCQCaAQC6AQDQAQC-AQDAAQDkAQDUAQEyAYoBAQcF-AcAnAEAmgEAnAEAmgEAlgEAugEAwgEAbgDEAQCABABYAIQHALoBAMIBAMYBAMIBAHoA1AEAbgDAAQDAAQDEAQD0CACaAQCaAQCWAQC6AQDCAQDCAQCEAgDUAQBuAL4BAMABAMIBAPYOAJgBAJoBAJIBALoBANABAL4BAHoA0gEAsgEA0gEA3AEA0gEAsgEA0gEA2AEA0gEAbgC6AQDAAQDECgCYAQCgAQB4AMIBANABAKYBALoBAJQBAJYBANIBAMABARwBigEAbgDCAQDAAQC8BQB6AOYBAIwBAA + ;; sm:jwGIBQCaAQFEAowBAG4AwgEAuAYAugEAwgEAyAEAbgDGAQCyCACWAQC6AQDIAQDIAQCGAQB8AMgMAJwBAJoBAJwBAJoBAJYBAOQBANQBAQUBigEBAAHYCgCaAQCaAQCaAQCaAQCUAQC6AQDCAQDeAQDSAQB6ANIBAG4AvAEAwgEAvgEAzggAlgEAugEA0AEAvgEAxgEAvAEAbgC-AQDEAQCCAQDOCQCaAQC6AQDQAQC-AQDAAQDkAQDUAQEyAYoBAQcF-AcAnAEAmgEAnAEAmgEAlgEAugEAwgEAbgDEAQCABABYAIQHALoBAMIBAMYBAMIBAHoA1AEAbgDAAQDAAQDEAQD0CACaAQCaAQCWAQC6AQDCAQDCAQCEAgDUAQBuAL4BAMABAMIBAPYOAJgBAJoBAJIBAIQBALoBANABAL4BAHoA0gEAsgEA0gEA3AEA0gEAsgEA0gEA2AEA0gEAbgC6AQDAAQCWCwCcAQCmAQCYAQCgAQB4AMIBANABAKYBALoBAJQBAJYBANIBAMABARwBigEAbgDCAQDAAQCCAQC8BQB6AOYBAIwBAA test 'mutual recursion — ping pong', fn: @@ -1096,6 +1125,7 @@ test 'mutual recursion — ping pong', fn: (local.set $:ret_6 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:params (call $rt/apply.wat:args_tail (local.get $:params))) (local.set $x_2 (call $rt/apply.wat:args_head (local.get $:params))) + (call $rt/trace.wat:trace_push (i32.const 0) (i32.const 63)) (local.set $:caps_cast (ref.cast (ref $rt/apply.wat:Captures) (local.get $:caps_param))) (local.set $:slot_58_raw (array.get $rt/apply.wat:Captures (local.get $:caps_cast) (i32.const 0))) (local.set $:slot_58 (ref.cast (ref null $rt/apply.wat:Cell) (local.get $:slot_58_raw))) @@ -1103,6 +1133,7 @@ test 'mutual recursion — ping pong', fn: (local.set $:args (call $rt/apply.wat:args_empty)) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $x_2) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:ret_6) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 11)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $:unwrap_pong_58)) ) (func $test::v_55 (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) @@ -1116,6 +1147,7 @@ test 'mutual recursion — ping pong', fn: (local.set $:ret_14 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:params (call $rt/apply.wat:args_tail (local.get $:params))) (local.set $x_3 (call $rt/apply.wat:args_head (local.get $:params))) + (call $rt/trace.wat:trace_push (i32.const 0) (i32.const 55)) (local.set $:caps_cast (ref.cast (ref $rt/apply.wat:Captures) (local.get $:caps_param))) (local.set $:slot_50_raw (array.get $rt/apply.wat:Captures (local.get $:caps_cast) (i32.const 0))) (local.set $:slot_50 (ref.cast (ref null $rt/apply.wat:Cell) (local.get $:slot_50_raw))) @@ -1123,6 +1155,7 @@ test 'mutual recursion — ping pong', fn: (local.set $:args (call $rt/apply.wat:args_empty)) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $x_3) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:ret_14) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 19)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $:unwrap_ping_50)) ) (func $test::fink_module (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) @@ -1142,6 +1175,9 @@ test 'mutual recursion — ping pong', fn: (local $:unwrap_ping_0 (ref null any)) (local $:lit_22 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_4 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_ping_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:ping (local.get $:cell_ping_0)) @@ -1166,6 +1202,7 @@ test 'mutual recursion — ping pong', fn: (local.set $:args (call $rt/apply.wat:args_empty)) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:lit_22) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:ret_4) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 25)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $:unwrap_ping_0)) ) (func $test::host_wrapper (export "test") (type $test::Fn_host_wrapper) (param $:cont (ref null any)) @@ -1185,7 +1222,7 @@ test 'mutual recursion — ping pong', fn: (data $d_1 "ping") (data $d_2 "pong") ) - ;; sm:M_gHAJgBAJoBAJIBALoBAM4BALoBALIBAG4AugEAwAEAzggAmgEAmgEAkgEAugEAzgEAugEAsgEAbgC6AQDCAQDSDgCYAQCaAQBsAJoBAGwAvAEAzgEAoAEArgEAlAEAlgEAzAEAvAEA0AEAogEArgEAlAEAlgEAzAEAtAEBWgGKAQBuAMIBAMABALYFAHoA5gEAjAEA + ;; sm:OvgHAJgBAJoBAJIBAIIBALoBAM4BALoBALIBAG4AugEAwAEAggEAzggAmgEAmgEAkgEAggEAugEAzgEAugEAsgEAbgC6AQDCAQCCAQCkDwCcAQCmAQCYAQCaAQBsAJoBAGwAvAEAzgEAoAEArgEAlAEAlgEAzAEAvAEA0AEAogEArgEAlAEAlgEAzAEAtAEBWgGKAQBuAMIBAMABAIIBALYFAHoA5gEAjAEA test 'mutual recursion — is_even / is_odd', fn: @@ -1312,6 +1349,7 @@ test 'mutual recursion — is_even / is_odd', fn: (local.set $:args (call $rt/apply.wat:args_empty)) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:v_52) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:ret_305) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 56)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $:unwrap_is_odd_304)) ) (func $test::v_357 (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) @@ -1418,6 +1456,7 @@ test 'mutual recursion — is_even / is_odd', fn: (local.set $:ret_6 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:params (call $rt/apply.wat:args_tail (local.get $:params))) (local.set $n_2 (call $rt/apply.wat:args_head (local.get $:params))) + (call $rt/trace.wat:trace_push (i32.const 0) (i32.const 483)) (local.set $:caps_cast (ref.cast (ref $rt/apply.wat:Captures) (local.get $:caps_param))) (local.set $:slot_478_raw (array.get $rt/apply.wat:Captures (local.get $:caps_cast) (i32.const 0))) (local.set $:slot_478 (ref.cast (ref null $rt/apply.wat:Cell) (local.get $:slot_478_raw))) @@ -1546,6 +1585,7 @@ test 'mutual recursion — is_even / is_odd', fn: (local.set $:args (call $rt/apply.wat:args_empty)) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:v_139) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:ret_401) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 143)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $:unwrap_is_even_400)) ) (func $test::v_453 (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) @@ -1652,6 +1692,7 @@ test 'mutual recursion — is_even / is_odd', fn: (local.set $:ret_93 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:params (call $rt/apply.wat:args_tail (local.get $:params))) (local.set $n_3 (call $rt/apply.wat:args_head (local.get $:params))) + (call $rt/trace.wat:trace_push (i32.const 0) (i32.const 475)) (local.set $:caps_cast (ref.cast (ref $rt/apply.wat:Captures) (local.get $:caps_param))) (local.set $:slot_470_raw (array.get $rt/apply.wat:Captures (local.get $:caps_cast) (i32.const 0))) (local.set $:slot_470 (ref.cast (ref null $rt/apply.wat:Cell) (local.get $:slot_470_raw))) @@ -1687,6 +1728,9 @@ test 'mutual recursion — is_even / is_odd', fn: (local $:unwrap_is_even_0 (ref null any)) (local $:lit_180 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_4 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_is_even_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:is_even (local.get $:cell_is_even_0)) @@ -1711,6 +1755,7 @@ test 'mutual recursion — is_even / is_odd', fn: (local.set $:args (call $rt/apply.wat:args_empty)) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:lit_180) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:ret_4) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 183)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $:unwrap_is_even_0)) ) (func $test::host_wrapper (export "test") (type $test::Fn_host_wrapper) (param $:cont (ref null any)) @@ -1734,7 +1779,7 @@ test 'mutual recursion — is_even / is_odd', fn: (data $d_1 "is_even") (data $d_2 "is_odd") ) - ;; sm:iQKIBQCaAQFEBGIAbgDCAQC4BgC6AQDCAQDIAQBuAMYBALIIAJYBALoBAMgBAMgBAIYBAHwAyAwAnAEAmgEAnAEAmgEAlgEA5AEA1AEBBQGKAQEAAdoKAJoBAJoBAJwBAJoBAJQBALoBAMIBAN4BANIBAHoA0gEAbgC8AQDEAQC-AQDMCACWAQC6AQDQAQC-AQDGAQC6AQBuAL4BAMQBAMwJAJoBALoBANABAL4BAMABAOQBANQBATQBigEBBwX4BwCcAQCaAQCcAQCaAQCWAQC6AQDCAQBuAMQBAIAEAFgAhAcAugEAwgEAxgEAwgEAegDUAQBuAMABAMABAMQBAPQIAJoBAJoBAJYBALoBAMIBAMIBAIQCANQBAG4AvgEAwAEAwgEA9g4AmAEAmgEAkgEAugEA0AEAvgEAegDSAQCyAQDSAQDcAQDSAQCyAQDSAQDYAQDSAQBuALoBAMABAMwFAJwBAU4FZABuAMQBALoGALoBAMIBAMgBAG4AxgEAtAgAmAEAugEAyAEAyAEAiAEAfADODACeAQCaAQCeAQCaAQCWAQDoAQDUAQEFAYwBAQAB5AoAnAEAmgEAnAEAmgEAlgEAugEAwgEA4AEA1AEAegDUAQBuAL4BAMQBAMABANIIAJgBALoBANABAL4BAMYBALwBAG4AwAEAxAEA0gkAnAEAugEA0AEAvgEAwAEA5gEA1AEBOAGMAQEHBYAIAJ4BAJoBAJ4BAJoBAJgBALoBAMIBAG4AxgEAgAQAWACEBwC6AQDCAQDGAQDCAQB6ANQBAG4AwAEAwAEAxAEA-AgAnAEAmgEAmAEAugEAwgEAwgEAiAIA1AEAbgDAAQDAAQDEAQCCDwCaAQCaAQCSAQC6AQDQAQC-AQB6ANQBALQBANQBANwBANQBALQBANQBANwBANQBAG4AugEAwgEA3A4AmAEAoAEAeACeAQB0AMABANABAKYBALoBAJQBAJYBANIBAMIBANIBAKYBALYBAJQBAJYBANABAMABARwBjAEAbgDEAQDAAQC8BQB6AOYBAIwBAA + ;; sm:kAKIBQCaAQFEBGIAbgDCAQC4BgC6AQDCAQDIAQBuAMYBALIIAJYBALoBAMgBAMgBAIYBAHwAyAwAnAEAmgEAnAEAmgEAlgEA5AEA1AEBBQGKAQEAAdoKAJoBAJoBAJwBAJoBAJQBALoBAMIBAN4BANIBAHoA0gEAbgC8AQDEAQC-AQDMCACWAQC6AQDQAQC-AQDGAQC6AQBuAL4BAMQBAIIBAMwJAJoBALoBANABAL4BAMABAOQBANQBATQBigEBBwX4BwCcAQCaAQCcAQCaAQCWAQC6AQDCAQBuAMQBAIAEAFgAhAcAugEAwgEAxgEAwgEAegDUAQBuAMABAMABAMQBAPQIAJoBAJoBAJYBALoBAMIBAMIBAIQCANQBAG4AvgEAwAEAwgEA9g4AmAEAmgEAkgEAhAEAugEA0AEAvgEAegDSAQCyAQDSAQDcAQDSAQCyAQDSAQDYAQDSAQBuALoBAMABAMwFAJwBAU4FZABuAMQBALoGALoBAMIBAMgBAG4AxgEAtAgAmAEAugEAyAEAyAEAiAEAfADODACeAQCaAQCeAQCaAQCWAQDoAQDUAQEFAYwBAQAB5AoAnAEAmgEAnAEAmgEAlgEAugEAwgEA4AEA1AEAegDUAQBuAL4BAMQBAMABANIIAJgBALoBANABAL4BAMYBALwBAG4AwAEAxAEAhAEA0gkAnAEAugEA0AEAvgEAwAEA5gEA1AEBOAGMAQEHBYAIAJ4BAJoBAJ4BAJoBAJgBALoBAMIBAG4AxgEAgAQAWACEBwC6AQDCAQDGAQDCAQB6ANQBAG4AwAEAwAEAxAEA-AgAnAEAmgEAmAEAugEAwgEAwgEAiAIA1AEAbgDAAQDAAQDEAQCCDwCaAQCaAQCSAQCEAQC6AQDQAQC-AQB6ANQBALQBANQBANwBANQBALQBANQBANwBANQBAG4AugEAwgEArg8AnAEApgEAmAEAoAEAeACeAQB0AMABANABAKYBALoBAJQBAJYBANIBAMIBANIBAKYBALYBAJQBAJYBANABAMABARwBjAEAbgDEAQDAAQCEAQC8BQB6AOYBAIwBAA test 'closure construction and call', fn: @@ -1754,6 +1799,7 @@ test 'closure construction and call', fn: (local.set $:ret_8 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:params (call $rt/apply.wat:args_tail (local.get $:params))) (local.set $y_3 (call $rt/apply.wat:args_head (local.get $:params))) + (call $rt/trace.wat:trace_push (i32.const 0) (i32.const 59)) (local.set $:caps_cast (ref.cast (ref $rt/apply.wat:Captures) (local.get $:caps_param))) (local.set $x_54 (array.get $rt/apply.wat:Captures (local.get $:caps_cast) (i32.const 0))) (return_call $std/operators.fnk:op_plus (local.get $:ctx_param) (local.get $x_54) (local.get $y_3) (local.get $:ret_8)) @@ -1767,8 +1813,10 @@ test 'closure construction and call', fn: (local.set $:ret_6 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:params (call $rt/apply.wat:args_tail (local.get $:params))) (local.set $x_2 (call $rt/apply.wat:args_head (local.get $:params))) + (call $rt/trace.wat:trace_push (i32.const 0) (i32.const 79)) (local.set $:caps_arg (array.new_fixed $rt/apply.wat:Captures 1 (local.get $x_2))) (local.set $:v_7 (struct.new $rt/apply.wat:Closure (ref.func $test::v_59) (local.get $:caps_arg))) + (call $rt/trace.wat:trace_pop (i32.const 0) (i32.const 79)) (local.set $:args (call $rt/apply.wat:args_empty)) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:v_7) (local.get $:args))) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $:ret_6)) @@ -1800,6 +1848,7 @@ test 'closure construction and call', fn: (local.set $:args (call $rt/apply.wat:args_empty)) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:lit_22) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:ret_67) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 25)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $:unwrap_add1_66)) ) (func $test::fink_module (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) @@ -1816,6 +1865,9 @@ test 'closure construction and call', fn: (local $:unwrap_add_0 (ref null any)) (local $:lit_18 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_4 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_add_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:add (local.get $:cell_add_0)) @@ -1835,6 +1887,7 @@ test 'closure construction and call', fn: (local.set $:args (call $rt/apply.wat:args_empty)) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:lit_18) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:v_51) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 29)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $:unwrap_add_0)) ) (func $test::host_wrapper (export "test") (type $test::Fn_host_wrapper) (param $:cont (ref null any)) @@ -1853,7 +1906,7 @@ test 'closure construction and call', fn: (data $d_1 "add1") (data $d_2 "add") ) - ;; sm:Nu4FAJgBAJoBAJIBALoBAL4BASgFnAcAmAEAmgEAkgEArgEAzgEAbgC8AQDuCgCWAQC6AQDOAQC6AQDEAQCeAQCuAQCUAQCWAQDMAQCyAQEwAYoBAG4AwgEAwgEA5gwAmAEAmAEAaACaAQBsAHoAzgEAngEAqgEAlAEAlgEAygEA5AEA0AEAsAEBDQGKAQBuAMIBAL4BALQFAHoA5gEAjAEA + ;; sm:Pe4FAJgBAJoBAJIBAIIBALoBAL4BASgFnAcAmAEAmgEAkgEAggEArgEAzgEAgAEAbgC8AQDuCgCWAQC6AQDOAQC6AQDEAQCeAQCuAQCUAQCWAQDMAQCyAQEwAYoBAG4AwgEAwgEAggEAuA0AnAEApgEAmAEAmAEAaACaAQBsAHoAzgEAngEAqgEAlAEAlgEAygEA5AEA0AEAsAEBDQGKAQBuAMIBAL4BAIIBALQFAHoA5gEAjAEA test 'self-recursive fn defined inside another fn', fn: @@ -1981,6 +2034,7 @@ test 'self-recursive fn defined inside another fn', fn: (local.set $:args (call $rt/apply.wat:args_empty)) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:v_54) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:ret_188) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 58)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $:unwrap_inner_187)) ) (func $test::v_240 (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) @@ -2088,6 +2142,7 @@ test 'self-recursive fn defined inside another fn', fn: (local.set $:ret_8 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:params (call $rt/apply.wat:args_tail (local.get $:params))) (local.set $n_3 (call $rt/apply.wat:args_head (local.get $:params))) + (call $rt/trace.wat:trace_push (i32.const 0) (i32.const 266)) (local.set $:caps_cast (ref.cast (ref $rt/apply.wat:Captures) (local.get $:caps_param))) (local.set $x_259 (array.get $rt/apply.wat:Captures (local.get $:caps_cast) (i32.const 0))) (local.set $:slot_260_raw (array.get $rt/apply.wat:Captures (local.get $:caps_cast) (i32.const 1))) @@ -2119,6 +2174,7 @@ test 'self-recursive fn defined inside another fn', fn: (local.set $:ret_6 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:params (call $rt/apply.wat:args_tail (local.get $:params))) (local.set $x_1 (call $rt/apply.wat:args_head (local.get $:params))) + (call $rt/trace.wat:trace_push (i32.const 0) (i32.const 272)) (local.set $:cell_inner_2 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test::inner_2 (local.get $:cell_inner_2)) (local.set $:caps_arg (array.new_fixed $rt/apply.wat:Captures 2 (local.get $x_1) (global.get $test::inner_2))) @@ -2129,6 +2185,7 @@ test 'self-recursive fn defined inside another fn', fn: (local.set $:args (call $rt/apply.wat:args_empty)) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:lit_95) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:ret_6) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 98)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $:unwrap_inner_2)) ) (func $test::fink_module (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) @@ -2142,6 +2199,9 @@ test 'self-recursive fn defined inside another fn', fn: (local $:unwrap_outer_0 (ref null any)) (local $:lit_106 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_4 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_outer_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:outer (local.get $:cell_outer_0)) @@ -2157,6 +2217,7 @@ test 'self-recursive fn defined inside another fn', fn: (local.set $:args (call $rt/apply.wat:args_empty)) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:lit_106) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:ret_4) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 109)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $:unwrap_outer_0)) ) (func $test::host_wrapper (export "test") (type $test::Fn_host_wrapper) (param $:cont (ref null any)) @@ -2176,7 +2237,7 @@ test 'self-recursive fn defined inside another fn', fn: (data $d_0 "test") (data $d_1 "outer") ) - ;; sm:mgHuBQCaAQC6AQDAAQBuAL4BALgGALoBAMIBAMgBAG4AxgEAsggAlgEAugEAyAEAyAEAhgEAfADIDACcAQCaAQCcAQCaAQCWAQDkAQDUAQFiAYoBAQAB3goAnAEAmgEAnAEAmgEAlgEAugEAwgEA4AEA0gEAegDSAQBuAL4BAMQBAL4BAMoIAJYBALoBANABAL4BAMYBALgBAG4AvgEAxAEAygkAmgEAugEA0AEAvgEAwAEA5AEA1AEBMAGKAQEHBfgHAJwBAJoBAJwBAJoBAJYBALoBAMIBAG4AxAEAgAQAWACEBwC6AQDCAQDGAQDCAQB6ANQBAG4AwAEAwAEAxAEA9AgAmgEAmgEAlgEAugEAwgEAwgEAhAIA1AEAbgC-AQDAAQDCAQC6DwCYAQCaAQCSAQC6AQDAAQDQAQC-AQCyAQDSAQCyAQDSAQDcAQDSAQCyAQDSAQDYAQDSAQBuALoBAMABAIQJAJgBAJoBAJIBAJwBAHYA5gEA0AEAqAEAvgEBHAGKAQBuAMIBAMABAM4KAJgBAJwBAHAAegDQAQCiAQCyAQCUAQCWAQDOAQC4AQESAo4BAG4AxAEAwAEAuAUAegDmAQCMAQA + ;; sm:oQHuBQCaAQC6AQDAAQBuAL4BALgGALoBAMIBAMgBAG4AxgEAsggAlgEAugEAyAEAyAEAhgEAfADIDACcAQCaAQCcAQCaAQCWAQDkAQDUAQFiAYoBAQAB3goAnAEAmgEAnAEAmgEAlgEAugEAwgEA4AEA0gEAegDSAQBuAL4BAMQBAL4BAMoIAJYBALoBANABAL4BAMYBALgBAG4AvgEAxAEAggEAygkAmgEAugEA0AEAvgEAwAEA5AEA1AEBMAGKAQEHBfgHAJwBAJoBAJwBAJoBAJYBALoBAMIBAG4AxAEAgAQAWACEBwC6AQDCAQDGAQDCAQB6ANQBAG4AwAEAwAEAxAEA9AgAmgEAmgEAlgEAugEAwgEAwgEAhAIA1AEAbgC-AQDAAQDCAQC6DwCYAQCaAQCSAQCEAQC6AQDAAQDQAQC-AQCyAQDSAQCyAQDSAQDcAQDSAQCyAQDSAQDYAQDSAQBuALoBAMABAIQJAJgBAJoBAJIBAIQBAJwBAHYA5gEA0AEAqAEAvgEBHAGKAQBuAMIBAMABAIIBAKALAJwBAKYBAJgBAJwBAHAAegDQAQCiAQCyAQCUAQCWAQDOAQC4AQESAo4BAG4AxAEAwAEAhAEAuAUAegDmAQCMAQA # TODO, duplicate? @@ -2334,6 +2395,7 @@ test 'recursive list sum', fn: (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:v_85) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $rest_307) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:ret_306) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 89)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $:unwrap_sum_305)) ) (func $test::v_402 (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) @@ -2541,6 +2603,7 @@ test 'recursive list sum', fn: (local.set $items_1 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:params (call $rt/apply.wat:args_tail (local.get $:params))) (local.set $c_2 (call $rt/apply.wat:args_head (local.get $:params))) + (call $rt/trace.wat:trace_push (i32.const 0) (i32.const 466)) (local.set $:caps_cast (ref.cast (ref $rt/apply.wat:Captures) (local.get $:caps_param))) (local.set $:slot_461_raw (array.get $rt/apply.wat:Captures (local.get $:caps_cast) (i32.const 0))) (local.set $:slot_461 (ref.cast (ref null $rt/apply.wat:Cell) (local.get $:slot_461_raw))) @@ -2579,6 +2642,7 @@ test 'recursive list sum', fn: (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:lit_151) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:v_149) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:ret_422) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 154)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $:unwrap_sum_421)) ) (func $test::v_438 (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) @@ -2650,6 +2714,9 @@ test 'recursive list sum', fn: (local $:caps_arg (ref null $rt/apply.wat:Captures)) (local $:lit_141 (ref null any)) (local $:lit_142 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_5 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_sum_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:sum (local.get $:cell_sum_0)) @@ -2686,7 +2753,7 @@ test 'recursive list sum', fn: (data $d_0 "test") (data $d_1 "sum") ) - ;; sm:9wHuBQCaAQC6AQDAAQBuAL4BALgGALoBAMIBAMgBAG4AxgEAsggAlgEAugEAyAEAyAEAhgEAfACyDQCWAQC6AQDIAQDIAQFMAlQA6AEA1AEBAAL8BQC6AQDIAQBuAM4IAJwBAJoBAJwBAJoBAJYBAOQBANQBALgBANQBAQAC5goAnAEAmgEAnAEAmgEAlAEAugEAwgEA4AEA0gEAegDSAQBuALwBAMQBAL4BAJAJAJYBALoBANABAL4BAMYBAMYBALQBAG4AvgEAxAEAxAEAhAoAmgEAmgEAkgEAmgEAmAEAugEA0AEAvgEAwAEAjAIA1AEBQgXwCACWAQCaAQCWAQC6AQDCAQDIAQErAVABCgRWAG4AvgEAvgEAxgEAvAcAlgEAmgEAlgEAugEAyAEBCwtUAG4AvgEAvgEAhAgAlgEAugEAyAEAyAEAugEA1AEBAAuUBgC6AQDIAQBuAM4IAJwBAJoBAJwBAJoBAJYBAOQBANQBALgBANQBAQAL6goAnAEAmgEAnAEAmgEAlgEAugEAwgEA4AEA1AEAegDSAQBuAL4BAMQBAMABAP4DAFgAhAcAugEAwgEAxgEAwgEAegDUAQBuAMABAMABAMQBAPgIAJwBAJoBAJgBALoBAMIBAMIBAIgCANQBAG4AwAEAwAEAxAEAwg8AmAEAmgEAmgEAmgEAkgEAugEA0AEAvgEArgEA0gEAsgEA0gEA3AEA0gEAsgEA1AEA2gEA1AEAbgDCAQDAAQCUCQCYAQC6AQDQAQC-AQDGAQC0AQFgAYwBAG4AxAEAwAEAxAEAzAkAmAEAugEA0AEAvgEAxgEA5gEA1AEBGQGMAQEAAeYJAJgBALoBANABAL4BAMYBAOYBANQBAQYBjAEBAAHmCQCYAQC6AQDQAQC-AQDGAQDmAQDUAQEGAYwBAQAB0AsAmAEAmAEAaAC6AQDQAQCeAQCqAQCUAQCWAQDKAQDiAQDUAQEGAYwBARMMdAEUAdYFAHoA5gEAjAEA + ;; sm:_AHuBQCaAQC6AQDAAQBuAL4BALgGALoBAMIBAMgBAG4AxgEAsggAlgEAugEAyAEAyAEAhgEAfACyDQCWAQC6AQDIAQDIAQFMAlQA6AEA1AEBAAL8BQC6AQDIAQBuAM4IAJwBAJoBAJwBAJoBAJYBAOQBANQBALgBANQBAQAC5goAnAEAmgEAnAEAmgEAlAEAugEAwgEA4AEA0gEAegDSAQBuALwBAMQBAL4BAJAJAJYBALoBANABAL4BAMYBAMYBALQBAG4AvgEAxAEAxAEAggEAhAoAmgEAmgEAkgEAmgEAmAEAugEA0AEAvgEAwAEAjAIA1AEBQgXwCACWAQCaAQCWAQC6AQDCAQDIAQErAVABCgRWAG4AvgEAvgEAxgEAvAcAlgEAmgEAlgEAugEAyAEBCwtUAG4AvgEAvgEAhAgAlgEAugEAyAEAyAEAugEA1AEBAAuUBgC6AQDIAQBuAM4IAJwBAJoBAJwBAJoBAJYBAOQBANQBALgBANQBAQAL6goAnAEAmgEAnAEAmgEAlgEAugEAwgEA4AEA1AEAegDSAQBuAL4BAMQBAMABAP4DAFgAhAcAugEAwgEAxgEAwgEAegDUAQBuAMABAMABAMQBAPgIAJwBAJoBAJgBALoBAMIBAMIBAIgCANQBAG4AwAEAwAEAxAEAwg8AmAEAmgEAmgEAmgEAkgEAhAEAugEA0AEAvgEArgEA0gEAsgEA0gEA3AEA0gEAsgEA1AEA2gEA1AEAbgDCAQDAAQCUCQCYAQC6AQDQAQC-AQDGAQC0AQFgAYwBAG4AxAEAwAEAxAEAhAEAzAkAmAEAugEA0AEAvgEAxgEA5gEA1AEBGQGMAQEAAeYJAJgBALoBANABAL4BAMYBAOYBANQBAQYBjAEBAAHmCQCYAQC6AQDQAQC-AQDGAQDmAQDUAQEGAYwBAQABogwAnAEApgEAmAEAmAEAaAC6AQDQAQCeAQCqAQCUAQCWAQDKAQDiAQDUAQEGAYwBARMMdAEUAdYFAHoA5gEAjAEA @@ -2705,6 +2772,8 @@ test 'main returns exit code', fn: (local $:lit_4 (ref null any)) (local $:args (ref any)) (local.set $:ret_3 (call $rt/apply.wat:args_head (local.get $:params))) + (call $rt/trace.wat:trace_push (i32.const 0) (i32.const 28)) + (call $rt/trace.wat:trace_pop (i32.const 0) (i32.const 28)) (local.set $:lit_4 (struct.new $std/int.wat:I64 (i64.const 0))) (local.set $:args (call $rt/apply.wat:args_empty)) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:lit_4) (local.get $:args))) @@ -2720,6 +2789,9 @@ test 'main returns exit code', fn: (local $:pub_name (ref null any)) (local $:unwrap_main_0 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_1 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_main_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:main (local.get $:cell_main_0)) @@ -2748,4 +2820,4 @@ test 'main returns exit code', fn: (data $d_0 "test") (data $d_1 "main") ) - ;; sm:F4IFAJgBARoBiAEAbgDAAQDsCQCYAQCaAQBsAHoAzgEAoAEArgEAlAEAlgEAzAEAtAEAbgDQAQCmBQB6AOYBAIwBAA + ;; sm:G4IFAJgBAIIBAIABARoBiAEAbgDAAQC-CgCcAQCmAQCYAQCaAQBsAHoAzgEAoAEArgEAlAEAlgEAzAEAtAEAbgDQAQCmBQB6AOYBAIwBAA diff --git a/src/passes/wasm/test_io.fnk b/src/passes/wasm/test_io.fnk index 52299d4..45f1076 100644 --- a/src/passes/wasm/test_io.fnk +++ b/src/passes/wasm/test_io.fnk @@ -31,6 +31,7 @@ test 'std io import handling', fn: (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:v_82) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $stderr_198) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:ret_197) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 86)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $write_196)) ) (func $test::v_219 (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) @@ -88,6 +89,7 @@ test 'std io import handling', fn: (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:v_73) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $stdout_226) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:v_163) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 92)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $write_222)) ) (func $test::v_249 (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) @@ -163,6 +165,7 @@ test 'std io import handling', fn: (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:lit_66) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $stdin_2) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:v_169) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 98)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $read_3)) ) (func $test::v_265 (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) @@ -368,6 +371,9 @@ test 'std io import handling', fn: (local $:imp_url (ref null any)) (local $:imp_caps_arg (ref null $rt/apply.wat:Captures)) (local $:imp_mod_clos (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_1 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_7 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_ham_5 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:ham (local.get $:cell_ham_5)) @@ -401,4 +407,4 @@ test 'std io import handling', fn: (data $d_8 "stdout") (data $d_9 "std/io.fnk") ) - ;; sm:wQGMCACWAQC6AQDIAQDGAQDKAQBuAL4BAMgBAMQBAOAMAJYBALoBAMgBAMYBAMoBANABAL4BAaYBGlQAlgIA1AEBVASSAQC0AQDsAQEBDJoLAJYBALoBAMgBAMYBAMoBANABAL4BAMoBAMQCANQBAG4AvgEAyAEAwAEAjA0AlgEAugEAyAEAxgEAygEAygEAoAEAqgEAlAEAlgEAygEA9AIA1AEBMwSSAQCwAQDoAQEBDLYNAJYBAJoBAJYBAJoBAJYBAJoBAJYBAJoBAJYBALoBAMYBAb8BBloBEAZaARAFWAEOBFYBDAVYALoCANQBAWAEkAEAbgDCAQDCAQDAAQCQCQCWAQCaAQCWAQC6AQDIAQDCAQDCAQDCAQDCAQBuAL4BAMABAMABAMABAMABAOIKAJYBAJoBAJYBALoBAMgBAMIBAMIBAMIBAMgBANgCANQBAZsBOpIBAQA65AoAlgEAmgEAlgEAugEAyAEAwgEAwgEAyAEA3gIA1AEBADqSAQEAOp4KAJYBAJoBAJYBALoBAMgBAMIBAMgBALYCANQBAQA6kgEBADrYCQCWAQCaAQCWAQC6AQDIAQDIAQCOAgDUAQEAOpIBAQA6lAkAlgEAugEAyAEAyAEA6AEA1AEBADqSAQEAOr4GALoBAMgBAG4AzggAnAEAmgEAnAEAmgEAlgEA5AEA1AEAuAEA1AEBADq6BABYAKoJAJYBALoBAMYBALgBANQBAHoA0gEAegDUAQBuAL4BAMABAMABAMoKAJgBAJgBAGgAtAEA1AEAlgEAggEAgAIA5gUAegDmAQCMAQA + ;; sm:xgGMCACWAQC6AQDIAQDGAQDKAQBuAL4BAMgBAMQBAIIBAOAMAJYBALoBAMgBAMYBAMoBANABAL4BAaYBGlQAlgIA1AEBVASSAQC0AQDsAQEBDJoLAJYBALoBAMgBAMYBAMoBANABAL4BAMoBAMQCANQBAG4AvgEAyAEAwAEAggEAjA0AlgEAugEAyAEAxgEAygEAygEAoAEAqgEAlAEAlgEAygEA9AIA1AEBMwSSAQCwAQDoAQEBDLYNAJYBAJoBAJYBAJoBAJYBAJoBAJYBAJoBAJYBALoBAMYBAb8BBloBEAZaARAFWAEOBFYBDAVYALoCANQBAWAEkAEAbgDCAQDCAQDAAQCCAQCQCQCWAQCaAQCWAQC6AQDIAQDCAQDCAQDCAQDCAQBuAL4BAMABAMABAMABAMABAOIKAJYBAJoBAJYBALoBAMgBAMIBAMIBAMIBAMgBANgCANQBAZsBOpIBAQA65AoAlgEAmgEAlgEAugEAyAEAwgEAwgEAyAEA3gIA1AEBADqSAQEAOp4KAJYBAJoBAJYBALoBAMgBAMIBAMgBALYCANQBAQA6kgEBADrYCQCWAQCaAQCWAQC6AQDIAQDIAQCOAgDUAQEAOpIBAQA6lAkAlgEAugEAyAEAyAEA6AEA1AEBADqSAQEAOr4GALoBAMgBAG4AzggAnAEAmgEAnAEAmgEAlgEA5AEA1AEAuAEA1AEBADq6BABYAKoJAJYBALoBAMYBALgBANQBAHoA0gEAegDUAQBuAL4BAMABAMABAJwLAJwBAKYBAJgBAJgBAGgAtAEA1AEAlgEAggEAgAIA5gUAegDmAQCMAQA diff --git a/src/passes/wasm/test_linking.fnk b/src/passes/wasm/test_linking.fnk index 461d455..2cd55b7 100644 --- a/src/passes/wasm/test_linking.fnk +++ b/src/passes/wasm/test_linking.fnk @@ -28,6 +28,7 @@ test 'multi module import', fn: (local.set $:args (call $rt/apply.wat:args_empty)) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:lit_28) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:ret_114) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 31)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $shrub_0)) ) (func $./test.fnk::v_81 (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) @@ -127,6 +128,9 @@ test 'multi module import', fn: (local $:imp_url (ref null any)) (local $:imp_caps_arg (ref null $rt/apply.wat:Captures)) (local $:imp_mod_clos (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_2 10))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_2 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:caps_arg (array.new_fixed $rt/apply.wat:Captures 1 (local.get $:ret_2))) (local.set $:v_73 (struct.new $rt/apply.wat:Closure (ref.func $./test.fnk::v_127) (local.get $:caps_arg))) @@ -153,11 +157,13 @@ test 'multi module import', fn: (local.set $:ret_30 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:params (call $rt/apply.wat:args_tail (local.get $:params))) (local.set $ham_3 (call $rt/apply.wat:args_head (local.get $:params))) + (call $rt/trace.wat:trace_push (i32.const 1) (i32.const 100)) (local.set $:caps_cast (ref.cast (ref $rt/apply.wat:Captures) (local.get $:caps_param))) (local.set $foo_95 (array.get $rt/apply.wat:Captures (local.get $:caps_cast) (i32.const 0))) (local.set $:args (call $rt/apply.wat:args_empty)) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $ham_3) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:ret_30) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 1) (i32.const 35)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $foo_95)) ) (func $./test_link/simple.fnk::v_146 (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) @@ -286,6 +292,9 @@ test 'multi module import', fn: (local $:imp_url (ref null any)) (local $:imp_caps_arg (ref null $rt/apply.wat:Captures)) (local $:imp_mod_clos (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_3 22))) + (call $rt/modules.wat:register_module (i32.const 1) (local.get $:mod_reg_url)) (local.set $:ret_4 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_shrub_1 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $./test_link/simple.fnk:shrub (local.get $:cell_shrub_1)) @@ -312,6 +321,7 @@ test 'multi module import', fn: (local.set $:ret_4 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:params (call $rt/apply.wat:args_tail (local.get $:params))) (local.set $ni_1 (call $rt/apply.wat:args_head (local.get $:params))) + (call $rt/trace.wat:trace_push (i32.const 2) (i32.const 31)) (local.set $:lit_6 (struct.new $std/int.wat:I64 (i64.const 2))) (return_call $std/operators.fnk:op_mul (local.get $:ctx_param) (local.get $ni_1) (local.get $:lit_6) (local.get $:ret_4)) ) @@ -325,6 +335,9 @@ test 'multi module import', fn: (local $:pub_name (ref null any)) (local $:unwrap_foo_0 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_7 27))) + (call $rt/modules.wat:register_module (i32.const 2) (local.get $:mod_reg_url)) (local.set $:ret_2 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_foo_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $./test_link/foobar/spam.fnk:foo (local.get $:cell_foo_0)) @@ -361,7 +374,7 @@ test 'multi module import', fn: (data $d_7 "./test_link/foobar/spam.fnk") (data $d_8 "foo") ) - ;; sm:rAHmCwCWAQC6AQDGAQECBVgBXgKMAQBuAMIBAMQBAIIHAJYBAJoBAJYBALoBAMYBAG4AvgEAzggAlgEAugEAxgEAxgEAuAEA3AEBXymSAQEAKcIGALoBAMYBAG4AzggAmgEAmgEAmgEAmgEAlAEA4AEA3AEAtgEA3AEBACnABABYALAJAJQBALoBAMYBALgBAN4BAHoA3gEAegDeAQBuALwBAL4BAL4BAKoIAJgBALQBAN4BAJYBAIIBAJoCAIgGAHoA8gEAjgEAogcAmgEAmgEAlgEAugEAwgEAbgC-AQDCAQCQCwCWAQC6AQDGAQECA1QAsgEA9gEAyAEA1gEAlgEAlgEAzgEA3AEAbgDSAQCgBwCWAQCaAQCWAQC6AQDIAQBuAL4BAO4IAJYBALoBAMgBAMgBALoBAPYBAQEikgEBACLgBgC6AQDIAQBuAOwIAJwBAJoBAJwBAJoBAJQBAOQBAPYBALgBAPYBAQAi2AQAWADICQCUAQC6AQDGAQC4AQD2AQB6APYBAHoA9gEAbgC8AQC-AQC-AQC0CQCYAQCcAQCUAQC0AQD2AQCWAQCCAQCkAgDQBgB6AIoCAI4BAIIGAJgBAJoBAJQBASgBiAEBCQbCCgCYAQCYAQCWAQB6APwBAMwBANgBAJYBAJYBAMoBAN4BAG4AzgEAsAYAegCUAgCOAQA + ;; sm:tgHmCwCWAQC6AQDGAQECBVgBXgKMAQBuAMIBAMQBAIIBAIIHAJYBAJoBAJYBALoBAMYBAG4AvgEAzggAlgEAugEAxgEAxgEAuAEA3AEBXymSAQEAKcIGALoBAMYBAG4AzggAmgEAmgEAmgEAmgEAlAEA4AEA3AEAtgEA3AEBACnABABYALAJAJQBALoBAMYBALgBAN4BAHoA3gEAegDeAQBuALwBAL4BAL4BAPwIAJ4BAKYBAJgBALQBAN4BAJYBAIIBAJoCAIgGAHoA8gEAjgEAogcAmgEAmgEAlgEAhAEAugEAwgEAbgC-AQDCAQCCAQCQCwCWAQC6AQDGAQECA1QAsgEA9gEAyAEA1gEAlgEAlgEAzgEA3AEAbgDSAQCgBwCWAQCaAQCWAQC6AQDIAQBuAL4BAO4IAJYBALoBAMgBAMgBALoBAPYBAQEikgEBACLgBgC6AQDIAQBuAOwIAJwBAJoBAJwBAJoBAJQBAOQBAPYBALgBAPYBAQAi2AQAWADICQCUAQC6AQDGAQC4AQD2AQB6APYBAHoA9gEAbgC8AQC-AQC-AQCGCgCeAQCmAQCYAQCcAQCUAQC0AQD2AQCWAQCCAQCkAgDQBgB6AIoCAI4BAIIGAJgBAJoBAJQBAIIBASgBiAEBCQaUCwCeAQCmAQCYAQCYAQCWAQB6APwBAMwBANgBAJYBAJYBAMoBAN4BAG4AzgEAsAYAegCUAgCOAQA --- @@ -498,6 +511,9 @@ test 'diamond with two paths to same dep', fn: (local $:imp_url (ref null any)) (local $:imp_caps_arg (ref null $rt/apply.wat:Captures)) (local $:imp_mod_clos (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_2 10))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_2 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:caps_arg (array.new_fixed $rt/apply.wat:Captures 1 (local.get $:ret_2))) (local.set $:v_70 (struct.new $rt/apply.wat:Closure (ref.func $./test.fnk::v_124) (local.get $:caps_arg))) @@ -899,6 +915,9 @@ test 'diamond with two paths to same dep', fn: (local $:imp_url (ref null any)) (local $:imp_caps_arg (ref null $rt/apply.wat:Captures)) (local $:imp_mod_clos (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_3 23))) + (call $rt/modules.wat:register_module (i32.const 1) (local.get $:mod_reg_url)) (local.set $:ret_5 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_total_3 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $./test_link/diamond.fnk:total (local.get $:cell_total_3)) @@ -927,6 +946,9 @@ test 'diamond with two paths to same dep', fn: (local $:pub_name (ref null any)) (local $:unwrap_base_0 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_11 26))) + (call $rt/modules.wat:register_module (i32.const 2) (local.get $:mod_reg_url)) (local.set $:ret_1 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_base_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $./test_link/sub/common.fnk:base (local.get $:cell_base_0)) @@ -1087,6 +1109,9 @@ test 'diamond with two paths to same dep', fn: (local $:imp_url (ref null any)) (local $:imp_caps_arg (ref null $rt/apply.wat:Captures)) (local $:imp_mod_clos (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_13 24))) + (call $rt/modules.wat:register_module (i32.const 3) (local.get $:mod_reg_url)) (local.set $:ret_3 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_left_val_1 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $./test_link/sub/left.fnk:left_val (local.get $:cell_left_val_1)) @@ -1243,6 +1268,9 @@ test 'diamond with two paths to same dep', fn: (local $:imp_url (ref null any)) (local $:imp_caps_arg (ref null $rt/apply.wat:Captures)) (local $:imp_mod_clos (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_17 25))) + (call $rt/modules.wat:register_module (i32.const 4) (local.get $:mod_reg_url)) (local.set $:ret_3 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_right_val_1 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $./test_link/sub/right.fnk:right_val (local.get $:cell_right_val_1)) @@ -1288,4 +1316,4 @@ test 'diamond with two paths to same dep', fn: (data $d_19 "base") (data $d_20 "./test_link/sub/common.fnk") ) - ;; sm:ugPsDwCWAQC6AQDGAQECBVgAbgDCAQCEBwCWAQCaAQCWAQC6AQDGAQBuAL4BAM4IAJYBALoBAMYBAMYBALgBANwBAQEqkgEBACrCBgC6AQDGAQBuAM4IAJoBAJoBAJoBAJoBAJQBAOABANwBALYBANwBAQAqwAQAWACwCQCUAQC6AQDGAQC4AQDeAQB6AN4BAHoA3gEAbgC8AQC-AQC-AQCqCACYAQC0AQDeAQCWAQCCAQCcAgCIBgB6APIBAI4BAKAJAJYBALoBAMYBAMoBANgBAJYBAJYBAM4BAN4BAG4A0gEArggAlgEAugEAxgEA0AEAuAEA-gEBgAkbggoAlgEAugEAxgEA0AEAzgEBqwMEVgDuAQD6AQGsAw_eBwCWAQCaAQCWAQC6AQDIAQBuAL4BAPIIAJYBALoBAMgBAMgBALoBAPoBAa0DIpIBAQAi5AYAugEAyAEAbgD0CACcAQCaAQCcAQCaAQCWAQDkAQD6AQC4AQD6AQEAIuAEAFgA8goAlgEAugEAxgEA0AEAzgEAogIA-AEAegD4AQB6APgBAG4AvgEAvgEAvgEAjgsAlgEAugEAxgEAzgEBSwlgAJ4CAPoBAJYBAIIBAKICAN4HAJYBAJoBAJYBALoBAMgBAG4AvgEA8ggAlgEAugEAyAEAyAEAugEA-gEBASaSAQEAJuQGALoBAMgBAG4A9AgAnAEAmgEAnAEAmgEAlgEA5AEA-gEAuAEA-gEBACbgBABYAKIKAJYBALoBAMYBAM4BAOwBAPoBAHoA-AEAegD6AQBuAL4BAMABAMABALoKAJYBALoBAMYBAUcIXgDoAQD6AQCWAQCCAQCgAgDeBwCWAQCaAQCWAQC6AQDIAQBuAL4BAPIIAJYBALoBAMgBAMgBALoBAPoBAQEkkgEBACTkBgC6AQDIAQBuAPQIAJwBAJoBAJwBAJoBAJYBAOQBAPoBALgBAPoBAQAk4AQAWADOCQCUAQC6AQDGAQC4AQD6AQB6APgBAHoA-gEAbgC8AQDAAQDAAQC4CQCYAQCcAQCWAQC0AQD6AQCYAQCCAQCeAgDYBgB6AIwCAI4BALIJAJgBAJoBAJgBAbkEBIoBANABANoBAJgBAJgBAMwBAOABAG4A0AEAqgYAegCSAgCQAQCqCQCWAQC6AQDEAQDSAQDmAQCYAQCYAQDUAQDsAQBuANgBAOYIAJYBALoBAMYBAe4BBFYAuAEA-AEBYgGKAQENCNQHAJYBAJoBAJYBALoBAMgBAG4AvgEA8ggAlgEAugEAyAEAyAEAugEA-gEBVR6UAQEAHuQGALoBAMgBAG4A7ggAmgEAmgEAnAEAmgEAlAEA4gEA-gEAuAEA-gEBAB7cBABYAMwJAJQBALoBAMYBALgBAPoBAHoA-gEAegD6AQBuALwBAL4BAL4BAL4JAJgBAKIBAKQBALQBAPoBAJgBAIIBAKICANwGAHoAjgIAkAEAsAkAlgEAugEAxAEA1gEA7AEAmAEAmAEA1gEA8gEAbgDaAQDoCACWAQC6AQDGAQGMAwRWALgBAPoBAW4BigEBDQjWBwCWAQCaAQCWAQC6AQDIAQBuAL4BAPQIAJYBALoBAMgBAMgBALoBAPwBAWEjlAEBACPmBgC6AQDIAQBuAPAIAJoBAJoBAJwBAJoBAJQBAOIBAPwBALgBAPwBAQAj3gQAWADOCQCUAQC6AQDGAQC4AQD8AQB6APwBAHoA_AEAbgC8AQC-AQC-AQDCCQCYAQCkAQCqAQC0AQD8AQCYAQCCAQCiAgDiBgB6AJACAJABAA + ;; sm:xAPsDwCWAQC6AQDGAQECBVgAbgDCAQCEBwCWAQCaAQCWAQC6AQDGAQBuAL4BAM4IAJYBALoBAMYBAMYBALgBANwBAQEqkgEBACrCBgC6AQDGAQBuAM4IAJoBAJoBAJoBAJoBAJQBAOABANwBALYBANwBAQAqwAQAWACwCQCUAQC6AQDGAQC4AQDeAQB6AN4BAHoA3gEAbgC8AQC-AQC-AQD8CACeAQCmAQCYAQC0AQDeAQCWAQCCAQCcAgCIBgB6APIBAI4BAKAJAJYBALoBAMYBAMoBANgBAJYBAJYBAM4BAN4BAG4A0gEArggAlgEAugEAxgEA0AEAuAEA-gEBgAkbggoAlgEAugEAxgEA0AEAzgEBqwMEVgDuAQD6AQGsAw_eBwCWAQCaAQCWAQC6AQDIAQBuAL4BAPIIAJYBALoBAMgBAMgBALoBAPoBAa0DIpIBAQAi5AYAugEAyAEAbgD0CACcAQCaAQCcAQCaAQCWAQDkAQD6AQC4AQD6AQEAIuAEAFgA8goAlgEAugEAxgEA0AEAzgEAogIA-AEAegD4AQB6APgBAG4AvgEAvgEAvgEAjgsAlgEAugEAxgEAzgEBSwlgAJ4CAPoBAJYBAIIBAKICAN4HAJYBAJoBAJYBALoBAMgBAG4AvgEA8ggAlgEAugEAyAEAyAEAugEA-gEBASaSAQEAJuQGALoBAMgBAG4A9AgAnAEAmgEAnAEAmgEAlgEA5AEA-gEAuAEA-gEBACbgBABYAKIKAJYBALoBAMYBAM4BAOwBAPoBAHoA-AEAegD6AQBuAL4BAMABAMABALoKAJYBALoBAMYBAUcIXgDoAQD6AQCWAQCCAQCgAgDeBwCWAQCaAQCWAQC6AQDIAQBuAL4BAPIIAJYBALoBAMgBAMgBALoBAPoBAQEkkgEBACTkBgC6AQDIAQBuAPQIAJwBAJoBAJwBAJoBAJYBAOQBAPoBALgBAPoBAQAk4AQAWADOCQCUAQC6AQDGAQC4AQD6AQB6APgBAHoA-gEAbgC8AQDAAQDAAQCKCgCeAQCmAQCYAQCcAQCWAQC0AQD6AQCYAQCCAQCeAgDYBgB6AIwCAI4BAIQKAKABAKYBAJgBAJoBAJgBAbkEBIoBANABANoBAJgBAJgBAMwBAOABAG4A0AEAqgYAegCSAgCQAQCqCQCWAQC6AQDEAQDSAQDmAQCYAQCYAQDUAQDsAQBuANgBAOYIAJYBALoBAMYBAe4BBFYAuAEA-AEBYgGKAQENCNQHAJYBAJoBAJYBALoBAMgBAG4AvgEA8ggAlgEAugEAyAEAyAEAugEA-gEBVR6UAQEAHuQGALoBAMgBAG4A7ggAmgEAmgEAnAEAmgEAlAEA4gEA-gEAuAEA-gEBAB7cBABYAMwJAJQBALoBAMYBALgBAPoBAHoA-gEAegD6AQBuALwBAL4BAL4BAJAKAKABAKYBAJgBAKIBAKQBALQBAPoBAJgBAIIBAKICANwGAHoAjgIAkAEAsAkAlgEAugEAxAEA1gEA7AEAmAEAmAEA1gEA8gEAbgDaAQDoCACWAQC6AQDGAQGMAwRWALgBAPoBAW4BigEBDQjWBwCWAQCaAQCWAQC6AQDIAQBuAL4BAPQIAJYBALoBAMgBAMgBALoBAPwBAWEjlAEBACPmBgC6AQDIAQBuAPAIAJoBAJoBAJwBAJoBAJQBAOIBAPwBALgBAPwBAQAj3gQAWADOCQCUAQC6AQDGAQC4AQD8AQB6APwBAHoA_AEAbgC8AQC-AQC-AQCUCgCgAQCmAQCYAQCkAQCqAQC0AQD8AQCYAQCCAQCiAgDiBgB6AJACAJABAA diff --git a/src/passes/wasm/test_literals.fnk b/src/passes/wasm/test_literals.fnk index 96c9e28..9de6a46 100644 --- a/src/passes/wasm/test_literals.fnk +++ b/src/passes/wasm/test_literals.fnk @@ -12,6 +12,9 @@ test 'literal bool', fn: (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (ref.i31 (i32.const 1))) (local.set $:args (call $rt/apply.wat:args_empty)) @@ -29,7 +32,7 @@ test 'literal bool', fn: ) (data $d_0 "test") ) - ;; sm:CZAFAJgBAQAEYABuAMABAKYFAHoA5gEAjAEA + ;; sm:C-IFAJwBAKYBAJgBAQAEYABuAMABAKYFAHoA5gEAjAEA test 'literal bool false', fn: @@ -42,6 +45,9 @@ test 'literal bool false', fn: (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (ref.i31 (i32.const 0))) (local.set $:args (call $rt/apply.wat:args_empty)) @@ -59,7 +65,7 @@ test 'literal bool false', fn: ) (data $d_0 "test") ) - ;; sm:CZAFAJgBAQAFYABuAMABAKYFAHoA5gEAjAEA + ;; sm:C-IFAJwBAKYBAJgBAQAFYABuAMABAKYFAHoA5gEAjAEA test 'literal int', fn: @@ -72,6 +78,9 @@ test 'literal int', fn: (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (struct.new $std/int.wat:I64 (i64.const 42))) (local.set $:args (call $rt/apply.wat:args_empty)) @@ -89,7 +98,7 @@ test 'literal int', fn: ) (data $d_0 "test") ) - ;; sm:CZAFAJgBAQACigEAbgDAAQCmBQB6AOYBAIwBAA + ;; sm:C-IFAJwBAKYBAJgBAQACigEAbgDAAQCmBQB6AOYBAIwBAA test 'literal neg 0', fn: @@ -102,6 +111,9 @@ test 'literal neg 0', fn: (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (struct.new $std/int.wat:I64 (i64.const 0))) (local.set $:args (call $rt/apply.wat:args_empty)) @@ -119,7 +131,7 @@ test 'literal neg 0', fn: ) (data $d_0 "test") ) - ;; sm:CZAFAJgBAQACiAEAbgDAAQCmBQB6AOYBAIwBAA + ;; sm:C-IFAJwBAKYBAJgBAQACiAEAbgDAAQCmBQB6AOYBAIwBAA @@ -133,6 +145,9 @@ test 'literal float', fn: (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (struct.new $std/float.wat:F64 (f64.const 123400))) (local.set $:args (call $rt/apply.wat:args_empty)) @@ -150,7 +165,7 @@ test 'literal float', fn: ) (data $d_0 "test") ) - ;; sm:CZAFAJgBAQAIlgEAbgDAAQCmBQB6AOYBAIwBAA + ;; sm:C-IFAJwBAKYBAJgBAQAIlgEAbgDAAQCmBQB6AOYBAIwBAA test 'literal decimal', fn: @@ -163,6 +178,9 @@ test 'literal decimal', fn: (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (struct.new $std/decimal.wat:Decimal (i64.const 10) (i32.const -1))) (local.set $:args (call $rt/apply.wat:args_empty)) @@ -180,7 +198,7 @@ test 'literal decimal', fn: ) (data $d_0 "test") ) - ;; sm:CZAFAJgBAQAEuAEAbgDAAQCmBQB6AOYBAIwBAA + ;; sm:C-IFAJwBAKYBAJgBAQAEuAEAbgDAAQCmBQB6AOYBAIwBAA diff --git a/src/passes/wasm/test_operators.fnk b/src/passes/wasm/test_operators.fnk index 3cb0b6c..06e29e9 100644 --- a/src/passes/wasm/test_operators.fnk +++ b/src/passes/wasm/test_operators.fnk @@ -13,6 +13,9 @@ test 'add two literals', fn: (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) (local $:lit_2 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (struct.new $std/int.wat:I64 (i64.const 2))) (local.set $:lit_2 (struct.new $std/int.wat:I64 (i64.const 3))) @@ -29,7 +32,7 @@ test 'add two literals', fn: ) (data $d_0 "test") ) - ;; sm:CJwFAJgBAQABiAEBCAGIAQEHBdoFAHoA5gEAjAEA + ;; sm:Cu4FAJwBAKYBAJgBAQABiAEBCAGIAQEHBdoFAHoA5gEAjAEA @@ -56,6 +59,9 @@ test 'chained arithmetic', fn: (local $:caps_arg (ref null $rt/apply.wat:Captures)) (local $:lit_1 (ref null any)) (local $:lit_2 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:caps_arg (array.new_fixed $rt/apply.wat:Captures 1 (local.get $:ret_0))) (local.set $:v_16 (struct.new $rt/apply.wat:Closure (ref.func $test::v_24) (local.get $:caps_arg))) @@ -74,7 +80,7 @@ test 'chained arithmetic', fn: ) (data $d_0 "test") ) - ;; sm:D_YFAJQBALoBAMQBARABiAEBDwnGBwCYAQC0AQDQAQEAAYgBAQgBiAEBBwXWBQB6AOYBAIwBAA + ;; sm:EfYFAJQBALoBAMQBARABiAEBDwmYCACcAQCmAQCYAQC0AQDQAQEAAYgBAQgBiAEBBwXWBQB6AOYBAIwBAA test 'unary not', fn: @@ -86,6 +92,9 @@ test 'unary not', fn: (func $test::fink_module (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (ref.i31 (i32.const 1))) (return_call $std/operators.fnk:op_not (local.get $:ctx_param) (local.get $:lit_1) (local.get $:ret_0)) @@ -101,7 +110,7 @@ test 'unary not', fn: ) (data $d_0 "test") ) - ;; sm:B9YEAJgBAQgEYAEHCLAFAHoA5gEAjAEA + ;; sm:CagFAJwBAKYBAJgBAQgEYAEHCLAFAHoA5gEAjAEA test 'comparison eq', fn: @@ -114,6 +123,9 @@ test 'comparison eq', fn: (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) (local $:lit_2 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (struct.new $std/int.wat:I64 (i64.const 2))) (local.set $:lit_2 (struct.new $std/int.wat:I64 (i64.const 3))) @@ -130,7 +142,7 @@ test 'comparison eq', fn: ) (data $d_0 "test") ) - ;; sm:CJwFAJgBAQABiAEBCgGIAQEJBtYFAHoA5gEAjAEA + ;; sm:Cu4FAJwBAKYBAJgBAQABiAEBCgGIAQEJBtYFAHoA5gEAjAEA test 'comparison lt', fn: @@ -143,6 +155,9 @@ test 'comparison lt', fn: (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) (local $:lit_2 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (struct.new $std/int.wat:I64 (i64.const 2))) (local.set $:lit_2 (struct.new $std/int.wat:I64 (i64.const 3))) @@ -159,7 +174,7 @@ test 'comparison lt', fn: ) (data $d_0 "test") ) - ;; sm:CJwFAJgBAQABiAEBCAGIAQEHBdYFAHoA5gEAjAEA + ;; sm:Cu4FAJwBAKYBAJgBAQABiAEBCAGIAQEHBdYFAHoA5gEAjAEA test 'logical and', fn: @@ -172,6 +187,9 @@ test 'logical and', fn: (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) (local $:lit_2 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (ref.i31 (i32.const 1))) (local.set $:lit_2 (ref.i31 (i32.const 0))) @@ -188,7 +206,7 @@ test 'logical and', fn: ) (data $d_0 "test") ) - ;; sm:CJwFAJgBAQAEYAESBWABEQ7YBQB6AOYBAIwBAA + ;; sm:Cu4FAJwBAKYBAJgBAQAEYAESBWABEQ7YBQB6AOYBAIwBAA test 'logical or', fn: @@ -201,6 +219,9 @@ test 'logical or', fn: (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) (local $:lit_2 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (ref.i31 (i32.const 1))) (local.set $:lit_2 (ref.i31 (i32.const 0))) @@ -217,7 +238,7 @@ test 'logical or', fn: ) (data $d_0 "test") ) - ;; sm:CJwFAJgBAQAEYAEQBWABDw3WBQB6AOYBAIwBAA + ;; sm:Cu4FAJwBAKYBAJgBAQAEYAEQBWABDw3WBQB6AOYBAIwBAA test 'power', fn: @@ -230,6 +251,9 @@ test 'power', fn: (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) (local $:lit_2 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (struct.new $std/int.wat:I64 (i64.const 2))) (local.set $:lit_2 (struct.new $std/int.wat:I64 (i64.const 8))) @@ -246,7 +270,7 @@ test 'power', fn: ) (data $d_0 "test") ) - ;; sm:CJwFAJgBAQABiAEBCgGIAQEJBtgFAHoA5gEAjAEA + ;; sm:Cu4FAJwBAKYBAJgBAQABiAEBCgGIAQEJBtgFAHoA5gEAjAEA test 'power float', fn: @@ -259,6 +283,9 @@ test 'power float', fn: (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) (local $:lit_2 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (struct.new $std/float.wat:F64 (f64.const 2))) (local.set $:lit_2 (struct.new $std/float.wat:F64 (f64.const 0.5))) @@ -275,7 +302,7 @@ test 'power float', fn: ) (data $d_0 "test") ) - ;; sm:CJwFAJgBAQADjAEBDgOQAQENCtgFAHoA5gEAjAEA + ;; sm:Cu4FAJwBAKYBAJgBAQADjAEBDgOQAQENCtgFAHoA5gEAjAEA test 'divmod', fn: @@ -288,6 +315,9 @@ test 'divmod', fn: (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) (local $:lit_2 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (struct.new $std/int.wat:I64 (i64.const 10))) (local.set $:lit_2 (struct.new $std/int.wat:I64 (i64.const 3))) @@ -304,7 +334,7 @@ test 'divmod', fn: ) (data $d_0 "test") ) - ;; sm:CJwFAJgBAQACigEBDAGIAQELB94FAHoA5gEAjAEA + ;; sm:Cu4FAJwBAKYBAJgBAQACigEBDAGIAQELB94FAHoA5gEAjAEA test 'rotate left', fn: @@ -317,6 +347,9 @@ test 'rotate left', fn: (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) (local $:lit_2 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (struct.new $std/int.wat:I64 (i64.const 1))) (local.set $:lit_2 (struct.new $std/int.wat:I64 (i64.const 4))) @@ -333,7 +366,7 @@ test 'rotate left', fn: ) (data $d_0 "test") ) - ;; sm:CJwFAJgBAQABiAEBDAGIAQELB9oFAHoA5gEAjAEA + ;; sm:Cu4FAJwBAKYBAJgBAQABiAEBDAGIAQELB9oFAHoA5gEAjAEA test 'rotate right', fn: @@ -346,6 +379,9 @@ test 'rotate right', fn: (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) (local $:lit_2 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (struct.new $std/int.wat:I64 (i64.const 16))) (local.set $:lit_2 (struct.new $std/int.wat:I64 (i64.const 4))) @@ -362,4 +398,4 @@ test 'rotate right', fn: ) (data $d_0 "test") ) - ;; sm:CJwFAJgBAQACigEBDgGIAQENCNoFAHoA5gEAjAEA + ;; sm:Cu4FAJwBAKYBAJgBAQACigEBDgGIAQENCNoFAHoA5gEAjAEA diff --git a/src/passes/wasm/test_range.fnk b/src/passes/wasm/test_range.fnk index 85f8f0b..4f3490d 100644 --- a/src/passes/wasm/test_range.fnk +++ b/src/passes/wasm/test_range.fnk @@ -12,6 +12,9 @@ test 'range exclusive', fn: (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) (local $:lit_2 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (struct.new $std/int.wat:I64 (i64.const 0))) (local.set $:lit_2 (struct.new $std/int.wat:I64 (i64.const 10))) @@ -28,7 +31,7 @@ test 'range exclusive', fn: ) (data $d_0 "test") ) - ;; sm:CJwFAJgBAQABiAEBBgKKAQEFBcwFAHoA5gEAjAEA + ;; sm:Cu4FAJwBAKYBAJgBAQABiAEBBgKKAQEFBcwFAHoA5gEAjAEA test 'range inclusive', fn: @@ -41,6 +44,9 @@ test 'range inclusive', fn: (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) (local $:lit_2 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (struct.new $std/int.wat:I64 (i64.const 0))) (local.set $:lit_2 (struct.new $std/int.wat:I64 (i64.const 10))) @@ -57,7 +63,7 @@ test 'range inclusive', fn: ) (data $d_0 "test") ) - ;; sm:CJwFAJgBAQABiAEBCAKKAQEHBswFAHoA5gEAjAEA + ;; sm:Cu4FAJwBAKYBAJgBAQABiAEBCAKKAQEHBswFAHoA5gEAjAEA test 'open range exclusive', fn: @@ -69,6 +75,9 @@ test 'open range exclusive', fn: (func $test::fink_module (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (struct.new $std/int.wat:I64 (i64.const 0))) (return_call $std/range.fnk:from (local.get $:ctx_param) (local.get $:lit_1) (local.get $:ret_0)) @@ -84,7 +93,7 @@ test 'open range exclusive', fn: ) (data $d_0 "test") ) - ;; sm:B9YEAJgBAQABiAEBAAOkBQB6AOYBAIwBAA + ;; sm:CagFAJwBAKYBAJgBAQABiAEBAAOkBQB6AOYBAIwBAA test 'range in', fn: @@ -110,6 +119,9 @@ test 'range in', fn: (local $:caps_arg (ref null $rt/apply.wat:Captures)) (local $:lit_2 (ref null any)) (local $:lit_3 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:caps_arg (array.new_fixed $rt/apply.wat:Captures 1 (local.get $:ret_0))) (local.set $:v_16 (struct.new $rt/apply.wat:Closure (ref.func $test::v_24) (local.get $:caps_arg))) @@ -128,4 +140,4 @@ test 'range in', fn: ) (data $d_0 "test") ) - ;; sm:D_YFAJQBALoBAMQBAQABiAEBAArCBwCYAQC0AQDQAQEKAYgBAQYCigEBBQXKBQB6AOYBAIwBAA + ;; sm:EfYFAJQBALoBAMQBAQABiAEBAAqUCACcAQCmAQCYAQC0AQDQAQEKAYgBAQYCigEBBQXKBQB6AOYBAIwBAA diff --git a/src/passes/wasm/test_records.fnk b/src/passes/wasm/test_records.fnk index 71fb74b..158cd8b 100644 --- a/src/passes/wasm/test_records.fnk +++ b/src/passes/wasm/test_records.fnk @@ -29,6 +29,9 @@ test 'rec literal', fn: (local $:lit_1 (ref null any)) (local $:lit_2 (ref null any)) (local $:lit_3 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_2 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:caps_arg (array.new_fixed $rt/apply.wat:Captures 1 (local.get $:ret_0))) (local.set $:v_18 (struct.new $rt/apply.wat:Closure (ref.func $test::v_26) (local.get $:caps_arg))) @@ -50,7 +53,7 @@ test 'rec literal', fn: (data $d_1 "a") (data $d_2 "test") ) - ;; sm:Eb4HAJQBALoBAMQBAQ4BkAEBBgGIAQEFBKAIAJgBALQBANABAQ0MYAECAZABAQYBiAEBBQTsBQB6AOYBAIwBAA + ;; sm:E74HAJQBALoBAMQBAQ4BkAEBBgGIAQEFBPIIAJwBAKYBAJgBALQBANABAQ0MYAECAZABAQYBiAEBBQTsBQB6AOYBAIwBAA test 'rec destructure', fn: @@ -216,6 +219,9 @@ test 'rec destructure', fn: (local $:lit_3 (ref null any)) (local $:lit_4 (ref null any)) (local $:lit_5 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_2 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_2 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_a_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test::a_0 (local.get $:cell_a_0)) @@ -240,7 +246,7 @@ test 'rec destructure', fn: (data $d_1 "a") (data $d_2 "test") ) - ;; sm:WIwIAJYBAJoBAJYBALoBAMYBAKIBAQ4BUACuAQEkBfoHAJYBAJoBAJYBALoBAMgBAMIBAG4AvgEAwAEAjgkAlgEAmgEAlgEAugEAyAEAyAEA4AEA0gEBMRiSAQEAGJAJAJYBALoBAMgBAMgBAOgBANIBAQAYkgEBABi8BgC6AQDIAQBuAMoIAJwBAJoBAJwBAJoBAJYBAOQBANIBALgBANIBAQAYtgQAWACmCQCWAQC6AQDGAQC4AQDSAQB6ANIBAHoA0gEAbgC-AQC-AQC-AQC2CACUAQC6AQDGAQC4AQDSAQEmAZABAQYBiAEBBQSICQCYAQCUAQBmALQBANQBAQ0MYAECAZABAQYBiAEBBQTuBQB6AOYBAIwBAA + ;; sm:WowIAJYBAJoBAJYBALoBAMYBAKIBAQ4BUACuAQEkBfoHAJYBAJoBAJYBALoBAMgBAMIBAG4AvgEAwAEAjgkAlgEAmgEAlgEAugEAyAEAyAEA4AEA0gEBMRiSAQEAGJAJAJYBALoBAMgBAMgBAOgBANIBAQAYkgEBABi8BgC6AQDIAQBuAMoIAJwBAJoBAJwBAJoBAJYBAOQBANIBALgBANIBAQAYtgQAWACmCQCWAQC6AQDGAQC4AQDSAQB6ANIBAHoA0gEAbgC-AQC-AQC-AQC2CACUAQC6AQDGAQC4AQDSAQEmAZABAQYBiAEBBQTaCQCcAQCmAQCYAQCUAQBmALQBANQBAQ0MYAECAZABAQYBiAEBBQTuBQB6AOYBAIwBAA test 'rec spread', fn: expect wat ƒink: @@ -321,6 +327,9 @@ test 'rec spread', fn: (local $:lit_2 (ref null any)) (local $:lit_3 (ref null any)) (local $:lit_4 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_1 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_1 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_r_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:r (local.get $:cell_r_0)) @@ -349,7 +358,7 @@ test 'rec spread', fn: (data $d_3 "b") (data $d_4 "a") ) - ;; sm:LMQHAJYBALoBAMQBAS4BkgEBBgGKAQEFBKgMAJQBALoBAM4BALoBAMQBAJwBAKIBAJQBAJYBAMYBALYBANABAQsLYgCsAQECA54KAJQBALoBAM4BALoBAMQBAOIBANABAQ0BkAEBBgGIAQEFBIYJAJgBAJQBAGAA3gEA0AEBDQxgAQIBkAEBBgGIAQEFBOwFAHoA5gEAjAEA + ;; sm:LsQHAJYBALoBAMQBAS4BkgEBBgGKAQEFBKgMAJQBALoBAM4BALoBAMQBAJwBAKIBAJQBAJYBAMYBALYBANABAQsLYgCsAQECA54KAJQBALoBAM4BALoBAMQBAOIBANABAQ0BkAEBBgGIAQEFBNgJAJwBAKYBAJgBAJQBAGAA3gEA0AEBDQxgAQIBkAEBBgGIAQEFBOwFAHoA5gEAjAEA test 'rec empty literal', fn: expect wat ƒink: @@ -362,6 +371,9 @@ test 'rec empty literal', fn: (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (call $std/rec.fnk:new)) (local.set $:args (call $rt/apply.wat:args_empty)) @@ -379,7 +391,7 @@ test 'rec empty literal', fn: ) (data $d_0 "test") ) - ;; sm:CZIGAJgBAQACYABuAMABAKYFAHoA5gEAjAEA + ;; sm:C-QGAJwBAKYBAJgBAQACYABuAMABAKYFAHoA5gEAjAEA test 'rec single field', fn: expect wat ƒink: @@ -393,6 +405,9 @@ test 'rec single field', fn: (local $:lit_1 (ref null any)) (local $:lit_2 (ref null any)) (local $:lit_3 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_1 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (call $std/rec.fnk:new)) (local.set $:lit_2 (call $std/str.fnk:from_data (data.ref $d_0 1))) @@ -411,7 +426,7 @@ test 'rec single field', fn: (data $d_0 "a") (data $d_1 "test") ) - ;; sm:CeQGAJgBAQAGYAECAZABAQYBiAEBBQTuBQB6AOYBAIwBAA + ;; sm:C7YHAJwBAKYBAJgBAQAGYAECAZABAQYBiAEBBQTuBQB6AOYBAIwBAA test 'rec nested destructure', fn: expect wat ƒink: @@ -646,6 +661,9 @@ test 'rec nested destructure', fn: (local $:lit_5 (ref null any)) (local $:lit_6 (ref null any)) (local $:lit_7 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_2 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_2 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_a_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test::a_0 (local.get $:cell_a_0)) @@ -673,7 +691,7 @@ test 'rec nested destructure', fn: (data $d_1 "a") (data $d_2 "test") ) - ;; sm:fcIHAJYBALoBAMYBAKIBAK4BAG4AygEA_AYAlgEAmgEAlgEAugEAyAEAbgC-AQDMCACWAQC6AQDIAQDIAQC6AQDUAQEmB5IBAQAHvgYAugEAyAEAbgDOCACcAQCaAQCcAQCaAQCWAQDkAQDUAQC4AQDUAQEAB7oEAFgA9gkAlgEAugEAxgEAogEAuAEA0gEAegDSAQB6ANIBAK4BAG4AygEAvgEAvgEA9gYAlgEAmgEAlgEAugEAyAEAbgC-AQDMCACWAQC6AQDIAQDIAQC6AQDUAQElEpIBAQASvgYAugEAyAEAbgDOCACcAQCaAQCcAQCaAQCWAQDkAQDUAQC4AQDUAQEAEroEAFgApgkAlgEAugEAxgEAuAEA0gEAegDSAQB6ANIBAG4AvgEAvgEAvgEAuAgAlAEAugEAxgEAuAEA1AEBDAxgAQIBkAEBAAr0CQCYAQCUAQBmAJQBAGYAtAEA1AEBBgdgAQIBkAEBBgKKAQEFBe4FAHoA5gEAjAEA + ;; sm:f8IHAJYBALoBAMYBAKIBAK4BAG4AygEA_AYAlgEAmgEAlgEAugEAyAEAbgC-AQDMCACWAQC6AQDIAQDIAQC6AQDUAQEmB5IBAQAHvgYAugEAyAEAbgDOCACcAQCaAQCcAQCaAQCWAQDkAQDUAQC4AQDUAQEAB7oEAFgA9gkAlgEAugEAxgEAogEAuAEA0gEAegDSAQB6ANIBAK4BAG4AygEAvgEAvgEA9gYAlgEAmgEAlgEAugEAyAEAbgC-AQDMCACWAQC6AQDIAQDIAQC6AQDUAQElEpIBAQASvgYAugEAyAEAbgDOCACcAQCaAQCcAQCaAQCWAQDkAQDUAQC4AQDUAQEAEroEAFgApgkAlgEAugEAxgEAuAEA0gEAegDSAQB6ANIBAG4AvgEAvgEAvgEAuAgAlAEAugEAxgEAuAEA1AEBDAxgAQIBkAEBAArGCgCcAQCmAQCYAQCUAQBmAJQBAGYAtAEA1AEBBgdgAQIBkAEBBgKKAQEFBe4FAHoA5gEAjAEA test 'rec spread merge two', fn: expect wat ƒink: @@ -776,6 +794,9 @@ test 'rec spread merge two', fn: (local $:lit_3 (ref null any)) (local $:lit_4 (ref null any)) (local $:lit_5 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_2 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_r1_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:r1 (local.get $:cell_r1_0)) @@ -810,7 +831,7 @@ test 'rec spread merge two', fn: (data $d_3 "b") (data $d_4 "a") ) - ;; sm:OcIIAJYBALoBAM4BALoBAMQBAK4BAT4Ezg0AlgEAugEAzgEAugEAxAEAzgEAugEAngEApgEAlAEAlgEAyAEA4gEA0AEBDQxiAK4BAQIEhA4AlAEAugEAzgEAugEAzgEAugEAxAEAnAEApgEAlAEAlgEAyAEAjgIA0AEBDwZgAQIBkAEBBgGKAQEFBPoJAJgBAJYBAGQAlgEAZACMAgDQAQEZBmABAgGQAQEGAYgBAQUE7AUAegDmAQCMAQA + ;; sm:O8IIAJYBALoBAM4BALoBAMQBAK4BAT4Ezg0AlgEAugEAzgEAugEAxAEAzgEAugEAngEApgEAlAEAlgEAyAEA4gEA0AEBDQxiAK4BAQIEhA4AlAEAugEAzgEAugEAzgEAugEAxAEAnAEApgEAlAEAlgEAyAEAjgIA0AEBDwZgAQIBkAEBBgGKAQEFBMwKAJwBAKYBAJgBAJYBAGQAlgEAZACMAgDQAQEZBmABAgGQAQEGAYgBAQUE7AUAegDmAQCMAQA # TODO: should this be in strings? test 'rec format template', fn: @@ -840,6 +861,9 @@ test 'rec format template', fn: (local $:lit_2 (ref null any)) (local $:lit_3 (ref null any)) (local $:lit_4 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_2 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:caps_arg (array.new_fixed $rt/apply.wat:Captures 1 (local.get $:ret_0))) (local.set $:v_17 (struct.new $rt/apply.wat:Closure (ref.func $test::v_25) (local.get $:caps_arg))) @@ -861,7 +885,7 @@ test 'rec format template', fn: (data $d_1 "a") (data $d_2 "test") ) - ;; sm:EeYHAJQBALoBAMQBAQIFkAEA1AEBARDmBwCYAQC0AQDQAQEQBmABAgGQAQEGAYgBAQUE7AUAegDmAQCMAQA + ;; sm:E-YHAJQBALoBAMQBAQIFkAEA1AEBARC4CACcAQCmAQCYAQC0AQDQAQEQBmABAgGQAQEGAYgBAQUE7AUAegDmAQCMAQA test 'rec dot dynamic key', fn: expect wat ƒink: @@ -920,6 +944,9 @@ test 'rec dot dynamic key', fn: (local $:lit_3 (ref null any)) (local $:lit_4 (ref null any)) (local $:lit_5 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_2 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_r_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:r (local.get $:cell_r_0)) @@ -950,5 +977,5 @@ test 'rec dot dynamic key', fn: (data $d_2 "a") (data $d_3 "k") ) - ;; sm:JMwOAJQBALoBAM4BALoBAM4BALoBAMQBAJwBAKIBAJQBAJYBAMYBARgBjAEAnAEAogEAlAEAlgEAxgEArAEArAEBEAX6CQCYAQCUAQBgAJQBAGAAiAIA0AEBHwdgAQIBkAEBBgKKAQEFBewFAHoA5gEAjAEA -BAK4BAMwBAR8HWgECAYoBAQYChAEBBQXYBQB6AOYBAIwBAA + ;; sm:JswOAJQBALoBAM4BALoBAM4BALoBAMQBAJwBAKIBAJQBAJYBAMYBARgBjAEAnAEAogEAlAEAlgEAxgEArAEArAEBEAXMCgCcAQCmAQCYAQCUAQBgAJQBAGAAiAIA0AEBHwdgAQIBkAEBBgKKAQEFBewFAHoA5gEAjAEA + diff --git a/src/passes/wasm/test_sets.fnk b/src/passes/wasm/test_sets.fnk index 526618c..440355b 100644 --- a/src/passes/wasm/test_sets.fnk +++ b/src/passes/wasm/test_sets.fnk @@ -33,6 +33,7 @@ test 'set import + construction', fn: (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:lit_29) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:lit_28) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:ret_116) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 33)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $set_0)) ) (func $test::v_83 (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) @@ -134,6 +135,9 @@ test 'set import + construction', fn: (local $:imp_val_set (ref null any)) (local $:imp_key_set (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_1 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_2 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:caps_arg (array.new_fixed $rt/apply.wat:Captures 1 (local.get $:ret_2))) (local.set $:v_75 (struct.new $rt/apply.wat:Closure (ref.func $test::v_129) (local.get $:caps_arg))) @@ -157,7 +161,7 @@ test 'set import + construction', fn: (data $d_0 "set") (data $d_1 "test") ) - ;; sm:SY4JAJYBALoBAMYBAQIDVAFAAYoBAQYBigEBBgGKAQBuAMIBAMIBAMIBAMQBAPIGAJYBAJoBAJYBALoBAMYBAG4AvgEAxAgAlgEAugEAxgEAxgEAuAEA0AEBTRySAQEAHLYGALoBAMYBAG4AwggAmgEAmgEAmgEAmgEAlAEA4AEA0gEAtgEA0AEBABy0BABYAKQJAJQBALoBAMYBALgBANIBAHoA0gEAegDSAQBuALwBAL4BAL4BANwJAJgBALQBANIBAGQAbACcAQCGAgBuAMQBAKQFAHoA5gEAjAEA + ;; sm:TI4JAJYBALoBAMYBAQIDVAFAAYoBAQYBigEBBgGKAQBuAMIBAMIBAMIBAMQBAIIBAPIGAJYBAJoBAJYBALoBAMYBAG4AvgEAxAgAlgEAugEAxgEAxgEAuAEA0AEBTRySAQEAHLYGALoBAMYBAG4AwggAmgEAmgEAmgEAmgEAlAEA4AEA0gEAtgEA0AEBABy0BABYAKQJAJQBALoBAMYBALgBANIBAHoA0gEAegDSAQBuALwBAL4BAL4BAK4KAJwBAKYBAJgBALQBANIBAGQAbACcAQCGAgBuAMQBAKQFAHoA5gEAjAEA test 'set spread', fn: @@ -181,6 +185,7 @@ test 'set spread', fn: (local.set $:args (call $rt/apply.wat:args_empty)) (local.set $:args (call $rt/apply.wat:args_concat (local.get $:v_36) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:ret_107) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 40)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $set_106)) ) (func $test::v_123 (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) @@ -335,6 +340,9 @@ test 'set spread', fn: (local $:imp_val_set (ref null any)) (local $:imp_key_set (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_1 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_2 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:caps_arg (array.new_fixed $rt/apply.wat:Captures 1 (local.get $:ret_2))) (local.set $:v_103 (struct.new $rt/apply.wat:Closure (ref.func $test::v_187) (local.get $:caps_arg))) @@ -358,7 +366,7 @@ test 'set spread', fn: (data $d_0 "set") (data $d_1 "test") ) - ;; sm:XboHAJYBALoBAMQBAMYBAG4AvAEAxAEAwAgAlgEAugEAxAEAxgEA4gEA0gEBSAGKAQEAAeQIAJYBALoBAMQBAMYBAOIBANIBAQYBigEBAAGoCQCWAQC6AQDGAQFLA1QA3gEA0gEBUgGKAQENCXIBDgGiBwCWAQCaAQCWAQC6AQDIAQBuAL4BAMoIAJYBALoBAMgBAMgBALoBANIBAVMckgEBABy8BgC6AQDIAQBuAMQIAJoBAJoBAJoBAJoBAJQBAOABANIBALYBANIBAQActAQAWACkCQCUAQC6AQDGAQC4AQDSAQB6ANIBAHoA0gEAbgC8AQC-AQC-AQDeCQCYAQC0AQDUAQBkAGwAnAEAhgIAbgDEAQCmBQB6AOYBAIwBAA + ;; sm:YLoHAJYBALoBAMQBAMYBAG4AvAEAxAEAggEAwAgAlgEAugEAxAEAxgEA4gEA0gEBSAGKAQEAAeQIAJYBALoBAMQBAMYBAOIBANIBAQYBigEBAAGoCQCWAQC6AQDGAQFLA1QA3gEA0gEBUgGKAQENCXIBDgGiBwCWAQCaAQCWAQC6AQDIAQBuAL4BAMoIAJYBALoBAMgBAMgBALoBANIBAVMckgEBABy8BgC6AQDIAQBuAMQIAJoBAJoBAJoBAJoBAJQBAOABANIBALYBANIBAQActAQAWACkCQCUAQC6AQDGAQC4AQDSAQB6ANIBAHoA0gEAbgC8AQC-AQC-AQCwCgCcAQCmAQCYAQC0AQDUAQBkAGwAnAEAhgIAbgDEAQCmBQB6AOYBAIwBAA test 'set destructure empty', fn: @@ -628,6 +636,7 @@ test 'set destructure empty', fn: (local.set $:v_198 (struct.new $rt/apply.wat:Closure (ref.func $test::v_318) (local.get $:caps_arg))) (local.set $:args (call $rt/apply.wat:args_empty)) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:v_198) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 118)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $set_0)) ) (func $test::v_326 (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) @@ -730,6 +739,9 @@ test 'set destructure empty', fn: (local $:imp_val_set (ref null any)) (local $:imp_key_set (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_3 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_s_1 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:s (local.get $:cell_s_1)) @@ -757,7 +769,7 @@ test 'set destructure empty', fn: (data $d_1 "s") (data $d_2 "set") ) - ;; sm:vwGKBgCaAQFsAYoBAG4AwgEAuAYAugEAwgEAyAEAbgDGAQCyCACWAQC6AQDIAQDIAQCGAQB8ALINAJYBALoBAMgBAMgBAQcCVADoAQDUAQEAAvwFALoBAMgBAG4AzggAnAEAmgEAnAEAmgEAlgEA5AEA1AEAuAEA1AEBAALoCgCcAQCaAQCcAQCaAQCWAQC6AQDCAQDgAQDSAQB6ANIBAG4AvgEAxAEAvgEAyAUAmgEBFgGKAQBuAMIBAMQHAJwBAJoBAJwBAJoBAJYBALoBAMIBAG4AxAEAgAQAWACEBwC6AQDCAQDGAQDCAQB6ANQBAG4AwAEAwAEAxAEA9AgAmgEAmgEAlgEAugEAwgEAwgEAhAIA1AEAbgC-AQDAAQDCAQDyDwCWAQC6AQDGAQCcAQCiAQCUAQCWAQDGAQB6ANIBALIBANIBAHoA0gEAsgEA0gEA2AEA1AEAqAEAbgDKAQDEAQCuCACWAQC6AQDGAQF3A1QAuAEA1AEAbgDAAQD2BgCWAQCaAQCWAQC6AQDIAQBuAL4BAMwIAJYBALoBAMgBAMgBALoBANQBAQEckgEBABy-BgC6AQDIAQBuAMoIAJoBAJoBAJwBAJoBAJQBAOIBANQBALgBANQBAQAcuAQAWACoCQCUAQC6AQDGAQC4AQDUAQB6ANIBAHoA1AEAbgC8AQDAAQDAAQDICgCYAQCUAQBgALQBANQBAGQAbACcAQCGAgBuAMQBAKYFAHoA5gEAjAEA + ;; sm:wgGKBgCaAQFsAYoBAG4AwgEAuAYAugEAwgEAyAEAbgDGAQCyCACWAQC6AQDIAQDIAQCGAQB8ALINAJYBALoBAMgBAMgBAQcCVADoAQDUAQEAAvwFALoBAMgBAG4AzggAnAEAmgEAnAEAmgEAlgEA5AEA1AEAuAEA1AEBAALoCgCcAQCaAQCcAQCaAQCWAQC6AQDCAQDgAQDSAQB6ANIBAG4AvgEAxAEAvgEAyAUAmgEBFgGKAQBuAMIBAMQHAJwBAJoBAJwBAJoBAJYBALoBAMIBAG4AxAEAgAQAWACEBwC6AQDCAQDGAQDCAQB6ANQBAG4AwAEAwAEAxAEA9AgAmgEAmgEAlgEAugEAwgEAwgEAhAIA1AEAbgC-AQDAAQDCAQDyDwCWAQC6AQDGAQCcAQCiAQCUAQCWAQDGAQB6ANIBALIBANIBAHoA0gEAsgEA0gEA2AEA1AEAqAEAbgDKAQDEAQCuCACWAQC6AQDGAQF3A1QAuAEA1AEAbgDAAQCEAQD2BgCWAQCaAQCWAQC6AQDIAQBuAL4BAMwIAJYBALoBAMgBAMgBALoBANQBAQEckgEBABy-BgC6AQDIAQBuAMoIAJoBAJoBAJwBAJoBAJQBAOIBANQBALgBANQBAQAcuAQAWACoCQCUAQC6AQDGAQC4AQDUAQB6ANIBAHoA1AEAbgC8AQDAAQDAAQCaCwCcAQCmAQCYAQCUAQBgALQBANQBAGQAbACcAQCGAgBuAMQBAKYFAHoA5gEAjAEA test 'set destructure non-empty', fn: @@ -1036,6 +1048,7 @@ test 'set destructure non-empty', fn: (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:lit_30) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:lit_29) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:v_201) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 121)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $set_0)) ) (func $test::v_329 (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) @@ -1138,6 +1151,9 @@ test 'set destructure non-empty', fn: (local $:imp_val_set (ref null any)) (local $:imp_key_set (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_3 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_s_1 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:s (local.get $:cell_s_1)) @@ -1165,7 +1181,7 @@ test 'set destructure non-empty', fn: (data $d_1 "s") (data $d_2 "set") ) - ;; sm:xQGKBgCaAQF4AYoBAG4AwgEAuAYAugEAwgEAyAEAbgDGAQCyCACWAQC6AQDIAQDIAQCGAQB8ALINAJYBALoBAMgBAMgBAQcCVADoAQDUAQEAAvwFALoBAMgBAG4AzggAnAEAmgEAnAEAmgEAlgEA5AEA1AEAuAEA1AEBAALoCgCcAQCaAQCcAQCaAQCWAQC6AQDCAQDgAQDSAQB6ANIBAG4AvgEAxAEAvgEAyAUAmgEBFgGKAQBuAMIBAMQHAJwBAJoBAJwBAJoBAJYBALoBAMIBAG4AxAEAgAQAWACEBwC6AQDCAQDGAQDCAQB6ANQBAG4AwAEAwAEAxAEA9AgAmgEAmgEAlgEAugEAwgEAwgEAhAIA1AEAbgC-AQDAAQDCAQDyDwCWAQC6AQDGAQCcAQCiAQCUAQCWAQDGAQB6ANIBALIBANIBAHoA0gEAsgEA0gEA2AEA1AEAqAEAbgDKAQDEAQCGCgCWAQC6AQDGAQGDAQNUALgBANQBAUgBigEBBgGKAQEGAYoBAG4AwgEAwgEAwgEAwAEA9gYAlgEAmgEAlgEAugEAyAEAbgC-AQDMCACWAQC6AQDIAQDIAQC6AQDUAQFVHJIBAQAcvgYAugEAyAEAbgDKCACaAQCaAQCcAQCaAQCUAQDiAQDUAQC4AQDUAQEAHLgEAFgAqAkAlAEAugEAxgEAuAEA1AEAegDSAQB6ANQBAG4AvAEAwAEAwAEAyAoAmAEAlAEAYAC0AQDUAQBkAGwAnAEAhgIAbgDEAQCmBQB6AOYBAIwBAA + ;; sm:yAGKBgCaAQF4AYoBAG4AwgEAuAYAugEAwgEAyAEAbgDGAQCyCACWAQC6AQDIAQDIAQCGAQB8ALINAJYBALoBAMgBAMgBAQcCVADoAQDUAQEAAvwFALoBAMgBAG4AzggAnAEAmgEAnAEAmgEAlgEA5AEA1AEAuAEA1AEBAALoCgCcAQCaAQCcAQCaAQCWAQC6AQDCAQDgAQDSAQB6ANIBAG4AvgEAxAEAvgEAyAUAmgEBFgGKAQBuAMIBAMQHAJwBAJoBAJwBAJoBAJYBALoBAMIBAG4AxAEAgAQAWACEBwC6AQDCAQDGAQDCAQB6ANQBAG4AwAEAwAEAxAEA9AgAmgEAmgEAlgEAugEAwgEAwgEAhAIA1AEAbgC-AQDAAQDCAQDyDwCWAQC6AQDGAQCcAQCiAQCUAQCWAQDGAQB6ANIBALIBANIBAHoA0gEAsgEA0gEA2AEA1AEAqAEAbgDKAQDEAQCGCgCWAQC6AQDGAQGDAQNUALgBANQBAUgBigEBBgGKAQEGAYoBAG4AwgEAwgEAwgEAwAEAhAEA9gYAlgEAmgEAlgEAugEAyAEAbgC-AQDMCACWAQC6AQDIAQDIAQC6AQDUAQFVHJIBAQAcvgYAugEAyAEAbgDKCACaAQCaAQCcAQCaAQCUAQDiAQDUAQC4AQDUAQEAHLgEAFgAqAkAlAEAugEAxgEAuAEA1AEAegDSAQB6ANQBAG4AvAEAwAEAwAEAmgsAnAEApgEAmAEAlAEAYAC0AQDUAQBkAGwAnAEAhgIAbgDEAQCmBQB6AOYBAIwBAA test 'set destructure peel one', fn: @@ -1529,6 +1545,7 @@ test 'set destructure peel one', fn: (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:lit_31) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:lit_30) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:v_252) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 153)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $set_0)) ) (func $test::v_422 (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) @@ -1631,6 +1648,9 @@ test 'set destructure peel one', fn: (local $:imp_val_set (ref null any)) (local $:imp_key_set (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_4 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_s_1 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:s (local.get $:cell_s_1)) @@ -1658,5 +1678,5 @@ test 'set destructure peel one', fn: (data $d_1 "s") (data $d_2 "set") ) - ;; sm:8QGKBgCaAQF4AYoBAG4AwgEAuAYAugEAwgEAyAEAbgDGAQCyCACWAQC6AQDIAQDIAQCGAQB8ALINAJYBALoBAMgBAMgBAQcCVADoAQDUAQEAAvwFALoBAMgBAG4AzggAnAEAmgEAnAEAmgEAlgEA5AEA1AEAuAEA1AEBAALoCgCcAQCaAQCcAQCaAQCWAQC6AQDCAQDgAQDSAQB6ANIBAG4AvgEAxAEAvgEA0gUAnAEAmgEAkgEBKgOQAQEHB_AHAJYBALoBAMIBAMgBAQ8BUABuAL4BAMYBAPgGAJYBAJoBAJYBALoBAMgBAG4AvgEAhAgAlgEAugEAyAEAyAEAugEA1AEBAQeUBgC6AQDIAQBuAM4IAJwBAJoBAJwBAJoBAJYBAOQBANQBALgBANQBAQAH6goAnAEAmgEAnAEAmgEAlgEAugEAwgEA4AEA1AEAegDSAQBuAL4BAMQBAMABAP4DAFgAhAcAugEAwgEAxgEAwgEAegDUAQBuAMABAMABAMQBAPgIAJwBAJoBAJgBALoBAMIBAMIBAIgCANQBAG4AwAEAwAEAxAEA9g8AlgEAugEAxgEAnAEAogEAlAEAlgEAxgEAegDSAQCyAQDSAQB6ANQBALQBANQBANoBANQBAKgBAG4AygEAxAEAhgoAlgEAugEAxgEBfQNUALgBANQBAUgBigEBBgGKAQEGAYoBAG4AwgEAwgEAwgEAwAEA9gYAlgEAmgEAlgEAugEAyAEAbgC-AQDMCACWAQC6AQDIAQDIAQC6AQDUAQFVHJIBAQAcvgYAugEAyAEAbgDMCACcAQCaAQCcAQCaAQCUAQDkAQDUAQC4AQDUAQEAHLgEAFgAqAkAlAEAugEAxgEAuAEA1AEAegDSAQB6ANQBAG4AvAEAwAEAwAEAyAoAmAEAlAEAYAC0AQDUAQBkAGwAnAEAhgIAbgDEAQCmBQB6AOYBAIwBAA + ;; sm:9AGKBgCaAQF4AYoBAG4AwgEAuAYAugEAwgEAyAEAbgDGAQCyCACWAQC6AQDIAQDIAQCGAQB8ALINAJYBALoBAMgBAMgBAQcCVADoAQDUAQEAAvwFALoBAMgBAG4AzggAnAEAmgEAnAEAmgEAlgEA5AEA1AEAuAEA1AEBAALoCgCcAQCaAQCcAQCaAQCWAQC6AQDCAQDgAQDSAQB6ANIBAG4AvgEAxAEAvgEA0gUAnAEAmgEAkgEBKgOQAQEHB_AHAJYBALoBAMIBAMgBAQ8BUABuAL4BAMYBAPgGAJYBAJoBAJYBALoBAMgBAG4AvgEAhAgAlgEAugEAyAEAyAEAugEA1AEBAQeUBgC6AQDIAQBuAM4IAJwBAJoBAJwBAJoBAJYBAOQBANQBALgBANQBAQAH6goAnAEAmgEAnAEAmgEAlgEAugEAwgEA4AEA1AEAegDSAQBuAL4BAMQBAMABAP4DAFgAhAcAugEAwgEAxgEAwgEAegDUAQBuAMABAMABAMQBAPgIAJwBAJoBAJgBALoBAMIBAMIBAIgCANQBAG4AwAEAwAEAxAEA9g8AlgEAugEAxgEAnAEAogEAlAEAlgEAxgEAegDSAQCyAQDSAQB6ANQBALQBANQBANoBANQBAKgBAG4AygEAxAEAhgoAlgEAugEAxgEBfQNUALgBANQBAUgBigEBBgGKAQEGAYoBAG4AwgEAwgEAwgEAwAEAhAEA9gYAlgEAmgEAlgEAugEAyAEAbgC-AQDMCACWAQC6AQDIAQDIAQC6AQDUAQFVHJIBAQAcvgYAugEAyAEAbgDMCACcAQCaAQCcAQCaAQCUAQDkAQDUAQC4AQDUAQEAHLgEAFgAqAkAlAEAugEAxgEAuAEA1AEAegDSAQB6ANQBAG4AvAEAwAEAwAEAmgsAnAEApgEAmAEAlAEAYAC0AQDUAQBkAGwAnAEAhgIAbgDEAQCmBQB6AOYBAIwBAA diff --git a/src/passes/wasm/test_strings.fnk b/src/passes/wasm/test_strings.fnk index 80373d4..48d6ad4 100644 --- a/src/passes/wasm/test_strings.fnk +++ b/src/passes/wasm/test_strings.fnk @@ -12,6 +12,9 @@ test 'empty string literal', fn: (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (call $std/str.fnk:str_empty)) (local.set $:args (call $rt/apply.wat:args_empty)) @@ -29,7 +32,7 @@ test 'empty string literal', fn: ) (data $d_0 "test") ) - ;; sm:CZAFAJgBAQACbABuAMABAKYFAHoA5gEAjAEA + ;; sm:C-IFAJwBAKYBAJgBAQACbABuAMABAKYFAHoA5gEAjAEA @@ -43,6 +46,9 @@ test 'string literal', fn: (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_1 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (call $std/str.fnk:from_data (data.ref $d_0 5))) (local.set $:args (call $rt/apply.wat:args_empty)) @@ -61,7 +67,7 @@ test 'string literal', fn: (data $d_0 "hello") (data $d_1 "test") ) - ;; sm:CZAFAJgBAQAHkAEAbgDAAQCmBQB6AOYBAIwBAA + ;; sm:C-IFAJwBAKYBAJgBAQAHkAEAbgDAAQCmBQB6AOYBAIwBAA test 'string literal dedup', fn: @@ -85,6 +91,9 @@ test 'string literal dedup', fn: (local $:pub_name (ref null any)) (local $:unwrap_y_1 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_1 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_2 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_x_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:x (local.get $:cell_x_0)) @@ -123,7 +132,7 @@ test 'string literal dedup', fn: (data $d_2 "x") (data $d_3 "y") ) - ;; sm:Ga4LAJgBAJQBAGAAlAEAYAEAAYoBAJgBAKIBAJQBAJYBAMYBARgBigEAmAEAogEAlAEAlgEAxgEAqAEAbgDKAQCmBQB6AOYBAIwBAA + ;; sm:G4AMAJwBAKYBAJgBAJQBAGAAlAEAYAEAAYoBAJgBAKIBAJQBAJYBAMYBARgBigEAmAEAogEAlAEAlgEAxgEAqAEAbgDKAQCmBQB6AOYBAIwBAA test 'str templ two exprs', fn: @@ -150,6 +159,9 @@ test 'str templ two exprs', fn: (local $:lit_6 (ref null any)) (local $:unwrap_b_1 (ref null any)) (local $:varargs (ref null $rt/apply.wat:VarArgs)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_2 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_a_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:a (local.get $:cell_a_0)) @@ -189,7 +201,7 @@ test 'str templ two exprs', fn: (data $d_2 "b") (data $d_3 " and ") ) - ;; sm:GvgMAJgBAJQBAGAAlAEAYAEAAYIBAJgBAKIBAJQBAJYBAMYBAQwBggEAmAEAogEAlAEAlgEAxgEAqAEBFgWQAQCoAQCUAgEJD7AFAHoA5gEAjAEA + ;; sm:HMoNAJwBAKYBAJgBAJQBAGAAlAEAYAEAAYIBAJgBAKIBAJQBAJYBAMYBAQwBggEAmAEAogEAlAEAlgEAxgEAqAEBFgWQAQCoAQCUAgEJD7AFAHoA5gEAjAEA test 'str tagged template', fn: @@ -206,6 +218,8 @@ test 'str tagged template', fn: (local.set $:ret_4 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:params (call $rt/apply.wat:args_tail (local.get $:params))) (local.set $parts_1 (local.get $:params)) + (call $rt/trace.wat:trace_push (i32.const 0) (i32.const 51)) + (call $rt/trace.wat:trace_pop (i32.const 0) (i32.const 51)) (local.set $:args (call $rt/apply.wat:args_empty)) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $parts_1) (local.get $:args))) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $:ret_4)) @@ -227,6 +241,7 @@ test 'str tagged template', fn: (local.set $:args (call $rt/apply.wat:args_empty)) (local.set $:args (call $rt/apply.wat:args_concat (local.get $:v_12) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:ret_39) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 16)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $:unwrap_foo_38)) ) (func $test::fink_module (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) @@ -241,6 +256,9 @@ test 'str tagged template', fn: (local $:caps_arg (ref null $rt/apply.wat:Captures)) (local $:lit_11 (ref null any)) (local $:lit_10 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_2 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_foo_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:foo (local.get $:cell_foo_0)) @@ -272,7 +290,7 @@ test 'str tagged template', fn: (data $d_1 "foo") (data $d_2 "1\\n2") ) - ;; sm:I4QFAJgBAJoBAFwAbgDCAQC-CACWAQC6AQDOAQC6AQDEAQCwAQBuALwBAMIBAK4LAJgBAJgBAGgAegDOAQCeAQCqAQCUAQCWAQDKAQDiAQDQAQE4BJIBAQcJcgEACdAFAHoA5gEAjAEA + ;; sm:KIQFAJgBAJoBAFwAggEAgAEAbgDCAQC-CACWAQC6AQDOAQC6AQDEAQCwAQBuALwBAMIBAIIBAIAMAJwBAKYBAJgBAJgBAGgAegDOAQCeAQCqAQCUAQCWAQDKAQDiAQDQAQE4BJIBAQcJcgEACdAFAHoA5gEAjAEA test 'str tagged template escape handling', fn: @@ -290,6 +308,8 @@ test 'str tagged template escape handling', fn: (local.set $:ret_5 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:params (call $rt/apply.wat:args_tail (local.get $:params))) (local.set $parts_2 (local.get $:params)) + (call $rt/trace.wat:trace_push (i32.const 0) (i32.const 101)) + (call $rt/trace.wat:trace_pop (i32.const 0) (i32.const 101)) (local.set $:args (call $rt/apply.wat:args_empty)) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $parts_2) (local.get $:args))) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $:ret_5)) @@ -311,6 +331,7 @@ test 'str tagged template escape handling', fn: (local.set $:args (call $rt/apply.wat:args_empty)) (local.set $:args (call $rt/apply.wat:args_concat (local.get $:v_20) (local.get $:args))) (local.set $:args (call $rt/apply.wat:args_prepend (local.get $:ret_67) (local.get $:args))) + (call $rt/trace.wat:trace_mark (i32.const 0) (i32.const 24)) (return_call $rt/apply.wat:apply_3 (local.get $:args) (local.get $:ctx_param) (local.get $:unwrap_foo_66)) ) (func $test::v_83 (type $rt/apply.wat:Fn3) (param $:caps_param (ref null any)) (param $:ctx_param (ref null any)) (param $:params (ref null any)) @@ -372,6 +393,9 @@ test 'str tagged template escape handling', fn: (local $:caps_arg (ref null $rt/apply.wat:Captures)) (local $:lit_13 (ref null any)) (local $:lit_12 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_1 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_3 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_foo_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:foo (local.get $:cell_foo_0)) @@ -417,7 +441,7 @@ test 'str tagged template escape handling', fn: (data $d_3 "bar") (data $d_4 "\\b\\v\\$\\'\\\\\\xC3\\xA9\\u{8A_9E}") ) - ;; sm:P4YFAJgBAJoBAFwAbgDCAQC-CACWAQC6AQDOAQC6AQDEAQCwAQBuALwBAMIBALwJAJYBALoBAM4BALoBAMQBAOIBANABAUgIkgEBBy6aCwCWAQC6AQDOAQC6AQDEAQDOAQC6AQDiAQDQAQCwAQEALugOAJgBAJgBAGgAmAEAaAB6ANABAJ4BAKoBAJQBAJYBAMoBAQ8DhgEAoAEAqgEAlAEAlgEAygEAkAIA0AEBNBuUAQEjLnIBAC7QBQB6AOYBAIwBAA + ;; sm:RIYFAJgBAJoBAFwAhAEAggEAbgDCAQC-CACWAQC6AQDOAQC6AQDEAQCwAQBuALwBAMIBAIIBALwJAJYBALoBAM4BALoBAMQBAOIBANABAUgIkgEBBy6aCwCWAQC6AQDOAQC6AQDEAQDOAQC6AQDiAQDQAQCwAQEALroPAJwBAKYBAJgBAJgBAGgAmAEAaAB6ANABAJ4BAKoBAJQBAJYBAMoBAQ8DhgEAoAEAqgEAlAEAlgEAygEAkAIA0AEBNBuUAQEjLnIBAC7QBQB6AOYBAIwBAA test 'str implicit formatting handling', fn: @@ -432,6 +456,9 @@ test 'str implicit formatting handling', fn: (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_1 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (call $std/str.fnk:from_data (data.ref $d_0 5))) (local.set $:args (call $rt/apply.wat:args_empty)) @@ -450,7 +477,7 @@ test 'str implicit formatting handling', fn: (data $d_0 "1\0a2\0a3") (data $d_1 "test") ) - ;; sm:CZAFAJgBAQANkAEAbgDAAQCmBQB6AOYBAIwBAA + ;; sm:C-IFAJwBAKYBAJgBAQANkAEAbgDAAQCmBQB6AOYBAIwBAA test 'str implicit formatting escapes', fn: @@ -463,6 +490,9 @@ test 'str implicit formatting escapes', fn: (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_1 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (call $std/str.fnk:from_data (data.ref $d_0 14))) (local.set $:args (call $rt/apply.wat:args_empty)) @@ -481,7 +511,7 @@ test 'str implicit formatting escapes', fn: (data $d_0 "\0a\0d\09\0c\08\0b$'\\\c3\a9\e8\aa\9e") (data $d_1 "test") ) - ;; sm:CZAFAJgBAQAlkgEAbgDAAQCmBQB6AOYBAIwBAA + ;; sm:C-IFAJwBAKYBAJgBAQAlkgEAbgDAAQCmBQB6AOYBAIwBAA test 'empty string eq', fn: @@ -494,6 +524,9 @@ test 'empty string eq', fn: (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) (local $:lit_2 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (call $std/str.fnk:str_empty)) (local.set $:lit_2 (call $std/str.fnk:str_empty)) @@ -510,7 +543,7 @@ test 'empty string eq', fn: ) (data $d_0 "test") ) - ;; sm:CJwFAJgBAQACbAEMAmwBCwjWBQB6AOYBAIwBAA + ;; sm:Cu4FAJwBAKYBAJgBAQACbAEMAmwBCwjWBQB6AOYBAIwBAA # TODO: move to ./test_patterns.fnk @@ -708,6 +741,7 @@ test 'match empty string', fn: (local.set $:ret_4 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:params (call $rt/apply.wat:args_tail (local.get $:params))) (local.set $x_1 (call $rt/apply.wat:args_head (local.get $:params))) + (call $rt/trace.wat:trace_push (i32.const 0) (i32.const 215)) (local.set $:caps_arg (ref.null $rt/apply.wat:Captures)) (local.set $:v_29 (struct.new $rt/apply.wat:Closure (ref.func $test::v_209) (local.get $:caps_arg))) (local.set $:caps_arg (array.new_fixed $rt/apply.wat:Captures 1 (local.get $:v_29))) @@ -733,6 +767,9 @@ test 'match empty string', fn: (local $:pub_name (ref null any)) (local $:unwrap_main_0 (ref null any)) (local $:args (ref any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_2 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:cell_main_0 (struct.new $rt/apply.wat:Cell (ref.null any))) (global.set $test:main (local.get $:cell_main_0)) @@ -761,7 +798,7 @@ test 'match empty string', fn: (data $d_0 "test") (data $d_1 "main") ) - ;; sm:d4gFAJoBAUABigEAbgDCAQC4BgC6AQDCAQDIAQBuAMYBALIIAJYBALoBAMgBAMgBAIYBAHwAyAwAnAEAmgEAnAEAmgEAlgEA5AEA1AEBBwJuAQAC2AoAmgEAmgEAmgEAmgEAlAEAugEAwgEA3gEA0gEAegDSAQBuALwBAMIBAL4BAMgFAJoBARoBigEAbgDCAQDEBwCcAQCaAQCcAQCaAQCWAQC6AQDCAQBuAMQBAIAEAFgAhAcAugEAwgEAxgEAwgEAegDUAQBuAMABAMABAMQBAPQIAJoBAJoBAJYBALoBAMIBAMIBAIQCANQBAG4AvgEAwAEAwgEAzgwAmAEAmgEAkgEAegDSAQCyAQDSAQB6ANIBALIBANIBANgBANIBAG4AugEAwAEA6gkAmAEAmgEAbAB6ANABAKABAK4BAJQBAJYBAMwBALQBAG4A0AEApgUAegDmAQCMAQA + ;; sm:eogFAJoBAUABigEAbgDCAQC4BgC6AQDCAQDIAQBuAMYBALIIAJYBALoBAMgBAMgBAIYBAHwAyAwAnAEAmgEAnAEAmgEAlgEA5AEA1AEBBwJuAQAC2AoAmgEAmgEAmgEAmgEAlAEAugEAwgEA3gEA0gEAegDSAQBuALwBAMIBAL4BAMgFAJoBARoBigEAbgDCAQDEBwCcAQCaAQCcAQCaAQCWAQC6AQDCAQBuAMQBAIAEAFgAhAcAugEAwgEAxgEAwgEAegDUAQBuAMABAMABAMQBAPQIAJoBAJoBAJYBALoBAMIBAMIBAIQCANQBAG4AvgEAwAEAwgEAzgwAmAEAmgEAkgEAhAEAegDSAQCyAQDSAQB6ANIBALIBANIBANgBANIBAG4AugEAwAEAvAoAnAEApgEAmAEAmgEAbAB6ANABAKABAK4BAJQBAJYBAMwBALQBAG4A0AEApgUAegDmAQCMAQA test 'empty string eq template', fn: @@ -774,6 +811,9 @@ test 'empty string eq template', fn: (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) (local $:lit_2 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_0 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (call $std/str.fnk:str_empty)) (local.set $:lit_2 (call $std/str.fnk:str_empty)) @@ -790,7 +830,7 @@ test 'empty string eq template', fn: ) (data $d_0 "test") ) - ;; sm:CJwFAJgBAQACbAEMB2wBCw3WBQB6AOYBAIwBAA + ;; sm:Cu4FAJwBAKYBAJgBAQACbAEMB2wBCw3WBQB6AOYBAIwBAA test 'str eq', fn: @@ -803,6 +843,9 @@ test 'str eq', fn: (local $:ret_0 (ref null any)) (local $:lit_1 (ref null any)) (local $:lit_2 (ref null any)) + (local $:mod_reg_url (ref null any)) + (local.set $:mod_reg_url (call $std/str.fnk:from_data (data.ref $d_1 4))) + (call $rt/modules.wat:register_module (i32.const 0) (local.get $:mod_reg_url)) (local.set $:ret_0 (call $rt/apply.wat:args_head (local.get $:params))) (local.set $:lit_1 (call $std/str.fnk:from_data (data.ref $d_0 5))) (local.set $:lit_2 (call $std/str.fnk:from_data (data.ref $d_0 5))) @@ -820,5 +863,7 @@ test 'str eq', fn: (data $d_0 "hello") (data $d_1 "test") ) - ;; sm:CJwFAJgBAQAHkAEBFgeQAQEVEtYFAHoA5gEAjAEA + ;; sm:Cu4FAJwBAKYBAJgBAQAHkAEBFgeQAQEVEtYFAHoA5gEAjAEA + + diff --git a/src/runner/wasmtime_runner.rs b/src/runner/wasmtime_runner.rs index 87cf5f2..067f042 100644 --- a/src/runner/wasmtime_runner.rs +++ b/src/runner/wasmtime_runner.rs @@ -79,6 +79,14 @@ pub fn run( let exit_state: Arc> = Arc::new(Mutex::new(ExitState::default())); let cli_args = Arc::new(args); + // (module_id, cps_id) -> source line, built from the debug marks. Lets + // the trace's `get_loc` resolve a frame's (mid, cid) to a source line. + let loc_map: Arc> = Arc::new( + wasm.marks.iter() + .map(|m| ((m.module_id.0, m.cps_id.0), m.source.start.line)) + .collect(), + ); + let mut linker = Linker::new(&engine); for import in module.imports() { if import.module() == "env" @@ -102,6 +110,18 @@ pub fn run( Ok(()) }).map_err(|e| e.to_string())?; } + "host_resolve_loc" => { + // (module_id, cps_id) -> source line (0 if unknown). Backs the + // trace's get_loc; resolves a frame to a source location. + let lm = loc_map.clone(); + linker.func_new("env", &name, ft, move |_caller, params, results| { + let mid = params[0].unwrap_i32() as u32; + let cid = params[1].unwrap_i32() as u32; + let line = lm.get(&(mid, cid)).copied().unwrap_or(0); + results[0] = Val::I32(line as i32); + Ok(()) + }).map_err(|e| e.to_string())?; + } "host_read_sync" => { let input = stdin.clone(); linker.func_new("env", &name, ft, move |mut caller, params, results| { diff --git a/src/runtime/interop/js/fink.js b/src/runtime/interop/js/fink.js index 108f81f..941c60a 100644 --- a/src/runtime/interop/js/fink.js +++ b/src/runtime/interop/js/fink.js @@ -267,6 +267,10 @@ export const init_wasm = async (bytes, host = {}) => { host_write, host_read_sync: (_fd, _size, _ptr) => 0, host_invoke_cont: (resolver, args, ctx) => resolver(args, ctx), + // Trace source-line resolution needs the compiled debug marks, which + // the wasm+js artifact does not carry. Return 0 (the import's + // "unknown" sentinel) so get_loc yields no line in the JS host. + host_resolve_loc: (_mid, _cid) => 0, }; const { instance } = await WebAssembly.instantiate(bytes, { env }); diff --git a/src/runtime/interop/js/interop.wat b/src/runtime/interop/js/interop.wat index 3955daa..dde5d04 100644 --- a/src/runtime/interop/js/interop.wat +++ b/src/runtime/interop/js/interop.wat @@ -76,6 +76,15 @@ (param $args (ref null any)) (param $ctx (ref null any)) (param $callee (ref null any)))) + ;; Keep rt/trace.wat's instrumentation primitives in the link and alive: + ;; user fragments call them from lowered code, but no runtime module + ;; references them. (get_trace is kept alive via std/trace.fnk's import.) + (import "rt/trace.wat" "trace_push" + (func $trace_push (param i32) (param i32))) + (import "rt/trace.wat" "trace_mark" + (func $trace_mark (param i32) (param i32))) + (import "rt/trace.wat" "trace_pop" + (func $trace_pop (param i32) (param i32))) (import "rt/apply.wat" "empty_ctx" (func $empty_ctx_inner (result (ref any)))) (import "rt/apply.wat" "set_ctx" diff --git a/src/runtime/interop/rust/interop.wat b/src/runtime/interop/rust/interop.wat index bcce381..e242a29 100644 --- a/src/runtime/interop/rust/interop.wat +++ b/src/runtime/interop/rust/interop.wat @@ -61,6 +61,15 @@ (param $args (ref null any)) (param $ctx (ref null any)) (param $callee (ref null any)))) + ;; Keep rt/trace.wat's instrumentation primitives in the link and alive: + ;; user fragments call them from lowered code, but no runtime module + ;; references them. (get_trace is kept alive via std/trace.fnk's import.) + (import "rt/trace.wat" "trace_push" + (func $trace_push (param i32) (param i32))) + (import "rt/trace.wat" "trace_mark" + (func $trace_mark (param i32) (param i32))) + (import "rt/trace.wat" "trace_pop" + (func $trace_pop (param i32) (param i32))) (import "rt/apply.wat" "empty_ctx" (func $empty_ctx (result (ref any)))) (import "rt/apply.wat" "set_ctx" diff --git a/src/runtime/rt/modules.wat b/src/runtime/rt/modules.wat index c242a0c..b4ae173 100644 --- a/src/runtime/rt/modules.wat +++ b/src/runtime/rt/modules.wat @@ -65,6 +65,21 @@ (import "std/list.wat" "prepend" (func $list_prepend (param $head (ref any)) (param $tail (ref $List)) (result (ref $List)))) + ;; Args machinery + int unboxing for the fink-callable get_module_url + ;; Fn3 wrapper. + (import "rt/apply.wat" "args_head" + (func $args_head (param (ref null any)) (result (ref null any)))) + (import "rt/apply.wat" "args_tail" + (func $args_tail (param (ref null any)) (result (ref null any)))) + (import "rt/apply.wat" "args_empty" + (func $args_empty (result (ref any)))) + (import "rt/apply.wat" "args_prepend" + (func $args_prepend (param (ref null any)) (param (ref any)) (result (ref any)))) + (import "std/num.wat" "Num" (type $Num (sub any))) + (import "std/int.wat" "Int" (type $Int (sub $Num (struct)))) + (import "std/int.wat" "_int_ival" + (func $int_ival (param (ref $Int)) (result i64))) + ;; -- Registry ------------------------------------------------------- @@ -72,6 +87,122 @@ ;; Stored as $Rec so we can call rec_get/put_field directly. (global $registry (mut (ref null $Rec)) (ref.null $Rec)) + + ;; -- Module-id → url array ------------------------------------------ + ;; + ;; The trace buffer records call sites as (module_id, cps_id) i32 pairs + ;; (rt/trace.wat). Resolving a frame back to a source location needs + ;; module_id → url. ModuleId is a compile-time concept that does not + ;; otherwise exist in the runtime, so each module self-registers its + ;; own (id, url) from its fink_module via `register_module`. + ;; + ;; A GC array indexed directly by module_id (not a wasm table). Module + ;; ids are small dense ints assigned in BFS order by compile_package. + ;; It grows by 100 slots at a time (array.copy into a bigger array, the + ;; same idiom dict.wat/set.wat use) when an id exceeds capacity. + (type $ModuleUrls (array (mut (ref null any)))) + (global $module_urls (mut (ref null $ModuleUrls)) (ref.null $ModuleUrls)) + + ;; Record module_id → url. Idempotent: re-registering the same id with + ;; the same url is a harmless overwrite (fink_module may run more than + ;; once). Lazy-allocates and grows the table as needed. + (func $register_module (@pub) + (param $id i32) + (param $url (ref null any)) + (local $old (ref null $ModuleUrls)) + (local $new_len i32) + (local $new (ref $ModuleUrls)) + + (local.set $old (global.get $module_urls)) + + ;; Grow (or allocate) if id is out of the current bounds. + (if (i32.ge_u + (local.get $id) + (if (result i32) (ref.is_null (local.get $old)) + (then (i32.const 0)) + (else (array.len (ref.as_non_null (local.get $old)))))) + (then + ;; new_len = max(old_len + 100, id + 1) so a single large id + ;; can't outpace the growth step. + (local.set $new_len + (i32.add + (if (result i32) (ref.is_null (local.get $old)) + (then (i32.const 0)) + (else (array.len (ref.as_non_null (local.get $old))))) + (i32.const 100))) + (if (i32.gt_u (i32.add (local.get $id) (i32.const 1)) (local.get $new_len)) + (then (local.set $new_len (i32.add (local.get $id) (i32.const 1))))) + + (local.set $new (array.new $ModuleUrls (ref.null any) (local.get $new_len))) + (if (i32.eqz (ref.is_null (local.get $old))) + (then + (array.copy $ModuleUrls $ModuleUrls + (local.get $new) (i32.const 0) + (ref.as_non_null (local.get $old)) (i32.const 0) + (array.len (ref.as_non_null (local.get $old)))))) + (global.set $module_urls (local.get $new)))) + + (array.set $ModuleUrls + (ref.as_non_null (global.get $module_urls)) + (local.get $id) + (local.get $url))) + + ;; Look up the url registered for module_id, or null if unregistered + ;; or out of bounds. Raw i32 worker; the fink-callable entry is the + ;; Fn3 wrapper below. + (func $_get_module_url + (param $id i32) + (result (ref null any)) + (if (ref.is_null (global.get $module_urls)) + (then (return (ref.null any)))) + (if (i32.ge_u + (local.get $id) + (array.len (ref.as_non_null (global.get $module_urls)))) + (then (return (ref.null any)))) + (array.get $ModuleUrls + (ref.as_non_null (global.get $module_urls)) + (local.get $id))) + + ;; Fink-callable entry: `get_module_url mod_id`. CPS-lowered args = + ;; [k_caller, mod_id]. mod_id arrives as a boxed $Int; unbox, look up, + ;; tail-call k_caller with the url (or null). + (elem declare func $get_module_url_apply) + + (func $get_module_url_apply (type $Fn3) + (param $_caps (ref null any)) + (param $ctx (ref null any)) + (param $args (ref null any)) + (local $k_caller (ref any)) + (local $id (ref null any)) + (local $rest (ref null any)) + (local $url (ref null any)) + (local $k_args (ref any)) + + (local.set $k_caller (ref.as_non_null (call $args_head (local.get $args)))) + (local.set $rest (call $args_tail (local.get $args))) + (local.set $id (call $args_head (local.get $rest))) + + (local.set $url + (call $_get_module_url + (i32.wrap_i64 + (call $int_ival (ref.cast (ref $Int) (local.get $id)))))) + + (local.set $k_args (call $args_empty)) + (local.set $k_args (call $args_prepend (local.get $url) (local.get $k_args))) + (return_call $apply_3 + (local.get $k_args) + (local.get $ctx) + (local.get $k_caller))) + + (global $get_module_url_closure (ref $Closure) + (struct.new $Closure + (ref.func $get_module_url_apply) + (ref.null $Captures))) + + (func $get_module_url (@pub) + (result (ref any)) + (global.get $get_module_url_closure)) + ;; -- init ----------------------------------------------------------- ;; ;; Direct call. Returns 1 if this is the first call for `mod_url` diff --git a/src/runtime/rt/trace.wat b/src/runtime/rt/trace.wat new file mode 100644 index 0000000..4946515 --- /dev/null +++ b/src/runtime/rt/trace.wat @@ -0,0 +1,273 @@ +;; Trace buffer -- a bounded stack of userland function activations. +;; +;; This is a real backtrace, not a recency log. Each frame is one userland +;; function activation; the live stack of frames is the current call chain. +;; Because Fink compiles every call to a tail call, there is no native wasm +;; call stack to walk; this stack is the portable substitute -- it lives in +;; linear memory so a host can read it even after a hard trap, on any +;; runtime, not just the wasmtime debugger. +;; +;; Three primitives drive it (all carry the full (mid, cid) pair; the +;; redundancy is a dev-time balance check, removable later): +;; trace_push(mid, cid) -- enter a userland fn defined at (mid, cid): +;; push a frame stamped with that identity. +;; trace_mark(mid, cid) -- a call site (mid, cid) within the current fn: +;; update the top frame's current-call-site fields. +;; trace_pop(mid, cid) -- leave fn (mid, cid): pop the top frame. +;; +;; Frame = 4 x i32 = 16 bytes: { fn_mid, fn_cid, call_mid, call_cid }. +;; fn_* -- the function's identity (stamped by push). +;; call_* -- where in the function we currently are (set by mark; 0 until +;; the first call). +;; +;; Bounded window of TRACE_CAP frames. trace_depth is the logical depth and +;; may exceed TRACE_CAP; storage is a ring of TRACE_CAP frames indexed by +;; (depth mod TRACE_CAP), so a push when full overwrites the oldest (bottom, +;; main-ward) frame and a pop at depth 0 is a no-op. The window size is all +;; that bounds how deep the backtrace goes. +;; +;; The user fragment brings memory 0; this module doesn't declare its own, +;; matching interop.wat. + +(module + + (import "rt/apply.wat" "Fn3" (type $Fn3 (sub any))) + (import "rt/apply.wat" "Closure" (type $Closure (sub any))) + (import "rt/apply.wat" "Captures" (type $Captures (sub any))) + (import "rt/apply.wat" "args_empty" + (func $args_empty (result (ref any)))) + (import "rt/apply.wat" "args_prepend" + (func $args_prepend (param (ref null any)) (param (ref any)) (result (ref any)))) + (import "rt/apply.wat" "args_head" + (func $args_head (param (ref null any)) (result (ref null any)))) + (import "rt/apply.wat" "args_tail" + (func $args_tail (param (ref null any)) (result (ref null any)))) + (import "rt/apply.wat" "apply_3" + (func $apply_3 + (param (ref null any)) (param (ref null any)) (param (ref null any)))) + + (import "std/list.wat" "List" (type $List (sub any))) + (import "std/list.wat" "empty" + (func $list_empty (result (ref $List)))) + (import "std/list.wat" "prepend" + (func $list_prepend (param (ref any)) (param (ref $List)) (result (ref $List)))) + + (import "std/num.wat" "Num" (type $Num (sub any))) + (import "std/int.wat" "Int" (type $Int (sub $Num (struct)))) + (import "std/int.wat" "I64" (type $I64 (sub $Int (struct (field $ival i64))))) + (import "std/int.wat" "_box_i64" + (func $box_i64 (param i64) (result (ref $I64)))) + (import "std/int.wat" "_int_ival" + (func $int_ival (param (ref $Int)) (result i64))) + + ;; Host resolves (module_id, cps_id) -> source line (0 if unknown), via + ;; the compiled debug marks. Backs the fink-callable get_loc. + (import "env" "host_resolve_loc" + (func $host_resolve_loc (param i32) (param i32) (result i32))) + + ;; Window capacity in frames. + (global $TRACE_CAP i32 (i32.const 64)) + ;; Bytes per frame: 4 x i32 = { fn_mid, fn_cid, call_mid, call_cid }. + (global $FRAME_BYTES i32 (i32.const 16)) + ;; Byte offset of the frame region (bottom of memory). + (global $trace_base i32 (i32.const 0)) + ;; Logical stack depth. May exceed TRACE_CAP; storage wraps mod TRACE_CAP. + (global $trace_depth (mut i32) (i32.const 0)) + + ;; Byte address of the frame at logical index `idx` (idx mod TRACE_CAP). + (func $frame_addr (param $idx i32) (result i32) + (i32.add + (global.get $trace_base) + (i32.mul + (i32.rem_u (local.get $idx) (global.get $TRACE_CAP)) + (global.get $FRAME_BYTES)))) + + ;; Enter a userland fn defined at (mid, cid): push a frame stamped with + ;; that identity, call site cleared. depth++ (storage wraps when full, + ;; dropping the oldest frame). + (func $trace_push (@pub) + (param $fn_mid i32) + (param $fn_cid i32) + (local $addr i32) + (local.set $addr (call $frame_addr (global.get $trace_depth))) + (i32.store (local.get $addr) (local.get $fn_mid)) + (i32.store offset=4 (local.get $addr) (local.get $fn_cid)) + (i32.store offset=8 (local.get $addr) (i32.const 0)) ;; call_mid + (i32.store offset=12 (local.get $addr) (i32.const 0)) ;; call_cid + (global.set $trace_depth (i32.add (global.get $trace_depth) (i32.const 1)))) + + ;; A call site (mid, cid) within the current fn: update the top frame's + ;; current-call-site fields. No-op if the stack is empty. + (func $trace_mark (@pub) + (param $call_mid i32) + (param $call_cid i32) + (local $addr i32) + (if (i32.eqz (global.get $trace_depth)) + (then (return))) + (local.set $addr + (call $frame_addr (i32.sub (global.get $trace_depth) (i32.const 1)))) + (i32.store offset=8 (local.get $addr) (local.get $call_mid)) + (i32.store offset=12 (local.get $addr) (local.get $call_cid))) + + ;; Leave fn (mid, cid): pop the top frame. No-op at depth 0 (a pop of a + ;; frame that aged out of the bounded window). The (mid, cid) args are + ;; carried for a future balance assert; unused for now. + (func $trace_pop (@pub) + (param $fn_mid i32) + (param $fn_cid i32) + (if (i32.eqz (global.get $trace_depth)) + (then (return))) + (global.set $trace_depth (i32.sub (global.get $trace_depth) (i32.const 1)))) + + ;; Read up to `depth` innermost frames as a fink list of + ;; [call_mid, call_cid] pairs -- the current call site of each live + ;; function, newest (innermost) first. Walks the stack top-down. A frame + ;; whose call site is still 0 (entered, not yet at a call) is emitted as + ;; [fn_mid, fn_cid] instead, so the innermost frame always carries a + ;; useful location. + (func $read_trace + (param $depth i32) + (result (ref $List)) + (local $n i32) + (local $avail i32) + (local $i i32) + (local $addr i32) + (local $mid i32) + (local $cid i32) + (local $result (ref $List)) + (local $frame (ref $List)) + + ;; avail = min(trace_depth, TRACE_CAP); n = min(depth, avail). + (local.set $avail + (select (global.get $trace_depth) (global.get $TRACE_CAP) + (i32.le_u (global.get $trace_depth) (global.get $TRACE_CAP)))) + (local.set $n + (select (local.get $depth) (local.get $avail) + (i32.le_u (local.get $depth) (local.get $avail)))) + + (local.set $result (call $list_empty)) + + ;; Walk bottom-up over the window so that prepending leaves the + ;; newest (innermost) frame at the head - conventional backtrace order + ;; (get_trace's own call site first, callers after). The oldest + ;; in-window frame is logical index (trace_depth - n); the i-th walked + ;; is (trace_depth - n + i). + (local.set $i (i32.const 0)) + (block $done (loop $next + (br_if $done (i32.ge_u (local.get $i) (local.get $n))) + + (local.set $addr + (call $frame_addr + (i32.add + (i32.sub (global.get $trace_depth) (local.get $n)) + (local.get $i)))) + + ;; Prefer the current call site; fall back to fn identity if no call + ;; has been marked yet (call_cid == 0). + (local.set $cid (i32.load offset=12 (local.get $addr))) + (if (i32.eqz (local.get $cid)) + (then + (local.set $mid (i32.load (local.get $addr))) + (local.set $cid (i32.load offset=4 (local.get $addr)))) + (else + (local.set $mid (i32.load offset=8 (local.get $addr))))) + + (local.set $frame + (call $list_prepend + (call $box_i64 (i64.extend_i32_u (local.get $mid))) + (call $list_prepend + (call $box_i64 (i64.extend_i32_u (local.get $cid))) + (call $list_empty)))) + (local.set $result + (call $list_prepend (local.get $frame) (local.get $result))) + + (local.set $i (i32.add (local.get $i) (i32.const 1))) + (br $next))) + + (local.get $result)) + + ;; Fink-callable entry: `get_trace depth`. + ;; CPS-lowered args = [k_caller, depth]. `depth` arrives as a boxed $Int; + ;; unbox it, read the stack, tail-call k_caller with the list. + (elem declare func $get_trace_apply) + + (func $get_trace_apply (type $Fn3) + (param $_caps (ref null any)) + (param $ctx (ref null any)) + (param $args (ref null any)) + (local $k_caller (ref any)) + (local $depth (ref null any)) + (local $rest (ref null any)) + (local $trace (ref $List)) + (local $k_args (ref any)) + + (local.set $k_caller (ref.as_non_null (call $args_head (local.get $args)))) + (local.set $rest (call $args_tail (local.get $args))) + (local.set $depth (call $args_head (local.get $rest))) + + (local.set $trace + (call $read_trace + (i32.wrap_i64 + (call $int_ival (ref.cast (ref $Int) (local.get $depth)))))) + + (local.set $k_args (call $args_empty)) + (local.set $k_args (call $args_prepend (local.get $trace) (local.get $k_args))) + (return_call $apply_3 + (local.get $k_args) + (local.get $ctx) + (local.get $k_caller))) + + (global $get_trace_closure (ref $Closure) + (struct.new $Closure + (ref.func $get_trace_apply) + (ref.null $Captures))) + + (func $get_trace (@pub) + (result (ref any)) + (global.get $get_trace_closure)) + + ;; Fink-callable entry: `get_loc mid, cid` -> source line (0 if unknown). + ;; CPS-lowered args = [k_caller, mid, cid], both boxed $Int. + (elem declare func $get_loc_apply) + + (func $get_loc_apply (type $Fn3) + (param $_caps (ref null any)) + (param $ctx (ref null any)) + (param $args (ref null any)) + (local $k_caller (ref any)) + (local $rest (ref null any)) + (local $mid (ref null any)) + (local $cid (ref null any)) + (local $line i32) + (local $k_args (ref any)) + + (local.set $k_caller (ref.as_non_null (call $args_head (local.get $args)))) + (local.set $rest (call $args_tail (local.get $args))) + (local.set $mid (call $args_head (local.get $rest))) + (local.set $rest (call $args_tail (local.get $rest))) + (local.set $cid (call $args_head (local.get $rest))) + + (local.set $line + (call $host_resolve_loc + (i32.wrap_i64 (call $int_ival (ref.cast (ref $Int) (local.get $mid)))) + (i32.wrap_i64 (call $int_ival (ref.cast (ref $Int) (local.get $cid)))))) + + (local.set $k_args (call $args_empty)) + (local.set $k_args + (call $args_prepend + (call $box_i64 (i64.extend_i32_u (local.get $line))) + (local.get $k_args))) + (return_call $apply_3 + (local.get $k_args) + (local.get $ctx) + (local.get $k_caller))) + + (global $get_loc_closure (ref $Closure) + (struct.new $Closure + (ref.func $get_loc_apply) + (ref.null $Captures))) + + (func $get_loc (@pub) + (result (ref any)) + (global.get $get_loc_closure)) +) diff --git a/std/all.test.fnk b/std/all.test.fnk index 98e3231..b69ec5e 100644 --- a/std/all.test.fnk +++ b/std/all.test.fnk @@ -5,6 +5,7 @@ import './tasks.test.fnk' import './channels.test.fnk' import './effects.test.fnk' import './io.test.fnk' +import './trace.test.fnk' diff --git a/std/testing.fnk b/std/testing.fnk index c4deafd..30f7979 100644 --- a/std/testing.fnk +++ b/std/testing.fnk @@ -1,6 +1,7 @@ {write, stderr} = import 'std/io.fnk' -{suspend, unique, init_ctx} = import 'std/effects.fnk' +{suspend, init_ctx} = import 'std/effects.fnk' +{get_trace, get_module_url, get_loc} = import 'std/trace.fnk' test = fn name, body: @@ -17,7 +18,7 @@ upd_curr_test = fn upd_fn: set_curr_test = fn test_case: - upd_tests fn ctx: + upd_tests fn _: [test_case, {curr: test_case}] @@ -48,7 +49,20 @@ run_test = fn test_case: true -fail = fn failure: +trace_to_str = fn t, s: + match t: + []: s + [[mid, cid], ..rest]: + murl = get_module_url mid + trace_to_str rest, '${s}\n ${murl}:${get_loc mid, cid} (${mid}:${cid})' + + + +fail = fn msg: + trace = get_trace 5 + + failure = trace_to_str trace, '${msg}\nTraceback:' + abort = upd_curr_test fn {abort}: [abort, {result: {failure}}] @@ -81,7 +95,7 @@ test_all = fn: equals = fn actual, expected: match actual == expected: true: true - false: fail '${actual}\n !=\n ${expected}' + false: fail 'act: ${actual}\n !=\n exp: ${expected}' diff --git a/std/trace.fnk b/std/trace.fnk new file mode 100644 index 0000000..4556965 --- /dev/null +++ b/std/trace.fnk @@ -0,0 +1,10 @@ +{get_module_url: rt_get_module_url} = import 'rt/modules.wat' +{get_trace: rt_get_trace, get_loc: rt_get_loc} = import 'rt/trace.wat' + + +get_loc = rt_get_loc + +get_trace = rt_get_trace + + +get_module_url = rt_get_module_url \ No newline at end of file diff --git a/std/trace.test.fnk b/std/trace.test.fnk new file mode 100644 index 0000000..b1728af --- /dev/null +++ b/std/trace.test.fnk @@ -0,0 +1,41 @@ +{test, equals} = import 'std/testing.fnk' + +{get_trace, get_module_url, get_loc} = import 'std/trace.fnk' + + + +trace_to_str = fn t, s: + match t: + []: s + [[mid, cid], ..rest]: + murl = get_module_url mid + trace_to_str rest, '${s}\n ${murl}:${get_loc mid, cid}' + + + +# test 'foooooobar', fn: +# equals +# 41 +# 42 + + +test 'get_trace', fn: + bar = fn depth: + get_trace depth + + [_, ..foo_t] = get_trace 4 + [_, _, ..bar_t] = bar 5 + + equals + trace_to_str foo_t, '' + trace_to_str bar_t, '' + + + + +test 'get_module_url', fn: + [[mod_id, _]] = get_trace 1 + + equals + get_module_url mod_id + './trace.test.fnk'