MCPcopy Index your code
hub / github.com/RustPython/RustPython / write_cache_u16

Method write_cache_u16

crates/compiler-core/src/bytecode.rs:706–710  ·  view source on GitHub ↗

Write a u16 value into a CACHE code unit at `index`. Each CodeUnit is 2 bytes (#[repr(C)]: op u8 + arg u8), so one u16 fits exactly. Uses Relaxed atomic store; ordering is provided by replace_op (Release). # Safety - `index` must be in bounds and point to a CACHE entry.

(&self, index: usize, value: u16)

Source from the content-addressed store, hash-verified

704 /// # Safety
705 /// - `index` must be in bounds and point to a CACHE entry.
706 pub unsafe fn write_cache_u16(&self, index: usize, value: u16) {
707 let units = unsafe { &*self.units.get() };
708 let ptr = units.as_ptr().wrapping_add(index) as *const AtomicU16;
709 unsafe { &*ptr }.store(value, Ordering::Relaxed);
710 }
711
712 /// Read a u16 value from a CACHE code unit at `index`.
713 /// Uses Relaxed atomic load; ordering is provided by read_op (Acquire).

Callers 4

specialize_store_attrMethod · 0.80
instrument_codeFunction · 0.80
write_cache_u32Method · 0.80

Calls 3

getMethod · 0.45
as_ptrMethod · 0.45
storeMethod · 0.45

Tested by

no test coverage detected