Repository navigation
move remaining globals into native tls storage #25277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,8 +81,9 @@ MUTEX_T cwd_mutex; | |
| #endif | ||
|
|
||
| #ifdef ZTS | ||
| ts_rsrc_id cwd_globals_id; | ||
| size_t cwd_globals_offset; | ||
| CWD_API ts_rsrc_id cwd_globals_id; | ||
| ZEND_TLS_API TSRM_TLS TSRM_TLS_MODEL_ATTR virtual_cwd_globals cwd_globals; | ||
| static void *cwd_globals_tls_addr(void) { return &cwd_globals; } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto (not API) |
||
| #else | ||
| virtual_cwd_globals cwd_globals; | ||
| #endif | ||
|
|
@@ -204,7 +205,7 @@ CWD_API void virtual_cwd_startup(void) /* {{{ */ | |
| { | ||
| virtual_cwd_main_cwd_init(0); | ||
| #ifdef ZTS | ||
| ts_allocate_fast_id(&cwd_globals_id, &cwd_globals_offset, sizeof(virtual_cwd_globals), (ts_allocate_ctor) cwd_globals_ctor, (ts_allocate_dtor) cwd_globals_dtor); | ||
| ts_allocate_tls_id(&cwd_globals_id, cwd_globals_tls_addr, sizeof(virtual_cwd_globals), (ts_allocate_ctor) cwd_globals_ctor, (ts_allocate_dtor) cwd_globals_dtor); | ||
| #else | ||
| cwd_globals_ctor(&cwd_globals); | ||
| #endif | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,8 +47,9 @@ | |
| #endif | ||
|
|
||
| #ifdef ZTS | ||
| int jit_globals_id; | ||
| size_t jit_globals_offset; | ||
| ZEND_API int jit_globals_id; | ||
| ZEND_TLS_API TSRM_TLS TSRM_TLS_MODEL_ATTR zend_jit_globals jit_globals; | ||
|
Comment on lines
+50
to
+51
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's fine removing the In zend_jit.h, we can assume ZEND_TLS_DIRECT as these globals are not accessed by other modules. Ditto for ext/opcache/ZendAccelerator.c / ext/opcache/ZendAccelerator.h. |
||
| static void *jit_globals_tls_addr(void) { return &jit_globals; } | ||
| #else | ||
| zend_jit_globals jit_globals; | ||
| #endif | ||
|
|
@@ -3770,7 +3771,7 @@ int zend_jit_debug_config(zend_long old_val, zend_long new_val, int stage) | |
| void zend_jit_init(void) | ||
| { | ||
| #ifdef ZTS | ||
| jit_globals_id = ts_allocate_fast_id(&jit_globals_id, &jit_globals_offset, sizeof(zend_jit_globals), (ts_allocate_ctor) zend_jit_globals_ctor, (ts_allocate_dtor) zend_jit_globals_dtor); | ||
| jit_globals_id = ts_allocate_tls_id(&jit_globals_id, jit_globals_tls_addr, sizeof(zend_jit_globals), (ts_allocate_ctor) zend_jit_globals_ctor, (ts_allocate_dtor) zend_jit_globals_dtor); | ||
| #else | ||
| zend_jit_globals_ctor(&jit_globals); | ||
| #endif | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -96,7 +96,8 @@ PHPAPI int (*php_register_internal_extensions_func)(void) = php_register_interna | |
| php_core_globals core_globals; | ||
| #else | ||
| PHPAPI int core_globals_id; | ||
| PHPAPI size_t core_globals_offset; | ||
| ZEND_TLS_API TSRM_TLS TSRM_TLS_MODEL_ATTR php_core_globals core_globals; | ||
| static void *core_globals_tls_addr(void) { return &core_globals; } | ||
| #endif | ||
|
|
||
| #define SAFE_FILENAME(f) ((f)?(f):"-") | ||
|
|
@@ -2214,7 +2215,7 @@ zend_result php_module_startup(sapi_module_struct *sf, zend_module_entry *additi | |
| php_output_startup(); | ||
|
|
||
| #ifdef ZTS | ||
| ts_allocate_fast_id(&core_globals_id, &core_globals_offset, sizeof(php_core_globals), (ts_allocate_ctor) core_globals_ctor, (ts_allocate_dtor) core_globals_dtor); | ||
| ts_allocate_tls_id(&core_globals_id, core_globals_tls_addr, sizeof(php_core_globals), (ts_allocate_ctor) core_globals_ctor, (ts_allocate_dtor) core_globals_dtor); | ||
| #ifdef PHP_WIN32 | ||
| ts_allocate_id(&php_win32_core_globals_id, sizeof(php_win32_core_globals), (ts_allocate_ctor) php_win32_core_globals_ctor, (ts_allocate_dtor) php_win32_core_globals_dtor); | ||
| #endif | ||
|
|
@@ -2794,32 +2795,9 @@ PHPAPI zend_result php_lint_script(zend_file_handle *file) | |
| /* }}} */ | ||
|
|
||
| #ifdef ZTS | ||
| /* {{{ php_reserve_tsrm_memory */ | ||
| PHPAPI void php_reserve_tsrm_memory(void) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume it's fine to remove this in one go?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes 👍 |
||
| { | ||
| /* CG/EG/GC globals live in native __thread storage and need no | ||
| * reserved TSRM space. */ | ||
| tsrm_reserve( | ||
| TSRM_ALIGNED_SIZE(sizeof(zend_ini_scanner_globals)) + | ||
| TSRM_ALIGNED_SIZE(sizeof(virtual_cwd_globals)) + | ||
| #ifdef ZEND_SIGNALS | ||
| TSRM_ALIGNED_SIZE(sizeof(zend_signal_globals_t)) + | ||
| #endif | ||
| TSRM_ALIGNED_SIZE(sizeof(php_core_globals)) + | ||
| TSRM_ALIGNED_SIZE(sizeof(sapi_globals_struct)) + | ||
| TSRM_ALIGNED_SIZE(sizeof(zend_accel_globals)) + | ||
| #ifdef HAVE_JIT | ||
| TSRM_ALIGNED_SIZE(sizeof(zend_jit_globals)) + | ||
| #endif | ||
| 0 | ||
| ); | ||
| } | ||
| /* }}} */ | ||
|
|
||
| PHPAPI bool php_tsrm_startup_ex(int expected_threads) | ||
| { | ||
| bool ret = tsrm_startup(expected_threads, 1, 0, NULL); | ||
| php_reserve_tsrm_memory(); | ||
| (void)ts_resource(0); | ||
| return ret; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the conventions here, could I just amend the initial upgrading entry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah