Fix native bootstrap callback narrowing

- Check callback IR shapes before selecting the fast path.
- Align the emitter contract with inline cycle deallocation.
This commit is contained in:
Chris Tate
2026-10-08 17:40:35 -05:00
parent b9241fe8f6
commit a52126b871
2 changed files with 7 additions and 3 deletions
@@ -416,8 +416,12 @@ function withFastCallback(fn: IrFunction, fastT: CallbackType | null, elem: IrTy
return null;
const at = e.args.findIndex(isValueRead);
if (at < 0) return null;
const read = e.args[at] as IrExpr & { kind: "ternary" };
const state = (read.cond as IrExpr & { kind: "bin" }).left as IrExpr & { kind: "arrayState" };
const read = e.args[at]!;
if (read.kind !== "ternary") return null;
const condition = read.cond;
if (condition.kind !== "bin") return null;
const state = condition.left;
if (state.kind !== "arrayState") return null;
const fastArgs = e.args.slice();
fastArgs[at] = {
kind: "arrayGet",
@@ -62,7 +62,7 @@ export function llvmEmitterCases(): LlvmEmitterCase[] {
"@scr_str_release",
"@scr_arr_release",
);
find("recursive record trace and teardown").contains.push("@scr_cyc_alloc", "@scr_cyc_free");
find("recursive record trace and teardown").contains.push("@scr_cyc_alloc", "@scr_cyc_live");
find("closure capture boxes").contains.push("@sc_retain_box", "@scr_closure_new");
find("synchronous callback environment").contains.push(
"alloca { %ScrClosure, [1 x ptr] }",