
Member-only story
JIT Compiler in PHP
Here are my notes about the JIT compiler in PHP.
Before PHP JIT Compilation
- each script processed in a request to a PHP web application is parsed, and then compiled into “byte codes” (op codes)
- “op codes”, are pseudo-instructions that a virtual machine can process.
- Zend Engine”; this is a virtual machine, similar to LLVM or the JVM.
- A virtual machine’s job is to take those byte codes, compile them to machine code, and then execute them.
- When the OPcache is enabled, PHP takes the byte codes it compiles to and stores them in the OPcache before passing them to the VM (Introduced in PHP 5.5). On subsequent requests, it checks to see if it has an entry for that script in the OPcache; if so, it passes those directly to the VM, thus skipping the steps of parsing and compiling to opcodes. This helps improve performance.

- OPCache is not enough because it is memory limited. Even with an OPcache, there are bottlenecks in many applications. Also most of modern PHP frameworks tend to be bootstrap-heavy.
- To overcome this situation PHP 7.4 introduced opcache…