[php-src] PR #17870: Fix circumvented added hooks in JIT

From: Date: Thu, 20 Feb 2025 21:08:42 +0000
Subject: [php-src] PR #17870: Fix circumvented added hooks in JIT
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-30849@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/17870 Author: iluuu1994 The following code poses a problem in the JIT: ```php class A { public $prop = 1; } class B extends A { public $prop = 1 { get => parent::$prop::get() * 2; } } function test(A $a) { var_dump($a->prop); } test(new B); ``` The JIT would assume A::$prop in test() could be accessed directly through OBJ_PROP_NUM(). However, since child classes can add new hooks to existing properties, this assumption no longer holds. To avoid introducing more JIT checks, a hooked property that overrides a unhooked property now results in a separate zval slot that is used instead of the parent slot. This causes the JIT to pick the slow path due to an IS_UNDEF value in the parent slot. zend_class_entry.properties_info_table poses a problem in that zend_get_property_info_for_slot() and friends will be called using the child slot, which does not store its property info, since the parent slot already does. In this case, zend_get_property_info_for_slot() now provides a fallback that will iterate all property infos to find the correct one. This also uncovered a bug (see Zend/tests/property_hooks/dump.phpt) where the default value of a parent property would accidentally be inherited by the child property. Fixes GH-17376

« previous php.git-pulls (#30849) next »