#[repr(transparent)]pub struct TypedObjectPtr(pub *const TypedObjectStorage);Expand description
Owning newtype around *const TypedObjectStorage carrying one
v2-raw refcount share on the pointed-to allocation’s HeapHeader.
Wave 2 Round 4 D4 ckpt-final (2026-05-14): redesigned to own its
share. Previously a trivially-Copy transparent newtype; that shape
leaks element refcounts when the enclosing Vec<TypedObjectPtr>
drops because trivial bit-copy Drop never calls release_elem. Now
the wrapper:
- Owns one v2-raw HeapHeader-at-offset-0 refcount share.
Clonebumps the refcount viav2_retain.Dropretires the share viaTypedObjectStorage::release_elem.Defaultis the null pointer (no refcount share owed).
#[repr(transparent)] so the in-memory layout is identical to
*const TypedObjectStorage — zero ABI cost vs the raw pointer; the
wrapper exists only to localize the manual Send/Sync impl + the
Drop/Clone refcount discipline (Rust disables auto-Send/Sync for ALL
instantiations of a generic struct as soon as ANY manual impl exists,
so per-T newtypes are the canonical workaround for raw-ptr inner
elements in generic buffers).
Used as the inner element type of:
HashMapValueBuf::TypedObject(Arc<TypedBuffer<TypedObjectPtr>>)TypedArrayData::TypedObject(Arc<TypedBuffer<TypedObjectPtr>>)
Construction-side contract: callers transfer one strong-count share
on the v2-raw HeapHeader to the new TypedObjectPtr. Reads via
as_ptr() return the underlying pointer without bumping refcount.
Tuple Fields§
§0: *const TypedObjectStorageImplementations§
Source§impl TypedObjectPtr
impl TypedObjectPtr
Sourcepub fn new(ptr: *const TypedObjectStorage) -> Self
pub fn new(ptr: *const TypedObjectStorage) -> Self
Construct from a raw pointer obtained via TypedObjectStorage::_new.
The caller transfers one strong-count share to the wrapper.
Sourcepub fn as_ptr(&self) -> *const TypedObjectStorage
pub fn as_ptr(&self) -> *const TypedObjectStorage
Recover the underlying raw pointer. Does NOT bump refcount; the returned pointer is borrowed for the wrapper’s lifetime.
Sourcepub fn is_null(&self) -> bool
pub fn is_null(&self) -> bool
Whether the pointer is null. Construction-side contract permits null only for default-initialized cells.
Sourcepub fn into_raw(self) -> *const TypedObjectStorage
pub fn into_raw(self) -> *const TypedObjectStorage
Consume the wrapper without running Drop, returning the raw
pointer. The caller takes over the one refcount share. Mirror
of Arc::into_raw.
Methods from Deref<Target = TypedObjectStorage>§
Sourcepub unsafe fn write_slot_in_place(&self, idx: usize, new_bits: u64) -> u64
pub unsafe fn write_slot_in_place(&self, idx: usize, new_bits: u64) -> u64
In-place write of slot idx through a shared &TypedObjectStorage
(i.e. through an Arc<TypedObjectStorage> with refcount > 1).
Returns the prior (bits, kind) so the caller can run
drop_with_kind on the released share. The caller transfers
ownership of new_bits (one strong-count share for heap kinds) to
the slot.
This is the Q14 / ADR-006 §2.7.13 in-place write path for
RefTarget::TypedField projection writes — the receiver Arc
is shared between the ref carrier and the originating binding,
so Arc::get_mut / Arc::make_mut cannot apply (refcount > 1
by construction, and TypedObjectStorage is intentionally not
Clone per the §2.5 documentation). The Box<[ValueSlot]>
inside the storage is logically owned; the single-word u64
inside each ValueSlot is written atomically (single-word
aligned store on every supported architecture).
§Safety
Callers must guarantee:
- Single-threaded write: the VM is single-threaded, and the
refs that drive this path are constrained by the §3.1
ref-escape analysis to stay within their originating task
(refs cannot cross task boundaries — error B0014
NonSendableAcrossTaskBoundary). No other thread may hold an&Arc<TypedObjectStorage>to the same storage at the same time the write executes. - No aliased
&mut ValueSlot: callers must NOT mint a&mut ValueSlotto slotidxfrom any path while this write is in flight. The Q14 dispatch inop_deref_store/op_set_index_refis the only caller, and it operates on&TypedObjectStorageexclusively. - Kind invariance:
new_kindmust equalself.field_kinds[idx]. The Q14 RefTarget carries the projected slot’s kind at construction (MakeFieldRefsources it fromfield_type_tag); the post-proof§2.7.5.1contract forbids mid-life kind changes for typed fields. The caller debug_asserts this before calling. heap_maskbit consistency: for heap-kinded slots (NativeKind::String or Ptr(HeapKind::_)), the correspondingheap_maskbit must already be set per theTypedObjectStorage::newconstruction-side contract, AND the prior bits must be a validArc::into_raw::<T>for the slot’s kind. The returnedprior_bitsis exactly that share; the caller releases it viadrop_with_kindafter running the post-write barrier.
Q14 / ADR-006 §2.7.13. Mirror of the clone_with_kind /
drop_with_kind symmetry used by RefTarget::Local and
RefTarget::ModuleBinding writes (stack_write_kinded and
module_binding_write_kinded already encapsulate this pattern
for non-projected places; this is the projected-place mirror).
Trait Implementations§
Source§impl Clone for TypedObjectPtr
impl Clone for TypedObjectPtr
Source§impl Debug for TypedObjectPtr
impl Debug for TypedObjectPtr
Source§impl Default for TypedObjectPtr
impl Default for TypedObjectPtr
Source§impl Deref for TypedObjectPtr
impl Deref for TypedObjectPtr
Source§type Target = TypedObjectStorage
type Target = TypedObjectStorage
Source§fn deref(&self) -> &TypedObjectStorage
fn deref(&self) -> &TypedObjectStorage
Source§impl Drop for TypedObjectPtr
impl Drop for TypedObjectPtr
Source§impl Hash for TypedObjectPtr
impl Hash for TypedObjectPtr
Source§impl HashMapValueElem for TypedObjectPtr
impl HashMapValueElem for TypedObjectPtr
Source§unsafe fn release_typed_array(ptr: *mut TypedArray<Self>)
unsafe fn release_typed_array(ptr: *mut TypedArray<Self>)
TypedObjectPtr is #[repr(transparent)] over *const TypedObjectStorage
but has a manual Drop impl (calls release_elem). Walk the buffer
via ptr::read to invoke each element’s Drop (which retires the v2-raw
HeapHeader share), then free the data allocation + struct.
Source§unsafe fn release_owned(_value: Self)
unsafe fn release_owned(_value: Self)
release_elem on the pointer. For Ptr-newtype
V the wrapper’s Drop runs automatically when the value drops. Read moreSource§impl PartialEq for TypedObjectPtr
impl PartialEq for TypedObjectPtr
Source§fn eq(&self, other: &TypedObjectPtr) -> bool
fn eq(&self, other: &TypedObjectPtr) -> bool
self and other values to be equal, and is used by ==.