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

Method specialize_store_subscr

crates/vm/src/frame.rs:9033–9066  ·  view source on GitHub ↗
(
        &mut self,
        vm: &VirtualMachine,
        instr_idx: usize,
        cache_base: usize,
    )

Source from the content-addressed store, hash-verified

9031 }
9032
9033 fn specialize_store_subscr(
9034 &mut self,
9035 vm: &VirtualMachine,
9036 instr_idx: usize,
9037 cache_base: usize,
9038 ) {
9039 if !matches!(
9040 self.code.instructions.read_op(instr_idx),
9041 Instruction::StoreSubscr
9042 ) {
9043 return;
9044 }
9045 // Stack: [value, obj, idx] — obj is TOS-1
9046 let obj = self.nth_value(1);
9047 let idx = self.top_value();
9048
9049 let new_op = if let (Some(list), Some(int_idx)) = (
9050 obj.downcast_ref_if_exact::<PyList>(vm),
9051 idx.downcast_ref_if_exact::<PyInt>(vm),
9052 ) {
9053 let list_len = list.borrow_vec().len();
9054 if specialization_nonnegative_compact_index(int_idx, vm).is_some_and(|i| i < list_len) {
9055 Some(Instruction::StoreSubscrListInt)
9056 } else {
9057 None
9058 }
9059 } else if obj.downcast_ref_if_exact::<PyDict>(vm).is_some() {
9060 Some(Instruction::StoreSubscrDict)
9061 } else {
9062 None
9063 };
9064
9065 self.commit_specialization(instr_idx, cache_base, new_op);
9066 }
9067
9068 fn specialize_contains_op(&mut self, vm: &VirtualMachine, instr_idx: usize, cache_base: usize) {
9069 if !matches!(

Callers 1

execute_instructionMethod · 0.80

Calls 7

nth_valueMethod · 0.80
top_valueMethod · 0.80
borrow_vecMethod · 0.80
commit_specializationMethod · 0.80
SomeClass · 0.50
lenMethod · 0.45

Tested by

no test coverage detected