agra
79896188eb
ffi M5.A.next.2b: per-call-shape monomorphisation for pack-fns
...
Pack-fns (`isPackFn(fd) == true` — last param `is_variadic AND
is_comptime`, no other comptime params) now emit ONE
monomorphised function per unique call-site signature. Repeat
calls with the same arg-type tuple share the mono; distinct
shapes get distinct symbols. Pre-2b each call inlined a fresh
body copy into the caller's basic block; IR size grew linearly
in call sites.
Plumbing in `src/ir/lower.zig`:
- `isPackFn(fd)` — true when the only comptime param is a
trailing pack. Mixed `($fmt, ..$args)` shapes stay on the
inline `lowerComptimeCall` path (different substitution
mechanism for the comptime non-pack param; deferred).
- `lowerPackFnCall(fd, call_node)`:
- Builds a mangled name `<fn_name>__pack__<arg_types>` from
call-site `inferExprType` results. Distinct shapes get
distinct symbols.
- Cache-checks `lowered_functions`; calls
`monomorphizePackFn` on miss.
- Lowers call args, then re-fetches the func pointer (the
fetch BEFORE arg lowering would invalidate after any
transitively-triggered module.functions.items realloc),
prepends ctx if needed, coerces, emits direct call.
- `monomorphizePackFn(fd, mangled, arg_types)`:
- Mirrors `monomorphizeFunction` for the standard fn build:
save state, build param list (ctx + fixed prefix + N pack
params with synthesised names `__pack_<name>_<i>`),
`beginFunction`, entry block, bind params to scope.
- Installs `pack_arg_nodes[<name>]` with synthesised AST
identifier nodes pointing at the pack-param slots so the
body's `args[<int_literal>]` substitutes through the
existing 2a.B mechanism — substitution resolves to the
mono's own param slot loads.
- Installs `pack_param_count[<name>] = N` so the body's
`args.len` resolves to a compile-time constant via a new
intercept in `lowerFieldAccess` (and the parallel arm in
`inferExprType`).
- Lowers the body with `inline_return_target = null` so
`return X;` emits a real `ret X` instead of the inline-slot
routing — the mono is a real fn now.
- Routed at three call sites: each `if (hasComptimeParams(fd))
{ return self.lowerComptimeCall(...); }` now first checks
`isPackFn(fd)` and routes to `lowerPackFnCall` when true.
Lifetime gotcha caught and fixed: `params.items` is stored by
reference in `Function.init` (no copy), so the local
`ArrayList(Function.Param)` must NOT be deinit'd in
`monomorphizePackFn` — matches the leak convention already used
by `monomorphizeFunction`.
`examples/158-pack-mono-dedup.sx` confirms the dedup
end-to-end: `count(), count(1), count(2), count(1,2,3),
count("x", true)` produces `0 1 1 3 2` at runtime AND emits
exactly 4 monos in IR (`count__pack`, `count__pack_s64`,
`count__pack_s64_s64_s64`, `count__pack_string_bool`) — the
two s64 calls share. `args.len` resolves to the comptime
constant N inside each mono.
`examples/156-pack-typed-index.sx` and
`examples/157-pack-if-return.sx` continue to pass unchanged.
Out of scope:
- Mixed `$fmt + ..$args` shapes (stays on inline path).
- Generic `$R` return types (concrete returns only).
- Bare `args` reference (passing the slice as a whole).
- `args[<runtime_int>]` (non-literal index).
197/197 example tests + `zig build test` green.
2026-05-27 15:44:05 +03:00
..
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 19:44:20 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-05-17 13:19:08 +03:00
2026-05-25 09:10:04 +03:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-05-24 22:59:20 +03:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-20 18:22:42 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 19:44:20 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-22 22:16:30 +02:00
2026-02-22 22:16:30 +02:00
2026-02-22 17:24:04 +02:00
2026-02-22 17:24:04 +02:00
2026-02-22 17:24:04 +02:00
2026-02-22 17:24:04 +02:00
2026-02-22 17:24:04 +02:00
2026-02-28 18:03:38 +02:00
2026-02-23 13:45:44 +02:00
2026-02-23 13:45:44 +02:00
2026-02-25 15:51:22 +02:00
2026-02-25 15:51:22 +02:00
2026-03-02 21:00:55 +02:00
2026-03-02 21:00:55 +02:00
2026-02-15 19:44:20 +02:00
2026-05-25 15:33:28 +03:00
2026-03-05 16:20:36 +02:00
2026-03-05 16:20:36 +02:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-18 00:11:23 +03:00
2026-05-18 00:11:23 +03:00
2026-05-18 00:11:23 +03:00
2026-05-18 00:11:23 +03:00
2026-05-18 00:11:23 +03:00
2026-05-18 00:11:23 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-19 12:06:08 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-27 00:26:30 +03:00
2026-05-27 00:26:30 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 18:32:55 +03:00
2026-05-18 18:32:55 +03:00
2026-05-24 22:59:20 +03:00
2026-05-24 22:59:20 +03:00
2026-05-19 00:22:35 +03:00
2026-05-19 00:22:35 +03:00
2026-05-19 11:31:04 +03:00
2026-05-19 11:31:04 +03:00
2026-05-19 19:18:31 +03:00
2026-05-19 19:18:31 +03:00
2026-05-19 21:14:31 +03:00
2026-05-19 21:14:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-23 01:28:32 +03:00
2026-05-23 01:28:32 +03:00
2026-05-24 22:59:20 +03:00
2026-05-24 22:59:20 +03:00
2026-05-24 22:59:20 +03:00
2026-05-24 22:59:20 +03:00
2026-05-24 22:59:20 +03:00
2026-05-24 22:59:20 +03:00
2026-05-24 22:59:20 +03:00
2026-05-24 22:59:20 +03:00
2026-05-24 22:59:20 +03:00
2026-05-24 22:59:20 +03:00
2026-05-24 22:59:20 +03:00
2026-05-24 22:59:20 +03:00
2026-05-25 09:50:37 +03:00
2026-05-25 09:50:37 +03:00
2026-05-25 11:41:59 +03:00
2026-05-25 11:41:59 +03:00
2026-05-25 12:18:27 +03:00
2026-05-25 12:18:27 +03:00
2026-05-25 15:01:58 +03:00
2026-05-25 15:01:58 +03:00
2026-05-25 15:23:13 +03:00
2026-05-25 15:23:13 +03:00
2026-05-25 15:45:33 +03:00
2026-05-25 15:45:33 +03:00
2026-05-25 15:59:32 +03:00
2026-05-25 15:59:32 +03:00
2026-05-25 17:52:53 +03:00
2026-05-25 17:52:53 +03:00
2026-05-25 21:15:44 +03:00
2026-05-25 21:15:44 +03:00
2026-05-25 21:18:09 +03:00
2026-05-25 21:18:09 +03:00
2026-05-25 21:33:20 +03:00
2026-05-25 21:33:20 +03:00
2026-05-25 22:08:23 +03:00
2026-05-26 22:30:48 +03:00
2026-05-25 22:08:23 +03:00
2026-05-25 22:14:31 +03:00
2026-05-25 22:14:31 +03:00
2026-05-25 22:23:59 +03:00
2026-05-25 22:23:59 +03:00
2026-05-25 22:58:20 +03:00
2026-05-25 22:58:20 +03:00
2026-05-25 23:17:30 +03:00
2026-05-25 23:17:30 +03:00
2026-05-25 23:25:13 +03:00
2026-05-25 23:25:13 +03:00
2026-05-25 23:33:52 +03:00
2026-05-25 23:33:52 +03:00
2026-05-25 23:40:51 +03:00
2026-05-25 23:40:51 +03:00
2026-05-25 23:43:46 +03:00
2026-05-25 23:43:46 +03:00
2026-05-27 09:49:41 +03:00
2026-05-27 09:49:41 +03:00
2026-05-26 01:45:21 +03:00
2026-05-26 01:45:21 +03:00
2026-05-26 01:49:31 +03:00
2026-05-26 01:49:31 +03:00
2026-05-26 01:56:25 +03:00
2026-05-26 01:56:25 +03:00
2026-05-27 12:12:16 +03:00
2026-05-27 12:12:16 +03:00
2026-05-27 12:57:45 +03:00
2026-05-27 12:57:45 +03:00
2026-05-27 13:55:19 +03:00
2026-05-27 13:55:19 +03:00
2026-05-27 14:52:43 +03:00
2026-05-27 14:55:25 +03:00
2026-05-27 15:44:05 +03:00
2026-05-27 15:44:05 +03:00
2026-05-19 11:15:13 +03:00
2026-05-19 11:15:13 +03:00
2026-05-19 11:21:16 +03:00
2026-05-19 11:32:36 +03:00
2026-05-19 11:41:06 +03:00
2026-05-19 11:41:06 +03:00
2026-05-19 11:44:43 +03:00
2026-05-19 11:44:43 +03:00
2026-05-19 11:46:47 +03:00
2026-05-19 11:46:47 +03:00
2026-05-19 11:48:34 +03:00
2026-05-19 11:48:34 +03:00
2026-05-19 11:51:34 +03:00
2026-05-19 11:51:34 +03:00
2026-05-19 11:57:44 +03:00
2026-05-19 11:57:44 +03:00
2026-05-19 11:59:18 +03:00
2026-05-19 11:59:18 +03:00
2026-05-22 13:13:43 +03:00
2026-05-22 13:13:43 +03:00
2026-05-19 12:46:53 +03:00
2026-05-19 12:46:53 +03:00
2026-05-19 21:25:42 +03:00
2026-05-19 21:25:42 +03:00
2026-05-19 21:41:26 +03:00
2026-05-25 15:33:28 +03:00
2026-05-19 21:41:26 +03:00
2026-05-19 22:26:03 +03:00
2026-05-25 15:33:28 +03:00
2026-05-19 22:26:03 +03:00
2026-05-19 22:30:05 +03:00
2026-05-25 15:33:28 +03:00
2026-05-19 22:30:05 +03:00
2026-05-19 22:31:58 +03:00
2026-05-25 15:33:28 +03:00
2026-05-19 22:31:58 +03:00
2026-05-19 22:33:58 +03:00
2026-05-25 15:33:28 +03:00
2026-05-19 22:33:58 +03:00
2026-05-19 22:36:36 +03:00
2026-05-25 15:33:28 +03:00
2026-05-19 22:36:36 +03:00
2026-05-19 22:40:47 +03:00
2026-05-25 15:33:28 +03:00
2026-05-19 22:40:47 +03:00
2026-05-23 01:28:32 +03:00
2026-05-23 01:28:32 +03:00
2026-05-23 01:28:32 +03:00
2026-05-23 01:28:32 +03:00
2026-05-20 09:24:14 +03:00
2026-05-20 09:24:14 +03:00
2026-05-20 09:30:02 +03:00
2026-05-20 09:30:02 +03:00
2026-05-20 09:35:09 +03:00
2026-05-20 09:35:09 +03:00
2026-05-20 10:02:56 +03:00
2026-05-20 10:02:56 +03:00
2026-05-20 10:05:30 +03:00
2026-05-20 10:05:30 +03:00
2026-05-20 10:10:23 +03:00
2026-05-20 10:10:23 +03:00
2026-05-20 10:15:10 +03:00
2026-05-20 10:15:10 +03:00
2026-05-20 11:07:41 +03:00
2026-05-25 15:33:28 +03:00
2026-05-20 11:07:41 +03:00
2026-05-23 01:28:32 +03:00
2026-05-23 01:28:32 +03:00
2026-05-20 10:41:24 +03:00
2026-05-20 10:41:24 +03:00
2026-05-20 10:54:37 +03:00
2026-05-25 15:33:28 +03:00
2026-05-20 10:54:37 +03:00
2026-05-20 13:53:25 +03:00
2026-05-20 13:53:25 +03:00
2026-05-20 14:42:03 +03:00
2026-05-20 14:42:03 +03:00
2026-05-20 16:57:30 +03:00
2026-05-20 16:57:30 +03:00
2026-05-20 17:14:51 +03:00
2026-05-20 17:14:51 +03:00
2026-05-26 22:46:56 +03:00
2026-05-26 22:46:56 +03:00
2026-05-26 22:46:56 +03:00
2026-05-26 22:46:56 +03:00
2026-05-26 22:38:32 +03:00
2026-05-26 22:38:32 +03:00
2026-05-26 23:10:00 +03:00
2026-05-26 23:10:00 +03:00
2026-05-26 23:02:08 +03:00
2026-05-26 23:02:08 +03:00
2026-05-19 12:45:49 +03:00
2026-05-19 12:45:49 +03:00
2026-05-19 12:56:53 +03:00
2026-05-19 12:56:53 +03:00
2026-05-19 12:59:13 +03:00
2026-05-25 15:33:28 +03:00
2026-05-19 12:59:13 +03:00
2026-05-19 18:39:10 +03:00
2026-05-19 18:39:10 +03:00
2026-05-19 18:44:14 +03:00
2026-05-19 18:44:14 +03:00
2026-05-19 18:45:57 +03:00
2026-05-26 22:38:32 +03:00
2026-05-19 18:50:26 +03:00
2026-05-19 18:51:56 +03:00
2026-05-19 18:51:56 +03:00
2026-05-19 18:53:19 +03:00
2026-05-19 18:53:19 +03:00
2026-05-19 18:57:41 +03:00
2026-05-19 18:57:41 +03:00
2026-05-19 19:00:47 +03:00
2026-05-19 19:00:47 +03:00
2026-05-19 20:12:09 +03:00
2026-05-19 20:12:09 +03:00
2026-05-19 21:19:09 +03:00
2026-05-19 21:19:09 +03:00
2026-05-25 23:29:55 +03:00
2026-05-25 23:29:55 +03:00
2026-05-25 16:10:22 +03:00
2026-05-25 16:10:22 +03:00
2026-05-25 16:10:22 +03:00
2026-05-25 16:10:22 +03:00
2026-05-25 16:10:22 +03:00
2026-05-25 16:10:22 +03:00
2026-05-25 16:07:19 +03:00
2026-05-25 17:00:23 +03:00
2026-05-25 16:23:24 +03:00
2026-05-25 16:23:24 +03:00
2026-05-25 17:00:23 +03:00
2026-05-25 17:00:23 +03:00
2026-05-25 17:03:16 +03:00
2026-05-26 22:38:32 +03:00
2026-05-25 17:03:16 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-26 16:42:21 +03:00
2026-05-26 16:42:21 +03:00
2026-05-27 13:21:23 +03:00
2026-05-27 13:21:23 +03:00