From 853504f806bdf3ff3a4b16fee22ee79037e74ca0 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 6 Sep 2023 16:20:29 +0300 Subject: [PATCH] Update README --- ext/opcache/jit/README-IR.md | 38 +++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/ext/opcache/jit/README-IR.md b/ext/opcache/jit/README-IR.md index 1b7d50a146220..530b8a4380248 100644 --- a/ext/opcache/jit/README-IR.md +++ b/ext/opcache/jit/README-IR.md @@ -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 ==================== @@ -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