Skip to content

Commit 7d846b4

Browse files
committed
remove unused old paths
1 parent 08c6319 commit 7d846b4

5 files changed

Lines changed: 16 additions & 126 deletions

File tree

Zend/Zend.m4

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -179,22 +179,10 @@ AS_VAR_IF([ZEND_ZTS], [yes], [
179179
AC_DEFINE([ZTS], [1], [Define to 1 if thread safety (ZTS) is enabled.])
180180
AS_VAR_APPEND([CFLAGS], [" -DZTS"])
181181
182-
AC_CACHE_CHECK([for __thread support], [php_cv_have_thread_local], [
183-
AC_LINK_IFELSE([AC_LANG_PROGRAM(
184-
[[static __thread int tls_var;]],
185-
[[tls_var = 1; return tls_var;]])],
186-
[php_cv_have_thread_local=yes], [php_cv_have_thread_local=no])
187-
])
188-
AS_VAR_IF([php_cv_have_thread_local], [yes], [
189-
AC_DEFINE([ZEND_EG_TLS], [1],
190-
[Define to hold EG()/CG() in a __thread variable under ZTS.])
191-
AS_VAR_APPEND([CFLAGS], [" -DZEND_EG_TLS"])
192-
193-
dnl -mtls-size=12 drops the dead high-bits offset add from TLS access,
194-
dnl valid while the thread-local block stays under 4 KiB.
195-
AX_CHECK_COMPILE_FLAG([-mtls-size=12],
196-
[AS_VAR_APPEND([CFLAGS], [" -mtls-size=12"])])
197-
])
182+
dnl -mtls-size=12 drops the dead high-bits offset add from TLS access,
183+
dnl valid while the thread-local block stays under 4 KiB.
184+
AX_CHECK_COMPILE_FLAG([-mtls-size=12],
185+
[AS_VAR_APPEND([CFLAGS], [" -mtls-size=12"])])
198186
])
199187
200188
AC_MSG_CHECKING([whether to enable Zend debugging])

Zend/zend.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,12 @@ static bool startup_done = false;
5252
#ifdef ZTS
5353
ZEND_API int compiler_globals_id;
5454
ZEND_API int executor_globals_id;
55-
ZEND_API size_t compiler_globals_offset;
56-
ZEND_API size_t executor_globals_offset;
57-
# ifdef ZEND_EG_TLS
5855
ZEND_API TSRM_TLS TSRM_TLS_MODEL_ATTR zend_executor_globals executor_globals_tls;
5956
ZEND_API TSRM_TLS TSRM_TLS_MODEL_ATTR zend_compiler_globals compiler_globals_tls;
6057
/* ts_allocate_tls_id takes a callback so each thread resolves its own block.
6158
* A plain &..._tls would capture only the registering thread's address. */
6259
static void *executor_globals_tls_addr(void) { return &executor_globals_tls; }
6360
static void *compiler_globals_tls_addr(void) { return &compiler_globals_tls; }
64-
# endif
6561
static HashTable *global_function_table = NULL;
6662
static HashTable *global_class_table = NULL;
6763
static HashTable *global_constants_table = NULL;
@@ -1027,13 +1023,8 @@ void zend_startup(zend_utility_functions *utility_functions) /* {{{ */
10271023
zend_init_rsrc_list_dtors();
10281024

10291025
#ifdef ZTS
1030-
#ifdef ZEND_EG_TLS
10311026
ts_allocate_tls_id(&compiler_globals_id, compiler_globals_tls_addr, sizeof(zend_compiler_globals), (ts_allocate_ctor) compiler_globals_ctor, (ts_allocate_dtor) compiler_globals_dtor);
10321027
ts_allocate_tls_id(&executor_globals_id, executor_globals_tls_addr, sizeof(zend_executor_globals), (ts_allocate_ctor) executor_globals_ctor, (ts_allocate_dtor) executor_globals_dtor);
1033-
#else
1034-
ts_allocate_fast_id(&compiler_globals_id, &compiler_globals_offset, sizeof(zend_compiler_globals), (ts_allocate_ctor) compiler_globals_ctor, (ts_allocate_dtor) compiler_globals_dtor);
1035-
ts_allocate_fast_id(&executor_globals_id, &executor_globals_offset, sizeof(zend_executor_globals), (ts_allocate_ctor) executor_globals_ctor, (ts_allocate_dtor) executor_globals_dtor);
1036-
#endif
10371028
ts_allocate_fast_id(&language_scanner_globals_id, &language_scanner_globals_offset, sizeof(zend_php_scanner_globals), (ts_allocate_ctor) php_scanner_globals_ctor, NULL);
10381029
ts_allocate_fast_id(&ini_scanner_globals_id, &ini_scanner_globals_offset, sizeof(zend_ini_scanner_globals), (ts_allocate_ctor) ini_scanner_globals_ctor, NULL);
10391030
compiler_globals = ts_resource(compiler_globals_id);

Zend/zend_globals.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@
5151
BEGIN_EXTERN_C()
5252
ZEND_API extern int compiler_globals_id;
5353
ZEND_API extern int executor_globals_id;
54-
ZEND_API extern size_t compiler_globals_offset;
55-
ZEND_API extern size_t executor_globals_offset;
5654
END_EXTERN_C()
5755

5856
#endif

Zend/zend_globals_macros.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,8 @@ BEGIN_EXTERN_C()
3030

3131
/* Compiler */
3232
#ifdef ZTS
33-
# ifdef ZEND_EG_TLS
3433
extern ZEND_API TSRM_TLS TSRM_TLS_MODEL_ATTR zend_compiler_globals compiler_globals_tls;
35-
# define CG(v) (compiler_globals_tls.v)
36-
# else
37-
# define CG(v) ZEND_TSRMG_FAST(compiler_globals_offset, zend_compiler_globals *, v)
38-
# endif
34+
# define CG(v) (compiler_globals_tls.v)
3935
#else
4036
# define CG(v) (compiler_globals.v)
4137
extern ZEND_API struct _zend_compiler_globals compiler_globals;
@@ -45,12 +41,8 @@ ZEND_API int zendparse(void);
4541

4642
/* Executor */
4743
#ifdef ZTS
48-
# ifdef ZEND_EG_TLS
4944
extern ZEND_API TSRM_TLS TSRM_TLS_MODEL_ATTR zend_executor_globals executor_globals_tls;
50-
# define EG(v) (executor_globals_tls.v)
51-
# else
52-
# define EG(v) ZEND_TSRMG_FAST(executor_globals_offset, zend_executor_globals *, v)
53-
# endif
45+
# define EG(v) (executor_globals_tls.v)
5446
#else
5547
# define EG(v) (executor_globals.v)
5648
extern ZEND_API zend_executor_globals executor_globals;

ext/opcache/jit/zend_jit_ir.c

Lines changed: 10 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -201,56 +201,35 @@ static uint32_t default_mflags = 0;
201201
static bool delayed_call_chain = false; // TODO: remove this var (use jit->delayed_call_level) ???
202202

203203
#ifdef ZTS
204-
static size_t tsrm_ls_cache_tcb_offset = 0;
205-
static size_t tsrm_tls_index = -1;
206-
static size_t tsrm_tls_offset = -1;
207-
208-
# ifdef ZEND_EG_TLS
209-
/* When nonzero, &executor_globals_tls/&compiler_globals_tls equal the thread
210-
* pointer plus this offset, so the JIT forms them without a runtime call. */
211204
static size_t eg_tls_tcb_offset = 0;
212205
static size_t cg_tls_tcb_offset = 0;
213206
/* gottpoff yields the offset from the %fs-based thread pointer that ir_TLS(0)
214207
* loads. */
215-
# if defined(__ELF__) && defined(__x86_64__) && defined(__GNUC__) && !defined(TSRM_TLS_MODEL_DEFAULT)
216-
# define ZEND_JIT_TLS_TCB_OFFSET(sym) __extension__({ \
208+
# if defined(__ELF__) && defined(__x86_64__) && defined(__GNUC__) && !defined(TSRM_TLS_MODEL_DEFAULT)
209+
# define ZEND_JIT_TLS_TCB_OFFSET(sym) __extension__({ \
217210
size_t _off; \
218211
__asm__ ("movq " #sym "@gottpoff(%%rip),%0" : "=r" (_off)); \
219212
_off; \
220213
})
221-
# elif defined(__ELF__) && defined(__aarch64__) && !defined(__APPLE__) && \
214+
# elif defined(__ELF__) && defined(__aarch64__) && !defined(__APPLE__) && \
222215
(defined(__GNUC__) || defined(__clang__))
223216
/* The TLS variable sits at a fixed offset from tpidr_el0 (the thread pointer
224217
* the JIT reads with mrs); compute it once on the main thread. Subtracting the
225218
* thread pointer is model-independent (works for both local- and initial-exec)
226219
* and matches tsrm_get_ls_cache_tcb_offset()'s tprel reasoning. */
227-
# define ZEND_JIT_TLS_TCB_OFFSET(sym) __extension__({ \
220+
# define ZEND_JIT_TLS_TCB_OFFSET(sym) __extension__({ \
228221
char *_tp; \
229222
__asm__ ("mrs %0, tpidr_el0" : "=r" (_tp)); \
230223
(size_t)((char*)&(sym) - _tp); \
231224
})
232-
# else
233-
# define ZEND_JIT_TLS_TCB_OFFSET(sym) ((size_t)0)
234-
# endif
225+
# else
226+
# define ZEND_JIT_TLS_TCB_OFFSET(sym) ((size_t)0)
235227
# endif
236228

237-
# define EG_TLS_OFFSET(field) \
238-
(executor_globals_offset + offsetof(zend_executor_globals, field))
239-
240-
# define CG_TLS_OFFSET(field) \
241-
(compiler_globals_offset + offsetof(zend_compiler_globals, field))
242-
243-
# ifdef ZEND_EG_TLS
244-
# define jit_EG(_field) \
229+
# define jit_EG(_field) \
245230
ir_ADD_OFFSET(jit_EG_base(jit), offsetof(zend_executor_globals, _field))
246-
# define jit_CG(_field) \
231+
# define jit_CG(_field) \
247232
ir_ADD_OFFSET(jit_CG_base(jit), offsetof(zend_compiler_globals, _field))
248-
# else
249-
# define jit_EG(_field) \
250-
ir_ADD_OFFSET(jit_TLS(jit), EG_TLS_OFFSET(_field))
251-
# define jit_CG(_field) \
252-
ir_ADD_OFFSET(jit_TLS(jit), CG_TLS_OFFSET(_field))
253-
# endif
254233

255234
#else
256235

@@ -333,12 +312,9 @@ typedef struct _zend_jit_ctx {
333312
uint32_t delayed_call_level;
334313
int b; /* current basic block number or -1 */
335314
#ifdef ZTS
336-
ir_ref tls;
337-
# ifdef ZEND_EG_TLS
338315
ir_ref tp; /* cached thread pointer for &EG/&CG */
339316
ir_ref eg_tls; /* cached base of __thread executor_globals_tls */
340317
ir_ref cg_tls; /* cached base of __thread compiler_globals_tls */
341-
# endif
342318
#endif
343319
ir_ref fp;
344320
ir_ref poly_func_ref; /* restored from parent trace snapshot */
@@ -529,12 +505,6 @@ static const char* zend_reg_name(int8_t reg)
529505
/* IR helpers */
530506

531507
#ifdef ZTS
532-
static void * ZEND_FASTCALL zend_jit_get_tsrm_ls_cache(void)
533-
{
534-
return _tsrm_ls_cache;
535-
}
536-
537-
# ifdef ZEND_EG_TLS
538508
static void * ZEND_FASTCALL zend_jit_get_eg_tls(void)
539509
{
540510
return &executor_globals_tls;
@@ -583,44 +553,12 @@ static ir_ref jit_GLOBALS_TLS_call(zend_jit_ctx *jit, ir_ref *cache, const void
583553
}
584554
return *cache;
585555
}
586-
# define jit_EG_base(jit) (eg_tls_tcb_offset \
556+
# define jit_EG_base(jit) (eg_tls_tcb_offset \
587557
? ir_ADD_OFFSET(jit_TP(jit), eg_tls_tcb_offset) \
588558
: jit_GLOBALS_TLS_call((jit), &(jit)->eg_tls, zend_jit_get_eg_tls))
589-
# define jit_CG_base(jit) (cg_tls_tcb_offset \
559+
# define jit_CG_base(jit) (cg_tls_tcb_offset \
590560
? ir_ADD_OFFSET(jit_TP(jit), cg_tls_tcb_offset) \
591561
: jit_GLOBALS_TLS_call((jit), &(jit)->cg_tls, zend_jit_get_cg_tls))
592-
# endif
593-
594-
static ZEND_ATTRIBUTE_UNUSED ir_ref jit_TLS(zend_jit_ctx *jit)
595-
{
596-
ZEND_ASSERT(jit->ctx.control);
597-
if (jit->tls) {
598-
/* Emit "TLS" once for basic block */
599-
ir_insn *insn;
600-
ir_ref ref = jit->ctx.control;
601-
602-
while (1) {
603-
if (ref == jit->tls) {
604-
return jit->tls;
605-
}
606-
insn = &jit->ctx.ir_base[ref];
607-
if (insn->op >= IR_START || insn->op == IR_CALL) {
608-
break;
609-
}
610-
ref = insn->op1;
611-
}
612-
}
613-
614-
if (tsrm_ls_cache_tcb_offset == 0 && tsrm_tls_index == -1) {
615-
jit->tls = ir_CALL(IR_ADDR, ir_CONST_FC_FUNC(zend_jit_get_tsrm_ls_cache));
616-
} else {
617-
jit->tls = ir_TLS(
618-
tsrm_ls_cache_tcb_offset ? tsrm_ls_cache_tcb_offset : tsrm_tls_index,
619-
tsrm_ls_cache_tcb_offset ? IR_NULL : tsrm_tls_offset);
620-
}
621-
622-
return jit->tls;
623-
}
624562
#endif
625563

626564
static ir_ref jit_CONST_ADDR(zend_jit_ctx *jit, uintptr_t addr)
@@ -2917,12 +2855,9 @@ static void zend_jit_init_ctx(zend_jit_ctx *jit, uint32_t flags)
29172855
delayed_call_chain = false;
29182856
jit->b = -1;
29192857
#ifdef ZTS
2920-
jit->tls = IR_UNUSED;
2921-
# ifdef ZEND_EG_TLS
29222858
jit->tp = IR_UNUSED;
29232859
jit->eg_tls = IR_UNUSED;
29242860
jit->cg_tls = IR_UNUSED;
2925-
# endif
29262861
#endif
29272862
jit->fp = IR_UNUSED;
29282863
jit->poly_func_ref = IR_UNUSED;
@@ -3316,11 +3251,8 @@ static void zend_jit_setup_disasm(void)
33163251

33173252
REGISTER_DATA(CG(map_ptr_base));
33183253
#else /* ZTS */
3319-
REGISTER_HELPER(zend_jit_get_tsrm_ls_cache);
3320-
# ifdef ZEND_EG_TLS
33213254
REGISTER_HELPER(zend_jit_get_eg_tls);
33223255
REGISTER_HELPER(zend_jit_get_cg_tls);
3323-
# endif
33243256
#endif
33253257
#endif
33263258
}
@@ -3531,19 +3463,8 @@ static void zend_jit_setup(bool reattached)
35313463
#endif
35323464

35333465
#ifdef ZTS
3534-
zend_result result = zend_jit_resolve_tsrm_ls_cache_offsets(
3535-
&tsrm_ls_cache_tcb_offset,
3536-
&tsrm_tls_index,
3537-
&tsrm_tls_offset
3538-
);
3539-
if (result == FAILURE) {
3540-
zend_accel_error(ACCEL_LOG_INFO,
3541-
"Could not get _tsrm_ls_cache offsets, will fallback to runtime resolution");
3542-
}
3543-
# ifdef ZEND_EG_TLS
35443466
eg_tls_tcb_offset = ZEND_JIT_TLS_TCB_OFFSET(executor_globals_tls);
35453467
cg_tls_tcb_offset = ZEND_JIT_TLS_TCB_OFFSET(compiler_globals_tls);
3546-
# endif
35473468
#endif
35483469

35493470
#if !defined(ZEND_WIN32) && !defined(IR_TARGET_AARCH64)

0 commit comments

Comments
 (0)