test: migrate Fam10 alias value tests to @test, carve divergences to pins (#5-C3)
fold-2 chunk C3 (drew's Fam8-13 plan): 8 alias value-row C drivers, 205 rows
re-homed with zero loss -- 177 value -> 8 test/lang/alias_*_test.ww @test
row-tables; 16 reject -> runww //ww:error carriers (both stages reject);
3 cs!=ww value rows -> 2 *_runonly_test.ww (T1, byte-id-excluded, #60/#81);
9 irreducible asymmetric rows -> slim C pins, each ticket-cited and
mutation-proven non-vacuous:
- accept amplen1/2,ampcap2: cs runs / ww rejects 'unsupported address-of
shape' (#96)
- cgen_b5 g73_heapfill: cs!=ww .s + ww link-fails on self-contained alloc;
compile-smoke pin (#24)
- cgen_b6 fsarg2_bound: both reject, different msgs, each vs the correct
stage (#271/#165 cs vs #272/#276/#277 ww)
- emit_b7 slc/slcstr/slctag _2lvl + slc_plain_ctl: slice-literal static-init
divergence (#120/#29-kin, ken-d2-oracle)
4 fully-migrated drivers deleted, 4 slimmed-in-place to hold only the
irreducible pins. LANGBYTEID floor 74->82 (8 new byte-id @test files); test
count 388->384 (4 deleted; 4 slimmed kept). do-not-auto-batch files not in
Fam10.
This commit is contained in:
@@ -1,118 +1,19 @@
|
||||
/*
|
||||
* 944_alias_cgen_b5_run — #5 alias arc F2b (B5 train): cstage cgen
|
||||
* helper + funnel internalization through type_chase_named (c1), the
|
||||
* #73 tripwire graduation (c2), the #89 cgreturn return-position widen
|
||||
* (c3) and the #93 deref-index pointee chase (c4). All cs-only: every
|
||||
* graduation is a DIVERGE→byte-id flip (cs aligns UP to ww's already-
|
||||
* chasing asm); zero selfhost/lib bytes move across the train, so the
|
||||
* _ww binaries stay bit-identical (the crossing detector).
|
||||
* 944_alias_cgen_b5_run — SLIM CARRIER (#5-C3 alias fold-2). The 27 K_RUN value
|
||||
* rows migrated to test/lang/alias_cgen_b5_test.ww (@test, cs==ww byte-id); the
|
||||
* symmetric K_BUILDERR rejects (fill0_ctl, fill2_loud, g73_static_str) to
|
||||
* test/wcc/data/alias_{fill0_ctl,fill2_loud,g73_static_str}/case.ww runww.
|
||||
*
|
||||
* Row sources are ken's B5 oracle probes (/tmp/ken_b5/src,
|
||||
* .ai/ken-b5-oracle.md + its c1-BOUNDARY ADDENDUM) and the c3/c4
|
||||
* seeds (/tmp/ken_na, kb4).
|
||||
*
|
||||
* row | shape (oracle row) | cs/ww
|
||||
* --------------------+-------------------------------------+------
|
||||
* signed_ctl | kb5_signed: 2-lvl alias i8 field |
|
||||
* | load (fld_issigned) — classifiers |
|
||||
* | recurse, NO-mover control | 0/0
|
||||
* targ_2lvl | kb5_targ: 2-lvl alias (void|i64) |
|
||||
* | param ≤48B (tagged_arg_size) — was |
|
||||
* | cs LIVE exit-1, c1 graduation | 0/0
|
||||
* tmem_2lvl | kb5_tmem: >48B memarg twin |
|
||||
* | (tagged_memarg_size) — graduation | 0/0
|
||||
* wpush_2lvl | kb5_wpush: call-site widen, literal |
|
||||
* | arg (:2905 du) — divergence flip | 0/0
|
||||
* wstore_2lvl/_1lvl | kb5_wstore/wstore1: let-route |
|
||||
* | controls (du arrives chased |
|
||||
* | upstream — ken FLAG-1), NEUTRAL | 0/0
|
||||
* wstore_a_2lvl | kb5_wstore_a: ASSIGN-route re-store |
|
||||
* | — was both-correct divergent; the |
|
||||
* | ident-lhs N_ASSIGN gate (:6359) is |
|
||||
* | cgexpr INLINE, NOT the :2456 funnel |
|
||||
* | (C1-CORR-2) — GRADUATED at B6-c1 | 0/0
|
||||
* succ_2lvl | kb5_succ: `?`-success remap over |
|
||||
* | 2-lvl alias result — was divergent |
|
||||
* | at RETURN positions only (C1-CORR-1)|
|
||||
* | — GRADUATED at c3 with the rt chase | 0/0
|
||||
* null_2lvl | kb5_null: nullable fold + deref |
|
||||
* | (type_isnullable/nullable_ptr_tag) |
|
||||
* | — divergence flip | 0/0
|
||||
* f32p_2lvl | kb5_f32p: nested 2-lvl-alias f64 |
|
||||
* | field struct param |
|
||||
* | (struct_float_class) — flip | 0/0
|
||||
* fill0_ctl | kb5_fill0: named-struct array elem |
|
||||
* | in struct lit — LOUD both stages |
|
||||
* | (twin texts share the experr) | err/err
|
||||
* fill2_loud | kb5_fill2: 1-alias-lvl elem — was |
|
||||
* | both-wrong-IDENTICAL gate-blind, |
|
||||
* | then cs-loud/ww-silent for the one |
|
||||
* | R4-blessed train; #100's ww twin |
|
||||
* | chase closed the window — LOUD-HOLD |
|
||||
* | pair, twin texts share the experr | err/err
|
||||
* tuparg_bound99 / | alias-tuple fn-arg (2-lvl / 1-lvl |
|
||||
* tuparg1_bound99 / | / cast spelling) + alias-tuple |
|
||||
* tuparg_cast_bound99/| global. #99 GRADUATED: cstage |
|
||||
* tupglobal_bound99 | type.c chase accepts the coercion, |
|
||||
* | wwstage cgendecl.ww spill chase |
|
||||
* | sizes the alias param 16B (was |
|
||||
* | dropping SI → t.1 garbage). All |
|
||||
* | now 0/0 byte-id | 0/0
|
||||
* ---- c2 (#73 graduation: tripwire deleted, 6 fu gates chased) --
|
||||
* g73_idxstore / | slice / str / tagged 2-lvl alias |
|
||||
* g73_strfield / | field at the indexed-elem STORE |
|
||||
* g73_tagfield | gate — pre = loud "#73" fatal | 0/0
|
||||
* g73_idxread / | slice arm at the indexed-elem READ, |
|
||||
* g73_ptrread / | ptr-chain READ and tuple-elem READ |
|
||||
* g73_tupread | gates — pre = loud "#73" fatal | 0/0
|
||||
* g73_static_struct | nested-struct arm at the static |
|
||||
* | struct-lit emit gate — pre = "#73" | 0/0
|
||||
* g73_heapfill | str arm at the heap struct-lit fill |
|
||||
* | gate — COMPILE-only pin: bare /tmp |
|
||||
* | programs never link malloc (both |
|
||||
* | stages, pre-existing infra) and the |
|
||||
* | ww deref-field READ carries the |
|
||||
* | #24-kin field(SB) leak, so run + |
|
||||
* | byte-id cells are unavailable; the |
|
||||
* | FILL bytes themselves verified |
|
||||
* | byte-id by hand (= plain control) | asm
|
||||
* g73_static_str | str-field static emit: the #73 |
|
||||
* | fatal gave way to the #129 A.2 |
|
||||
* | foldability loud — now fill0-class |
|
||||
* | both-loud (twin texts) | err/err
|
||||
* ---- c3 (#89: cgreturn return-position widen rt/vu chase) ------
|
||||
* g89_ret_widen | alias-struct return into union — |
|
||||
* | was cs word0-to-DX + CX zeroed |
|
||||
* | (payload dropped, silent exit 1) | 0/0
|
||||
* g89_ret_errunion | 1-LVL alias error-union return — |
|
||||
* | cs MOVQ AX,DX dropped e.aux (the |
|
||||
* | live-truncation seed) | 0/0
|
||||
* g89_ret_named_ctl | bare NAMED struct return control — |
|
||||
* | held 0/0 byte-id throughout | 0/0
|
||||
* ---- c4 (#93: deref-index pointee chase, #263-polarity) --------
|
||||
* g93_l2_local | `(*p)[2]` over *arr2 (arr2=arr= |
|
||||
* | [3]int) — cs emitted ONE spurious |
|
||||
* | MOVQ (AX),AX (pointee ARRAY skip |
|
||||
* | missed at 2 levels), SEGV 139; ww |
|
||||
* | was the runtime-correct side | 0/0
|
||||
* g93_def | def twin: `(*p)[2]` over &D, D a |
|
||||
* | 2-lvl alias def array (kb5_def93) | 0/0
|
||||
* g93_1lvl_ctl | 1-level pointee control — held 0/0 |
|
||||
* | byte-id throughout | 0/0
|
||||
*
|
||||
* K_RUN rows build+run BOTH drivers (cs exit==cswant, ww exit==wwwant)
|
||||
* and assert cstage/wwstage asm byte-id. K_RUN_NOID asserts both run
|
||||
* cells but waives byte-id — cite the blocking task/commit at the row.
|
||||
* K_CSERR_WWRUN is the dual-cell bound kind (the inverse of
|
||||
* 944_alias_accept_run's K_RUN_CS_WWERR): the cstage build must FAIL
|
||||
* with experr AND the wwstage build+run must exit wwwant — both cells
|
||||
* asserted so neither the cs loudness nor the ww behavior can drift
|
||||
* silently while the cited task is parked. NNN<950, self-contained
|
||||
* /tmp sources, no imports (944 precedent).
|
||||
* What survives here is the one IRREDUCIBLE K_COMPILES row: both stages
|
||||
* FRONTEND-compile (w6c / w6c_ww → .s, rc 0) but the asm diverges (the ww
|
||||
* deref-field READ carries the #24 field(SB) leak) so run + byte-id cells are
|
||||
* unavailable, and a full `ww build` can't link this self-contained `alloc()`
|
||||
* case (no rt malloc) — runww //ww:compile links and so cannot host it. The
|
||||
* pin is the ABSENCE of the pre-c2 cstage #73 fatal at the heap struct-lit
|
||||
* str-arm fill; the ww-side leak rides task #24. Compile-smoke only.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
@@ -126,407 +27,40 @@ runwait(const char *cmd)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* both w6c and w6c_ww must FRONTEND-compile (rc 0); no run, no byte-id (#24). */
|
||||
static int
|
||||
slurp_eq(const char *a, const char *b)
|
||||
run_row(const char *bin, const char *label, const char *src, int i)
|
||||
{
|
||||
FILE *fa = fopen(a, "rb");
|
||||
FILE *fb = fopen(b, "rb");
|
||||
if (!fa || !fb) { if (fa) fclose(fa); if (fb) fclose(fb); return -1; }
|
||||
int rc = 0;
|
||||
for (;;) {
|
||||
int ca = fgetc(fa), cb = fgetc(fb);
|
||||
if (ca != cb) { rc = -1; break; }
|
||||
if (ca == EOF) break;
|
||||
}
|
||||
fclose(fa); fclose(fb);
|
||||
return rc;
|
||||
}
|
||||
char dir[96], srcf[160], ss[160], rm[200], cmd[2048];
|
||||
snprintf(dir, sizeof dir, "/tmp/ab5_%d_%d", getpid(), i);
|
||||
mkdir(dir, 0755);
|
||||
snprintf(srcf, sizeof srcf, "%s/c.ww", dir);
|
||||
snprintf(ss, sizeof ss, "%s/o.s", dir);
|
||||
snprintf(rm, sizeof rm, "rm -rf %s", dir);
|
||||
|
||||
#define K_RUN 0 /* build+run BOTH, exits==wants, + byte-id */
|
||||
#define K_BUILDERR 1 /* build FAILS with experr on BOTH drivers */
|
||||
#define K_RUN_NOID 2 /* build+run BOTH, exits==wants, byte-id
|
||||
* SKIPPED — cite the blocking task */
|
||||
#define K_CSERR_WWRUN 3 /* dual-cell bound row: cstage build must
|
||||
* FAIL with experr; wwstage build+run,
|
||||
* exit==wwwant — cite the blocking task */
|
||||
#define K_COMPILES 4 /* w6c AND w6c_ww must COMPILE (no run, no
|
||||
* byte-id) — cite why the other cells are
|
||||
* unavailable at the row */
|
||||
|
||||
struct row { const char *label; const char *src;
|
||||
int cswant; int wwwant; int kind; const char *experr; };
|
||||
|
||||
/* errlog_has — a builderr cell must fail WITH its diagnostic; any other
|
||||
* failure (parse error, crash, hang-kill) is a vacuous reject (940
|
||||
* precedent). */
|
||||
static int
|
||||
errlog_has(const char *path, const char *needle)
|
||||
{
|
||||
FILE *f = fopen(path, "rb");
|
||||
if (!f) return 0;
|
||||
char buf[8192];
|
||||
size_t got = fread(buf, 1, sizeof buf - 1, f);
|
||||
FILE *f = fopen(srcf, "wb");
|
||||
if (!f) { runwait(rm); return -1; }
|
||||
fputs(src, f);
|
||||
fclose(f);
|
||||
buf[got] = '\0';
|
||||
return strstr(buf, needle) != NULL;
|
||||
|
||||
int ok = 1;
|
||||
snprintf(cmd, sizeof cmd, "%s/w6c -o %s %s 2>/dev/null", bin, ss, srcf);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "row[%s]: cstage frontend compile failed\n", label);
|
||||
ok = 0;
|
||||
}
|
||||
snprintf(cmd, sizeof cmd, "%s/w6c_ww -o %s %s 2>/dev/null", bin, ss, srcf);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "row[%s]: wwstage frontend compile failed\n", label);
|
||||
ok = 0;
|
||||
}
|
||||
runwait(rm);
|
||||
return ok ? 0 : 1;
|
||||
}
|
||||
|
||||
struct row { const char *label; const char *src; };
|
||||
|
||||
static const struct row rows[] = {
|
||||
/* ---- c1: helper + funnel internalization (the F2c-cs fuse) */
|
||||
{ "signed_ctl",
|
||||
"package main;\n"
|
||||
"type s0 = i8;\n"
|
||||
"type s1 = s0;\n"
|
||||
"type st = struct { f: s1, g: s1 };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let x: st;\n"
|
||||
" x.f = -5;\n"
|
||||
" x.g = 3;\n"
|
||||
" if (x.f >= 0) { return 1; };\n"
|
||||
" let w: i64 = x.f: i64;\n"
|
||||
" if (w != -5) { return 2; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
/* LIVE c1 graduation: tagged_arg_size single-peeled the 2-level
|
||||
* alias union param to 0 → wrong arg path (cs exit 1 SILENT, ww
|
||||
* correct). */
|
||||
{ "targ_2lvl",
|
||||
"package main;\n"
|
||||
"type u0 = (void | i64);\n"
|
||||
"type u = u0;\n"
|
||||
"fn h(v: u) i32 = {\n"
|
||||
" match (v) {\n"
|
||||
" case let n: i64 => { if (n != 42) { return 1; }; return 0; };\n"
|
||||
" case void => { return 2; };\n"
|
||||
" };\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let x: u = 42i64;\n"
|
||||
" return h(x);\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
/* LIVE c1 graduation: the >48B MEMORY-class twin
|
||||
* (tagged_memarg_size). LAST payload word checked. */
|
||||
{ "tmem_2lvl",
|
||||
"package main;\n"
|
||||
"type big = struct { a: i64, b: i64, c: i64, d: i64, e: i64, f: i64, g: i64 };\n"
|
||||
"type m0 = (void | big);\n"
|
||||
"type m = m0;\n"
|
||||
"fn h(v: m) i32 = {\n"
|
||||
" match (v) {\n"
|
||||
" case let s: big => { if (s.g != 77) { return 1; }; return 0; };\n"
|
||||
" case void => { return 2; };\n"
|
||||
" };\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let s: big;\n"
|
||||
" s.a = 11; s.b = 22; s.c = 33; s.d = 44; s.e = 55; s.f = 66; s.g = 77;\n"
|
||||
" let x: m = s;\n"
|
||||
" return h(x);\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
{ "wpush_2lvl",
|
||||
"package main;\n"
|
||||
"type u0 = (void | i64);\n"
|
||||
"type u = u0;\n"
|
||||
"fn h(v: u) i32 = {\n"
|
||||
" match (v) {\n"
|
||||
" case let n: i64 => { if (n != 42) { return 1; }; return 0; };\n"
|
||||
" case void => { return 2; };\n"
|
||||
" };\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" return h(42i64);\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
{ "wstore_2lvl",
|
||||
"package main;\n"
|
||||
"type u0 = (void | i64);\n"
|
||||
"type u = u0;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: u = 42i64;\n"
|
||||
" match (v) {\n"
|
||||
" case let n: i64 => { if (n != 42) { return 1; }; };\n"
|
||||
" case void => { return 2; };\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
{ "wstore_1lvl",
|
||||
"package main;\n"
|
||||
"type u = (void | i64);\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: u = 42i64;\n"
|
||||
" match (v) {\n"
|
||||
" case let n: i64 => { if (n != 42) { return 1; }; };\n"
|
||||
" case void => { return 2; };\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
/* C1-CORR-2 → GRADUATED at B6-c1: the ident-lhs N_ASSIGN tagged
|
||||
* store gate (:6359) was the cgexpr INLINE peel B5 could not
|
||||
* reach; the B6-c1 chase closed it (pins-follow-the-layer, ken
|
||||
* B6 oracle C1 seed). */
|
||||
{ "wstore_a_2lvl",
|
||||
"package main;\n"
|
||||
"type u0 = (void | i64);\n"
|
||||
"type u = u0;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: u = void;\n"
|
||||
" v = 42i64;\n"
|
||||
" match (v) {\n"
|
||||
" case let n: i64 => { if (n != 42) { return 1; }; };\n"
|
||||
" case void => { return 2; };\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL }, /* graduated: B6-c1 */
|
||||
/* C1-CORR-1 → GRADUATED at c3: the residual divergence was
|
||||
* exactly three paired return-position tag syntheses — the
|
||||
* cgreturn return-route family; the c3 rt chase closed it
|
||||
* (pins-follow-the-layer, ken c1-boundary addendum). */
|
||||
{ "succ_2lvl",
|
||||
"package main;\n"
|
||||
"type e0 = !i64;\n"
|
||||
"type r0 = (i64 | e0);\n"
|
||||
"type r = r0;\n"
|
||||
"fn w(bad: bool) r = {\n"
|
||||
" if (bad) { return 7: e0; };\n"
|
||||
" return 42;\n"
|
||||
"};\n"
|
||||
"fn outer() r = {\n"
|
||||
" let v = w(false)?;\n"
|
||||
" return v + 1;\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" match (outer()) {\n"
|
||||
" case let n: i64 => { if (n != 43) { return 1; }; };\n"
|
||||
" case e0 => { return 2; };\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL }, /* graduated: #89 (B5-c3) */
|
||||
{ "null_2lvl",
|
||||
"package main;\n"
|
||||
"type np0 = (*i64 | void);\n"
|
||||
"type np = np0;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let n: i64 = 31;\n"
|
||||
" let p: np = &n;\n"
|
||||
" match (p) {\n"
|
||||
" case let q: *i64 => { if (*q != 31) { return 1; }; };\n"
|
||||
" case void => { return 2; };\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
{ "f32p_2lvl",
|
||||
"package main;\n"
|
||||
"type in0 = struct { a: f64 };\n"
|
||||
"type in1 = in0;\n"
|
||||
"type pt = struct { x: in1, y: f64 };\n"
|
||||
"fn g(p: pt) f64 = { return p.x.a + p.y; };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let p: pt;\n"
|
||||
" p.x.a = 2.5;\n"
|
||||
" p.y = 1.5;\n"
|
||||
" if (g(p) != 4.0) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
/* fill loudness control: named-struct array elem louds on BOTH
|
||||
* stages with twin texts — the experr substring is shared. */
|
||||
{ "fill0_ctl",
|
||||
"package main;\n"
|
||||
"type el0 = struct { a: i64 };\n"
|
||||
"type S = struct { arr: [2]el0, n: i64 };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let s = S { arr = [el0 { a = 5 }, el0 { a = 6 }], n = 3 };\n"
|
||||
" if (s.arr[0].a + s.arr[1].a + s.n != 14) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_BUILDERR,
|
||||
"has a str/slice/struct/tagged element" },
|
||||
/* #100 GRADUATION (closes the B5 re-rule R4 designed divergence):
|
||||
* pre-B5 this was both-wrong-IDENTICAL-silent (gate-blind #263
|
||||
* class — both stages accepted and ran exit 1 byte-id); B5-c1's
|
||||
* cs-only :3195 chase made it cs-loud/ww-silent-wrong for one
|
||||
* train. The ww twin gate now keys off the chased stamped tinfo
|
||||
* (cgenutil.ww, task #100) — LOUD-HOLD pair, twin texts share
|
||||
* the experr tail (fill0-class). */
|
||||
{ "fill2_loud",
|
||||
"package main;\n"
|
||||
"type el0 = struct { a: i64 };\n"
|
||||
"type el = el0;\n"
|
||||
"type S = struct { arr: [2]el, n: i64 };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let s = S { arr = [el0 { a = 5 }, el0 { a = 6 }], n = 3 };\n"
|
||||
" if (s.arr[0].a + s.arr[1].a + s.n != 14) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_BUILDERR,
|
||||
"has a str/slice/struct/tagged element" },
|
||||
/* #99 GRADUATION: both halves landed — the cstage type.c
|
||||
* type_chase_named tuple-arm (init/fn-arg untyped->alias coercion
|
||||
* reject->accept) AND the wwstage cgendecl.ww tuple-PARAM spill
|
||||
* chase (alias param fell to the scalar path, dropped SI, t.1
|
||||
* garbage). All four rows now build+run 0 on BOTH stages and the
|
||||
* .s is byte-identical (full 0/0 byte-id, the designed path). */
|
||||
{ "tuparg_bound99",
|
||||
"package main;\n"
|
||||
"type tp0 = (i64, i64);\n"
|
||||
"type tp = tp0;\n"
|
||||
"fn f(t: tp) i64 = { return t.0 + t.1; };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let t: tp = (4, 9);\n"
|
||||
" if (f(t) != 13) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
{ "tuparg1_bound99", /* 1-LEVEL identical — not alias-depth */
|
||||
"package main;\n"
|
||||
"type tp = (i64, i64);\n"
|
||||
"fn f(t: tp) i64 = { return t.0 + t.1; };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let t: tp = (4, 9);\n"
|
||||
" if (f(t) != 13) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
/* cast spelling — was the LIVE-cs / wrong-ww K_RUN_NOID pin; the
|
||||
* wwstage spill chase reds the old ww-1 cell and graduates it to
|
||||
* full 0/0 byte-id alongside its siblings. */
|
||||
{ "tuparg_cast_bound99",
|
||||
"package main;\n"
|
||||
"type tp0 = (i64, i64);\n"
|
||||
"type tp = tp0;\n"
|
||||
"fn f(t: tp) i64 = { return t.0 + t.1; };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let t: tp = (4, 9): tp;\n"
|
||||
" if (f(t) != 13) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
/* alias-tuple module-global — the cstage chase accepts the global
|
||||
* init and ww already read it correctly; now both 0/0 byte-id. */
|
||||
{ "tupglobal_bound99",
|
||||
"package main;\n"
|
||||
"type tp0 = (i64, i64);\n"
|
||||
"type tp = tp0;\n"
|
||||
"let G: tp = (4, 9);\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" if (G.0 + G.1 != 13) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
/* ---- c2: #73 graduation — the F1 tripwire's containment
|
||||
* replaced by the designed chase (close-by-construction). Each
|
||||
* row was the loud "#73" fatal on cs at the c1 tip (ww ok/0);
|
||||
* post-c2 the gates read the chased field type and every
|
||||
* runnable arm lands 0/0 byte-id. Values exceed 255 / use the
|
||||
* LAST element so a word0 tail can't pass by prefix-luck;
|
||||
* noise() clobbers BX/CX on the read rows. */
|
||||
{ "g73_idxstore",
|
||||
"package main;\n"
|
||||
"type sl = []int;\n"
|
||||
"type sl2 = sl;\n"
|
||||
"type box = struct { s: sl2, n: int };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let a: [3]int = [700: int, 800: int, 900: int];\n"
|
||||
" let xs: [2]box;\n"
|
||||
" xs[0].s = a[0:3];\n"
|
||||
" if (xs[0].s.len != 3) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
{ "g73_strfield",
|
||||
"package main;\n"
|
||||
"type s1t = str;\n"
|
||||
"type s2t = s1t;\n"
|
||||
"type box = struct { s: s2t, n: int };\n"
|
||||
"fn noise(x: int) int = { return x * 7 + 3; };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let xs: [2]box;\n"
|
||||
" xs[1].s = \"hello\";\n"
|
||||
" xs[1].n = 4;\n"
|
||||
" let k = noise(9);\n"
|
||||
" if (k != 66) { return 9; };\n"
|
||||
" let w = xs[1].s;\n"
|
||||
" if (w.len != 5) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
{ "g73_tagfield",
|
||||
"package main;\n"
|
||||
"type tu0 = (void | i64);\n"
|
||||
"type tu = tu0;\n"
|
||||
"type box = struct { u: tu, n: int };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let xs: [2]box;\n"
|
||||
" xs[0].n = 5;\n"
|
||||
" xs[0].u = 42i64;\n"
|
||||
" if (xs[0].n != 5) { return 1; };\n"
|
||||
" match (xs[0].u) {\n"
|
||||
" case let v: i64 => { if (v != 42) { return 2; }; };\n"
|
||||
" case void => { return 3; };\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
/* store rides the (F1-chased) single-dot via-ptr route so the
|
||||
* indexed-elem READ gate fires in isolation. */
|
||||
{ "g73_idxread",
|
||||
"package main;\n"
|
||||
"type sl = []int;\n"
|
||||
"type sl2 = sl;\n"
|
||||
"type box = struct { s: sl2, n: int };\n"
|
||||
"fn noise(x: int) int = { return x * 7 + 3; };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let a: [3]int = [700: int, 800: int, 900: int];\n"
|
||||
" let xs: [2]box;\n"
|
||||
" let p = &xs[1];\n"
|
||||
" p.s = a[0:3];\n"
|
||||
" p.n = 4;\n"
|
||||
" let k = noise(9);\n"
|
||||
" if (k != 66) { return 9; };\n"
|
||||
" let w = xs[1].s;\n"
|
||||
" if (w.len != 3) { return 1; };\n"
|
||||
" if (w[2] != 900) { return 2; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
{ "g73_ptrread",
|
||||
"package main;\n"
|
||||
"type sl = []int;\n"
|
||||
"type sl2 = sl;\n"
|
||||
"type inner = struct { s: sl2, n: int };\n"
|
||||
"type outer = struct { pi: *inner };\n"
|
||||
"fn noise(x: int) int = { return x * 7 + 3; };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let a: [3]int = [700: int, 800: int, 900: int];\n"
|
||||
" let i: inner;\n"
|
||||
" i.s = a[0:3];\n"
|
||||
" i.n = 1;\n"
|
||||
" let v: outer;\n"
|
||||
" v.pi = &i;\n"
|
||||
" let k = noise(9);\n"
|
||||
" if (k != 66) { return 9; };\n"
|
||||
" let w = v.pi.s;\n"
|
||||
" if (w.len != 3) { return 1; };\n"
|
||||
" if (w[2] != 900) { return 2; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
{ "g73_tupread",
|
||||
"package main;\n"
|
||||
"type sl = []int;\n"
|
||||
"type sl2 = sl;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let a: [3]int = [700: int, 800: int, 900: int];\n"
|
||||
" let t: (sl2, int) = (a[0:3], 5);\n"
|
||||
" let s = t.0;\n"
|
||||
" if (s.len != 3) { return 1; };\n"
|
||||
" if (t.1 != 5) { return 2; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
{ "g73_static_struct",
|
||||
"package main;\n"
|
||||
"type in0 = struct { a: i64, b: i64 };\n"
|
||||
"type in1 = in0;\n"
|
||||
"type box = struct { i: in1, n: i64 };\n"
|
||||
"let g: box = box { i = in0 { a = 4, b = 9 }, n = 5 };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" if (g.n != 5) { return 1; };\n"
|
||||
" if (g.i.b != 9) { return 2; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
/* COMPILE-only pin: bare /tmp programs never link malloc (both
|
||||
* stages, pre-existing infra) and the ww deref-field READ
|
||||
* carries the #24-kin field(SB) leak — run + byte-id cells are
|
||||
* unavailable. The chased FILL bytes were verified byte-id by
|
||||
* hand against the plain control (/tmp/b5/work). Pre-c2 the cs
|
||||
* cell was the "#73" fatal — this row pins its absence. */
|
||||
{ "g73_heapfill",
|
||||
"package main;\n"
|
||||
"type s1t = str;\n"
|
||||
@@ -537,223 +71,9 @@ static const struct row rows[] = {
|
||||
" if (p.n != 5) { return 1; };\n"
|
||||
" if (p.s.len != 5) { return 2; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_COMPILES, NULL },
|
||||
/* str-field static emit: the #73 fatal gave way to the
|
||||
* pre-existing #129 A.2 foldability loud — both-loud twin texts
|
||||
* now (the fill0 class), pinned so neither side regresses to a
|
||||
* silent emit. */
|
||||
{ "g73_static_str",
|
||||
"package main;\n"
|
||||
"type s1t = str;\n"
|
||||
"type s2t = s1t;\n"
|
||||
"type box = struct { s: s2t, n: int };\n"
|
||||
"let g: box = box { s = \"hello\", n = 5: int };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" if (g.n != 5) { return 1; };\n"
|
||||
" if (g.s.len != 5) { return 2; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_BUILDERR,
|
||||
"#129 A.2 scope" },
|
||||
/* ---- c3: #89 — the cgreturn rt/vu single peels left a 2-level
|
||||
* alias RETURN TYPE un-tagged (no tag synthesis at all, the succ
|
||||
* shape) and an alias-struct SOURCE un-structed (the scalar arm
|
||||
* shuffled word0 into DX and ZEROED the rest — s.b/e.aux
|
||||
* dropped, cs silent exit 1, ww runtime-correct since B2-c2). */
|
||||
{ "g89_ret_widen",
|
||||
"package main;\n"
|
||||
"type base = struct { a: size, b: size };\n"
|
||||
"type ali = base;\n"
|
||||
"fn mk() (void | ali) = {\n"
|
||||
" let x: ali;\n"
|
||||
" x.a = 4; x.b = 9;\n"
|
||||
" return x;\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" match (mk()) {\n"
|
||||
" case let s: ali => { if (s.b != 9) { return 1; }; };\n"
|
||||
" case void => { return 2; };\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
{ "g89_ret_errunion",
|
||||
"package main;\n"
|
||||
"type failure = struct { code: i32, aux: size };\n"
|
||||
"type myerr = failure;\n"
|
||||
"fn work(bad: bool) (i32 | myerr) = {\n"
|
||||
" if (bad) {\n"
|
||||
" let e: myerr;\n"
|
||||
" e.code = 7; e.aux = 99;\n"
|
||||
" return e;\n"
|
||||
" };\n"
|
||||
" return 42;\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" match (work(true)) {\n"
|
||||
" case let e: myerr => { if (e.aux != 99) { return 1; }; };\n"
|
||||
" case i32 => { return 2; };\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
{ "g89_ret_named_ctl",
|
||||
"package main;\n"
|
||||
"type base = struct { a: size, b: size };\n"
|
||||
"fn make() (void | base) = {\n"
|
||||
" let x: base;\n"
|
||||
" x.a = 4; x.b = 9;\n"
|
||||
" return x;\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v = make();\n"
|
||||
" match (v) {\n"
|
||||
" case let s: base => { if (s.b != 9) { return 1; }; };\n"
|
||||
" case void => { return 2; };\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
/* ---- c4: #93 — the N_UN(STAR) pointee classify single-peeled,
|
||||
* so a 2-level alias ARRAY pointee missed the array skip (an
|
||||
* array value IS its address, #270-1a) and the scalar load
|
||||
* pulled a[0]'s VALUE as the index base — ONE spurious
|
||||
* MOVQ (AX),AX, SIGSEGV on cs. ww chases (the runtime-correct
|
||||
* reference, #263 polarity): cs converges on WW's asm. */
|
||||
{ "g93_l2_local",
|
||||
"package main;\n"
|
||||
"type arr = [3]int;\n"
|
||||
"type arr2 = arr;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let a: arr2 = [1000: int, 2000: int, 3000: int];\n"
|
||||
" let p: *arr2 = &a;\n"
|
||||
" if ((*p)[2] != 3000) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
{ "g93_def",
|
||||
"package main;\n"
|
||||
"type arr0 = [3]i64;\n"
|
||||
"type arr = arr0;\n"
|
||||
"def D: arr = [18i64, 29i64, 40i64];\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let p: *arr = &D;\n"
|
||||
" if ((*p)[2] != 40i64) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
{ "g93_1lvl_ctl",
|
||||
"package main;\n"
|
||||
"type arr = [3]int;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let a: arr = [1000: int, 2000: int, 3000: int];\n"
|
||||
" let p: *arr = &a;\n"
|
||||
" if ((*p)[2] != 3000) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL },
|
||||
"};\n" },
|
||||
};
|
||||
|
||||
static int
|
||||
run_driver(const char *driver, const struct row *r, int i, int expect_err,
|
||||
int want)
|
||||
{
|
||||
char tmpdir[96], src[160], outbin[160], errf[160], rmcmd[176], cmd[1024];
|
||||
snprintf(tmpdir, sizeof tmpdir, "/tmp/ab5_%d_d_%d", getpid(), i);
|
||||
mkdir(tmpdir, 0755);
|
||||
snprintf(src, sizeof src, "%s/ab5_%d_%d.ww", tmpdir, getpid(), i);
|
||||
snprintf(outbin, sizeof outbin, "%s/ab5_%d_%d", tmpdir, getpid(), i);
|
||||
snprintf(errf, sizeof errf, "%s/err", tmpdir);
|
||||
snprintf(rmcmd, sizeof rmcmd, "rm -rf %s", tmpdir);
|
||||
|
||||
FILE *f = fopen(src, "wb");
|
||||
if (!f) { runwait(rmcmd); return -1; }
|
||||
fputs(r->src, f);
|
||||
fclose(f);
|
||||
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"timeout 20 %s build -o %s %s >/dev/null 2>%s",
|
||||
driver, outbin, src, errf);
|
||||
int brc = runwait(cmd);
|
||||
if (expect_err) {
|
||||
int ok = (brc != 0)
|
||||
&& (r->experr == NULL || errlog_has(errf, r->experr));
|
||||
if (!ok)
|
||||
fprintf(stderr, "row[%s]: %s expected loud builderr "
|
||||
"\"%s\" (brc=%d)\n", r->label, driver,
|
||||
r->experr ? r->experr : "", brc);
|
||||
runwait(rmcmd);
|
||||
return ok ? 0 : 1;
|
||||
}
|
||||
if (brc != 0) {
|
||||
fprintf(stderr, "row[%s]: build via %s failed\n",
|
||||
r->label, driver);
|
||||
runwait(rmcmd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int got = runwait(outbin);
|
||||
|
||||
runwait(rmcmd);
|
||||
if (got != want) {
|
||||
fprintf(stderr, "row[%s]: %s exit %d, want %d\n",
|
||||
r->label, driver, got, want);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* asm_compiles — K_COMPILES cell: the named stage compiler must emit
|
||||
* asm without a fatal. */
|
||||
static int
|
||||
asm_compiles(const char *bin, const char *cc, const struct row *r, int i)
|
||||
{
|
||||
char src[96], outs[96], cmd[1024];
|
||||
snprintf(src, sizeof src, "/tmp/ab5_cmp_%d_%d.ww", getpid(), i);
|
||||
snprintf(outs, sizeof outs, "/tmp/ab5_cmp_%d_%d.s", getpid(), i);
|
||||
|
||||
FILE *f = fopen(src, "wb");
|
||||
if (!f) return -1;
|
||||
fputs(r->src, f);
|
||||
fclose(f);
|
||||
|
||||
snprintf(cmd, sizeof cmd, "%s/%s -o %s %s 2>/dev/null",
|
||||
bin, cc, outs, src);
|
||||
int rc = runwait(cmd);
|
||||
if (rc != 0)
|
||||
fprintf(stderr, "row[%s]: %s failed to compile\n",
|
||||
r->label, cc);
|
||||
unlink(src); unlink(outs);
|
||||
return rc != 0;
|
||||
}
|
||||
|
||||
static int
|
||||
asm_byte_identical(const char *bin, const struct row *r, int i)
|
||||
{
|
||||
char src[96], cs[96], ws[96], cmd[1024];
|
||||
snprintf(src, sizeof src, "/tmp/ab5_asm_%d_%d.ww", getpid(), i);
|
||||
snprintf(cs, sizeof cs, "/tmp/ab5_asm_%d_%d_c.s", getpid(), i);
|
||||
snprintf(ws, sizeof ws, "/tmp/ab5_asm_%d_%d_w.s", getpid(), i);
|
||||
|
||||
FILE *f = fopen(src, "wb");
|
||||
if (!f) return -1;
|
||||
fputs(r->src, f);
|
||||
fclose(f);
|
||||
|
||||
snprintf(cmd, sizeof cmd, "%s/w6c -o %s %s 2>/dev/null", bin, cs, src);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "row[%s]: w6c errored\n", r->label);
|
||||
unlink(src);
|
||||
return -1;
|
||||
}
|
||||
snprintf(cmd, sizeof cmd, "%s/w6c_ww -o %s %s 2>/dev/null",
|
||||
bin, ws, src);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "row[%s]: w6c_ww errored\n", r->label);
|
||||
unlink(src); unlink(cs);
|
||||
return -1;
|
||||
}
|
||||
int rc = slurp_eq(cs, ws);
|
||||
if (rc != 0)
|
||||
fprintf(stderr, "row[%s]: cstage vs wwstage asm differs\n",
|
||||
r->label);
|
||||
unlink(src); unlink(cs); unlink(ws);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
@@ -767,50 +87,15 @@ main(void)
|
||||
bin = absbin;
|
||||
}
|
||||
|
||||
char cdrv[2120], wdrv[2120];
|
||||
snprintf(cdrv, sizeof cdrv, "%s/ww", bin);
|
||||
snprintf(wdrv, sizeof wdrv, "%s/ww_ww", bin);
|
||||
|
||||
int n = (int)(sizeof rows / sizeof rows[0]);
|
||||
int total = 0, fail = 0;
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
total++;
|
||||
if (rows[i].kind == K_COMPILES) {
|
||||
if (asm_compiles(bin, "w6c", &rows[i], i) != 0)
|
||||
fail++;
|
||||
continue;
|
||||
}
|
||||
int cs_err = rows[i].kind == K_BUILDERR
|
||||
|| rows[i].kind == K_CSERR_WWRUN;
|
||||
if (run_driver(cdrv, &rows[i], i, cs_err,
|
||||
rows[i].cswant) != 0) fail++;
|
||||
}
|
||||
if (access(wdrv, X_OK) == 0) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
total++;
|
||||
if (rows[i].kind == K_COMPILES) {
|
||||
if (asm_compiles(bin, "w6c_ww",
|
||||
&rows[i], i) != 0) fail++;
|
||||
continue;
|
||||
}
|
||||
int ww_err = rows[i].kind == K_BUILDERR;
|
||||
if (run_driver(wdrv, &rows[i], i, ww_err,
|
||||
rows[i].wwwant) != 0) fail++;
|
||||
}
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (rows[i].kind != K_RUN)
|
||||
continue;
|
||||
total++;
|
||||
if (asm_byte_identical(bin, &rows[i], i) != 0) fail++;
|
||||
}
|
||||
}
|
||||
int fail = 0;
|
||||
for (int i = 0; i < n; i++)
|
||||
if (run_row(bin, rows[i].label, rows[i].src, i) != 0) fail++;
|
||||
|
||||
if (fail) {
|
||||
fprintf(stderr, "alias_cgen_b5: %d/%d checks failed\n",
|
||||
fail, total);
|
||||
fprintf(stderr, "alias_cgen_b5 (slim): %d/%d rows failed\n", fail, n);
|
||||
return 1;
|
||||
}
|
||||
printf("alias_cgen_b5: %d/%d ok\n", total, total);
|
||||
printf("alias_cgen_b5 (slim): %d/%d ok\n", n, n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user