Skip to content

Commit be27543

Browse files
authored
Remove old JIT implementation (#12498)
* Remove old JIT implementation * Remove ext/opcache/jit/zend_jit_vtune.c
1 parent e58af7c commit be27543

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+55
-69120
lines changed

build/Makefile.global

-3
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,6 @@ clean:
119119
find . -name \*.so | xargs rm -f
120120
find . -name .libs -a -type d|xargs rm -rf
121121
rm -f libphp.la $(SAPI_CLI_PATH) $(SAPI_CGI_PATH) $(SAPI_LITESPEED_PATH) $(SAPI_FPM_PATH) $(OVERALL_TARGET) modules/* libs/*
122-
rm -f ext/opcache/jit/zend_jit_x86.c
123-
rm -f ext/opcache/jit/zend_jit_arm64.c
124-
rm -f ext/opcache/minilua
125122
rm -f ext/opcache/jit/ir/gen_ir_fold_hash
126123
rm -f ext/opcache/jit/ir/minilua
127124
rm -f ext/opcache/jit/ir/ir_fold_hash.h

ext/opcache/config.m4

+2-56
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ PHP_ARG_WITH([capstone],,
2424
[no],
2525
[no])
2626

27-
PHP_ARG_ENABLE([opcache-jit-ir],
28-
[whether to enable JIT based on IR framework],
29-
[AS_HELP_STRING([--disable-opcache-jit-ir],
30-
[Disable JIT based on IR framework (use old JIT)])],
31-
[yes],
32-
[no])
33-
3427
if test "$PHP_OPCACHE" != "no"; then
3528

3629
dnl Always build as shared extension
@@ -51,52 +44,7 @@ if test "$PHP_OPCACHE" != "no"; then
5144
esac
5245
fi
5346

54-
if test "$PHP_OPCACHE_JIT" = "yes" -a "$PHP_OPCACHE_JIT_IR" = "no" ; then
55-
AC_DEFINE(HAVE_JIT, 1, [Define to enable JIT])
56-
ZEND_JIT_SRC="jit/zend_jit.c jit/zend_jit_gdb.c jit/zend_jit_vm_helpers.c"
57-
58-
dnl Find out which ABI we are using.
59-
case $host_alias in
60-
x86_64-*-darwin*)
61-
DASM_FLAGS="-D X64APPLE=1 -D X64=1"
62-
DASM_ARCH="x86"
63-
;;
64-
x86_64*)
65-
DASM_FLAGS="-D X64=1"
66-
DASM_ARCH="x86"
67-
;;
68-
i[[34567]]86*)
69-
DASM_ARCH="x86"
70-
;;
71-
x86*)
72-
DASM_ARCH="x86"
73-
;;
74-
aarch64*)
75-
DASM_FLAGS="-D ARM64=1"
76-
DASM_ARCH="arm64"
77-
;;
78-
esac
79-
80-
if test "$PHP_THREAD_SAFETY" = "yes"; then
81-
DASM_FLAGS="$DASM_FLAGS -D ZTS=1"
82-
fi
83-
84-
AS_IF([test x"$with_capstone" = "xyes"],[
85-
PKG_CHECK_MODULES([CAPSTONE],[capstone >= 3.0.0],[
86-
AC_DEFINE([HAVE_CAPSTONE], [1], [Capstone is available])
87-
PHP_EVAL_LIBLINE($CAPSTONE_LIBS, OPCACHE_SHARED_LIBADD)
88-
PHP_EVAL_INCLINE($CAPSTONE_CFLAGS)
89-
],[
90-
AC_MSG_ERROR([capstone >= 3.0 required but not found])
91-
])
92-
])
93-
94-
PHP_SUBST(DASM_FLAGS)
95-
PHP_SUBST(DASM_ARCH)
96-
97-
JIT_CFLAGS=
98-
99-
elif test "$PHP_OPCACHE_JIT" = "yes" -a "$PHP_OPCACHE_JIT_IR" = "yes"; then
47+
if test "$PHP_OPCACHE_JIT" = "yes" ; then
10048
AC_DEFINE(HAVE_JIT, 1, [Define to enable JIT])
10149
AC_DEFINE(ZEND_JIT_IR, 1, [Use JIT IR framework])
10250
ZEND_JIT_SRC="jit/zend_jit.c jit/zend_jit_vm_helpers.c jit/ir/ir.c jit/ir/ir_strtab.c \
@@ -383,9 +331,7 @@ int main(void) {
383331

384332
if test "$PHP_OPCACHE_JIT" = "yes"; then
385333
PHP_ADD_BUILD_DIR([$ext_builddir/jit], 1)
386-
if test "$PHP_OPCACHE_JIT_IR" = "yes"; then
387-
PHP_ADD_BUILD_DIR([$ext_builddir/jit/ir], 1)
388-
fi
334+
PHP_ADD_BUILD_DIR([$ext_builddir/jit/ir], 1)
389335
PHP_ADD_MAKEFILE_FRAGMENT($ext_srcdir/jit/Makefile.frag)
390336
fi
391337
PHP_SUBST(OPCACHE_SHARED_LIBADD)

ext/opcache/config.w32

+1-22
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ if (PHP_OPCACHE != "no") {
55

66
ARG_ENABLE("opcache-jit", "whether to enable JIT", "yes");
77

8-
ARG_ENABLE("opcache-jit-ir", "whether to enable JIT based on IR framework", "yes");
9-
108
ZEND_EXTENSION('opcache', "\
119
ZendAccelerator.c \
1210
zend_accelerator_blacklist.c \
@@ -20,26 +18,7 @@ if (PHP_OPCACHE != "no") {
2018
zend_shared_alloc.c \
2119
shared_alloc_win32.c", true, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
2220

23-
if (PHP_OPCACHE_JIT == "yes" && PHP_OPCACHE_JIT_IR == "no") {
24-
if (CHECK_HEADER_ADD_INCLUDE("dynasm/dasm_x86.h", "CFLAGS_OPCACHE", PHP_OPCACHE + ";ext\\opcache\\jit")) {
25-
var dasm_flags = (X64 ? "-D X64=1" : "") + (X64 ? " -D X64WIN=1" : "") + " -D WIN=1";
26-
if (PHP_ZTS == "yes") {
27-
dasm_flags += " -D ZTS=1";
28-
}
29-
DEFINE("DASM_FLAGS", dasm_flags);
30-
DEFINE("DASM_ARCH", "x86");
31-
32-
AC_DEFINE('HAVE_JIT', 1, 'Define to enable JIT');
33-
/* XXX read this dynamically */
34-
/*ADD_FLAG("CFLAGS_OPCACHE", "/D DASM_VERSION=10400");*/
35-
36-
ADD_MAKEFILE_FRAGMENT(configure_module_dirname + "\\jit\\Makefile.frag.w32");
37-
38-
ADD_SOURCES(configure_module_dirname + "\\jit", "zend_jit.c zend_jit_vm_helpers.c", "opcache", "ext\\opcache\\jit");
39-
} else {
40-
WARNING("JIT not enabled, headers not found");
41-
}
42-
} else if (PHP_OPCACHE_JIT == "yes" && PHP_OPCACHE_JIT_IR == "yes") {
21+
if (PHP_OPCACHE_JIT == "yes") {
4322
if (CHECK_HEADER_ADD_INCLUDE("ir/ir.h", "CFLAGS_OPCACHE", PHP_OPCACHE + ";ext\\opcache\\jit")) {
4423
var dasm_flags = (X64 ? "-D X64=1" : "") + (X64 ? " -D X64WIN=1" : "") + " -D WIN=1";
4524
var ir_target = (X64 ? "IR_TARGET_X64" : "IR_TARGET_X86");

ext/opcache/jit/Makefile.frag

-22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
ifdef IR_TARGET
2-
# New IR based JIT
31
$(builddir)/jit/ir/minilua: $(srcdir)/jit/ir/dynasm/minilua.c
42
$(BUILD_CC) $(srcdir)/jit/ir/dynasm/minilua.c -lm -o $@
53

@@ -22,26 +20,6 @@ $(builddir)/jit/zend_jit.lo: \
2220
$(srcdir)/jit/zend_jit_helpers.c \
2321
$(srcdir)/jit/zend_jit_ir.c
2422

25-
else
26-
# Old DynAsm based JIT
27-
$(builddir)/minilua: $(srcdir)/jit/dynasm/minilua.c
28-
$(BUILD_CC) $(srcdir)/jit/dynasm/minilua.c -lm -o $@
29-
30-
$(builddir)/jit/zend_jit_$(DASM_ARCH).c: $(srcdir)/jit/zend_jit_$(DASM_ARCH).dasc $(srcdir)/jit/dynasm/*.lua $(builddir)/minilua
31-
$(builddir)/minilua $(srcdir)/jit/dynasm/dynasm.lua $(DASM_FLAGS) -o $@ $(srcdir)/jit/zend_jit_$(DASM_ARCH).dasc
32-
33-
$(builddir)/jit/zend_jit.lo: \
34-
$(builddir)/jit/zend_jit_$(DASM_ARCH).c \
35-
$(srcdir)/jit/zend_jit_helpers.c \
36-
$(srcdir)/jit/zend_jit_disasm.c \
37-
$(srcdir)/jit/zend_jit_gdb.c \
38-
$(srcdir)/jit/zend_jit_perf_dump.c \
39-
$(srcdir)/jit/zend_jit_vtune.c \
40-
$(srcdir)/jit/zend_jit_trace.c \
41-
$(srcdir)/jit/zend_elf.c
42-
43-
endif
44-
4523
# For non-GNU make, jit/zend_jit.lo and ./jit/zend_jit.lo are considered distinct targets.
4624
# Use this workaround to allow building from inside ext/opcache.
4725
jit/zend_jit.lo: $(builddir)/jit/zend_jit.lo

ext/opcache/jit/Makefile.frag.w32

-24
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
!if "$(IR_TARGET)" != ""
2-
# New IR based JIT
3-
41
$(BUILD_DIR)\\minilua.exe: ext\opcache\jit\ir\dynasm\minilua.c
52
@if exist $(BUILD_DIR)\\minilua.exe del $(BUILD_DIR)\\minilua.exe
63
$(PHP_CL) /Fo$(BUILD_DIR)\ /Fd$(BUILD_DIR)\ /Fp$(BUILD_DIR)\ /FR$(BUILD_DIR) /Fe$(BUILD_DIR)\minilua.exe ext\opcache\jit\ir\dynasm\minilua.c
@@ -39,24 +36,3 @@ $(BUILD_DIR)\ext\opcache\jit\zend_jit.obj: \
3936
ext\opcache\jit\zend_jit_helpers.c \
4037
ext\opcache\jit\ir\ir.h \
4138
ext\opcache\jit\ir\ir_builder.h
42-
43-
!else
44-
# Old DynAsm based JIT
45-
46-
$(BUILD_DIR)\\minilua.exe: ext\opcache\jit\dynasm\minilua.c
47-
@if exist $(BUILD_DIR)\\minilua.exe del $(BUILD_DIR)\\minilua.exe
48-
$(PHP_CL) /Fo$(BUILD_DIR)\ /Fd$(BUILD_DIR)\ /Fp$(BUILD_DIR)\ /FR$(BUILD_DIR) /Fe$(BUILD_DIR)\minilua.exe ext\opcache\jit\dynasm\minilua.c
49-
50-
ext\opcache\jit\zend_jit_x86.c: ext\opcache\jit\zend_jit_x86.dasc $(BUILD_DIR)\\minilua.exe
51-
@if exist ext\opcache\jit\zend_jit_x86.c del ext\opcache\jit\zend_jit_x86.c
52-
$(BUILD_DIR)\\minilua.exe ext/opcache/jit/dynasm/dynasm.lua $(DASM_FLAGS) -o $@ ext/opcache/jit/zend_jit_x86.dasc
53-
54-
$(BUILD_DIR)\ext\opcache\jit\zend_jit.obj: \
55-
ext/opcache/jit/zend_jit_x86.c \
56-
ext/opcache/jit/zend_jit_helpers.c \
57-
ext/opcache/jit/zend_jit_disasm.c \
58-
ext/opcache/jit/zend_jit_gdb.c \
59-
ext/opcache/jit/zend_jit_perf_dump.c \
60-
ext/opcache/jit/zend_jit_trace.c \
61-
ext/opcache/jit/zend_jit_vtune.c
62-
!endif

ext/opcache/jit/README-IR.md

-32
This file was deleted.

ext/opcache/jit/README.md

+4-38
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,10 @@ Opcache JIT
22
===========
33

44
This is the implementation of Opcache's JIT (Just-In-Time compiler),
5-
This converts the PHP Virtual Machine's opcodes into x64/x86 assembly,
6-
on POSIX platforms and Windows.
7-
8-
It generates native code directly from PHP byte-code and information collected
9-
by the SSA static analysis framework (a part of the opcache optimizer).
10-
Code is usually generated separately for each PHP byte-code instruction. Only
11-
a few combinations are considered together (e.g. compare + conditional jump).
12-
13-
See [the JIT RFC](https://wiki.php.net/rfc/jit) for more details.
14-
15-
DynAsm
16-
------
17-
18-
This uses [DynAsm](https://luajit.org/dynasm.html) (developed for LuaJIT project)
19-
for the generation of native code. It's a very lightweight and advanced tool,
20-
but does assume good, and very low-level development knowledge of target
21-
assembler languages. In the past we tried LLVM, but its code generation speed
22-
was almost 100 times slower, making it prohibitively expensive to use.
23-
24-
[The unofficial DynASM Documentation](https://corsix.github.io/dynasm-doc/tutorial.html)
25-
has a tutorial, reference, and instruction listing.
26-
27-
In x86 builds, `zend_jit_x86.dasc` gets automatically converted to `zend_jit_x86.c` by the bundled
28-
`dynasm` during `make`.
29-
30-
In arm64 builds, `zend_jit_arm64.dasc` gets automatically converted to `zend_jit_arm64.c` by the bundled
31-
`dynasm` during `make`.
5+
This converts the PHP Virtual Machine's opcodes into Intermediate
6+
Representation and uses [IR - Lightweight JIT Compilation Framework](https://github.com/dstogov/ir)
7+
to produce optimized native code. The necessary part of the IR
8+
Framework is embedded into php-src.
329

3310
Running tests of the JIT
3411
------------------------
@@ -62,17 +39,6 @@ Note that the JIT supports 3 different architectures: `X86_64`, `i386`, and `arm
6239
Miscellaneous
6340
-------------
6441

65-
### Checking dasc files for in a different architecture
66-
67-
The following command can be run to manually check if the modified `.dasc code` is at least transpilable
68-
for an architecture you're not using, e.g.:
69-
70-
For arm64: `ext/opcache/minilua ext/opcache/jit/dynasm/dynasm.lua -D ARM64=1 -o ext/opcache/jit/zend_jit_arm64.ignored.c ext/opcache/jit/zend_jit_arm64.dasc`
71-
72-
For x86_64: `ext/opcache/minilua ext/opcache/jit/dynasm/dynasm.lua -D X64=1 -o ext/opcache/jit/zend_jit_x86.ignored.c ext/opcache/jit/zend_jit_x86.dasc`
73-
74-
For i386 (i.e. 32-bit): `ext/opcache/minilua ext/opcache/jit/dynasm/dynasm.lua -o ext/opcache/jit/zend_jit_x86.ignored.c ext/opcache/jit/zend_jit_x86.dasc`
75-
7642
### How to build 32-bit builds on x86_64 environments
7743

7844
Refer to [../../../.github/workflows/push.yml](../../../.github/workflows/push.yml) for examples of

0 commit comments

Comments
 (0)