Skip to content

Commit 4358e7d

Browse files
committed
Merge branch 'master' into jit-dynasm
* master: Better data packing Avoid reinitailization of ZTS cache pointer. Initialize it once in TSRM.c Fixed ZTS cache usage Fixed ZTS cache usage Fixed ZTS cache usage Fixed ZTS cache usage Switch to use ZTS cache Cleanup unused module globals Fixed ZTS cache usage Fixed bug #77722 add --enable-rtld-now in upgrade info use DL_LOAD in litespeed add --enable-rtld-now build option to change dlopen behavior
2 parents ae158c0 + 4111daf commit 4358e7d

Some content is hidden

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

58 files changed

+142
-184
lines changed

TSRM/TSRM.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919

2020
typedef struct _tsrm_tls_entry tsrm_tls_entry;
2121

22-
#if defined(TSRM_WIN32)
2322
/* TSRMLS_CACHE_DEFINE; is already done in Zend, this is being always compiled statically. */
24-
#endif
23+
TSRMLS_CACHE_EXTERN();
2524

2625
struct _tsrm_tls_entry {
2726
void **storage;
@@ -300,6 +299,7 @@ static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_
300299

301300
/* Set thread local storage to this new thread resources structure */
302301
tsrm_tls_set(*thread_resources_ptr);
302+
TSRMLS_CACHE = *thread_resources_ptr;
303303

304304
if (tsrm_new_thread_begin_handler) {
305305
tsrm_new_thread_begin_handler(thread_id);

Zend/zend.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,6 @@ static void compiler_globals_dtor(zend_compiler_globals *compiler_globals) /* {{
679679

680680
static void executor_globals_ctor(zend_executor_globals *executor_globals) /* {{{ */
681681
{
682-
ZEND_TSRMLS_CACHE_UPDATE();
683-
684682
zend_startup_constants();
685683
zend_copy_constants(executor_globals->zend_constants, GLOBAL_CONSTANTS_TABLE);
686684
zend_init_rsrc_plist();
@@ -780,7 +778,6 @@ int zend_startup(zend_utility_functions *utility_functions) /* {{{ */
780778
zend_executor_globals *executor_globals;
781779
extern ZEND_API ts_rsrc_id ini_scanner_globals_id;
782780
extern ZEND_API ts_rsrc_id language_scanner_globals_id;
783-
ZEND_TSRMLS_CACHE_UPDATE();
784781
#else
785782
extern zend_ini_scanner_globals ini_scanner_globals;
786783
extern zend_php_scanner_globals language_scanner_globals;

Zend/zend_alloc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2723,7 +2723,6 @@ static void alloc_globals_ctor(zend_alloc_globals *alloc_globals)
27232723
if (tmp && zend_atoi(tmp, 0)) {
27242724
zend_mm_use_huge_pages = 1;
27252725
}
2726-
ZEND_TSRMLS_CACHE_UPDATE();
27272726
alloc_globals->mm_heap = zend_mm_init();
27282727
}
27292728

Zend/zend_gc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,13 @@ typedef struct _gc_root_buffer {
183183
} gc_root_buffer;
184184

185185
typedef struct _zend_gc_globals {
186+
gc_root_buffer *buf; /* preallocated arrays of buffers */
187+
186188
zend_bool gc_enabled;
187189
zend_bool gc_active; /* GC currently running, forbid nested GC */
188190
zend_bool gc_protected; /* GC protected, forbid root additions */
189191
zend_bool gc_full;
190192

191-
gc_root_buffer *buf; /* preallocated arrays of buffers */
192193
uint32_t unused; /* linked list of unused buffers */
193194
uint32_t first_unused; /* first unused buffer */
194195
uint32_t gc_threshold; /* GC collection threshold */

Zend/zend_portability.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,18 @@
139139
# define RTLD_GLOBAL 0
140140
# endif
141141

142+
# ifdef PHP_USE_RTLD_NOW
143+
# define PHP_RTLD_MODE RTLD_NOW
144+
# else
145+
# define PHP_RTLD_MODE RTLD_LAZY
146+
# endif
147+
142148
# if defined(RTLD_GROUP) && defined(RTLD_WORLD) && defined(RTLD_PARENT)
143-
# define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL | RTLD_GROUP | RTLD_WORLD | RTLD_PARENT)
149+
# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_GROUP | RTLD_WORLD | RTLD_PARENT)
144150
# elif defined(RTLD_DEEPBIND) && !defined(__SANITIZE_ADDRESS__)
145-
# define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL | RTLD_DEEPBIND)
151+
# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_DEEPBIND)
146152
# else
147-
# define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL)
153+
# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL)
148154
# endif
149155
# define DL_UNLOAD dlclose
150156
# if defined(DLSYM_NEEDS_UNDERSCORE)

Zend/zend_signal.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ void zend_signal_handler_defer(int signo, siginfo_t *siginfo, void *context)
8787
zend_bool is_handling_safe = 1;
8888

8989
#ifdef ZTS
90-
ZEND_TSRMLS_CACHE_UPDATE();
9190
/* A signal could hit after TSRM shutdown, in this case globals are already freed. */
9291
if (NULL == TSRMLS_CACHE || NULL == TSRMG_BULK_STATIC(zend_signal_globals_id, zend_signal_globals_t *)) {
9392
is_handling_safe = 0;

configure.ac

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,17 @@ else
928928
ZEND_DEBUG=no
929929
fi
930930

931+
PHP_ARG_ENABLE([rtld-now],
932+
[whether to dlopen extensions with RTLD_NOW instead of RTLD_LAZY],
933+
[AS_HELP_STRING([--enable-rtld-now],
934+
[Use dlopen with RTLD_NOW instead of RTLD_LAZY])],
935+
[no],
936+
[no])
937+
938+
if test "$PHP_RTLD_NOW" = "yes"; then
939+
AC_DEFINE(PHP_USE_RTLD_NOW, 1, [ Use dlopen with RTLD_NOW instead of RTLD_LAZY ])
940+
fi
941+
931942
PHP_ARG_WITH([layout],
932943
[layout of installed files],
933944
[AS_HELP_STRING([--with-layout=TYPE],

ext/dba/config.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ if test "$HAVE_DBA" = "1"; then
700700
AC_MSG_RESULT([yes])
701701
fi
702702
AC_DEFINE(HAVE_DBA, 1, [ ])
703-
PHP_NEW_EXTENSION(dba, dba.c dba_cdb.c dba_dbm.c dba_gdbm.c dba_ndbm.c dba_db1.c dba_db2.c dba_db3.c dba_db4.c dba_flatfile.c dba_inifile.c dba_qdbm.c dba_tcadb.c dba_lmdb.c $cdb_sources $flat_sources $ini_sources, $ext_shared)
703+
PHP_NEW_EXTENSION(dba, dba.c dba_cdb.c dba_dbm.c dba_gdbm.c dba_ndbm.c dba_db1.c dba_db2.c dba_db3.c dba_db4.c dba_flatfile.c dba_inifile.c dba_qdbm.c dba_tcadb.c dba_lmdb.c $cdb_sources $flat_sources $ini_sources, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
704704
PHP_ADD_BUILD_DIR($ext_builddir/libinifile)
705705
PHP_ADD_BUILD_DIR($ext_builddir/libcdb)
706706
PHP_ADD_BUILD_DIR($ext_builddir/libflatfile)

ext/dba/config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ARG_WITH("db", "DBA: Berkeley DB support", "no");
66
ARG_WITH("lmdb", "DBA: Lightning memory-mapped database support", "no");
77

88
if (PHP_DBA != "no") {
9-
EXTENSION("dba", "dba.c dba_cdb.c dba_db1.c dba_db2.c dba_db3.c dba_dbm.c dba_flatfile.c dba_gdbm.c dba_ndbm.c dba_inifile.c");
9+
EXTENSION("dba", "dba.c dba_cdb.c dba_db1.c dba_db2.c dba_db3.c dba_dbm.c dba_flatfile.c dba_gdbm.c dba_ndbm.c dba_inifile.c", null, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
1010
ADD_SOURCES("ext/dba/libcdb", "cdb.c cdb_make.c uint32.c", "dba");
1111
ADD_SOURCES("ext/dba/libflatfile", "flatfile.c", "dba");
1212
ADD_SOURCES("ext/dba/libinifile", "inifile.c", "dba");

ext/dba/dba.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,7 @@ ZEND_END_MODULE_GLOBALS(dba)
160160

161161
ZEND_DECLARE_MODULE_GLOBALS(dba)
162162

163-
#ifdef ZTS
164-
#define DBA_G(v) TSRMG(dba_globals_id, zend_dba_globals *, v)
165-
#else
166-
#define DBA_G(v) (dba_globals.v)
167-
#endif
163+
#define DBA_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(dba, v)
168164

169165
static PHP_GINIT_FUNCTION(dba);
170166

@@ -186,6 +182,9 @@ zend_module_entry dba_module_entry = {
186182
};
187183

188184
#ifdef COMPILE_DL_DBA
185+
#ifdef ZTS
186+
ZEND_TSRMLS_CACHE_DEFINE()
187+
#endif
189188
ZEND_GET_MODULE(dba)
190189
#endif
191190

@@ -515,6 +514,9 @@ PHP_INI_END()
515514
*/
516515
static PHP_GINIT_FUNCTION(dba)
517516
{
517+
#if defined(COMPILE_DL_DBA) && defined(ZTS)
518+
ZEND_TSRMLS_CACHE_UPDATE();
519+
#endif
518520
dba_globals->default_handler = "";
519521
dba_globals->default_hptr = NULL;
520522
}

0 commit comments

Comments
 (0)