Skip to content

Commit d8e9ec6

Browse files
authored
ZJIT: Add specific dynamic send type counters (ruby#14528)
1 parent a35ceee commit d8e9ec6

3 files changed

Lines changed: 11 additions & 2 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: 'unhandled_yarv_insn_', prompt: 'unhandled YARV insns', buf:, stats:, limit: 20)
4545
print_counters_with_prefix(prefix: 'compile_error_', prompt: 'compile error reasons', buf:, stats:, limit: 20)
4646
print_counters_with_prefix(prefix: 'exit_', prompt: 'side exit reasons', buf:, stats:, limit: 20)
47+
print_counters_with_prefix(prefix: 'dynamic_send_type_', prompt: 'dynamic send 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: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ fn gen_insn(cb: &mut CodeBlock, jit: &mut JITState, asm: &mut Assembler, functio
370370
gen_send_without_block(jit, asm, *cd, &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)),
373-
Insn::InvokeBlock { cd, state, .. } => gen_invoke_block(jit, asm, *cd, &function.frame_state(*state)),
373+
Insn::InvokeBlock { cd, state, .. } => gen_invokeblock(jit, asm, *cd, &function.frame_state(*state)),
374374
// Ensure we have enough room fit ec, self, and arguments
375375
// TODO remove this check when we have stack args (we can use Time.new to test it)
376376
Insn::InvokeBuiltin { bf, state, .. } if bf.argc + 2 > (C_ARG_OPNDS.len() as i32) => return Err(*state),
@@ -981,6 +981,7 @@ fn gen_send(
981981
state: &FrameState,
982982
) -> lir::Opnd {
983983
gen_incr_counter(asm, Counter::dynamic_send_count);
984+
gen_incr_counter(asm, Counter::dynamic_send_type_send);
984985

985986
// Save PC and SP
986987
gen_prepare_call_with_gc(asm, state);
@@ -1008,6 +1009,7 @@ fn gen_send_without_block(
10081009
state: &FrameState,
10091010
) -> lir::Opnd {
10101011
gen_incr_counter(asm, Counter::dynamic_send_count);
1012+
gen_incr_counter(asm, Counter::dynamic_send_type_send_without_block);
10111013

10121014
// Note that it's incorrect to use this frame state to side exit because
10131015
// the state might not be on the boundary of an interpreter instruction.
@@ -1108,13 +1110,14 @@ fn gen_send_without_block_direct(
11081110
}
11091111

11101112
/// Compile for invokeblock
1111-
fn gen_invoke_block(
1113+
fn gen_invokeblock(
11121114
jit: &mut JITState,
11131115
asm: &mut Assembler,
11141116
cd: *const rb_call_data,
11151117
state: &FrameState,
11161118
) -> lir::Opnd {
11171119
gen_incr_counter(asm, Counter::dynamic_send_count);
1120+
gen_incr_counter(asm, Counter::dynamic_send_type_invokeblock);
11181121

11191122
// Save PC and SP, spill locals and stack
11201123
gen_prepare_call_with_gc(asm, state);
@@ -1141,6 +1144,7 @@ fn gen_invokesuper(
11411144
state: &FrameState,
11421145
) -> lir::Opnd {
11431146
gen_incr_counter(asm, Counter::dynamic_send_count);
1147+
gen_incr_counter(asm, Counter::dynamic_send_type_invokesuper);
11441148

11451149
// Save PC and SP
11461150
gen_prepare_call_with_gc(asm, state);

zjit/src/stats.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ make_counters! {
142142

143143
// The number of times we do a dynamic dispatch from JIT code
144144
dynamic_send_count,
145+
dynamic_send_type_send_without_block,
146+
dynamic_send_type_send,
147+
dynamic_send_type_invokeblock,
148+
dynamic_send_type_invokesuper,
145149
}
146150

147151
/// Increase a counter by a specified amount

0 commit comments

Comments
 (0)