(
&mut self,
instruction: Instruction,
arg: bytecode::OpArg,
extend_arg: &mut bool,
vm: &VirtualMachine,
)
| 2004 | /// Execute a single instruction. |
| 2005 | #[inline(always)] |
| 2006 | fn execute_instruction( |
| 2007 | &mut self, |
| 2008 | instruction: Instruction, |
| 2009 | arg: bytecode::OpArg, |
| 2010 | extend_arg: &mut bool, |
| 2011 | vm: &VirtualMachine, |
| 2012 | ) -> FrameResult { |
| 2013 | flame_guard!(format!( |
| 2014 | "Frame::execute_instruction({})", |
| 2015 | instruction.display(arg, &self.code.code).to_string() |
| 2016 | )); |
| 2017 | |
| 2018 | #[cfg(feature = "vm-tracing-logging")] |
| 2019 | { |
| 2020 | trace!("======="); |
| 2021 | /* TODO: |
| 2022 | for frame in self.frames.iter() { |
| 2023 | trace!(" {:?}", frame); |
| 2024 | } |
| 2025 | */ |
| 2026 | trace!(" {:#?}", self); |
| 2027 | trace!( |
| 2028 | " Executing op code: {}", |
| 2029 | instruction.display(arg, &self.code.code) |
| 2030 | ); |
| 2031 | trace!("======="); |
| 2032 | } |
| 2033 | |
| 2034 | #[cold] |
| 2035 | fn name_error(name: &'static PyStrInterned, vm: &VirtualMachine) -> PyBaseExceptionRef { |
| 2036 | vm.new_name_error(format!("name '{name}' is not defined"), name.to_owned()) |
| 2037 | } |
| 2038 | |
| 2039 | match instruction { |
| 2040 | Instruction::BinaryOp { op } => { |
| 2041 | let op_val = op.get(arg); |
| 2042 | self.adaptive(|s, ii, cb| s.specialize_binary_op(vm, op_val, ii, cb)); |
| 2043 | self.execute_bin_op(vm, op_val) |
| 2044 | } |
| 2045 | // Super-instruction for BINARY_OP_ADD_UNICODE + STORE_FAST targeting |
| 2046 | // the left local, matching BINARY_OP_INPLACE_ADD_UNICODE shape. |
| 2047 | Instruction::BinaryOpInplaceAddUnicode => { |
| 2048 | let b = self.top_value(); |
| 2049 | let a = self.nth_value(1); |
| 2050 | let instr_idx = self.lasti() as usize - 1; |
| 2051 | let cache_base = instr_idx + 1; |
| 2052 | let target_local = self.binary_op_inplace_unicode_target_local(cache_base, a); |
| 2053 | if let (Some(_a_str), Some(_b_str), Some(target_local)) = ( |
| 2054 | a.downcast_ref_if_exact::<PyStr>(vm), |
| 2055 | b.downcast_ref_if_exact::<PyStr>(vm), |
| 2056 | target_local, |
| 2057 | ) { |
| 2058 | let right = self.pop_value(); |
| 2059 | let left = self.pop_value(); |
| 2060 | |
| 2061 | let local_obj = self.localsplus.fastlocals_mut()[target_local] |
| 2062 | .take() |
| 2063 | .expect("BINARY_OP_INPLACE_ADD_UNICODE target local missing"); |
no test coverage detected