Skip to main content

InlineInternSite

Struct InlineInternSite 

Source
pub struct InlineInternSite { /* private fields */ }
Expand description

Everything generated code may bake in to answer an interned scalar inline, and nothing else (ADR-113).

§What this makes unrepresentable

The Cranelift backend’s inline sequence for Inst::Materialize { Int } is four displacements and three immediates: where Heap hangs off the context, where the two pacing words sit inside it, where the intern table’s base pointer sits in the context, and the range and stride of the table itself. Six of those seven numbers name a private field of a #[repr(C)] struct in this crate. Handed to the backend as loose constants they would be six independent chances to pair the Int table’s base with the Char table’s bounds — a read past the end of a table whose length is the only thing keeping the probe in bounds.

So they are one value with private fields, and there is exactly one of it: crate::small_int::INLINE_INTERN_SITE. InlineInternSite::new is pub(crate), so a site can only be minted inside this crate — and the one place it is minted is beside the range constants it describes, in the module whose doc already calls itself “the one statement of the range”. “Inline-probe a table the backend has no right to probe” has no spelling, because there is no second value to name; a future Char arm (P-4a) mints its own in small_char.rs, next to its bounds, and cannot get Int’s by accident.

§And the half it cannot make unrepresentable

The pacing offsets are not arguments to new: it fills them from PacingOffsets::new, which reads Heap’s own Heap::BYTES_SINCE_COLLECT_OFFSET and Heap::COLLECT_THRESHOLD_OFFSET, so a site cannot exist that describes an intern table without also carrying the pacing predicate’s operands. That is as far as a type can go. A type cannot force the backend to emit the compare — that claim is about an instruction stream, and it is carried by an_inline_int_box_tests_the_pacing_counter_before_it_reads_the_table in the backend, which reads the emitted IR.

Implementations§

Source§

impl InlineInternSite

Source

pub const fn pacing(self) -> PacingOffsets

The pacing predicate’s operands — the three displacements generated code emits the compare from, before it looks at the value at all.

The same value InlineClaimSite::pacing answers, which is what lets the backend transcribe Heap::collection_is_due in one place. See PacingOffsets.

Source

pub const fn table_offset(self) -> usize

Where the table’s base pointer sits in a RuntimeContext.

Source

pub const fn min(self) -> i64

The lowest interned value — the addend that turns a value into an index.

Source

pub const fn span(self) -> u64

max - min, as the unsigned bound of the one compare that decides membership.

Generated code tests (value - min) as u64 <= span rather than comparing against min and max separately: in two’s complement that single unsigned compare is exactly min <= value <= max for every i64 including the wrapping ones, it reuses the subtract the index needs anyway, and it costs one branch where the two-compare form costs two. crate::small_int’s the_unsigned_range_test_generated_code_emits_answers_index_of is the proof, over the boundary values and both extremes of the type.

Source

pub const fn stride_shift(self) -> u8

log2(stride) — the shift that scales an index to a byte offset.

A shift rather than a multiply because the stride is a pointer width and a shift is the thing actually meant. new asserts the stride is a power of two, so this is exact rather than approximate.

Trait Implementations§

Source§

impl Clone for InlineInternSite

Source§

fn clone(&self) -> InlineInternSite

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for InlineInternSite

Source§

impl Debug for InlineInternSite

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.