summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorDaniel Colson <danieljamescolson@gmail.com>2022-11-30 20:28:14 -0500
committerJohn Hawthorn <john@hawthorn.email>2022-12-06 12:37:23 -0800
commitc43951e60eed0b01f464cd25441b81751d2d5087 (patch)
treebcf5a060db738653287650970c0034b0d3473a6e /vm.c
parent9d4483f24deaf360dafe745a71211ec73dc7029a (diff)
downloadruby-c43951e60eed0b01f464cd25441b81751d2d5087.tar.gz
Move BOP macros to separate file
This commit moves ruby_basic_operators and the unredefined macros out of vm_core.h and into basic_operators.h so that we can use them more broadly in places where we currently use a method look up via `rb_method_basic_definition_p` (e.g. object.c, numeric.c, complex.c, enum.c, but also in internal/compar.h after introducing BOP_CMP and elsewhere if we introduce more BOPs) The most controversial part of this change is probably moving redefined_flag out of rb_vm_t. [vm_opt_method_def_table and vm_opt_mid_table](https://github.com/ruby/ruby/blob/9da2a5204f32a4f2ce135fddde2abb6e07d647e9/vm.c) are not part of rb_vm_t either, and I think this fits well with those. But more significantly it seems to result in one fewer instruction. For example: Before: ``` (lldb) disassemble -n vm_opt_str_freeze miniruby`vm_exec_core: miniruby[0x10028233e] <+14558>: movq 0x11a86b(%rip), %rax ; ruby_current_vm_ptr miniruby[0x100282345] <+14565>: testb $0x4, 0x242c(%rax) ``` After: ``` (lldb) disassemble -n vm_opt_str_freeze ruby`vm_exec_core: ruby[0x100280ebe] <+14510>: testb $0x4, 0x120147(%rip) ; ruby_vm_redefined_flag + 43 ``` Co-authored-by: John Hawthorn <jhawthorn@github.com>
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/vm.c b/vm.c
index 490bee677b..0f0383b9b8 100644
--- a/vm.c
+++ b/vm.c
@@ -466,7 +466,6 @@ VALUE rb_cThread;
VALUE rb_mRubyVMFrozenCore;
VALUE rb_block_param_proxy;
-#define ruby_vm_redefined_flag GET_VM()->redefined_flag
VALUE ruby_vm_const_missing_count = 0;
rb_vm_t *ruby_current_vm_ptr = NULL;
rb_ractor_t *ruby_single_main_ractor;
@@ -1894,6 +1893,7 @@ rb_iter_break_value(VALUE val)
/* optimization: redefine management */
+short ruby_vm_redefined_flag[BOP_LAST_];
static st_table *vm_opt_method_def_table = 0;
static st_table *vm_opt_mid_table = 0;