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

Method execute_call_instrumented

crates/vm/src/frame.rs:6692–6746  ·  view source on GitHub ↗

Instrumented version of execute_call: fires CALL, C_RETURN, and C_RAISE events.

(&mut self, args: FuncArgs, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

6690
6691 /// Instrumented version of execute_call: fires CALL, C_RETURN, and C_RAISE events.
6692 fn execute_call_instrumented(&mut self, args: FuncArgs, vm: &VirtualMachine) -> FrameResult {
6693 let self_or_null = self.pop_value_opt();
6694 let callable = self.pop_value();
6695
6696 let final_args = if let Some(self_val) = self_or_null {
6697 let mut args = args;
6698 args.prepend_arg(self_val);
6699 args
6700 } else {
6701 args
6702 };
6703
6704 let is_python_call = callable.downcast_ref_if_exact::<PyFunction>(vm).is_some();
6705
6706 // Fire CALL event
6707 let call_arg0 = if self.monitoring_mask & monitoring::EVENT_CALL != 0 {
6708 let arg0 = final_args
6709 .args
6710 .first()
6711 .cloned()
6712 .unwrap_or_else(|| monitoring::get_missing(vm));
6713 let offset = (self.lasti() - 1) * 2;
6714 monitoring::fire_call(vm, self.code, offset, &callable, arg0.clone())?;
6715 Some(arg0)
6716 } else {
6717 None
6718 };
6719
6720 match callable.call(final_args, vm) {
6721 Ok(value) => {
6722 if let Some(arg0) = call_arg0
6723 && !is_python_call
6724 {
6725 let offset = (self.lasti() - 1) * 2;
6726 monitoring::fire_c_return(vm, self.code, offset, &callable, arg0)?;
6727 }
6728 self.push_value(value);
6729 Ok(None)
6730 }
6731 Err(exc) => {
6732 let exc = if let Some(arg0) = call_arg0
6733 && !is_python_call
6734 {
6735 let offset = (self.lasti() - 1) * 2;
6736 match monitoring::fire_c_raise(vm, self.code, offset, &callable, arg0) {
6737 Ok(()) => exc,
6738 Err(monitor_exc) => monitor_exc,
6739 }
6740 } else {
6741 exc
6742 };
6743 Err(exc)
6744 }
6745 }
6746 }
6747
6748 fn execute_raise(&mut self, vm: &VirtualMachine, kind: bytecode::RaiseKind) -> FrameResult {
6749 let cause = match kind {

Callers 1

execute_instrumentedMethod · 0.80

Calls 14

get_missingFunction · 0.85
fire_callFunction · 0.85
fire_c_returnFunction · 0.85
fire_c_raiseFunction · 0.85
pop_value_optMethod · 0.80
pop_valueMethod · 0.80
prepend_argMethod · 0.80
lastiMethod · 0.80
push_valueMethod · 0.80
SomeClass · 0.50
ErrClass · 0.50
firstMethod · 0.45

Tested by

no test coverage detected