| 988 | impl Py<Frame> { |
| 989 | #[inline(always)] |
| 990 | fn with_exec<R>(&self, vm: &VirtualMachine, f: impl FnOnce(ExecutingFrame<'_>) -> R) -> R { |
| 991 | // SAFETY: Frame execution is single-threaded. Only one thread at a time |
| 992 | // executes a given frame (enforced by the owner field and generator |
| 993 | // running flag). Same safety argument as FastLocals (UnsafeCell). |
| 994 | let iframe = unsafe { &mut *self.iframe.get() }; |
| 995 | let exec = ExecutingFrame { |
| 996 | code: &iframe.code, |
| 997 | localsplus: &mut iframe.localsplus, |
| 998 | locals: &iframe.locals, |
| 999 | globals: &iframe.globals, |
| 1000 | builtins: &iframe.builtins, |
| 1001 | builtins_dict: if iframe.globals.class().is(vm.ctx.types.dict_type) { |
| 1002 | iframe |
| 1003 | .builtins |
| 1004 | .downcast_ref_if_exact::<PyDict>(vm) |
| 1005 | // SAFETY: downcast_ref_if_exact already verified exact type |
| 1006 | .map(|d| unsafe { PyExact::ref_unchecked(d) }) |
| 1007 | } else { |
| 1008 | None |
| 1009 | }, |
| 1010 | lasti: &iframe.lasti, |
| 1011 | object: self, |
| 1012 | prev_line: &mut iframe.prev_line, |
| 1013 | monitoring_mask: 0, |
| 1014 | }; |
| 1015 | f(exec) |
| 1016 | } |
| 1017 | |
| 1018 | // #[cfg_attr(feature = "flame-it", flame("Frame"))] |
| 1019 | pub fn run(&self, vm: &VirtualMachine) -> PyResult<ExecutionResult> { |