Translator: a slot's direct base takes no borrow; an unbiased SlotGuestBase word there is an invariant error

pointer::direct_base made its base in one of two ways. A biased SlotGuestBase word was used as
it is. An unbiased one, a device-replay variant's under the identity domains, was the word less
2^31, with a borrow from the high word. No admitted compile reaches the second arm.
plan_replay (lower/access/mod.rs) swaps every SlotGuestBase field for RootTableAddress, and
identity_refusal (lower/select.rs) refuses RootTableAddress. identity_admits runs at the end of
every identity select, before emission. So a replay variant that reaches a slot is refused,
typed, under the identity domains, and the emitter never runs with identity && replay.
a_replay_variant_under_the_identity_domains_is_refused_typed (pipeline/compile/tests.rs) holds
that refusal for a vertex function's and a kernel's buffers.

The arm goes. Its place returns an invariant error (EmitCx::fail), so an identity+replay
compile that select admits one day fails visibly and is never silently wrong. Nothing else was
used only by the arm: k32, BinOp and biased all keep other callers. Module bytes do not change
(the arm emitted nothing in an admitted compile), so SEMANTICS_VERSION stays.

Verified: not yet run; the msi job's results follow in the hand-over.
This commit is contained in:
Anees Iqbal committed 2026-12-02 05:48:53 -08:00
1 parent 6fff439212
commit f1dfed1138
1 file changed
+10 -18
+10 -18
View File
@@ -812,10 +812,12 @@ pub(super) fn slot_address(
}
/// Buffer slot `slot`'s Metal address less [`SLOT_ADDRESS_BIAS`](super::SLOT_ADDRESS_BIAS), as its
/// low and high words: its `SlotGuestBase` word where the word is biased ([`biased`]), else that
/// word less the bias, borrowing from the high word. The base an access reached from the slot's
/// own address adds its biased offset to (`psb::prepare_direct`), made once where it dominates,
/// so each access adds its offset to the low word and the carry to the high word, and no more.
/// low and high words: its biased `SlotGuestBase` word ([`biased`]). The base an access reached
/// from the slot's own address adds its biased offset to (`psb::prepare_direct`), made once where
/// it dominates, so each access adds its offset to the low word and the carry to the high word,
/// and no more. Only the identity domains reach a slot so, and they refuse a device-replay
/// variant, whose word is not biased (`select::identity_admits`): an unbiased word here is an
/// invariant error.
pub(super) fn direct_base(
cx: &mut EmitCx<'_>,
fb: &mut FunctionBuilder<'_>,
@@ -828,21 +830,11 @@ pub(super) fn direct_base(
if let (Some(lo), Some(hi)) = (cx.recall_slot(fb, lo), cx.recall_slot(fb, hi)) {
return Ok(Pair { lo, hi });
}
if !biased(cx) {
return Err(cx.fail("a direct access of a slot whose SlotGuestBase word is not biased"));
}
let v = cx.push_field(fb, PushField::SlotGuestBase(slot))?;
let word = wide::split(fb, v)?;
let base = match biased(cx) {
true => word,
false => {
let bias = k32(fb, super::SLOT_ADDRESS_BIAS as u32)?;
let less = fb.binary(BinOp::ISubBorrow, word.lo, bias)?;
let low = fb.composite_extract(less, &[0])?;
let borrow = fb.composite_extract(less, &[1])?;
Pair {
lo: low,
hi: fb.binary(BinOp::ISub, word.hi, borrow)?,
}
}
};
let base = wide::split(fb, v)?;
cx.remember_slot(fb, lo, base.lo);
cx.remember_slot(fb, hi, base.hi);
Ok(base)