Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
5af178b
perf: embed executor and compiler globals in the __thread TLS cache s…
henderkes Jul 14, 2026
6494cd5
fix typo
henderkes Jul 23, 2026
b8cc198
remove ts_allocate_fast_id_at again (unused, now that the four global…
henderkes Aug 11, 2026
de08f98
guard ts_apply_for_id and ts_free_id for own threads globals too
henderkes Aug 12, 2026
ad1345b
clarification
henderkes Aug 12, 2026
8c2f270
abort, rather than assert
henderkes Aug 12, 2026
56a83ca
largely revert jit, just offsetof self* in the tsrm struct
henderkes Aug 13, 2026
4f28aa3
LE guard for external embedders
henderkes Aug 13, 2026
8b5c693
drop unused TSRMLS_MAIN_CACHE_DEFINE()
henderkes Aug 20, 2026
54ce036
remove useless line
henderkes Aug 20, 2026
8ec8026
move GC globals into __thread storage too
henderkes Aug 20, 2026
dcf8fbe
feedback: teb slot needs _m_x64
henderkes Aug 27, 2026
1238c3b
feedback: precompute teb slot offset
henderkes Aug 27, 2026
7d66f72
feedback: move macros into tsrm.h
henderkes Aug 27, 2026
b893abc
feedback: add zend_tsrmg_direct macro
henderkes Aug 27, 2026
8bf2d99
feedback: move zend_win_tsrm_cache_init to tsrm.c
henderkes Aug 27, 2026
a6828cf
feedback: tsrm initializes tls slot
henderkes Aug 27, 2026
f0beb24
perf: non-volatile gs read on clang
henderkes Aug 27, 2026
9fb4fc4
fix tests
henderkes Aug 28, 2026
1f96e9c
fix gdb script
henderkes Aug 28, 2026
d730858
fall back to &_tsrm_ls_cache in case something blew the early TEB slo…
henderkes Aug 28, 2026
307b8cc
suggestion: TlsFree in case of dll unload or late-TEB fallback
henderkes Aug 28, 2026
c1123c1
use ir TLS_ADDR
henderkes Sep 21, 2026
4b270dd
cache index based tls jit too
henderkes Oct 13, 2026
b11b7b5
figure out linker relaxation for initial-exec
henderkes Oct 15, 2026
a40042e
fix old typo
henderkes Oct 15, 2026
8809b41
aarch64 too
henderkes Oct 15, 2026
aefbb93
no surplus case gets global dynamic model
henderkes Oct 15, 2026
47ee7c8
remove forward declaration
henderkes Oct 28, 2026
c5c8866
simplify jit?
henderkes Oct 28, 2026
5367efc
drop Windows TEB fast path, cherry-pick this later in a follow-up PR
henderkes Oct 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions .gdbinit
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@ define set_ts
end

document set_ts
set the ts resource, it is impossible for gdb to
call ts_resource_ex while no process is running,
but we could get the resource from the argument
of frame info.
set a legacy TSRM resource cache pointer when it is available
from a frame argument. Pass 0 to use the current thread's
direct executor and compiler globals.
end

define ____executor_globals
if basic_functions_module.zts
set $tsrm_ls = _tsrm_ls_cache
set $eg = ((zend_executor_globals*) (*((void ***) $tsrm_ls))[executor_globals_id-1])
set $cg = ((zend_compiler_globals*) (*((void ***) $tsrm_ls))[compiler_globals_id-1])
set $eg_ptr = $eg
if !$tsrm_ls
set $eg = _tsrm_ls_cache.eg
set $cg = _tsrm_ls_cache.cg
set $eg_ptr = (zend_executor_globals*) &_tsrm_ls_cache.eg
else
set $eg = ((zend_executor_globals*) (*((void ***) $tsrm_ls))[executor_globals_id-1])
set $cg = ((zend_compiler_globals*) (*((void ***) $tsrm_ls))[compiler_globals_id-1])
set $eg_ptr = $eg
end
else
set $eg = executor_globals
set $cg = compiler_globals
Expand Down
44 changes: 8 additions & 36 deletions TSRM/TSRM.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ static int resource_types_table_size;
/* Reserved space for fast globals access */
static size_t tsrm_reserved_pos = 0;
static size_t tsrm_reserved_size = 0;
static size_t tsrm_reserved_front = 0;

static MUTEX_T tsmm_mutex; /* thread-safe memory manager mutex */
static MUTEX_T tsrm_env_mutex; /* tsrm environ mutex */
Expand Down Expand Up @@ -168,7 +167,6 @@ TSRM_API bool tsrm_startup(int expected_threads, int expected_resources, int deb

tsrm_reserved_pos = 0;
tsrm_reserved_size = 0;
tsrm_reserved_front = 0;

tsrm_env_mutex = tsrm_mutex_alloc();
tsrm_atexit_init();
Expand Down Expand Up @@ -229,7 +227,7 @@ TSRM_API void tsrm_shutdown(void)
} else {
free(p->storage);
}
free((char *) p - tsrm_reserved_front);
free(p);
p = next_p;
}
}
Expand Down Expand Up @@ -261,7 +259,6 @@ TSRM_API void tsrm_shutdown(void)

tsrm_reserved_pos = 0;
tsrm_reserved_size = 0;
tsrm_reserved_front = 0;
}/*}}}*/

/* {{{ */
Expand Down Expand Up @@ -354,19 +351,10 @@ TSRM_API void tsrm_reserve(size_t size)
}/*}}}*/


/* Carve a fixed-offset front region out of the reserved space. It is placed
* before the TLS entry, so the hot globals get compile-time-constant negative
* offsets from the cache pointer. */
TSRM_API void tsrm_reserve_fast_front(size_t size)
{
tsrm_reserved_front = TSRM_ALIGNED_SIZE(size);
tsrm_reserved_size -= tsrm_reserved_front;
}


/* allocates a new fast thread-safe-resource id */
TSRM_API ts_rsrc_id ts_allocate_fast_id(ts_rsrc_id *rsrc_id, size_t *offset, size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor)
{/*{{{*/
TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Obtaining a new fast resource id, %d bytes", size));
tsrm_mutex_lock(tsmm_mutex);
size = TSRM_ALIGNED_SIZE(size);
if (tsrm_reserved_size - tsrm_reserved_pos < size) {
Expand All @@ -376,27 +364,13 @@ TSRM_API ts_rsrc_id ts_allocate_fast_id(ts_rsrc_id *rsrc_id, size_t *offset, siz
tsrm_mutex_unlock(tsmm_mutex);
return 0;
}
ptrdiff_t fixed_offset = TSRM_ALIGNED_SIZE(sizeof(tsrm_tls_entry)) + tsrm_reserved_pos;
*offset = TSRM_ALIGNED_SIZE(sizeof(tsrm_tls_entry)) + tsrm_reserved_pos;
tsrm_reserved_pos += size;
tsrm_mutex_unlock(tsmm_mutex);

return ts_allocate_fast_id_at(rsrc_id, offset, fixed_offset, size, ctor, dtor);
}/*}}}*/


TSRM_API ts_rsrc_id ts_allocate_fast_id_at(ts_rsrc_id *rsrc_id, size_t *offset, ptrdiff_t fixed_offset, size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor)
{
TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Obtaining a new fast resource id, %d bytes", size));

tsrm_mutex_lock(tsmm_mutex);

/* obtain a resource id */
*rsrc_id = TSRM_SHUFFLE_RSRC_ID(id_count++);
TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Obtained resource id %d", *rsrc_id));

size = TSRM_ALIGNED_SIZE(size);
*offset = (size_t) fixed_offset;

/* store the new resource type in the resource sizes table */
if (resource_types_table_size < id_count) {
tsrm_resource_type *_tmp;
Expand All @@ -423,7 +397,7 @@ TSRM_API ts_rsrc_id ts_allocate_fast_id_at(ts_rsrc_id *rsrc_id, size_t *offset,

TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Successfully allocated new resource id %d", *rsrc_id));
return *rsrc_id;
}
}/*}}}*/

/* allocates a resource id whose per-thread storage is a native __thread block */
TSRM_API ts_rsrc_id ts_allocate_tls_id(ts_rsrc_id *rsrc_id, void *(*tls_addr)(void), size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor)
Expand Down Expand Up @@ -471,10 +445,8 @@ static void set_thread_local_storage_resource_to(tsrm_tls_entry *thread_resource
static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_T thread_id)
{/*{{{*/
TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Creating data structures for thread %x", thread_id));
/* The entry follows the fixed-offset front region.
* hot globals live at negative offsets from the TLS cache pointer. */
char *block = (char *) malloc(tsrm_reserved_front + TSRM_ALIGNED_SIZE(sizeof(tsrm_tls_entry)) + tsrm_reserved_size);
(*thread_resources_ptr) = (tsrm_tls_entry *) (block + tsrm_reserved_front);
/* Fast resources live in the reserved space right behind the entry. */
(*thread_resources_ptr) = (tsrm_tls_entry *) malloc(TSRM_ALIGNED_SIZE(sizeof(tsrm_tls_entry)) + tsrm_reserved_size);
(*thread_resources_ptr)->storage = NULL;
if (id_count > 0) {
(*thread_resources_ptr)->storage = (void **) malloc(sizeof(void *)*id_count);
Expand Down Expand Up @@ -587,7 +559,7 @@ TSRM_API void *ts_resource_ex(ts_rsrc_id id, THREAD_T *th_id)
/* The dead thread's native TLS is gone, and its remaining resource dtors
* may depend on those globals. Only release directly owned allocations. */
ts_free_resources(thread_resources, false, false);
free((char *) thread_resources - tsrm_reserved_front);
free(thread_resources);
/* Allocate a new resource at the same point in the linked list, and relink the next pointer */
allocate_new_resource(last_thread_resources, thread_id);
thread_resources = *last_thread_resources;
Expand Down Expand Up @@ -640,7 +612,7 @@ void ts_free_thread(void)
tsrm_atexit_set_data(NULL);
TSRMLS_CACHE = NULL;
if (thread_resources) {
free((char *) thread_resources - tsrm_reserved_front);
free(thread_resources);
}
tsrm_mutex_unlock(tsmm_mutex);
}/*}}}*/
Expand Down
46 changes: 32 additions & 14 deletions TSRM/TSRM.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@ TSRM_API ts_rsrc_id ts_allocate_id(ts_rsrc_id *rsrc_id, size_t size, ts_allocate
TSRM_API void tsrm_reserve(size_t size);
TSRM_API ts_rsrc_id ts_allocate_fast_id(ts_rsrc_id *rsrc_id, size_t *offset, size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor);

/* Fast resources at caller-chosen, compile-time-constant offsets. The fixed
* front region must be reserved after tsrm_reserve() and before any fast id. */
TSRM_API void tsrm_reserve_fast_front(size_t size);
TSRM_API ts_rsrc_id ts_allocate_fast_id_at(ts_rsrc_id *rsrc_id, size_t *offset, ptrdiff_t fixed_offset, size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor);

/* Resource whose per-thread storage is a native __thread block.
* Must be called at startup before any other thread exists. */
TSRM_API ts_rsrc_id ts_allocate_tls_id(ts_rsrc_id *rsrc_id, void *(*tls_addr)(void), size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor);
Expand Down Expand Up @@ -168,7 +163,7 @@ TSRM_API bool tsrm_is_managed_thread(void);
|| defined(__MUSL__) || defined(__HAIKU__) || defined(_AIX)
# define TSRM_TLS_MODEL_ATTR
# define TSRM_TLS_MODEL_DEFAULT
#elif defined(__PIC__) && !defined(__PIE__)
#elif (defined(__PIC__) && !defined(__PIE__)) || !defined(ZEND_ENABLE_STATIC_TSRMLS_CACHE)
# if defined(TSRM_TLS_MODEL_USE_DEFAULT)
# define TSRM_TLS_MODEL_ATTR
# define TSRM_TLS_MODEL_DEFAULT
Expand All @@ -193,17 +188,41 @@ TSRM_API bool tsrm_is_managed_thread(void);
#define TSRMG_BULK_STATIC(id, type) ((type) (*((void ***) TSRMLS_CACHE))[TSRM_UNSHUFFLE_RSRC_ID(id)])
Comment thread
henderkes marked this conversation as resolved.
#define TSRMG_FAST_STATIC(offset, type, element) (TSRMG_FAST_BULK_STATIC(offset, type)->element)
#define TSRMG_FAST_BULK_STATIC(offset, type) ((type) (((char*) TSRMLS_CACHE)+(offset)))

/* Windows can't dllexport __declspec(thread) symbols, so outside Zend each module
* keeps a per-module `void *` pointer and reaches EG/CG via the resource-id indirection. */
#ifdef ZEND_WIN32
# define ZEND_TLS_API
# ifdef LIBZEND_EXPORTS
# define ZEND_TLS_DIRECT 1
# endif
#else
# define ZEND_TLS_API ZEND_API
# define ZEND_TLS_DIRECT 1
#endif

typedef struct _zend_tsrm_ls_cache zend_tsrm_ls_cache;

#ifdef ZEND_TLS_DIRECT
# define ZEND_TSRMLS_CACHE_T zend_tsrm_ls_cache
# define TSRMLS_CACHE_DEFINE()
extern ZEND_TLS_API TSRM_TLS TSRM_TLS_MODEL_ATTR zend_tsrm_ls_cache _tsrm_ls_cache;
# define ZEND_TSRM_CACHE_PTR (&_tsrm_ls_cache)
# define ZEND_TSRMG_DIRECT(id, type, member, element) (ZEND_TSRM_CACHE_PTR->member.element)
#else
# define ZEND_TSRMLS_CACHE_T void *
# define TSRMLS_CACHE_DEFINE() TSRM_TLS void *_tsrm_ls_cache = NULL;
# define ZEND_TSRMG_DIRECT(id, type, member, element) ZEND_TSRMG(id, type, element)
#endif
#ifdef __cplusplus
#define TSRMLS_MAIN_CACHE_EXTERN() extern "C" { extern TSRM_TLS void *TSRMLS_CACHE TSRM_TLS_MODEL_ATTR; }
#define TSRMLS_CACHE_EXTERN() extern "C" { extern TSRM_TLS void *TSRMLS_CACHE; }
#define TSRMLS_MAIN_CACHE_EXTERN() extern "C" { extern TSRM_TLS ZEND_TSRMLS_CACHE_T _tsrm_ls_cache TSRM_TLS_MODEL_ATTR; }
#define TSRMLS_CACHE_EXTERN() extern "C" { extern TSRM_TLS ZEND_TSRMLS_CACHE_T _tsrm_ls_cache; }
#else
#define TSRMLS_MAIN_CACHE_EXTERN() extern TSRM_TLS void *TSRMLS_CACHE TSRM_TLS_MODEL_ATTR;
#define TSRMLS_CACHE_EXTERN() extern TSRM_TLS void *TSRMLS_CACHE;
#define TSRMLS_MAIN_CACHE_EXTERN() extern TSRM_TLS ZEND_TSRMLS_CACHE_T _tsrm_ls_cache TSRM_TLS_MODEL_ATTR;
#define TSRMLS_CACHE_EXTERN() extern TSRM_TLS ZEND_TSRMLS_CACHE_T _tsrm_ls_cache;
#endif
#define TSRMLS_MAIN_CACHE_DEFINE() TSRM_TLS void *TSRMLS_CACHE TSRM_TLS_MODEL_ATTR = NULL;
#define TSRMLS_CACHE_DEFINE() TSRM_TLS void *TSRMLS_CACHE = NULL;
#define TSRMLS_CACHE_UPDATE() TSRMLS_CACHE = tsrm_get_ls_cache()
#define TSRMLS_CACHE _tsrm_ls_cache
#define TSRMLS_CACHE (*(void **) &_tsrm_ls_cache)

#ifdef __cplusplus
}
Expand All @@ -216,7 +235,6 @@ TSRM_API bool tsrm_is_managed_thread(void);

#define TSRMG_STATIC(id, type, element)
#define TSRMLS_MAIN_CACHE_EXTERN()
#define TSRMLS_MAIN_CACHE_DEFINE()
#define TSRMLS_CACHE_EXTERN()
#define TSRMLS_CACHE_DEFINE()
#define TSRMLS_CACHE_UPDATE()
Expand Down
2 changes: 2 additions & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ PHP 8.7 INTERNALS UPGRADE NOTES
allowed anymore. User-facing HashTables must have pDestructor = ZVAL_PTR_DTOR
or NULL, and must be freed with zend_array_destroy(). Other HashTables can be
freed with zend_hash_destroy() + pefree().
- The ZTS symbols compiler_globals_offset and executor_globals_offset have been
removed: CG()/EG() now reach the globals through a __thread struct.

========================
2. Build system changes
Expand Down
12 changes: 5 additions & 7 deletions Zend/zend.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ static bool startup_done = false;
#ifdef ZTS
ZEND_API int compiler_globals_id;
ZEND_API int executor_globals_id;
ZEND_API size_t compiler_globals_offset;
ZEND_API size_t executor_globals_offset;
ZEND_TLS_API TSRM_TLS TSRM_TLS_MODEL_ATTR zend_tsrm_ls_cache _tsrm_ls_cache = {0};
/* ts_allocate_tls_id takes a callback so each thread resolves its own block.
* A plain &language_scanner_globals would capture only the registering thread's address. */
static void *executor_globals_tls_addr(void) { return &_tsrm_ls_cache.eg; }
static void *compiler_globals_tls_addr(void) { return &_tsrm_ls_cache.cg; }
static void *language_scanner_globals_tls_addr(void) { return &language_scanner_globals; }
static HashTable *global_function_table = NULL;
static HashTable *global_class_table = NULL;
static HashTable *global_constants_table = NULL;
static HashTable *global_auto_globals_table = NULL;
TSRMLS_MAIN_CACHE_DEFINE()
# define GLOBAL_FUNCTION_TABLE global_function_table
# define GLOBAL_CLASS_TABLE global_class_table
# define GLOBAL_CONSTANTS_TABLE global_constants_table
Expand Down Expand Up @@ -1031,11 +1031,9 @@ void zend_startup(zend_utility_functions *utility_functions) /* {{{ */
zend_init_rsrc_list_dtors();

#ifdef ZTS
ts_allocate_fast_id_at(&compiler_globals_id, &compiler_globals_offset, ZEND_CG_OFFSET, sizeof(zend_compiler_globals), (ts_allocate_ctor) compiler_globals_ctor, (ts_allocate_dtor) compiler_globals_dtor);
ts_allocate_fast_id_at(&executor_globals_id, &executor_globals_offset, ZEND_EG_OFFSET, sizeof(zend_executor_globals), (ts_allocate_ctor) executor_globals_ctor, (ts_allocate_dtor) executor_globals_dtor);
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);
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);
Comment thread
henderkes marked this conversation as resolved.
ts_allocate_tls_id(&language_scanner_globals_id, language_scanner_globals_tls_addr, sizeof(zend_php_scanner_globals), (ts_allocate_ctor) php_scanner_globals_ctor, NULL);
ZEND_ASSERT(compiler_globals_offset == ZEND_CG_OFFSET);
ZEND_ASSERT(executor_globals_offset == ZEND_EG_OFFSET);
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);
compiler_globals = ts_resource(compiler_globals_id);
executor_globals = ts_resource(executor_globals_id);
Expand Down
15 changes: 4 additions & 11 deletions Zend/zend_gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,12 @@ typedef struct _zend_gc_globals {

#ifdef ZTS
static int gc_globals_id;
Comment thread
henderkes marked this conversation as resolved.
static size_t gc_globals_offset;
#define GC_G(v) ZEND_TSRMG_FAST(gc_globals_offset, zend_gc_globals *, v)
static TSRM_TLS TSRM_TLS_MODEL_ATTR zend_gc_globals gc_globals;
static void *gc_globals_tls_addr(void) { return &gc_globals; }
#else
#define GC_G(v) (gc_globals.v)
static zend_gc_globals gc_globals;
#endif
#define GC_G(v) (gc_globals.v)

#if GC_BENCH
# define GC_BENCH_INC(counter) GC_G(counter)++
Expand Down Expand Up @@ -549,7 +549,7 @@ static void gc_globals_ctor_ex(zend_gc_globals *gc_globals)
void gc_globals_ctor(void)
{
#ifdef ZTS
ts_allocate_fast_id(&gc_globals_id, &gc_globals_offset, sizeof(zend_gc_globals), (ts_allocate_ctor) gc_globals_ctor_ex, (ts_allocate_dtor) root_buffer_dtor);
ts_allocate_tls_id(&gc_globals_id, gc_globals_tls_addr, sizeof(zend_gc_globals), (ts_allocate_ctor) gc_globals_ctor_ex, (ts_allocate_dtor) root_buffer_dtor);
#else
gc_globals_ctor_ex(&gc_globals);
#endif
Expand Down Expand Up @@ -2322,13 +2322,6 @@ void gc_bench_print(void)
}
#endif

#ifdef ZTS
size_t zend_gc_globals_size(void)
{
return sizeof(zend_gc_globals);
}
#endif

static ZEND_FUNCTION(gc_destructor_fiber)
{
uint32_t idx, end;
Expand Down
4 changes: 0 additions & 4 deletions Zend/zend_gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ void gc_globals_ctor(void);
void gc_globals_dtor(void);
void gc_reset(void);

#ifdef ZTS
size_t zend_gc_globals_size(void);
#endif

#define GC_REMOVE_FROM_BUFFER(p) do { \
zend_refcounted *_p = (zend_refcounted*)(p); \
if (GC_TYPE_INFO(_p) & GC_INFO_MASK) { \
Expand Down
10 changes: 5 additions & 5 deletions Zend/zend_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@
BEGIN_EXTERN_C()
ZEND_API extern int compiler_globals_id;
ZEND_API extern int executor_globals_id;
ZEND_API extern size_t compiler_globals_offset;
ZEND_API extern size_t executor_globals_offset;
END_EXTERN_C()

#endif
Expand Down Expand Up @@ -342,9 +340,11 @@ struct _zend_executor_globals {
};

#ifdef ZTS
/* Compile-time offsets of the hot globals, in a reserved region just before *_tsrm_ls_cache. */
# define ZEND_CG_OFFSET (-(ptrdiff_t) TSRM_ALIGNED_SIZE(sizeof(zend_compiler_globals)))
# define ZEND_EG_OFFSET (ZEND_CG_OFFSET - (ptrdiff_t) TSRM_ALIGNED_SIZE(sizeof(zend_executor_globals)))
struct _zend_tsrm_ls_cache {
void *cache;
zend_executor_globals eg;
zend_compiler_globals cg;
};
#endif

#define EG_FLAGS_INITIAL (0)
Expand Down
12 changes: 6 additions & 6 deletions Zend/zend_globals_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ BEGIN_EXTERN_C()

/* Compiler */
#ifdef ZTS
# define CG(v) ZEND_TSRMG_FAST(ZEND_CG_OFFSET, zend_compiler_globals *, v)
# define CG(v) ZEND_TSRMG_DIRECT(compiler_globals_id, zend_compiler_globals *, cg, v)
#else
# define CG(v) (compiler_globals.v)
extern ZEND_API struct _zend_compiler_globals compiler_globals;
Expand All @@ -40,7 +40,7 @@ ZEND_API int zendparse(void);

/* Executor */
#ifdef ZTS
# define EG(v) ZEND_TSRMG_FAST(ZEND_EG_OFFSET, zend_executor_globals *, v)
# define EG(v) ZEND_TSRMG_DIRECT(executor_globals_id, zend_executor_globals *, eg, v)
#else
# define EG(v) (executor_globals.v)
extern ZEND_API zend_executor_globals executor_globals;
Expand All @@ -49,15 +49,15 @@ extern ZEND_API zend_executor_globals executor_globals;
/* Language Scanner */
#ifdef ZTS
extern ZEND_API ts_rsrc_id language_scanner_globals_id;
# if defined(ZEND_WIN32) && !defined(LIBZEND_EXPORTS)
# define LANG_SCNG(v) TSRMG(language_scanner_globals_id, zend_php_scanner_globals *, v)
# else
# ifdef ZEND_TLS_DIRECT
# ifdef ZEND_WIN32
extern TSRM_TLS zend_php_scanner_globals language_scanner_globals;
# else
extern ZEND_API TSRM_TLS TSRM_TLS_MODEL_ATTR zend_php_scanner_globals language_scanner_globals;
extern ZEND_TLS_API TSRM_TLS TSRM_TLS_MODEL_ATTR zend_php_scanner_globals language_scanner_globals;
# endif
# define LANG_SCNG(v) (language_scanner_globals.v)
# else
# define LANG_SCNG(v) TSRMG(language_scanner_globals_id, zend_php_scanner_globals *, v)
# endif
#else
extern ZEND_API zend_php_scanner_globals language_scanner_globals;
Expand Down
Loading
Loading