OSC-2: the second compiler slice (design, normative)
OSC-2 slice; not a general Omega compiler; no self-hosting.
Status note 2026-10-01: OSC-2 items 1 to 4 are merged (omega#148 0abdb08 contracts, #149 845dce4 structs, #150 c773622 arenas, #151 7e713e3 writer range checks). Status is IMPLEMENTED / NOT QUALIFIED (host receipts only). Shortfalls against the ADR and audit III.7 are listed in the addendum of docs/osc/OSC-1-SELF-HOST-STATEMENT.md.
OSC-2 extends the OSC-1 slice (docs/osc/OSC-1-DESIGN.md) item by item. Everything
OSC-1 states stays in force unless a section below changes it. Each item ships with
its own golden programs, named negatives, fuzz coverage and a receipt
(make osc2-receipt ITEM=<name>, schema omega.osc2.compiler.receipt.v1, written to
evidence/OSC-2/receipts/osc2-<item>-<sha256>.json).
1. Contracts
1.1 Subset statement
OSC-1 parsed requires / ensures and recorded them as text only. OSC-2 item 1 makes
them enforced contracts:
- a clause is a pure
boolexpression of the OSC-1 expression grammar; - a clause that constant folding decides false is refused at compile time;
- every other clause is checked at run time, by a check lowered into the IR, so native code and the reference interpreter run the same check and report the same trap;
- there is no symbolic proof: anything constant folding cannot decide is left to the run-time check.
Functions without clauses compile to byte-identical IR and machine code compared with
OSC-1 (checked for every program in tests/compiler/progs/ that existed before OSC-2).
1.2 Grammar change
fn_decl = "fn" ident "(" [ params ] ")" [ "->" type ]
[ "requires" expr ] [ "ensures" expr ] block ;
clause = { token } from OSC-1 section 2 is replaced by expr. The clause must be
followed by ensures (after requires) or by the function's {. An empty clause is a
SYNTAX error. The source text is still recorded in OscFunc.requires_text /
ensures_text (it is part of the canonical IR encoding, unchanged from OSC-1), rebuilt
from the clause tokens with the OSC-1 spacing rule. Longer than 255 bytes is CAPACITY.
1.3 Names a clause may use
| clause | may use |
|---|---|
requires | parameters; element reads p[i] through any array parameter (own, &, &mut) |
ensures | parameters; result (the return value) in a non-void function; element reads only through shared & parameters |
- Contracts are pure. A call inside a clause is refused: CONTRACT_INVALID, transition
call in contract, object = callee. (This rules out side effects and keeps the evaluation order of a contract trivially the same in both engines.) resultinrequires: CONTRACT_INVALID, objectresult, transitionresult in requires.resultin theensuresof a void function: CONTRACT_INVALID, objectresult, transitionresult in void function.- An element read in
ensuresthrough anownor&mutparameter: CONTRACT_INVALID, object = the array, transitionarray read in ensures. (The body may have changed or moved that array; a shared borrow cannot change while the call runs.) resultis a name only inside anensuresclause. A parameter namedresultin a function that has anensuresclause is REDEFINED_NAME (transitionparameter named result with ensures).- Any other name is UNDEFINED_NAME (locals of the body are not in scope).
- A clause that is not
boolis TYPE_MISMATCH with objectrequires/ensures. All other OSC-1 expression rules (AMBIGUOUS_WIDTH, static OVERFLOW folding, ...) apply unchanged. - Parameters are immutable, so
ensuressees the values the function was called with. - An element read in
requiresis traced as a read at function entry (ownership trace).
1.4 Static enforcement (constant folding only)
The checker evaluates clauses with the same arithmetic as the interpreter (wrap for
unsigned, checked for signed). A sub-expression that would trap, an element read and a
call are "unknown". && and || are decided left to right, so false && x is false and
true || x is true. Three refusals, all CONTRACT_VIOLATION with origin_line = the line
of the clause and other = the clause text:
| transition | line | object | when |
|---|---|---|---|
requires is constant false / ensures is constant false | clause | function | the clause folds to false on its own |
requires false at call | call | callee | the arguments of a call fold to constants that make the callee's requires fold to false |
ensures false at return | return | function | a return with a constant value makes ensures fold to false |
1.5 Run-time checks
requiresis checked once, on the callee side, at function entry, before the first statement. False: TRAP REQUIRES (code 9).ensuresis checked at everyreturn(and at the fall-off end of a void function) after the return value is computed and before the releases of the scopes being left. False: TRAP ENSURES (code 10).- A contract trap ends the run like every OSC-1 trap: no destructors run; owners that were live stay live in the pool log.
- A clause obeys the checked semantics: signed overflow inside a clause traps OVERFLOW, a dynamic out-of-range element index traps BOUNDS, and so on, before the contract's own verdict.
- Lowering:
v = clause; CBR v ok bad; bad: TRAP code; BR ok; ok: .... The interpreter executes the same instructions, so both engines report the identical trap.
Trap codes 9 and 10 are appended to the OSC-1 list; existing codes are never renumbered.
OSC_TRAP_MAX = 10. The back end emits a trap stub only for codes a unit uses, so units
without contracts produce the same bytes as OSC-1.
1.6 Elision
- A clause that folds to true on its own gets no run-time check at all.
- A
returnwhose constant value makesensuresfold to true gets no check at that return.
1.7 Evidence
- Golden programs:
tests/compiler/progs/contracts_basic.osc,contracts_requires.osc,contracts_ensures.osc(passing calls, TRAP REQUIRES, TRAP ENSURES, OVERFLOW and BOUNDS inside a clause, voidensures, elided clauses), each with hand-computedexpect-runlines checked in both engines. - Negatives in
tests/compiler/neg/:cv_requires_false_at_call,cv_constant_false_clause,cv_ensures_static,cv_ensures_constant_false,ci_result_in_requires,ci_result_in_void,ci_call_in_contract,ci_array_read_ensures,tm_non_bool_clause,undefined_in_clause. - Contract fuzz (
test_osc_compiler): generated units whose functions carry randomrequires/ensures; each unit compiles or is refused with CONTRACT_VIOLATION only; compiled units run native vs interpreter with 0 mismatches and must hit both TRAP REQUIRES and TRAP ENSURES.
2. Structs
2.1 Subset statement
OSC-2 item 2 adds fixed-layout structs to the OSC-1 subset. A struct is a named group of
fields that lives in one pool allocation and is handled exactly like an owned array: it is
created by its owner, moved, borrowed with & / &mut, and released at scope end. A struct
is never a value: there is no struct copy, compare, or return. OSC-2 slice; not a general
Omega compiler; no self-hosting.
2.2 Grammar
unit := (struct | fn)*
struct := "struct" NAME "{" field ("," field)* "}"
field := NAME ":" ftype
ftype := scalar | "[" scalar ";" INT "]" scalar = integer type or bool
type := ... | "own" NAME | "&" NAME | "&mut" NAME (NAME = a declared struct)
let := ... | "let" NAME ":" "own" NAME "=" NAME "{" init ("," init)* "}" ";"
init := NAME ":" expr (scalar field)
| NAME ":" "[" expr ";" INT "]" (array field, INT = its length)
expr := ... | NAME "." NAME | NAME "." NAME "[" expr "]"
stmt := ... | NAME "." NAME "=" expr ";" | NAME "." NAME "[" expr "]" "=" expr ";"
structdeclarations sit at unit level, before any function that names them.structis now a keyword and.a token.- A struct literal appears only as the initialiser of
let x: own S = S { ... }. Fields may be listed in any order. The values are evaluated in source order. - A local, parameter, or binding of struct type is always
own S,&S, or&mut S.
2.3 Layout (fixed, part of the IR digest)
- Every field takes whole 8-byte cells, in declaration order. A scalar takes 1 cell and
[T; N]takes N cells. Field offsets are prefix sums, with no padding and no reordering. Example:struct L { a: u8, b: [i16; 3], c: bool, d: [u64; 2], e: i64 }has offsets 0 1 4 5 7 and uses 8 cells.test_osc_compilerasserts this. - A struct owner is one pool allocation of
ncellscells. This uses the samealloc/releaseevents and the same 64-slot pool as arrays. - IR:
OscUnit.structs[]records each struct's name, fields (name, scalar type, array length, offset) and cell count.osc_ir_validatere-checks the prefix sums. A struct reference type isOSC_T_REFwithsid= struct index + 1. Two new instructions are added,FLOAD dst, a, idx|-1, fieldandFSTORE a, idx|-1, value, field. FSTORE needs an own or&mutreference. - Encoding: a unit with no structs encodes exactly as in OSC-1 (version byte 1), so every existing program keeps byte-identical IR and machine code. A unit with structs uses version byte 2 and adds the struct table (names, field types, lengths, offsets, cell counts), so the digest binds the layout. Reordering two fields changes the digest.
2.4 Semantics
- Creation.
let s: own S = S { f: e, ... }allocates one object and stores every field. An array field[e; N]fills all N elements withe. - Field access.
s.freads ands.f = vwrites. For an array field,s.f[i]reads ands.f[i] = vwrites, with the same bounds checks as arrays: a constant index outside 0..N-1 is STATIC_OUT_OF_BOUNDS, and a dynamic one traps with TRAP BOUNDS (3) in both the interpreter and native code. A field is used at its declared type. Arithmetic follows the OSC-1 rules (wrap for unsigned types, overflow trap for signed types). - Ownership (OSC-0B, as for arrays).
let t: own S = s;and passingsto anown Sparameter are moves. Any later use ofsis USE_AFTER_MOVE.&sand&mut sfollow the same lexical borrow rules as arrays: no&muttogether with any other live borrow (MUTABLE_ALIAS), no write through&(READ_ONLY_BORROW), and no borrow outliving its owner (BORROW_OUTLIVES_OWNER).- Struct borrows produce the same model trace events, which are replayed against the OSC-0B model.
- Destruction. Owners are released at scope end in reverse declaration order, structs
and arrays alike. A moved-from owner is not released again.
tests/compiler/progs/structs_dtor.oscasserts the event sequence alloc 1 2 3, release 3 2, alloc 4, release 4 1 in both engines. - Functions. A struct passes as
own S,&S, or&mut S. Returning a struct (any-> S,-> own S,-> &S) is refused as UNSUPPORTED, transitionstruct return type. BareSas a parameter or local type is UNSUPPORTED (struct by value). - Contracts.
requiresmay read fields (and array-field elements) through any struct parameter.ensuresmay read them only through a shared&Sparameter; otherwise the clause is CONTRACT_INVALID (struct field read in ensures). This is the same rule as array element reads (section 1.3): anownor&mutparameter may have changed by the time of the return.
2.5 Diagnostics
New kinds (appended; existing kinds unchanged):
| Kind | Transition | Cause |
|---|---|---|
| UNKNOWN_FIELD | access unknown field / initialise unknown field | s.z or S { z: .. } with no field z |
| DUPLICATE_FIELD | field initialised twice / field declared twice | a field given twice in a literal or declaration |
| MISSING_FIELD | field not initialised | a literal omits a field |
| UNDEFINED_TYPE | undefined struct type | a type name that is not a declared struct |
| RECURSIVE_STRUCT | struct field of its own type | a field whose type names the struct itself |
Existing kinds used by structs:
- TYPE_MISMATCH:
- a field given a value of the wrong type
- a literal of another struct
- an array field set without
[e; N], or with the wrong N - indexing a struct, or
.fon an array - indexing a scalar field, or using an array field without an index
- a struct used as a scalar
- a struct passed or moved where another struct type is needed
- UNSUPPORTED:
empty structstruct-typed fieldowner or borrow fieldstruct by valuestruct return typealloc of a struct
- CAPACITY:
struct capacity,field capacity,struct size. - REDEFINED_NAME:
struct declared twice. - STATIC_OUT_OF_BOUNDS on
s.f[k]. - CONTRACT_INVALID:
struct field read in ensures.
2.6 Limits
- At most 16 structs per unit.
- Each struct has 1 to 16 fields and at most 64 cells.
- An array field is
[T; N]of any integer type or bool, N >= 1. - Fields cannot be structs, owners, or borrows.
- Struct literals appear only in
let owninitialisers.
2.7 Evidence
- Golden programs:
structs_fields.osc: layout use, field read/write, array fields, TRAP BOUNDS.structs_owner.osc: moves, own /&/&mutparameters, borrow bindings.structs_contracts.osc: TRAP REQUIRES and TRAP ENSURES on fields.structs_dtor.osc: destruction order.
- Negatives in
tests/compiler/neg/st_*.osc(36), each asserting kind, object, line, and transition. They include:- unknown field
- duplicate field init
- missing field init
- field type mismatch
- write through shared borrow
- use after move
- mutable alias
- borrow outlives owner
- recursive struct
- undefined struct type
test_osc_compileradds:- the layout assertion, with the digest binding the layout and struct-free units still using version 1;
- the destruction-order event check;
- struct fuzz: generated units with random field types, literals, field writes,
moves, and
&/&mut/ own calls withrequireson fields. Every unit compiles, and native and interpreter outcomes are identical (struct fuzz: ... mismatches=0) in the plain and ASan/UBSan runs. The fuzz must hit TRAP BOUNDS and TRAP REQUIRES.
3. Arenas
3.1 Subset statement
OSC-2 item 3 wires the OSC-0B region rules (model events REGION_OPEN, ALLOC with a region, REGION_DESTROY) into the compiler. An arena is a bounded block of cells. Objects allocated in it are never released one by one: the whole arena is destroyed when its block ends. OSC-2 slice; not a general Omega compiler; no self-hosting.
3.2 Grammar
stmt := ... | "arena" NAME "bound" INT block (INT = K, 1..64 cells)
let := ... | "let" NAME ":" "own" "[" scalar ";" INT "]" "in" NAME "=" "alloc" "(" expr ")" ";"
| "let" NAME ":" "own" NAME "in" NAME "=" NAME "{" init ("," init)* "}" ";"
arenais now a keyword.in(already a keyword forfor) also names the arena of an allocation.- The arena name is visible only inside its block, so allocating from an arena outside its block is impossible: the name is undefined there (UNDEFINED_NAME).
- An arena name is not a value. Any other use of it is TYPE_MISMATCH (`arena used as a value`). It cannot be passed to a function or returned.
3.3 Semantics
- Capacity. K counts 8-byte cells.
[T; N]uses N cells and a struct uses its cell count (section 2.3). An allocation is definite when it is in the arena's own straight-line code: same loop depth and same branch depth as thearenastatement (nested arena blocks count as straight-line code). The checker adds up definite allocations; going over K is refused (ARENA_CAPACITY). Every other allocation (inside awhile/forbody or anif/elsebranch) is checked at run time: past K the run traps with TRAP ARENA_FULL (11) in both the interpreter and native code. - Runtime. An arena takes one slot of the 64-slot pool (the lowest free one, like any allocation; no free slot is TRAP OOM) and bump-allocates its objects inside that slot's cells. Cells are filled with the initial value at allocation and zeroed at destroy.
- Destruction order (deterministic). At the end of an arena block (normal end, or a
returnfrom inside it):- the unique owners declared inside the block are released, in reverse declaration order (OSC-1 rule);
- then the arena is destroyed: one REGION_DESTROY frees all its objects at once.
Nested arenas: the inner block ends first, so the inner arena is destroyed before the
outer one. A
returndestroys every enclosing arena, innermost first, interleaved with the releases of each scope.tests/compiler/progs/arena_dtor.oscasserts the exact event sequence (alloc 1, open 2, arena alloc 3, open 4, arena alloc 5, alloc 6, release 6, destroy 4, alloc 7, release 7, destroy 2, release 1) in both engines.
- Borrows.
&xand&mut xof an arena object follow the OSC-1 lexical rules (MUTABLE_ALIAS, READ_ONLY_BORROW,&/&mutparameters). A borrow of an arena object may not outlive the arena: assigning it to a borrow binding declared outside the arena block, or returning it, is ARENA_ESCAPE. The model rejects the same situation (a REGION_DESTROY while a borrow of one of its objects is live) asarena-escape. - Moves (slice restriction). Every move that involves an arena object is refused with
ARENA_MOVE:
let y: own .. = x;withxin an arena (move out of arena), passingxto anownparameter (move into own parameter), andlet x: own .. in r = y;(move into arena). The OSC-0B model allows a move inside a region (the new owner inherits the region); this slice is stricter than the model and refuses all of them. - Model trace. The checker trace gains REGION_OPEN (at
arena), ALLOC with the region id (forin r) and REGION_DESTROY (at block end), with per-function region ids 1..16. Arena objects get no RELEASE event. Golden and fuzz traces replay through the model with ACCEPT; an ARENA_ESCAPE refusal ends its trace in the refused REGION_DESTROY, which the model rejects witharena-escape(model-agreement test). - Runtime event log.
osc_rtlogs REGION_OPEN (slot, K, region serial), ARENA_ALLOC (slot, length, object serial) and REGION_DESTROY next to ALLOC / RELEASE. Interpreter and native code produce identical logs (checked on every differential run). Releasing an arena slot with RELEASE is a runtime invariant violation (TRAP RUNTIME, never seen for checked code). - IR. Three instructions are added.
AOPEN dst, Kputs a u64 arena handle indst.AALLOC dst, init, hallocatesdst(an own reference or struct) from handleh.ADESTROY hdestroys the arena. The validator enforces a handle discipline: a handle register is defined once, by AOPEN only, is never a parameter, and is used only as the handle operand of AALLOC / ADESTROY. Native code calls the runtime through three new OscRt entry points at offsets 24, 32 and 40 (arena_open,arena_alloc,arena_destroy). - Encoding. A unit with no arena instruction encodes exactly as before (version byte 1 without structs, 2 with structs), so every existing program keeps byte-identical IR and machine code (checked: all 31 earlier golden programs and all 82 earlier negatives give the same oscc output as origin/main). A unit with arena instructions uses version byte 3, always writes the struct table, and encodes the new instructions.
3.4 Diagnostics
New kinds (appended; existing kinds unchanged):
| Kind | Transition | Cause |
|---|---|---|
| ARENA_ESCAPE | outer borrow assigned a borrow of an arena object / borrow of an arena object returned / borrow live at arena end | a borrow of an arena object outlives the arena |
| ARENA_MOVE | move out of arena / move into own parameter / move into arena | any move of an arena object (slice restriction) |
| ARENA_CAPACITY | arena bound outside 1..64 / arena capacity exceeded | K not in 1..64; definite allocations over K |
borrow live at arena end is a defence in depth: with lexical borrows the two other
ARENA_ESCAPE checks catch every escape first, so no test reaches it.
Existing kinds used by arenas:
- UNDEFINED_NAME:
allocate in undefined arena(unknown name, or an arena used after its block). - TYPE_MISMATCH:
in a non-arena(in xwherexis not an arena), `arena used as a value`. - REDEFINED_NAME: an arena name that shadows a visible name (no shadowing, OSC-1 rule).
New trap: TRAP ARENA_FULL = 11 (OSC_TRAP_ARENA_FULL, now OSC_TRAP_MAX).
3.5 Limits
- K is 1..64 cells (one pool slot). An arena uses one of the 64 pool slots while open.
- The static model trace holds 16 arenas per function (the model's region capacity). A function with more still compiles, but its trace is marked overflow and is not replayed (same rule as the 64-object and 64-borrow limits).
- Objects are never moved into, out of, or between arenas.
- Arena objects cannot be released early; there is no per-object free.
- Arena names are not values: no arena parameters, returns, or arenas outliving their block.
3.6 Evidence
- Golden programs:
arena_basic.osc: basic allocation,returnfrom inside an arena, unique owners mixed with arena objects.arena_nested.osc: nested arenas, allocation into the outer arena from the inner block, sibling arenas reusing a slot.arena_structs.osc: struct literals in an arena.arena_borrows.osc:&/&mutborrows and parameters on arena objects.arena_full.osc: allocations in a loop and in a branch, TRAP ARENA_FULL.arena_dtor.osc: destruction order (event sequence above).
- Negatives in
tests/compiler/neg/ar_*.osc(14), each asserting kind, object, line, and transition: escape through an outer borrow, escape by return, move out, move into, move into an own parameter, static capacity, bound 0, bound 65, undefined arena,ina non-arena, arena shadowing, allocation after the block, arena object used after the block, arena used as a value. The two ARENA_ESCAPE negatives also pass the model-agreement check (ARENA_ESCAPEmaps to the model'sarena-escape). test_osc_backendadds the arena validator cases (bad bound, handle type, double definition, allocation or destroy from a non-handle, handle used as a value or redefined).test_osc_compileradds:- the arena destruction-order event check (
arena destruction order: ...); - arena fuzz: generated units with nested arenas of random bound, array and struct
allocations into any visible arena, unique owners, borrows passed to
&/&mutparameters, and allocations in loops and branches. Every unit compiles, native and interpreter outcomes are identical (arena fuzz: ... mismatches=0) in the plain and ASan/UBSan runs, and the fuzz must hit TRAP ARENA_FULL; - runtime model replay: the runtime event log of every native run in the test
(golden fuzz, expect-run lines, contract, struct and arena fuzz, destruction-order
tests) is replayed through the OSC-0B model. A run that returns replays fully; a run
that traps replays the prefix logged before the trap. Object and region ids are
windowed when a run exceeds 64 objects or 16 regions (a new window re-opens the open
regions and re-allocates the live objects). The line
runtime model replay: runs=.. events=.. accepted=.. rejected=0must reportrejected=0. **This checks the runs that were executed. It is not a proof that every program's runtime behaviour satisfies the model.**
- the arena destruction-order event check (
make osc2-receipt ITEM=arenasrecords the arena fuzz lines, the destruction order, the runtime model replay lines (plain and ASan) and the ARENA_FULL run count.
4. Legacy AArch64 writer
4.1 Statement
src/aarch64_encoder.c is the instruction writer used by the existing Omega code
(omega_program_realize, the matvec emitters, omega_self_host, omega_exec, the
polyglot encoder, rx_omega, the M5/M6/M9/M14 gates). Up to OSC-1 it trimmed fields
silently (rm & 0x1f, imm19 & 0x7FFFF, (uoff >> scale) & 0xFFF, simm9 & 0x1FF,
(shift / 16) & 3, ...), which OSC-0 III.6 says must be hardened (OSC-1-DESIGN.md
section 9 left it untouched). OSC-2 item 4 takes option A (fix, not retire):
- every emitter checks every field against its exact architectural range before it encodes anything;
- an in-range call produces the same word as before: the encoding formulas are unchanged and their masks are now no-ops;
- an out-of-range field is refused, never trimmed (4.3);
- the set of files that use the writer is frozen (4.4). New code uses the validating
encoder
src/compiler/osc_a64.c.
Option B (keep trimming for a caller that relies on it) was not needed: an audit of all
280 call sites found no caller that passes an out-of-range field. Every constant is in
range; computed values are either range-checked by the caller first
(src/polyglot/omx_encoder.c, its resolve() branch fix-ups), already cast to the
parameter type by the caller (omega_self_host.c instruction counts), or registers
X0..X17/XZR. The M6/M9/M14 gates and the host suites in 4.5 run through the strict writer
and pass unchanged.
4.2 Ranges (normative)
| Emitter | Field | Accepted |
|---|---|---|
| all | rd rn rm rt | 0..31 (31 is XZR or SP, as the instruction defines) |
all with sf | sf | C bool (0 or 1 by type) |
movz movk | imm16 | 0..65535 (uint16_t) |
movz movk | shift | 0, 16, 32, 48 when sf = 1; 0, 16 when sf = 0 |
b | imm26 (words) | -2^25 .. 2^25 - 1 |
b_cond | cond | 0..15 |
b_cond cbz cbnz | imm19 (words) | -2^18 .. 2^18 - 1 |
adr | imm21 (bytes) | -2^20 .. 2^20 - 1 |
ldr_uoff str_uoff | uoff (bytes) | multiple of 8 (sf = 1) or 4 (sf = 0), uoff / size <= 4095 |
ldrb_uoff strb_uoff | uoff (bytes) | 0..4095 |
ldr_post str_post ldr_x_post str_x_post | simm9 | -256..255 |
subs_imm | imm12 | 0..4095 |
ret has no fields. The "buffer full" result (-1, nothing written) is unchanged.
4.3 Refusal path
A refused call writes nothing and does not advance *pos. It prints exactly one line on
stderr,
A64_LEGACY_FIELD_OUT_OF_RANGE <emitter> <field>=<value>
(<emitter> is the C function name, e.g. aarch64_emit_cbz; <field> is the parameter
name; <value> is the received value in signed decimal), and then calls abort()
(SIGABRT). Abort is deliberate and deterministic: several existing callers ignore the
emitter's int result (for example the matvec emitters), and this item may not change
callers, so a soft error would silently drop an instruction and produce wrong code. A
refusal is a bug in the caller.
4.4 No new callers
tests/compiler/legacy_a64_allowlist.txt lists the 17 C files that include
aarch64_encoder.h or name an aarch64_emit_* function (14 callers, the writer itself
and its header, this item's test, and seed/check/a64check.c, a reference check that uses
the writer only as an oracle for the seed's hand-written words and makes no program with it).
tests/compiler/legacy_a64_callers.sh scans every
tracked and untracked (not ignored) *.c / *.h file and requires the set to equal the
list:
A64_LEGACY_NEW_CALLER <file>: a file not on the list uses the writer;A64_LEGACY_ALLOWLIST_STALE <file>: a listed file no longer uses it (drop the line; the list may only shrink).
--selftest first proves both refusals fire on a synthetic tree (a new includer, a new
direct caller, a stale line). It runs in make test-compiler. The CI compiler job
guard now also triggers on src/aarch64_* changes.
4.5 Evidence
tests/compiler/test_legacy_a64.c(inmake test-compiler, plain and ASan/UBSan):- differential: the pre-OSC-2 formulas are kept in the test as the oracle
(
old_*). For all 25 emitters, in-range fields give the oracle's word. The field space is covered exhaustively for the register-register forms,mov_reg,movz/movk(all registers, immediates and shifts),b_cond(all conditions and offsets),ldr/strunsigned offset,ldrb/strb, the post-index forms andsubs_imm;b,cbz,cbnzandadruse 400 000 seeded random samples each with every range edge (about 71 million words in all). Each word also decodes throughsrc/aarch64_decoder.cto the same operation and to every field that decoder reports (sf, registers,imm16/hw, condition, raw branch field). The decoder does not report load/store orsubsimmediates or the ADR offset, so the test checks theimm12field ofldr/strand the reassembled ADR offset from the word directly. Line:legacy a64 differential: emitters=25 mode=full words=.. decoded=.. mismatches=0. The ASan leg runsquick(strided samples, same edges). - refusal: 90 cases, every field of every emitter that has one, just outside its
range and at extremes (for example
rd=32,shift=17,shift=32withsf= 0,imm26=2^25,cond=16, misaligneduoff,simm9=-257). Each runs in a child process with output buffer and position in shared memory; the child must die by SIGABRT with exactly the line of 4.3 on stderr and must not touch buffer or position (core dumps disabled in the child). Line:legacy a64 refusal: cases=90 named_abort_and_no_write=90. - mutation check (done once, not in the suite): removing the
simm9check, or changing one bit of themul_regformula, makes the test fail.
- differential: the pre-OSC-2 formulas are kept in the test as the oracle
(
- M6/M9/M14 gate output (from
omegatool --runon) is byte-identical to the baseline taken before this item. - Host suites that link the writer were run on one core and pass (list and results in the item report); suites that need the GB10, the resident seat or the quiet flag were not run.
make osc2-receipt ITEM=encoderrecords the differential, ASan and refusal lines, the caller check line and, withPHYSICS_DIRset, the M6/M9/M14 gates.
4.6 Not covered
- Instructions are checked field by field; the writer still does not know whether a
register choice is legal for a particular form beyond 0..31 (for example it does not
refuse SP where an instruction reads XZR). Callers keep that responsibility; the OSC-1
encoder
osc_a64.cis the one that checks SP vs XZR. src/aarch64_decoder.cis unchanged: it still decodes only the subset above and keeps no load/store orsubsimmediate.- The allowlist check scans C files only; it does not stop a caller written in another language or one that declares the functions itself under another spelling.
- Refusal ends the process; there is no recoverable error API for the legacy writer.