From ff2e0823e97d10477341192d72f5d9e61d9d5bad Mon Sep 17 00:00:00 2001 From: eunhhu Date: Sun, 18 Oct 2026 23:29:42 +0100 Subject: 027's 4f-2: no fixed count of states: the header's u16 alone (PURE_MODULE_STATES gone); a module's transient and counted states are flags of each, the lists views and functions change or name sets of states (state_words words, a bit each), the verifier's walked lists a list with its length, duplicate names found by sorting them; an app's eighteen arrays of each state (values, texts, lists, the stored lists' slots, the last save's and the burst's, a reader's, an event's values and marks) in one block sized to its module, a replace laying the new module's apart and taking it once nothing can fail; the runtime's lists placed past any state (PURE_LIST_HEARD 0x10000), their slots after the states'; a snapshot's arrays sized so too; pure_app_read false without room (pure-serve then shows none); a save's drafts, values and the tree's revisions on the stack for 64 states, else on the heap; the JIT compiles modules of 32 states at most (its sets a word), the app's lists read through a pointer; a view reads the app's values as they are (no state changes in one), no copy of 32 a evaluation; unit test: 300 states loaded and the last counted; a hole closed: pure_app_stop read the arrays a failed start never laid; PureApp 4,256 bytes, not 8,504; counts: b39b against b38 with batches within 0.06%, without batches knapsack +0.49%, join +0.23%, the rest within 0.17%; the bank's queries (s38 and s39b in turns, three each) field -1.99%, found -1.18%, in_credit -1.10%, large -0.99%, the rest -0.58% to +0.11% (the first build, s39, copied a view's values at run time's size: in_credit +2.4%); 008 and 027 --- core/test-module.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'core/test-module.c') diff --git a/core/test-module.c b/core/test-module.c index 8014d63..14a2335 100644 --- a/core/test-module.c +++ b/core/test-module.c @@ -190,10 +190,10 @@ static Spec expand(Spec spec) { static size_t build(unsigned char *out, Spec spec) { spec = expand(spec); - unsigned char strings[4096], blob[4096]; + static unsigned char strings[16384], blob[4096]; size_t used = 0, blob_used = 0; - const char *text[512]; - uint32_t offset[512]; + static const char *text[2048]; + static uint32_t offset[2048]; size_t names = 0; for (size_t i = 0; i < spec.ns; ++i) text[names++] = spec.s[i].name; for (size_t i = 0; i < spec.nt; ++i) text[names++] = spec.t[i].name; @@ -555,10 +555,21 @@ static void rejections(void) { abort(); } } - static S many[33]; - static char many_names[33][8]; - for (unsigned i = 0; i < 33; ++i) { snprintf(many_names[i], 8, "s%u", i % 100u); many[i] = (S){many_names[i], 0}; } - CHECK(load((Spec){many, 33, i1, 0, clash, 0, none, 0, load_a, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0}, &module_a) == PURE_LIMIT); + /* No fixed count of states (027's 4f-2): 300 of them (sets of them past a word), the last one counted by a key; a + * module of as many runs in the executor alone (the JIT's sets are a word). */ + enum { MANY = 300 }; + static S many[MANY]; + static char many_names[MANY][8]; + for (unsigned i = 0; i < MANY; ++i) { snprintf(many_names[i], 8, "s%u", i); many[i] = (S){many_names[i], 0}; } + static const O count_last[] = {{L, MANY - 1, 0}, {C, 0, 1}, {ADD, 0, 0}, {ST, MANY - 1, 0}}; + static const I key_in[] = {KEY("go", "KeyG")}; + static const H go[] = {{1, 0, 4}}; + CHECK(load((Spec){many, MANY, key_in, 1, clash, 0, go, 1, count_last, 4, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0}, + &module_a) == PURE_OK && module_a.state_words == 5 && !module_a.jit); + PureApp wide; + CHECK(pure_app_start(&wide, &module_a, (PureData){0}) == PURE_OK && press(&wide, 0) == PURE_OK && press(&wide, 0) == PURE_OK && + wide.values[MANY - 1].num == 2 && wide.values[0].num == 0); + pure_app_stop(&wide); static unsigned char bytes[65536]; size_t size = build(bytes, (Spec){s1, 1, i1, 0, clash, 0, none, 0, load_a, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0}); CHECK(pure_module_load(bytes, size - 1, &module_a, error, sizeof(error)) == PURE_INVALID); @@ -6343,8 +6354,9 @@ static void functions_and_characters(void) { Spec spec = {nums, 1, inputs, LEN(inputs), NULL, 0, handlers, LEN(handlers), code, LEN(code), NULL, 0, others, LEN(others), constants, LEN(constants), NULL, 0, records, 2, NULL, 0}; if (load_functions(spec, fns, LEN(fns), &module_b) != PURE_OK) { fprintf(stderr, "functions: %s\n", error); abort(); } - CHECK(module_b.function[2].lists == UINT32_C(1) << OWN && module_b.function[1].registers == UINT32_C(1) << R_ && - module_b.function[3].held == UINT32_C(1) << 16 && module_b.runner == 2); + CHECK(module_b.state_words == 1 && module_b.function_lists[2] == UINT64_C(1) << OWN && + module_b.function_registers[1] == UINT64_C(1) << R_ && module_b.function[3].held == UINT32_C(1) << 16 && + module_b.runner == 2); PureApp app; CHECK(pure_app_start(&app, &module_b, (PureData){0}) == PURE_OK); for (int round = 0; round < 3; ++round) { /* the frames' room used again, each event alike */ @@ -7109,7 +7121,8 @@ static void view_bodies(void) { Spec spec = {nums, 2, inputs, 1, views, 4, handlers, 1, code, LEN(code), NULL, 0, states, 2, NULL, 0, NULL, 0, records, 1, NULL, 0}; CHECK(load(spec, &module_a) == PURE_OK); - CHECK(module_a.view_body[0] && module_a.view_body[1] && !module_a.view_lists[0] && module_a.view_lists[1] == 1u << SEEN); + CHECK(module_a.view_body[0] && module_a.view_body[1] && module_a.state_words == 1 && !module_a.view_lists[0] && + module_a.view_lists[1] == UINT64_C(1) << SEEN); char *path = new_store(); PureApp app; CHECK(pure_app_start(&app, &module_a, pure_tree_data(path)) == PURE_OK); -- cgit v1.2.3