Skip to content
Merged
15 changes: 10 additions & 5 deletions ext/opcache/jit/zend_jit.c
Original file line number Diff line number Diff line change
Expand Up @@ -3724,6 +3724,16 @@ int zend_jit_check_support(void)
{
int i;

#ifdef ZEND_JIT_USE_APPLE_MAP_JIT
if (!pthread_jit_write_protect_supported_np()) {
zend_accel_error(ACCEL_LOG_WARNING,
"Apple Silicon ZTS JIT requires pthread_jit_write_protect_np() support. JIT disabled.");
JIT_G(enabled) = 0;
JIT_G(on) = 0;
return FAILURE;
}
#endif

if (zend_execute_ex != execute_ex) {
if (zend_dtrace_enabled) {
zend_error(E_WARNING, "JIT is incompatible with DTrace. JIT disabled.");
Expand Down Expand Up @@ -3792,11 +3802,6 @@ void zend_jit_startup(void *buf, size_t size, bool reattached)
"Unable to share JIT buffer across fork using minherit(): %s (%d)",
strerror(error), error);
}
if (!pthread_jit_write_protect_supported_np()) {
munmap(buf, size);
zend_accel_error_noreturn(ACCEL_LOG_FATAL,
"Apple Silicon ZTS JIT requires pthread_jit_write_protect_np() support");
}
#endif

dasm_buf = buf;
Expand Down
5 changes: 4 additions & 1 deletion ext/opcache/tests/jit/gh14267_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ opcache.jit_buffer_size=32M
opcache
--FILE--
<?php
ini_set('opcache.jit', 'tracing');
// Skip when JIT was completely disabled at runtime.
if (($status = opcache_get_status()) === false || $status['jit']['enabled']) {

@iluuu1994 iluuu1994 Jul 24, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be:

if (($status = opcache_get_status()) !== false && $status['jit']['enabled']) {

? I guess it's fine to try to set it even with opcache disabled.

ini_set('opcache.jit', 'tracing');
}
?>
===DONE===
--EXPECT--
Expand Down
7 changes: 5 additions & 2 deletions ext/opcache/tests/jit/gh16393.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ opcache.jit=1215
opcache.jit_buffer_size=64M
--FILE--
<?php
ini_set('opcache.jit', 'tracing');
// Skip when JIT was completely disabled at runtime.
if (($status = opcache_get_status()) === false || $status['jit']['enabled']) {
ini_set('opcache.jit', 'tracing');
}
class Test {
}
$appendProp2 = (function() {
})->bindTo($test, Test::class);
$appendProp2();
?>
--EXPECTF--
Warning: Undefined variable $test in %sgh16393.php on line 6
Warning: Undefined variable $test in %sgh16393.php on line 9
Loading