Use better data structures (incomplete) - refactored return_value handling

This commit is contained in:
Dmitry Stogov 2014-02-12 14:29:51 +04:00
parent e2ea9a7319
commit 4e66abad54
12 changed files with 1005 additions and 1756 deletions

View file

@ -1277,7 +1277,6 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval *retval, int file_cou
int i; int i;
zend_file_handle *file_handle; zend_file_handle *file_handle;
zend_op_array *orig_op_array = EG(active_op_array); zend_op_array *orig_op_array = EG(active_op_array);
//??? zval **orig_retval_ptr_ptr = EG(return_value_ptr_ptr);
long orig_interactive = CG(interactive); long orig_interactive = CG(interactive);
va_start(files, file_count); va_start(files, file_count);
@ -1301,8 +1300,7 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval *retval, int file_cou
} }
zend_destroy_file_handle(file_handle TSRMLS_CC); zend_destroy_file_handle(file_handle TSRMLS_CC);
if (EG(active_op_array)) { if (EG(active_op_array)) {
//??? EG(return_value_ptr_ptr) = retval ? retval : NULL; zend_execute(EG(active_op_array), retval TSRMLS_CC);
zend_execute(EG(active_op_array) TSRMLS_CC);
zend_exception_restore(TSRMLS_C); zend_exception_restore(TSRMLS_C);
if (EG(exception)) { if (EG(exception)) {
if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) { if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
@ -1334,14 +1332,12 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval *retval, int file_cou
} else if (type==ZEND_REQUIRE) { } else if (type==ZEND_REQUIRE) {
va_end(files); va_end(files);
EG(active_op_array) = orig_op_array; EG(active_op_array) = orig_op_array;
//??? EG(return_value_ptr_ptr) = orig_retval_ptr_ptr;
CG(interactive) = orig_interactive; CG(interactive) = orig_interactive;
return FAILURE; return FAILURE;
} }
} }
va_end(files); va_end(files);
EG(active_op_array) = orig_op_array; EG(active_op_array) = orig_op_array;
//??? EG(return_value_ptr_ptr) = orig_retval_ptr_ptr;
CG(interactive) = orig_interactive; CG(interactive) = orig_interactive;
return SUCCESS; return SUCCESS;

View file

@ -383,7 +383,7 @@ struct _zend_execute_data {
struct _zend_execute_data *prev_execute_data; struct _zend_execute_data *prev_execute_data;
zval old_error_reporting; zval old_error_reporting;
zend_bool nested; zend_bool nested;
//??? zval **original_return_value; zval *return_value;
//??? zend_class_entry *current_scope; //??? zend_class_entry *current_scope;
//??? zend_class_entry *current_called_scope; //??? zend_class_entry *current_called_scope;
//??? zval *current_this; //??? zval *current_this;

View file

@ -1379,7 +1379,7 @@ void zend_free_compiled_variables(zend_execute_data *execute_data TSRMLS_DC) /*
* +----------------------------------------+ * +----------------------------------------+
*/ */
static zend_always_inline zend_execute_data *i_create_execute_data_from_op_array(zend_op_array *op_array, zend_bool nested TSRMLS_DC) /* {{{ */ static zend_always_inline zend_execute_data *i_create_execute_data_from_op_array(zend_op_array *op_array, zval *return_value, zend_bool nested TSRMLS_DC) /* {{{ */
{ {
zend_execute_data *execute_data; zend_execute_data *execute_data;
@ -1462,6 +1462,7 @@ static zend_always_inline zend_execute_data *i_create_execute_data_from_op_array
EG(current_execute_data) = execute_data; EG(current_execute_data) = execute_data;
EX(nested) = nested; EX(nested) = nested;
EX(delayed_exception) = NULL; EX(delayed_exception) = NULL;
EX(return_value) = return_value;
if (!op_array->run_time_cache && op_array->last_cache_slot) { if (!op_array->run_time_cache && op_array->last_cache_slot) {
op_array->run_time_cache = ecalloc(op_array->last_cache_slot, sizeof(void*)); op_array->run_time_cache = ecalloc(op_array->last_cache_slot, sizeof(void*));
@ -1489,9 +1490,9 @@ static zend_always_inline zend_execute_data *i_create_execute_data_from_op_array
} }
/* }}} */ /* }}} */
ZEND_API zend_execute_data *zend_create_execute_data_from_op_array(zend_op_array *op_array, zend_bool nested TSRMLS_DC) /* {{{ */ ZEND_API zend_execute_data *zend_create_execute_data_from_op_array(zend_op_array *op_array, zval *return_value, zend_bool nested TSRMLS_DC) /* {{{ */
{ {
return i_create_execute_data_from_op_array(op_array, nested TSRMLS_CC); return i_create_execute_data_from_op_array(op_array, return_value, nested TSRMLS_CC);
} }
/* }}} */ /* }}} */

View file

@ -55,8 +55,8 @@ ZEND_API extern void (*zend_execute_internal)(zend_execute_data *execute_data_pt
void init_executor(TSRMLS_D); void init_executor(TSRMLS_D);
void shutdown_executor(TSRMLS_D); void shutdown_executor(TSRMLS_D);
void shutdown_destructors(TSRMLS_D); void shutdown_destructors(TSRMLS_D);
ZEND_API zend_execute_data *zend_create_execute_data_from_op_array(zend_op_array *op_array, zend_bool nested TSRMLS_DC); ZEND_API zend_execute_data *zend_create_execute_data_from_op_array(zend_op_array *op_array, zval *return_value, zend_bool nested TSRMLS_DC);
ZEND_API void zend_execute(zend_op_array *op_array TSRMLS_DC); ZEND_API void zend_execute(zend_op_array *op_array, zval *return_value TSRMLS_DC);
ZEND_API void execute_ex(zend_execute_data *execute_data TSRMLS_DC); ZEND_API void execute_ex(zend_execute_data *execute_data TSRMLS_DC);
ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, struct _zend_fcall_info *fci, int return_value_used TSRMLS_DC); ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, struct _zend_fcall_info *fci, int return_value_used TSRMLS_DC);
ZEND_API int zend_is_true(zval *op TSRMLS_DC); ZEND_API int zend_is_true(zval *op TSRMLS_DC);

View file

@ -138,7 +138,6 @@ void init_executor(TSRMLS_D) /* {{{ */
#if 0&&ZEND_DEBUG #if 0&&ZEND_DEBUG
original_sigsegv_handler = signal(SIGSEGV, zend_handle_sigsegv); original_sigsegv_handler = signal(SIGSEGV, zend_handle_sigsegv);
#endif #endif
//??? EG(return_value_ptr_ptr) = NULL;
EG(symtable_cache_ptr) = EG(symtable_cache) - 1; EG(symtable_cache_ptr) = EG(symtable_cache) - 1;
EG(symtable_cache_limit) = EG(symtable_cache) + SYMTABLE_CACHE_SIZE - 1; EG(symtable_cache_limit) = EG(symtable_cache) + SYMTABLE_CACHE_SIZE - 1;
@ -722,7 +721,6 @@ int call_user_function_ex(HashTable *function_table, zval *object, zval *functio
int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TSRMLS_DC) /* {{{ */ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TSRMLS_DC) /* {{{ */
{ {
zend_uint i; zend_uint i;
//??? zval **original_return_value;
HashTable *calling_symbol_table; HashTable *calling_symbol_table;
zend_op_array *original_op_array; zend_op_array *original_op_array;
zend_op **original_opline_ptr; zend_op **original_opline_ptr;
@ -912,16 +910,14 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
EG(active_symbol_table) = NULL; EG(active_symbol_table) = NULL;
} }
//??? original_return_value = EG(return_value_ptr_ptr);
original_op_array = EG(active_op_array); original_op_array = EG(active_op_array);
//??? EG(return_value_ptr_ptr) = fci->retval_ptr_ptr;
EG(active_op_array) = (zend_op_array *) EX(function_state).function; EG(active_op_array) = (zend_op_array *) EX(function_state).function;
original_opline_ptr = EG(opline_ptr); original_opline_ptr = EG(opline_ptr);
if (EG(active_op_array)->fn_flags & ZEND_ACC_GENERATOR) { if (EG(active_op_array)->fn_flags & ZEND_ACC_GENERATOR) {
//??? *fci->retval_ptr_ptr = zend_generator_create_zval(EG(active_op_array) TSRMLS_CC); zend_generator_create_zval(EG(active_op_array), fci->retval TSRMLS_CC);
} else { } else {
zend_execute(EG(active_op_array) TSRMLS_CC); zend_execute(EG(active_op_array), fci->retval TSRMLS_CC);
} }
if (!fci->symbol_table && EG(active_symbol_table)) { if (!fci->symbol_table && EG(active_symbol_table)) {
@ -929,7 +925,6 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
} }
EG(active_symbol_table) = calling_symbol_table; EG(active_symbol_table) = calling_symbol_table;
EG(active_op_array) = original_op_array; EG(active_op_array) = original_op_array;
//??? EG(return_value_ptr_ptr)=original_return_value;
EG(opline_ptr) = original_opline_ptr; EG(opline_ptr) = original_opline_ptr;
} else if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION) { } else if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION) {
int call_via_handler = (EX(function_state).function->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0; int call_via_handler = (EX(function_state).function->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0;
@ -1135,12 +1130,10 @@ ZEND_API int zend_eval_stringl(char *str, int str_len, zval *retval_ptr, char *s
CG(compiler_options) = original_compiler_options; CG(compiler_options) = original_compiler_options;
if (new_op_array) { if (new_op_array) {
//??? zval *local_retval_ptr=NULL; zval local_retval;
//??? zval **original_return_value_ptr_ptr = EG(return_value_ptr_ptr);
zend_op **original_opline_ptr = EG(opline_ptr); zend_op **original_opline_ptr = EG(opline_ptr);
int orig_interactive = CG(interactive); int orig_interactive = CG(interactive);
//??? EG(return_value_ptr_ptr) = &local_retval_ptr;
EG(active_op_array) = new_op_array; EG(active_op_array) = new_op_array;
EG(no_extensions)=1; EG(no_extensions)=1;
if (!EG(active_symbol_table)) { if (!EG(active_symbol_table)) {
@ -1149,7 +1142,8 @@ ZEND_API int zend_eval_stringl(char *str, int str_len, zval *retval_ptr, char *s
CG(interactive) = 0; CG(interactive) = 0;
zend_try { zend_try {
zend_execute(new_op_array TSRMLS_CC); ZVAL_UNDEF(&local_retval);
zend_execute(new_op_array, &local_retval TSRMLS_CC);
} zend_catch { } zend_catch {
destroy_op_array(new_op_array TSRMLS_CC); destroy_op_array(new_op_array TSRMLS_CC);
efree(new_op_array); efree(new_op_array);
@ -1157,24 +1151,23 @@ ZEND_API int zend_eval_stringl(char *str, int str_len, zval *retval_ptr, char *s
} zend_end_try(); } zend_end_try();
CG(interactive) = orig_interactive; CG(interactive) = orig_interactive;
//??? if (local_retval_ptr) { if (Z_TYPE(local_retval) != IS_UNDEF) {
//??? if (retval_ptr) { if (retval_ptr) {
//??? COPY_PZVAL_TO_ZVAL(*retval_ptr, local_retval_ptr); COPY_PZVAL_TO_ZVAL(*retval_ptr, &local_retval);
//??? } else { } else {
//??? zval_ptr_dtor(&local_retval_ptr); zval_ptr_dtor(&local_retval);
//??? } }
//??? } else { } else {
//??? if (retval_ptr) { if (retval_ptr) {
//??? INIT_ZVAL(*retval_ptr); ZVAL_NULL(retval_ptr);
//??? } }
//??? } }
EG(no_extensions)=0; EG(no_extensions)=0;
EG(opline_ptr) = original_opline_ptr; EG(opline_ptr) = original_opline_ptr;
EG(active_op_array) = original_active_op_array; EG(active_op_array) = original_active_op_array;
destroy_op_array(new_op_array TSRMLS_CC); destroy_op_array(new_op_array TSRMLS_CC);
efree(new_op_array); efree(new_op_array);
//??? EG(return_value_ptr_ptr) = original_return_value_ptr_ptr;
retval = SUCCESS; retval = SUCCESS;
} else { } else {
retval = FAILURE; retval = FAILURE;
@ -1268,11 +1261,10 @@ void execute_new_code(TSRMLS_D) /* {{{ */
zend_release_labels(1 TSRMLS_CC); zend_release_labels(1 TSRMLS_CC);
//??? EG(return_value_ptr_ptr) = NULL;
EG(active_op_array) = CG(active_op_array); EG(active_op_array) = CG(active_op_array);
orig_interactive = CG(interactive); orig_interactive = CG(interactive);
CG(interactive) = 0; CG(interactive) = 0;
zend_execute(CG(active_op_array) TSRMLS_CC); zend_execute(CG(active_op_array), NULL TSRMLS_CC);
CG(interactive) = orig_interactive; CG(interactive) = orig_interactive;
if (EG(exception)) { if (EG(exception)) {

View file

@ -282,7 +282,7 @@ ZEND_API void zend_generator_create_zval(zend_op_array *op_array, zval *return_v
opline_ptr = EG(opline_ptr); opline_ptr = EG(opline_ptr);
current_symbol_table = EG(active_symbol_table); current_symbol_table = EG(active_symbol_table);
EG(active_symbol_table) = NULL; EG(active_symbol_table) = NULL;
execute_data = zend_create_execute_data_from_op_array(op_array, 0 TSRMLS_CC); execute_data = zend_create_execute_data_from_op_array(op_array, return_value, 0 TSRMLS_CC);
EG(active_symbol_table) = current_symbol_table; EG(active_symbol_table) = current_symbol_table;
EG(current_execute_data) = current_execute_data; EG(current_execute_data) = current_execute_data;
EG(opline_ptr) = opline_ptr; EG(opline_ptr) = opline_ptr;
@ -331,7 +331,6 @@ ZEND_API void zend_generator_resume(zend_generator *generator TSRMLS_DC) /* {{{
{ {
/* Backup executor globals */ /* Backup executor globals */
//??? zval **original_return_value_ptr_ptr = EG(return_value_ptr_ptr);
zend_execute_data *original_execute_data = EG(current_execute_data); zend_execute_data *original_execute_data = EG(current_execute_data);
zend_op **original_opline_ptr = EG(opline_ptr); zend_op **original_opline_ptr = EG(opline_ptr);
zend_op_array *original_active_op_array = EG(active_op_array); zend_op_array *original_active_op_array = EG(active_op_array);
@ -343,10 +342,6 @@ ZEND_API void zend_generator_resume(zend_generator *generator TSRMLS_DC) /* {{{
ZVAL_COPY_VALUE(&original_This, &EG(This)); ZVAL_COPY_VALUE(&original_This, &EG(This));
/* We (mis)use the return_value_ptr_ptr to provide the generator object
* to the executor, so YIELD will be able to set the yielded value */
//??? EG(return_value_ptr_ptr) = (zval **) generator;
/* Set executor globals */ /* Set executor globals */
EG(current_execute_data) = generator->execute_data; EG(current_execute_data) = generator->execute_data;
EG(opline_ptr) = &generator->execute_data->opline; EG(opline_ptr) = &generator->execute_data->opline;
@ -371,7 +366,6 @@ ZEND_API void zend_generator_resume(zend_generator *generator TSRMLS_DC) /* {{{
generator->flags &= ~ZEND_GENERATOR_CURRENTLY_RUNNING; generator->flags &= ~ZEND_GENERATOR_CURRENTLY_RUNNING;
/* Restore executor globals */ /* Restore executor globals */
//??? EG(return_value_ptr_ptr) = original_return_value_ptr_ptr;
EG(current_execute_data) = original_execute_data; EG(current_execute_data) = original_execute_data;
EG(opline_ptr) = original_opline_ptr; EG(opline_ptr) = original_opline_ptr;
EG(active_op_array) = original_active_op_array; EG(active_op_array) = original_active_op_array;

View file

@ -158,8 +158,6 @@ struct _zend_compiler_globals {
struct _zend_executor_globals { struct _zend_executor_globals {
//??? zval **return_value_ptr_ptr;
zval uninitialized_zval; zval uninitialized_zval;
zval error_zval; zval error_zval;

View file

@ -948,7 +948,7 @@ ZEND_VM_HANDLER(40, ZEND_ECHO, CONST|TMP|VAR|CV, ANY)
z = GET_OP1_ZVAL_PTR(BP_VAR_R); z = GET_OP1_ZVAL_PTR(BP_VAR_R);
if (OP1_TYPE == IS_TMP_VAR && Z_TYPE_P(z) == IS_OBJECT) { if (OP1_TYPE == IS_TMP_VAR && Z_TYPE_P(z) == IS_OBJECT) {
//??? INIT_PZVAL(z); Z_SET_REFCOUNT_P(z, 1);
} }
zend_print_variable(z); zend_print_variable(z);
@ -1771,7 +1771,6 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY)
EG(opline_ptr) = &EX(opline); EG(opline_ptr) = &EX(opline);
EG(active_op_array) = EX(op_array); EG(active_op_array) = EX(op_array);
//??? EG(return_value_ptr_ptr) = EX(original_return_value);
destroy_op_array(op_array TSRMLS_CC); destroy_op_array(op_array TSRMLS_CC);
efree(op_array); efree(op_array);
if (UNEXPECTED(EG(exception) != NULL)) { if (UNEXPECTED(EG(exception) != NULL)) {
@ -1784,7 +1783,6 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY)
} else { } else {
EG(opline_ptr) = &EX(opline); EG(opline_ptr) = &EX(opline);
EG(active_op_array) = EX(op_array); EG(active_op_array) = EX(op_array);
//??? EG(return_value_ptr_ptr) = EX(original_return_value);
if (EG(active_symbol_table)) { if (EG(active_symbol_table)) {
zend_clean_and_cache_symbol_table(EG(active_symbol_table) TSRMLS_CC); zend_clean_and_cache_symbol_table(EG(active_symbol_table) TSRMLS_CC);
} }
@ -1814,7 +1812,7 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY)
if (UNEXPECTED(EG(exception) != NULL)) { if (UNEXPECTED(EG(exception) != NULL)) {
zend_throw_exception_internal(NULL TSRMLS_CC); zend_throw_exception_internal(NULL TSRMLS_CC);
if (RETURN_VALUE_USED(opline) /*???&& EX_VAR(opline->result.var).var.ptr*/) { if (RETURN_VALUE_USED(opline) /*???&& EX_VAR(opline->result.var) */) {
zval_ptr_dtor(EX_VAR(opline->result.var)); zval_ptr_dtor(EX_VAR(opline->result.var));
} }
HANDLE_EXCEPTION_LEAVE(); HANDLE_EXCEPTION_LEAVE();
@ -1917,15 +1915,14 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY)
//??? EX_T(opline->result.var).var.ptr = NULL; //??? EX_T(opline->result.var).var.ptr = NULL;
} }
} else if (fbc->type == ZEND_USER_FUNCTION) { } else if (fbc->type == ZEND_USER_FUNCTION) {
//??? EX(original_return_value) = EG(return_value_ptr_ptr); zval *return_value = NULL;
EG(active_symbol_table) = NULL; EG(active_symbol_table) = NULL;
EG(active_op_array) = &fbc->op_array; EG(active_op_array) = &fbc->op_array;
//??? EG(return_value_ptr_ptr) = NULL;
if (RETURN_VALUE_USED(opline)) { if (RETURN_VALUE_USED(opline)) {
zval *ret = EX_VAR(opline->result.var); return_value = EX_VAR(opline->result.var);
ZVAL_NULL(ret); ZVAL_NULL(return_value);
//??? EG(return_value_ptr_ptr) = &ret->var.ptr;
//??? ret->var.ptr_ptr = &ret->var.ptr; //??? ret->var.ptr_ptr = &ret->var.ptr;
//??? ret->var.fcall_returned_reference = (fbc->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) != 0; //??? ret->var.fcall_returned_reference = (fbc->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) != 0;
} }
@ -1936,15 +1933,15 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY)
} }
} else if (EXPECTED(zend_execute_ex == execute_ex)) { } else if (EXPECTED(zend_execute_ex == execute_ex)) {
if (EXPECTED(EG(exception) == NULL)) { if (EXPECTED(EG(exception) == NULL)) {
i_create_execute_data_from_op_array(EG(active_op_array), return_value, 1 TSRMLS_CC);
ZEND_VM_ENTER(); ZEND_VM_ENTER();
} }
} else { } else {
zend_execute(EG(active_op_array) TSRMLS_CC); zend_execute(EG(active_op_array), return_value TSRMLS_CC);
} }
EG(opline_ptr) = &EX(opline); EG(opline_ptr) = &EX(opline);
EG(active_op_array) = EX(op_array); EG(active_op_array) = EX(op_array);
//??? EG(return_value_ptr_ptr) = EX(original_return_value);
if (EG(active_symbol_table)) { if (EG(active_symbol_table)) {
zend_clean_and_cache_symbol_table(EG(active_symbol_table) TSRMLS_CC); zend_clean_and_cache_symbol_table(EG(active_symbol_table) TSRMLS_CC);
} }
@ -2733,7 +2730,7 @@ ZEND_VM_HANDLER(62, ZEND_RETURN, CONST|TMP|VAR|CV, ANY)
SAVE_OPLINE(); SAVE_OPLINE();
retval_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R); retval_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
if (/*???!EG(return_value_ptr_ptr)*/0) { if (!EX(return_value)) {
FREE_OP1(); FREE_OP1();
} else { } else {
if (OP1_TYPE == IS_CONST || if (OP1_TYPE == IS_CONST ||
@ -2745,10 +2742,10 @@ ZEND_VM_HANDLER(62, ZEND_RETURN, CONST|TMP|VAR|CV, ANY)
if (OP1_TYPE != IS_TMP_VAR) { if (OP1_TYPE != IS_TMP_VAR) {
zval_copy_ctor(&ret); zval_copy_ctor(&ret);
} }
//??? *EG(return_value_ptr_ptr) = ret; ZVAL_COPY_VALUE(EX(return_value), &ret);
FREE_OP1_IF_VAR(); FREE_OP1_IF_VAR();
} else { } else {
//??? *EG(return_value_ptr_ptr) = retval_ptr; ZVAL_COPY_VALUE(EX(return_value), retval_ptr);
if (OP1_TYPE == IS_CV) { if (OP1_TYPE == IS_CV) {
Z_ADDREF_P(retval_ptr); Z_ADDREF_P(retval_ptr);
} }
@ -2772,20 +2769,14 @@ ZEND_VM_HANDLER(111, ZEND_RETURN_BY_REF, CONST|TMP|VAR|CV, ANY)
zend_error(E_NOTICE, "Only variable references should be returned by reference"); zend_error(E_NOTICE, "Only variable references should be returned by reference");
retval_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R); retval_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
if (/*???!EG(return_value_ptr_ptr)*/0) { if (!EX(return_value)) {
if (OP1_TYPE == IS_TMP_VAR) { if (OP1_TYPE == IS_TMP_VAR) {
FREE_OP1(); FREE_OP1();
} }
} else if (!IS_OP1_TMP_FREE()) { /* Not a temp var */ } else if (!IS_OP1_TMP_FREE()) { /* Not a temp var */
zval ret; ZVAL_DUP(EX(return_value), retval_ptr);
ZVAL_DUP(&ret, retval_ptr);
//??? *EG(return_value_ptr_ptr) = ret;
} else { } else {
zval ret; ZVAL_COPY_VALUE(EX(return_value), retval_ptr);
ZVAL_COPY_VALUE(&ret, retval_ptr);
//??? *EG(return_value_ptr_ptr) = ret;
} }
break; break;
} }
@ -2796,31 +2787,22 @@ ZEND_VM_HANDLER(111, ZEND_RETURN_BY_REF, CONST|TMP|VAR|CV, ANY)
zend_error_noreturn(E_ERROR, "Cannot return string offsets by reference"); zend_error_noreturn(E_ERROR, "Cannot return string offsets by reference");
} }
//??? if (OP1_TYPE == IS_VAR && !Z_ISREF_P(retval_ptr)) {
#if 0 //??? if (opline->extended_value == ZEND_RETURNS_FUNCTION &&
if (OP1_TYPE == IS_VAR && !Z_ISREF_PP(retval_ptr_ptr)) { //??? EX_T(opline->op1.var).var.fcall_returned_reference) {
if (opline->extended_value == ZEND_RETURNS_FUNCTION && //??? } else if (EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) {
EX_T(opline->op1.var).var.fcall_returned_reference) {
} else if (EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) {
zend_error(E_NOTICE, "Only variable references should be returned by reference"); zend_error(E_NOTICE, "Only variable references should be returned by reference");
if (EG(return_value_ptr_ptr)) { if (EX(return_value)) {
zval *ret; ZVAL_DUP(EX(return_value), retval_ptr);
ALLOC_ZVAL(ret);
INIT_DUP(ret, *retval_ptr_ptr);
*EG(return_value_ptr_ptr) = ret;
} }
break; break;
} //??? }
} }
if (EG(return_value_ptr_ptr)) { if (EX(return_value)) {
SEPARATE_ZVAL_TO_MAKE_IS_REF(retval_ptr_ptr); SEPARATE_ZVAL_TO_MAKE_IS_REF(retval_ptr);
Z_ADDREF_PP(retval_ptr_ptr); ZVAL_COPY(EX(return_value), retval_ptr);
*EG(return_value_ptr_ptr) = *retval_ptr_ptr;
} }
#endif
} while (0); } while (0);
FREE_OP1_VAR_PTR(); FREE_OP1_VAR_PTR();
@ -2830,10 +2812,10 @@ ZEND_VM_HANDLER(111, ZEND_RETURN_BY_REF, CONST|TMP|VAR|CV, ANY)
ZEND_VM_HANDLER(161, ZEND_GENERATOR_RETURN, ANY, ANY) ZEND_VM_HANDLER(161, ZEND_GENERATOR_RETURN, ANY, ANY)
{ {
/* The generator object is stored in return_value_ptr_ptr */ /* The generator object is stored in return_value_ptr_ptr */
//??? zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); zend_generator *generator = (zend_generator *) Z_OBJ_P(EX(return_value));
/* Close the generator to free up resources */ /* Close the generator to free up resources */
//??? zend_generator_close(generator, 1 TSRMLS_CC); zend_generator_close(generator, 1 TSRMLS_CC);
/* Pass execution back to handling code */ /* Pass execution back to handling code */
ZEND_VM_RETURN(); ZEND_VM_RETURN();
@ -3847,13 +3829,11 @@ ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMP|VAR|CV, ANY)
if (UNEXPECTED(EG(exception) != NULL)) { if (UNEXPECTED(EG(exception) != NULL)) {
HANDLE_EXCEPTION(); HANDLE_EXCEPTION();
} else if (EXPECTED(new_op_array != NULL)) { } else if (EXPECTED(new_op_array != NULL)) {
//??? EX(original_return_value) = EG(return_value_ptr_ptr); zval *return_value = NULL;
EG(active_op_array) = new_op_array; EG(active_op_array) = new_op_array;
if (RETURN_VALUE_USED(opline)) { if (RETURN_VALUE_USED(opline)) {
//??? EX_T(opline->result.var).var.ptr_ptr = &EX_T(opline->result.var).var.ptr; return_value = EX_VAR(opline->result.var);
//??? EG(return_value_ptr_ptr) = EX_T(opline->result.var).var.ptr_ptr;
} else {
//??? EG(return_value_ptr_ptr) = NULL;
} }
EX(function_state).function = (zend_function *) new_op_array; EX(function_state).function = (zend_function *) new_op_array;
@ -3864,16 +3844,16 @@ ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMP|VAR|CV, ANY)
} }
if (EXPECTED(zend_execute_ex == execute_ex)) { if (EXPECTED(zend_execute_ex == execute_ex)) {
i_create_execute_data_from_op_array(new_op_array, return_value, 1 TSRMLS_CC);
ZEND_VM_ENTER(); ZEND_VM_ENTER();
} else { } else {
zend_execute(new_op_array TSRMLS_CC); zend_execute(new_op_array, return_value TSRMLS_CC);
} }
EX(function_state).function = (zend_function *) EX(op_array); EX(function_state).function = (zend_function *) EX(op_array);
EG(opline_ptr) = &EX(opline); EG(opline_ptr) = &EX(opline);
EG(active_op_array) = EX(op_array); EG(active_op_array) = EX(op_array);
//??? EG(return_value_ptr_ptr) = EX(original_return_value);
destroy_op_array(new_op_array TSRMLS_CC); destroy_op_array(new_op_array TSRMLS_CC);
efree(new_op_array); efree(new_op_array);
if (UNEXPECTED(EG(exception) != NULL)) { if (UNEXPECTED(EG(exception) != NULL)) {
@ -5227,27 +5207,20 @@ ZEND_VM_HANDLER(156, ZEND_SEPARATE, VAR, UNUSED)
ZEND_VM_HANDLER(160, ZEND_YIELD, CONST|TMP|VAR|CV|UNUSED, CONST|TMP|VAR|CV|UNUSED) ZEND_VM_HANDLER(160, ZEND_YIELD, CONST|TMP|VAR|CV|UNUSED, CONST|TMP|VAR|CV|UNUSED)
{ {
//???
return 0;
#if 0
USE_OPLINE USE_OPLINE
/* The generator object is stored in return_value_ptr_ptr */ /* The generator object is stored in return_value_ptr_ptr */
zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); zend_generator *generator = (zend_generator *) Z_OBJ_P(EX(return_value));
if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) {
zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator");
} }
/* Destroy the previously yielded value */ /* Destroy the previously yielded value */
if (generator->value) { zval_ptr_dtor(&generator->value);
zval_ptr_dtor(&generator->value);
}
/* Destroy the previously yielded key */ /* Destroy the previously yielded key */
if (generator->key) { zval_ptr_dtor(&generator->key);
zval_ptr_dtor(&generator->key);
}
/* Set the new yielded value */ /* Set the new yielded value */
if (OP1_TYPE != IS_UNUSED) { if (OP1_TYPE != IS_UNUSED) {
@ -5257,42 +5230,37 @@ return 0;
/* Constants and temporary variables aren't yieldable by reference, /* Constants and temporary variables aren't yieldable by reference,
* but we still allow them with a notice. */ * but we still allow them with a notice. */
if (OP1_TYPE == IS_CONST || OP1_TYPE == IS_TMP_VAR) { if (OP1_TYPE == IS_CONST || OP1_TYPE == IS_TMP_VAR) {
zval *value, *copy; zval *value;
zend_error(E_NOTICE, "Only variable references should be yielded by reference"); zend_error(E_NOTICE, "Only variable references should be yielded by reference");
value = GET_OP1_ZVAL_PTR(BP_VAR_R); value = GET_OP1_ZVAL_PTR(BP_VAR_R);
ALLOC_ZVAL(copy); ZVAL_COPY_VALUE(&generator->value, value);
INIT_PZVAL_COPY(copy, value); Z_SET_REFCOUNT(generator->value, 1);
/* Temporary variables don't need ctor copying */ /* Temporary variables don't need ctor copying */
if (!IS_OP1_TMP_FREE()) { if (!IS_OP1_TMP_FREE()) {
zval_copy_ctor(copy); zval_copy_ctor(&generator->value);
} }
generator->value = copy;
} else { } else {
zval **value_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W); zval *value_ptr = GET_OP1_ZVAL_PTR(BP_VAR_W);
if (OP1_TYPE == IS_VAR && UNEXPECTED(value_ptr == NULL)) { if (OP1_TYPE == IS_VAR && UNEXPECTED(Z_TYPE_P(value_ptr) == IS_STR_OFFSET)) {
zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference");
} }
/* If a function call result is yielded and the function did /* If a function call result is yielded and the function did
* not return by reference we throw a notice. */ * not return by reference we throw a notice. */
if (OP1_TYPE == IS_VAR && !Z_ISREF_PP(value_ptr) if (OP1_TYPE == IS_VAR && !Z_ISREF_P(value_ptr)
&& !(opline->extended_value == ZEND_RETURNS_FUNCTION //??? && !(opline->extended_value == ZEND_RETURNS_FUNCTION
&& EX_T(opline->op1.var).var.fcall_returned_reference) //??? && EX_T(opline->op1.var).var.fcall_returned_reference)
&& EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { //??? && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) {
) {
zend_error(E_NOTICE, "Only variable references should be yielded by reference"); zend_error(E_NOTICE, "Only variable references should be yielded by reference");
Z_ADDREF_PP(value_ptr);
generator->value = *value_ptr;
} else { } else {
SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr);
Z_ADDREF_PP(value_ptr);
generator->value = *value_ptr;
} }
ZVAL_COPY(&generator->value, value_ptr);
FREE_OP1_VAR_PTR(); FREE_OP1_VAR_PTR();
} }
@ -5303,29 +5271,26 @@ return 0;
if (OP1_TYPE == IS_CONST || OP1_TYPE == IS_TMP_VAR if (OP1_TYPE == IS_CONST || OP1_TYPE == IS_TMP_VAR
|| Z_ISREF_P(value) || Z_ISREF_P(value)
) { ) {
zval *copy; //??? INIT_PZVAL_COPY(copy, value);
ZVAL_COPY_VALUE(&generator->value, value);
ALLOC_ZVAL(copy); Z_SET_REFCOUNT(generator->value, 1);
INIT_PZVAL_COPY(copy, value);
/* Temporary variables don't need ctor copying */ /* Temporary variables don't need ctor copying */
if (!IS_OP1_TMP_FREE()) { if (!IS_OP1_TMP_FREE()) {
zval_copy_ctor(copy); zval_copy_ctor(&generator->value);
} }
generator->value = copy;
FREE_OP1_IF_VAR(); FREE_OP1_IF_VAR();
} else { } else {
if (OP1_TYPE == IS_CV) { if (OP1_TYPE == IS_CV) {
Z_ADDREF_P(value); Z_ADDREF_P(value);
} }
generator->value = value; ZVAL_COPY_VALUE(&generator->value, value);
} }
} }
} else { } else {
/* If no value was specified yield null */ /* If no value was specified yield null */
Z_ADDREF(EG(uninitialized_zval)); ZVAL_NULL(&generator->value);
generator->value = &EG(uninitialized_zval);
} }
/* Set the new yielded key */ /* Set the new yielded key */
@ -5337,43 +5302,36 @@ return 0;
if (OP2_TYPE == IS_CONST || OP2_TYPE == IS_TMP_VAR if (OP2_TYPE == IS_CONST || OP2_TYPE == IS_TMP_VAR
|| (Z_ISREF_P(key) && Z_REFCOUNT_P(key) > 0) || (Z_ISREF_P(key) && Z_REFCOUNT_P(key) > 0)
) { ) {
zval *copy; //??? INIT_PZVAL_COPY(copy, key);
ZVAL_COPY_VALUE(&generator->key, key);
ALLOC_ZVAL(copy); Z_SET_REFCOUNT(generator->key, 1);
INIT_PZVAL_COPY(copy, key);
/* Temporary variables don't need ctor copying */ /* Temporary variables don't need ctor copying */
if (!IS_OP2_TMP_FREE()) { if (!IS_OP2_TMP_FREE()) {
zval_copy_ctor(copy); zval_copy_ctor(&generator->key);
} }
generator->key = copy;
} else { } else {
Z_ADDREF_P(key); ZVAL_COPY(&generator->key, key);
generator->key = key;
} }
if (Z_TYPE_P(generator->key) == IS_LONG if (Z_TYPE(generator->key) == IS_LONG
&& Z_LVAL_P(generator->key) > generator->largest_used_integer_key && Z_LVAL(generator->key) > generator->largest_used_integer_key
) { ) {
generator->largest_used_integer_key = Z_LVAL_P(generator->key); generator->largest_used_integer_key = Z_LVAL(generator->key);
} }
FREE_OP2_IF_VAR(); FREE_OP2_IF_VAR();
} else { } else {
/* If no key was specified we use auto-increment keys */ /* If no key was specified we use auto-increment keys */
generator->largest_used_integer_key++; generator->largest_used_integer_key++;
ZVAL_LONG(&generator->key, generator->largest_used_integer_key);
ALLOC_INIT_ZVAL(generator->key);
ZVAL_LONG(generator->key, generator->largest_used_integer_key);
} }
if (RETURN_VALUE_USED(opline)) { if (RETURN_VALUE_USED(opline)) {
/* If the return value of yield is used set the send /* If the return value of yield is used set the send
* target and initialize it to NULL */ * target and initialize it to NULL */
generator->send_target = &EX_T(opline->result.var).var.ptr; generator->send_target = EX_VAR(opline->result.var);
Z_ADDREF(EG(uninitialized_zval)); ZVAL_NULL(generator->send_target);
EX_T(opline->result.var).var.ptr = &EG(uninitialized_zval);
} else { } else {
generator->send_target = NULL; generator->send_target = NULL;
} }
@ -5387,7 +5345,6 @@ return 0;
SAVE_OPLINE(); SAVE_OPLINE();
ZEND_VM_RETURN(); ZEND_VM_RETURN();
#endif
} }
ZEND_VM_HANDLER(159, ZEND_DISCARD_EXCEPTION, ANY, ANY) ZEND_VM_HANDLER(159, ZEND_DISCARD_EXCEPTION, ANY, ANY)

File diff suppressed because it is too large Load diff

View file

@ -12,11 +12,6 @@ ZEND_API void {%EXECUTOR_NAME%}_ex(zend_execute_data *execute_data TSRMLS_DC)
original_in_execution = EG(in_execution); original_in_execution = EG(in_execution);
EG(in_execution) = 1; EG(in_execution) = 1;
if (0) {
zend_vm_enter:
execute_data = i_create_execute_data_from_op_array(EG(active_op_array), 1 TSRMLS_CC);
}
LOAD_REGS(); LOAD_REGS();
LOAD_OPLINE(); LOAD_OPLINE();
@ -36,12 +31,12 @@ zend_vm_enter:
zend_error_noreturn(E_ERROR, "Arrived at end of main loop which shouldn't happen"); zend_error_noreturn(E_ERROR, "Arrived at end of main loop which shouldn't happen");
} }
ZEND_API void zend_{%EXECUTOR_NAME%}(zend_op_array *op_array TSRMLS_DC) ZEND_API void zend_{%EXECUTOR_NAME%}(zend_op_array *op_array, zval *return_value TSRMLS_DC)
{ {
if (EG(exception) != NULL) { if (EG(exception) != NULL) {
return; return;
} }
zend_{%EXECUTOR_NAME%}_ex(i_create_execute_data_from_op_array(op_array, 0 TSRMLS_CC) TSRMLS_CC); zend_{%EXECUTOR_NAME%}_ex(i_create_execute_data_from_op_array(op_array, return_value, 0 TSRMLS_CC) TSRMLS_CC);
} }
{%EXTERNAL_EXECUTOR%} {%EXTERNAL_EXECUTOR%}

View file

@ -827,7 +827,7 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name,
out($f,"#define LOAD_REGS()\n"); out($f,"#define LOAD_REGS()\n");
out($f,"#define ZEND_VM_CONTINUE() goto zend_vm_continue\n"); out($f,"#define ZEND_VM_CONTINUE() goto zend_vm_continue\n");
out($f,"#define ZEND_VM_RETURN() EG(in_execution) = original_in_execution; return\n"); out($f,"#define ZEND_VM_RETURN() EG(in_execution) = original_in_execution; return\n");
out($f,"#define ZEND_VM_ENTER() goto zend_vm_enter\n"); out($f,"#define ZEND_VM_ENTER() ZEND_VM_CONTINUE()\n");
out($f,"#define ZEND_VM_LEAVE() ZEND_VM_CONTINUE()\n"); out($f,"#define ZEND_VM_LEAVE() ZEND_VM_CONTINUE()\n");
out($f,"#define ZEND_VM_DISPATCH(opcode, opline) dispatch_handler = zend_vm_get_opcode_handler(opcode, opline); goto zend_vm_dispatch;\n\n"); out($f,"#define ZEND_VM_DISPATCH(opcode, opline) dispatch_handler = zend_vm_get_opcode_handler(opcode, opline); goto zend_vm_dispatch;\n\n");
out($f,"#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC\n"); out($f,"#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC\n");
@ -859,7 +859,7 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name,
out($f,"#define LOAD_REGS()\n"); out($f,"#define LOAD_REGS()\n");
out($f,"#define ZEND_VM_CONTINUE() goto *(void**)(OPLINE->handler)\n"); out($f,"#define ZEND_VM_CONTINUE() goto *(void**)(OPLINE->handler)\n");
out($f,"#define ZEND_VM_RETURN() EG(in_execution) = original_in_execution; return\n"); out($f,"#define ZEND_VM_RETURN() EG(in_execution) = original_in_execution; return\n");
out($f,"#define ZEND_VM_ENTER() goto zend_vm_enter\n"); out($f,"#define ZEND_VM_ENTER() ZEND_VM_CONTINUE()\n");
out($f,"#define ZEND_VM_LEAVE() ZEND_VM_CONTINUE()\n"); out($f,"#define ZEND_VM_LEAVE() ZEND_VM_CONTINUE()\n");
out($f,"#define ZEND_VM_DISPATCH(opcode, opline) goto *(void**)(zend_vm_get_opcode_handler(opcode, opline));\n\n"); out($f,"#define ZEND_VM_DISPATCH(opcode, opline) goto *(void**)(zend_vm_get_opcode_handler(opcode, opline));\n\n");
out($f,"#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC\n"); out($f,"#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC\n");
@ -931,8 +931,6 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name,
$m[1]."\t\tEG(in_execution) = original_in_execution;\n". $m[1]."\t\tEG(in_execution) = original_in_execution;\n".
$m[1]."\t\treturn;\n". $m[1]."\t\treturn;\n".
$m[1]."\tcase 2:\n" . $m[1]."\tcase 2:\n" .
$m[1]."\t\tgoto zend_vm_enter;\n".
$m[1]."\t\tbreak;\n" .
$m[1]."\tcase 3:\n" . $m[1]."\tcase 3:\n" .
$m[1]."\t\texecute_data = EG(current_execute_data);\n". $m[1]."\t\texecute_data = EG(current_execute_data);\n".
$m[1]."\t\tbreak;\n" . $m[1]."\t\tbreak;\n" .

View file

@ -252,7 +252,7 @@ static int spl_autoload(zend_string *class_name, zend_string *lc_name, const cha
zval dummy; zval dummy;
zend_file_handle file_handle; zend_file_handle file_handle;
zend_op_array *new_op_array; zend_op_array *new_op_array;
zval *result = NULL; zval result;
int ret; int ret;
class_file_len = spprintf(&class_file, 0, "%s%.*s", lc_name->val, ext_len, ext); class_file_len = spprintf(&class_file, 0, "%s%.*s", lc_name->val, ext_len, ext);
@ -286,21 +286,18 @@ static int spl_autoload(zend_string *class_name, zend_string *lc_name, const cha
} }
STR_FREE(opened_path); STR_FREE(opened_path);
if (new_op_array) { if (new_op_array) {
//!!! EG(return_value_ptr_ptr) = &result;
EG(active_op_array) = new_op_array; EG(active_op_array) = new_op_array;
if (!EG(active_symbol_table)) { if (!EG(active_symbol_table)) {
zend_rebuild_symbol_table(TSRMLS_C); zend_rebuild_symbol_table(TSRMLS_C);
} }
zend_execute(new_op_array TSRMLS_CC); ZVAL_UNDEF(&result);
zend_execute(new_op_array, &result TSRMLS_CC);
destroy_op_array(new_op_array TSRMLS_CC); destroy_op_array(new_op_array TSRMLS_CC);
efree(new_op_array); efree(new_op_array);
if (!EG(exception)) { if (!EG(exception)) {
/*!!! if (EG(return_value_ptr_ptr)) { zval_ptr_dtor(&result);
zval_ptr_dtor(EG(return_value_ptr_ptr));
}
*/
} }
efree(class_file); efree(class_file);
@ -318,7 +315,6 @@ PHP_FUNCTION(spl_autoload)
int found = 0, pos_len; int found = 0, pos_len;
char *pos, *pos1; char *pos, *pos1;
zend_string *class_name, *lc_name, *file_exts = SPL_G(autoload_extensions); zend_string *class_name, *lc_name, *file_exts = SPL_G(autoload_extensions);
//!!! zval **original_return_value = EG(return_value_ptr_ptr);
zend_op **original_opline_ptr = EG(opline_ptr); zend_op **original_opline_ptr = EG(opline_ptr);
zend_op_array *original_active_op_array = EG(active_op_array); zend_op_array *original_active_op_array = EG(active_op_array);
@ -337,7 +333,6 @@ PHP_FUNCTION(spl_autoload)
lc_name = STR_ALLOC(class_name->len, 0); lc_name = STR_ALLOC(class_name->len, 0);
zend_str_tolower_copy(lc_name->val, class_name->val, class_name->len); zend_str_tolower_copy(lc_name->val, class_name->val, class_name->len);
while (pos && *pos && !EG(exception)) { while (pos && *pos && !EG(exception)) {
//!!! EG(return_value_ptr_ptr) = original_return_value;
EG(opline_ptr) = original_opline_ptr; EG(opline_ptr) = original_opline_ptr;
EG(active_op_array) = original_active_op_array; EG(active_op_array) = original_active_op_array;
pos1 = strchr(pos, ','); pos1 = strchr(pos, ',');
@ -353,7 +348,6 @@ PHP_FUNCTION(spl_autoload)
} }
STR_FREE(lc_name); STR_FREE(lc_name);
//!!! EG(return_value_ptr_ptr) = original_return_value;
EG(opline_ptr) = original_opline_ptr; EG(opline_ptr) = original_opline_ptr;
EG(active_op_array) = original_active_op_array; EG(active_op_array) = original_active_op_array;
@ -365,7 +359,7 @@ PHP_FUNCTION(spl_autoload)
if (active_opline->opcode != ZEND_FETCH_CLASS) { if (active_opline->opcode != ZEND_FETCH_CLASS) {
zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Class %s could not be loaded", class_name); zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Class %s could not be loaded", class_name);
} else { } else {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Class %s could not be loaded", class_name); php_error_docref(NULL TSRMLS_CC, E_ERROR, "Class %s could not be loaded", class_name->val);
} }
} }
} /* }}} */ } /* }}} */
@ -743,18 +737,17 @@ PHP_FUNCTION(spl_autoload_functions)
Z_ADDREF_P(alfi->closure); Z_ADDREF_P(alfi->closure);
add_next_index_zval(return_value, alfi->closure); add_next_index_zval(return_value, alfi->closure);
} else if (alfi->func_ptr->common.scope) { } else if (alfi->func_ptr->common.scope) {
zval *tmp; zval tmp;
MAKE_STD_ZVAL(tmp);
array_init(tmp);
array_init(&tmp);
if (alfi->obj) { if (alfi->obj) {
Z_ADDREF_P(alfi->obj); Z_ADDREF_P(alfi->obj);
add_next_index_zval(tmp, alfi->obj); add_next_index_zval(&tmp, alfi->obj);
} else { } else {
add_next_index_str(tmp, alfi->ce->name); add_next_index_str(&tmp, alfi->ce->name);
} }
add_next_index_str(tmp, alfi->func_ptr->common.function_name); add_next_index_str(&tmp, alfi->func_ptr->common.function_name);
add_next_index_zval(return_value, tmp); add_next_index_zval(return_value, &tmp);
} else { } else {
if (strncmp(alfi->func_ptr->common.function_name->val, "__lambda_func", sizeof("__lambda_func") - 1)) { if (strncmp(alfi->func_ptr->common.function_name->val, "__lambda_func", sizeof("__lambda_func") - 1)) {
add_next_index_str(return_value, alfi->func_ptr->common.function_name); add_next_index_str(return_value, alfi->func_ptr->common.function_name);
@ -817,11 +810,11 @@ PHPAPI void php_spl_object_hash(zval *obj, char *result TSRMLS_DC) /* {{{*/
} }
/* }}} */ /* }}} */
int spl_build_class_list_string(zval **entry, char **list TSRMLS_DC) /* {{{ */ int spl_build_class_list_string(zval *entry, char **list TSRMLS_DC) /* {{{ */
{ {
char *res; char *res;
spprintf(&res, 0, "%s, %s", *list, Z_STRVAL_PP(entry)); spprintf(&res, 0, "%s, %s", *list, Z_STRVAL_P(entry));
efree(*list); efree(*list);
*list = res; *list = res;
return ZEND_HASH_APPLY_KEEP; return ZEND_HASH_APPLY_KEEP;
@ -837,7 +830,6 @@ PHP_MINFO_FUNCTION(spl)
php_info_print_table_start(); php_info_print_table_start();
php_info_print_table_header(2, "SPL support", "enabled"); php_info_print_table_header(2, "SPL support", "enabled");
INIT_PZVAL(&list);
array_init(&list); array_init(&list);
SPL_LIST_CLASSES(&list, 0, 1, ZEND_ACC_INTERFACE) SPL_LIST_CLASSES(&list, 0, 1, ZEND_ACC_INTERFACE)
strg = estrdup(""); strg = estrdup("");
@ -846,7 +838,6 @@ PHP_MINFO_FUNCTION(spl)
php_info_print_table_row(2, "Interfaces", strg + 2); php_info_print_table_row(2, "Interfaces", strg + 2);
efree(strg); efree(strg);
INIT_PZVAL(&list);
array_init(&list); array_init(&list);
SPL_LIST_CLASSES(&list, 0, -1, ZEND_ACC_INTERFACE) SPL_LIST_CLASSES(&list, 0, -1, ZEND_ACC_INTERFACE)
strg = estrdup(""); strg = estrdup("");