summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorJean Boussier <[email protected]>2024-04-15 13:03:26 +0200
committerJean Boussier <[email protected]>2024-04-15 18:21:41 +0200
commitd019b3baec4485909e6727db2507f943e78f38ec (patch)
tree1ae1e64d5fa54ebb462ff94ece0d1369f54a7847 /vm.c
parent2eafed0f3bd33d5a4e6103259e1aba6400e5146e (diff)
Emit a performance warning when redefining specially optimized methods
This makes it easier to notice a dependency is causing interpreter or JIT deoptimization. ```ruby Warning[:performance] = true class String def freeze super end end ``` ``` ./test.rb:4: warning: Redefining 'String#freeze' disable multiple interpreter and JIT optimizations ```
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/vm.c b/vm.c
index e7335aa1bd..3fb57e2eb6 100644
--- a/vm.c
+++ b/vm.c
@@ -2132,6 +2132,12 @@ rb_vm_check_redefinition_opt_method(const rb_method_entry_t *me, VALUE klass)
if (st_lookup(vm_opt_method_def_table, (st_data_t)me->def, &bop)) {
int flag = vm_redefinition_check_flag(klass);
if (flag != 0) {
+ rb_category_warn(
+ RB_WARN_CATEGORY_PERFORMANCE,
+ "Redefining '%s#%s' disables interpreter and JIT optimizations",
+ rb_class2name(me->owner),
+ rb_id2name(me->called_id)
+ );
rb_yjit_bop_redefined(flag, (enum ruby_basic_operators)bop);
rb_rjit_bop_redefined(flag, (enum ruby_basic_operators)bop);
ruby_vm_redefined_flag[bop] |= flag;