DEV Community

Chokri K'
Chokri K'

Posted on • Originally published at on

PHP 8: Introducing JIT

Basically, the PHP scripts are compiled into instructions, which are called opcodes that are understandable to the machine. Opcodes are low-level, and hence faster to translate to machine code as compared to the original PHP code.

This stage of execution is called compile time. These opcodes are then executed by the Zend VM in the runtime stage.

JIT (Just In Time) is being implemented as an almost independent part of OPcache, an extension to cache the opcodes so that compilation happens only when it is required. In PHP, JIT will treat the instructions generated for the Zend VM as the intermediate representation. It will then generate an architecture dependent machine code so that the host of your code is no longer the Zend VM, but the CPU directly

Why JIT?

Many improvements have been done to PHP since its 7.0 version including optimizations for HashTable, specializations in the Zend VM for certain opcodes, specializations in the compiler for certain sequences, and many more. After so many improvements, now PHP has reached the extent of its ability to be improved any further.

So, JIT is a technique that will compile parts of the code at runtime, so that the compiled version can be used instead.(Just In Time)

PHP comparing to C/Ruby/Python

Adding support for JIT in PHP will allow its use in scenarios for which it is not even considered today, PHP is not that HTML Templating but a programming language comparing to Ruby, Python and Java.

Faster and more secure

With JIT support, the core team will be able to develop built-in functions in PHP instead of C without any huge performance penalty. This will make PHP less susceptible to memory management, overflows, and other similar issues associated with C-based development.

According to stitcher, PHP 7.4 will introduce JIT. The release date is probably around December 2019, but not yet confirmed. Though there is no official announcement about the release schedule of PHP 8, many are speculating its release in late 2021.

The post PHP 8: Introducing JIT appeared first on C.Khalifa.

Top comments (0)