#[repr(C)]pub struct VecPayload {
pub element_descriptor: *const TypeDescriptor,
pub items: ReprCVec<GcRef>,
}Expand description
The Vec[T] payload: the element descriptor plus the growable items.
items grows in place (§11.1) and is Drop, so VEC’s drop_value
releases its buffer on sweep (§12.5). The element descriptor is a 'static
borrow and owns nothing.
Fields§
§element_descriptor: *const TypeDescriptorThe descriptor for every element in items, or null when this
vector has not been told its element type. Read by
trace/format/equals to dispatch without a scattered type switch
(§11.4); read it through VecPayload::element, not directly.
Null is the honest encoding of “unknown”, and it only survives while the
vector is empty: the first push adopts the pushed value’s descriptor.
A vector that has been told its element type is never retagged.
items: ReprCVec<GcRef>The elements, in order. Growable (not Box<[T]>) so push mutates in
place, and a ReprCVec rather than a std::Vec so the length and the
element pointer are at offsets generated code is allowed to know
(ADR-118). std::Vec is #[repr(Rust)] and hides both inside a private
RawVec.
Implementations§
Source§impl VecPayload
impl VecPayload
Sourcepub fn element(&self) -> Option<&'static TypeDescriptor>
pub fn element(&self) -> Option<&'static TypeDescriptor>
The element descriptor, or None if this vector was never told its
element type. None implies items is empty.
[ElementSeq::element] is the body; this forwarder is the public
spelling, and it exists because [ElementSeq] is pub(crate) while one
caller is not: praxis-codegen-cranelift’s adversarial audit reads an
empty Vec[Float]’s descriptor through this method, which is the check
that codegen labelled the vector before any push could repair it.