zend-opcache - What is the difference between php's opcache and the recent php jit?
我想大声告诉你
我想大声告诉你 2017-06-26 10:49:19
0
2
1272

opcache is used to cache the opcode generated by zend engine compilation, so there is no need to compile it next time.
I recently heard about php jit and took a look at the concept of jit. The description is as follows:

JIT compilation (just-in-time compilation), that is, just-in-time compilation, in a narrow sense refers to compiling a certain piece of code when it is about to be executed for the first time, and then directly executing it without compilation. It is a type of dynamic compilation. special case.

What is the difference between php's jit and opcache?

我想大声告诉你
我想大声告诉你

reply all(2)
黄舟

Source code (understood by humans) ->Bytecode (understood by interpreter) ->Machine code (understood by hardware)
Let’s take a look at the execution process of PHP. Suppose there is an a.php file and opacache is not enabled. The process is as follows:
a.php-> compiled by zend->opcode->PHP interpreter->machine code
The process of enabling opacache is as follows
a.php->Look for the opacache cache, if not Then compile zend into opcode and cache ->opacode->PHP interpreter->machine code
The process of enabling jit is as follows
a.php->Compile->machine code
will only be executed in the future Machine code, no compilation, much more efficient

三叔

The concept of JIT actually comes from Java. In Java, the JIT compiler is the process of compiling bytecode into machine code.

If PHP and Java are mapped, then the process of compiling PHP into OpCode is the process of compiling Java into bytecode, and by extension, PHP's JIT is the process of compiling OpCode into machine code.

To put it more simply, the PHP program is compiled into OpCode and then handed over to the PHP interpreter for execution. This process is still a process of interpretation and execution. And if compiled into machine code through JIT, the execution efficiency of the program can be greatly improved.

Several popular scripting languages ​​​​already have their own JIT, but PHP is still lacking in this aspect. So, look forward to it, look forward to PHP 8

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template