Optimization when extensions don't provide handlers

php.internals

Barel

224 days ago
Hi I have seen that the php-src uses some flags like ZEND_EXTENSIONS_HAVE_OP_ARRAY_HANDLER to optimise the code so that the loop that calls the op array handler is not called if no extension has set up an op array handler I wonder why this has not been done for the statement_handler, fcall_begin_handler and fcall_end_handler. This could be used to provide an optimised execution when no extension sets up a handler for these extension points Interested to know if there is a technical reason for this Cheers Carlos

Barel

224 days ago
On Tue, 20 Jan 2026 at 15:28, Barel <barel.barelon@gmail.com> wrote:
> Hi > > I have seen that the php-src uses some flags > like ZEND_EXTENSIONS_HAVE_OP_ARRAY_HANDLER to optimise the code so that the > loop that calls the op array handler is not called if no extension has set > up an op array handler > > I wonder why this has not been done for > the statement_handler, fcall_begin_handler and fcall_end_handler. This > could be used to provide an optimised execution when no extension sets up a > handler for these extension points > > Interested to know if there is a technical reason for this > > Cheers > > Carlos >
OK, I reply to myself. I can see that these handlers are only called if the corresponding opcodes are compiled and these are only compiled if ZEND_COMPILE_EXTENDED_STMT or ZEND_COMPILE_EXTENDED_FCALL are set. So an extension that does not set these handlers would not set these compiler flags, then there is no need to do any more optimization :-)