From e776104e496af423ea347c5445aea5efa6a2cc9c Mon Sep 17 00:00:00 2001 From: David Carlier Date: Mon, 1 Feb 2021 17:26:39 +0000 Subject: [PATCH] opcache jit for Mac x86 getting tsrm tcb offset cached/ZTS build proposal. Tested with php-cgi and wordpress and 1255 for jit settings. --- TSRM/TSRM.c | 6 ++++-- 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 cd340035a27e2..2e489137fb8e7 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 5700a92ff1c44..31876caba5abf 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();