Use preallocated permanent zvals instead of null, true, false, 0 and 1 #1302
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.
This is what was implemented in 2.0.0 / Zephir and appears to be very useful optimization. In some cases it helps avoid creation of the memory frame because we don't need
PHALCON_INIT_VAR
anymore.In addition, this PR fixes the bug when a function calls another function (passing it its return_value and return_value_ptr) and the called function throws an exception:
In this scenario, Zend (
zend_call_function()
) detects the exception and frees the variablereturn_value_ptr
points to. But becausetest1
passed totest2
its ownreturn_value
/return_value_ptr
,test2
freestest1
's return value. Then, aftertest2
andtest1
return, Zend sees there is an active exception and tries to free the return value oftest1
which was already freed on return fromtest2
and segmentation fault happens.We tried to address this issue in the past (in
phalcon_alt_call_method
) but that fix is not applicable to all kinds of static calls because they are dispatched viazend_call_function
.