ApplyIndirect Closure Ownership Model
3 sections
100%
Overview
Fix the architectural gap where ApplyIndirect/InvokeIndirect (indirect calls through closures) lack per-argument ownership semantics. Currently, Apply/Invoke carry arg_ownership that tells the AIMS system whether the caller or callee manages RC cleanup, but ApplyIndirect/InvokeIndirect have no such field. This forces an inconsistent hybrid: the caller always emits RcDec for indirect call arguments, but PartialApply inside the callee uses ownership transfer semantics (suppresses callee-side RcDec). The result is double-drop or RC leak for every closure that captures an argument passed through ApplyIndirect.