Skip to content

Commit 0591def

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Remove dynamic defs from property hooks Add missing hooks JIT restart code
2 parents cee8ed2 + 771bfaf commit 0591def

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4199,6 +4199,24 @@ static void preload_link(void)
41994199
preload_remove_declares(op_array);
42004200
}
42014201
} ZEND_HASH_FOREACH_END();
4202+
4203+
if (ce->num_hooked_props > 0) {
4204+
zend_property_info *info;
4205+
4206+
ZEND_HASH_MAP_FOREACH_PTR(&ce->properties_info, info) {
4207+
if (info->hooks) {
4208+
for (uint32_t i = 0; i < ZEND_PROPERTY_HOOK_COUNT; i++) {
4209+
if (info->hooks[i]) {
4210+
op_array = &info->hooks[i]->op_array;
4211+
ZEND_ASSERT(op_array->type == ZEND_USER_FUNCTION);
4212+
if (!(op_array->fn_flags & ZEND_ACC_TRAIT_CLONE)) {
4213+
preload_remove_declares(op_array);
4214+
}
4215+
}
4216+
}
4217+
}
4218+
} ZEND_HASH_FOREACH_END();
4219+
}
42024220
} ZEND_HASH_FOREACH_END();
42034221
}
42044222

ext/opcache/jit/zend_jit.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3983,6 +3983,24 @@ static void zend_jit_restart_preloaded_script(zend_persistent_script *script)
39833983
zend_jit_restart_preloaded_op_array(op_array);
39843984
}
39853985
} ZEND_HASH_FOREACH_END();
3986+
3987+
if (ce->num_hooked_props > 0) {
3988+
zend_property_info *prop;
3989+
3990+
ZEND_HASH_MAP_FOREACH_PTR(&ce->properties_info, prop) {
3991+
if (prop->hooks) {
3992+
for (uint32_t i = 0; i < ZEND_PROPERTY_HOOK_COUNT; i++) {
3993+
if (prop->hooks[i]) {
3994+
op_array = &prop->hooks[i]->op_array;
3995+
ZEND_ASSERT(op_array->type == ZEND_USER_FUNCTION);
3996+
if (!(op_array->fn_flags & ZEND_ACC_TRAIT_CLONE)) {
3997+
zend_jit_restart_preloaded_op_array(op_array);
3998+
}
3999+
}
4000+
}
4001+
}
4002+
} ZEND_HASH_FOREACH_END();
4003+
}
39864004
} ZEND_HASH_FOREACH_END();
39874005
}
39884006

ext/opcache/tests/preload_dynamic_def_removal.inc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ class Test {
55
echo "dynamic\n";
66
}
77
}
8+
9+
public int $hook {
10+
get {
11+
function dynamic_in_hook() {
12+
echo "dynamic in hook\n";
13+
}
14+
return 1;
15+
}
16+
}
817
}
918

1019
function func() {
@@ -16,3 +25,4 @@ function func() {
1625
$test = new Test;
1726
$test->method();
1827
func();
28+
$test->hook;

ext/opcache/tests/preload_dynamic_def_removal.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows
1515
<?php
1616
dynamic();
1717
dynamic2();
18+
dynamic_in_hook();
1819
?>
1920
--EXPECT--
2021
dynamic
2122
dynamic2
23+
dynamic in hook

0 commit comments

Comments
 (0)