From e1c8812473c89b96e9c1a09f3a46f8f392945b64 Mon Sep 17 00:00:00 2001 From: eunhhu Date: Tue, 6 Oct 2026 03:46:11 +0100 Subject: JIT: an append to a HASHED list in a nest whose books keep DENSE appends' growth in registers checks the memory against the books' headroom (the app's growth lacks theirs until written back): it faulted MEMORY a round late, its work a round more than the executor's (a loop appending to DENSE, FLAT and HASHED lists, memory 6000: 3562 for 3525). pure-run: memory N, the states' budget --- core/module-jit.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'core/module-jit.c') diff --git a/core/module-jit.c b/core/module-jit.c index 7110a19..765d3cd 100644 --- a/core/module-jit.c +++ b/core/module-jit.c @@ -1555,17 +1555,21 @@ static void append(Block *k, const PureOp *op, uint32_t pc, unsigned height) { load64(e, X0, X23, offsetof(PureApp, spent)); add_imm(e, X0, X0, bytes); store64(e, X0, X23, offsetof(PureApp, spent)); - int budgeted = new_label(e); - load64(e, X1, X23, offsetof(PureApp, memory)); - cbz_x(e, X1, budgeted); - cmp_reg(e, X10, X1); - b_cond(e, GT, fault_at(k, PURE_FAULT_MEMORY, pc)); - bind(e, budgeted); - load64(e, X1, X23, offsetof(PureApp, room)); - cmp_reg(e, X0, X1); - b_cond(e, GT, fault_at(k, PURE_FAULT_MEMORY, pc)); int head = kept_find(k, k->loop_of[pc - k->block.start], C_HEADROOM, 0, 0); - if (head >= 0 && k->fresh >> head & 1) sub_imm(e, k->kept[head].reg, k->kept[head].reg, bytes); /* the nest's books' */ + if (head >= 0 && k->fresh >> head & 1) { /* the nest's books keep the headroom: the growth they hold not in the app's yet */ + subs_imm(e, k->kept[head].reg, k->kept[head].reg, bytes); + b_cond(e, LT, fault_at(k, PURE_FAULT_MEMORY, pc)); + } else { + int budgeted = new_label(e); + load64(e, X1, X23, offsetof(PureApp, memory)); + cbz_x(e, X1, budgeted); + cmp_reg(e, X10, X1); + b_cond(e, GT, fault_at(k, PURE_FAULT_MEMORY, pc)); + bind(e, budgeted); + load64(e, X1, X23, offsetof(PureApp, room)); + cmp_reg(e, X0, X1); + b_cond(e, GT, fault_at(k, PURE_FAULT_MEMORY, pc)); + } slow_back(k, s, V_MEM, 0); } -- cgit v1.2.3