fix push array on itself

This commit is contained in:
2026-02-17 13:27:08 -06:00
parent 2e78e7e0b8
commit ad26e71ad1
2 changed files with 11 additions and 4 deletions

View File

@@ -517,13 +517,19 @@ ${alloc_tail("%r")}
${alloc_tail("%r")}
}`
// push(ctx, fp, arr_slot, val_slot) — no dest write
// push(ctx, fp, arr_slot, val_slot) — write back arr in case GC moved it
h[] = `export function l $__push_ss(l %ctx, l %fp, l %arr_slot, l %val_slot) {
@entry
${sr("a", "%arr_slot")}
${sr("b", "%val_slot")}
call $cell_rt_push(l %ctx, l %a, l %b)
${alloc_tail_nw()}
%r =l call $cell_rt_push(l %ctx, l %a, l %b)
%fp2 =l call $cell_rt_refresh_fp_checked(l %ctx)
jnz %fp2, @ok, @exc
@ok
${sw("w", "%fp2", "%arr_slot", "%r")}
ret %fp2
@exc
ret 0
}`
// pop(ctx, fp, dest, arr_slot)

View File

@@ -573,8 +573,9 @@ JSValue cell_rt_goinvoke(JSContext *ctx, JSValue frame_val) {
/* --- Array push/pop --- */
void cell_rt_push(JSContext *ctx, JSValue arr, JSValue val) {
JSValue cell_rt_push(JSContext *ctx, JSValue arr, JSValue val) {
JS_ArrayPush(ctx, &arr, val);
return arr;
}
JSValue cell_rt_pop(JSContext *ctx, JSValue arr) {