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

Method compare_exchange_op

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

Atomically replace opcode only if it still matches `expected`. Returns true on success. Uses Release ordering on success. # Safety - `index` must be in bounds.

(
        &self,
        index: usize,
        expected: Instruction,
        new_op: Instruction,
    )

Source from the content-addressed store, hash-verified

662 /// # Safety
663 /// - `index` must be in bounds.
664 pub unsafe fn compare_exchange_op(
665 &self,
666 index: usize,
667 expected: Instruction,
668 new_op: Instruction,
669 ) -> bool {
670 let units = unsafe { &*self.units.get() };
671 let ptr = units.as_ptr().wrapping_add(index) as *const AtomicU8;
672 unsafe { &*ptr }
673 .compare_exchange(
674 expected.into(),
675 new_op.into(),
676 Ordering::Release,
677 Ordering::Relaxed,
678 )
679 .is_ok()
680 }
681
682 /// Atomically read the opcode at `index` with Acquire ordering.
683 /// Pairs with `replace_op` (Release) to ensure cache data visibility.

Callers

nothing calls this directly

Calls 2

getMethod · 0.45
as_ptrMethod · 0.45

Tested by

no test coverage detected