mirror of
https://github.com/danog/ir.git
synced 2024-12-04 02:28:32 +01:00
Update README.md
This commit is contained in:
parent
d435e7c404
commit
0b5254b769
64
README.md
64
README.md
@ -1,12 +1,16 @@
|
|||||||
# IR - Lightweight JIT Compilation Framework
|
# IR - Lightweight JIT Compilation Framework
|
||||||
|
|
||||||
The main task of this framework is transformation of the IR (Intermediate
|
IR Framework is a practical solution for implementing JIT in medium-size projects.
|
||||||
Representation) into an optimized in-memory target machine code, that may
|
It defines Intermediate Representaion (IR), provies simple API for IR construction and
|
||||||
be directly executed.
|
a set of algorithms for optimization, scheduling, register allocation and code
|
||||||
|
generation. The resulting generated in-memory code, may be directly executed.
|
||||||
|
|
||||||
This is not a stable finished product yet. It’s used as a base for development
|
This is not a stable finished product yet. It’s still under active development.
|
||||||
of the next generation JIT compiler for PHP-9. There are a lot of required
|
It was started as a base for development of the next generation JIT compiler for PHP-9,
|
||||||
things are not implemented yet.
|
but it's completly PHP independent.
|
||||||
|
|
||||||
|
A preesentation about IR framewor design and implementation details is available at
|
||||||
|
[researchgate](https://www.researchgate.net/publication/374470404_IR_JIT_Framework_a_base_for_the_next_generation_JIT_for_PHP).
|
||||||
|
|
||||||
## IR - Intermediate Representation
|
## IR - Intermediate Representation
|
||||||
|
|
||||||
@ -109,6 +113,10 @@ and inserts the necessary spill load/store and SSA deconstruction code.
|
|||||||
- GDB/JIT interface to allow debugging of JIT-ed code
|
- GDB/JIT interface to allow debugging of JIT-ed code
|
||||||
- Linux perf interface to analyze the code performance
|
- Linux perf interface to analyze the code performance
|
||||||
|
|
||||||
|
## LLVM interopability
|
||||||
|
|
||||||
|
Under development...
|
||||||
|
|
||||||
## IR Example
|
## IR Example
|
||||||
|
|
||||||
Let's try to generate code for the following function:
|
Let's try to generate code for the following function:
|
||||||
@ -272,6 +280,50 @@ test:
|
|||||||
A new experimental JIT for PHP based on IR is developed at [php-ir](https://github.com/dstogov/php-src/tree/php-ir/ext/opcache/jit) branch.
|
A new experimental JIT for PHP based on IR is developed at [php-ir](https://github.com/dstogov/php-src/tree/php-ir/ext/opcache/jit) branch.
|
||||||
See [README-IR.md](https://github.com/dstogov/php-src/blob/php-ir/ext/opcache/jit/README-IR.md).
|
See [README-IR.md](https://github.com/dstogov/php-src/blob/php-ir/ext/opcache/jit/README-IR.md).
|
||||||
|
|
||||||
|
### Building and Testing PHP with JIT based on IR Framework
|
||||||
|
|
||||||
|
Install pre-requested libraries. PHP and their extensions may require different libraries.
|
||||||
|
JIT itself needs just **libcapstone** to produce disassembler output.
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo dbf install capstone-devel
|
||||||
|
```
|
||||||
|
|
||||||
|
Build PHP
|
||||||
|
|
||||||
|
```
|
||||||
|
git clone -b php-ir --single-branch git@github.com:dstogov/php-src.git php-ir
|
||||||
|
cd php-ir
|
||||||
|
./buildconf --force
|
||||||
|
mkdir install
|
||||||
|
./configure --with-capstone --prefix=`pwd`/install --with-config-file-path=`pwd`/install/etc
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
mkdir install/etc
|
||||||
|
cat > install/etc/php.ini <<EOL
|
||||||
|
zend_extension=opcache.so
|
||||||
|
opcache.enable=1
|
||||||
|
opcache.enable_cli=1
|
||||||
|
opcache.optimization_level=-1
|
||||||
|
opcache.jit_buffer_size=32M
|
||||||
|
opcache.jit=tracing
|
||||||
|
opcache.huge_code_pages=1
|
||||||
|
EOL
|
||||||
|
```
|
||||||
|
|
||||||
|
Check if opcache s loaded
|
||||||
|
|
||||||
|
```
|
||||||
|
sapi/cli/php -v | grep -i opcache
|
||||||
|
```
|
||||||
|
|
||||||
|
See JIT in action
|
||||||
|
|
||||||
|
```
|
||||||
|
sapi/cli/php -d opcache.jit=tracing -d opcache.jit_debug=1 Zend/bench.php
|
||||||
|
sapi/cli/php -d opcache.jit=function -d opcache.jit_debug=1 Zend/bench.php
|
||||||
|
```
|
||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
1. C. Click, M. Paleczny. “A Simple Graph-Based Intermediate Representation” In ACM SIGPLAN Workshop on Intermediate Representations (IR '95), pages 35-49, Jan. 1995.
|
1. C. Click, M. Paleczny. “A Simple Graph-Based Intermediate Representation” In ACM SIGPLAN Workshop on Intermediate Representations (IR '95), pages 35-49, Jan. 1995.
|
||||||
|
Loading…
Reference in New Issue
Block a user