iter hs.2: static-Str layout retrofit — drop sentinel rc-header slot
Per the amended heap-Str ABI spec (2a72a4a), static-Str globals lose
the leading UINT64_MAX sentinel rc-header field that hs.1 introduced.
Layout flips from <{ i64, i64, [N x i8] }> <{ i64 -1, i64 N, ... }>
to <{ i64, [N x i8] }> <{ i64 N, ... }>; the IR-Str pointer now lands
on the len-field at struct-index 0 (was 1) via constexpr-GEP. The four
+8 consumer-side GEPs (@puts / @ail_str_eq / @ail_str_compare / @strcmp)
do not change — the bytes still sit 8 bytes past the len-field. Static-
Str pointers are kept out of ailang_rc_dec at the codegen level via
move-tracking (iter 18d.3) and non-escape lowering (iter 18b), so no
header slot is needed at the global; this is a codegen-level invariant,
not a runtime guard.
Change surface: three format strings + two doc-comments in lib.rs,
rename + assertion update of two IR-shape tests, snapshot regen of
hello.ll. No runtime changes, no checker changes, no new fixtures.
Static-Str globals are now 8 bytes smaller per literal.
cargo test --workspace green; cross_lang.py / compile_check.py /
check.py all green. 3 tasks, 0 re-loops.
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
# iter hs.2 — Static-Str sentinel-slot retrofit
|
||||
|
||||
**Date:** 2026-05-12
|
||||
**Started from:** 51a096cf8354362783d8caf2ec4b35179d935a7a
|
||||
**Status:** DONE
|
||||
**Tasks completed:** 3 of 3
|
||||
|
||||
## Summary
|
||||
|
||||
Second iter of the heap-Str ABI milestone. Surgical codegen-side
|
||||
retrofit of hs.1's static-`Str` global layout: per the amended parent
|
||||
spec (`docs/specs/2026-05-12-heap-str-abi.md`) the sentinel rc-header
|
||||
slot drops. Language `Str` literals now emit as
|
||||
`<{ i64, [N+1 x i8] }> <{ i64 N, [N+1 x i8] c"…\00" }>` instead of
|
||||
the hs.1 shape `<{ i64, i64, [N+1 x i8] }> <{ i64 -1, i64 N, …}>`. The
|
||||
explicit `len` field becomes the first (and only non-byte) field on
|
||||
which the IR-`Str` pointer lands via constexpr-GEP `i32 0, i32 0`. The
|
||||
`+8 GEP` consumer-side calls (`@puts`, `@ail_str_eq`, `@ail_str_compare`,
|
||||
inline `@strcmp`) do **not** change — the bytes still sit 8 bytes past
|
||||
the `len`-field. Static-Str pointers are kept out of `ailang_rc_dec`
|
||||
at the codegen level via move-tracking (iter 18d.3) and non-escape
|
||||
lowering (iter 18b), so no header slot is needed at the global.
|
||||
|
||||
Change surface: three format-string sites and two doc-comments in
|
||||
`crates/ailang-codegen/src/lib.rs`, rename + assertion update of two
|
||||
IR-shape tests in the same crate's test module, plus snapshot
|
||||
regeneration of `crates/ail/tests/snapshots/hello.ll`. No runtime
|
||||
changes, no checker changes, no new fixtures. Static-Str globals are
|
||||
now 8 bytes smaller per literal.
|
||||
|
||||
Acceptance verified end-to-end: `cargo test --workspace` green (every
|
||||
test result `ok`, 0 failures across the workspace), `bench/cross_lang.py`
|
||||
exit 0 (byte-identical stdout across all `ail/c` benchmark pairs),
|
||||
`bench/compile_check.py` exit 0, `bench/check.py` exit 0 within the
|
||||
known `latency.explicit_at_rc.*` nondeterminism tolerance.
|
||||
|
||||
## Per-task notes
|
||||
|
||||
- iter hs.2.1: renamed `static_str_global_uses_packed_struct_with_sentinel_and_len`
|
||||
→ `static_str_global_uses_packed_struct_with_len`; updated its
|
||||
doc-comment and assertion substring (struct loses leading `i64, `,
|
||||
initialiser loses leading `i64 -1, `). Updated assertion in
|
||||
`static_str_callsite_pointer_is_payload_via_constexpr_gep` (name
|
||||
preserved — "payload" still describes the `len`-field-as-pointer-target;
|
||||
struct loses leading `i64, `, GEP indices `i32 0, i32 1` → `i32 0, i32 0`).
|
||||
RED confirmed: both tests fail against hs.1 emission with the expected
|
||||
assertion-substring mismatch. The four `+8 GEP` tests stayed green.
|
||||
- iter hs.2.2: flipped the global-emission loop format string at
|
||||
`lib.rs:471` to the 2-field shape; flipped both `Literal::Str` arms
|
||||
(`emit_const_def` ~ `lib.rs:933`, `lower_term` ~ `lib.rs:1255`) to
|
||||
emit constexpr-GEP `i32 0, i32 0` onto the 2-field struct type;
|
||||
updated the two doc-comments on the `str_literals` field
|
||||
(`lib.rs:561`) and on `intern_str_literal` (`lib.rs:2596`) to the
|
||||
amended-spec wording. All five edits exactly per plan text. Static_str_
|
||||
tests GREEN, `_calls_` tests GREEN, full `cargo test -p ailang-codegen`
|
||||
GREEN (33 tests).
|
||||
- iter hs.2.3: regenerated `crates/ail/tests/snapshots/hello.ll` via
|
||||
`UPDATE_SNAPSHOTS=1 cargo test -p ail --test ir_snapshot hello`. The
|
||||
two affected lines (the `@.str_hello_str_0` global and its constexpr-
|
||||
GEP at `%v1`) flipped to the new shape; the outer `i64 8` byte offset
|
||||
preserved. Workspace `cargo test --workspace` green; `cross_lang.py`,
|
||||
`compile_check.py`, `check.py` all green.
|
||||
|
||||
## Concerns
|
||||
|
||||
(none)
|
||||
|
||||
## Known debt
|
||||
|
||||
(none)
|
||||
|
||||
## Files touched
|
||||
|
||||
- `crates/ailang-codegen/src/lib.rs` — three format strings, two
|
||||
doc-comments, two test names + assertions + doc-comments
|
||||
- `crates/ail/tests/snapshots/hello.ll` — regenerated snapshot
|
||||
(2 lines content change, byte offsets preserved)
|
||||
|
||||
## Stats
|
||||
|
||||
bench/orchestrator-stats/2026-05-12-iter-hs.2.json
|
||||
@@ -31,3 +31,5 @@
|
||||
- 2026-05-12 — iter ext-rename: `.ailx` → `.ail` extension rename across the live toolchain (61 example renames + 35 content edits + experiment-crate cohort rename `ailx → ail`); historical docs (journals, archive, specs, plans, frozen experiment runs) deliberately untouched; cargo+bench all-green; opens follow-up `.ail`-CLI-acceptance iter → 2026-05-12-iter-ext-rename.md
|
||||
- 2026-05-12 — iter ext-cli.1: `ail check`/build/run/...all 12 path-taking subcommands now accept `.ail` (Form A) inputs via `ailang_surface::{load_module, load_workspace}` (extension-dispatching loaders + injection point `core::load_workspace_with<F>`); workspace imports prefer `.ail` sibling over `.ail.json`; new `WorkspaceLoadError::SurfaceParse` variant routes surface parse errors as `surface-parse-error` structured diagnostics through `ail check --json`; DESIGN.md §Decision 6 CLI addendum; +7 new tests; closes the loop opened by iter ext-rename → 2026-05-12-iter-ext-cli.1.md
|
||||
- 2026-05-12 — iter hs.1: heap-Str ABI iter 1 — static-Str LLVM globals migrate from `[N x i8]` to packed-struct `<{ i64, i64, [N x i8] }>` carrying a `UINT64_MAX` sentinel rc-header + explicit `len`; IR-Str pointers now land on the `len`-field; `@puts` / `@ail_str_eq` / `@ail_str_compare` / `@strcmp` callsites GEP +8 to recover the bytes pointer (4 sites; plan listed 3, Task-5 e2e regression surfaced the 4th); 6 IR-shape pins; format strings stay raw `[N x i8]`; cross_lang.py + compile_check.py + full cargo test --workspace all green; byte-identical stdout across every example → 2026-05-12-iter-hs.1.md
|
||||
- 2026-05-12 — spec amendment: heap-str-abi — sentinel-rc-header story dropped after hs.2 BLOCKED finding (codegen-level elision via move-tracking + non-escape lowering keeps static-Str pointers out of `ailang_rc_dec` along every shipping execution path; no runtime guard needed); re-dispatched grounding-check PASS → see commit `2a72a4a` (no per-iter journal — spec edit)
|
||||
- 2026-05-12 — iter hs.2: static-Str layout retrofit — drop the `UINT64_MAX` sentinel slot from packed-struct globals (`<{ i64, i64, [N x i8] }>` → `<{ i64, [N x i8] }>`); IR-`Str` pointer now lands on the `len`-field at struct-index 0 (was 1) via constexpr-GEP `i32 0, i32 0`; `+8` consumer-side GEPs at the four C-API callsites invariant across the switch; renamed `..._sentinel_and_len` test to `..._with_len`; updated 5 sites in `crates/ailang-codegen/src/lib.rs` (3 format strings + 2 doc-comments); regenerated `hello.ll` snapshot; full `cargo test --workspace`, cross_lang.py, compile_check.py, check.py all green; static-Str globals are now 8 bytes smaller per literal → 2026-05-12-iter-hs.2.md
|
||||
|
||||
Reference in New Issue
Block a user