[php-src] PR #25057: Added ZEND_ASSIGN_OBJ fast path for the first write to an uninitializ…

From: Date: Fri, 30 Oct 2026 16:37:06 +0000
Subject: [php-src] PR #25057: Added ZEND_ASSIGN_OBJ fast path for the first write to an uninitializ…
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-40097@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/25057 Author: adapik Modern PHP code mostly initializes properties through constructor property promotion, often with readonly (DTOs, value objects, services). Every such property is a typed property without a default, so its first write always goes through zend_std_write_property(). This PR adds a fast path in ZEND_ASSIGN_OBJ for the case where the cache slot is hit, the property is IS_UNDEF with IS_PROP_UNINIT set (never unset()), and neither the property nor the object is lazy. A new zend_assign_to_uninit_typed_prop() verifies the type and stores the value. Write access isn't rechecked, since a primed cache slot means it was already checked. This depends on the fix for the cache slot bypassing scope checks, so it must be merged after that one. Results (release build, callgrind over 200k constructor calls with promoted readonly properties): - Without opcache: −24% instructions, −25% time. - Opcache without JIT: −24% instructions, −26% time. Two new tests cover coercion, union and class types, readonly, protected(set), hooks and lazy objects. This PR is related to #24566 and relies on it: that fix makes sure a failed write doesn't leave the cache slot primed. Without it, this fast path would also let a first write bypass those checks. It would be best if this lands after #24566.

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