Skip to main content

jit_alloc_shared_cell

Function jit_alloc_shared_cell 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn jit_alloc_shared_cell( _initial_bits: u64, ) -> u64
Expand description

Allocate a fresh Arc<SharedCell> from initial_bits and return the raw pointer bits of the strong share.

The returned pointer is owned by the caller’s slot; it MUST be released via jit_arc_shared_release exactly once when the slot exits scope. ValueWord::from_bits(initial_bits) seeds the cell’s inner payload; subsequent reads/writes go through the lock-gated pointer-deref lowering in mir_compiler/places.rs.

§Safety

  • initial_bits is a raw ValueWord bit pattern. If the bits encode a heap-refcounted pointer, the caller must ensure the appropriate refcount share was already taken — this FFI does not retain or release heap refs on the payload.
  • The returned pointer is 8-byte aligned (Arc + repr(C) SharedCell) and non-null (Arc::new never returns null).
  • The returned pointer is the sole strong share owned by the caller’s slot; jit_arc_shared_release is the sole releaser. Additional shares (one per capturing closure) are minted via jit_arc_shared_retain and balanced by release_typed_closure on closure drop.