Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Sep 8, 2023
1 parent 13b6c8d commit 853504f
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions ext/opcache/jit/README-IR.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
New JIT implementation
======================

This branch contains a new **experimental** JIT implementation based
on [IR - Lightweight JIT Compilation Framework](https://github.com/dstogov/ir).
This branch provides a new JIT implementation based on [IR - Lightweight
JIT Compilation Framework](https://github.com/dstogov/ir).

Despite of the PHP 8.* JIT approach, that generates native code directly from
PHP byte-code, this implementation generates intermediate representation (IR) and
delegates all lower-level tasks to IR Framework.
PHP byte-code, this implementation generates intermediate representation (IR)
and delegates all lower-level tasks to the IR Framework. IR for JIT is like an
AST for compiler.

Both IR and PHP JIT implementation are under development. Only 50% of PHP byte-code
instructions are covered. Windows support is missing yet. ZTS and CLANG builds are
not tested. Few *.phpt tests fail...
Key benefits of the new JIT implementation:
- Usage of IR opens possibilities for better optimization and register
allocation (the resulting native code is more efficient)
- PHP doesn't have to care about most low-level details (different CPUs,
calling conventions, TLS details, etc)
- it's mach easier to implement support for new targets (e.g. RISCV)
- IR framework is going to be developed separately from PHP and may accept
contibutions from other projects (new optimizations, improvemets, bug fixes)

New IR based JIT is disabled by default. It may be enable during PHP build process,
running configured with **--enable-opcache-jit-ir**. Otherwise, PHP is going to be
built with old JIT implementation.
Disadvantages:
- JIT compilation becomes slower (this is almost invisible for tracing
JIT, but function JIT compilation of Wordpress becomes 4 times slower)

IR Framework is included into PHP as a GIT submodule. It should be fetched by

``git submodule update --init --recursive``

The new JIT implementation sucessfully passes all CI workflows, but it's still
not mature and may cause failures. To reduce risks, this patch doesn't remove
the old JIT implementation (that is the same as PHP-8.3 JIT). It's possible
to build PHP with the old JIT by configuring with **--disable-opcache-jit-ir**.
In the future the old implementation should be removed.

Building and Testing
====================
Expand All @@ -34,7 +50,7 @@ cd php-ir
git submodule update --init --recursive
./buildconf --force
mkdir install
./configure --enable-opcache-jit-ir --with-capstone --prefix=`pwd`/install --with-config-file-path=`pwd`/install/etc
./configure --with-capstone --prefix=`pwd`/install --with-config-file-path=`pwd`/install/etc
make
make install
mkdir install/etc
Expand Down

0 comments on commit 853504f

Please sign in to comment.