diff options
author | Dmitry Stogov <dmitry@zend.com> | 2014-07-02 23:29:53 +0400 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2014-07-02 23:29:53 +0400 |
commit | 63c057e3313918a800ad7faebdb648216ddba4c0 (patch) | |
tree | 04ede4c58aa008868e82606b16cafc9d51757f87 | |
parent | 4b09dd69e6bd31f4010bf48e9e07e63cb5f3c2a4 (diff) | |
download | php-git-63c057e3313918a800ad7faebdb648216ddba4c0.tar.gz |
Removed EG(opline_ptr) and use corresponding value from EG(current_execute_data)
-rw-r--r-- | Zend/zend.c | 19 | ||||
-rw-r--r-- | Zend/zend_API.c | 2 | ||||
-rw-r--r-- | Zend/zend_execute.c | 1 | ||||
-rw-r--r-- | Zend/zend_execute.h | 2 | ||||
-rw-r--r-- | Zend/zend_execute_API.c | 7 | ||||
-rw-r--r-- | Zend/zend_generators.c | 8 | ||||
-rw-r--r-- | Zend/zend_globals.h | 2 | ||||
-rw-r--r-- | Zend/zend_vm_def.h | 5 | ||||
-rw-r--r-- | Zend/zend_vm_execute.h | 8 | ||||
-rw-r--r-- | ext/opcache/ZendAccelerator.c | 66 | ||||
-rw-r--r-- | ext/spl/php_spl.c | 11 | ||||
-rw-r--r-- | main/main.c | 3 |
12 files changed, 56 insertions, 78 deletions
diff --git a/Zend/zend.c b/Zend/zend.c index 1d77665bc2..68ed5c9fd1 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -938,7 +938,7 @@ void zend_call_destructors(TSRMLS_D) /* {{{ */ ZEND_API void zend_deactivate(TSRMLS_D) /* {{{ */ { /* we're no longer executing anything */ - EG(opline_ptr) = NULL; + EG(current_execute_data) = NULL; EG(active_symbol_table) = NULL; zend_try { @@ -1042,6 +1042,9 @@ ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */ /* Report about uncaught exception in case of fatal errors */ if (EG(exception)) { + zend_execute_data *ex; + zend_op *opline; + switch (type) { case E_CORE_ERROR: case E_ERROR: @@ -1049,13 +1052,19 @@ ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */ case E_PARSE: case E_COMPILE_ERROR: case E_USER_ERROR: - if (zend_is_executing(TSRMLS_C)) { - error_lineno = zend_get_executed_lineno(TSRMLS_C); + ex = EG(current_execute_data); + opline = NULL; + while (ex && (!ex->func || !ZEND_USER_CODE(ex->func->type))) { + ex = ex->prev_execute_data; + } + if (ex && ex->opline && ex->opline->opcode == ZEND_HANDLE_EXCEPTION && + EG(opline_before_exception)) { + opline = EG(opline_before_exception); } zend_exception_error(EG(exception), E_WARNING TSRMLS_CC); EG(exception) = NULL; - if (zend_is_executing(TSRMLS_C) && EG(opline_ptr)) { - active_opline->lineno = error_lineno; + if (opline) { + ex->opline = opline; } break; default: diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 3a96574fcc..36b615ba1b 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -2494,7 +2494,7 @@ static int module_registry_cleanup(zval *zv TSRMLS_DC) /* {{{ */ ZEND_API void zend_deactivate_modules(TSRMLS_D) /* {{{ */ { - EG(opline_ptr) = NULL; /* we're no longer executing anything */ + EG(current_execute_data) = NULL; /* we're no longer executing anything */ zend_try { if (EG(full_tables_cleanup)) { diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index a40bb4cefd..e551ba67b2 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1555,7 +1555,6 @@ static zend_always_inline void i_init_execute_data(zend_execute_data *execute_da EX(delayed_exception) = NULL; EX(call) = NULL; - EG(opline_ptr) = &EX(opline); EX(opline) = UNEXPECTED((op_array->fn_flags & ZEND_ACC_INTERACTIVE) != 0) && EG(start_op) ? EG(start_op) : op_array->opcodes; EX(scope) = EG(scope); EX(symbol_table) = EG(active_symbol_table); diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index 9bcdbc3f30..f807874a1e 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -296,8 +296,6 @@ void zend_shutdown_timeout_thread(void); #define WM_UNREGISTER_ZEND_TIMEOUT (WM_USER+2) #endif -#define active_opline (*EG(opline_ptr)) - /* The following tries to resolve the classname of a zval of type object. * Since it is slow it should be only used in error messages. */ diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index dfd82b25b4..7e66b64d98 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -163,7 +163,6 @@ void init_executor(TSRMLS_D) /* {{{ */ EG(active_symbol_table) = &EG(symbol_table); zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_activator TSRMLS_CC); - EG(opline_ptr) = NULL; zend_hash_init(&EG(included_files), 8, NULL, NULL, 0); @@ -663,7 +662,6 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS { zend_uint i; zend_array *calling_symbol_table; - zend_op **original_opline_ptr; zend_class_entry *calling_scope = NULL; zend_class_entry *called_scope = NULL; zend_execute_data *call, dummy_execute_data; @@ -863,15 +861,12 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS EG(active_symbol_table) = NULL; } - original_opline_ptr = EG(opline_ptr); - if (EXPECTED((func->op_array.fn_flags & ZEND_ACC_GENERATOR) == 0)) { zend_execute(&func->op_array, fci->retval TSRMLS_CC); } else { zend_generator_create_zval(&func->op_array, fci->retval TSRMLS_CC); } - EG(opline_ptr) = original_opline_ptr; if (!fci->symbol_table && EG(active_symbol_table)) { zend_clean_and_cache_symbol_table(EG(active_symbol_table) TSRMLS_CC); } @@ -1114,7 +1109,6 @@ ZEND_API int zend_eval_stringl(char *str, int str_len, zval *retval_ptr, char *s if (new_op_array) { zval local_retval; - zend_op **original_opline_ptr = EG(opline_ptr); int orig_interactive = CG(interactive); EG(no_extensions)=1; @@ -1150,7 +1144,6 @@ ZEND_API int zend_eval_stringl(char *str, int str_len, zval *retval_ptr, char *s } EG(no_extensions)=0; - EG(opline_ptr) = original_opline_ptr; destroy_op_array(new_op_array TSRMLS_CC); efree(new_op_array); retval = SUCCESS; diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index a1c1257c55..4505081ee2 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -230,7 +230,6 @@ ZEND_API void zend_generator_create_zval(zend_op_array *op_array, zval *return_v { zend_generator *generator; zend_execute_data *current_execute_data; - zend_op **opline_ptr; zend_array *current_symbol_table; zend_execute_data *execute_data; zend_vm_stack current_stack = EG(argument_stack); @@ -260,16 +259,14 @@ ZEND_API void zend_generator_create_zval(zend_op_array *op_array, zval *return_v } /* Create new execution context. We have to back up and restore - * EG(current_execute_data), EG(opline_ptr) and EG(active_symbol_table) + * EG(current_execute_data) and EG(active_symbol_table) * here because the function modifies or uses them */ current_execute_data = EG(current_execute_data); - opline_ptr = EG(opline_ptr); current_symbol_table = EG(active_symbol_table); EG(active_symbol_table) = NULL; execute_data = zend_create_generator_execute_data(op_array, return_value TSRMLS_CC); EG(active_symbol_table) = current_symbol_table; EG(current_execute_data) = current_execute_data; - EG(opline_ptr) = opline_ptr; object_init_ex(return_value, zend_ce_generator); @@ -314,7 +311,6 @@ ZEND_API void zend_generator_resume(zend_generator *generator TSRMLS_DC) /* {{{ { /* Backup executor globals */ zend_execute_data *original_execute_data = EG(current_execute_data); - zend_op **original_opline_ptr = EG(opline_ptr); zend_array *original_active_symbol_table = EG(active_symbol_table); zend_object *original_This; zend_class_entry *original_scope = EG(scope); @@ -325,7 +321,6 @@ ZEND_API void zend_generator_resume(zend_generator *generator TSRMLS_DC) /* {{{ /* Set executor globals */ EG(current_execute_data) = generator->execute_data; - EG(opline_ptr) = &generator->execute_data->opline; EG(active_symbol_table) = generator->execute_data->symbol_table; Z_OBJ(EG(This)) = generator->execute_data->object; EG(scope) = generator->execute_data->scope; @@ -355,7 +350,6 @@ ZEND_API void zend_generator_resume(zend_generator *generator TSRMLS_DC) /* {{{ /* Restore executor globals */ EG(current_execute_data) = original_execute_data; - EG(opline_ptr) = original_opline_ptr; EG(active_symbol_table) = original_active_symbol_table; Z_OBJ(EG(This)) = original_This; EG(scope) = original_scope; diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h index a16fdabfcd..c3105ec47b 100644 --- a/Zend/zend_globals.h +++ b/Zend/zend_globals.h @@ -170,8 +170,6 @@ struct _zend_executor_globals { zend_array **symtable_cache_limit; zend_array **symtable_cache_ptr; - zend_op **opline_ptr; - zend_array *active_symbol_table; zend_array symbol_table; /* main symbol table */ diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 3170f2e0dd..0cd5419d9c 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -1789,7 +1789,6 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY) execute_data = EG(current_execute_data); EX(call) = prev_nested_call; - EG(opline_ptr) = &EX(opline); EG(active_symbol_table) = EX(symbol_table); if (Z_OBJ(EG(This))) { @@ -1834,7 +1833,6 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY) execute_data = EG(current_execute_data); EX(call) = prev_nested_call; zend_attach_symbol_table(execute_data); - EG(opline_ptr) = &EX(opline); if (UNEXPECTED(EG(exception) != NULL)) { zend_throw_exception_internal(NULL TSRMLS_CC); HANDLE_EXCEPTION_LEAVE(); @@ -1873,7 +1871,6 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY) if (EG(current_execute_data)) { EG(current_execute_data)->call = prev_nested_call; } - EG(opline_ptr) = NULL; ZEND_VM_RETURN(); } } @@ -2711,7 +2708,6 @@ ZEND_VM_HANDLER(60, ZEND_DO_FCALL, ANY, ANY) } } - EG(opline_ptr) = &EX(opline); if (UNEXPECTED(EG(active_symbol_table) != NULL)) { zend_clean_and_cache_symbol_table(EG(active_symbol_table) TSRMLS_CC); } @@ -4004,7 +4000,6 @@ ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMP|VAR|CV, ANY) execute_ex(EG(current_execute_data) TSRMLS_CC); } - EG(opline_ptr) = &EX(opline); destroy_op_array(new_op_array TSRMLS_CC); efree(new_op_array); if (UNEXPECTED(EG(exception) != NULL)) { diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 921d0d678c..fb41fd41a3 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -412,7 +412,6 @@ static int ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS) execute_data = EG(current_execute_data); EX(call) = prev_nested_call; - EG(opline_ptr) = &EX(opline); EG(active_symbol_table) = EX(symbol_table); if (Z_OBJ(EG(This))) { @@ -457,7 +456,6 @@ static int ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS) execute_data = EG(current_execute_data); EX(call) = prev_nested_call; zend_attach_symbol_table(execute_data); - EG(opline_ptr) = &EX(opline); if (UNEXPECTED(EG(exception) != NULL)) { zend_throw_exception_internal(NULL TSRMLS_CC); HANDLE_EXCEPTION_LEAVE(); @@ -496,7 +494,6 @@ static int ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS) if (EG(current_execute_data)) { EG(current_execute_data)->call = prev_nested_call; } - EG(opline_ptr) = NULL; ZEND_VM_RETURN(); } } @@ -663,7 +660,6 @@ static int ZEND_FASTCALL ZEND_DO_FCALL_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } } - EG(opline_ptr) = &EX(opline); if (UNEXPECTED(EG(active_symbol_table) != NULL)) { zend_clean_and_cache_symbol_table(EG(active_symbol_table) TSRMLS_CC); } @@ -2944,7 +2940,6 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER(ZEND_OPCODE_HA execute_ex(EG(current_execute_data) TSRMLS_CC); } - EG(opline_ptr) = &EX(opline); destroy_op_array(new_op_array TSRMLS_CC); efree(new_op_array); if (UNEXPECTED(EG(exception) != NULL)) { @@ -8136,7 +8131,6 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_TMP_HANDLER(ZEND_OPCODE_HAND execute_ex(EG(current_execute_data) TSRMLS_CC); } - EG(opline_ptr) = &EX(opline); destroy_op_array(new_op_array TSRMLS_CC); efree(new_op_array); if (UNEXPECTED(EG(exception) != NULL)) { @@ -13395,7 +13389,6 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_VAR_HANDLER(ZEND_OPCODE_HAND execute_ex(EG(current_execute_data) TSRMLS_CC); } - EG(opline_ptr) = &EX(opline); destroy_op_array(new_op_array TSRMLS_CC); efree(new_op_array); if (UNEXPECTED(EG(exception) != NULL)) { @@ -30526,7 +30519,6 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER(ZEND_OPCODE_HANDL execute_ex(EG(current_execute_data) TSRMLS_CC); } - EG(opline_ptr) = &EX(opline); destroy_op_array(new_op_array TSRMLS_CC); efree(new_op_array); if (UNEXPECTED(EG(exception) != NULL)) { diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 426156fa5b..112d1576c6 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -733,7 +733,7 @@ static accel_time_t zend_get_file_handle_timestamp(zend_file_handle *file_handle #endif if (sapi_module.get_stat && - !EG(opline_ptr) && + !EG(current_execute_data) && file_handle->filename == SG(request_info).path_translated) { struct stat *tmpbuf = sapi_module.get_stat(TSRMLS_C); @@ -1518,16 +1518,16 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type T /* In case this callback is called from include_once, require_once or it's * a main FastCGI request, the key must be already calculated, and cached * persistent script already found */ - if ((EG(opline_ptr) == NULL && + if ((EG(current_execute_data) == NULL && ZCG(cache_opline) == NULL && file_handle->filename == SG(request_info).path_translated && ZCG(cache_persistent_script)) || - (EG(opline_ptr) && *EG(opline_ptr) && - *EG(opline_ptr) == ZCG(cache_opline) && - (*EG(opline_ptr))->opcode == ZEND_INCLUDE_OR_EVAL && + (EG(current_execute_data) && EG(current_execute_data)->opline && + EG(current_execute_data)->opline == ZCG(cache_opline) && + EG(current_execute_data)->opline->opcode == ZEND_INCLUDE_OR_EVAL && #if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO - ((*EG(opline_ptr))->extended_value == ZEND_INCLUDE_ONCE || - (*EG(opline_ptr))->extended_value == ZEND_REQUIRE_ONCE))) { + (EG(current_execute_data)->opline->extended_value == ZEND_INCLUDE_ONCE || + EG(current_execute_data)->opline->extended_value == ZEND_REQUIRE_ONCE))) { #else ((*EG(opline_ptr))->op2.u.constant.value.lval == ZEND_INCLUDE_ONCE || (*EG(opline_ptr))->op2.u.constant.value.lval == ZEND_REQUIRE_ONCE))) { @@ -1682,11 +1682,11 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type T /* see bug #15471 (old BTS) */ if (persistent_script->full_path) { - if (!EG(opline_ptr) || !*EG(opline_ptr) || - (*EG(opline_ptr))->opcode != ZEND_INCLUDE_OR_EVAL || + if (!EG(current_execute_data) || !EG(current_execute_data)->opline || + EG(current_execute_data)->opline->opcode != ZEND_INCLUDE_OR_EVAL || #if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO - ((*EG(opline_ptr))->extended_value != ZEND_INCLUDE_ONCE && - (*EG(opline_ptr))->extended_value != ZEND_REQUIRE_ONCE)) { + (EG(current_execute_data)->opline->extended_value != ZEND_INCLUDE_ONCE && + EG(current_execute_data)->opline->extended_value != ZEND_REQUIRE_ONCE)) { #else ((*EG(opline_ptr))->op2.u.constant.value.lval != ZEND_INCLUDE_ONCE && (*EG(opline_ptr))->op2.u.constant.value.lval != ZEND_REQUIRE_ONCE)) { @@ -1843,8 +1843,8 @@ static int persistent_stream_open_function(const char *filename, zend_file_handl !CG(interactive) && !ZCSG(restart_in_progress)) { - if (EG(opline_ptr) && *EG(opline_ptr)) { - zend_op *opline = *EG(opline_ptr); + if (EG(current_execute_data) && EG(current_execute_data)->opline) { + zend_op *opline = EG(current_execute_data)->opline; if (opline->opcode == ZEND_INCLUDE_OR_EVAL && (opline->op2.u.constant.value.lval == ZEND_INCLUDE_ONCE || @@ -1940,14 +1940,14 @@ static int persistent_stream_open_function(const char *filename, zend_file_handl !ZCSG(restart_in_progress)) { /* check if callback is called from include_once or it's a main request */ - if ((!EG(opline_ptr) && + if ((!EG(current_execute_data) && filename == SG(request_info).path_translated) || - (EG(opline_ptr) && - *EG(opline_ptr) && - (*EG(opline_ptr))->opcode == ZEND_INCLUDE_OR_EVAL && + (EG(current_execute_data) && + EG(current_execute_data)->opline && + EG(current_execute_data)->opline->opcode == ZEND_INCLUDE_OR_EVAL && #if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO - ((*EG(opline_ptr))->extended_value == ZEND_INCLUDE_ONCE || - (*EG(opline_ptr))->extended_value == ZEND_REQUIRE_ONCE))) { + (EG(current_execute_data)->opline->extended_value == ZEND_INCLUDE_ONCE || + EG(current_execute_data)->opline->extended_value == ZEND_REQUIRE_ONCE))) { #else ((*EG(opline_ptr))->op2.u.constant.value.lval == ZEND_INCLUDE_ONCE || (*EG(opline_ptr))->op2.u.constant.value.lval == ZEND_REQUIRE_ONCE))) { @@ -1960,11 +1960,11 @@ static int persistent_stream_open_function(const char *filename, zend_file_handl handle->free_filename = 0; /* check if cached script was already found by resolve_path() */ - if ((EG(opline_ptr) == NULL && + if ((EG(current_execute_data) == NULL && ZCG(cache_opline) == NULL && ZCG(cache_persistent_script) != NULL) || - (EG(opline_ptr) && - (ZCG(cache_opline) == *EG(opline_ptr)))) { + (EG(current_execute_data) && + (ZCG(cache_opline) == EG(current_execute_data)->opline))) { persistent_script = ZCG(cache_persistent_script); handle->opened_path = estrndup(persistent_script->full_path->val, persistent_script->full_path->len); handle->type = ZEND_HANDLE_FILENAME; @@ -1983,8 +1983,8 @@ static int persistent_stream_open_function(const char *filename, zend_file_handl handle->type = ZEND_HANDLE_FILENAME; memcpy(ZCG(key), persistent_script->full_path, persistent_script->full_path_len + 1); ZCG(key_len) = persistent_script->full_path_len; - ZCG(cache_opline) = EG(opline_ptr) ? *EG(opline_ptr) : NULL; - ZCG(cache_persistent_script) = EG(opline_ptr) ? persistent_script : NULL; + ZCG(cache_opline) = EG(current_execute_data) ? EG(current_execute_data)->opline : NULL; + ZCG(cache_persistent_script) = EG(current_execute_data) ? persistent_script : NULL; return SUCCESS; } #endif @@ -2005,14 +2005,14 @@ static char* persistent_zend_resolve_path(const char *filename, int filename_len !ZCSG(restart_in_progress)) { /* check if callback is called from include_once or it's a main request */ - if ((!EG(opline_ptr) && + if ((!EG(current_execute_data) && filename == SG(request_info).path_translated) || - (EG(opline_ptr) && - *EG(opline_ptr) && - (*EG(opline_ptr))->opcode == ZEND_INCLUDE_OR_EVAL && + (EG(current_execute_data) && + EG(current_execute_data)->opline && + EG(current_execute_data)->opline->opcode == ZEND_INCLUDE_OR_EVAL && #if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO - ((*EG(opline_ptr))->extended_value == ZEND_INCLUDE_ONCE || - (*EG(opline_ptr))->extended_value == ZEND_REQUIRE_ONCE))) { + (EG(current_execute_data)->opline->extended_value == ZEND_INCLUDE_ONCE || + EG(current_execute_data)->opline->extended_value == ZEND_REQUIRE_ONCE))) { #else ((*EG(opline_ptr))->op2.u.constant.value.lval == ZEND_INCLUDE_ONCE || (*EG(opline_ptr))->op2.u.constant.value.lval == ZEND_REQUIRE_ONCE))) { @@ -2034,7 +2034,7 @@ static char* persistent_zend_resolve_path(const char *filename, int filename_len if (persistent_script && !persistent_script->corrupted) { memcpy(ZCG(key), persistent_script->full_path->val, persistent_script->full_path->len + 1); ZCG(key_len) = persistent_script->full_path->len; - ZCG(cache_opline) = EG(opline_ptr) ? *EG(opline_ptr) : NULL; + ZCG(cache_opline) = EG(current_execute_data) ? EG(current_execute_data)->opline : NULL; ZCG(cache_persistent_script) = persistent_script; return estrndup(persistent_script->full_path->val, persistent_script->full_path->len); } @@ -2051,7 +2051,7 @@ static char* persistent_zend_resolve_path(const char *filename, int filename_len !persistent_script->corrupted) { /* we have persistent script */ - ZCG(cache_opline) = EG(opline_ptr) ? *EG(opline_ptr) : NULL; + ZCG(cache_opline) = EG(current_execute_data) ? EG(current_execute_data)->opline : NULL; ZCG(cache_persistent_script) = persistent_script; return estrndup(persistent_script->full_path->val, persistent_script->full_path->len); } @@ -2073,7 +2073,7 @@ static char* persistent_zend_resolve_path(const char *filename, int filename_len zend_shared_alloc_unlock(TSRMLS_C); SHM_PROTECT(); } - ZCG(cache_opline) = (EG(opline_ptr) && key) ? *EG(opline_ptr): NULL; + ZCG(cache_opline) = (EG(current_execute_data) && key) ? EG(current_execute_data)->opline : NULL; ZCG(cache_persistent_script) = key ? persistent_script : NULL; return resolved_path; } diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index 2daeff6603..8bab4ae3cf 100644 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -318,7 +318,6 @@ PHP_FUNCTION(spl_autoload) int found = 0, pos_len, pos1_len; char *pos, *pos1; zend_string *class_name, *lc_name, *file_exts = SPL_G(autoload_extensions); - zend_op **original_opline_ptr = EG(opline_ptr); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|S", &class_name, &file_exts) == FAILURE) { RETURN_FALSE; @@ -335,7 +334,6 @@ PHP_FUNCTION(spl_autoload) lc_name = STR_ALLOC(class_name->len, 0); zend_str_tolower_copy(lc_name->val, class_name->val, class_name->len); while (pos && *pos && !EG(exception)) { - EG(opline_ptr) = original_opline_ptr; pos1 = strchr(pos, ','); if (pos1) { pos1_len = pos1 - pos; @@ -351,14 +349,17 @@ PHP_FUNCTION(spl_autoload) } STR_FREE(lc_name); - EG(opline_ptr) = original_opline_ptr; - if (!found && !SPL_G(autoload_running)) { /* For internal errors, we generate E_ERROR, for direct calls an exception is thrown. * The "scope" is determined by an opcode, if it is ZEND_FETCH_CLASS we know function was called indirectly by * the Zend engine. */ - if (active_opline->opcode != ZEND_FETCH_CLASS) { + zend_execute_data *ex = EG(current_execute_data); + + while (ex && (!ex->func || !ZEND_USER_CODE(ex->func->type))) { + ex = ex->prev_execute_data; + } + if (ex && ex->opline && ex->opline->opcode != ZEND_FETCH_CLASS) { zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Class %s could not be loaded", class_name->val); } else { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Class %s could not be loaded", class_name->val); diff --git a/main/main.c b/main/main.c index f0c6418e9a..ca25e17113 100644 --- a/main/main.c +++ b/main/main.c @@ -1776,10 +1776,9 @@ void php_request_shutdown(void *dummy) report_memleaks = PG(report_memleaks); - /* EG(opline_ptr) points into nirvana and therefore cannot be safely accessed + /* EG(current_execute_data) points into nirvana and therefore cannot be safely accessed * inside zend_executor callback functions. */ - EG(opline_ptr) = NULL; EG(current_execute_data) = NULL; php_deactivate_ticks(TSRMLS_C); |