[php-src] PR #20628: VAR|TMP overhaul
| From: | iluuu1994 | Date: | Mon, 01 Dec 2025 15:15:48 +0000 |
| Subject: | [php-src] PR #20628: VAR|TMP overhaul | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-34188@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/20628
Author: iluuu1994
The aim of this PR is twofold:
- Reduce the number of highly similar TMP|VAR handlers
- Avoid ZVAL_DEREF in most of these cases
This is achieved by guaranteeing that all zend_compile_expr() calls, as well as all other compile
calls with BP_VAR_R, will result in a TMP variable. This implies that the result will not contain an
IS_INDIRECT or IS_REFERENCE value, which was mostly already the case, with two exceptions:
- Calls to return-by-reference functions. Because return-by-reference functions are quite rare, this
is solved by delegating the DEREF to the RETURN_BY_REF handler, which will examine the stack to
check whether the caller expects a VAR or TMP to understand whether the DEREF is needed.
- By-reference assignments, including both $a = &$b, as well as $a = [&$b]. When the result
of these expressions is used in a BP_VAR_R context, it will be passed to a new ZEND_DEREF opcode
beforehand. This is exceptionally rare.
Preliminary testing shows a 1.1% wall time improvement in Symfony Demo and roughly 0.5% in
Wordpress.
TODOs:
- [ ] Verify this doesn't break important optimizations