From b02bdd043673419357eadd6c646b9a77c62e5792 Mon Sep 17 00:00:00 2001 From: zinc Date: Thu, 15 Oct 2026 02:37:04 +0330 Subject: destructors: hint: x: has drop and is live at spawn; the worker's copy drops it too, on x.spawn() of a mailbox struct for each live owned local with a drop; spec 6.15.4, lsp hint check --- src/compiler/builtins.zc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/compiler/builtins.zc') diff --git a/src/compiler/builtins.zc b/src/compiler/builtins.zc index 44ed3b1..fb2dcb2 100644 --- a/src/compiler/builtins.zc +++ b/src/compiler/builtins.zc @@ -856,6 +856,19 @@ int tdroppable(word t) { } // local i holds a value with a drop: one set on it, or one its type declares int ldroppable(int i) { return (local_dropset && local_dropset[i]) || tdroppable(ltype[i]); } +// x.spawn() on a mailbox struct snapshots the whole vm into a worker process, so an +// owned value with a drop that is live there is dropped once in each process (6.15.4) +int spawn_hint() { + int i = lbase; + if (!fchk || !local_dropset) return 0; + while (i < nloc) { + if (!empty(lstate[i]) && !isalias(i) && lstate[i] != S_BORROW && ldroppable(i) && hint_begin(tpack(), HINT_SMALL)) { + rt.put_s(lname[i]); rt.put_s(": has drop and is live at spawn; the worker's copy drops it too"); dg_close(); + } + i++; + } + return 0; +} // entering o3 from normal code: the collector waits until the outermost region is left int o3_enter_code() { callname(intern("rt.o3_enter")); op(O_DROP); return 0; } // a fresh value with a drop that nothing holds: it is held in a hidden slot and -- cgit v1.2.3