Skip to content

Commit 85e6ac5

Browse files
committed
ZJIT: Add stat for def_type of send fallbacks
1 parent e758198 commit 85e6ac5

4 files changed

Lines changed: 170 additions & 81 deletions

File tree

zjit.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def stats_string
4444
print_counters_with_prefix(prefix: 'compile_error_', prompt: 'compile error reasons', buf:, stats:, limit: 20)
4545
print_counters_with_prefix(prefix: 'exit_', prompt: 'side exit reasons', buf:, stats:, limit: 20)
4646
print_counters_with_prefix(prefix: 'dynamic_send_type_', prompt: 'dynamic send types', buf:, stats:, limit: 20)
47+
print_counters_with_prefix(prefix: 'send_fallback_', prompt: 'send fallback def_types', buf:, stats:, limit: 20)
4748

4849
# Show the most important stats ratio_in_zjit at the end
4950
print_counters([

zjit/src/codegen.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ use crate::invariants::{track_bop_assumption, track_cme_assumption, track_no_ep_
1313
use crate::gc::{append_gc_offsets, get_or_create_iseq_payload, get_or_create_iseq_payload_ptr, IseqPayload, IseqStatus};
1414
use crate::state::ZJITState;
1515
use crate::stats::{exit_counter_for_compile_error, incr_counter, incr_counter_by, CompileError};
16-
use crate::stats::{counter_ptr, with_time_stat, Counter, Counter::{compile_time_ns, exit_compile_error}};
16+
use crate::stats::{counter_ptr, with_time_stat, Counter, send_fallback_counter, Counter::{compile_time_ns, exit_compile_error}};
1717
use crate::{asm::CodeBlock, cruby::*, options::debug, virtualmem::CodePtr};
1818
use crate::backend::lir::{self, asm_comment, asm_ccall, Assembler, Opnd, Target, CFP, C_ARG_OPNDS, C_RET_OPND, EC, NATIVE_STACK_PTR, NATIVE_BASE_PTR, SCRATCH_OPND, SP};
19-
use crate::hir::{iseq_to_hir, Block, BlockId, BranchEdge, Invariant, RangeType, SideExitReason, SideExitReason::*, SpecialObjectType, SpecialBackrefSymbol, SELF_PARAM_IDX};
19+
use crate::hir::{iseq_to_hir, Block, BlockId, BranchEdge, Invariant, RangeType, SideExitReason, SideExitReason::*, MethodType, SpecialObjectType, SpecialBackrefSymbol, SELF_PARAM_IDX};
2020
use crate::hir::{Const, FrameState, Function, Insn, InsnId};
2121
use crate::hir_type::{types, Type};
2222
use crate::options::get_option;
@@ -364,10 +364,10 @@ fn gen_insn(cb: &mut CodeBlock, jit: &mut JITState, asm: &mut Assembler, functio
364364
Insn::IfTrue { val, target } => no_output!(gen_if_true(jit, asm, opnd!(val), target)),
365365
Insn::IfFalse { val, target } => no_output!(gen_if_false(jit, asm, opnd!(val), target)),
366366
&Insn::Send { cd, blockiseq, state, .. } => gen_send(jit, asm, cd, blockiseq, &function.frame_state(state)),
367-
Insn::SendWithoutBlock { cd, state, .. } => gen_send_without_block(jit, asm, *cd, &function.frame_state(*state)),
367+
Insn::SendWithoutBlock { cd, state, def_type, .. } => gen_send_without_block(jit, asm, *cd, *def_type, &function.frame_state(*state)),
368368
// Give up SendWithoutBlockDirect for 6+ args since asm.ccall() doesn't support it.
369369
Insn::SendWithoutBlockDirect { cd, state, args, .. } if args.len() + 1 > C_ARG_OPNDS.len() => // +1 for self
370-
gen_send_without_block(jit, asm, *cd, &function.frame_state(*state)),
370+
gen_send_without_block(jit, asm, *cd, None, &function.frame_state(*state)),
371371
Insn::SendWithoutBlockDirect { cme, iseq, recv, args, state, .. } => gen_send_without_block_direct(cb, jit, asm, *cme, *iseq, opnd!(recv), opnds!(args), &function.frame_state(*state)),
372372
&Insn::InvokeSuper { cd, blockiseq, state, .. } => gen_invokesuper(jit, asm, cd, blockiseq, &function.frame_state(state)),
373373
Insn::InvokeBlock { cd, state, .. } => gen_invokeblock(jit, asm, *cd, &function.frame_state(*state)),
@@ -999,10 +999,16 @@ fn gen_send_without_block(
999999
jit: &mut JITState,
10001000
asm: &mut Assembler,
10011001
cd: *const rb_call_data,
1002+
def_type: Option<MethodType>,
10021003
state: &FrameState,
10031004
) -> lir::Opnd {
10041005
gen_incr_counter(asm, Counter::dynamic_send_count);
10051006
gen_incr_counter(asm, Counter::dynamic_send_type_send_without_block);
1007+
1008+
if let Some(def_type) = def_type {
1009+
gen_incr_counter(asm, send_fallback_counter(def_type));
1010+
}
1011+
10061012
gen_prepare_non_leaf_call(jit, asm, state);
10071013
asm_comment!(asm, "call #{} with dynamic dispatch", ruby_call_method_name(cd));
10081014
unsafe extern "C" {

0 commit comments

Comments
 (0)