Skip to content

Commit b27f9e2

Browse files
committed
_tsrm_ls_cache resolution
1 parent 27e485d commit b27f9e2

File tree

20 files changed

+1307
-168
lines changed

20 files changed

+1307
-168
lines changed

.github/actions/freebsd/action.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ runs:
3737
webp \
3838
libavif \
3939
`#sqlite3` \
40-
curl
40+
curl \
41+
gcc \
42+
clang
4143
4244
./buildconf -f
4345
./configure \
@@ -102,3 +104,6 @@ runs:
102104
--show-slow 1000 \
103105
--set-timeout 120 \
104106
-d zend_extension=opcache.so
107+
108+
export TLSC=$(pwd)/ext/opcache/jit/tls/zend_jit_tls_x86_64.c
109+
./ext/opcache/jit/tls/testing/test.sh
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: Test TLS
2+
runs:
3+
using: composite
4+
steps:
5+
- shell: bash
6+
run: |
7+
set -x
8+
apk add clang gcc binutils-gold lld
9+
export TLSC=$(pwd)/ext/opcache/jit/tls/zend_jit_tls_x86_64.c
10+
./ext/opcache/jit/tls/testing/test.sh
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Test TLS
2+
runs:
3+
using: composite
4+
steps:
5+
- shell: bash
6+
run: |
7+
set -x
8+
export TLSC=$(pwd)/ext/opcache/jit/tls/zend_jit_tls_darwin.c
9+
./ext/opcache/jit/tls/testing/test.sh
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Test TLS
2+
runs:
3+
using: composite
4+
steps:
5+
- shell: bash
6+
run: |
7+
set -x
8+
export DEBIAN_FRONTEND=noninteractive
9+
sudo apt-get install -y gcc clang lld
10+
export TLSC=$(pwd)/ext/opcache/jit/tls/zend_jit_tls_x86.c
11+
./ext/opcache/jit/tls/testing/test.sh
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Test TLS
2+
runs:
3+
using: composite
4+
steps:
5+
- shell: bash
6+
run: |
7+
set -x
8+
export DEBIAN_FRONTEND=noninteractive
9+
sudo apt-get install -y gcc clang lld
10+
export TLSC=$(pwd)/ext/opcache/jit/tls/zend_jit_tls_x86_64.c
11+
./ext/opcache/jit/tls/testing/test.sh

.github/workflows/nightly.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ jobs:
128128
--asan -x
129129
-d zend_extension=opcache.so
130130
-d opcache.enable_cli=1
131+
- name: Test TLS resolution
132+
uses: ./.github/actions/test-tls-alpine
131133
- name: Notify Slack
132134
if: failure()
133135
uses: ./.github/actions/notify-slack
@@ -260,6 +262,9 @@ jobs:
260262
${{ matrix.run_tests_parameters }}
261263
-d zend_extension=opcache.so
262264
-d opcache.enable_cli=1
265+
- name: Test TLS resolution
266+
if: matrix.debug && matrix.zts && !matrix.asan
267+
uses: ./.github/actions/test-tls-x64
263268
- name: Verify generated files are up to date
264269
uses: ./.github/actions/verify-generated-files
265270
- name: Notify Slack
@@ -349,6 +354,9 @@ jobs:
349354
${{ matrix.run_tests_parameters }}
350355
-d zend_extension=opcache.so
351356
-d opcache.enable_cli=1
357+
- name: Test TLS resolution
358+
if: matrix.debug && matrix.zts
359+
uses: ./.github/actions/test-tls-x32
352360
- name: Notify Slack
353361
if: failure()
354362
uses: ./.github/actions/notify-slack
@@ -408,6 +416,9 @@ jobs:
408416
runTestsParameters: >-
409417
-d zend_extension=opcache.so
410418
-d opcache.enable_cli=1
419+
- name: Test TLS resolution
420+
if: matrix.debug && matrix.zts
421+
uses: ./.github/actions/test-tls-macos
411422
- name: Verify generated files are up to date
412423
uses: ./.github/actions/verify-generated-files
413424
- name: Notify Slack

ext/opcache/config.m4

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,23 @@ if test "$PHP_OPCACHE" != "no"; then
7373
IR_TARGET=IR_TARGET_X64
7474
DASM_FLAGS="-D X64APPLE=1 -D X64=1"
7575
DASM_ARCH="x86"
76+
TLS_TARGET="darwin"
7677
],
7778
[*x86_64*|amd64-*-freebsd*], [
7879
IR_TARGET=IR_TARGET_X64
7980
DASM_FLAGS="-D X64=1"
8081
DASM_ARCH="x86"
82+
TLS_TARGET="x86_64"
8183
],
8284
[[i[34567]86*|x86*]], [
8385
IR_TARGET=IR_TARGET_X86
8486
DASM_ARCH="x86"
87+
TLS_TARGET="x86"
8588
],
8689
[aarch64*], [
8790
IR_TARGET=IR_TARGET_AARCH64
8891
DASM_ARCH="aarch64"
92+
TLS_TARGET="aarch64"
8993
])
9094
9195
AS_VAR_IF([PHP_CAPSTONE], [yes],
@@ -102,6 +106,10 @@ if test "$PHP_OPCACHE" != "no"; then
102106
103107
JIT_CFLAGS="-I@ext_builddir@/jit/ir -D$IR_TARGET -DIR_PHP"
104108
AS_VAR_IF([ZEND_DEBUG], [yes], [JIT_CFLAGS="$JIT_CFLAGS -DIR_DEBUG"])
109+
110+
AS_VAR_IF([PHP_THREAD_SAFETY], [yes], [
111+
ZEND_JIT_SRC="$ZEND_JIT_SRC jit/tls/zend_jit_tls_$TLS_TARGET.c"
112+
])
105113
])
106114

107115
AC_CHECK_FUNCS([mprotect shm_create_largepage])

ext/opcache/config.w32

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ if (PHP_OPCACHE != "no") {
3333
DEFINE("IR_TARGET", ir_target);
3434
DEFINE("DASM_FLAGS", dasm_flags);
3535
DEFINE("DASM_ARCH", "x86");
36+
DEFINE("TLS_TARGET", "win");
3637

3738
AC_DEFINE('HAVE_JIT', 1, 'Define to 1 to enable JIT.');
3839

@@ -52,6 +53,11 @@ if (PHP_OPCACHE != "no") {
5253
ADD_SOURCES(configure_module_dirname + "\\jit",
5354
"zend_jit.c zend_jit_vm_helpers.c",
5455
"opcache", "ext\\opcache\\jit");
56+
if (PHP_ZTS == "yes") {
57+
ADD_SOURCES(configure_module_dirname + "\\jit\\tls",
58+
"zend_jit_tls_win.c",
59+
"opcache", "ext\\opcache\\jit\\tls");
60+
}
5561
ADD_SOURCES(configure_module_dirname + "\\jit\\ir",
5662
"ir.c", "opcache", "ext\\opcache\\jit\\ir");
5763
ADD_SOURCES(configure_module_dirname + "\\jit\\ir",
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.so
2+
*.o
3+
main

ext/opcache/jit/tls/testing/decl.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
#include <unistd.h>
3+
#include <stdio.h>
4+
#include <stdarg.h>
5+
6+
#ifdef NO_SURPLUS
7+
__thread void* _u0001;
8+
__thread void* _u0002;
9+
__thread void* _u0003;
10+
__thread void* _u0004;
11+
__thread void* _u0005;
12+
__thread void* _u0006;
13+
__thread void* _u0007;
14+
__thread void* _u0008;
15+
__thread void* _u0009;
16+
__thread void* _u0010;
17+
__thread void* _u0011;
18+
__thread void* _u0012;
19+
__thread void* _u0013;
20+
__thread void* _u0014;
21+
__thread void* _u0015;
22+
#endif
23+
24+
__thread void* _tsrm_ls_cache;
25+
26+
size_t tsrm_get_ls_cache_tcb_offset(void) {
27+
return 0;
28+
}
29+
30+
void zend_accel_error(int type, const char *format, ...) {
31+
if (type < 4) {
32+
va_list ap;
33+
va_start(ap, format);
34+
vprintf(format, ap);
35+
va_end(ap);
36+
}
37+
}
38+
39+
int test(void);
40+
41+
int decl(void) {
42+
return test();
43+
}
44+

0 commit comments

Comments
 (0)