mirror of
https://github.com/php/php-src.git
synced 2026-03-24 08:12:21 +01:00
Split zend_init_execute_data() into zend_init_func_execute_data() and zend_init_code_execute_data()
This commit is contained in:
@@ -2238,88 +2238,35 @@ static zend_always_inline void i_init_code_execute_data(zend_execute_data *execu
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static zend_always_inline void i_init_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value) /* {{{ */
|
||||
ZEND_API void zend_init_func_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value) /* {{{ */
|
||||
{
|
||||
ZEND_ASSERT(EX(func) == (zend_function*)op_array);
|
||||
|
||||
EX(opline) = op_array->opcodes;
|
||||
EX(call) = NULL;
|
||||
EX(return_value) = return_value;
|
||||
|
||||
if (EX_CALL_INFO() & ZEND_CALL_HAS_SYMBOL_TABLE) {
|
||||
zend_attach_symbol_table(execute_data);
|
||||
} else {
|
||||
uint32_t first_extra_arg, num_args;
|
||||
|
||||
/* Handle arguments */
|
||||
first_extra_arg = op_array->num_args;
|
||||
num_args = EX_NUM_ARGS();
|
||||
if (UNEXPECTED(num_args > first_extra_arg)) {
|
||||
if (EXPECTED(!(op_array->fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE))) {
|
||||
zval *end, *src, *dst;
|
||||
uint32_t type_flags = 0;
|
||||
|
||||
if (EXPECTED((op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS) == 0)) {
|
||||
/* Skip useless ZEND_RECV and ZEND_RECV_INIT opcodes */
|
||||
EX(opline) += first_extra_arg;
|
||||
}
|
||||
|
||||
/* move extra args into separate array after all CV and TMP vars */
|
||||
end = EX_VAR_NUM(first_extra_arg - 1);
|
||||
src = end + (num_args - first_extra_arg);
|
||||
dst = src + (op_array->last_var + op_array->T - first_extra_arg);
|
||||
if (EXPECTED(src != dst)) {
|
||||
do {
|
||||
type_flags |= Z_TYPE_INFO_P(src);
|
||||
ZVAL_COPY_VALUE(dst, src);
|
||||
ZVAL_UNDEF(src);
|
||||
src--;
|
||||
dst--;
|
||||
} while (src != end);
|
||||
} else {
|
||||
do {
|
||||
type_flags |= Z_TYPE_INFO_P(src);
|
||||
src--;
|
||||
} while (src != end);
|
||||
}
|
||||
ZEND_ADD_CALL_FLAG(execute_data, ((type_flags >> Z_TYPE_FLAGS_SHIFT) & IS_TYPE_REFCOUNTED));
|
||||
}
|
||||
} else if (EXPECTED((op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS) == 0)) {
|
||||
/* Skip useless ZEND_RECV and ZEND_RECV_INIT opcodes */
|
||||
EX(opline) += num_args;
|
||||
}
|
||||
|
||||
/* Initialize CV variables (skip arguments) */
|
||||
if (EXPECTED((int)num_args < op_array->last_var)) {
|
||||
zval *var = EX_VAR_NUM(num_args);
|
||||
zval *end = EX_VAR_NUM(op_array->last_var);
|
||||
|
||||
do {
|
||||
ZVAL_UNDEF(var);
|
||||
var++;
|
||||
} while (var != end);
|
||||
}
|
||||
}
|
||||
|
||||
EX(prev_execute_data) = EG(current_execute_data);
|
||||
if (!op_array->run_time_cache) {
|
||||
if (op_array->function_name) {
|
||||
op_array->run_time_cache = zend_arena_alloc(&CG(arena), op_array->cache_size);
|
||||
} else {
|
||||
op_array->run_time_cache = emalloc(op_array->cache_size);
|
||||
}
|
||||
op_array->run_time_cache = zend_arena_alloc(&CG(arena), op_array->cache_size);
|
||||
memset(op_array->run_time_cache, 0, op_array->cache_size);
|
||||
}
|
||||
EX_LOAD_RUN_TIME_CACHE(op_array);
|
||||
EX_LOAD_LITERALS(op_array);
|
||||
i_init_func_execute_data(execute_data, op_array, return_value);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
EG(current_execute_data) = execute_data;
|
||||
ZEND_API void zend_init_code_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value) /* {{{ */
|
||||
{
|
||||
EX(prev_execute_data) = EG(current_execute_data);
|
||||
if (!op_array->run_time_cache) {
|
||||
op_array->run_time_cache = emalloc(op_array->cache_size);
|
||||
memset(op_array->run_time_cache, 0, op_array->cache_size);
|
||||
}
|
||||
i_init_code_execute_data(execute_data, op_array, return_value);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
ZEND_API void zend_init_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value) /* {{{ */
|
||||
{
|
||||
EX(prev_execute_data) = EG(current_execute_data);
|
||||
i_init_execute_data(execute_data, op_array, return_value);
|
||||
if (EX_CALL_INFO() & ZEND_CALL_HAS_SYMBOL_TABLE) {
|
||||
zend_init_code_execute_data(execute_data, op_array, return_value);
|
||||
} else {
|
||||
zend_init_func_execute_data(execute_data, op_array, return_value);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ void init_executor(void);
|
||||
void shutdown_executor(void);
|
||||
void shutdown_destructors(void);
|
||||
ZEND_API void zend_init_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value);
|
||||
ZEND_API void zend_init_func_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value);
|
||||
ZEND_API void zend_init_code_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value);
|
||||
ZEND_API void zend_execute(zend_op_array *op_array, zval *return_value);
|
||||
ZEND_API void execute_ex(zend_execute_data *execute_data);
|
||||
ZEND_API void execute_internal(zend_execute_data *execute_data, zval *return_value);
|
||||
|
||||
@@ -822,7 +822,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /
|
||||
int call_via_handler = (func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) != 0;
|
||||
const zend_op *current_opline_before_exception = EG(opline_before_exception);
|
||||
|
||||
zend_init_execute_data(call, &func->op_array, fci->retval);
|
||||
zend_init_func_execute_data(call, &func->op_array, fci->retval);
|
||||
zend_execute_ex(call);
|
||||
EG(opline_before_exception) = current_opline_before_exception;
|
||||
if (call_via_handler) {
|
||||
|
||||
@@ -63121,7 +63121,7 @@ ZEND_API void zend_execute(zend_op_array *op_array, zval *return_value)
|
||||
execute_data->symbol_table = &EG(symbol_table);
|
||||
}
|
||||
EX(prev_execute_data) = EG(current_execute_data);
|
||||
i_init_execute_data(execute_data, op_array, return_value);
|
||||
i_init_code_execute_data(execute_data, op_array, return_value);
|
||||
zend_execute_ex(execute_data);
|
||||
zend_vm_stack_free_call_frame(execute_data);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ ZEND_API void zend_{%EXECUTOR_NAME%}(zend_op_array *op_array, zval *return_value
|
||||
execute_data->symbol_table = &EG(symbol_table);
|
||||
}
|
||||
EX(prev_execute_data) = EG(current_execute_data);
|
||||
i_init_execute_data(execute_data, op_array, return_value);
|
||||
i_init_code_execute_data(execute_data, op_array, return_value);
|
||||
zend_{%EXECUTOR_NAME%}_ex(execute_data);
|
||||
zend_vm_stack_free_call_frame(execute_data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user