3 ms·
> there's not compiled machine code that does a jump It's more of an implementation detail, but the Ruby VM actually does a jump if all the cases are "keyable"
by byroot 3y ago
> there's not compiled machine code that does a jump
It's more of an implementation detail, but the Ruby VM actually does a jump if all the cases are "keyable"(typically integers, strings, symbols, etc). It does a hash lookup and jump to the returning address.
https://github.com/ruby/ruby/blob/92466e440d459cd21e89f8bfbe6d8438bcaa9389/insns.def#L1094-L1096 https://github.com/ruby/ruby/blob/92466e440d459cd21e89f8bfbe...
- cschneid 3y agoThat's cool, thanks for the code pointer. I knew I was probably wrong in the strictest sense, especially with all the work that's gone into the various approaches to JIT and performance work in Ruby. I should go read some of the interpreter code at some point - fun work going on there.