Repository navigation
feat(t27b): memory primitives -- frame slots, loads/stores, rodata, bounds (Refs #5977) - #6007
Merged
Merged
Conversation
…ounds
The IR primitives that structs, arrays, slices and strings lower onto,
end to end through the interpreter, the JIT and the Mach-O object:
- Ty::Ptr; ExprKind::Slot / Data / Load{addr,off} / Offset{base,idx,
scale} / Bounds{idx,len,site}; Stmt::Store / Copy; Func::slots;
Program::data; TrapKind::Bounds = 16 (numbered high, so the scalar
lane can add kinds below it).
- eval (the oracle): a byte-addressed model with per-call slots, a gap
between objects and per-byte written flags. It faults on a read of
unwritten bytes, an access outside a live slot or blob, a store into
data, and a bool load of anything but 0/1. A fault is a lowering
defect and never agrees with the JIT.
- codegen:
- an aggregate area below x29, up to 16 KiB;
- x29-relative ldur/stur fast paths;
- uimm, unscaled and register load/store forms, with signed narrow
loads;
- ADRP + ADD for data;
- shifted add or madd for Offset;
- cmp + b.hs to a Bounds trap stub;
- Copy unrolled 8/4/2/1, or as a post-indexed loop past 64 bytes.
- JIT: data blobs appended to the image and patched in place.
- Mach-O: a __const section with PAGE21/PAGEOFF12 relocations against
local l_t27b_data.N symbols.
- a64: sized load/store, adr/adrp encoders and disassembly, with 32
new clang-verified encodings and an otool comparison.
Tests:
- The random differential generator covers every primitive: slots up
to 9000 bytes, data blobs, loads and stores of every scalar type at
constant, masked and bounds-checked indices, short and looped
copies, and pointer parameters into the caller's frame (the
hidden-pointer ABI). 0 mismatches over 2500 programs per overflow
mode.
- tests/macho.rs links an object with clang and runs it against the
interpreter.
- tests/memory.rs pins the interpreter's faults.
Corpus unchanged (47 pass): nothing lowers to these yet.
Refs #5977
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 4, 2026
Merged
This was referenced Oct 4, 2026
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #5992. The base is
claude/t27b-coverage, so this diff shows only this PR's commit. GitHub retargets it tomasteronce #5992 merges.Summary
This adds the memory primitives that t27b will lower structs, fixed arrays, slices and strings onto. Each one works end to end in the interpreter (the oracle), the JIT and the Mach-O object. No front-end construct lowers to them yet; that comes in the next PRs of #5977.
IR (one contiguous memory-lane block in
ir.rs):Ty::Ptr;Slot(k)andData(k)addresses;Load{addr, off}andStore{addr, off, value};Offset{base, idx, scale};Bounds{idx, len, site}, a checked index that traps;Copy{dst, src, size};Func::slotsandProgram::data;TrapKind::Bounds = 16, numbered high so the scalar lane can add kinds below it.Interpreter. Memory is modelled byte by byte:
Copycopies those flags too.The interpreter faults on each of these, and never treats them as a pass:
A fault is a lowering defect, and
--checkcounts it as a mismatch.Codegen (AArch64):
lsl #12form.ldur/stur. Other loads and stores use the uimm, unscaled or register form, with sign-extending narrow loads.adrp+add.Offsetuses a shiftedadd, ormaddwhen the scale is not a power of two.Boundsiscmp+b.hsto the trap stub.Copyis unrolled in 8/4/2/1-byte steps, or becomes a post-indexed loop past 64 bytes.JIT. Data blobs are appended to the image, and the
adrp/addpairs are patched in place.Mach-O. A
__TEXT,__constsection is added, withARM64_RELOC_PAGE21/PAGEOFF12relocation pairs against locall_t27b_data.Nsymbols.Encoders. There are new encoders for sized load/store,
adrandadrp, with disassembly for each. 32 new encodings are verified against clang, plus a comparison againstotooloutput.Tests
Differential test. The random program generator now covers every primitive:
It found 0 mismatches:
tests/macho.rsbuilds an object that reads data across two pages and copies between slots. It links that object with clang into a C harness, runs it, and compares every result with the interpreter.tests/memory.rspins each fault the interpreter raises, plus the little-endian layout and sign extension.cargo check --target x86_64-unknown-linux-gnu --all-targetspasses.Numbers
t27b corpus specs/(1185 files) is unchanged: 47 supported and all pass, 0 mismatches. Nothing lowers to these primitives yet.Refs #5977. Part of #5905.
🤖 Generated with Claude Code