Finding the compiler: adding `opt_respond_to` to the Ruby VM, part 2

In Adding opt_respond_to to the Ruby VM: part 1 , inspired by recent JSON gem optimizations, I setup my goal: I want to add a new bytecode instruction to the Ruby VM which optimizes respond_to? calls. I took this Ruby code: if $stdout . respond_to?( :write ) puts 'Did you know you can write to $stdout?' end And identified what bytecode instructions matter most (I think): == disasm:…