diff options
author | Nikita Popov <nikic@php.net> | 2013-08-26 19:06:36 +0200 |
---|---|---|
committer | Nikita Popov <nikic@php.net> | 2013-08-31 13:16:41 +0200 |
commit | 08567145763f25aae3882f682d41d1b50cd9e666 (patch) | |
tree | 0458355affcbbbf8c936dc01f1792182c7b6ad6a /Zend/zend_execute.c | |
parent | d7ffca590b4ee188a5dcdbafb036e6541f3c79be (diff) | |
download | php-git-08567145763f25aae3882f682d41d1b50cd9e666.tar.gz |
Always pass return_value_ptr to internal functions
Previous some places passed return_value_ptr only if the function
returned by reference. Now return_value_ptr is always set, even
for functions returning by-value.
This allows you to return zvals without copying their contents. For
this purpose two new macros RETVAL_ZVAL_FAST and RETURN_ZVAL_FAST
are added:
RETVAL_ZVAL_FAST(zv); /* Analog to RETVAL_ZVAL(zv, 1, 0) */
RETURN_ZVAL_FAST(zv); /* Analog to RETURN_ZVAL(zv, 1, 0) */
These macros behave similarly to the non-FAST versions with
copy=1 and dtor=0, with the difference that the FAST versions
will try return the zval without copying by utilizing return_value_ptr.
Diffstat (limited to 'Zend/zend_execute.c')
-rw-r--r-- | Zend/zend_execute.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 3c3dd8e3b0..048c1fc184 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1487,15 +1487,17 @@ ZEND_API opcode_handler_t *zend_opcode_handlers; ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, zend_fcall_info *fci, int return_value_used TSRMLS_DC) { - if(fci != NULL) { - ((zend_internal_function *) execute_data_ptr->function_state.function)->handler(fci->param_count, - *fci->retval_ptr_ptr, fci->retval_ptr_ptr, fci->object_ptr, 1 TSRMLS_CC); - + if (fci != NULL) { + execute_data_ptr->function_state.function->internal_function.handler( + fci->param_count, *fci->retval_ptr_ptr, fci->retval_ptr_ptr, + fci->object_ptr, 1 TSRMLS_CC + ); } else { zval **return_value_ptr = &EX_TMP_VAR(execute_data_ptr, execute_data_ptr->opline->result.var)->var.ptr; - ((zend_internal_function *) execute_data_ptr->function_state.function)->handler(execute_data_ptr->opline->extended_value, *return_value_ptr, - (execute_data_ptr->function_state.function->common.fn_flags & ZEND_ACC_RETURN_REFERENCE)?return_value_ptr:NULL, - execute_data_ptr->object, return_value_used TSRMLS_CC); + execute_data_ptr->function_state.function->internal_function.handler( + execute_data_ptr->opline->extended_value, *return_value_ptr, return_value_ptr, + execute_data_ptr->object, return_value_used TSRMLS_CC + ); } } |