Returns 0 if the call is safe to proceed, or a poison pointer if the call
should be short-circuited (runtime error already set or call depth exceeded).
Return a pointer to a pre-allocated “poison” Closure heap object.
When JIT code tries to call this as a function, it returns itself,
preventing cascading crashes. The runtime error flag is already set,
so the effect machine will catch it before the poison reaches user code.
Return a pre-allocated “lazy poison” Closure for a given error kind.
Unlike error_poison_ptr(), this does NOT set the error flag at creation
time. The error is only triggered when the closure is actually called
(via poison_trampoline_lazy). This is critical for typeclass dictionaries
where error methods exist as fields but may never be invoked.
Debug: called instead of trap user2 when TIDEPOOL_DEBUG_CASE is set.
Prints diagnostic info about the scrutinee that failed case matching.
scrut_ptr is the heap pointer to the scrutinee.
num_alts is the number of data alt tags expected.
alt_tags is a pointer to an array of expected tag u64 values.
Called by JIT code for runtime errors (divZeroError, overflowError).
Sets a thread-local error flag and returns a “poison” Lit(Int#, 0) object
instead of null. This prevents JIT code from segfaulting on the return value.
The effect machine checks the error flag after JIT returns and converts
to Yield::Error.
kind: 0 = divZeroError, 1 = overflowError, 2 = UserError, 3 = Undefined
Allocate a new boxed array of len pointer slots, each initialized to init.
Layout: [u64 length][ptr0][ptr1]…[ptrN-1]
Each slot is 8 bytes (a heap pointer).
Allocate a new mutable byte array of size bytes, zeroed.
Layout: [u64 length][u8 bytes…]
Returns a raw pointer to the allocation (caller stores in Lit value slot).
Called by JIT code when an unresolved external variable is forced.
Returns null to allow execution to continue (will likely segfault later).
In debug mode (TIDEPOOL_TRACE), logs and returns null.