[php-src] PR #13649: Optimize observers
| From: | bwoebi | Date: | Sat, 09 Mar 2024 11:52:48 +0000 |
| Subject: | [php-src] PR #13649: Optimize observers | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-25332@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/13649
Author: bwoebi
Inline the lookup whether a function is observed at all. This strategy is also used for FRAMELESS
calls. If the frameless call is observed, we instead allocate a call frame and push the arguments,
to call the the function afterwards. Doing so is still a performance benefit as opposed to executing
individual INIT_FCALL+SEND_VAL ops. Thus, even if the frameless call turns out to be observed, the
call overhead is slightly lower than before. If the internal function is not observed at all, the
unavoidable overhead is fetching the FLF zend_function pointer and the run-time cache needs to be
inspected.
As part of this work, it turned out to be most viable to put the result operand on the ZEND_OP_DATA
instead of ZEND_FRAMELESS_ICALL_3, allowing seamless interoperability with the DO_ICALL opcode. This
is a bit unusual in comparison to all other ZEND_OP_DATA usages, but seems to not pose problems
overall.
There is also a small issue resolved: trampolines would always use the
ZEND_CALL_TRAMPOLINE_SPEC_OBSERVER function due to zend_observer_fcall_op_array_extension being set
to -1 too late.
Note: I haven't yet looked at the JIT changes necessary to support observed FRAMELESS_ICALL
there. But drafting the PR now to evaluate the general approach aside from JIT.