diff options
author | David Carlier <devnexen@gmail.com> | 2021-02-01 17:26:39 +0000 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2021-02-11 15:48:20 +0100 |
commit | 1106ff9a0e420e043c2e56c8ca00db85f1b85ee6 (patch) | |
tree | cf4f919145510a9d101c75e0bad8b0336811cda2 | |
parent | 070e24d7a91a49fce56b5ee4d5a102d022d3e724 (diff) | |
download | php-git-1106ff9a0e420e043c2e56c8ca00db85f1b85ee6.tar.gz |
Implement fetching TLS TCB offset on MacOS
Tested with php-cgi and wordpress and 1255 for jit settings.
Closes GH-6659.
-rw-r--r-- | TSRM/TSRM.c | 6 | ||||
-rw-r--r-- | ext/opcache/jit/zend_jit_x86.dasc | 8 |
2 files changed, 12 insertions, 2 deletions
diff --git a/TSRM/TSRM.c b/TSRM/TSRM.c index cd340035a2..2e489137fb 100644 --- a/TSRM/TSRM.c +++ b/TSRM/TSRM.c @@ -727,8 +727,10 @@ TSRM_API void *tsrm_get_ls_cache(void) TSRM_API size_t tsrm_get_ls_cache_tcb_offset(void) {/*{{{*/ #if defined(__APPLE__) && defined(__x86_64__) - // TODO: Implement support for fast JIT ZTS code ??? - return 0; + size_t ret; + asm ("movq __tsrm_ls_cache(%%rip),%0" + : "=r" (ret)); + return ret; #elif defined(__x86_64__) && defined(__GNUC__) size_t ret; diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index fa203f850c..844aaefc1b 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -2923,12 +2923,20 @@ static int zend_jit_setup(void) # elif defined(__APPLE__) && defined(__x86_64__) tsrm_ls_cache_tcb_offset = tsrm_get_ls_cache_tcb_offset(); if (tsrm_ls_cache_tcb_offset == 0) { +#if defined(__has_attribute) && __has_attribute(tls_model) + size_t ret; + + asm ("movq __tsrm_ls_cache(%%rip),%0" + : "=r" (ret)); + tsrm_ls_cache_tcb_offset = ret; +#else size_t *ti; __asm__( "leaq __tsrm_ls_cache(%%rip),%0" : "=r" (ti)); tsrm_tls_offset = ti[2]; tsrm_tls_index = ti[1] * 8; +#endif } # elif defined(__GNUC__) && defined(__x86_64__) tsrm_ls_cache_tcb_offset = tsrm_get_ls_cache_tcb_offset(); |