summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--yjit.rb1
-rw-r--r--yjit_codegen.c2
-rw-r--r--yjit_iface.c37
-rw-r--r--yjit_iface.h7
4 files changed, 36 insertions, 11 deletions
diff --git a/yjit.rb b/yjit.rb
index f7e283dc05..29a8d39d27 100644
--- a/yjit.rb
+++ b/yjit.rb
@@ -160,6 +160,7 @@ module YJIT
print_counters(stats, prefix: 'oaref_', prompt: 'opt_aref exit reasons: ')
print_counters(stats, prefix: 'expandarray_', prompt: 'expandarray exit reasons: ')
print_counters(stats, prefix: 'opt_getinlinecache_', prompt: 'opt_getinlinecache exit reasons: ')
+ print_counters(stats, prefix: 'invalidate_', prompt: 'invalidation reasons: ')
side_exits = total_exit_count(stats)
total_exits = side_exits + stats[:leave_interp_return]
diff --git a/yjit_codegen.c b/yjit_codegen.c
index fddf460280..ac7f866d9e 100644
--- a/yjit_codegen.c
+++ b/yjit_codegen.c
@@ -4079,7 +4079,7 @@ gen_opt_getinlinecache(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb)
// Cache is keyed on a certain lexical scope. Use the interpreter's cache.
uint8_t *side_exit = yjit_side_exit(jit, ctx);
- // Call function to verify the cache
+ // Call function to verify the cache. It doesn't allocate or call methods.
bool rb_vm_ic_hit_p(IC ic, const VALUE *reg_ep);
mov(cb, C_ARG_REGS[0], const_ptr_opnd((void *)ic));
mov(cb, C_ARG_REGS[1], member_opnd(REG_CFP, rb_control_frame_t, ep));
diff --git a/yjit_iface.c b/yjit_iface.c
index 8268440465..be4480b9d6 100644
--- a/yjit_iface.c
+++ b/yjit_iface.c
@@ -318,11 +318,13 @@ static const rb_data_type_t yjit_root_type = {
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
};
+// st_table iterator for invalidating blocks that are keys to the table.
static int
block_set_invalidate_i(st_data_t key, st_data_t v, st_data_t ignore)
{
block_t *version = (block_t *)key;
+ // Thankfully, st_table supports deleting while iterating.
invalidate_block_version(version);
return ST_CONTINUE;
@@ -348,6 +350,11 @@ rb_yjit_method_lookup_change(VALUE klass, ID mid)
rb_id_table_delete(id2blocks, mid);
st_table *block_set = (st_table *)blocks;
+
+#if YJIT_STATS
+ yjit_runtime_counters.invalidate_method_lookup += block_set->num_entries;
+#endif
+
st_foreach(block_set, block_set_invalidate_i, 0);
st_free_table(block_set);
@@ -374,6 +381,10 @@ rb_yjit_cme_invalidate(VALUE cme)
if (st_delete(cme_validity_dependency, &cme_as_st_data, &blocks)) {
st_table *block_set = (st_table *)blocks;
+#if YJIT_STATS
+ yjit_runtime_counters.invalidate_method_lookup += block_set->num_entries;
+#endif
+
// Invalidate each block
st_foreach(block_set, block_set_invalidate_i, 0);
@@ -569,19 +580,16 @@ iseq_end_index(VALUE self)
return INT2NUM(block->end_idx);
}
-static int
-block_invalidation_iterator(st_data_t key, st_data_t value, st_data_t data) {
- block_t *block = (block_t *)key;
- invalidate_block_version(block); // Thankfully, st_table supports deleteing while iterating
- return ST_CONTINUE;
-}
-
/* Called when a basic operation is redefined */
void
rb_yjit_bop_redefined(VALUE klass, const rb_method_entry_t *me, enum ruby_basic_operators bop)
{
if (blocks_assuming_bops) {
- st_foreach(blocks_assuming_bops, block_invalidation_iterator, 0);
+#if YJIT_STATS
+ yjit_runtime_counters.invalidate_bop_redefined += blocks_assuming_bops->num_entries;
+#endif
+
+ st_foreach(blocks_assuming_bops, block_set_invalidate_i, 0);
}
}
@@ -590,10 +598,12 @@ void
rb_yjit_constant_state_changed(void)
{
if (blocks_assuming_stable_global_constant_state) {
- st_foreach(blocks_assuming_stable_global_constant_state, block_invalidation_iterator, 0);
#if YJIT_STATS
yjit_runtime_counters.constant_state_bumps++;
+ yjit_runtime_counters.invalidate_constant_state_bump += blocks_assuming_stable_global_constant_state->num_entries;
#endif
+
+ st_foreach(blocks_assuming_stable_global_constant_state, block_set_invalidate_i, 0);
}
}
@@ -629,6 +639,9 @@ yjit_constant_ic_update(const rb_iseq_t *iseq, IC ic)
rb_darray_for(getinlinecache_blocks, i) {
block_t *block = rb_darray_get(getinlinecache_blocks, i);
invalidate_block_version(block);
+#if YJIT_STATS
+ yjit_runtime_counters.invalidate_constant_ic_fill++;
+#endif
}
}
else {
@@ -642,7 +655,11 @@ void
rb_yjit_before_ractor_spawn(void)
{
if (blocks_assuming_single_ractor_mode) {
- st_foreach(blocks_assuming_single_ractor_mode, block_invalidation_iterator, 0);
+#if YJIT_STATS
+ yjit_runtime_counters.invalidate_ractor_spawn += blocks_assuming_single_ractor_mode->num_entries;
+#endif
+
+ st_foreach(blocks_assuming_single_ractor_mode, block_set_invalidate_i, 0);
}
}
diff --git a/yjit_iface.h b/yjit_iface.h
index ea57dc1282..7820cafc99 100644
--- a/yjit_iface.h
+++ b/yjit_iface.h
@@ -92,7 +92,14 @@ YJIT_DECLARE_COUNTERS(
vm_insns_count,
compiled_iseq_count,
compiled_block_count,
+
invalidation_count,
+ invalidate_method_lookup,
+ invalidate_bop_redefined,
+ invalidate_ractor_spawn,
+ invalidate_constant_state_bump,
+ invalidate_constant_ic_fill,
+
constant_state_bumps,
expandarray_splat,