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)
| 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> { |
no test coverage detected