O'Reilly logo

Ruby Under a Microscope by Pat Shaughnessy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. How Ruby Executes Your Code

image with no caption

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required