-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
A new PHP JIT implementation based on IR JIT framework #12079
Changes from all commits
4cf9a2a
edad2d3
55a9cb3
98fee72
f4965fc
89d47ab
552bcb5
7cd0c70
44481d4
0aeddcc
5809fd5
e486bba
3486ad2
cc5af33
60d25ca
297ecdb
b1240f5
044de77
8197542
5730e0a
ef9a24e
c770d92
2d10c54
ac8c561
f562c2b
ad120f9
ce81c2c
a0c5322
4fc8807
5bde17c
5205bca
da68de6
3a83946
6a389e8
b3f2b80
489fa45
2bc29a1
477cd93
322b985
a79bf60
f629619
13f4ed4
fe0255c
8b21f1b
b527559
55ec6e3
e264431
c44c7c5
d2d73e9
ac857f6
df6be03
f59583c
fb77e41
4d2ba14
fcd0163
996a7e7
f8b4a0d
f70097b
2849dfd
9b5b90a
32fe8e6
da4fe5a
8621618
9bbeedb
8663d75
9906d8d
5793566
761e5c6
1214ab1
1da98f0
7429a46
081effc
8b6f985
55771f4
4b94e20
1152ddf
7dce8f4
f41b9a8
b2bfab2
6736fb0
60c23fb
406d312
d03e088
df99df2
7efbceb
a65d2bd
fff2212
aae334a
2407368
21ba94c
e8f11e4
7d4c939
538d8a7
2fe61cd
c876936
803b287
ef05026
04eab37
7b07b86
9de67d3
ba60549
eaaa6b8
e36025f
7ff8824
4857023
ae64b0d
c0ab97d
3707beb
57de2f6
a1d5856
38e742d
f025b93
942a815
405e639
3468833
0b2ed32
1701e06
fb44261
84b3b70
777c540
10f4b61
881a259
4031616
c84db8d
faf8c45
e311d2f
76d1a5f
ffd6526
b9f1792
fd00ea6
65167f8
6c4e883
ed87e39
3e57c1e
604fad7
2c880eb
b055d21
79d1f66
b7cff55
4711eb3
4336048
55131b7
56460c2
f78bfaa
dfcf747
0f75000
a4ad9c7
32a8fef
f8ed858
4cd2643
c2a1776
f7afc2f
3226320
1d754b5
ef27251
50b4e3f
bd4bd8b
7db3bd3
4d92a31
1a302b1
985912d
9b5c075
9c98c0d
7c0f937
ffa84ce
f9022f5
3950ee2
4bd5650
b311658
fb99de1
6d909c3
62c437e
820c765
008f245
c542bd8
fcb55df
d78c858
0a18004
555f8c7
c2bbd76
ccf1b31
3f2b7f6
1574d12
a04286d
08e79dc
61feb23
971a4c8
0520487
a0b5478
677c987
28a7426
0a71689
e85e864
53b55d1
147323a
7b82954
5302cb6
30670ba
4a81c49
3025e8b
1f7d4e0
825af91
68e956d
d8c3d8d
fd31208
31390eb
3091305
2e71a2a
05a7cc0
36e1d9a
736723a
df9e215
375cca1
3708d5d
2e2144e
a6cffcc
f099941
dabf2c6
33bebb6
a18cc16
ab40832
fa418a6
60ab2ff
54d40de
e7c04ec
16b82b2
b189b91
654ae29
15bbe57
0605bd2
87b85aa
afc773a
a2ea5d2
1ce6646
7e77941
943ec88
87666da
e64b2b7
72ade5c
74e82f2
c417f21
290059a
053772d
02a9d73
7fba3de
2ac2190
44451b0
487b22f
193a03d
66d40ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
New JIT implementation | ||
====================== | ||
|
||
This branch provides a new JIT implementation based on [IR - Lightweight | ||
JIT Compilation Framework](https://github.com/dstogov/ir). | ||
|
||
As opposed to 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 the IR Framework. IR for JIT is like an | ||
AST for compiler. | ||
|
||
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 much easier to implement support for new targets (e.g. RISCV) | ||
- IR framework is going to be developed separately from PHP and may accept | ||
contributions from other projects (new optimizations, improvements, bug fixes) | ||
|
||
Disadvantages: | ||
- JIT compilation becomes slower (this is almost invisible for tracing | ||
JIT, but function JIT compilation of Wordpress becomes 4 times slower) | ||
|
||
The necessary part of the IR Framework is embedded into php-src. So, the PR | ||
doesn't introduce new dependencies. | ||
|
||
The new JIT implementation successfully 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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO, the old implementation should be removed in the same minor version.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm going to agree :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this not make problems with MSVC or non-GNU-compatible C compilers? (e.g. intel ICC)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand you don't save esi and edi in i386 for example because they are global registers. Same reasoning for other architectures.
What if GCC global regs is not enabled? Don't you then need to save those registers too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MSVC is not affected by this macros an JIT produces a less efficient code.
ICC is actually based on GCC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
esi
andedi
are saved/restored manually throughorig_opline
ansorig_execute_data
.e.g. for CLANG build...
Good catch. The current JIT implementation uses this feature only for HYBRID VM.
It probably makes sense to wrap this builtins with ``#if```.
For CALL VM, JIT now saves/restores all the preserved registers, but this may be improved, at least for CLANG.