Skip to content

Commit 6754913

Browse files
committed
Fix jit on darwin x86_64
1 parent 8aff8c4 commit 6754913

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

ext/opcache/jit/tls/zend_jit_tls_darwin.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,8 @@ zend_result zend_jit_resolve_tsrm_ls_cache_offsets(
3737
}
3838

3939
#if defined(__x86_64__)
40-
size_t *ti;
41-
__asm__ __volatile__(
42-
"leaq __tsrm_ls_cache(%%rip),%0"
43-
: "=r" (ti));
44-
*module_offset = ti[2];
45-
*module_index = ti[1] * 8;
40+
*module_index = (size_t)-1;
41+
*module_offset = (size_t)-1;
4642

4743
return SUCCESS;
4844
#endif
@@ -67,6 +63,17 @@ void *zend_jit_tsrm_ls_cache_address(
6763
);
6864
return addr;
6965
}
66+
if (module_index == (size_t)-1 && module_offset == (size_t)-1) {
67+
void *tlvp;
68+
__asm__ __volatile__(
69+
"leaq __tsrm_ls_cache@TLVP(%%rip), %0\n"
70+
: "=&r" (tlvp)
71+
:
72+
: "memory"
73+
);
74+
void *(*thunk)(void*) = *(void **)tlvp;
75+
return thunk(tlvp);
76+
}
7077
if (module_index != (size_t)-1 && module_offset != (size_t)-1) {
7178
char *base;
7279
__asm__ __volatile__(

0 commit comments

Comments
 (0)