Skip to content

Commit 7c02611

Browse files
committed
Merge remote-tracking branch 'origin/master' into test_repeat
2 parents ce13272 + 3d832fc commit 7c02611

Some content is hidden

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

68 files changed

+71978
-540
lines changed

.github/workflows/push.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,17 @@ jobs:
7373
asan: true
7474
name: "LINUX_X64_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || '' }}"
7575
runs-on: ubuntu-22.04
76-
container:
77-
image: ${{ matrix.asan && 'ubuntu:23.04' || null }}
7876
steps:
7977
- name: git checkout
8078
uses: actions/checkout@v4
8179
- name: apt
8280
uses: ./.github/actions/apt-x64
81+
- name: LLVM 16 (ASAN-only)
82+
if: ${{ matrix.asan }}
83+
run: |
84+
wget https://apt.llvm.org/llvm.sh
85+
chmod u+x llvm.sh
86+
sudo ./llvm.sh 16
8387
- name: System info
8488
run: |
8589
echo "::group::Show host CPU info"
@@ -110,7 +114,7 @@ jobs:
110114
configurationParameters: >-
111115
--${{ matrix.debug && 'enable' || 'disable' }}-debug
112116
--${{ matrix.zts && 'enable' || 'disable' }}-zts
113-
${{ matrix.asan && 'CFLAGS="-fsanitize=undefined,address -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-fsanitize=undefined,address" CC=clang CXX=clang++ --disable-opcache-jit' || '' }}
117+
${{ matrix.asan && 'CFLAGS="-fsanitize=undefined,address -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-fsanitize=undefined,address" CC=clang-16 CXX=clang++-16 --disable-opcache-jit' || '' }}
114118
skipSlow: ${{ matrix.asan }}
115119
- name: make
116120
run: make -j$(/usr/bin/nproc) >/dev/null

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ Standard:
3838
. Fix GH-12252 (round(): Validate the rounding mode). (timwolla)
3939
. Increase the default BCrypt cost to 12. (timwolla)
4040

41+
XML:
42+
. Added XML_OPTION_PARSE_HUGE parser option. (nielsdos)
43+
4144
XSL:
4245
. Implement request #64137 (XSLTProcessor::setParameter() should allow both
4346
quotes to be used). (nielsdos)

Zend/tests/match/046.phpt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
--TEST--
2+
Nested match expressions
3+
--FILE--
4+
<?php
5+
6+
// Nested in return expression:
7+
$b = 'b';
8+
echo match($b) {
9+
'a' => 1,
10+
'b' => match (1) {
11+
strpos('ab', $b) => 100,
12+
default => 15
13+
},
14+
default => 4
15+
};
16+
17+
echo "\n";
18+
19+
// Nested in condition expression:
20+
$c = 'c';
21+
echo match($c) {
22+
'foo' => 'bar',
23+
match ($c) { default => 'c' } => 300
24+
};
25+
26+
echo "\n";
27+
28+
// Nested in one of many condition expressions:
29+
$d = 'd';
30+
echo match($d) {
31+
'foo' => 'bar',
32+
match ($d) { default => 'd' },
33+
match ($d) { default => 'e' } => 500
34+
};
35+
36+
37+
?>
38+
--EXPECT--
39+
100
40+
300
41+
500

Zend/tests/match/047.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Match expression inside subject expression
3+
--FILE--
4+
<?php
5+
6+
echo match (match ('b') { default => 'b' }) {
7+
'a' => 100,
8+
'b' => 200,
9+
'c' => 300
10+
};
11+
12+
?>
13+
--EXPECT--
14+
200

Zend/zend_vm_execute.h

Lines changed: 13 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Zend/zend_vm_execute.skl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ ZEND_API void {%EXECUTOR_NAME%}_ex(zend_execute_data *ex)
1313

1414
{%INTERNAL_LABELS%}
1515

16+
#if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID)
17+
/* Force C compiler to store preserved registers to allow JIT using them */
18+
# if defined(__GNUC__) && defined(__i386__)
19+
__asm__ __volatile__ (""::: "ebx");
20+
# elif defined(__GNUC__) && defined(__x86_64__)
21+
__asm__ __volatile__ (""::: "rbx","r12","r13");
22+
# elif defined(__GNUC__) && defined(__aarch64__)
23+
__asm__ __volatile__ (""::: "x19","x20","x21","x22","x23","x24","x25","x26");
24+
# endif
25+
#endif
1626
LOAD_OPLINE();
1727
ZEND_VM_LOOP_INTERRUPT_CHECK();
1828

Zend/zend_vm_gen.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,14 +2046,14 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
20462046
} else {
20472047
out($f,"#if defined(ZEND_VM_IP_GLOBAL_REG) || defined(ZEND_VM_FP_GLOBAL_REG)\n");
20482048
out($f,$m[1]."struct {\n");
2049+
out($f,"#ifdef ZEND_VM_HYBRID_JIT_RED_ZONE_SIZE\n");
2050+
out($f,$m[1]."\tchar hybrid_jit_red_zone[ZEND_VM_HYBRID_JIT_RED_ZONE_SIZE];\n");
2051+
out($f,"#endif\n");
20492052
out($f,"#ifdef ZEND_VM_IP_GLOBAL_REG\n");
20502053
out($f,$m[1]."\tconst zend_op *orig_opline;\n");
20512054
out($f,"#endif\n");
20522055
out($f,"#ifdef ZEND_VM_FP_GLOBAL_REG\n");
20532056
out($f,$m[1]."\tzend_execute_data *orig_execute_data;\n");
2054-
out($f,"#ifdef ZEND_VM_HYBRID_JIT_RED_ZONE_SIZE\n");
2055-
out($f,$m[1]."\tchar hybrid_jit_red_zone[ZEND_VM_HYBRID_JIT_RED_ZONE_SIZE];\n");
2056-
out($f,"#endif\n");
20572057
out($f,"#endif\n");
20582058
out($f,$m[1]."} vm_stack_data;\n");
20592059
out($f,"#endif\n");
@@ -2339,7 +2339,7 @@ function gen_vm_opcodes_header(
23392339
$str .= "\n";
23402340
$str .= "#if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID) && !defined(__SANITIZE_ADDRESS__)\n";
23412341
$str .= "# if ((defined(i386) && !defined(__PIC__)) || defined(__x86_64__) || defined(_M_X64))\n";
2342-
$str .= "# define ZEND_VM_HYBRID_JIT_RED_ZONE_SIZE 16\n";
2342+
$str .= "# define ZEND_VM_HYBRID_JIT_RED_ZONE_SIZE 48\n";
23432343
$str .= "# endif\n";
23442344
$str .= "#endif\n";
23452345
$str .= "\n";

Zend/zend_vm_opcodes.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/Makefile.global

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ clean:
122122
rm -f ext/opcache/jit/zend_jit_x86.c
123123
rm -f ext/opcache/jit/zend_jit_arm64.c
124124
rm -f ext/opcache/minilua
125+
rm -f ext/opcache/jit/ir/gen_ir_fold_hash
126+
rm -f ext/opcache/jit/ir/minilua
127+
rm -f ext/opcache/jit/ir/ir_fold_hash.h
128+
rm -f ext/opcache/jit/ir/ir_emit_x86.h
129+
rm -f ext/opcache/jit/ir/ir_emit_aarch64.h
125130

126131
distclean: clean
127132
rm -f Makefile config.cache config.log config.status Makefile.objects Makefile.fragments libtool main/php_config.h main/internal_functions_cli.c main/internal_functions.c Zend/zend_dtrace_gen.h Zend/zend_dtrace_gen.h.bak Zend/zend_config.h

ext/opcache/config.m4

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ 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+
2734
if test "$PHP_OPCACHE" != "no"; then
2835

2936
dnl Always build as shared extension
@@ -44,7 +51,7 @@ if test "$PHP_OPCACHE" != "no"; then
4451
esac
4552
fi
4653

47-
if test "$PHP_OPCACHE_JIT" = "yes"; then
54+
if test "$PHP_OPCACHE_JIT" = "yes" -a "$PHP_OPCACHE_JIT_IR" = "no" ; then
4855
AC_DEFINE(HAVE_JIT, 1, [Define to enable JIT])
4956
ZEND_JIT_SRC="jit/zend_jit.c jit/zend_jit_gdb.c jit/zend_jit_vm_helpers.c"
5057

@@ -86,6 +93,62 @@ if test "$PHP_OPCACHE" != "no"; then
8693

8794
PHP_SUBST(DASM_FLAGS)
8895
PHP_SUBST(DASM_ARCH)
96+
97+
JIT_CFLAGS=
98+
99+
elif test "$PHP_OPCACHE_JIT" = "yes" -a "$PHP_OPCACHE_JIT_IR" = "yes"; then
100+
AC_DEFINE(HAVE_JIT, 1, [Define to enable JIT])
101+
AC_DEFINE(ZEND_JIT_IR, 1, [Use JIT IR framework])
102+
ZEND_JIT_SRC="jit/zend_jit.c jit/zend_jit_vm_helpers.c jit/ir/ir.c jit/ir/ir_strtab.c \
103+
jit/ir/ir_cfg.c jit/ir/ir_sccp.c jit/ir/ir_gcm.c jit/ir/ir_ra.c jit/ir/ir_save.c \
104+
jit/ir/ir_dump.c jit/ir/ir_gdb.c jit/ir/ir_perf.c jit/ir/ir_check.c \
105+
jit/ir/ir_patch.c jit/ir/ir_emit.c"
106+
107+
dnl Find out which ABI we are using.
108+
case $host_alias in
109+
x86_64-*-darwin*)
110+
IR_TARGET=IR_TARGET_X64
111+
DASM_FLAGS="-D X64APPLE=1 -D X64=1"
112+
DASM_ARCH="x86"
113+
;;
114+
x86_64*)
115+
IR_TARGET=IR_TARGET_X64
116+
DASM_FLAGS="-D X64=1"
117+
DASM_ARCH="x86"
118+
;;
119+
i[[34567]]86*)
120+
IR_TARGET=IR_TARGET_X86
121+
DASM_ARCH="x86"
122+
;;
123+
x86*)
124+
IR_TARGET=IR_TARGET_X86
125+
DASM_ARCH="x86"
126+
;;
127+
aarch64*)
128+
IR_TARGET=IR_TARGET_AARCH64
129+
DASM_ARCH="aarch64"
130+
;;
131+
esac
132+
133+
AS_IF([test x"$with_capstone" = "xyes"],[
134+
PKG_CHECK_MODULES([CAPSTONE],[capstone >= 3.0.0],[
135+
AC_DEFINE([HAVE_CAPSTONE], [1], [Capstone is available])
136+
PHP_EVAL_LIBLINE($CAPSTONE_LIBS, OPCACHE_SHARED_LIBADD)
137+
PHP_EVAL_INCLINE($CAPSTONE_CFLAGS)
138+
ZEND_JIT_SRC+=" jit/ir/ir_disasm.c"
139+
],[
140+
AC_MSG_ERROR([capstone >= 3.0 required but not found])
141+
])
142+
])
143+
144+
PHP_SUBST(IR_TARGET)
145+
PHP_SUBST(DASM_FLAGS)
146+
PHP_SUBST(DASM_ARCH)
147+
148+
JIT_CFLAGS="-I@ext_builddir@/jit/ir -D${IR_TARGET} -DIR_PHP"
149+
if test "$ZEND_DEBUG" = "yes"; then
150+
JIT_CFLAGS="${JIT_CFLAGS} -DIR_DEBUG"
151+
fi
89152
fi
90153

91154
AC_CHECK_FUNCS([mprotect memfd_create shm_create_largepage])
@@ -310,7 +373,7 @@ int main(void) {
310373
shared_alloc_mmap.c \
311374
shared_alloc_posix.c \
312375
$ZEND_JIT_SRC,
313-
shared,,"-Wno-implicit-fallthrough -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1",,yes)
376+
shared,,"-Wno-implicit-fallthrough -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 ${JIT_CFLAGS}",,yes)
314377

315378
PHP_ADD_EXTENSION_DEP(opcache, pcre)
316379

@@ -320,6 +383,9 @@ int main(void) {
320383

321384
if test "$PHP_OPCACHE_JIT" = "yes"; then
322385
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
323389
PHP_ADD_MAKEFILE_FRAGMENT($ext_srcdir/jit/Makefile.frag)
324390
fi
325391
PHP_SUBST(OPCACHE_SHARED_LIBADD)

0 commit comments

Comments
 (0)