summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Bernstein <ruby@bernsteinbear.com>2025-10-28 10:36:37 -0400
committerMax Bernstein <tekknolagi@gmail.com>2025-10-28 13:37:20 -0400
commit2c90da465a7ff601007b324f5ab4959ef6277a89 (patch)
treeafecc9c5e68aef57e7a6680b577b5914ef724830
parentf6cd20c61e8e4e130c9c13a2010b03fd07c999f8 (diff)
ZJIT: Count GuardType instructions
We can measure how many we can remove by adding type information to C functions, etc.
-rw-r--r--zjit.rb2
-rw-r--r--zjit/src/codegen.rs1
-rw-r--r--zjit/src/stats.rs3
3 files changed, 6 insertions, 0 deletions
diff --git a/zjit.rb b/zjit.rb
index 9ea83fe10f..b62d8e2b52 100644
--- a/zjit.rb
+++ b/zjit.rb
@@ -197,6 +197,8 @@ class << RubyVM::ZJIT
:vm_write_to_parent_iseq_local_count,
:vm_read_from_parent_iseq_local_count,
+ :guard_type_count,
+
:code_region_bytes,
:side_exit_count,
:total_insn_count,
diff --git a/zjit/src/codegen.rs b/zjit/src/codegen.rs
index bfbc8e88b9..2b71be0e15 100644
--- a/zjit/src/codegen.rs
+++ b/zjit/src/codegen.rs
@@ -1595,6 +1595,7 @@ fn gen_test(asm: &mut Assembler, val: lir::Opnd) -> lir::Opnd {
/// Compile a type check with a side exit
fn gen_guard_type(jit: &mut JITState, asm: &mut Assembler, val: lir::Opnd, guard_type: Type, state: &FrameState) -> lir::Opnd {
+ gen_incr_counter(asm, Counter::guard_type_count);
if guard_type.is_subtype(types::Fixnum) {
asm.test(val, Opnd::UImm(RUBY_FIXNUM_FLAG as u64));
asm.jz(side_exit(jit, state, GuardType(guard_type)));
diff --git a/zjit/src/stats.rs b/zjit/src/stats.rs
index 5ab81f9ac6..4874d0fe64 100644
--- a/zjit/src/stats.rs
+++ b/zjit/src/stats.rs
@@ -249,6 +249,9 @@ make_counters! {
vm_read_from_parent_iseq_local_count,
// TODO(max): Implement
// vm_reify_stack_count,
+
+ // The number of times we ran a dynamic check
+ guard_type_count,
}
/// Increase a counter by a specified amount