v4 ACL: the countdown at call, as v3 -- the call hook may redirect
Captain Bob ruled "As v3: add at call", "Engine: call redirects" and "Build it". - The engine's call hook returns where P goes. - The kernel checks every call from code defined at run time. A TTL is counted down at the call. At a TTL of 0, or a denied word, the call is sent to (ACL-CALL), with the target on the data stack, which rechecks or refuses it by the word's own name, then goes on to it. - A word being compiled is no longer checked, as in v3. Two things were added while building, both from v3: - (ACL-BUSY) turns the check off while the policy rechecks. Without it the recheck recursed. - (ACL-CALL) does its own refusal and leaves WORD's buffer alone. A first version broke POST's CONVERT.digits. Test first: test_mesh_boot's five new checks failed before; now 120 pass and POST is 990/990. test_exec tests the redirect. test_host_quit's two v4-only expectations now follow v3: a denied word compiles. All 52 tests, test-32 and ASan/UBSan pass. An amd64 session passes 18/18. Five alternating host boots: +1.4% median, inside the noise. DECOMPOSITION.md 5.20 is updated, and the FPGA's call opcode is recorded as owing the same redirect. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
+25
-1
@@ -575,12 +575,21 @@ static void test_address_faults(void)
|
||||
* is pushed and before P moves; with no hook the node runs exactly as before. */
|
||||
static v4_cell seen[8];
|
||||
static unsigned nseen, hook_bad;
|
||||
static void record_call(void *ctx, v4_node *nd, v4_cell target)
|
||||
static v4_cell record_call(void *ctx, v4_node *nd, v4_cell target)
|
||||
{
|
||||
if (ctx != (void *)&seen || nd != &n) hook_bad++;
|
||||
if (nd->p != nd->rs.r) hook_bad++; /* P not moved yet: still the return address */
|
||||
if (nseen < 8) seen[nseen] = target;
|
||||
nseen++;
|
||||
return target; /* the call goes where it was going */
|
||||
}
|
||||
/* a hook that sends the call to 300 instead, when it is for 200 (the ACL's redirect, 2026-11-19) */
|
||||
static v4_cell redirect_call(void *ctx, v4_node *nd, v4_cell target)
|
||||
{
|
||||
(void)ctx; (void)nd;
|
||||
if (nseen < 8) seen[nseen] = target;
|
||||
nseen++;
|
||||
return target == 200 ? 300 : target;
|
||||
}
|
||||
|
||||
static void call_programme(void) /* 100, 200, 100 again, 300; then a halt loop */
|
||||
@@ -620,6 +629,21 @@ static void test_call_hook_sees_every_call(void)
|
||||
"with no hook the node runs the same (P %ld/%ld, depth %u/%u, retired %u/%u)",
|
||||
(long)p_plain, (long)p_hooked, depth_plain, depth_hooked, retired_plain, retired_hooked);
|
||||
CHECK(es.on_call == 0, "v4_exec_reset leaves no hook");
|
||||
|
||||
/* the hook may send the call elsewhere: where it returns is where P goes, and the return address is
|
||||
* the one the call pushed, so the place it is sent to returns to the caller */
|
||||
call_programme();
|
||||
n.mem[300] = word6(V4_OP_SEMI, NOP, NOP, NOP, NOP, NOP);
|
||||
es.on_call = redirect_call; es.on_call_ctx = 0;
|
||||
nseen = 0;
|
||||
v4_exec_step_word(&n, &es, &h); /* call 100, ; */
|
||||
v4_exec_step_word(&n, &es, &h);
|
||||
v4_exec_step_word(&n, &es, &h); /* call 200 -- sent to 300 */
|
||||
CHECK(n.p == 300 && n.rs.depth == 1 && n.rs.r == 12, "a hook that returns 300 for a call to 200 sends it to 300 (P %ld, R %ld)",
|
||||
(long)n.p, (long)n.rs.r);
|
||||
v4_exec_step_word(&n, &es, &h); /* 300's ; */
|
||||
CHECK(n.p == 12 && n.rs.depth == 0, " which returns to the caller, after the call (P %ld)", (long)n.p);
|
||||
v4_exec_reset(&es);
|
||||
}
|
||||
|
||||
/* the hook at retire (#189 Phase 7, ruling 7: compudynamics on the opcodes): every retired instruction, its opcode,
|
||||
|
||||
Reference in New Issue
Block a user