phalcon_call_user_function() optimization #1846
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
phalcon_call_user_function():
zend_fcall_info_cache
to avoid expensivezend_is_callable()
checksreturn_value_ptr
instead ofreturn_value
to enable return value optimizationAdded
phalcon_call_func_aparams
:Unlike
phalcon_call_func_params
it useszval**
(array) to pass the parameters and not variadic arguments (functions with variadic arguments cannot be inlined)PHALCON_CALL_FUNCTION:
phalcon_call_func_params
instead ofphalcon_call_func_params
return_value
(this makesphalcon_call_func_pXXX_ex
andphalcon_call_func_pXXX
behave identically)nparams
because the number of function arguments is calculated automaticallyNULL
when the called function does not need any argumentsRETURN_ON_FAILURE
macrosPHALCON_CALL_xxx macros:
__builtin_constant_p(s)
is#define
'd to 0)Now that
PHALCON_CALL_FUNCTION()
macro can detect the number of function arguments automatically, we don't needphalcon_call_func_pXXX
,phalcon_return_call_func_pXXX
,phalcon_call_func_pXXX_noret
,phalcon_call_func_pXXX_ex
macros — they all have been replaced withPHALCON_CALL_FUNCTION
Other things:
phalcon_return_call_function()
inline function which is used when the return value of the called function is passed directly intoreturn_value
andreturn_value_ptr
. The function is useful when you need to do a cleanup on exception or call failure before returning;PHALCON_CALL_FUNCTIONW()
andPHALCON_RETURN_CALL_FUNCTIONW()
which do the same asPHALCON_CALL_FUNCTION()
andPHALCON_RETURN_CALL_FUNCTION()
but do not restore the memory frame;__attribute__((warn_unused_result))
to allphalcon_call_xxx
functions, as failure to check the result of the call may lead to unexpected thingsHow it breaks the API:
Used to be:
Now:
Advantages:
return_value
is now allocated by Zend; used to be: allocated by Phalcon, desstroyed by Zend, reallocated by Zend)zend_fcall_info_cache