Use datastack path for __init__ dispatch in CallAllocAndEnterInit (#8448)

specialization_run_init used prepare_exact_args_frame which heap-allocates
a FrameObject with 4-5 atomic refcount bumps per call. Switch to
invoke_prepared_exact_args which uses InterpreterFrame::new_on_datastack
with zero refcount bumps.

CallAllocAndEnterInit already guards against tracing (eval_frame_active)
and recursion limits before reaching this path.

Assisted-by: Claude
This commit is contained in:
Jeong, YunWon authored and GitHub committed 2026-08-04 07:31:06 +09:00
1 parent 51d7b50a6e
commit 331c3b14c8
2 files changed
+2 -5

No files matched your search

+1 -1
View File
@@ -791,7 +791,7 @@ impl Py<PyFunction> {
frame
}
fn invoke_prepared_exact_args(
pub(crate) fn invoke_prepared_exact_args(
&self,
args: impl ExactSizeIterator<Item = PyObjectRef>,
vm: &VirtualMachine,
+1 -4
View File
@@ -2673,10 +2673,7 @@ impl ExecutingFrame<'_> {
.iter_mut()
.map(|slot| slot.take().expect("arg slot must be filled"));
let init_frame = init_func.prepare_exact_args_frame(taken, vm);
let init_result = vm.run_frame(init_frame.clone());
release_datastack_frame(&init_frame, vm);
let init_result = init_result?;
let init_result = init_func.invoke_prepared_exact_args(taken, vm)?;
if !vm.is_none(&init_result) {
return Err(vm.new_type_error(format!(