diff options
author | Daniel Colson <[email protected]> | 2022-11-30 20:28:14 -0500 |
---|---|---|
committer | John Hawthorn <[email protected]> | 2022-12-06 12:37:23 -0800 |
commit | c43951e60eed0b01f464cd25441b81751d2d5087 (patch) | |
tree | bcf5a060db738653287650970c0034b0d3473a6e /internal/enum.h | |
parent | 9d4483f24deaf360dafe745a71211ec73dc7029a (diff) |
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 <[email protected]>
Diffstat (limited to 'internal/enum.h')
0 files changed, 0 insertions, 0 deletions