(
&mut self,
vm: &VirtualMachine,
expected_count: u32,
instr_idx: usize,
cache_base: usize,
)
| 9087 | } |
| 9088 | |
| 9089 | fn specialize_unpack_sequence( |
| 9090 | &mut self, |
| 9091 | vm: &VirtualMachine, |
| 9092 | expected_count: u32, |
| 9093 | instr_idx: usize, |
| 9094 | cache_base: usize, |
| 9095 | ) { |
| 9096 | if !matches!( |
| 9097 | self.code.instructions.read_op(instr_idx), |
| 9098 | Instruction::UnpackSequence { .. } |
| 9099 | ) { |
| 9100 | return; |
| 9101 | } |
| 9102 | let obj = self.top_value(); |
| 9103 | let new_op = if let Some(tuple) = obj.downcast_ref_if_exact::<PyTuple>(vm) { |
| 9104 | if tuple.len() != expected_count as usize { |
| 9105 | None |
| 9106 | } else if expected_count == 2 { |
| 9107 | Some(Instruction::UnpackSequenceTwoTuple) |
| 9108 | } else { |
| 9109 | Some(Instruction::UnpackSequenceTuple) |
| 9110 | } |
| 9111 | } else if let Some(list) = obj.downcast_ref_if_exact::<PyList>(vm) { |
| 9112 | if list.borrow_vec().len() == expected_count as usize { |
| 9113 | Some(Instruction::UnpackSequenceList) |
| 9114 | } else { |
| 9115 | None |
| 9116 | } |
| 9117 | } else { |
| 9118 | None |
| 9119 | }; |
| 9120 | |
| 9121 | self.commit_specialization(instr_idx, cache_base, new_op); |
| 9122 | } |
| 9123 | |
| 9124 | fn specialize_store_attr( |
| 9125 | &mut self, |
no test coverage detected