Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IR based JIT #2

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Add IR based JIT #2

wants to merge 17 commits into from

Conversation

dstogov
Copy link

@dstogov dstogov commented Nov 15, 2024

This adds JIT for your VM bytecode based on https://github.com/dstogov/ir
I just liked to check how IR framework does its work. The first naive version was 10 times slower than "native" code, but the obvious stack resolution made JIT-ed code almost as fast as "native" (~2-2.5% slower). The SSA construction removed even this gap.

It shouldn't be a big problem to port this to LLVM. SSA construction should be done by "mem2reg" pass on top of "jitted_ir_var".

Also, I found that a weak-typed PHP interpreter is significantly faster than your best asm optimized version.
So it's definitely possible to write much faster interpreters...

@atakua you may be interested.

Benchmark Results

native                                   0.601
asmopt                                   2.986
predecoded                              21.943
subroutined                             15.425
switched                                24.787
tailrecursive                           14.670
threaded                                25.444
threaded-cached                         18.190
translated                              20.212

php -d opcache.enable=0                  2.188
php -d opcache.jit=0                     1.968
php -d opcache.jit=function              1.005
php -d opcache.jit=tracing               1.011

jited_ir                                 6.277
jited_ir_stack                           0.616
jited_ir_var                             0.613
jited_ir_ssa                             0.601

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant