aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-10-06 03:46:11 +0100
committereunhhu <[email protected]>2026-10-06 03:46:11 +0100
commite1c8812473c89b96e9c1a09f3a46f8f392945b64 (patch)
tree69d15026709b48933c9f2aa282f40de6624ba12e /core
parent1b64ab89710a637e66604ece15d83f40ba314586 (diff)
downloadpure-e1c8812473c89b96e9c1a09f3a46f8f392945b64.tar.gz
pure-e1c8812473c89b96e9c1a09f3a46f8f392945b64.zip
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
Diffstat (limited to 'core')
-rw-r--r--core/module-jit.c24
1 files changed, 14 insertions, 10 deletions
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);
}