Get the latest tech news
Peephole optimizations: adding `opt_respond_to` to the Ruby VM, part 4
In The Ruby Syntax Holy Grail: adding opt_respond_to to the Ruby VM, part 3, I found what I referred to as the “Holy Grail” of Ruby syntax. I’m way overstating it, but it’s a readable, sequential way of viewing how a large portion of the Ruby syntax is compiled. Here’s a snippet of it as a reminder: // prism_compile.c static void pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node) { const pm_parser_t *parser = scope_node->parser; //.
It’s daunting to say the least, but there are some obvious directions I can ignore - i’m trying to optimize a method call to respond_to?, so I can sidestep a majority of the Ruby syntax. So we’ll write a teensy Ruby program to demonstrate, and put it in test.rb at the root of our CRuby project: Similar to the lldb command expr, we can inspect the contents of locals using p or print in gdb:
Or read this on Hacker News