Skip to content

Commit c3b07db

Browse files
committed
ZJIT: Split the getivar not_monomorphic fallback counter by cause
Before this commit we were lumping all getivar fallback reasons in to one counter. This made it very hard to find the most popular reasons for why we're doing slowpath IV reads. This commit just adds more counters and splits up the fallback reason based on the type resolution.
1 parent 7a40f85 commit c3b07db

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

zjit/src/hir.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4907,16 +4907,28 @@ impl Function {
49074907
}
49084908
}
49094909

4910+
fn getivar_fallback_reason(resolution: ReceiverTypeResolution, ic: *const iseq_inline_iv_cache_entry) -> Counter {
4911+
match resolution {
4912+
ReceiverTypeResolution::Megamorphic => Counter::getivar_fallback_megamorphic,
4913+
ReceiverTypeResolution::SkewedMegamorphic { .. } => Counter::getivar_fallback_skewed_megamorphic,
4914+
ReceiverTypeResolution::Polymorphic => Counter::getivar_fallback_polymorphic,
4915+
ReceiverTypeResolution::NoProfile if ic.is_null() => Counter::getivar_fallback_no_profile_missing_ic,
4916+
ReceiverTypeResolution::NoProfile => Counter::getivar_fallback_no_profile,
4917+
_ => Counter::getivar_fallback_not_monomorphic,
4918+
}
4919+
}
4920+
49104921
fn optimize_getivar(&mut self) {
49114922
for block in self.reverse_post_order() {
49124923
let old_insns = std::mem::take(&mut self.blocks[block.0].insns);
49134924
assert!(self.blocks[block.0].insns.is_empty());
49144925
for insn_id in old_insns {
49154926
match self.find(insn_id) {
4916-
Insn::GetIvar { self_val, id, ic: _, state } => {
4927+
Insn::GetIvar { self_val, id, ic, state } => {
49174928
let Some(recv_type) = self.profiled_type_of_at(self_val, state) else {
4918-
// No (monomorphic/skewed polymorphic) profile info
4919-
self.count(block, Counter::getivar_fallback_not_monomorphic);
4929+
let resolution = self.resolve_receiver_type_from_profile(self_val, state);
4930+
let counter = Self::getivar_fallback_reason(resolution, ic);
4931+
self.count(block, counter);
49204932
self.push_insn_id(block, insn_id); continue;
49214933
};
49224934
if recv_type.flags().is_immediate() {

zjit/src/stats.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,11 @@ make_counters! {
324324
dynamic_getivar {
325325
// getivar_fallback_: Fallback reasons for dynamic getivar instructions
326326
getivar_fallback_not_monomorphic,
327+
getivar_fallback_megamorphic,
328+
getivar_fallback_skewed_megamorphic,
329+
getivar_fallback_polymorphic,
330+
getivar_fallback_no_profile_missing_ic,
331+
getivar_fallback_no_profile,
327332
getivar_fallback_immediate,
328333
getivar_fallback_not_t_object,
329334
getivar_fallback_complex,

0 commit comments

Comments
 (0)