mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-22 05:59:31 +08:00
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:
@@ -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] }",
|
||||
|
||||
Reference in New Issue
Block a user