agra
8e21cc5f73
mem: Phase 1.3 — closure env allocation through context.allocator
...
The closure trampoline's env-buffer heap-copy in `lowerLambda` used to
call `.heap_alloc` directly (libc malloc, no protocol). Now it routes
through `allocViaContext` like every other compiler-internal alloc,
so a closure created inside `push Context.{ allocator = ... }` honors
the installed allocator — trackers count the env, arenas absorb it,
custom allocators see it. Closes the last `.heap_alloc` shortcut for
sx-internal allocations.
One ordering subtlety fixed alongside: the deferred restore of
`current_ctx_ref` at lowerLambda exit fired AFTER the env-and-closure
build section, so `allocViaContext` was reading `Ref.fromIndex(0)`
(the lambda's own ctx param, only valid inside the lambda body) when
emitting the alloc in the CALLER's scope. Without the explicit
restore, the env_heap dispatch silently routed through the default
context — the captured tracker never saw it. Fixed by restoring
`current_ctx_ref` right after `self.builder.func = saved_func`, before
the env build.
Regression test: `examples/133-closure-env-routes-through-context-allocator.sx`
mirrors the 130-xx-value pattern — install a Tracer via `push Context`,
create a capturing closure inside, assert `Tracer.count = 1`. Without
the fix the count is 0 (env goes through default context). Verified
by stashing the lower.zig change and re-running.
Bonus: `examples/50-smoke.sx` "closure-gpa" output flips from
`allocs=-1` to `allocs=0`. The old `-1` was the bug's signature —
the test manually `dealloc`'d the env after the closure ran, but the
GPA had never seen the matching alloc, so its counter went negative.
With Phase 1.3 the alloc/dealloc balance at 0. Snapshot regen.
155/155 example tests pass (133 new + 50-smoke regen). Chess green on
macOS / iOS sim / Android.
2026-05-25 12:18:27 +03:00
..
2026-05-24 22:59:20 +03:00
2026-05-24 22:59:20 +03:00
2026-03-06 10:46:28 +02:00
2026-02-09 18:07:41 +02:00
2026-02-09 18:07:41 +02:00
2026-02-14 13:17:22 +02:00
2026-02-09 18:07:41 +02:00
2026-02-09 18:07:41 +02:00
2026-02-09 18:07:41 +02:00
2026-02-09 18:07:41 +02:00
2026-02-09 18:07:41 +02:00
2026-02-24 15:10:02 +02:00
2026-05-24 22:59:20 +03:00
2026-02-24 17:37:52 +02:00
2026-02-24 15:10:02 +02:00
2026-02-11 14:22:25 +02:00
2026-02-09 18:07:41 +02:00
2026-02-24 17:37:52 +02:00
2026-02-14 13:17:22 +02:00
2026-02-09 18:07:41 +02:00
2026-02-11 13:03:04 +02:00
2026-02-17 16:57:12 +02:00
2026-02-17 16:57:12 +02:00
2026-02-14 14:52:39 +02:00
2026-02-24 17:37:52 +02:00
2026-02-16 01:13:34 +02:00
2026-02-24 06:20:38 +02:00
2026-02-11 01:05:21 +02:00
2026-02-22 22:16:30 +02:00
2026-02-11 20:41:43 +02:00
2026-02-26 02:25:02 +02:00
2026-02-12 12:27:35 +02:00
2026-02-14 13:17:22 +02:00
2026-02-14 14:52:39 +02:00
2026-05-24 22:59:20 +03: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-24 17:37:52 +02:00
2026-02-25 15:51:22 +02:00
2026-03-02 21:00:55 +02:00
2026-05-24 22:59:20 +03:00
2026-03-04 17:12:56 +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-25 08:41:50 +03:00
2026-05-25 08:41:50 +03:00
2026-05-17 19:36:37 +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 17:46:17 +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-24 22:59:20 +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 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-19 12:06:08 +03:00
2026-05-25 08:41:50 +03:00
2026-05-25 08:41:50 +03:00
2026-05-25 08:41:50 +03:00
2026-05-18 18:32:55 +03:00
2026-05-24 22:59:20 +03:00
2026-05-19 00:22:35 +03:00
2026-05-19 11:54:36 +03:00
2026-05-19 11:54:36 +03:00
2026-05-19 19:18: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-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-25 09:50:37 +03:00
2026-05-25 11:41:59 +03:00
2026-05-25 12:18:27 +03:00
2026-05-19 11:54:36 +03:00
2026-05-19 11:54:36 +03:00
2026-05-19 11:54:36 +03:00
2026-05-19 11:54:36 +03:00
2026-05-19 11:54:36 +03:00
2026-05-19 11:54:36 +03:00
2026-05-19 11:54:36 +03:00
2026-05-19 11:54:36 +03:00
2026-05-19 11:54:36 +03:00
2026-05-19 11:54:36 +03:00
2026-05-19 11:54:36 +03:00
2026-05-19 11:54:36 +03:00
2026-05-19 11:54:36 +03:00
2026-05-19 11:54:36 +03:00
2026-05-19 11:54:36 +03:00
2026-05-19 11:54:36 +03:00
2026-05-19 11:54:36 +03:00
2026-05-25 09:50:37 +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 12:01:01 +03:00
2026-05-19 11:59:18 +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-20 13:53:25 +03:00
2026-05-20 15:13:33 +03:00
2026-05-20 13:53:25 +03:00
2026-05-20 13:53:25 +03:00
2026-05-20 13:53:25 +03:00
2026-05-20 13:53:25 +03:00
2026-05-20 13:53:25 +03:00
2026-05-20 13:53:25 +03:00
2026-05-20 13:53:25 +03:00
2026-05-23 01:28:32 +03:00
2026-05-23 01:28:32 +03:00
2026-05-20 12:46:40 +03:00
2026-05-20 12:46:40 +03:00
2026-05-20 12:46:40 +03:00
2026-05-20 12:46:40 +03:00
2026-05-20 12:46:40 +03:00
2026-05-20 12:46:40 +03:00
2026-05-20 12:46:40 +03:00
2026-05-20 12:46:40 +03:00
2026-05-23 01:28:32 +03:00
2026-05-20 10:32:56 +03:00
2026-05-20 10:47:07 +03:00
2026-05-20 12:51:48 +03:00
2026-05-20 14:50:21 +03:00
2026-05-20 16:57:30 +03:00
2026-05-20 17:14:51 +03:00
2026-05-19 12:40:21 +03:00
2026-05-19 12:48:38 +03:00
2026-05-19 13:01:28 +03:00
2026-05-19 18:39:10 +03:00
2026-05-19 18:44:14 +03:00
2026-05-19 18:50:26 +03:00
2026-05-19 18:51:56 +03:00
2026-05-19 18:53:19 +03:00
2026-05-19 21:14:31 +03:00
2026-05-20 15:13:33 +03:00
2026-05-19 20:12:09 +03:00
2026-05-19 21:19:09 +03:00
2026-05-17 21:17:17 +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-24 22:59:20 +03:00
2026-05-24 22:59:20 +03:00