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

Method specialize_call_kw

crates/vm/src/frame.rs:8538–8669  ·  view source on GitHub ↗
(
        &mut self,
        vm: &VirtualMachine,
        nargs: u32,
        instr_idx: usize,
        cache_base: usize,
    )

Source from the content-addressed store, hash-verified

8536 }
8537
8538 fn specialize_call_kw(
8539 &mut self,
8540 vm: &VirtualMachine,
8541 nargs: u32,
8542 instr_idx: usize,
8543 cache_base: usize,
8544 ) {
8545 if !matches!(
8546 self.code.instructions.read_op(instr_idx),
8547 Instruction::CallKw { .. }
8548 ) {
8549 return;
8550 }
8551 // Stack: [callable, self_or_null, arg1, ..., argN, kwarg_names]
8552 // callable is at position nargs + 2 from top
8553 let stack_len = self.localsplus.stack_len();
8554 let self_or_null_is_some = self
8555 .localsplus
8556 .stack_index(stack_len - nargs as usize - 2)
8557 .is_some();
8558 let callable = self.nth_value(nargs + 2);
8559
8560 if let Some(func) = callable.downcast_ref_if_exact::<PyFunction>(vm) {
8561 if self.specialization_eval_frame_active(vm) {
8562 unsafe {
8563 self.code.instructions.write_adaptive_counter(
8564 cache_base,
8565 bytecode::adaptive_counter_backoff(
8566 self.code.instructions.read_adaptive_counter(cache_base),
8567 ),
8568 );
8569 }
8570 return;
8571 }
8572 if !func.is_optimized_for_call_specialization() {
8573 unsafe {
8574 self.code.instructions.write_adaptive_counter(
8575 cache_base,
8576 bytecode::adaptive_counter_backoff(
8577 self.code.instructions.read_adaptive_counter(cache_base),
8578 ),
8579 );
8580 }
8581 return;
8582 }
8583 let version = func.get_version_for_current_state();
8584 if version == 0 {
8585 unsafe {
8586 self.code.instructions.write_adaptive_counter(
8587 cache_base,
8588 bytecode::adaptive_counter_backoff(
8589 self.code.instructions.read_adaptive_counter(cache_base),
8590 ),
8591 );
8592 }
8593 return;
8594 }
8595

Callers 1

execute_instructionMethod · 0.80

Calls 12

adaptive_counter_backoffFunction · 0.85
stack_lenMethod · 0.80
stack_indexMethod · 0.80
nth_valueMethod · 0.80
read_adaptive_counterMethod · 0.80
write_cache_u32Method · 0.80
specialize_atMethod · 0.80
function_objMethod · 0.80

Tested by

no test coverage detected