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

Method adaptive

crates/vm/src/frame.rs:8072–8086  ·  view source on GitHub ↗
(&mut self, specialize: impl FnOnce(&mut Self, usize, usize))

Source from the content-addressed store, hash-verified

8070 /// Adaptive counter: trigger specialization at zero, otherwise advance countdown.
8071 #[inline]
8072 fn adaptive(&mut self, specialize: impl FnOnce(&mut Self, usize, usize)) {
8073 let instr_idx = self.lasti() as usize - 1;
8074 let cache_base = instr_idx + 1;
8075 let counter = self.code.instructions.read_adaptive_counter(cache_base);
8076 if bytecode::adaptive_counter_triggers(counter) {
8077 specialize(self, instr_idx, cache_base);
8078 } else {
8079 unsafe {
8080 self.code.instructions.write_adaptive_counter(
8081 cache_base,
8082 bytecode::advance_adaptive_counter(counter),
8083 );
8084 }
8085 }
8086 }
8087
8088 /// Install a specialized opcode and set adaptive cooldown bits.
8089 #[inline]

Callers 2

execute_instructionMethod · 0.80
load_attrMethod · 0.80

Calls 5

advance_adaptive_counterFunction · 0.85
lastiMethod · 0.80
read_adaptive_counterMethod · 0.80

Tested by

no test coverage detected