File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,7 +40,9 @@ BEGIN_EXTERN_C()
4040
4141#ifdef ZTS
4242typedef struct _zend_tsrm_ls_cache zend_tsrm_ls_cache ;
43+ # ifdef ZEND_TLS_DIRECT
4344extern ZEND_TLS_API TSRM_TLS TSRM_TLS_MODEL_ATTR zend_tsrm_ls_cache _tsrm_ls_cache ;
45+ # endif
4446#endif
4547
4648/* Compiler */
Original file line number Diff line number Diff line change @@ -33,30 +33,21 @@ zend_result zend_jit_resolve_tsrm_ls_cache_offsets(
3333 size_t * module_index ,
3434 size_t * module_offset
3535) {
36- /* To find offset of "_tsrm_ls_cache" in TLS segment we perform a linear scan of local TLS memory */
37- /* Probably, it might be better solution */
36+ /* Offset of _tsrm_ls_cache within this module's TLS block. */
3837#ifdef _WIN64
3938 void * * * tls_mem = ((void * * * * )__readgsqword (0x58 ))[_tls_index ];
4039#else
4140 void * * * tls_mem = ((void * * * * )__readfsdword (0x2c ))[_tls_index ];
4241#endif
43- void * val = _tsrm_ls_cache ;
44- size_t offset = 0 ;
4542 size_t size = (char * )& _tls_end - (char * )& _tls_start ;
46-
47- while (offset < size ) {
48- if (* tls_mem == val ) {
49- * module_index = _tls_index * sizeof (void * );
50- * module_offset = offset ;
51- return SUCCESS ;
52- }
53- tls_mem ++ ;
54- offset += sizeof (void * );
55- }
43+ size_t offset = (size_t )((char * )& _tsrm_ls_cache - (char * )tls_mem );
5644
5745 if (offset >= size ) {
5846 zend_accel_error_noreturn (ACCEL_LOG_FATAL , "Could not enable JIT: offset >= size" );
47+ return FAILURE ;
5948 }
6049
61- return FAILURE ;
50+ * module_index = _tls_index * sizeof (void * );
51+ * module_offset = offset ;
52+ return SUCCESS ;
6253}
You can’t perform that action at this time.
0 commit comments