Nikita Popov has a new post to his site sharing a look behind the curtain of how the PHP 7 virtual machine works, the latest version in the Zend Virtual Machine that powers the language.
This article aims to provide an overview of the Zend Virtual Machine, as it is found in PHP 7. This is not a comprehensive description, but I try to cover most of the important parts, as well as some of the finer details.
This description targets PHP version 7.2 (currently in development), but nearly everything also applies to PHP 7.0/7.1. However, the differences to the PHP 5.x series VM are significant and I will generally not bother to draw parallels.
Most of this post will consider things at the level of instruction listings and only a few sections at the end deal with the actual C level implementation of the VM.
He then goes through many different points and piece of functionality in the VM and how they work including:
- variable types
- the stack frame layout
- fetch modes
- exception handling
- finally handling
There's lots of information here and it's definitely interesting to see what happens inside the language to create the fast and functional PHP 7 applications we have now.