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

Method execute_call_vectorcall

crates/vm/src/frame.rs:6554–6604  ·  view source on GitHub ↗
(&mut self, nargs: u32, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

6552 /// Uses vectorcall slot if available, otherwise falls back to FuncArgs.
6553 #[inline]
6554 fn execute_call_vectorcall(&mut self, nargs: u32, vm: &VirtualMachine) -> FrameResult {
6555 let nargs_usize = nargs as usize;
6556 let stack_len = self.localsplus.stack_len();
6557 debug_assert!(
6558 stack_len >= nargs_usize + 2,
6559 "CALL stack underflow: need callable + self_or_null + {nargs_usize} args, have {stack_len}"
6560 );
6561 let callable_idx = stack_len - nargs_usize - 2;
6562 let self_or_null_idx = stack_len - nargs_usize - 1;
6563 let args_start = stack_len - nargs_usize;
6564
6565 // Build args: [self?, arg1, ..., argN]
6566 let self_or_null = self
6567 .localsplus
6568 .stack_index_mut(self_or_null_idx)
6569 .take()
6570 .map(|sr| sr.to_pyobj());
6571 let has_self = self_or_null.is_some();
6572
6573 let effective_nargs = if has_self {
6574 nargs_usize + 1
6575 } else {
6576 nargs_usize
6577 };
6578 let mut args_vec = Vec::with_capacity(effective_nargs);
6579 if let Some(self_val) = self_or_null {
6580 args_vec.push(self_val);
6581 }
6582 for stack_idx in args_start..stack_len {
6583 let val = self
6584 .localsplus
6585 .stack_index_mut(stack_idx)
6586 .take()
6587 .unwrap()
6588 .to_pyobj();
6589 args_vec.push(val);
6590 }
6591
6592 let callable_obj = self
6593 .localsplus
6594 .stack_index_mut(callable_idx)
6595 .take()
6596 .unwrap()
6597 .to_pyobj();
6598 self.localsplus.stack_truncate(callable_idx);
6599
6600 // invoke_vectorcall falls back to FuncArgs if no vectorcall slot
6601 let result = callable_obj.vectorcall(args_vec, effective_nargs, None, vm)?;
6602 self.push_value(result);
6603 Ok(None)
6604 }
6605
6606 /// Vectorcall dispatch for Instruction::CallKw (positional + keyword args).
6607 #[inline]

Callers 1

execute_instructionMethod · 0.80

Calls 10

stack_lenMethod · 0.80
stack_index_mutMethod · 0.80
to_pyobjMethod · 0.80
stack_truncateMethod · 0.80
push_valueMethod · 0.80
mapMethod · 0.45
takeMethod · 0.45
pushMethod · 0.45
unwrapMethod · 0.45
vectorcallMethod · 0.45

Tested by

no test coverage detected