MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / record_inst

Method record_inst

compiler/src/modules/vm/cache.rs:142–159  ·  view source on GitHub ↗

Monomorphic instance-dunder hit counter, promotes after `QUICK_THRESH` consecutive hits with the same class + method pair. Polymorphic sites churn (`record_inst` overwrites on mismatch) but never wedge. */

(&mut self, ip: usize, class: u32, method: Val, arity: u8)

Source from the content-addressed store, hash-verified

140
141 /* Monomorphic instance-dunder hit counter, promotes after `QUICK_THRESH` consecutive hits with the same class + method pair. Polymorphic sites churn (`record_inst` overwrites on mismatch) but never wedge. */
142 pub fn record_inst(&mut self, ip: usize, class: u32, method: Val, arity: u8) {
143 let Some(s) = self.slots.get_mut(ip) else { return };
144 match s.inst.as_mut() {
145 Some(c) if c.class == class && c.method_bits == method.0 && c.arity == arity => {
146 c.hits = c.hits.saturating_add(1);
147 if c.hits >= QUICK_THRESH { c.promoted = true; }
148 }
149 _ => {
150 s.inst = Some(InstanceCache {
151 class,
152 method_bits: method.0,
153 arity,
154 hits: 1,
155 promoted: false,
156 });
157 }
158 }
159 }
160
161 #[inline]
162 pub fn get_inst(&self, ip: usize) -> Option<InstanceCache> {

Callers 1

record_dunder_hitMethod · 0.80

Calls 1

get_mutMethod · 0.80

Tested by

no test coverage detected