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

Method replace_op

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

Replace the opcode at `index` in-place without changing the arg byte. Uses atomic Release store to ensure prior cache writes are visible to threads that subsequently read the new opcode with Acquire. # Safety - `index` must be in bounds. - `new_op` must have the same arg semantics as the original opcode.

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

Source from the content-addressed store, hash-verified

651 /// - `index` must be in bounds.
652 /// - `new_op` must have the same arg semantics as the original opcode.
653 pub unsafe fn replace_op(&self, index: usize, new_op: Instruction) {
654 let units = unsafe { &*self.units.get() };
655 let ptr = units.as_ptr().wrapping_add(index) as *const AtomicU8;
656 unsafe { &*ptr }.store(new_op.into(), Ordering::Release);
657 }
658
659 /// Atomically replace opcode only if it still matches `expected`.
660 /// Returns true on success. Uses Release ordering on success.

Callers 3

execute_instructionMethod · 0.80
specialize_atMethod · 0.80
instrument_codeFunction · 0.80

Calls 3

getMethod · 0.45
as_ptrMethod · 0.45
storeMethod · 0.45

Tested by

no test coverage detected