From 0a77dcd4b9046adb7c8f719ded19c5eff0c8976a Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 3 Jul 2014 01:02:25 +0400 Subject: [PATCH] Removed EG(in_execution). If EG(currentent_execute_data) is not NULL we are executing something. --- Zend/zend.c | 10 +++++++--- Zend/zend_API.c | 4 ++-- Zend/zend_alloc.c | 2 +- Zend/zend_constants.c | 4 ++-- Zend/zend_execute_API.c | 3 +-- Zend/zend_globals.h | 1 - Zend/zend_objects.c | 8 ++++---- Zend/zend_vm_execute.h | 5 ----- Zend/zend_vm_execute.skl | 4 ---- Zend/zend_vm_gen.php | 5 ++--- ext/opcache/Optimizer/pass1_5.c | 3 --- ext/opcache/ZendAccelerator.c | 2 +- ext/opcache/zend_persist.c | 3 --- ext/soap/soap.c | 7 +------ ext/standard/assert.c | 2 +- main/SAPI.c | 10 +++++----- 16 files changed, 27 insertions(+), 46 deletions(-) diff --git a/Zend/zend.c b/Zend/zend.c index 68ed5c9fd1..14045914b6 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -559,7 +559,6 @@ static void executor_globals_ctor(zend_executor_globals *executor_globals TSRMLS EG(lambda_count) = 0; ZVAL_UNDEF(&EG(user_error_handler)); ZVAL_UNDEF(&EG(user_exception_handler)); - EG(in_execution) = 0; EG(in_autoload) = NULL; EG(current_execute_data) = NULL; EG(current_module) = NULL; @@ -880,7 +879,7 @@ ZEND_API void _zend_bailout(char *filename, uint lineno) /* {{{ */ } CG(unclean_shutdown) = 1; CG(active_class_entry) = NULL; - CG(in_compilation) = EG(in_execution) = 0; + CG(in_compilation) = 0; EG(current_execute_data) = NULL; LONGJMP(*EG(bailout), FAILURE); } @@ -1097,7 +1096,12 @@ ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */ error_lineno = zend_get_compiled_lineno(TSRMLS_C); } else if (zend_is_executing(TSRMLS_C)) { error_filename = zend_get_executed_filename(TSRMLS_C); - error_lineno = zend_get_executed_lineno(TSRMLS_C); + if (error_filename[0] == '[') { /* [no active file] */ + error_filename = NULL; + error_lineno = 0; + } else { + error_lineno = zend_get_executed_lineno(TSRMLS_C); + } } else { error_filename = NULL; error_lineno = 0; diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 36b615ba1b..6474fd6ad7 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -1072,7 +1072,7 @@ static int zval_update_class_constant(zval *pp, int is_static, int offset TSRMLS { ZVAL_DEREF(pp); if (Z_CONSTANT_P(pp)) { - zend_class_entry **scope = EG(in_execution)?&EG(scope):&CG(active_class_entry); + zend_class_entry **scope = EG(current_execute_data) ? &EG(scope) : &CG(active_class_entry); if ((*scope)->parent) { zend_class_entry *ce = *scope; @@ -1136,7 +1136,7 @@ ZEND_API void zend_update_class_constants(zend_class_entry *class_type TSRMLS_DC } if ((class_type->ce_flags & ZEND_ACC_CONSTANTS_UPDATED) == 0) { - zend_class_entry **scope = EG(in_execution)?&EG(scope):&CG(active_class_entry); + zend_class_entry **scope = EG(current_execute_data) ? &EG(scope) : &CG(active_class_entry); zend_class_entry *old_scope = *scope; zval *val; diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 1f6b62eb23..35a201b21c 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -1761,7 +1761,7 @@ static void zend_mm_safe_error(zend_mm_heap *heap, zend_string *str = zend_get_compiled_filename(TSRMLS_C); error_filename = str ? str->val : NULL; error_lineno = zend_get_compiled_lineno(TSRMLS_C); - } else if (EG(in_execution) && EG(current_execute_data)) { + } else if (EG(current_execute_data)) { zend_execute_data *ex = EG(current_execute_data); while (ex && (!ex->func || !ZEND_USER_CODE(ex->func->type))) { diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c index 4930d1fdd4..5366845519 100644 --- a/Zend/zend_constants.c +++ b/Zend/zend_constants.c @@ -231,7 +231,7 @@ static zend_constant *zend_get_special_constant(const char *name, uint name_len zend_constant *c; static char haltoff[] = "__COMPILER_HALT_OFFSET__"; - if (!EG(in_execution)) { + if (!EG(current_execute_data)) { return NULL; } else if (name_len == sizeof("__CLASS__")-1 && !memcmp(name, "__CLASS__", sizeof("__CLASS__")-1)) { @@ -354,7 +354,7 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope, lcname = do_alloca(class_name_len + 1, use_heap); zend_str_tolower_copy(lcname, name, class_name_len); if (!scope) { - if (EG(in_execution)) { + if (EG(current_execute_data)) { scope = EG(scope); } else { scope = CG(active_class_entry); diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 7e66b64d98..dc23ff85e0 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -150,7 +150,6 @@ void init_executor(TSRMLS_D) /* {{{ */ EG(function_table) = CG(function_table); EG(class_table) = CG(class_table); - EG(in_execution) = 0; EG(in_autoload) = NULL; EG(autoload_func) = NULL; EG(error_handling) = EH_NORMAL; @@ -483,7 +482,7 @@ ZEND_API uint zend_get_executed_lineno(TSRMLS_D) /* {{{ */ ZEND_API zend_bool zend_is_executing(TSRMLS_D) /* {{{ */ { - return EG(in_execution); + return EG(current_execute_data) != 0; } /* }}} */ diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h index c3105ec47b..6792811003 100644 --- a/Zend/zend_globals.h +++ b/Zend/zend_globals.h @@ -194,7 +194,6 @@ struct _zend_executor_globals { int ticks_count; - zend_bool in_execution; HashTable *in_autoload; zend_function *autoload_func; zend_bool full_tables_cleanup; diff --git a/Zend/zend_objects.c b/Zend/zend_objects.c index 1ef0e1d7e7..af0070c5fb 100644 --- a/Zend/zend_objects.c +++ b/Zend/zend_objects.c @@ -77,11 +77,11 @@ ZEND_API void zend_objects_destroy_object(zend_object *object TSRMLS_DC) if (object->ce != EG(scope)) { zend_class_entry *ce = object->ce; - zend_error(EG(in_execution) ? E_ERROR : E_WARNING, + zend_error(EG(current_execute_data) ? E_ERROR : E_WARNING, "Call to private %s::__destruct() from context '%s'%s", ce->name->val, EG(scope) ? EG(scope)->name->val : "", - EG(in_execution) ? "" : " during shutdown ignored"); + EG(current_execute_data) ? "" : " during shutdown ignored"); return; } } else { @@ -90,11 +90,11 @@ ZEND_API void zend_objects_destroy_object(zend_object *object TSRMLS_DC) if (!zend_check_protected(zend_get_function_root_class(destructor), EG(scope))) { zend_class_entry *ce = object->ce; - zend_error(EG(in_execution) ? E_ERROR : E_WARNING, + zend_error(EG(current_execute_data) ? E_ERROR : E_WARNING, "Call to protected %s::__destruct() from context '%s'%s", ce->name->val, EG(scope) ? EG(scope)->name->val : "", - EG(in_execution) ? "" : " during shutdown ignored"); + EG(current_execute_data) ? "" : " during shutdown ignored"); return; } } diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index fb41fd41a3..57fb40bc13 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -337,13 +337,9 @@ static opcode_handler_t zend_vm_get_opcode_handler(zend_uchar opcode, zend_op* o ZEND_API void execute_ex(zend_execute_data *execute_data TSRMLS_DC) { DCL_OPLINE - zend_bool original_in_execution; - original_in_execution = EG(in_execution); - EG(in_execution) = 1; - LOAD_REGS(); LOAD_OPLINE(); @@ -358,7 +354,6 @@ ZEND_API void execute_ex(zend_execute_data *execute_data TSRMLS_DC) if ((ret = OPLINE->handler(execute_data TSRMLS_CC)) > 0) { switch (ret) { case 1: - EG(in_execution) = original_in_execution; return; case 2: case 3: diff --git a/Zend/zend_vm_execute.skl b/Zend/zend_vm_execute.skl index 41a834de95..656c0fcd9e 100644 --- a/Zend/zend_vm_execute.skl +++ b/Zend/zend_vm_execute.skl @@ -3,15 +3,11 @@ ZEND_API void {%EXECUTOR_NAME%}_ex(zend_execute_data *execute_data TSRMLS_DC) { DCL_OPLINE - zend_bool original_in_execution; {%HELPER_VARS%} {%INTERNAL_LABELS%} - original_in_execution = EG(in_execution); - EG(in_execution) = 1; - LOAD_REGS(); LOAD_OPLINE(); diff --git a/Zend/zend_vm_gen.php b/Zend/zend_vm_gen.php index bdc6cc79b8..b0a642084d 100644 --- a/Zend/zend_vm_gen.php +++ b/Zend/zend_vm_gen.php @@ -941,7 +941,7 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name, out($f,"#define HANDLE_EXCEPTION_LEAVE() LOAD_OPLINE(); ZEND_VM_LEAVE()\n"); out($f,"#define LOAD_REGS()\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() return\n"); out($f,"#define ZEND_VM_ENTER() execute_data = EG(current_execute_data); LOAD_OPLINE(); 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"); @@ -973,7 +973,7 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name, } out($f,"#define LOAD_REGS()\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() return\n"); out($f,"#define ZEND_VM_ENTER() execute_data = EG(current_execute_data); LOAD_OPLINE(); 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"); @@ -1043,7 +1043,6 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name, // Executor is defined as a set of functions out($f, $m[1]."switch (ret) {\n" . $m[1]."\tcase 1:\n" . - $m[1]."\t\tEG(in_execution) = original_in_execution;\n". $m[1]."\t\treturn;\n". $m[1]."\tcase 2:\n" . $m[1]."\tcase 3:\n" . diff --git a/ext/opcache/Optimizer/pass1_5.c b/ext/opcache/Optimizer/pass1_5.c index 62cadc5710..91b78ec6f0 100644 --- a/ext/opcache/Optimizer/pass1_5.c +++ b/ext/opcache/Optimizer/pass1_5.c @@ -219,12 +219,10 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) { Z_STRLEN(ZEND_OP2_LITERAL(opline)) == sizeof("__COMPILER_HALT_OFFSET__") - 1 && memcmp(Z_STRVAL(ZEND_OP2_LITERAL(opline)), "__COMPILER_HALT_OFFSET__", sizeof("__COMPILER_HALT_OFFSET__") - 1) == 0) { /* substitute __COMPILER_HALT_OFFSET__ constant */ - zend_bool orig_in_execution = EG(in_execution); zend_execute_data *orig_execute_data = EG(current_execute_data); zend_execute_data fake_execute_data; zval *offset; - EG(in_execution) = 1; memset(&fake_execute_data, 0, sizeof(zend_execute_data)); fake_execute_data.func = (zend_function*)op_array; EG(current_execute_data) = &fake_execute_data; @@ -236,7 +234,6 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) { replace_tmp_by_const(op_array, opline, tv, offset TSRMLS_CC); } EG(current_execute_data) = orig_execute_data; - EG(in_execution) = orig_in_execution; break; } diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 112d1576c6..e84de1a34c 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -995,7 +995,7 @@ char *accel_make_persistent_key_ex(zend_file_handle *file_handle, int path_lengt since fopen_wrappers from version 4.0.7 use current script's path in include path too. */ - if (EG(in_execution) && + if (EG(current_execute_data) && (parent_script = zend_get_executed_filename(TSRMLS_C)) != NULL && parent_script[0] != '[') { diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c index 304c8c2b91..e47cfda894 100644 --- a/ext/opcache/zend_persist.c +++ b/ext/opcache/zend_persist.c @@ -297,7 +297,6 @@ static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_sc op_array->refcount = NULL; if (main_persistent_script) { - zend_bool orig_in_execution = EG(in_execution); zend_execute_data *orig_execute_data = EG(current_execute_data); zend_execute_data fake_execute_data; zval *offset; @@ -305,7 +304,6 @@ static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_sc #if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO main_persistent_script->early_binding = -1; #endif - EG(in_execution) = 1; memset(&fake_execute_data, 0, sizeof(fake_execute_data)); fake_execute_data.func = (zend_function*)op_array; EG(current_execute_data) = &fake_execute_data; @@ -313,7 +311,6 @@ static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_sc main_persistent_script->compiler_halt_offset = Z_LVAL_P(offset); } EG(current_execute_data) = orig_execute_data; - EG(in_execution) = orig_in_execution; } if (op_array->static_variables) { diff --git a/ext/soap/soap.c b/ext/soap/soap.c index fe97793afe..d98d1fc494 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -92,7 +92,6 @@ static void soap_error_handler(int error_num, const char *error_filename, const zend_object* _old_error_object = Z_OBJ(SOAP_GLOBAL(error_object));\ int _old_soap_version = SOAP_GLOBAL(soap_version);\ zend_bool _old_in_compilation = CG(in_compilation); \ - zend_bool _old_in_execution = EG(in_execution); \ zend_execute_data *_old_current_execute_data = EG(current_execute_data); \ zval *_old_stack_top = EG(argument_stack)->top; \ int _bailout = 0;\ @@ -104,7 +103,6 @@ static void soap_error_handler(int error_num, const char *error_filename, const #define SOAP_CLIENT_END_CODE() \ } zend_catch {\ CG(in_compilation) = _old_in_compilation; \ - EG(in_execution) = _old_in_execution; \ EG(current_execute_data) = _old_current_execute_data; \ if (EG(exception) == NULL || \ !instanceof_function(zend_get_class_entry(EG(exception) TSRMLS_CC), soap_fault_class_entry TSRMLS_CC)) {\ @@ -2131,14 +2129,13 @@ static void soap_server_fault(char* code, char* string, char *actor, zval* detai static void soap_error_handler(int error_num, const char *error_filename, const uint error_lineno, const char *format, va_list args) { - zend_bool _old_in_compilation, _old_in_execution; + zend_bool _old_in_compilation; zend_execute_data *_old_current_execute_data; int _old_http_response_code; char *_old_http_status_line; TSRMLS_FETCH(); _old_in_compilation = CG(in_compilation); - _old_in_execution = EG(in_execution); _old_current_execute_data = EG(current_execute_data); _old_http_response_code = SG(sapi_headers).http_response_code; _old_http_status_line = SG(sapi_headers).http_status_line; @@ -2204,7 +2201,6 @@ static void soap_error_handler(int error_num, const char *error_filename, const call_old_error_handler(error_num, error_filename, error_lineno, format, args); } zend_catch { CG(in_compilation) = _old_in_compilation; - EG(in_execution) = _old_in_execution; EG(current_execute_data) = _old_current_execute_data; if (SG(sapi_headers).http_status_line) { efree(SG(sapi_headers).http_status_line); @@ -2287,7 +2283,6 @@ static void soap_error_handler(int error_num, const char *error_filename, const call_old_error_handler(error_num, error_filename, error_lineno, format, args); } zend_catch { CG(in_compilation) = _old_in_compilation; - EG(in_execution) = _old_in_execution; EG(current_execute_data) = _old_current_execute_data; if (SG(sapi_headers).http_status_line) { efree(SG(sapi_headers).http_status_line); diff --git a/ext/standard/assert.c b/ext/standard/assert.c index 3ec7361197..e64e2e1ecb 100644 --- a/ext/standard/assert.c +++ b/ext/standard/assert.c @@ -53,7 +53,7 @@ enum { static PHP_INI_MH(OnChangeCallback) /* {{{ */ { - if (EG(in_execution)) { + if (EG(current_execute_data)) { if (Z_TYPE(ASSERTG(callback)) != IS_UNDEF) { zval_ptr_dtor(&ASSERTG(callback)); ZVAL_UNDEF(&ASSERTG(callback)); diff --git a/main/SAPI.c b/main/SAPI.c index e587f7aaf7..229396dd79 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -947,7 +947,7 @@ SAPI_API int sapi_register_post_entries(sapi_post_entry *post_entries TSRMLS_DC) SAPI_API int sapi_register_post_entry(sapi_post_entry *post_entry TSRMLS_DC) { - if (SG(sapi_started) && EG(in_execution)) { + if (SG(sapi_started) && EG(current_execute_data)) { return FAILURE; } return zend_hash_str_add_mem(&SG(known_post_content_types), @@ -957,7 +957,7 @@ SAPI_API int sapi_register_post_entry(sapi_post_entry *post_entry TSRMLS_DC) SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry TSRMLS_DC) { - if (SG(sapi_started) && EG(in_execution)) { + if (SG(sapi_started) && EG(current_execute_data)) { return; } zend_hash_str_del(&SG(known_post_content_types), post_entry->content_type, @@ -967,7 +967,7 @@ SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry TSRMLS_DC) SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(TSRMLS_D) TSRMLS_DC) { - if (SG(sapi_started) && EG(in_execution)) { + if (SG(sapi_started) && EG(current_execute_data)) { return FAILURE; } sapi_module.default_post_reader = default_post_reader; @@ -977,7 +977,7 @@ SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(TSRML SAPI_API int sapi_register_treat_data(void (*treat_data)(int arg, char *str, zval *destArray TSRMLS_DC) TSRMLS_DC) { - if (SG(sapi_started) && EG(in_execution)) { + if (SG(sapi_started) && EG(current_execute_data)) { return FAILURE; } sapi_module.treat_data = treat_data; @@ -986,7 +986,7 @@ SAPI_API int sapi_register_treat_data(void (*treat_data)(int arg, char *str, zva SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC), unsigned int (*input_filter_init)(TSRMLS_D) TSRMLS_DC) { - if (SG(sapi_started) && EG(in_execution)) { + if (SG(sapi_started) && EG(current_execute_data)) { return FAILURE; } sapi_module.input_filter = input_filter; -- 2.40.0