diff options
| author | eunhhu <[email protected]> | 2026-10-05 07:32:17 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-10-05 07:38:00 +0100 |
| commit | 75b9c1c1e936e2b7c55275139897e1c78d7939c1 (patch) | |
| tree | 63f4a2c15a9ca651b9ce7f961683692626e551e0 /core/test-module.c | |
| parent | 71f1de8416a01ce6305ec9c5ed29895f4344886b (diff) | |
| download | pure-75b9c1c1e936e2b7c55275139897e1c78d7939c1.tar.gz pure-75b9c1c1e936e2b7c55275139897e1c78d7939c1.zip | |
Run a block through a frame and step, and compile blocks to AArch64 that call the same steps (021)
- run() keeps a block's operand stack and open loops in a Frame; step()
runs one instruction (branches and loops too, one dispatch), and
enter_each, enter_loop, leave_loop and iterate are their own functions.
The executor is the same machine code, 7% fewer instructions.
- The verifier records each instruction's stack height (from its block's
start), so compiled code knows each slot's place.
- module-jit.c (AArch64 Linux; elsewhere, or PURE_JIT=0, none): a
module's handlers', views' and folds' blocks compiled when it loads.
Branches and loops are branches; every other instruction calls the
executor's own step, so both run the same meaning. A loop that is not
opened lands where its iteration would have ended; an empty loop
iterates in place.
- test-module recompiles a module whose code a test changes after load.
- A search (100,000 nodes, 1,000,000 edges, core only) is 150 ms
compiled, against 122 ms executed: a call of step for every instruction
costs more than the executor's switch; the hot instructions are written
as code next.
Diffstat (limited to 'core/test-module.c')
| -rw-r--r-- | core/test-module.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/core/test-module.c b/core/test-module.c index a509349..b7fea70 100644 --- a/core/test-module.c +++ b/core/test-module.c @@ -3,6 +3,7 @@ #define _DARWIN_C_SOURCE /* mkdtemp, which _POSIX_C_SOURCE hides there */ #endif #include "module.h" +#include "module-run.h" #include "module-save.h" #include "module-store.h" #include "module-text.h" @@ -3171,6 +3172,8 @@ static void lane_folds(void) { } planned += module_a.view_plan[VIEWS]; memset(module_b.view_plan, 0, sizeof(module_b.view_plan)); + pure_jit_free(module_b.jit); /* its code changed: compiled again (021) */ + module_b.jit = pure_jit_make(&module_b); PureApp a, b; CHECK(pure_app_start(&a, &module_a, (PureData){0}) == PURE_OK && pure_app_start(&b, &module_b, (PureData){0}) == PURE_OK); pure_app_work(&a, UINT64_MAX); /* counted, never past it */ @@ -3765,6 +3768,8 @@ static void ranges(void) { !module_a.code[118].range && module_a.code[118].plan); for (uint32_t i = 0; i < module_b.code_count; ++i) module_b.code[i].range = 0; memset(module_b.view_range, 0, sizeof(module_b.view_range)); + pure_jit_free(module_b.jit); /* its code changed: compiled again (021) */ + module_b.jit = pure_jit_make(&module_b); uint32_t seed = 0x7a45e11u; unsigned compared = 0, walked = 0; for (unsigned round = 0; round < 60; ++round) { |
