YARV is not just a stack machine—it’s a double-stack machine!
Now that Ruby has tokenized, parsed, and compiled your code, it’s finally ready to execute it. But just how does it do that? We’ve seen how the Ruby compiler creates YARV (Yet Another Ruby Virtual Machine) instructions, but how does YARV actually run them? How does it track variables and return values and arguments? How does it implement
if statements and other control structures?
Koichi Sasada and the Ruby core team designed YARV to use a stack pointer and a program counter—that is, to function like your computer’s actual microprocessor. In this chapter, ...