summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Bernstein <ruby@bernsteinbear.com>2025-08-27 17:50:58 -0400
committerMax Bernstein <tekknolagi@gmail.com>2025-08-27 15:56:13 -0700
commit984e05a11b761186c50971d6ef40e6207669fc7e (patch)
treeefb6547a94e87035588bfa3105d9825918bc7ab9
parentfb3d2a2a1977e702e46723ab0ed691b1e9433e7f (diff)
ZJIT: Count dynamic dispatch (SendWithoutBlock)
-rw-r--r--zjit.rb1
-rw-r--r--zjit/src/codegen.rs4
-rw-r--r--zjit/src/stats.rs3
3 files changed, 8 insertions, 0 deletions
diff --git a/zjit.rb b/zjit.rb
index 3476c1cb38..86d6643df2 100644
--- a/zjit.rb
+++ b/zjit.rb
@@ -56,6 +56,7 @@ class << RubyVM::ZJIT
:total_insn_count,
:vm_insn_count,
:zjit_insn_count,
+ :zjit_dynamic_dispatch,
:ratio_in_zjit,
], buf:, stats:)
print_counters_with_prefix(prefix: 'exit_', prompt: 'side exit reasons', buf:, stats:, limit: 20)
diff --git a/zjit/src/codegen.rs b/zjit/src/codegen.rs
index 2b71596a17..fd804e5a42 100644
--- a/zjit/src/codegen.rs
+++ b/zjit/src/codegen.rs
@@ -858,6 +858,10 @@ fn gen_send_without_block(
cd: *const rb_call_data,
state: &FrameState,
) -> lir::Opnd {
+ if get_option!(stats) {
+ gen_incr_counter(asm, Counter::zjit_dynamic_dispatch);
+ }
+
// Note that it's incorrect to use this frame state to side exit because
// the state might not be on the boundary of an interpreter instruction.
// For example, `opt_str_uminus` pushes to the stack and then sends.
diff --git a/zjit/src/stats.rs b/zjit/src/stats.rs
index c6b1ed29d6..10692d83f5 100644
--- a/zjit/src/stats.rs
+++ b/zjit/src/stats.rs
@@ -72,6 +72,9 @@ make_counters! {
// The number of times YARV instructions are executed on JIT code
zjit_insn_count,
+ // The number of times we do a dynamic dispatch from JIT code
+ zjit_dynamic_dispatch,
+
// failed_: Compilation failure reasons
failed_iseq_stack_too_large,
failed_hir_compile,