From 8202b4ed09fe4160ac9265780816cf380a34b480 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 17 Aug 2020 13:50:03 +0300 Subject: [PATCH 001/170] Properly patch jmp tables --- ext/opcache/jit/zend_jit.c | 2 +- ext/opcache/jit/zend_jit_internal.h | 1 + ext/opcache/jit/zend_jit_trace.c | 6 +++- ext/opcache/jit/zend_jit_x86.dasc | 43 ++++++++++++++++++++++------- 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index e2e85f3431904..90bed235d26dc 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -2925,7 +2925,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op case ZEND_SWITCH_LONG: case ZEND_SWITCH_STRING: case ZEND_MATCH: - if (!zend_jit_switch(&dasm_state, opline, op_array, ssa, NULL)) { + if (!zend_jit_switch(&dasm_state, opline, op_array, ssa, NULL, NULL)) { goto jit_failure; } goto done; diff --git a/ext/opcache/jit/zend_jit_internal.h b/ext/opcache/jit/zend_jit_internal.h index 7dd8786fde2e1..b40553b03dbde 100644 --- a/ext/opcache/jit/zend_jit_internal.h +++ b/ext/opcache/jit/zend_jit_internal.h @@ -350,6 +350,7 @@ typedef struct _zend_jit_trace_info { uint32_t stack_map_size; uint32_t flags; /* See ZEND_JIT_TRACE_... defines above */ uint32_t polymorphism; /* Counter of polymorphic calls */ + uint32_t jmp_table_size;/* number of jmp_table slots */ const zend_op *opline; /* first opline */ const void *code_start; /* address of native code */ zend_jit_trace_exit_info *exit_info; /* info about side exits */ diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index 96fa37abb79a5..24b4e7cd81905 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -4163,7 +4163,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par case ZEND_SWITCH_LONG: case ZEND_SWITCH_STRING: case ZEND_MATCH: - if (!zend_jit_switch(&dasm_state, opline, op_array, op_array_ssa, p+1)) { + if (!zend_jit_switch(&dasm_state, opline, op_array, op_array_ssa, p+1, &zend_jit_traces[ZEND_JIT_TRACE_NUM])) { goto jit_failure; } goto done; @@ -4827,6 +4827,7 @@ static zend_jit_trace_stop zend_jit_compile_root_trace(zend_jit_trace_rec *trace t->stack_map_size = 0; t->flags = 0; t->polymorphism = 0; + t->jmp_table_size = 0; t->opline = trace_buffer[1].opline; t->exit_info = exit_info; t->stack_map = NULL; @@ -5353,6 +5354,7 @@ static void zend_jit_blacklist_trace_exit(uint32_t trace_num, uint32_t exit_num) zend_jit_link_side_trace( zend_jit_traces[trace_num].code_start, zend_jit_traces[trace_num].code_size, + zend_jit_traces[trace_num].jmp_table_size, exit_num, handler); } @@ -5421,6 +5423,7 @@ static zend_jit_trace_stop zend_jit_compile_side_trace(zend_jit_trace_rec *trace t->stack_map_size = 0; t->flags = 0; t->polymorphism = polymorphism; + t->jmp_table_size = 0; t->opline = NULL; t->exit_info = exit_info; t->stack_map = NULL; @@ -5464,6 +5467,7 @@ static zend_jit_trace_stop zend_jit_compile_side_trace(zend_jit_trace_rec *trace zend_jit_link_side_trace( zend_jit_traces[parent_num].code_start, zend_jit_traces[parent_num].code_size, + zend_jit_traces[parent_num].jmp_table_size, exit_num, handler); diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index 32bd3b46774e2..520a3facfa633 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -153,7 +153,7 @@ static size_t tsrm_tls_offset; |.globals zend_lb static void* dasm_labels[zend_lb_MAX]; -|.section code, cold_code +|.section code, cold_code, jmp_table #define IS_32BIT(addr) (((uintptr_t)(addr)) <= 0xffffffff) @@ -3093,12 +3093,26 @@ mrm: typedef ZEND_SET_ALIGNED(1, uint16_t unaligned_uint16_t); typedef ZEND_SET_ALIGNED(1, int32_t unaligned_int32_t); -static int zend_jit_patch(const void *code, size_t size, const void *from_addr, const void *to_addr) +static int zend_jit_patch(const void *code, size_t size, uint32_t jmp_table_size, const void *from_addr, const void *to_addr) { int ret = 0; - uint8_t *p = (uint8_t*)code; - uint8_t *end = p + size - 5; + uint8_t *p, *end; + if (jmp_table_size) { + const void **jmp_slot = (const void **)((char*)code + size); + + size -= jmp_table_size * sizeof(void*); + do { + jmp_slot--; + if (*jmp_slot == from_addr) { + *jmp_slot = to_addr; + ret++; + } + } while (--jmp_table_size); + } + + p = (uint8_t*)code; + end = p + size - 5; while (p < end) { if ((*(unaligned_uint16_t*)p & 0xf0ff) == 0x800f && p + *(unaligned_int32_t*)(p+2) == (uint8_t*)from_addr - 6) { *(unaligned_int32_t*)(p+2) = ((uint8_t*)to_addr - (p + 6)); @@ -3115,9 +3129,9 @@ static int zend_jit_patch(const void *code, size_t size, const void *from_addr, return ret; } -static int zend_jit_link_side_trace(const void *code, size_t size, uint32_t exit_num, const void *addr) +static int zend_jit_link_side_trace(const void *code, size_t size, uint32_t jmp_table_size, uint32_t exit_num, const void *addr) { - return zend_jit_patch(code, size, zend_jit_trace_get_exit_addr(exit_num), addr); + return zend_jit_patch(code, size, jmp_table_size, zend_jit_trace_get_exit_addr(exit_num), addr); } static int zend_jit_trace_link_to_root(dasm_State **Dst, zend_jit_trace_info *t) @@ -11782,7 +11796,7 @@ static int zend_jit_fetch_this(dasm_State **Dst, const zend_op *opline, const ze return 1; } -static int zend_jit_switch(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, zend_ssa *ssa, zend_jit_trace_rec *trace) +static int zend_jit_switch(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, zend_ssa *ssa, zend_jit_trace_rec *trace, zend_jit_trace_info *trace_info) { HashTable *jumptable = Z_ARRVAL_P(RT_CONSTANT(opline, opline->op2)); const zend_op *next_opline = NULL; @@ -11920,9 +11934,12 @@ static int zend_jit_switch(dasm_State **Dst, const zend_op *opline, const zend_o |.else | jmp aword [FCARG2a * 4 + >4] |.endif - |.cold_code + |.jmp_table |.align aword |4: + if (trace_info) { + trace_info->jmp_table_size += count; + } p = jumptable->arData; do { if (Z_TYPE(p->val) == IS_UNDEF) { @@ -11981,9 +11998,12 @@ static int zend_jit_switch(dasm_State **Dst, const zend_op *opline, const zend_o |.else | jmp aword [r0 + >4] |.endif - |.cold_code + |.jmp_table |.align aword |4: + if (trace_info) { + trace_info->jmp_table_size += zend_hash_num_elements(jumptable); + } ZEND_HASH_FOREACH_VAL(jumptable, val) { target = ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL_P(val)); if (!next_opline) { @@ -12063,9 +12083,12 @@ static int zend_jit_switch(dasm_State **Dst, const zend_op *opline, const zend_o |.else | jmp aword [r0 + >4] |.endif - |.cold_code + |.jmp_table |.align aword |4: + if (trace_info) { + trace_info->jmp_table_size += zend_hash_num_elements(jumptable); + } ZEND_HASH_FOREACH_VAL(jumptable, val) { target = ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL_P(val)); if (!next_opline) { From a02237d2a9a7409b3763ac49ad41a244a2843c5f Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 17 Aug 2020 15:24:33 +0300 Subject: [PATCH 002/170] Removed outdated/duplicated code --- ext/opcache/jit/zend_jit_x86.dasc | 9 --------- 1 file changed, 9 deletions(-) diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index 520a3facfa633..8933c0890e221 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -10488,15 +10488,6 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, cons res_info |= AVOID_REFCOUNTING; ssa->var_info[ssa_op->result_def].type |= AVOID_REFCOUNTING; } - old_info = STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var)); - SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->result.var), IS_UNKNOWN); - SET_STACK_REG(stack, EX_VAR_TO_NUM(opline->result.var), ZREG_ZVAL_COPY_R0); - exit_point = zend_jit_trace_get_exit_point(opline, opline+1, NULL, flags); - SET_STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var), old_info); - res_exit_addr = zend_jit_trace_get_exit_addr(exit_point); - if (!res_exit_addr) { - return 0; - } if (!(op2_info & ((MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_REF) - (MAY_BE_STRING|MAY_BE_LONG)))) { old_info = STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var)); From 72383ccabba6d2d9c0255f19dbc4340e12c63fa1 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Wed, 8 Jul 2020 15:51:28 +0200 Subject: [PATCH 003/170] Promote warnings in ext/zip --- ext/zip/php_zip.c | 183 ++++++++++++++----------- ext/zip/tests/oo_getcomment.phpt | 18 ++- ext/zip/tests/oo_open.phpt | 11 +- ext/zip/tests/oo_setcomment_error.phpt | 31 +++-- ext/zip/tests/zip_open_error.phpt | 9 +- 5 files changed, 143 insertions(+), 109 deletions(-) diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index de3a695d96401..43c2da9af6660 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -52,11 +52,12 @@ static int le_zip_entry; } /* }}} */ -/* {{{ PHP_ZIP_STAT_PATH(za, path, path_len, flags, sb) */ +/* {{{ PHP_ZIP_STAT_PATH(za, path, path_len, flags, sb) + This is always used for the first argument*/ #define PHP_ZIP_STAT_PATH(za, path, path_len, flags, sb) \ - if (path_len < 1) { \ - php_error_docref(NULL, E_NOTICE, "Empty string as entry name"); \ - RETURN_FALSE; \ + if (path_len == 0) { \ + zend_argument_value_error(1, "cannot be empty"); \ + RETURN_THROWS(); \ } \ if (zip_stat(za, path, flags, &sb) != 0) { \ RETURN_FALSE; \ @@ -348,24 +349,41 @@ static int php_zip_parse_options(HashTable *options, zip_options *opts) #endif if ((option = zend_hash_str_find(options, "remove_all_path", sizeof("remove_all_path") - 1)) != NULL) { + if (Z_TYPE_P(option) != IS_FALSE && Z_TYPE_P(option) != IS_TRUE) { + php_error_docref(NULL, E_WARNING, "Option \"remove_all_path\" must be of type bool, %s given", + zend_zval_type_name(option)); + } opts->remove_all_path = zval_get_long(option); } if ((option = zend_hash_str_find(options, "comp_method", sizeof("comp_method") - 1)) != NULL) { + if (Z_TYPE_P(option) != IS_LONG) { + php_error_docref(NULL, E_WARNING, "Option \"comp_method\" must be of type int, %s given", + zend_zval_type_name(option)); + } opts->comp_method = zval_get_long(option); if ((option = zend_hash_str_find(options, "comp_flags", sizeof("comp_flags") - 1)) != NULL) { + if (Z_TYPE_P(option) != IS_LONG) { + php_error_docref(NULL, E_WARNING, "Option \"comp_flags\" must be of type int, %s given", + zend_zval_type_name(option)); + } opts->comp_flags = zval_get_long(option); } } #ifdef HAVE_ENCRYPTION if ((option = zend_hash_str_find(options, "enc_method", sizeof("enc_method") - 1)) != NULL) { + if (Z_TYPE_P(option) != IS_LONG) { + php_error_docref(NULL, E_WARNING, "Option \"enc_method\" must be of type int, %s given", + zend_zval_type_name(option)); + } opts->enc_method = zval_get_long(option); if ((option = zend_hash_str_find(options, "enc_password", sizeof("enc_password") - 1)) != NULL) { if (Z_TYPE_P(option) != IS_STRING) { - php_error_docref(NULL, E_WARNING, "enc_password option expected to be a string"); + zend_type_error("Option \"enc_password\" must be of type string, %s given", + zend_zval_type_name(option)); return -1; } opts->enc_password = Z_STRVAL_P(option); @@ -375,18 +393,18 @@ static int php_zip_parse_options(HashTable *options, zip_options *opts) if ((option = zend_hash_str_find(options, "remove_path", sizeof("remove_path") - 1)) != NULL) { if (Z_TYPE_P(option) != IS_STRING) { - php_error_docref(NULL, E_WARNING, "remove_path option expected to be a string"); + zend_type_error("Option \"remove_path\" must be of type string, %s given", + zend_zval_type_name(option)); return -1; } - if (Z_STRLEN_P(option) < 1) { - php_error_docref(NULL, E_NOTICE, "Empty string given as remove_path option"); + if (Z_STRLEN_P(option) == 0) { + zend_value_error("Option \"remove_path\" cannot be empty"); return -1; } if (Z_STRLEN_P(option) >= MAXPATHLEN) { - php_error_docref(NULL, E_WARNING, "remove_path string is too long (max: %d, %zd given)", - MAXPATHLEN - 1, Z_STRLEN_P(option)); + zend_value_error("Option \"remove_path\" must be less than %d bytes", MAXPATHLEN - 1); return -1; } opts->remove_path_len = Z_STRLEN_P(option); @@ -395,18 +413,18 @@ static int php_zip_parse_options(HashTable *options, zip_options *opts) if ((option = zend_hash_str_find(options, "add_path", sizeof("add_path") - 1)) != NULL) { if (Z_TYPE_P(option) != IS_STRING) { - php_error_docref(NULL, E_WARNING, "add_path option expected to be a string"); + zend_type_error("Option \"add_path\" must be of type string, %s given", + zend_zval_type_name(option)); return -1; } - if (Z_STRLEN_P(option) < 1) { - php_error_docref(NULL, E_NOTICE, "Empty string given as the add_path option"); + if (Z_STRLEN_P(option) == 0) { + zend_value_error("Option \"add_path\" cannot be empty"); return -1; } if (Z_STRLEN_P(option) >= MAXPATHLEN) { - php_error_docref(NULL, E_WARNING, "add_path string too long (max: %d, %zd given)", - MAXPATHLEN - 1, Z_STRLEN_P(option)); + zend_value_error("Option \"add_path\" must be less than %d bytes", MAXPATHLEN - 1); return -1; } opts->add_path_len = Z_STRLEN_P(option); @@ -415,7 +433,8 @@ static int php_zip_parse_options(HashTable *options, zip_options *opts) if ((option = zend_hash_str_find(options, "flags", sizeof("flags") - 1)) != NULL) { if (Z_TYPE_P(option) != IS_LONG) { - php_error_docref(NULL, E_WARNING, "flags option expected to be a integer"); + zend_type_error("Option \"flags\" must be of type int, %s given", + zend_zval_type_name(option)); return -1; } opts->flags = Z_LVAL_P(option); @@ -599,6 +618,7 @@ int php_zip_glob(char *pattern, int pattern_len, zend_long flags, zval *return_v } if ((GLOB_AVAILABLE_FLAGS & flags) != flags) { + php_error_docref(NULL, E_WARNING, "At least one of the passed flags is invalid or not supported on this platform"); return -1; } @@ -1134,8 +1154,8 @@ PHP_FUNCTION(zip_open) } if (ZSTR_LEN(filename) == 0) { - php_error_docref(NULL, E_WARNING, "Empty string as source"); - RETURN_FALSE; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } if (ZIP_OPENBASEDIR_CHECKPATH(ZSTR_VAL(filename))) { @@ -1414,8 +1434,8 @@ PHP_METHOD(ZipArchive, open) ze_obj = Z_ZIP_P(self); if (ZSTR_LEN(filename) == 0) { - php_error_docref(NULL, E_WARNING, "Empty string as source"); - RETURN_FALSE; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } if (ZIP_OPENBASEDIR_CHECKPATH(ZSTR_VAL(filename))) { @@ -1677,11 +1697,11 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /* } if (ZSTR_LEN(pattern) == 0) { - php_error_docref(NULL, E_NOTICE, "Empty string as pattern"); - RETURN_FALSE; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } if (options && zend_hash_num_elements(options) > 0 && (php_zip_parse_options(options, &opts) < 0)) { - RETURN_FALSE; + RETURN_THROWS(); } if (type == 1) { @@ -1795,8 +1815,8 @@ PHP_METHOD(ZipArchive, addFile) } if (ZSTR_LEN(filename) == 0) { - php_error_docref(NULL, E_NOTICE, "Empty string as filename"); - RETURN_FALSE; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } if (entry_name_len == 0) { @@ -1828,13 +1848,13 @@ PHP_METHOD(ZipArchive, replaceFile) } if (ZSTR_LEN(filename) == 0) { - php_error_docref(NULL, E_NOTICE, "Empty string as filename"); - RETURN_FALSE; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } if (index < 0) { - php_error_docref(NULL, E_NOTICE, "Invalid negative index"); - RETURN_FALSE; + zend_argument_value_error(2, "must be greater than or equal to 0"); + RETURN_THROWS(); } if (php_zip_add_file(Z_ZIP_P(self), ZSTR_VAL(filename), ZSTR_LEN(filename), @@ -2008,8 +2028,8 @@ PHP_METHOD(ZipArchive, setArchiveComment) ZIP_FROM_OBJECT(intern, self); if (comment_len > 0xffff) { - php_error_docref(NULL, E_WARNING, "Comment must not exceed 65535 bytes"); - RETURN_FALSE; + zend_argument_value_error(1, "must be less than 65535 bytes"); + RETURN_THROWS(); } if (zip_set_archive_comment(intern, (const char *)comment, comment_len)) { @@ -2057,15 +2077,16 @@ PHP_METHOD(ZipArchive, setCommentName) RETURN_THROWS(); } - if (name_len < 1) { - php_error_docref(NULL, E_NOTICE, "Empty string as entry name"); + if (name_len == 0) { + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } ZIP_FROM_OBJECT(intern, self); if (comment_len > 0xffff) { - php_error_docref(NULL, E_WARNING, "Comment must not exceed 65535 bytes"); - RETURN_FALSE; + zend_argument_value_error(2, "must be less than 65535 bytes"); + RETURN_THROWS(); } idx = zip_name_locate(intern, name, 0); @@ -2094,8 +2115,8 @@ PHP_METHOD(ZipArchive, setCommentIndex) ZIP_FROM_OBJECT(intern, self); if (comment_len > 0xffff) { - php_error_docref(NULL, E_WARNING, "Comment must not exceed 65535 bytes"); - RETURN_FALSE; + zend_argument_value_error(2, "must be less than 65535 bytes"); + RETURN_THROWS(); } PHP_ZIP_STAT_INDEX(intern, index, 0, sb); @@ -2123,11 +2144,13 @@ PHP_METHOD(ZipArchive, setExternalAttributesName) ZIP_FROM_OBJECT(intern, self); - if (name_len < 1) { - php_error_docref(NULL, E_NOTICE, "Empty string as entry name"); + if (name_len == 0) { + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } idx = zip_name_locate(intern, name, 0); + if (idx < 0) { RETURN_FALSE; } @@ -2182,11 +2205,13 @@ PHP_METHOD(ZipArchive, getExternalAttributesName) ZIP_FROM_OBJECT(intern, self); - if (name_len < 1) { - php_error_docref(NULL, E_NOTICE, "Empty string as entry name"); + if (name_len == 0) { + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } idx = zip_name_locate(intern, name, 0); + if (idx < 0) { RETURN_FALSE; } @@ -2247,11 +2272,13 @@ PHP_METHOD(ZipArchive, setEncryptionName) ZIP_FROM_OBJECT(intern, self); - if (name_len < 1) { - php_error_docref(NULL, E_NOTICE, "Empty string as entry name"); + if (name_len == 0) { + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } idx = zip_name_locate(intern, name, 0); + if (idx < 0) { RETURN_FALSE; } @@ -2306,12 +2333,13 @@ PHP_METHOD(ZipArchive, getCommentName) ZIP_FROM_OBJECT(intern, self); - if (name_len < 1) { - php_error_docref(NULL, E_NOTICE, "Empty string as entry name"); - RETURN_FALSE; + if (name_len == 0) { + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } idx = zip_name_locate(intern, name, 0); + if (idx < 0) { RETURN_FALSE; } @@ -2346,7 +2374,7 @@ PHP_METHOD(ZipArchive, getCommentIndex) /* {{{ Set the compression of a file in zip, using its name */ PHP_METHOD(ZipArchive, setCompressionName) - { +{ struct zip *intern; zval *this = ZEND_THIS; size_t name_len; @@ -2361,11 +2389,13 @@ PHP_METHOD(ZipArchive, setCompressionName) ZIP_FROM_OBJECT(intern, this); - if (name_len < 1) { - php_error_docref(NULL, E_NOTICE, "Empty string as entry name"); + if (name_len == 0) { + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } idx = zip_name_locate(intern, name, 0); + if (idx < 0) { RETURN_FALSE; } @@ -2404,7 +2434,7 @@ PHP_METHOD(ZipArchive, setCompressionIndex) #ifdef HAVE_SET_MTIME /* {{{ Set the modification time of a file in zip, using its name */ PHP_METHOD(ZipArchive, setMtimeName) - { +{ struct zip *intern; zval *this = ZEND_THIS; size_t name_len; @@ -2419,11 +2449,13 @@ PHP_METHOD(ZipArchive, setMtimeName) ZIP_FROM_OBJECT(intern, this); - if (name_len < 1) { - php_error_docref(NULL, E_NOTICE, "Empty string as entry name"); + if (name_len == 0) { + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } idx = zip_name_locate(intern, name, 0); + if (idx < 0) { RETURN_FALSE; } @@ -2531,9 +2563,9 @@ PHP_METHOD(ZipArchive, renameIndex) ZIP_FROM_OBJECT(intern, self); - if (new_name_len < 1) { - php_error_docref(NULL, E_NOTICE, "Empty string as new entry name"); - RETURN_FALSE; + if (new_name_len == 0) { + zend_argument_value_error(2, "cannot be empty"); + RETURN_THROWS(); } if (zip_file_rename(intern, index, (const char *)new_name, 0) != 0) { @@ -2559,9 +2591,9 @@ PHP_METHOD(ZipArchive, renameName) ZIP_FROM_OBJECT(intern, self); - if (new_name_len < 1) { - php_error_docref(NULL, E_NOTICE, "Empty string as new entry name"); - RETURN_FALSE; + if (new_name_len == 0) { + zend_argument_value_error(2, "cannot be empty"); + RETURN_THROWS(); } PHP_ZIP_STAT_PATH(intern, name, name_len, 0, sb); @@ -2886,19 +2918,12 @@ PHP_METHOD(ZipArchive, registerProgressCallback) struct zip *intern; zval *self = ZEND_THIS; double rate; - zval *callback; + zend_fcall_info fci; + zend_fcall_info_cache fcc; ze_zip_object *obj; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "dz", &rate, &callback) == FAILURE) { - return; - } - - /* callable? */ - if (!zend_is_callable(callback, 0, NULL)) { - zend_string *callback_name = zend_get_callable_name(callback); - php_error_docref(NULL, E_WARNING, "Invalid callback '%s'", ZSTR_VAL(callback_name)); - zend_string_release_ex(callback_name, 0); - RETURN_FALSE; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "df", &rate, &fci, &fcc) == FAILURE) { + RETURN_THROWS(); } ZIP_FROM_OBJECT(intern, self); @@ -2909,7 +2934,7 @@ PHP_METHOD(ZipArchive, registerProgressCallback) _php_zip_progress_callback_free(obj); /* register */ - ZVAL_COPY(&obj->progress_callback, callback); + ZVAL_COPY(&obj->progress_callback, &fci.function_name); if (zip_register_progress_callback_with_state(intern, rate, _php_zip_progress_callback, _php_zip_progress_callback_free, obj)) { RETURN_FALSE; } @@ -2939,30 +2964,22 @@ PHP_METHOD(ZipArchive, registerCancelCallback) { struct zip *intern; zval *self = ZEND_THIS; - zval *callback; + zend_fcall_info fci; + zend_fcall_info_cache fcc; ze_zip_object *obj; - - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &callback) == FAILURE) { - return; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "f", &fci, &fcc) == FAILURE) { + RETURN_THROWS(); } ZIP_FROM_OBJECT(intern, self); - /* callable? */ - if (!zend_is_callable(callback, 0, NULL)) { - zend_string *callback_name = zend_get_callable_name(callback); - php_error_docref(NULL, E_WARNING, "Invalid callback '%s'", ZSTR_VAL(callback_name)); - zend_string_release_ex(callback_name, 0); - RETURN_FALSE; - } - obj = Z_ZIP_P(self); /* free if called twice */ _php_zip_cancel_callback_free(obj); /* register */ - ZVAL_COPY(&obj->cancel_callback, callback); + ZVAL_COPY(&obj->cancel_callback, &fci.function_name); if (zip_register_cancel_callback_with_state(intern, _php_zip_cancel_callback, _php_zip_cancel_callback_free, obj)) { RETURN_FALSE; } diff --git a/ext/zip/tests/oo_getcomment.phpt b/ext/zip/tests/oo_getcomment.phpt index 6f54105cc88d2..8687167a40e93 100644 --- a/ext/zip/tests/oo_getcomment.phpt +++ b/ext/zip/tests/oo_getcomment.phpt @@ -16,16 +16,20 @@ if (!$zip->open($file)) { echo $zip->getArchiveComment() . "\n"; $idx = $zip->locateName('foo'); -echo $zip->getCommentName('foo') . "\n"; -echo $zip->getCommentIndex($idx); +var_dump($zip->getCommentName('foo')); +var_dump($zip->getCommentIndex($idx)); -echo $zip->getCommentName('') . "\n"; +try { + echo $zip->getCommentName('') . "\n"; +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} $zip->close(); ?> ---EXPECTF-- +--EXPECT-- Zip archive comment -foo comment -foo comment -Notice: ZipArchive::getCommentName(): Empty string as entry name in %s on line %d +string(11) "foo comment" +string(11) "foo comment" +ZipArchive::getCommentName(): Argument #1 ($name) cannot be empty diff --git a/ext/zip/tests/oo_open.phpt b/ext/zip/tests/oo_open.phpt index 2dffdc0d889f7..a7e8d308186df 100644 --- a/ext/zip/tests/oo_open.phpt +++ b/ext/zip/tests/oo_open.phpt @@ -25,7 +25,11 @@ if (!$r) { @unlink($dirname . 'nofile'); $zip = new ZipArchive; -$zip->open(''); +try { + $zip->open(''); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} if (!$zip->open($dirname . 'test.zip')) { exit("failed 1\n"); @@ -37,9 +41,8 @@ if ($zip->status == ZIPARCHIVE::ER_OK) { echo "failed\n"; } ?> ---EXPECTF-- +--EXPECT-- ER_OPEN: ok create: ok - -Warning: ZipArchive::open(): Empty string as source in %s on line %d +ZipArchive::open(): Argument #1 ($filename) cannot be empty OK diff --git a/ext/zip/tests/oo_setcomment_error.phpt b/ext/zip/tests/oo_setcomment_error.phpt index 78d8d3dc35602..74a582a6f8efe 100644 --- a/ext/zip/tests/oo_setcomment_error.phpt +++ b/ext/zip/tests/oo_setcomment_error.phpt @@ -20,21 +20,28 @@ $zip->addFromString('entry2.txt', 'entry #2'); $longComment = str_repeat('a', 0x10000); -var_dump($zip->setArchiveComment($longComment)); -var_dump($zip->setCommentName('entry1.txt', $longComment)); -var_dump($zip->setCommentIndex(1, $longComment)); +try { + var_dump($zip->setArchiveComment($longComment)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} +try { + var_dump($zip->setCommentName('entry1.txt', $longComment)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} +try { + var_dump($zip->setCommentIndex(1, $longComment)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} $zip->close(); ?> ---EXPECTF-- -Warning: ZipArchive::setArchiveComment(): Comment must not exceed 65535 bytes in %s on line %d -bool(false) - -Warning: ZipArchive::setCommentName(): Comment must not exceed 65535 bytes in %s on line %d -bool(false) - -Warning: ZipArchive::setCommentIndex(): Comment must not exceed 65535 bytes in %s on line %d -bool(false) +--EXPECT-- +ZipArchive::setArchiveComment(): Argument #1 ($comment) must be less than 65535 bytes +ZipArchive::setCommentName(): Argument #2 ($comment) must be less than 65535 bytes +ZipArchive::setCommentIndex(): Argument #2 ($comment) must be less than 65535 bytes --CLEAN-- getMessage() . \PHP_EOL; +} echo "Test case 2:\n"; $zip = zip_open("/non_exisitng_directory/test_procedural.zip"); @@ -19,8 +23,7 @@ echo is_resource($zip) ? "OK" : "Failure"; --EXPECTF-- Test case 1: Deprecated: Function zip_open() is deprecated in %s on line %d - -Warning: zip_open(): Empty string as source in %s on line %d +zip_open(): Argument #1 ($filename) cannot be empty Test case 2: Deprecated: Function zip_open() is deprecated in %s on line %d From 28e24e7accc1dad764ea7f2add87091bc4ebedc9 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 17 Aug 2020 20:47:06 +0300 Subject: [PATCH 004/170] Fixed JIT for indirectly recursive traces --- ext/opcache/jit/zend_jit_trace.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index 24b4e7cd81905..cdddc566020b2 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -4677,15 +4677,26 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if (handler) { if (p->stop == ZEND_JIT_TRACE_STOP_RECURSIVE_CALL) { - op_array = trace_buffer->op_array; + const zend_op_array *rec_op_array; + + rec_op_array = op_array = trace_buffer->op_array; + jit_extension = + (zend_jit_op_array_trace_extension*)ZEND_FUNC_INFO(op_array); p = trace_buffer + ZEND_JIT_TRACE_START_REC_SIZE; for (;;p++) { if (p->op == ZEND_JIT_TRACE_VM) { opline = p->opline; } else if (p->op == ZEND_JIT_TRACE_ENTER) { - if (p->op_array == op_array) { + if (p->op_array == rec_op_array) { zend_jit_trace_setup_ret_counter(opline, jit_extension->offset); } + op_array = p->op_array; + jit_extension = + (zend_jit_op_array_trace_extension*)ZEND_FUNC_INFO(op_array); + } else if (p->op == ZEND_JIT_TRACE_BACK) { + op_array = p->op_array; + jit_extension = + (zend_jit_op_array_trace_extension*)ZEND_FUNC_INFO(op_array); } else if (p->op == ZEND_JIT_TRACE_END) { break; } From afc93e44e5e356787c765b103bf133bcda5b640b Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 17 Aug 2020 20:48:48 +0300 Subject: [PATCH 005/170] JIT for ZEND_ISSET_ISEMPTY_CV --- ext/opcache/jit/zend_jit.c | 27 ++++++++++++ ext/opcache/jit/zend_jit_trace.c | 36 ++++++++++++++++ ext/opcache/jit/zend_jit_x86.dasc | 69 +++++++++++++++++++++++++++++++ 3 files changed, 132 insertions(+) diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index 90bed235d26dc..e66afd9d2b149 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -2790,6 +2790,33 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op goto jit_failure; } goto done; + case ZEND_ISSET_ISEMPTY_CV: + if ((opline->extended_value & ZEND_ISEMPTY)) { + // TODO: support for empty() ??? + break; + } + if ((opline->result_type & IS_TMP_VAR) + && (i + 1) <= end + && ((opline+1)->opcode == ZEND_JMPZ + || (opline+1)->opcode == ZEND_JMPNZ + || (opline+1)->opcode == ZEND_JMPZNZ) + && (opline+1)->op1_type == IS_TMP_VAR + && (opline+1)->op1.var == opline->result.var) { + i++; + smart_branch_opcode = (opline+1)->opcode; + target_label = ssa->cfg.blocks[b].successors[0]; + target_label2 = ssa->cfg.blocks[b].successors[1]; + } else { + smart_branch_opcode = 0; + target_label = target_label2 = (uint32_t)-1; + } + if (!zend_jit_isset_isempty_cv(&dasm_state, opline, op_array, + OP1_INFO(), OP1_REG_ADDR(), + smart_branch_opcode, target_label, target_label2, + NULL)) { + goto jit_failure; + } + goto done; case ZEND_FETCH_DIM_R: case ZEND_FETCH_DIM_IS: if (PROFITABILITY_CHECKS && (!ssa->ops || !ssa->var_info)) { diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index cdddc566020b2..0d2e187f0d22a 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -1486,6 +1486,7 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin case ZEND_JMPNZ_EX: case ZEND_BOOL: case ZEND_BOOL_NOT: + case ZEND_ISSET_ISEMPTY_CV: ADD_OP1_TRACE_GUARD(); break; case ZEND_ISSET_ISEMPTY_DIM_OBJ: @@ -3912,6 +3913,41 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par goto jit_failure; } goto done; + case ZEND_ISSET_ISEMPTY_CV: + if ((opline->extended_value & ZEND_ISEMPTY)) { + // TODO: support for empty() ??? + break; + } + op1_info = OP1_INFO(); + op1_addr = OP1_REG_ADDR(); + if (orig_op1_type != IS_UNKNOWN + && (orig_op1_type & IS_TRACE_REFERENCE)) { + if (!zend_jit_fetch_reference(&dasm_state, opline, orig_op1_type, &op1_info, &op1_addr, 1)) { + goto jit_failure; + } + } else { + CHECK_OP1_TRACE_TYPE(); + } + if ((opline->result_type & (IS_SMART_BRANCH_JMPZ|IS_SMART_BRANCH_JMPNZ)) != 0) { + zend_bool exit_if_true = 0; + const zend_op *exit_opline = zend_jit_trace_get_exit_opline(p + 1, opline + 1, &exit_if_true); + uint32_t exit_point = zend_jit_trace_get_exit_point(opline, exit_opline, p + 1, 0); + + exit_addr = zend_jit_trace_get_exit_addr(exit_point); + if (!exit_addr) { + goto jit_failure; + } + smart_branch_opcode = exit_if_true ? ZEND_JMPNZ : ZEND_JMPZ; + } else { + smart_branch_opcode = 0; + exit_addr = NULL; + } + if (!zend_jit_isset_isempty_cv(&dasm_state, opline, op_array, + op1_info, op1_addr, + smart_branch_opcode, -1, -1, exit_addr)) { + goto jit_failure; + } + goto done; case ZEND_FETCH_DIM_FUNC_ARG: if (!JIT_G(current_frame) || !JIT_G(current_frame)->call diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index 8933c0890e221..b92783c109631 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -12159,6 +12159,75 @@ static zend_bool zend_jit_verify_return_type(dasm_State **Dst, const zend_op *op return 1; } +static int zend_jit_isset_isempty_cv(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_jit_addr op1_addr, zend_uchar smart_branch_opcode, uint32_t target_label, uint32_t target_label2, const void *exit_addr) +{ + zend_jit_addr res_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->result.var); + + // TODO: support for empty() ??? + ZEND_ASSERT(!(opline->extended_value & ZEND_ISEMPTY)); + + if (op1_info & MAY_BE_REF) { + if (Z_MODE(op1_addr) != IS_MEM_ZVAL || Z_REG(op1_addr) != ZREG_FCARG1a || Z_OFFSET(op1_addr) != 0) { + | LOAD_ZVAL_ADDR FCARG1a, op1_addr + op1_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, 0); + } + | ZVAL_DEREF FCARG1a, op1_info + |1: + } + + if (!(op1_info & (MAY_BE_UNDEF|MAY_BE_NULL))) { + if (exit_addr) { + ZEND_ASSERT(smart_branch_opcode == ZEND_JMPZ); + } else if (smart_branch_opcode) { + if (smart_branch_opcode == ZEND_JMPNZ) { + | jmp =>target_label + } else if (smart_branch_opcode == ZEND_JMPZNZ) { + | jmp =>target_label2 + } + } else { + | SET_ZVAL_TYPE_INFO res_addr, IS_TRUE + } + } else if (!(op1_info & (MAY_BE_ANY - MAY_BE_NULL))) { + if (exit_addr) { + ZEND_ASSERT(smart_branch_opcode == ZEND_JMPNZ); + } else if (smart_branch_opcode) { + if (smart_branch_opcode != ZEND_JMPNZ) { + | jmp =>target_label + } + } else { + | SET_ZVAL_TYPE_INFO res_addr, IS_FALSE + } + } else { + ZEND_ASSERT(Z_MODE(op1_addr) == IS_MEM_ZVAL); + | cmp byte [Ra(Z_REG(op1_addr))+Z_OFFSET(op1_addr)+offsetof(zval, u1.v.type)], IS_NULL + if (exit_addr) { + if (smart_branch_opcode == ZEND_JMPNZ) { + | jg &exit_addr + } else { + | jle &exit_addr + } + } else if (smart_branch_opcode) { + if (smart_branch_opcode == ZEND_JMPZ) { + | jle =>target_label + } else if (smart_branch_opcode == ZEND_JMPNZ) { + | jg =>target_label + } else if (smart_branch_opcode == ZEND_JMPZNZ) { + | jle =>target_label + | jmp =>target_label2 + } else { + ZEND_UNREACHABLE(); + } + } else { + | setg al + | movzx eax, al + | lea eax, [eax + IS_FALSE] + | SET_ZVAL_TYPE_INFO res_addr, eax + } + } + + return 1; +} + static zend_bool zend_jit_noref_guard(dasm_State **Dst, const zend_op *opline, zend_jit_addr var_addr) { int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, 0); From 32052e74702aa27aacffa871aa1ff812e9f00c15 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 17 Aug 2020 22:31:03 +0300 Subject: [PATCH 006/170] Fixed support for possible indirect variable modification (ext/standard/tests/array/bug77135.phpt failure). --- ext/opcache/jit/zend_jit_trace.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index 0d2e187f0d22a..d86e1d10b9f5a 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -4585,6 +4585,10 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if (p->func) { if (p->func->type == ZEND_USER_FUNCTION) { if (JIT_G(opt_level) >= ZEND_JIT_LEVEL_INLINE) { + zend_jit_op_array_trace_extension *jit_extension = + (zend_jit_op_array_trace_extension*)ZEND_FUNC_INFO(p->op_array); + zend_ssa *op_array_ssa = &jit_extension->func_info.ssa; + i = 0; while (i < p->op_array->num_args) { /* Types of arguments are going to be stored in abstract stack when processing SEV instruction */ @@ -4592,7 +4596,11 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par i++; } while (i < p->op_array->last_var) { - SET_STACK_TYPE(call->stack, i, IS_UNDEF); + if (zend_jit_var_may_be_modified_indirectly(p->op_array, op_array_ssa, i)) { + SET_STACK_TYPE(call->stack, i, IS_UNKNOWN); + } else { + SET_STACK_TYPE(call->stack, i, IS_UNDEF); + } i++; } while (i < p->op_array->last_var + p->op_array->T) { From 3343eb64d7fbbb8b5fbd32c1082014f474515f4e Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 17 Aug 2020 22:55:25 +0300 Subject: [PATCH 007/170] Fixed trace type inference for FE_FETCH_R/RW --- ext/opcache/jit/zend_jit_trace.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index d86e1d10b9f5a..e8124f9ce8f49 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -1626,6 +1626,11 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin && !(op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS)) { /* RECV_INIT always copy the constant */ ssa_var_info[ssa_ops[idx].result_def].type = _const_op_type(RT_CONSTANT(opline, opline->op2)); + } else if ((opline->opcode == ZEND_FE_FETCH_R || opline->opcode == ZEND_FE_FETCH_RW) + && ssa_opcodes[idx + 1] == ZEND_OFFSET_TO_OPLINE(opline, opline->extended_value)) { + if (ssa_ops[idx].op2_use >= 0 && ssa_ops[idx].op2_def >= 0) { + ssa_var_info[ssa_ops[idx].op2_def] = ssa_var_info[ssa_ops[idx].op2_use]; + } } else { if (zend_update_type_info(op_array, tssa, script, (zend_op*)opline, ssa_ops + idx, ssa_opcodes, optimization_level) == FAILURE) { // TODO: @@ -1654,7 +1659,10 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin } } if (ssa_ops[idx].op2_def >= 0) { - zend_jit_trace_restrict_ssa_var_info(op_array, ssa, ssa_opcodes, tssa, ssa_ops[idx].op2_def); + if ((opline->opcode != ZEND_FE_FETCH_R && opline->opcode != ZEND_FE_FETCH_RW) + || ssa_opcodes[idx + 1] != ZEND_OFFSET_TO_OPLINE(opline, opline->extended_value)) { + zend_jit_trace_restrict_ssa_var_info(op_array, ssa, ssa_opcodes, tssa, ssa_ops[idx].op2_def); + } } if (ssa_ops[idx].result_def >= 0) { zend_jit_trace_restrict_ssa_var_info(op_array, ssa, ssa_opcodes, tssa, ssa_ops[idx].result_def); From fd0b57d48bab3924a31d3d0b038f0d5de6eab3e3 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 18 Aug 2020 00:12:05 +0300 Subject: [PATCH 008/170] Fixed support for named arguments --- ext/opcache/jit/zend_jit_trace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index e8124f9ce8f49..b8a4f6ac86f25 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -4476,7 +4476,8 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par /* Check if SEND_UNPACK/SEND_ARRAY may cause enter at different opline */ if (opline > op_array->opcodes && ((opline-1)->opcode == ZEND_SEND_ARRAY - || (opline-1)->opcode == ZEND_SEND_UNPACK) + || (opline-1)->opcode == ZEND_SEND_UNPACK + || (opline-1)->opcode == ZEND_CHECK_UNDEF_ARGS) && p->op_array->num_args && (p->op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS) == 0 && ((p+1)->op == ZEND_JIT_TRACE_VM From 5d94ff8a008c0399094374b47ff0aeff740ddff8 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 18 Aug 2020 09:28:13 +0300 Subject: [PATCH 009/170] JIT extension may be NULL --- ext/opcache/jit/zend_jit_trace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index b8a4f6ac86f25..6d28780fc5c7e 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -4596,7 +4596,6 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if (JIT_G(opt_level) >= ZEND_JIT_LEVEL_INLINE) { zend_jit_op_array_trace_extension *jit_extension = (zend_jit_op_array_trace_extension*)ZEND_FUNC_INFO(p->op_array); - zend_ssa *op_array_ssa = &jit_extension->func_info.ssa; i = 0; while (i < p->op_array->num_args) { @@ -4605,7 +4604,8 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par i++; } while (i < p->op_array->last_var) { - if (zend_jit_var_may_be_modified_indirectly(p->op_array, op_array_ssa, i)) { + if (jit_extension + && zend_jit_var_may_be_modified_indirectly(p->op_array, &jit_extension->func_info.ssa, i)) { SET_STACK_TYPE(call->stack, i, IS_UNKNOWN); } else { SET_STACK_TYPE(call->stack, i, IS_UNDEF); From 1ae80f8c92e37bc1940ee7d927ff365fc176f2d6 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Mon, 17 Aug 2020 18:36:02 +0200 Subject: [PATCH 010/170] Fix HTTP response status code --- ext/soap/soap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/soap/soap.c b/ext/soap/soap.c index bff077d95fdb8..3651779972e70 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -2059,7 +2059,7 @@ static void soap_server_fault_ex(sdlFunctionPtr function, zval* fault, soapHeade our fault code with their own handling... Figure this out later */ if (use_http_error_status) { - sapi_add_header("HTTP/1.1 500 Internal Service Error", sizeof("HTTP/1.1 500 Internal Service Error")-1, 1); + sapi_add_header("HTTP/1.1 500 Internal Server Error", sizeof("HTTP/1.1 500 Internal Server Error")-1, 1); } if (zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0)) { sapi_add_header("Connection: close", sizeof("Connection: close")-1, 1); From 499bf91cd0af7e2a283f89d15604478b111af955 Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Tue, 18 Aug 2020 08:06:20 +0100 Subject: [PATCH 011/170] Prepare for 7.4.11 --- NEWS | 5 ++++- configure.ac | 2 +- main/php_version.h | 6 +++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 9a971b5062b6d..5aa9df62d19b4 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,9 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -?? ??? 2020, PHP 7.4.10 +?? ??? 2020, PHP 7.4.11 + + +03 Sep 2020, PHP 7.4.10 - Core: . Fixed bug #79884 (PHP_CONFIG_FILE_PATH is meaningless). (cmb) diff --git a/configure.ac b/configure.ac index df3a0a1107c97..c843240f9fa7c 100644 --- a/configure.ac +++ b/configure.ac @@ -17,7 +17,7 @@ dnl Basic autoconf initialization, generation of config.nice. dnl ---------------------------------------------------------------------------- AC_PREREQ([2.68]) -AC_INIT([PHP],[7.4.10-dev],[https://bugs.php.net],[php],[https://www.php.net]) +AC_INIT([PHP],[7.4.11-dev],[https://bugs.php.net],[php],[https://www.php.net]) AC_CONFIG_SRCDIR([main/php_version.h]) AC_CONFIG_AUX_DIR([build]) AC_PRESERVE_HELP_ORDER diff --git a/main/php_version.h b/main/php_version.h index 0c0ffba6a02a0..75d1e02d5ec73 100644 --- a/main/php_version.h +++ b/main/php_version.h @@ -2,7 +2,7 @@ /* edit configure.ac to change version number */ #define PHP_MAJOR_VERSION 7 #define PHP_MINOR_VERSION 4 -#define PHP_RELEASE_VERSION 10 +#define PHP_RELEASE_VERSION 11 #define PHP_EXTRA_VERSION "-dev" -#define PHP_VERSION "7.4.10-dev" -#define PHP_VERSION_ID 70410 +#define PHP_VERSION "7.4.11-dev" +#define PHP_VERSION_ID 70411 From ff14b7adad4c63cc9f7118fd1794e006593391f8 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 18 Aug 2020 09:55:37 +0200 Subject: [PATCH 012/170] 7.3.23 is next --- NEWS | 5 ++++- Zend/zend.h | 2 +- configure.ac | 2 +- main/php_version.h | 6 +++--- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 178785e884be5..5757c09f51769 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,9 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -?? ??? ????, PHP 7.3.22 +?? ??? ????, PHP 7.3.23 + + +03 Sep 2020, PHP 7.3.22 - Core: . Fixed bug #79884 (PHP_CONFIG_FILE_PATH is meaningless). (cmb) diff --git a/Zend/zend.h b/Zend/zend.h index 98931f3c83eb4..f9900960bd9f5 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -20,7 +20,7 @@ #ifndef ZEND_H #define ZEND_H -#define ZEND_VERSION "3.3.22-dev" +#define ZEND_VERSION "3.3.23-dev" #define ZEND_ENGINE_3 diff --git a/configure.ac b/configure.ac index dadbb4799e7b8..2626bc5fed4a6 100644 --- a/configure.ac +++ b/configure.ac @@ -107,7 +107,7 @@ int zend_sprintf(char *buffer, const char *format, ...); PHP_MAJOR_VERSION=7 PHP_MINOR_VERSION=3 -PHP_RELEASE_VERSION=22 +PHP_RELEASE_VERSION=23 PHP_EXTRA_VERSION="-dev" PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION" PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION` diff --git a/main/php_version.h b/main/php_version.h index a4215ddeaec24..2c10ad05b900f 100644 --- a/main/php_version.h +++ b/main/php_version.h @@ -2,7 +2,7 @@ /* edit configure.ac to change version number */ #define PHP_MAJOR_VERSION 7 #define PHP_MINOR_VERSION 3 -#define PHP_RELEASE_VERSION 22 +#define PHP_RELEASE_VERSION 23 #define PHP_EXTRA_VERSION "-dev" -#define PHP_VERSION "7.3.22-dev" -#define PHP_VERSION_ID 70322 +#define PHP_VERSION "7.3.23-dev" +#define PHP_VERSION_ID 70323 From 8c900022014cd7cff0d7708f3dc7041e42db97b7 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 18 Aug 2020 11:08:04 +0300 Subject: [PATCH 013/170] Fixed bug #79987 (Memory leak in SplFileInfo because of missing zend_restore_error_handling()) --- NEWS | 3 +++ ext/spl/spl_directory.c | 4 ++++ ext/spl/tests/bug79987.phpt | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 ext/spl/tests/bug79987.phpt diff --git a/NEWS b/NEWS index c0d14769a227f..1f27ce6b62339 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,9 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 8.0.0beta2 +- SPL: + . Fixed bug #79987 (Memory leak in SplFileInfo because of missing + zend_restore_error_handling()). (Dmitry) 06 Aug 2020, PHP 8.0.0beta1 diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 93299470c9311..0836e18bc4534 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -1224,16 +1224,19 @@ PHP_METHOD(SplFileInfo, getLinkTarget) if (intern->file_name == NULL) { if (spl_filesystem_object_get_file_name(intern) != SUCCESS) { + zend_restore_error_handling(&error_handling); RETURN_THROWS(); } } #if defined(PHP_WIN32) || defined(HAVE_SYMLINK) if (intern->file_name == NULL) { + zend_restore_error_handling(&error_handling); php_error_docref(NULL, E_WARNING, "Empty filename"); RETURN_FALSE; } else if (!IS_ABSOLUTE_PATH(intern->file_name, intern->file_name_len)) { char expanded_path[MAXPATHLEN]; if (!expand_filepath_with_mode(intern->file_name, expanded_path, NULL, 0, CWD_EXPAND )) { + zend_restore_error_handling(&error_handling); php_error_docref(NULL, E_WARNING, "No such file or directory"); RETURN_FALSE; } @@ -1275,6 +1278,7 @@ PHP_METHOD(SplFileInfo, getRealPath) if (intern->type == SPL_FS_DIR && !intern->file_name && intern->u.dir.entry.d_name[0]) { if (spl_filesystem_object_get_file_name(intern) != SUCCESS) { + zend_restore_error_handling(&error_handling); RETURN_THROWS(); } } diff --git a/ext/spl/tests/bug79987.phpt b/ext/spl/tests/bug79987.phpt new file mode 100644 index 0000000000000..bda5841ee7a69 --- /dev/null +++ b/ext/spl/tests/bug79987.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #79987 (Memory leak in SplFileInfo because of missing zend_restore_error_handling()) +--FILE-- +getLinkTarget()); +} catch (Throwable $e) { + echo $e->getMessage() . "\n"; +} +--EXPECT-- +Object not initialized From 6f36b20abf2ec91d956d2df25ff1f785a665a20d Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 18 Aug 2020 13:13:58 +0300 Subject: [PATCH 014/170] Don't add guard for empty() --- ext/opcache/jit/zend_jit_trace.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index 6d28780fc5c7e..b2541d0346986 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -1486,7 +1486,13 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin case ZEND_JMPNZ_EX: case ZEND_BOOL: case ZEND_BOOL_NOT: + ADD_OP1_TRACE_GUARD(); + break; case ZEND_ISSET_ISEMPTY_CV: + if ((opline->extended_value & ZEND_ISEMPTY)) { + // TODO: support for empty() ??? + break; + } ADD_OP1_TRACE_GUARD(); break; case ZEND_ISSET_ISEMPTY_DIM_OBJ: From 4514afc1875bedf4dc07cb457f8ef5c986a7ca55 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 18 Aug 2020 12:39:18 +0200 Subject: [PATCH 015/170] Fix #79988: new reserved keyword `match` is a backward incompatible change --- UPGRADING | 1 + 1 file changed, 1 insertion(+) diff --git a/UPGRADING b/UPGRADING index c74fc585ad3c4..4cb91bc01305a 100644 --- a/UPGRADING +++ b/UPGRADING @@ -21,6 +21,7 @@ PHP 8.0 UPGRADE NOTES ======================================== - Core: + . `match` is now a reserved keyword. . Assertion failures now throw by default. If the old behavior is desired, then set `assert.exception=0` in INI settings. . Methods with the same name as the class are no longer interpreted as From 9b4abd0cffaac7382953abfa6d3b4320ac236512 Mon Sep 17 00:00:00 2001 From: Sara Golemon Date: Tue, 18 Aug 2020 13:44:29 +0000 Subject: [PATCH 016/170] Update NEWS for PHP 8.0.0beta2 --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 1f27ce6b62339..752f9082d94a2 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -?? ??? ????, PHP 8.0.0beta2 +20 Aug 2020, PHP 8.0.0beta2 - SPL: . Fixed bug #79987 (Memory leak in SplFileInfo because of missing From c905717dfa6c47e77f473b6d7800523585bd23a5 Mon Sep 17 00:00:00 2001 From: Sara Golemon Date: Tue, 18 Aug 2020 14:03:56 +0000 Subject: [PATCH 017/170] Update NEWS for 8.0.0beta3 --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 752f9082d94a2..1b5edd772abef 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +?? ??? ????, PHP 8.0.0beta3 + + 20 Aug 2020, PHP 8.0.0beta2 - SPL: From f7c43b8c72822a4722bd7404c6f65e15b2b912c1 Mon Sep 17 00:00:00 2001 From: Matteo Beccati Date: Tue, 18 Aug 2020 18:10:39 +0200 Subject: [PATCH 018/170] Fix #47021: SoapClient stumbles over WSDL delivered with "Transfer-Encoding: chunked" --- NEWS | 4 ++ ext/soap/php_http.c | 17 +++++++- ext/soap/tests/bug47021.phpt | 80 ++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 ext/soap/tests/bug47021.phpt diff --git a/NEWS b/NEWS index 5757c09f51769..4748996c26c83 100644 --- a/NEWS +++ b/NEWS @@ -38,6 +38,10 @@ PHP NEWS . Fixed bug #64705 (errorInfo property of PDOException is null when PDO::__construct() fails). (Ahmed Abdou) +- SOAP: + . Fixed bug #47021 (SoapClient stumbles over WSDL delivered with + "Transfer-Encoding: chunked"). (Matteo) + - Standard: . Fixed bug #79930 (array_merge_recursive() crashes when called with array with single reference). (Nikita) diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c index fb3089ec271aa..b054d9ba9ebc6 100644 --- a/ext/soap/php_http.c +++ b/ext/soap/php_http.c @@ -1375,11 +1375,24 @@ static char *get_http_header_value(char *headers, char *type) /* match */ tmp = pos + typelen; + + /* strip leading whitespace */ + while (*tmp == ' ' || *tmp == '\t') { + tmp++; + } + eol = strchr(tmp, '\n'); if (eol == NULL) { eol = headers + headerslen; - } else if (eol > tmp && *(eol-1) == '\r') { - eol--; + } else if (eol > tmp) { + if (*(eol-1) == '\r') { + eol--; + } + + /* strip trailing whitespace */ + while (eol > tmp && (*(eol-1) == ' ' || *(eol-1) == '\t')) { + eol--; + } } return estrndup(tmp, eol - tmp); } diff --git a/ext/soap/tests/bug47021.phpt b/ext/soap/tests/bug47021.phpt new file mode 100644 index 0000000000000..757e74ef15ee3 --- /dev/null +++ b/ext/soap/tests/bug47021.phpt @@ -0,0 +1,80 @@ +--TEST-- +Bug #47021 SoapClient (SoapClient stumbles over WSDL delivered with "Transfer-Encoding: chunked") +--INI-- +soap.wsdl_cache_enabled=0 +--SKIPIF-- + +--FILE-- + $v) { + $chunks[$k] = sprintf("%08x\r\n%s\r\n", strlen($v), $v); + } + + return join('', $chunks); +} + +$wsdl = file_get_contents(__DIR__.'/server030.wsdl'); + +$soap = << +text0text1text2text3text4text5text6text7text8text9 +EOF; + +$responses = [ + "data://text/plain,HTTP/1.1 200 OK\r\n". + "Content-Type: text/xml;charset=utf-8\r\n". + "Transfer-Encoding: \t chunked\t \r\n". + "Connection: close\r\n". + "\r\n". + chunk_body($wsdl, 64), + "data://text/plain,HTTP/1.1 200 OK\r\n". + "Content-Type: text/xml;charset=utf-8\r\n". + "Transfer-Encoding: \t chunked\t \r\n". + "Connection: close\r\n". + "\r\n". + chunk_body($soap, 156), +]; + + +$pid = http_server('tcp://127.0.0.1:12342', $responses); + +$options = [ + 'trace' => true, + 'location' => 'http://127.0.0.1:12342/', +]; + +class BugSoapClient extends SoapClient +{ + public function __doRequest($request, $location, $action, $version, $one_way = null) + { + $response = parent::__doRequest($request, $location, $action, $version, $one_way); + + var_dump(strlen($response)); + + return $response; + } +} + +$client = new BugSoapClient('http://127.0.0.1:12342/', $options); + +var_dump(count($client->getItems())); + +http_server_kill($pid); + +?> +--EXPECT-- +int(1291) +int(10) From bf9ef513c08d7c4b92710a78e3da32103f6c9f95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Tue, 18 Aug 2020 14:29:30 +0200 Subject: [PATCH 019/170] Promote warnings to exceptions in ext/pspell Closes GH-6010 --- ext/pspell/pspell.c | 8 ++++---- ext/pspell/tests/003.phpt | 10 ++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ext/pspell/pspell.c b/ext/pspell/pspell.c index 6712784b3141a..ce3242007e2f0 100644 --- a/ext/pspell/pspell.c +++ b/ext/pspell/pspell.c @@ -76,8 +76,8 @@ static void php_pspell_close_config(zend_resource *rsrc) #define PSPELL_FETCH_CONFIG do { \ zval *res = zend_hash_index_find(&EG(regular_list), conf); \ if (res == NULL || Z_RES_P(res)->type != le_pspell_config) { \ - php_error_docref(NULL, E_WARNING, ZEND_LONG_FMT " is not a PSPELL config index", conf); \ - RETURN_FALSE; \ + zend_throw_error(NULL, "%s(): " ZEND_LONG_FMT " is not a PSPELL config index", get_active_function_name(), conf); \ + RETURN_THROWS(); \ } \ config = (PspellConfig *)Z_RES_P(res)->ptr; \ } while (0) @@ -85,8 +85,8 @@ static void php_pspell_close_config(zend_resource *rsrc) #define PSPELL_FETCH_MANAGER do { \ zval *res = zend_hash_index_find(&EG(regular_list), scin); \ if (res == NULL || Z_RES_P(res)->type != le_pspell) { \ - php_error_docref(NULL, E_WARNING, ZEND_LONG_FMT " is not a PSPELL result index", scin); \ - RETURN_FALSE; \ + zend_throw_error(NULL, "%s(): " ZEND_LONG_FMT " is not a PSPELL result index", get_active_function_name(), scin); \ + RETURN_THROWS(); \ } \ manager = (PspellManager *)Z_RES_P(res)->ptr; \ } while (0); diff --git a/ext/pspell/tests/003.phpt b/ext/pspell/tests/003.phpt index 4fc34bf6bd88f..e8677ae82687d 100644 --- a/ext/pspell/tests/003.phpt +++ b/ext/pspell/tests/003.phpt @@ -15,7 +15,11 @@ $p = pspell_new_config($cfg); var_dump(pspell_check($p, 'yy')); $p2 = pspell_new_config($cfg2); -var_dump(pspell_check($p2, 'yy')); +try { + pspell_check($p2, 'yy'); +} catch (Error $exception) { + echo $exception->getMessage() . "\n"; +} echo "---\n"; var_dump(pspell_config_ignore($cfg, 2)); @@ -30,9 +34,7 @@ var_dump(pspell_config_ignore($cfg, PHP_INT_MAX)); bool(false) Warning: pspell_new_config(): PSPELL couldn't open the dictionary. reason: The encoding "b0rked" is not known. This could also mean that the file "%sb0rked.%s" could not be opened for reading or does not exist. in %s003.php on line 9 - -Warning: pspell_check(): 0 is not a PSPELL result index in %s003.php on line 10 -bool(false) +pspell_check(): 0 is not a PSPELL result index --- bool(true) bool(true) From f2d84888066146ebaa3feaafaee35b29fa497c25 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 18 Aug 2020 21:10:34 +0300 Subject: [PATCH 020/170] Fixed register allocation for CASE instruction. CASE don't destroy first operand and it may be used later in VM or different trace. --- ext/opcache/jit/zend_jit_trace.c | 4 ++++ ext/opcache/jit/zend_jit_x86.dasc | 3 +++ 2 files changed, 7 insertions(+) diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index b2541d0346986..b331b895270e5 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -2105,6 +2105,10 @@ static zend_lifetime_interval** zend_jit_trace_allocate_registers(zend_jit_trace && !zend_ssa_is_no_val_use(opline, ssa_op, ssa_op->op1_use)) { if (support_opline) { zend_jit_trace_use_var(idx, ssa_op->op1_use, ssa_op->op1_def, ssa_op->op1_use_chain, start, end, flags, ssa, ssa_opcodes, op_array, op_array_ssa); + if (opline->opcode == ZEND_CASE && opline->op1_type != IS_CV) { + /* The value may be used outside of the trace */ + flags[ssa_op->op1_use] |= ZREG_STORE; + } } else { start[ssa_op->op1_use] = -1; end[ssa_op->op1_use] = -1; diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index b92783c109631..cdae709b31862 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -10676,6 +10676,9 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, cons if (!(res_info & AVOID_REFCOUNTING)) { | TRY_ADDREF res_info, ch, r2 } + if (!zend_jit_store_var_if_necessary(Dst, opline->result.var, res_addr, res_info)) { + return 0; + } } else if (op1_info & MAY_BE_ARRAY_OF_REF) { | // ZVAL_COPY_DEREF | GET_ZVAL_TYPE_INFO Rd(ZREG_R2), val_addr From f559c78000b8e9ae71cdd882f4b26980e4731445 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 18 Aug 2020 21:13:18 +0300 Subject: [PATCH 021/170] Check for exception after $this destruction --- ext/opcache/jit/zend_jit_x86.dasc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index cdae709b31862..25cd3143fd8a6 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -10101,6 +10101,8 @@ static int zend_jit_leave_func(dasm_State **Dst, const zend_op *opline, const ze | mov FCARG1a, EX->This.value.obj | // OBJ_RELEASE(object); | OBJ_RELEASE ZREG_FCARG1a, >4 + // TODO: avoid EG(excption) check for $this->foo() calls + may_throw = 1; } |4: } From 9883fec99fdebf866c78c98d235c1e2dbb5e9e84 Mon Sep 17 00:00:00 2001 From: Tyson Andre Date: Tue, 18 Aug 2020 19:17:03 -0400 Subject: [PATCH 022/170] Fix more basic function stubs User-defined functions can't have multiple parameters with the same name. Don't do that for var_dump/debug_zval_dump. Consistently use array $array to match docs Fix typo in UPGRADING Fixes GH-6015 --- UPGRADING | 2 +- ext/standard/basic_functions.stub.php | 8 ++++---- ext/standard/basic_functions_arginfo.h | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/UPGRADING b/UPGRADING index 4cb91bc01305a..54993d77a9713 100644 --- a/UPGRADING +++ b/UPGRADING @@ -149,7 +149,7 @@ PHP 8.0 UPGRADE NOTES new class {}; // -> class@anonymous - The name shown above is still followed by a null byte and and a unique + The name shown above is still followed by a null byte and a unique suffix. . Non-absolute trait method references in trait alias adaptations are now required to be unambiguous: diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index f3ab8734ea334..73a82b627d7c3 100755 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -169,13 +169,13 @@ function array_count_values(array $array): array {} function array_column(array $array, int|string|null $column_key, int|string|null $index_key = null): array {} -function array_reverse(array $input, bool $preserve_keys = false): array {} +function array_reverse(array $array, bool $preserve_keys = false): array {} function array_pad(array $array, int $pad_size, mixed $pad_value): array {} function array_flip(array $array): array {} -function array_change_key_case(array $input, int $case = CASE_LOWER): array {} +function array_change_key_case(array $array, int $case = CASE_LOWER): array {} function array_unique(array $array, int $flags = SORT_STRING): array {} @@ -1500,11 +1500,11 @@ function convert_uudecode(string $data): string|false {} /* var.c */ -function var_dump(mixed $value, mixed ...$value): void {} +function var_dump(mixed $value, mixed ...$values): void {} function var_export(mixed $value, bool $return = false): ?string {} -function debug_zval_dump(mixed $value, mixed ...$value): void {} +function debug_zval_dump(mixed $value, mixed ...$values): void {} function serialize(mixed $value): string {} diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index d59c0167deff0..31200dbb92d3f 100755 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 269d4da84e4bc6fae246b90e4c50e48463b86f41 */ + * Stub hash: 8b6ef365e9635c92ef86adb40b2aba077867f3b2 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0) @@ -251,7 +251,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_array_column, 0, 2, IS_ARRAY, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_array_reverse, 0, 1, IS_ARRAY, 0) - ZEND_ARG_TYPE_INFO(0, input, IS_ARRAY, 0) + ZEND_ARG_TYPE_INFO(0, array, IS_ARRAY, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, preserve_keys, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() @@ -264,7 +264,7 @@ ZEND_END_ARG_INFO() #define arginfo_array_flip arginfo_array_values ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_array_change_key_case, 0, 1, IS_ARRAY, 0) - ZEND_ARG_TYPE_INFO(0, input, IS_ARRAY, 0) + ZEND_ARG_TYPE_INFO(0, array, IS_ARRAY, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, case, IS_LONG, 0, "CASE_LOWER") ZEND_END_ARG_INFO() @@ -2173,7 +2173,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_var_dump, 0, 1, IS_VOID, 0) ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) - ZEND_ARG_VARIADIC_TYPE_INFO(0, value, IS_MIXED, 0) + ZEND_ARG_VARIADIC_TYPE_INFO(0, values, IS_MIXED, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_var_export, 0, 1, IS_STRING, 1) From 736c5dca100813da4a32dab78f524b8b2f9c92e4 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 19 Aug 2020 09:30:08 +0300 Subject: [PATCH 023/170] Fixed memory leak (ext/hash/tests/mhash_001.phpt failure) --- ext/hash/hash.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ext/hash/hash.c b/ext/hash/hash.c index 3f01ebcce6c4d..64be043362ea6 100644 --- a/ext/hash/hash.c +++ b/ext/hash/hash.c @@ -1202,7 +1202,7 @@ PHP_FUNCTION(mhash) if (algorithm >= 0 && algorithm < MHASH_NUM_ALGOS) { struct mhash_bc_entry algorithm_lookup = mhash_to_hash[algorithm]; if (algorithm_lookup.hash_name) { - algo = zend_string_init(algorithm_lookup.hash_name, strlen(algorithm_lookup.hash_name), 1); + algo = zend_string_init(algorithm_lookup.hash_name, strlen(algorithm_lookup.hash_name), 0); } } @@ -1211,6 +1211,10 @@ PHP_FUNCTION(mhash) } else { php_hash_do_hash(return_value, algo, data, data_len, 1, 0); } + + if (algo) { + zend_string_release(algo); + } } /* }}} */ From 9f6820f7f1bfde876cb91bfd473f6d8b679fc474 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sat, 15 Aug 2020 10:52:04 +0200 Subject: [PATCH 024/170] Fix #79968: Manipulation on unattached DOMChildNode should throw DOMException --- ext/dom/parentnode.c | 5 +++++ ext/dom/tests/bug79968.phpt | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 ext/dom/tests/bug79968.phpt diff --git a/ext/dom/parentnode.c b/ext/dom/parentnode.c index a7627cb84c1cb..f47416edff3dd 100644 --- a/ext/dom/parentnode.c +++ b/ext/dom/parentnode.c @@ -134,6 +134,11 @@ xmlNode* dom_zvals_to_fragment(php_libxml_ref_obj *document, xmlNode *contextNod dom_object *newNodeObj; int stricterror; + if (document == NULL) { + php_dom_throw_error(HIERARCHY_REQUEST_ERR, 1); + return NULL; + } + if (contextNode->type == XML_DOCUMENT_NODE || contextNode->type == XML_HTML_DOCUMENT_NODE) { documentNode = (xmlDoc *) contextNode; } else { diff --git a/ext/dom/tests/bug79968.phpt b/ext/dom/tests/bug79968.phpt new file mode 100644 index 0000000000000..45107351a4eb0 --- /dev/null +++ b/ext/dom/tests/bug79968.phpt @@ -0,0 +1,17 @@ +--TEST-- +dom: Bug #79968 - Crash when calling before without valid hierachy +--SKIPIF-- + +--FILE-- +before("string"); +} catch (DOMException $e) { + echo $e->getMessage(); +} +?> +--EXPECT-- +Hierarchy Request Error From a34fd4d590b36a9c42bb7e65c51202ef951afbdf Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Wed, 19 Aug 2020 12:20:11 +0200 Subject: [PATCH 025/170] Update NEWS w.r.t to bugfix #79968 --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 1b5edd772abef..6666861170dd9 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,9 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 8.0.0beta3 +- DOM: + . Fixed bug #79968 (DOMChildNode API crash on unattached nodes). (Benjamin) + 20 Aug 2020, PHP 8.0.0beta2 From c6c1682d7acb842b493e8bd6d54c9e32af470fb8 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 19 Aug 2020 14:51:39 +0300 Subject: [PATCH 026/170] Fixed tracing JIT crash in case SSA for op_array is not provided --- ext/opcache/jit/zend_jit_x86.dasc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index 25cd3143fd8a6..e36292c1bb27b 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -11856,7 +11856,7 @@ static int zend_jit_switch(dasm_State **Dst, const zend_op *opline, const zend_o zend_jit_addr op1_addr = OP1_ADDR(); const zend_op *default_opline = ZEND_OFFSET_TO_OPLINE(opline, opline->extended_value); const zend_op *target; - int default_b = ssa->cfg.map[default_opline - op_array->opcodes]; + int default_b = next_opline ? -1 : ssa->cfg.map[default_opline - op_array->opcodes]; int b; zval *val; int32_t exit_point; From bcadf9da8a4544d90583284417b251b63d505522 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 19 Aug 2020 14:53:01 +0300 Subject: [PATCH 027/170] Shrink live intervals of IS_VAR/IS_TMP_VAR --- ext/opcache/jit/zend_jit_trace.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index b331b895270e5..29684a4085fa9 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -2105,9 +2105,25 @@ static zend_lifetime_interval** zend_jit_trace_allocate_registers(zend_jit_trace && !zend_ssa_is_no_val_use(opline, ssa_op, ssa_op->op1_use)) { if (support_opline) { zend_jit_trace_use_var(idx, ssa_op->op1_use, ssa_op->op1_def, ssa_op->op1_use_chain, start, end, flags, ssa, ssa_opcodes, op_array, op_array_ssa); - if (opline->opcode == ZEND_CASE && opline->op1_type != IS_CV) { - /* The value may be used outside of the trace */ - flags[ssa_op->op1_use] |= ZREG_STORE; + if (opline->op1_type != IS_CV) { + if (opline->opcode == ZEND_CASE + || opline->opcode == ZEND_CASE_STRICT + || opline->opcode == ZEND_SWITCH_LONG + || opline->opcode == ZEND_MATCH + || opline->opcode == ZEND_FETCH_LIST_R + || opline->opcode == ZEND_COPY_TMP + || opline->opcode == ZEND_SWITCH_STRING + || opline->opcode == ZEND_FE_FETCH_R + || opline->opcode == ZEND_FE_FETCH_RW + || opline->opcode == ZEND_FETCH_LIST_W + || opline->opcode == ZEND_VERIFY_RETURN_TYPE + || opline->opcode == ZEND_BIND_LEXICAL + || opline->opcode == ZEND_ROPE_ADD) { + /* The value is kept alive and may be used outside of the trace */ + flags[ssa_op->op1_use] |= ZREG_STORE; + } else { + flags[ssa_op->op1_use] |= ZREG_LAST_USE; + } } } else { start[ssa_op->op1_use] = -1; @@ -2121,6 +2137,9 @@ static zend_lifetime_interval** zend_jit_trace_allocate_registers(zend_jit_trace && !zend_ssa_is_no_val_use(opline, ssa_op, ssa_op->op2_use)) { if (support_opline) { zend_jit_trace_use_var(idx, ssa_op->op2_use, ssa_op->op2_def, ssa_op->op2_use_chain, start, end, flags, ssa, ssa_opcodes, op_array, op_array_ssa); + if (opline->op2_type != IS_CV) { + flags[ssa_op->op2_use] |= ZREG_LAST_USE; + } } else { start[ssa_op->op2_use] = -1; end[ssa_op->op2_use] = -1; @@ -2215,6 +2234,9 @@ static zend_lifetime_interval** zend_jit_trace_allocate_registers(zend_jit_trace && !zend_ssa_is_no_val_use(opline, ssa_op, ssa_op->op1_use)) { if (support_opline) { zend_jit_trace_use_var(idx, ssa_op->op1_use, ssa_op->op1_def, ssa_op->op1_use_chain, start, end, flags, ssa, ssa_opcodes, op_array, op_array_ssa); + if (opline->op1_type != IS_CV) { + flags[ssa_op->op1_use] |= ZREG_LAST_USE; + } } else { start[ssa_op->op1_use] = -1; end[ssa_op->op1_use] = -1; From 22982eee339c4983c87cea5d59aaf48601ad7030 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 19 Aug 2020 17:51:23 +0300 Subject: [PATCH 028/170] Load zval type into register to eliminate double load --- ext/opcache/jit/zend_jit_x86.dasc | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index e36292c1bb27b..f14df1009abc4 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -10672,13 +10672,24 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, cons if (op1_info & MAY_BE_ARRAY_OF_REF) { | ZVAL_DEREF r0, MAY_BE_REF } - | IF_NOT_ZVAL_TYPE val_addr, type, &res_exit_addr - | // ZVAL_COPY - | ZVAL_COPY_VALUE res_addr, -1, val_addr, res_info, ZREG_R1, ZREG_R2 - if (!(res_info & AVOID_REFCOUNTING)) { - | TRY_ADDREF res_info, ch, r2 + if (type < IS_STRING) { + | IF_NOT_ZVAL_TYPE val_addr, type, &res_exit_addr + } else { + | GET_ZVAL_TYPE_INFO edx, val_addr + | IF_NOT_TYPE dl, type, &res_exit_addr } - if (!zend_jit_store_var_if_necessary(Dst, opline->result.var, res_addr, res_info)) { + | // ZVAL_COPY + | ZVAL_COPY_VALUE_V res_addr, -1, val_addr, res_info, ZREG_R0, ZREG_R1 + if (Z_MODE(res_addr) == IS_MEM_ZVAL) { + if (type < IS_STRING) { + | SET_ZVAL_TYPE_INFO res_addr, type + } else { + | SET_ZVAL_TYPE_INFO res_addr, edx + if (!(res_info & AVOID_REFCOUNTING)) { + | TRY_ADDREF res_info, dh, r1 + } + } + } else if (!zend_jit_store_var_if_necessary(Dst, opline->result.var, res_addr, res_info)) { return 0; } } else if (op1_info & MAY_BE_ARRAY_OF_REF) { @@ -11511,7 +11522,7 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen | IF_NOT_TYPE dl, type, &exit_addr } | // ZVAL_COPY - | ZVAL_COPY_VALUE_V res_addr, -1, val_addr, res_info, ZREG_R2, ZREG_R1 + | ZVAL_COPY_VALUE_V res_addr, -1, val_addr, res_info, ZREG_R0, ZREG_R1 if (type < IS_STRING) { | SET_ZVAL_TYPE_INFO res_addr, type } else { From 4e6fbb0a125219d833902cf4360263bf224d333f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 19 Aug 2020 23:27:53 +0200 Subject: [PATCH 029/170] Promote warnings to exceptions in ext/gd Closes GH-6023 --- ext/gd/gd.c | 30 ++++++++++++------------ ext/gd/tests/001-mb.phpt | 2 +- ext/gd/tests/001.phpt | 2 +- ext/gd/tests/bug37346-mb.phpt | 2 +- ext/gd/tests/bug37346.phpt | 2 +- ext/gd/tests/bug37360.phpt | 2 +- ext/gd/tests/bug38112.phpt | 2 +- ext/gd/tests/bug39780.phpt | 2 +- ext/gd/tests/bug39780_extern.phpt | 2 +- ext/gd/tests/bug71912-mb.phpt | 2 +- ext/gd/tests/bug71912.phpt | 2 +- ext/gd/tests/bug72339.phpt | 2 +- ext/gd/tests/bug73161.phpt | 2 +- ext/gd/tests/bug73868.phpt | 2 +- ext/gd/tests/bug73869.phpt | 4 ++-- ext/gd/tests/bug75111.phpt | 2 +- ext/gd/tests/bug75571.phpt | 2 +- ext/gd/tests/bug77195.phpt | 2 +- ext/gd/tests/bug77973.phpt | 2 +- ext/gd/tests/colorclosest.phpt | 22 ++++++++++------- ext/gd/tests/colormatch.phpt | 10 +++++--- ext/gd/tests/crafted_gd2.phpt | 2 +- ext/gd/tests/createfromstring.phpt | 9 ++++--- ext/gd/tests/createfromwbmp2.phpt | 2 +- ext/gd/tests/createfromwbmp2_extern.phpt | 2 +- ext/gd/tests/imagecolormatch_error2.phpt | 13 ++++++---- ext/gd/tests/imagecolormatch_error3.phpt | 13 ++++++---- ext/gd/tests/imagecolormatch_error4.phpt | 13 ++++++---- ext/gd/tests/libgd00086.phpt | 2 +- ext/gd/tests/libgd00086_extern.phpt | 2 +- ext/gd/tests/libgd00094-mb.phpt | 2 +- ext/gd/tests/libgd00094.phpt | 2 +- ext/gd/tests/libgd00101.phpt | 2 +- 33 files changed, 95 insertions(+), 69 deletions(-) diff --git a/ext/gd/gd.c b/ext/gd/gd.c index b015143ad8061..48dd6ecf4518f 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -861,20 +861,20 @@ PHP_FUNCTION(imagecolormatch) result = gdImageColorMatch(im1, im2); switch (result) { case -1: - php_error_docref(NULL, E_WARNING, "Image1 must be TrueColor" ); - RETURN_FALSE; + zend_argument_value_error(1, "must be TrueColor"); + RETURN_THROWS(); break; case -2: - php_error_docref(NULL, E_WARNING, "Image2 must be Palette" ); - RETURN_FALSE; + zend_argument_value_error(2, "must be Palette"); + RETURN_THROWS(); break; case -3: - php_error_docref(NULL, E_WARNING, "Image1 and Image2 must be the same size" ); - RETURN_FALSE; + zend_argument_value_error(2, "must be the same size as argument #1 ($im1)"); + RETURN_THROWS(); break; case -4: - php_error_docref(NULL, E_WARNING, "Image2 must have at least one color" ); - RETURN_FALSE; + zend_argument_value_error(2, "must have at least one color"); + RETURN_THROWS(); break; } @@ -1459,7 +1459,7 @@ gdImagePtr _php_image_create_from_string(zend_string *data, char *tn, gdImagePtr im = (*ioctx_func_p)(io_ctx); if (!im) { - php_error_docref(NULL, E_WARNING, "Passed data is not in '%s' format", tn); + php_error_docref(NULL, E_WARNING, "Passed data is not in \"%s\" format", tn); io_ctx->gd_free(io_ctx); return NULL; } @@ -1483,8 +1483,8 @@ PHP_FUNCTION(imagecreatefromstring) } if (ZSTR_LEN(data) < sizeof(sig)) { - php_error_docref(NULL, E_WARNING, "Empty string or invalid image"); - RETURN_FALSE; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } memcpy(sig, ZSTR_VAL(data), sizeof(sig)); @@ -1666,7 +1666,7 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, return; } - php_error_docref(NULL, E_WARNING, "'%s' is not a valid %s file", file, tn); + php_error_docref(NULL, E_WARNING, "\"%s\" is not a valid %s file", file, tn); out_err: php_stream_close(stream); RETURN_FALSE; @@ -1806,7 +1806,7 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char fp = VCWD_FOPEN(fn, "wb"); if (!fp) { - php_error_docref(NULL, E_WARNING, "Unable to open '%s' for writing", fn); + php_error_docref(NULL, E_WARNING, "Unable to open \"%s\" for writing", fn); RETURN_FALSE; } @@ -2297,8 +2297,8 @@ PHP_FUNCTION(imagecolorsforindex) add_assoc_long(return_value,"blue", gdImageBlue(im,col)); add_assoc_long(return_value,"alpha", gdImageAlpha(im,col)); } else { - php_error_docref(NULL, E_WARNING, "Color index %d out of range", col); - RETURN_FALSE; + zend_argument_value_error(2, "is out of range"); + RETURN_THROWS(); } } /* }}} */ diff --git a/ext/gd/tests/001-mb.phpt b/ext/gd/tests/001-mb.phpt index c34c232d0ae70..38bf14a3cb808 100644 --- a/ext/gd/tests/001-mb.phpt +++ b/ext/gd/tests/001-mb.phpt @@ -20,6 +20,6 @@ echo "Done\n"; Warning: imagecreatefrompng(%s001私はガラスを食べられます.test): Failed to open stream: No such file or directory in %s on line %d bool(false) -Warning: imagecreatefrompng(): '%s001私はガラスを食べられます.test' is not a valid PNG file in %s on line %d +Warning: imagecreatefrompng(): "%s001私はガラスを食べられます.test" is not a valid PNG file in %s on line %d bool(false) Done diff --git a/ext/gd/tests/001.phpt b/ext/gd/tests/001.phpt index 75dbcc0d471a3..d741e1f50618d 100644 --- a/ext/gd/tests/001.phpt +++ b/ext/gd/tests/001.phpt @@ -20,6 +20,6 @@ echo "Done\n"; Warning: imagecreatefrompng(%s001.test): Failed to open stream: No such file or directory in %s on line %d bool(false) -Warning: imagecreatefrompng(): '%s001.test' is not a valid PNG file in %s on line %d +Warning: imagecreatefrompng(): "%s001.test" is not a valid PNG file in %s on line %d bool(false) Done diff --git a/ext/gd/tests/bug37346-mb.phpt b/ext/gd/tests/bug37346-mb.phpt index 4ec5734fc7939..e1a9b8b4706c9 100644 --- a/ext/gd/tests/bug37346-mb.phpt +++ b/ext/gd/tests/bug37346-mb.phpt @@ -9,4 +9,4 @@ Bug #37346 (gdimagecreatefromgif, bad colormap) $im = imagecreatefromgif(__DIR__ . '/bug37346私はガラスを食べられます.gif'); ?> --EXPECTF-- -Warning: imagecreatefromgif(): '%sbug37346私はガラスを食べられます.gif' is not a valid GIF file in %sbug37346-mb.php on line %d +Warning: imagecreatefromgif(): "%sbug37346私はガラスを食べられます.gif" is not a valid GIF file in %sbug37346-mb.php on line %d diff --git a/ext/gd/tests/bug37346.phpt b/ext/gd/tests/bug37346.phpt index 57701a7ad7b75..40b3341685daa 100644 --- a/ext/gd/tests/bug37346.phpt +++ b/ext/gd/tests/bug37346.phpt @@ -9,4 +9,4 @@ Bug #37346 (gdimagecreatefromgif, bad colormap) $im = imagecreatefromgif(__DIR__ . '/bug37346.gif'); ?> --EXPECTF-- -Warning: imagecreatefromgif(): '%sbug37346.gif' is not a valid GIF file in %sbug37346.php on line %d +Warning: imagecreatefromgif(): "%sbug37346.gif" is not a valid GIF file in %sbug37346.php on line %d diff --git a/ext/gd/tests/bug37360.phpt b/ext/gd/tests/bug37360.phpt index c2b8b9592dd75..74a58223a96c0 100644 --- a/ext/gd/tests/bug37360.phpt +++ b/ext/gd/tests/bug37360.phpt @@ -10,5 +10,5 @@ $im = imagecreatefromgif(__DIR__ . '/bug37360.gif'); var_dump($im); ?> --EXPECTF-- -Warning: imagecreatefromgif(): '%s' is not a valid GIF file in %s on line %d +Warning: imagecreatefromgif(): "%s" is not a valid GIF file in %s on line %d bool(false) diff --git a/ext/gd/tests/bug38112.phpt b/ext/gd/tests/bug38112.phpt index 8a6911ad9da94..4eb553b614384 100644 --- a/ext/gd/tests/bug38112.phpt +++ b/ext/gd/tests/bug38112.phpt @@ -11,4 +11,4 @@ Bug #38112 (GIF Invalid Code size ). $im = imagecreatefromgif(__DIR__ . '/bug38112.gif'); ?> --EXPECTF-- -Warning: imagecreatefromgif(): '%sbug38112.gif' is not a valid GIF file in %sbug38112.php on line %d +Warning: imagecreatefromgif(): "%sbug38112.gif" is not a valid GIF file in %sbug38112.php on line %d diff --git a/ext/gd/tests/bug39780.phpt b/ext/gd/tests/bug39780.phpt index 2a7af3e0f4982..6468f28b7342d 100644 --- a/ext/gd/tests/bug39780.phpt +++ b/ext/gd/tests/bug39780.phpt @@ -16,5 +16,5 @@ Warning: imagecreatefrompng(): gd-png: fatal libpng error: Read Error: truncate Warning: imagecreatefrompng(): gd-png error: setjmp returns error condition in %s on line %d -Warning: imagecreatefrompng(): '%s' is not a valid PNG file in %s on line %d +Warning: imagecreatefrompng(): "%s" is not a valid PNG file in %s on line %d bool(false) diff --git a/ext/gd/tests/bug39780_extern.phpt b/ext/gd/tests/bug39780_extern.phpt index 0656e52fc7df7..e090477314831 100644 --- a/ext/gd/tests/bug39780_extern.phpt +++ b/ext/gd/tests/bug39780_extern.phpt @@ -14,5 +14,5 @@ var_dump($im); --EXPECTF-- gd-png: fatal libpng error: Read Error: truncated data gd-png error: setjmp returns error condition 2 -Warning: imagecreatefrompng(): '%sbug39780.png' is not a valid PNG file in /%s on line %d +Warning: imagecreatefrompng(): v%sbug39780.png" is not a valid PNG file in /%s on line %d bool(false) diff --git a/ext/gd/tests/bug71912-mb.phpt b/ext/gd/tests/bug71912-mb.phpt index d0bf3a89c235a..32a6ee00bc71b 100644 --- a/ext/gd/tests/bug71912-mb.phpt +++ b/ext/gd/tests/bug71912-mb.phpt @@ -11,5 +11,5 @@ imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . "invalid_neg_size私はガラ ?> OK --EXPECTF-- -Warning: imagecreatefromgd2(): '%s%einvalid_neg_size私はガラスを食べられます.gd2' is not a valid GD2 file in %s%ebug71912-mb.php on line %d +Warning: imagecreatefromgd2(): "%s%einvalid_neg_size私はガラスを食べられます.gd2" is not a valid GD2 file in %s%ebug71912-mb.php on line %d OK diff --git a/ext/gd/tests/bug71912.phpt b/ext/gd/tests/bug71912.phpt index ed4665f439a81..30bde45d214c5 100644 --- a/ext/gd/tests/bug71912.phpt +++ b/ext/gd/tests/bug71912.phpt @@ -14,5 +14,5 @@ imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . "invalid_neg_size.gd2"); ?> OK --EXPECTF-- -Warning: imagecreatefromgd2(): '%s%einvalid_neg_size.gd2' is not a valid GD2 file in %s%ebug71912.php on line %d +Warning: imagecreatefromgd2(): "%s%einvalid_neg_size.gd2" is not a valid GD2 file in %s%ebug71912.php on line %d OK diff --git a/ext/gd/tests/bug72339.phpt b/ext/gd/tests/bug72339.phpt index bd8054cced24b..4baaa92ab21e1 100644 --- a/ext/gd/tests/bug72339.phpt +++ b/ext/gd/tests/bug72339.phpt @@ -35,4 +35,4 @@ unlink($fname); Warning: imagecreatefromgd2(): Product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully in %sbug72339.php on line %d -Warning: imagecreatefromgd2(): '%sbug72339.gd' is not a valid GD2 file in %sbug72339.php on line %d +Warning: imagecreatefromgd2(): "%sbug72339.gd" is not a valid GD2 file in %sbug72339.php on line %d diff --git a/ext/gd/tests/bug73161.phpt b/ext/gd/tests/bug73161.phpt index bc386dc9c22eb..90fd26274556f 100644 --- a/ext/gd/tests/bug73161.phpt +++ b/ext/gd/tests/bug73161.phpt @@ -12,5 +12,5 @@ $im = imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . 'bug73161.gd2'); var_dump($im); ?> --EXPECTF-- -Warning: imagecreatefromgd2(): '%s' is not a valid GD2 file in %s on line %d +Warning: imagecreatefromgd2(): "%s" is not a valid GD2 file in %s on line %d bool(false) diff --git a/ext/gd/tests/bug73868.phpt b/ext/gd/tests/bug73868.phpt index fd9537c4a017d..ed59ac7be3068 100644 --- a/ext/gd/tests/bug73868.phpt +++ b/ext/gd/tests/bug73868.phpt @@ -12,5 +12,5 @@ var_dump(imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . 'bug73868.gd2')); Warning: imagecreatefromgd2(): gd2: EOF while reading in %s on line %d -Warning: imagecreatefromgd2(): '%s' is not a valid GD2 file in %s on line %d +Warning: imagecreatefromgd2(): "%s" is not a valid GD2 file in %s on line %d bool(false) diff --git a/ext/gd/tests/bug73869.phpt b/ext/gd/tests/bug73869.phpt index 69c7e1b543902..6adb8c09a4fb1 100644 --- a/ext/gd/tests/bug73869.phpt +++ b/ext/gd/tests/bug73869.phpt @@ -10,8 +10,8 @@ var_dump(imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . 'bug73869a.gd2')); var_dump(imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . 'bug73869b.gd2')); ?> --EXPECTF-- -Warning: imagecreatefromgd2(): '%s' is not a valid GD2 file in %s on line %d +Warning: imagecreatefromgd2(): "%s" is not a valid GD2 file in %s on line %d bool(false) -Warning: imagecreatefromgd2(): '%s' is not a valid GD2 file in %s on line %d +Warning: imagecreatefromgd2(): "%s" is not a valid GD2 file in %s on line %d bool(false) diff --git a/ext/gd/tests/bug75111.phpt b/ext/gd/tests/bug75111.phpt index 4ec22c4a3a17f..e2e13f3b73640 100644 --- a/ext/gd/tests/bug75111.phpt +++ b/ext/gd/tests/bug75111.phpt @@ -17,7 +17,7 @@ $str .= hex2bin("01001800000000000000000000000000000000000000000000000000"); var_dump(imagecreatefromstring($str)); ?> --EXPECTF-- -Warning: imagecreatefromstring(): Passed data is not in 'BMP' format in %s on line %d +Warning: imagecreatefromstring(): Passed data is not in "BMP" format in %s on line %d Warning: imagecreatefromstring(): Couldn't create GD Image Stream out of Data in %s on line %d bool(false) diff --git a/ext/gd/tests/bug75571.phpt b/ext/gd/tests/bug75571.phpt index 10b459d421fea..898f1ecbad5c3 100644 --- a/ext/gd/tests/bug75571.phpt +++ b/ext/gd/tests/bug75571.phpt @@ -9,5 +9,5 @@ if (!extension_loaded('gd')) die('skip gd extension not available'); var_dump(imagecreatefromgif(__DIR__ . '/bug75571.gif')); ?> --EXPECTF-- -Warning: imagecreatefromgif(): '%s' is not a valid GIF file in %s on line %d +Warning: imagecreatefromgif(): "%s" is not a valid GIF file in %s on line %d bool(false) diff --git a/ext/gd/tests/bug77195.phpt b/ext/gd/tests/bug77195.phpt index f90035b7416be..fc788a6667574 100644 --- a/ext/gd/tests/bug77195.phpt +++ b/ext/gd/tests/bug77195.phpt @@ -14,4 +14,4 @@ imagecreatefromjpeg($filename); --EXPECTF-- Warning: imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error: JPEG datastream contains no image in %s on line %d -Warning: imagecreatefromjpeg(): '%s' is not a valid JPEG file in %s on line %d +Warning: imagecreatefromjpeg(): "%s" is not a valid JPEG file in %s on line %d diff --git a/ext/gd/tests/bug77973.phpt b/ext/gd/tests/bug77973.phpt index c9400987e07a6..434cc4449e1a4 100644 --- a/ext/gd/tests/bug77973.phpt +++ b/ext/gd/tests/bug77973.phpt @@ -16,7 +16,7 @@ var_dump($im); --EXPECTF-- Warning: imagecreatefromxbm(): Invalid XBM in %s on line %d -Warning: imagecreatefromxbm(): '%s' is not a valid XBM file in %s on line %d +Warning: imagecreatefromxbm(): "%s" is not a valid XBM file in %s on line %d bool(false) --CLEAN-- getMessage() . "\n"; +} imagedestroy($im); $im = imagecreate(5,5); @@ -48,7 +52,11 @@ imagedestroy($im); $im = imagecreate(5,5); $c = imagecolorclosestalpha($im, 255,0,255,100); -print_r(imagecolorsforindex($im, $c)); +try { + imagecolorsforindex($im, $c); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} imagedestroy($im); $im = imagecreate(5,5); @@ -62,7 +70,6 @@ for ($i=0; $i<255; $i++) imagecolorresolvealpha($im, $i,0,0,1); $c = imagecolorclosestalpha($im, 255,0,0,1); print_r(imagecolorsforindex($im, $c)); - $im = imagecreate(5,5); for ($i=0; $i<256; $i++) { if ($i == 246) { @@ -74,12 +81,10 @@ for ($i=0; $i<256; $i++) { $c = imagecolorclosestalpha($im, 255,10,10,1); print_r(imagecolorsforindex($im, $c)); - ?> ---EXPECTF-- +--EXPECT-- FF00FF - -Warning: imagecolorsforindex(): Color index -1 out of range in %s on line %d +imagecolorsforindex(): Argument #2 ($index) is out of range Array ( [red] => 255 @@ -102,8 +107,7 @@ Array [alpha] => 0 ) 64FF00FF - -Warning: imagecolorsforindex(): Color index -1 out of range in %s on line %d +imagecolorsforindex(): Argument #2 ($index) is out of range Array ( [red] => 255 diff --git a/ext/gd/tests/colormatch.phpt b/ext/gd/tests/colormatch.phpt index 283a200571919..5641bc01017fe 100644 --- a/ext/gd/tests/colormatch.phpt +++ b/ext/gd/tests/colormatch.phpt @@ -10,12 +10,16 @@ imagecolormatch $im = imagecreatetruecolor(5,5); $im2 = imagecreate(5,5); -imagecolormatch($im, $im2); +try { + imagecolormatch($im, $im2); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} echo "ok\n"; imagedestroy($im); ?> ---EXPECTF-- -Warning: imagecolormatch(): Image2 must have at least one color in %s on line %d +--EXPECT-- +imagecolormatch(): Argument #2 ($im2) must have at least one color ok diff --git a/ext/gd/tests/crafted_gd2.phpt b/ext/gd/tests/crafted_gd2.phpt index 60687dfa3c38a..a5b0dfe339bba 100644 --- a/ext/gd/tests/crafted_gd2.phpt +++ b/ext/gd/tests/crafted_gd2.phpt @@ -11,4 +11,4 @@ Test max colors for a gd image. imagecreatefromgd(__DIR__ . '/crafted.gd2'); ?> --EXPECTF-- -Warning: imagecreatefromgd(): '%scrafted.gd2' is not a valid GD file in %s on line %d +Warning: imagecreatefromgd(): "%scrafted.gd2" is not a valid GD file in %s on line %d diff --git a/ext/gd/tests/createfromstring.phpt b/ext/gd/tests/createfromstring.phpt index 5d14708a2ee32..d4d63149f13f1 100644 --- a/ext/gd/tests/createfromstring.phpt +++ b/ext/gd/tests/createfromstring.phpt @@ -51,14 +51,17 @@ unlink($dir . '/p.png'); //empty string -$im = imagecreatefromstring(''); +try { + imagecreatefromstring(''); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} //random string > 12 $im = imagecreatefromstring(' asdf jklp foo'); ?> --EXPECTF-- createfromstring truecolor png: ok createfromstring palette png: ok - -Warning: imagecreatefromstring(): Empty string or invalid image in %screatefromstring.php on line %d +imagecreatefromstring(): Argument #1 ($image) cannot be empty Warning: imagecreatefromstring(): Data is not in a recognized format in %screatefromstring.php on line %d diff --git a/ext/gd/tests/createfromwbmp2.phpt b/ext/gd/tests/createfromwbmp2.phpt index f75d02613d328..c6a1a22427d6a 100644 --- a/ext/gd/tests/createfromwbmp2.phpt +++ b/ext/gd/tests/createfromwbmp2.phpt @@ -45,4 +45,4 @@ unlink($filename); Warning: imagecreatefromwbmp(): Product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully in %s on line %d -Warning: imagecreatefromwbmp(): '%s' is not a valid WBMP file in %s on line %d +Warning: imagecreatefromwbmp(): "%s" is not a valid WBMP file in %s on line %d diff --git a/ext/gd/tests/createfromwbmp2_extern.phpt b/ext/gd/tests/createfromwbmp2_extern.phpt index ad7a130c18df4..ab15ec024e7e7 100644 --- a/ext/gd/tests/createfromwbmp2_extern.phpt +++ b/ext/gd/tests/createfromwbmp2_extern.phpt @@ -44,4 +44,4 @@ unlink($filename); --EXPECTF-- gd warning: Product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully -Warning: imagecreatefromwbmp(): '%s_tmp.wbmp' is not a valid WBMP file in %s on line %d +Warning: imagecreatefromwbmp(): "%s_tmp.wbmp" is not a valid WBMP file in %s on line %d diff --git a/ext/gd/tests/imagecolormatch_error2.phpt b/ext/gd/tests/imagecolormatch_error2.phpt index 2240f987df5f2..f356b716c6147 100644 --- a/ext/gd/tests/imagecolormatch_error2.phpt +++ b/ext/gd/tests/imagecolormatch_error2.phpt @@ -13,8 +13,13 @@ $ima = imagecreate(110, 20); $background_color = imagecolorallocate($ima, 0, 0, 0); $imb = imagecreate(110, 20); $background_color = imagecolorallocate($imb, 0, 0, 100); -var_dump(imagecolormatch($ima, $imb)); + +try { + imagecolormatch($ima, $imb); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + ?> ---EXPECTF-- -Warning: imagecolormatch(): Image1 must be TrueColor in %s on line %d -bool(false) +--EXPECT-- +imagecolormatch(): Argument #1 ($im1) must be TrueColor diff --git a/ext/gd/tests/imagecolormatch_error3.phpt b/ext/gd/tests/imagecolormatch_error3.phpt index 245ebca646d03..a3f556a3e12ba 100644 --- a/ext/gd/tests/imagecolormatch_error3.phpt +++ b/ext/gd/tests/imagecolormatch_error3.phpt @@ -13,8 +13,13 @@ $ima = imagecreatetruecolor(110, 20); $background_color = imagecolorallocate($ima, 0, 0, 0); $imb = imagecreatetruecolor(110, 20); $background_color = imagecolorallocate($imb, 0, 0, 100); -var_dump(imagecolormatch($ima, $imb)); + +try { + imagecolormatch($ima, $imb); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + ?> ---EXPECTF-- -Warning: imagecolormatch(): Image2 must be Palette in %s on line %d -bool(false) +--EXPECT-- +imagecolormatch(): Argument #2 ($im2) must be Palette diff --git a/ext/gd/tests/imagecolormatch_error4.phpt b/ext/gd/tests/imagecolormatch_error4.phpt index 4579192571a24..f1392c9149e90 100644 --- a/ext/gd/tests/imagecolormatch_error4.phpt +++ b/ext/gd/tests/imagecolormatch_error4.phpt @@ -13,8 +13,13 @@ $ima = imagecreatetruecolor(110, 20); $background_color = imagecolorallocate($ima, 0, 0, 0); $imb = imagecreate(100, 20); $background_color = imagecolorallocate($imb, 0, 0, 100); -var_dump(imagecolormatch($ima, $imb)); + +try { + imagecolormatch($ima, $imb); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + ?> ---EXPECTF-- -Warning: imagecolormatch(): Image1 and Image2 must be the same size in %s on line %d -bool(false) +--EXPECT-- +imagecolormatch(): Argument #2 ($im2) must be the same size as argument #1 ($im1) diff --git a/ext/gd/tests/libgd00086.phpt b/ext/gd/tests/libgd00086.phpt index c7954a0a002da..959828f0685ac 100644 --- a/ext/gd/tests/libgd00086.phpt +++ b/ext/gd/tests/libgd00086.phpt @@ -16,5 +16,5 @@ Warning: imagecreatefrompng(): gd-png: fatal libpng error: Read Error: truncate Warning: imagecreatefrompng(): gd-png error: setjmp returns error condition in %s on line %d -Warning: imagecreatefrompng(): '%s' is not a valid PNG file in %s on line %d +Warning: imagecreatefrompng(): "%s" is not a valid PNG file in %s on line %d bool(false) diff --git a/ext/gd/tests/libgd00086_extern.phpt b/ext/gd/tests/libgd00086_extern.phpt index 36b79b4835fb4..78bafa761e88b 100644 --- a/ext/gd/tests/libgd00086_extern.phpt +++ b/ext/gd/tests/libgd00086_extern.phpt @@ -15,5 +15,5 @@ var_dump($im); gd-png: fatal libpng error: Read Error: truncated data gd-png error: setjmp returns error condition 1 -Warning: imagecreatefrompng(): '%slibgd00086.png' is not a valid PNG file in %s on line %d +Warning: imagecreatefrompng(): "%slibgd00086.png" is not a valid PNG file in %s on line %d bool(false) diff --git a/ext/gd/tests/libgd00094-mb.phpt b/ext/gd/tests/libgd00094-mb.phpt index 76b6bcd5663cf..7ce24a43b22c2 100644 --- a/ext/gd/tests/libgd00094-mb.phpt +++ b/ext/gd/tests/libgd00094-mb.phpt @@ -11,5 +11,5 @@ $im = imagecreatefromxbm(__DIR__ . '/libgd00094私はガラスを食べられま var_dump($im); ?> --EXPECTF-- -Warning: imagecreatefromxbm(): '%slibgd00094私はガラスを食べられます.xbm' is not a valid XBM file in %slibgd00094-mb.php on line %d +Warning: imagecreatefromxbm(): "%slibgd00094私はガラスを食べられます.xbm" is not a valid XBM file in %slibgd00094-mb.php on line %d bool(false) diff --git a/ext/gd/tests/libgd00094.phpt b/ext/gd/tests/libgd00094.phpt index 17c4df70d56da..8af0b342d97c0 100644 --- a/ext/gd/tests/libgd00094.phpt +++ b/ext/gd/tests/libgd00094.phpt @@ -11,5 +11,5 @@ $im = imagecreatefromxbm(__DIR__ . '/libgd00094.xbm'); var_dump($im); ?> --EXPECTF-- -Warning: imagecreatefromxbm(): '%slibgd00094.xbm' is not a valid XBM file in %slibgd00094.php on line %d +Warning: imagecreatefromxbm(): "%slibgd00094.xbm" is not a valid XBM file in %slibgd00094.php on line %d bool(false) diff --git a/ext/gd/tests/libgd00101.phpt b/ext/gd/tests/libgd00101.phpt index 7e1e4b587219c..d2e278ced9888 100644 --- a/ext/gd/tests/libgd00101.phpt +++ b/ext/gd/tests/libgd00101.phpt @@ -14,5 +14,5 @@ var_dump($im); Warning: imagecreatefromgd(): Product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully in %slibgd00101.php on line %d -Warning: imagecreatefromgd(): '%slibgd00101.gd' is not a valid GD file in %slibgd00101.php on line %d +Warning: imagecreatefromgd(): "%slibgd00101.gd" is not a valid GD file in %slibgd00101.php on line %d bool(false) From aed1f785159e7c9e81da8f2e2e06df9a6ee0d809 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 20 Aug 2020 15:02:12 +0300 Subject: [PATCH 030/170] micro-optimization --- Zend/zend_vm_def.h | 36 ++-- Zend/zend_vm_execute.h | 423 +++++++++++++++++++++++++---------------- 2 files changed, 286 insertions(+), 173 deletions(-) diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index f06713d5ac8ab..55a1e9ba8671c 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -3428,8 +3428,17 @@ ZEND_VM_HOT_OBJ_HANDLER(112, ZEND_INIT_METHOD_CALL, CONST|TMPVAR|UNUSED|THIS|CV, do { if (OP1_TYPE == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { if ((OP1_TYPE & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { - object = Z_REFVAL_P(object); + zend_reference *ref = Z_REF_P(object); + + object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + if (OP1_TYPE & IS_VAR) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { + efree_size(ref, sizeof(zend_reference)); + } else { + Z_ADDREF_P(object); + } + } break; } } @@ -3473,7 +3482,9 @@ ZEND_VM_HOT_OBJ_HANDLER(112, ZEND_INIT_METHOD_CALL, CONST|TMPVAR|UNUSED|THIS|CV, zend_undefined_method(obj->ce, Z_STR_P(function_name)); } FREE_OP2(); - FREE_OP1(); + if ((OP1_TYPE & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } HANDLE_EXCEPTION(); } if (OP2_TYPE == IS_CONST && @@ -3482,8 +3493,10 @@ ZEND_VM_HOT_OBJ_HANDLER(112, ZEND_INIT_METHOD_CALL, CONST|TMPVAR|UNUSED|THIS|CV, CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc); } if ((OP1_TYPE & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) { - /* Reset "object" to trigger reference counting */ - object = NULL; + GC_ADDREF(obj); /* For $this pointer */ + if (GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } } if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) { init_func_run_time_cache(&fbc->op_array); @@ -3496,10 +3509,11 @@ ZEND_VM_HOT_OBJ_HANDLER(112, ZEND_INIT_METHOD_CALL, CONST|TMPVAR|UNUSED|THIS|CV, call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS; if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) { - FREE_OP1(); - - if ((OP1_TYPE & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(EG(exception))) { - HANDLE_EXCEPTION(); + if ((OP1_TYPE & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(obj) == 0) { + zend_objects_store_del(obj); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } } /* call static method */ obj = (zend_object*)called_scope; @@ -3507,12 +3521,6 @@ ZEND_VM_HOT_OBJ_HANDLER(112, ZEND_INIT_METHOD_CALL, CONST|TMPVAR|UNUSED|THIS|CV, } else if (OP1_TYPE & (IS_VAR|IS_TMP_VAR|IS_CV)) { if (OP1_TYPE == IS_CV) { GC_ADDREF(obj); /* For $this pointer */ - } else { - zval *free_op1 = EX_VAR(opline->op1.var); - if (free_op1 != object) { - GC_ADDREF(obj); /* For $this pointer */ - zval_ptr_dtor_nogc(free_op1); - } } /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS | ZEND_CALL_RELEASE_THIS; diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index f103e91d331a5..70506a6e1417b 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -5743,8 +5743,17 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ do { if (IS_CONST == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { if ((IS_CONST & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { - object = Z_REFVAL_P(object); + zend_reference *ref = Z_REF_P(object); + + object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + if (IS_CONST & IS_VAR) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { + efree_size(ref, sizeof(zend_reference)); + } else { + Z_ADDREF_P(object); + } + } break; } } @@ -5788,7 +5797,9 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ zend_undefined_method(obj->ce, Z_STR_P(function_name)); } - + if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } HANDLE_EXCEPTION(); } if (IS_CONST == IS_CONST && @@ -5797,8 +5808,10 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc); } if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) { - /* Reset "object" to trigger reference counting */ - object = NULL; + GC_ADDREF(obj); /* For $this pointer */ + if (GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } } if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) { init_func_run_time_cache(&fbc->op_array); @@ -5811,9 +5824,11 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS; if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) { - - if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(EG(exception))) { - HANDLE_EXCEPTION(); + if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(obj) == 0) { + zend_objects_store_del(obj); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } } /* call static method */ obj = (zend_object*)called_scope; @@ -5821,12 +5836,6 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ } else if (IS_CONST & (IS_VAR|IS_TMP_VAR|IS_CV)) { if (IS_CONST == IS_CV) { GC_ADDREF(obj); /* For $this pointer */ - } else { - zval *free_op1 = EX_VAR(opline->op1.var); - if (free_op1 != object) { - GC_ADDREF(obj); /* For $this pointer */ - zval_ptr_dtor_nogc(free_op1); - } } /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS | ZEND_CALL_RELEASE_THIS; @@ -8018,8 +8027,17 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ do { if (IS_CONST == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { if ((IS_CONST & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { - object = Z_REFVAL_P(object); + zend_reference *ref = Z_REF_P(object); + + object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + if (IS_CONST & IS_VAR) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { + efree_size(ref, sizeof(zend_reference)); + } else { + Z_ADDREF_P(object); + } + } break; } } @@ -8063,7 +8081,9 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ zend_undefined_method(obj->ce, Z_STR_P(function_name)); } zval_ptr_dtor_nogc(EX_VAR(opline->op2.var)); - + if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } HANDLE_EXCEPTION(); } if ((IS_TMP_VAR|IS_VAR) == IS_CONST && @@ -8072,8 +8092,10 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc); } if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) { - /* Reset "object" to trigger reference counting */ - object = NULL; + GC_ADDREF(obj); /* For $this pointer */ + if (GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } } if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) { init_func_run_time_cache(&fbc->op_array); @@ -8086,9 +8108,11 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS; if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) { - - if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(EG(exception))) { - HANDLE_EXCEPTION(); + if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(obj) == 0) { + zend_objects_store_del(obj); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } } /* call static method */ obj = (zend_object*)called_scope; @@ -8096,12 +8120,6 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ } else if (IS_CONST & (IS_VAR|IS_TMP_VAR|IS_CV)) { if (IS_CONST == IS_CV) { GC_ADDREF(obj); /* For $this pointer */ - } else { - zval *free_op1 = EX_VAR(opline->op1.var); - if (free_op1 != object) { - GC_ADDREF(obj); /* For $this pointer */ - zval_ptr_dtor_nogc(free_op1); - } } /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS | ZEND_CALL_RELEASE_THIS; @@ -10386,8 +10404,17 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ do { if (IS_CONST == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { if ((IS_CONST & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { - object = Z_REFVAL_P(object); + zend_reference *ref = Z_REF_P(object); + + object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + if (IS_CONST & IS_VAR) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { + efree_size(ref, sizeof(zend_reference)); + } else { + Z_ADDREF_P(object); + } + } break; } } @@ -10431,7 +10458,9 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ zend_undefined_method(obj->ce, Z_STR_P(function_name)); } - + if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } HANDLE_EXCEPTION(); } if (IS_CV == IS_CONST && @@ -10440,8 +10469,10 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc); } if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) { - /* Reset "object" to trigger reference counting */ - object = NULL; + GC_ADDREF(obj); /* For $this pointer */ + if (GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } } if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) { init_func_run_time_cache(&fbc->op_array); @@ -10454,9 +10485,11 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS; if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) { - - if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(EG(exception))) { - HANDLE_EXCEPTION(); + if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(obj) == 0) { + zend_objects_store_del(obj); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } } /* call static method */ obj = (zend_object*)called_scope; @@ -10464,12 +10497,6 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ } else if (IS_CONST & (IS_VAR|IS_TMP_VAR|IS_CV)) { if (IS_CONST == IS_CV) { GC_ADDREF(obj); /* For $this pointer */ - } else { - zval *free_op1 = EX_VAR(opline->op1.var); - if (free_op1 != object) { - GC_ADDREF(obj); /* For $this pointer */ - zval_ptr_dtor_nogc(free_op1); - } } /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS | ZEND_CALL_RELEASE_THIS; @@ -14746,8 +14773,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C do { if ((IS_TMP_VAR|IS_VAR) == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { - object = Z_REFVAL_P(object); + zend_reference *ref = Z_REF_P(object); + + object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + if ((IS_TMP_VAR|IS_VAR) & IS_VAR) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { + efree_size(ref, sizeof(zend_reference)); + } else { + Z_ADDREF_P(object); + } + } break; } } @@ -14791,7 +14827,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C zend_undefined_method(obj->ce, Z_STR_P(function_name)); } - zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); + if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } HANDLE_EXCEPTION(); } if (IS_CONST == IS_CONST && @@ -14800,8 +14838,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc); } if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) { - /* Reset "object" to trigger reference counting */ - object = NULL; + GC_ADDREF(obj); /* For $this pointer */ + if (GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } } if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) { init_func_run_time_cache(&fbc->op_array); @@ -14814,10 +14854,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS; if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) { - zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); - - if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(EG(exception))) { - HANDLE_EXCEPTION(); + if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(obj) == 0) { + zend_objects_store_del(obj); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } } /* call static method */ obj = (zend_object*)called_scope; @@ -14825,12 +14866,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C } else if ((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR|IS_CV)) { if ((IS_TMP_VAR|IS_VAR) == IS_CV) { GC_ADDREF(obj); /* For $this pointer */ - } else { - zval *free_op1 = EX_VAR(opline->op1.var); - if (free_op1 != object) { - GC_ADDREF(obj); /* For $this pointer */ - zval_ptr_dtor_nogc(free_op1); - } } /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS | ZEND_CALL_RELEASE_THIS; @@ -16153,8 +16188,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_T do { if ((IS_TMP_VAR|IS_VAR) == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { - object = Z_REFVAL_P(object); + zend_reference *ref = Z_REF_P(object); + + object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + if ((IS_TMP_VAR|IS_VAR) & IS_VAR) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { + efree_size(ref, sizeof(zend_reference)); + } else { + Z_ADDREF_P(object); + } + } break; } } @@ -16198,7 +16242,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_T zend_undefined_method(obj->ce, Z_STR_P(function_name)); } zval_ptr_dtor_nogc(EX_VAR(opline->op2.var)); - zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); + if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } HANDLE_EXCEPTION(); } if ((IS_TMP_VAR|IS_VAR) == IS_CONST && @@ -16207,8 +16253,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_T CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc); } if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) { - /* Reset "object" to trigger reference counting */ - object = NULL; + GC_ADDREF(obj); /* For $this pointer */ + if (GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } } if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) { init_func_run_time_cache(&fbc->op_array); @@ -16221,10 +16269,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_T call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS; if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) { - zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); - - if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(EG(exception))) { - HANDLE_EXCEPTION(); + if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(obj) == 0) { + zend_objects_store_del(obj); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } } /* call static method */ obj = (zend_object*)called_scope; @@ -16232,12 +16281,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_T } else if ((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR|IS_CV)) { if ((IS_TMP_VAR|IS_VAR) == IS_CV) { GC_ADDREF(obj); /* For $this pointer */ - } else { - zval *free_op1 = EX_VAR(opline->op1.var); - if (free_op1 != object) { - GC_ADDREF(obj); /* For $this pointer */ - zval_ptr_dtor_nogc(free_op1); - } } /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS | ZEND_CALL_RELEASE_THIS; @@ -17453,8 +17496,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C do { if ((IS_TMP_VAR|IS_VAR) == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { - object = Z_REFVAL_P(object); + zend_reference *ref = Z_REF_P(object); + + object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + if ((IS_TMP_VAR|IS_VAR) & IS_VAR) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { + efree_size(ref, sizeof(zend_reference)); + } else { + Z_ADDREF_P(object); + } + } break; } } @@ -17498,7 +17550,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C zend_undefined_method(obj->ce, Z_STR_P(function_name)); } - zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); + if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } HANDLE_EXCEPTION(); } if (IS_CV == IS_CONST && @@ -17507,8 +17561,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc); } if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) { - /* Reset "object" to trigger reference counting */ - object = NULL; + GC_ADDREF(obj); /* For $this pointer */ + if (GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } } if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) { init_func_run_time_cache(&fbc->op_array); @@ -17521,10 +17577,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS; if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) { - zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); - - if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(EG(exception))) { - HANDLE_EXCEPTION(); + if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(obj) == 0) { + zend_objects_store_del(obj); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } } /* call static method */ obj = (zend_object*)called_scope; @@ -17532,12 +17589,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C } else if ((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR|IS_CV)) { if ((IS_TMP_VAR|IS_VAR) == IS_CV) { GC_ADDREF(obj); /* For $this pointer */ - } else { - zval *free_op1 = EX_VAR(opline->op1.var); - if (free_op1 != object) { - GC_ADDREF(obj); /* For $this pointer */ - zval_ptr_dtor_nogc(free_op1); - } } /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS | ZEND_CALL_RELEASE_THIS; @@ -31478,8 +31529,17 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S do { if (IS_UNUSED == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { if ((IS_UNUSED & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { - object = Z_REFVAL_P(object); + zend_reference *ref = Z_REF_P(object); + + object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + if (IS_UNUSED & IS_VAR) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { + efree_size(ref, sizeof(zend_reference)); + } else { + Z_ADDREF_P(object); + } + } break; } } @@ -31523,7 +31583,9 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S zend_undefined_method(obj->ce, Z_STR_P(function_name)); } - + if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } HANDLE_EXCEPTION(); } if (IS_CONST == IS_CONST && @@ -31532,8 +31594,10 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc); } if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) { - /* Reset "object" to trigger reference counting */ - object = NULL; + GC_ADDREF(obj); /* For $this pointer */ + if (GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } } if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) { init_func_run_time_cache(&fbc->op_array); @@ -31546,9 +31610,11 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS; if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) { - - if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(EG(exception))) { - HANDLE_EXCEPTION(); + if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(obj) == 0) { + zend_objects_store_del(obj); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } } /* call static method */ obj = (zend_object*)called_scope; @@ -31556,12 +31622,6 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S } else if (IS_UNUSED & (IS_VAR|IS_TMP_VAR|IS_CV)) { if (IS_UNUSED == IS_CV) { GC_ADDREF(obj); /* For $this pointer */ - } else { - zval *free_op1 = EX_VAR(opline->op1.var); - if (free_op1 != object) { - GC_ADDREF(obj); /* For $this pointer */ - zval_ptr_dtor_nogc(free_op1); - } } /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS | ZEND_CALL_RELEASE_THIS; @@ -33374,8 +33434,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_T do { if (IS_UNUSED == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { if ((IS_UNUSED & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { - object = Z_REFVAL_P(object); + zend_reference *ref = Z_REF_P(object); + + object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + if (IS_UNUSED & IS_VAR) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { + efree_size(ref, sizeof(zend_reference)); + } else { + Z_ADDREF_P(object); + } + } break; } } @@ -33419,7 +33488,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_T zend_undefined_method(obj->ce, Z_STR_P(function_name)); } zval_ptr_dtor_nogc(EX_VAR(opline->op2.var)); - + if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } HANDLE_EXCEPTION(); } if ((IS_TMP_VAR|IS_VAR) == IS_CONST && @@ -33428,8 +33499,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_T CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc); } if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) { - /* Reset "object" to trigger reference counting */ - object = NULL; + GC_ADDREF(obj); /* For $this pointer */ + if (GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } } if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) { init_func_run_time_cache(&fbc->op_array); @@ -33442,9 +33515,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_T call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS; if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) { - - if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(EG(exception))) { - HANDLE_EXCEPTION(); + if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(obj) == 0) { + zend_objects_store_del(obj); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } } /* call static method */ obj = (zend_object*)called_scope; @@ -33452,12 +33527,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_T } else if (IS_UNUSED & (IS_VAR|IS_TMP_VAR|IS_CV)) { if (IS_UNUSED == IS_CV) { GC_ADDREF(obj); /* For $this pointer */ - } else { - zval *free_op1 = EX_VAR(opline->op1.var); - if (free_op1 != object) { - GC_ADDREF(obj); /* For $this pointer */ - zval_ptr_dtor_nogc(free_op1); - } } /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS | ZEND_CALL_RELEASE_THIS; @@ -35848,8 +35917,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_C do { if (IS_UNUSED == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { if ((IS_UNUSED & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { - object = Z_REFVAL_P(object); + zend_reference *ref = Z_REF_P(object); + + object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + if (IS_UNUSED & IS_VAR) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { + efree_size(ref, sizeof(zend_reference)); + } else { + Z_ADDREF_P(object); + } + } break; } } @@ -35893,7 +35971,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_C zend_undefined_method(obj->ce, Z_STR_P(function_name)); } - + if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } HANDLE_EXCEPTION(); } if (IS_CV == IS_CONST && @@ -35902,8 +35982,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_C CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc); } if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) { - /* Reset "object" to trigger reference counting */ - object = NULL; + GC_ADDREF(obj); /* For $this pointer */ + if (GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } } if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) { init_func_run_time_cache(&fbc->op_array); @@ -35916,9 +35998,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_C call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS; if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) { - - if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(EG(exception))) { - HANDLE_EXCEPTION(); + if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(obj) == 0) { + zend_objects_store_del(obj); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } } /* call static method */ obj = (zend_object*)called_scope; @@ -35926,12 +36010,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_C } else if (IS_UNUSED & (IS_VAR|IS_TMP_VAR|IS_CV)) { if (IS_UNUSED == IS_CV) { GC_ADDREF(obj); /* For $this pointer */ - } else { - zval *free_op1 = EX_VAR(opline->op1.var); - if (free_op1 != object) { - GC_ADDREF(obj); /* For $this pointer */ - zval_ptr_dtor_nogc(free_op1); - } } /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS | ZEND_CALL_RELEASE_THIS; @@ -40514,8 +40592,17 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S do { if (IS_CV == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { if ((IS_CV & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { - object = Z_REFVAL_P(object); + zend_reference *ref = Z_REF_P(object); + + object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + if (IS_CV & IS_VAR) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { + efree_size(ref, sizeof(zend_reference)); + } else { + Z_ADDREF_P(object); + } + } break; } } @@ -40559,7 +40646,9 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S zend_undefined_method(obj->ce, Z_STR_P(function_name)); } - + if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } HANDLE_EXCEPTION(); } if (IS_CONST == IS_CONST && @@ -40568,8 +40657,10 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc); } if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) { - /* Reset "object" to trigger reference counting */ - object = NULL; + GC_ADDREF(obj); /* For $this pointer */ + if (GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } } if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) { init_func_run_time_cache(&fbc->op_array); @@ -40582,9 +40673,11 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS; if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) { - - if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(EG(exception))) { - HANDLE_EXCEPTION(); + if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(obj) == 0) { + zend_objects_store_del(obj); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } } /* call static method */ obj = (zend_object*)called_scope; @@ -40592,12 +40685,6 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S } else if (IS_CV & (IS_VAR|IS_TMP_VAR|IS_CV)) { if (IS_CV == IS_CV) { GC_ADDREF(obj); /* For $this pointer */ - } else { - zval *free_op1 = EX_VAR(opline->op1.var); - if (free_op1 != object) { - GC_ADDREF(obj); /* For $this pointer */ - zval_ptr_dtor_nogc(free_op1); - } } /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS | ZEND_CALL_RELEASE_THIS; @@ -44086,8 +44173,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_TMPVA do { if (IS_CV == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { if ((IS_CV & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { - object = Z_REFVAL_P(object); + zend_reference *ref = Z_REF_P(object); + + object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + if (IS_CV & IS_VAR) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { + efree_size(ref, sizeof(zend_reference)); + } else { + Z_ADDREF_P(object); + } + } break; } } @@ -44131,7 +44227,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_TMPVA zend_undefined_method(obj->ce, Z_STR_P(function_name)); } zval_ptr_dtor_nogc(EX_VAR(opline->op2.var)); - + if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } HANDLE_EXCEPTION(); } if ((IS_TMP_VAR|IS_VAR) == IS_CONST && @@ -44140,8 +44238,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_TMPVA CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc); } if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) { - /* Reset "object" to trigger reference counting */ - object = NULL; + GC_ADDREF(obj); /* For $this pointer */ + if (GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } } if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) { init_func_run_time_cache(&fbc->op_array); @@ -44154,9 +44254,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_TMPVA call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS; if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) { - - if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(EG(exception))) { - HANDLE_EXCEPTION(); + if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(obj) == 0) { + zend_objects_store_del(obj); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } } /* call static method */ obj = (zend_object*)called_scope; @@ -44164,12 +44266,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_TMPVA } else if (IS_CV & (IS_VAR|IS_TMP_VAR|IS_CV)) { if (IS_CV == IS_CV) { GC_ADDREF(obj); /* For $this pointer */ - } else { - zval *free_op1 = EX_VAR(opline->op1.var); - if (free_op1 != object) { - GC_ADDREF(obj); /* For $this pointer */ - zval_ptr_dtor_nogc(free_op1); - } } /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS | ZEND_CALL_RELEASE_THIS; @@ -49195,8 +49291,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CV_HA do { if (IS_CV == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { if ((IS_CV & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { - object = Z_REFVAL_P(object); + zend_reference *ref = Z_REF_P(object); + + object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + if (IS_CV & IS_VAR) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { + efree_size(ref, sizeof(zend_reference)); + } else { + Z_ADDREF_P(object); + } + } break; } } @@ -49240,7 +49345,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CV_HA zend_undefined_method(obj->ce, Z_STR_P(function_name)); } - + if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } HANDLE_EXCEPTION(); } if (IS_CV == IS_CONST && @@ -49249,8 +49356,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CV_HA CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc); } if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) { - /* Reset "object" to trigger reference counting */ - object = NULL; + GC_ADDREF(obj); /* For $this pointer */ + if (GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } } if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) { init_func_run_time_cache(&fbc->op_array); @@ -49263,9 +49372,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CV_HA call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS; if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) { - - if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(EG(exception))) { - HANDLE_EXCEPTION(); + if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(obj) == 0) { + zend_objects_store_del(obj); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } } /* call static method */ obj = (zend_object*)called_scope; @@ -49273,12 +49384,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CV_HA } else if (IS_CV & (IS_VAR|IS_TMP_VAR|IS_CV)) { if (IS_CV == IS_CV) { GC_ADDREF(obj); /* For $this pointer */ - } else { - zval *free_op1 = EX_VAR(opline->op1.var); - if (free_op1 != object) { - GC_ADDREF(obj); /* For $this pointer */ - zval_ptr_dtor_nogc(free_op1); - } } /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS | ZEND_CALL_RELEASE_THIS; From dd29a6e79e7fbfd5529e746a17bed5f75f1b9d5b Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 20 Aug 2020 20:39:13 +0300 Subject: [PATCH 031/170] efree() doesn't use line number arguments (pass zeros) --- ext/opcache/jit/zend_jit_x86.dasc | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index f14df1009abc4..1cf4183b618cc 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -1471,17 +1471,16 @@ static void* dasm_labels[zend_lb_MAX]; || } |.endmacro -|.macro EFREE_REG_24, op_array, opline +|.macro EFREE_REG_24 ||#if ZEND_DEBUG -|| const char *filename = op_array->filename ? op_array->filename->val : NULL; -| LOAD_ADDR FCARG2a, filename +| xor FCARG2a, FCARG2a // filename | .if X64WIN -| mov CARG3d, opline->lineno +| xor CARG3d, CARG3d // lineno | xor CARG4, CARG4 | mov aword A5, 0 | EXT_CALL _efree, r0 | .elif X64 -| mov CARG3d, opline->lineno +| xor CARG3d, CARG3d // lineno | xor CARG4, CARG4 | xor CARG5, CARG5 | EXT_CALL _efree, r0 @@ -1489,7 +1488,7 @@ static void* dasm_labels[zend_lb_MAX]; | sub r4, 4 | push 0 | push 0 -| push opline->lineno +| push 0 // lineno | EXT_CALL _efree, r0 | add r4, 4 | .endif @@ -1502,9 +1501,9 @@ static void* dasm_labels[zend_lb_MAX]; ||#endif |.endmacro -|.macro EFREE_24, ptr, op_array, opline +|.macro EFREE_24, ptr | mov FCARG1a, ptr -| EFREE_REG_24 op_array, opline +| EFREE_REG_24 |.endmacro |.macro EMALLOC, size, op_array, opline @@ -5465,7 +5464,7 @@ static int zend_jit_simple_assign(dasm_State **Dst, if (save_r1) { | mov aword T1, FCARG1a // save } - | EFREE_24 aword [Ra(Z_REG(val_addr))+Z_OFFSET(val_addr)], op_array, opline + | EFREE_24 aword [Ra(Z_REG(val_addr))+Z_OFFSET(val_addr)] if (save_r1) { | mov FCARG1a, aword T1 // restore } @@ -9508,7 +9507,7 @@ static int zend_jit_send_var(dasm_State **Dst, const zend_op *opline, const zend | GC_ADDREF r2 | jmp >2 |1: - | EFREE_REG_24 op_array, opline + | EFREE_REG_24 | jmp >2 |.code | ZVAL_COPY_VALUE arg_addr, MAY_BE_ANY, op1_addr, op1_info, ZREG_R0, ZREG_R2 @@ -10353,7 +10352,7 @@ static int zend_jit_return(dasm_State **Dst, const zend_op *opline, const zend_o | jmp >9 } |2: - | EFREE_24 r0, op_array, opline + | EFREE_24 r0 if (jit_return_label >= 0) { | jmp =>jit_return_label } else { From c64cb19138fc4f91e3726f1332f45b691e795043 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 20 Aug 2020 20:43:40 +0300 Subject: [PATCH 032/170] cleanup unused parameters --- ext/opcache/jit/zend_jit.c | 78 ++++----- ext/opcache/jit/zend_jit_trace.c | 103 ++++++------ ext/opcache/jit/zend_jit_x86.dasc | 266 ++++++++++++++---------------- 3 files changed, 215 insertions(+), 232 deletions(-) diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index e66afd9d2b149..2956591490d3c 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -116,7 +116,7 @@ static void ZEND_FASTCALL zend_runtime_jit(void); static int zend_jit_trace_op_len(const zend_op *opline); static int zend_jit_trace_may_exit(const zend_op_array *op_array, const zend_op *opline); -static uint32_t zend_jit_trace_get_exit_point(const zend_op *from_opline, const zend_op *to_opline, zend_jit_trace_rec *trace, uint32_t flags); +static uint32_t zend_jit_trace_get_exit_point(const zend_op *to_opline, uint32_t flags); static const void *zend_jit_trace_get_exit_addr(uint32_t n); static void zend_jit_trace_add_code(const void *start, uint32_t size); @@ -2165,23 +2165,17 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op || op_array->opcodes[ssa->cfg.blocks[b].start - 1].opcode == ZEND_SWITCH_LONG || op_array->opcodes[ssa->cfg.blocks[b].start - 1].opcode == ZEND_SWITCH_STRING || op_array->opcodes[ssa->cfg.blocks[b].start - 1].opcode == ZEND_MATCH)) { - if (!zend_jit_reset_opline(&dasm_state, op_array->opcodes + ssa->cfg.blocks[b].start) - || !zend_jit_set_valid_ip(&dasm_state, op_array->opcodes + ssa->cfg.blocks[b].start)) { + zend_jit_reset_opline(); + if (!zend_jit_set_valid_ip(&dasm_state, op_array->opcodes + ssa->cfg.blocks[b].start)) { goto jit_failure; } } else { - if (!zend_jit_set_opline(&dasm_state, op_array->opcodes + ssa->cfg.blocks[b].start)) { - goto jit_failure; - } + zend_jit_set_opline(op_array->opcodes + ssa->cfg.blocks[b].start); } } else if (ssa->cfg.blocks[b].flags & ZEND_BB_TARGET) { - if (!zend_jit_reset_opline(&dasm_state, op_array->opcodes + ssa->cfg.blocks[b].start)) { - goto jit_failure; - } + zend_jit_reset_opline(); } else if (ssa->cfg.blocks[b].flags & (ZEND_BB_START|ZEND_BB_RECV_ENTRY|ZEND_BB_ENTRY)) { - if (!zend_jit_set_opline(&dasm_state, op_array->opcodes + ssa->cfg.blocks[b].start)) { - goto jit_failure; - } + zend_jit_set_opline(op_array->opcodes + ssa->cfg.blocks[b].start); } if (ssa->cfg.blocks[b].flags & ZEND_BB_LOOP_HEADER) { if (!zend_jit_check_timeout(&dasm_state, op_array->opcodes + ssa->cfg.blocks[b].start, NULL)) { @@ -2254,7 +2248,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op res_addr = 0; } op1_def_info = OP1_DEF_INFO(); - if (!zend_jit_inc_dec(&dasm_state, opline, op_array, + if (!zend_jit_inc_dec(&dasm_state, opline, op1_info, OP1_REG_ADDR(), op1_def_info, OP1_DEF_REG_ADDR(), res_use_info, res_info, @@ -2296,7 +2290,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op res_use_info = RES_USE_INFO(); res_addr = RES_REG_ADDR(); } - if (!zend_jit_long_math(&dasm_state, opline, op_array, + if (!zend_jit_long_math(&dasm_state, opline, op1_info, OP1_RANGE(), OP1_REG_ADDR(), op2_info, OP2_RANGE(), OP2_REG_ADDR(), res_use_info, RES_INFO(), res_addr, @@ -2320,7 +2314,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op if (opline->opcode == ZEND_ADD && (op1_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY && (op2_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY) { - if (!zend_jit_add_arrays(&dasm_state, opline, op_array, op1_info, op2_info)) { + if (!zend_jit_add_arrays(&dasm_state, opline, op1_info, op2_info)) { goto jit_failure; } goto done; @@ -2344,7 +2338,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op res_addr = RES_REG_ADDR(); } res_info = RES_INFO(); - if (!zend_jit_math(&dasm_state, opline, op_array, + if (!zend_jit_math(&dasm_state, opline, op1_info, OP1_REG_ADDR(), op2_info, OP2_REG_ADDR(), res_use_info, res_info, res_addr, @@ -2378,8 +2372,8 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op } else { send_result = 0; } - if (!zend_jit_concat(&dasm_state, opline, op_array, - op1_info, op2_info, RES_INFO(), send_result, + if (!zend_jit_concat(&dasm_state, opline, + op1_info, op2_info, send_result, zend_may_throw(opline, ssa_op, op_array, ssa))) { goto jit_failure; } @@ -2426,7 +2420,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op } } op1_def_info = OP1_DEF_INFO(); - if (!zend_jit_assign_op(&dasm_state, opline, op_array, + if (!zend_jit_assign_op(&dasm_state, opline, op1_info, op1_def_info, OP1_RANGE(), op2_info, OP2_RANGE(), (op1_info & MAY_BE_LONG) && (op2_info & MAY_BE_LONG) && (op1_def_info & MAY_BE_DOUBLE) && zend_may_overflow(opline, op_array, ssa), @@ -2446,7 +2440,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op if (PROFITABILITY_CHECKS && (!ssa->ops || !ssa->var_info)) { break; } - if (!zend_jit_assign_dim_op(&dasm_state, opline, op_array, + if (!zend_jit_assign_dim_op(&dasm_state, opline, OP1_INFO(), OP1_DEF_INFO(), OP1_REG_ADDR(), OP2_INFO(), OP1_DATA_INFO(), OP1_DATA_RANGE(), zend_may_throw(opline, ssa_op, op_array, ssa))) { @@ -2460,7 +2454,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op if (PROFITABILITY_CHECKS && (!ssa->ops || !ssa->var_info)) { break; } - if (!zend_jit_assign_dim(&dasm_state, opline, op_array, + if (!zend_jit_assign_dim(&dasm_state, opline, OP1_INFO(), OP1_REG_ADDR(), OP2_INFO(), OP1_DATA_INFO(), zend_may_throw(opline, ssa_op, op_array, ssa))) { goto jit_failure; @@ -2488,7 +2482,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op } else { op2_def_addr = op2_addr; } - if (!zend_jit_assign(&dasm_state, opline, op_array, + if (!zend_jit_assign(&dasm_state, opline, OP1_INFO(), OP1_REG_ADDR(), OP1_DEF_INFO(), OP1_DEF_REG_ADDR(), OP2_INFO(), op2_addr, op2_def_addr, @@ -2506,7 +2500,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op } else { op1_def_addr = op1_addr; } - if (!zend_jit_qm_assign(&dasm_state, opline, op_array, + if (!zend_jit_qm_assign(&dasm_state, opline, OP1_INFO(), op1_addr, op1_def_addr, RES_INFO(), RES_REG_ADDR())) { goto jit_failure; @@ -2529,7 +2523,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op && opline->op2.num > MAX_ARG_FLAG_NUM) { break; } - if (!zend_jit_send_val(&dasm_state, opline, op_array, + if (!zend_jit_send_val(&dasm_state, opline, OP1_INFO(), OP1_REG_ADDR())) { goto jit_failure; } @@ -2579,7 +2573,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op if (opline->op2.num > MAX_ARG_FLAG_NUM) { break; } - if (!zend_jit_check_func_arg(&dasm_state, opline, op_array)) { + if (!zend_jit_check_func_arg(&dasm_state, opline)) { goto jit_failure; } goto done; @@ -2626,7 +2620,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op smart_branch_opcode = 0; target_label = target_label2 = (uint32_t)-1; } - if (!zend_jit_cmp(&dasm_state, opline, op_array, + if (!zend_jit_cmp(&dasm_state, opline, OP1_INFO(), OP1_REG_ADDR(), OP2_INFO(), OP2_REG_ADDR(), res_addr, @@ -2654,7 +2648,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op smart_branch_opcode = 0; target_label = target_label2 = (uint32_t)-1; } - if (!zend_jit_identical(&dasm_state, opline, op_array, + if (!zend_jit_identical(&dasm_state, opline, OP1_INFO(), OP1_REG_ADDR(), OP2_INFO(), OP2_REG_ADDR(), RES_REG_ADDR(), @@ -2680,7 +2674,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op smart_branch_opcode = 0; target_label = target_label2 = (uint32_t)-1; } - if (!zend_jit_defined(&dasm_state, opline, op_array, smart_branch_opcode, target_label, target_label2, NULL)) { + if (!zend_jit_defined(&dasm_state, opline, smart_branch_opcode, target_label, target_label2, NULL)) { goto jit_failure; } goto done; @@ -2704,7 +2698,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op smart_branch_opcode = 0; target_label = target_label2 = (uint32_t)-1; } - if (!zend_jit_type_check(&dasm_state, opline, op_array, OP1_INFO(), smart_branch_opcode, target_label, target_label2, NULL)) { + if (!zend_jit_type_check(&dasm_state, opline, OP1_INFO(), smart_branch_opcode, target_label, target_label2, NULL)) { goto jit_failure; } goto done; @@ -2740,22 +2734,22 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op goto jit_failure; } for (j = 0 ; j < op_array->last_var; j++) { - uint32_t info = zend_ssa_cv_info(opline, op_array, ssa, j); + uint32_t info = zend_ssa_cv_info(op_array, ssa, j); if (info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)) { - if (!zend_jit_free_cv(&dasm_state, opline, op_array, info, j)) { + if (!zend_jit_free_cv(&dasm_state, info, j)) { goto jit_failure; } } } - if (!zend_jit_leave_func(&dasm_state, opline, op_array, NULL, NULL, 1)) { + if (!zend_jit_leave_func(&dasm_state, op_array, NULL, NULL, 1)) { goto jit_failure; } } goto done; case ZEND_BOOL: case ZEND_BOOL_NOT: - if (!zend_jit_bool_jmpznz(&dasm_state, opline, op_array, + if (!zend_jit_bool_jmpznz(&dasm_state, opline, OP1_INFO(), OP1_REG_ADDR(), RES_REG_ADDR(), -1, -1, zend_may_throw(opline, ssa_op, op_array, ssa), @@ -2782,7 +2776,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op } else { res_addr = RES_REG_ADDR(); } - if (!zend_jit_bool_jmpznz(&dasm_state, opline, op_array, + if (!zend_jit_bool_jmpznz(&dasm_state, opline, OP1_INFO(), OP1_REG_ADDR(), res_addr, ssa->cfg.blocks[b].successors[0], ssa->cfg.blocks[b].successors[1], zend_may_throw(opline, ssa_op, op_array, ssa), @@ -2810,7 +2804,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op smart_branch_opcode = 0; target_label = target_label2 = (uint32_t)-1; } - if (!zend_jit_isset_isempty_cv(&dasm_state, opline, op_array, + if (!zend_jit_isset_isempty_cv(&dasm_state, opline, OP1_INFO(), OP1_REG_ADDR(), smart_branch_opcode, target_label, target_label2, NULL)) { @@ -2822,7 +2816,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op if (PROFITABILITY_CHECKS && (!ssa->ops || !ssa->var_info)) { break; } - if (!zend_jit_fetch_dim_read(&dasm_state, opline, op_array, ssa, ssa_op, + if (!zend_jit_fetch_dim_read(&dasm_state, opline, ssa, ssa_op, OP1_INFO(), OP1_REG_ADDR(), OP2_INFO(), RES_INFO(), RES_REG_ADDR(), zend_may_throw(opline, ssa_op, op_array, ssa))) { goto jit_failure; @@ -2851,7 +2845,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op smart_branch_opcode = 0; target_label = target_label2 = (uint32_t)-1; } - if (!zend_jit_isset_isempty_dim(&dasm_state, opline, op_array, + if (!zend_jit_isset_isempty_dim(&dasm_state, opline, OP1_INFO(), OP1_REG_ADDR(), OP2_INFO(), zend_may_throw(opline, ssa_op, op_array, ssa), smart_branch_opcode, target_label, target_label2, @@ -2903,7 +2897,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op } else { op1_info = OP1_INFO(); } - if (!zend_jit_bind_global(&dasm_state, opline, op_array, op1_info)) { + if (!zend_jit_bind_global(&dasm_state, opline, op1_info)) { goto jit_failure; } goto done; @@ -2921,7 +2915,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op goto done; case ZEND_FREE: case ZEND_FE_FREE: - if (!zend_jit_free(&dasm_state, opline, op_array, OP1_INFO(), + if (!zend_jit_free(&dasm_state, opline, OP1_INFO(), zend_may_throw(opline, ssa_op, op_array, ssa))) { goto jit_failure; } @@ -2931,7 +2925,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op if ((op1_info & (MAY_BE_UNDEF|MAY_BE_ANY|MAY_BE_REF)) != MAY_BE_STRING) { break; } - if (!zend_jit_echo(&dasm_state, opline, op_array, op1_info)) { + if (!zend_jit_echo(&dasm_state, opline, op1_info)) { goto jit_failure; } goto done; @@ -2940,7 +2934,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op if ((op1_info & (MAY_BE_UNDEF|MAY_BE_ANY|MAY_BE_REF)) != MAY_BE_STRING) { break; } - if (!zend_jit_strlen(&dasm_state, opline, op_array, op1_info)) { + if (!zend_jit_strlen(&dasm_state, opline, op1_info)) { goto jit_failure; } goto done; @@ -2995,7 +2989,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op goto jit_failure; } } - zend_jit_set_opline(&dasm_state, opline+1); + zend_jit_set_opline(opline+1); break; case ZEND_NOP: case ZEND_OP_DATA: diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index 29684a4085fa9..6ad080003693a 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -132,7 +132,7 @@ static const void *zend_jit_trace_get_exit_addr(uint32_t n) ((n % ZEND_JIT_EXIT_POINTS_PER_GROUP) * ZEND_JIT_EXIT_POINTS_SPACING)); } -static uint32_t zend_jit_trace_get_exit_point(const zend_op *from_opline, const zend_op *to_opline, zend_jit_trace_rec *trace, uint32_t flags) +static uint32_t zend_jit_trace_get_exit_point(const zend_op *to_opline, uint32_t flags) { zend_jit_trace_info *t = &zend_jit_traces[ZEND_JIT_TRACE_NUM]; uint32_t exit_point; @@ -2954,13 +2954,13 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par parent_trace ? &zend_jit_traces[parent_trace] : NULL, exit_num); if (!parent_trace) { - zend_jit_set_opline(&dasm_state, opline); + zend_jit_set_opline(opline); } else { if (zend_jit_traces[parent_trace].exit_info[exit_num].opline == NULL) { zend_jit_trace_opline_guard(&dasm_state, opline); - zend_jit_set_opline(&dasm_state, opline); + zend_jit_set_opline(opline); } else { - zend_jit_reset_opline(&dasm_state, opline); + zend_jit_reset_opline(); } } @@ -3079,7 +3079,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if (trace_buffer->stop != ZEND_JIT_TRACE_STOP_RECURSIVE_RET) { if (ra && zend_jit_trace_stack_needs_deoptimization(stack, op_array->last_var + op_array->T)) { - uint32_t exit_point = zend_jit_trace_get_exit_point(NULL, NULL, NULL, ZEND_JIT_EXIT_TO_VM); + uint32_t exit_point = zend_jit_trace_get_exit_point(NULL, ZEND_JIT_EXIT_TO_VM); timeout_exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!timeout_exit_addr) { @@ -3181,7 +3181,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par res_addr = 0; } op1_def_info = OP1_DEF_INFO(); - if (!zend_jit_inc_dec(&dasm_state, opline, op_array, + if (!zend_jit_inc_dec(&dasm_state, opline, op1_info, OP1_REG_ADDR(), op1_def_info, OP1_DEF_REG_ADDR(), res_use_info, res_info, @@ -3255,7 +3255,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par res_addr = RES_REG_ADDR(); } res_info = RES_INFO(); - if (!zend_jit_long_math(&dasm_state, opline, op_array, + if (!zend_jit_long_math(&dasm_state, opline, op1_info, OP1_RANGE(), OP1_REG_ADDR(), op2_info, OP2_RANGE(), OP2_REG_ADDR(), res_use_info, res_info, res_addr, @@ -3278,7 +3278,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if (opline->opcode == ZEND_ADD && (op1_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY && (op2_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY) { - if (!zend_jit_add_arrays(&dasm_state, opline, op_array, op1_info, op2_info)) { + if (!zend_jit_add_arrays(&dasm_state, opline, op1_info, op2_info)) { goto jit_failure; } goto done; @@ -3326,7 +3326,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par res_addr = RES_REG_ADDR(); } res_info = RES_INFO(); - if (!zend_jit_math(&dasm_state, opline, op_array, + if (!zend_jit_math(&dasm_state, opline, op1_info, OP1_REG_ADDR(), op2_info, OP2_REG_ADDR(), res_use_info, res_info, res_addr, @@ -3378,9 +3378,8 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par } else { send_result = 0; } - res_info = RES_INFO(); - if (!zend_jit_concat(&dasm_state, opline, op_array, - op1_info, op2_info, res_info, send_result, + if (!zend_jit_concat(&dasm_state, opline, + op1_info, op2_info, send_result, zend_may_throw(opline, ssa_op, op_array, ssa))) { goto jit_failure; } @@ -3426,7 +3425,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par } } op1_def_info = OP1_DEF_INFO(); - if (!zend_jit_assign_op(&dasm_state, opline, op_array, + if (!zend_jit_assign_op(&dasm_state, opline, op1_info, op1_def_info, OP1_RANGE(), op2_info, OP2_RANGE(), (op1_info & MAY_BE_LONG) && (op2_info & MAY_BE_LONG) && (op1_def_info & (MAY_BE_DOUBLE|MAY_BE_GUARD)) && zend_may_overflow_ex(opline, ssa_op, op_array, ssa), @@ -3464,7 +3463,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par op1_data_info = OP1_DATA_INFO(); CHECK_OP1_DATA_TRACE_TYPE(); op1_def_info = OP1_DEF_INFO(); - if (!zend_jit_assign_dim_op(&dasm_state, opline, op_array, + if (!zend_jit_assign_dim_op(&dasm_state, opline, op1_info, op1_def_info, op1_addr, op2_info, op1_data_info, OP1_DATA_RANGE(), zend_may_throw_ex(opline, ssa_op, op_array, ssa, op1_info, op2_info))) { @@ -3489,7 +3488,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par CHECK_OP2_TRACE_TYPE(); op1_data_info = OP1_DATA_INFO(); CHECK_OP1_DATA_TRACE_TYPE(); - if (!zend_jit_assign_dim(&dasm_state, opline, op_array, + if (!zend_jit_assign_dim(&dasm_state, opline, op1_info, op1_addr, op2_info, op1_data_info, zend_may_throw_ex(opline, ssa_op, op_array, ssa, op1_info, op2_info))) { goto jit_failure; @@ -3525,7 +3524,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if (!zend_jit_fetch_reference(&dasm_state, opline, orig_op1_type, &op1_info, &op1_addr, 0)) { goto jit_failure; } - if (!zend_jit_assign_to_typed_ref(&dasm_state, opline, op_array, opline->op2_type, op2_addr, 1)) { + if (!zend_jit_assign_to_typed_ref(&dasm_state, opline, opline->op2_type, op2_addr, 1)) { goto jit_failure; } op1_def_addr = op1_addr; @@ -3538,7 +3537,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par op1_def_info &= ~MAY_BE_REF; } } - if (!zend_jit_assign(&dasm_state, opline, op_array, + if (!zend_jit_assign(&dasm_state, opline, op1_info, op1_addr, op1_def_info, op1_def_addr, op2_info, op2_addr, op2_def_addr, @@ -3564,7 +3563,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par op1_info = OP1_INFO(); CHECK_OP1_TRACE_TYPE(); res_info = RES_INFO(); - if (!zend_jit_qm_assign(&dasm_state, opline, op_array, + if (!zend_jit_qm_assign(&dasm_state, opline, op1_info, op1_addr, op1_def_addr, res_info, RES_REG_ADDR())) { goto jit_failure; @@ -3589,7 +3588,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par } op1_info = OP1_INFO(); CHECK_OP1_TRACE_TYPE(); - if (!zend_jit_send_val(&dasm_state, opline, op_array, + if (!zend_jit_send_val(&dasm_state, opline, op1_info, OP1_REG_ADDR())) { goto jit_failure; } @@ -3672,7 +3671,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par || !JIT_G(current_frame)->call->func)) { break; } - if (!zend_jit_check_func_arg(&dasm_state, opline, op_array)) { + if (!zend_jit_check_func_arg(&dasm_state, opline)) { goto jit_failure; } goto done; @@ -3706,7 +3705,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if (ra) { zend_jit_trace_clenup_stack(stack, opline, ssa_op, ssa, ra); } - exit_point = zend_jit_trace_get_exit_point(opline, exit_opline, p + 1, 0); + exit_point = zend_jit_trace_get_exit_point(exit_opline, 0); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { goto jit_failure; @@ -3716,7 +3715,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par smart_branch_opcode = 0; exit_addr = NULL; } - if (!zend_jit_cmp(&dasm_state, opline, op_array, + if (!zend_jit_cmp(&dasm_state, opline, op1_info, OP1_REG_ADDR(), op2_info, OP2_REG_ADDR(), RES_REG_ADDR(), @@ -3739,7 +3738,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if (ra) { zend_jit_trace_clenup_stack(stack, opline, ssa_op, ssa, ra); } - exit_point = zend_jit_trace_get_exit_point(opline, exit_opline, p + 1, 0); + exit_point = zend_jit_trace_get_exit_point(exit_opline, 0); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { goto jit_failure; @@ -3752,7 +3751,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par smart_branch_opcode = 0; exit_addr = NULL; } - if (!zend_jit_identical(&dasm_state, opline, op_array, + if (!zend_jit_identical(&dasm_state, opline, op1_info, OP1_REG_ADDR(), op2_info, OP2_REG_ADDR(), RES_REG_ADDR(), @@ -3765,7 +3764,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if ((opline->result_type & (IS_SMART_BRANCH_JMPZ|IS_SMART_BRANCH_JMPNZ)) != 0) { zend_bool exit_if_true = 0; const zend_op *exit_opline = zend_jit_trace_get_exit_opline(p + 1, opline + 1, &exit_if_true); - uint32_t exit_point = zend_jit_trace_get_exit_point(opline, exit_opline, p + 1, 0); + uint32_t exit_point = zend_jit_trace_get_exit_point(exit_opline, 0); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -3776,7 +3775,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par smart_branch_opcode = 0; exit_addr = NULL; } - if (!zend_jit_defined(&dasm_state, opline, op_array, smart_branch_opcode, -1, -1, exit_addr)) { + if (!zend_jit_defined(&dasm_state, opline, smart_branch_opcode, -1, -1, exit_addr)) { goto jit_failure; } goto done; @@ -3794,7 +3793,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if (ra) { zend_jit_trace_clenup_stack(stack, opline, ssa_op, ssa, ra); } - exit_point = zend_jit_trace_get_exit_point(opline, exit_opline, p + 1, 0); + exit_point = zend_jit_trace_get_exit_point(exit_opline, 0); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { goto jit_failure; @@ -3804,7 +3803,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par smart_branch_opcode = 0; exit_addr = NULL; } - if (!zend_jit_type_check(&dasm_state, opline, op_array, op1_info, smart_branch_opcode, -1, -1, exit_addr)) { + if (!zend_jit_type_check(&dasm_state, opline, op1_info, smart_branch_opcode, -1, -1, exit_addr)) { goto jit_failure; } goto done; @@ -3846,11 +3845,11 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par && TRACE_FRAME_IS_RETURN_VALUE_USED(JIT_G(current_frame))) { continue; } - info = zend_ssa_cv_info(opline, op_array, op_array_ssa, j); + info = zend_ssa_cv_info(op_array, op_array_ssa, j); type = STACK_TYPE(stack, j); info = zend_jit_trace_type_to_info_ex(type, info); if (info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)) { - if (!zend_jit_free_cv(&dasm_state, opline, op_array, info, j)) { + if (!zend_jit_free_cv(&dasm_state, info, j)) { goto jit_failure; } if (info & (MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_ARRAY_OF_RESOURCE)) { @@ -3860,7 +3859,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par } } } - if (!zend_jit_leave_func(&dasm_state, opline, op_array, p + 1, &zend_jit_traces[ZEND_JIT_TRACE_NUM], may_throw)) { + if (!zend_jit_leave_func(&dasm_state, op_array, p + 1, &zend_jit_traces[ZEND_JIT_TRACE_NUM], may_throw)) { goto jit_failure; } } @@ -3869,7 +3868,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par case ZEND_BOOL_NOT: op1_info = OP1_INFO(); CHECK_OP1_TRACE_TYPE(); - if (!zend_jit_bool_jmpznz(&dasm_state, opline, op_array, + if (!zend_jit_bool_jmpznz(&dasm_state, opline, op1_info, OP1_REG_ADDR(), RES_REG_ADDR(), -1, -1, zend_may_throw(opline, ssa_op, op_array, ssa), @@ -3926,10 +3925,10 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par uint32_t old_info = STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var)); SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->result.var), IS_UNKNOWN); - exit_point = zend_jit_trace_get_exit_point(opline, exit_opline, p+1, 0); + exit_point = zend_jit_trace_get_exit_point(exit_opline, 0); SET_STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var), old_info); } else { - exit_point = zend_jit_trace_get_exit_point(opline, exit_opline, p+1, 0); + exit_point = zend_jit_trace_get_exit_point(exit_opline, 0); } exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -3945,7 +3944,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par } op1_info = OP1_INFO(); CHECK_OP1_TRACE_TYPE(); - if (!zend_jit_bool_jmpznz(&dasm_state, opline, op_array, + if (!zend_jit_bool_jmpznz(&dasm_state, opline, op1_info, OP1_REG_ADDR(), res_addr, -1, -1, zend_may_throw(opline, ssa_op, op_array, ssa), @@ -3971,7 +3970,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if ((opline->result_type & (IS_SMART_BRANCH_JMPZ|IS_SMART_BRANCH_JMPNZ)) != 0) { zend_bool exit_if_true = 0; const zend_op *exit_opline = zend_jit_trace_get_exit_opline(p + 1, opline + 1, &exit_if_true); - uint32_t exit_point = zend_jit_trace_get_exit_point(opline, exit_opline, p + 1, 0); + uint32_t exit_point = zend_jit_trace_get_exit_point(exit_opline, 0); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -3982,7 +3981,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par smart_branch_opcode = 0; exit_addr = NULL; } - if (!zend_jit_isset_isempty_cv(&dasm_state, opline, op_array, + if (!zend_jit_isset_isempty_cv(&dasm_state, opline, op1_info, op1_addr, smart_branch_opcode, -1, -1, exit_addr)) { goto jit_failure; @@ -4011,7 +4010,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par op2_info = OP2_INFO(); CHECK_OP2_TRACE_TYPE(); res_info = RES_INFO(); - if (!zend_jit_fetch_dim_read(&dasm_state, opline, op_array, ssa, ssa_op, + if (!zend_jit_fetch_dim_read(&dasm_state, opline, ssa, ssa_op, op1_info, op1_addr, op2_info, res_info, RES_REG_ADDR(), ( (op1_info & MAY_BE_ANY) != MAY_BE_ARRAY || @@ -4059,10 +4058,10 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par uint32_t old_info = STACK_INFO(stack, EX_VAR_TO_NUM(opline->op1.var)); SET_STACK_REG(stack, EX_VAR_TO_NUM(opline->op1.var), ZREG_NONE); - exit_point = zend_jit_trace_get_exit_point(opline, exit_opline, p + 1, 0); + exit_point = zend_jit_trace_get_exit_point(exit_opline, 0); SET_STACK_INFO(stack, EX_VAR_TO_NUM(opline->op1.var), old_info); } else { - exit_point = zend_jit_trace_get_exit_point(opline, exit_opline, p + 1, 0); + exit_point = zend_jit_trace_get_exit_point(exit_opline, 0); } exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -4073,7 +4072,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par smart_branch_opcode = 0; exit_addr = NULL; } - if (!zend_jit_isset_isempty_dim(&dasm_state, opline, op_array, + if (!zend_jit_isset_isempty_dim(&dasm_state, opline, op1_info, op1_addr, op2_info, zend_may_throw_ex(opline, ssa_op, op_array, ssa, op1_info, op2_info), smart_branch_opcode, -1, -1, @@ -4159,7 +4158,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par } else { op1_info = OP1_INFO(); } - if (!zend_jit_bind_global(&dasm_state, opline, op_array, op1_info)) { + if (!zend_jit_bind_global(&dasm_state, opline, op1_info)) { goto jit_failure; } if ((opline+1)->opcode == ZEND_BIND_GLOBAL) { @@ -4199,7 +4198,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par case ZEND_FREE: case ZEND_FE_FREE: op1_info = OP1_INFO(); - if (!zend_jit_free(&dasm_state, opline, op_array, op1_info, + if (!zend_jit_free(&dasm_state, opline, op1_info, zend_may_throw(opline, ssa_op, op_array, ssa))) { goto jit_failure; } @@ -4210,7 +4209,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if ((op1_info & (MAY_BE_UNDEF|MAY_BE_ANY|MAY_BE_REF)) != MAY_BE_STRING) { break; } - if (!zend_jit_echo(&dasm_state, opline, op_array, op1_info)) { + if (!zend_jit_echo(&dasm_state, opline, op1_info)) { goto jit_failure; } goto done; @@ -4220,7 +4219,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if ((op1_info & (MAY_BE_UNDEF|MAY_BE_ANY|MAY_BE_REF)) != MAY_BE_STRING) { break; } - if (!zend_jit_strlen(&dasm_state, opline, op_array, op1_info)) { + if (!zend_jit_strlen(&dasm_state, opline, op1_info)) { goto jit_failure; } goto done; @@ -4249,7 +4248,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par goto jit_failure; } if ((p+1)->op == ZEND_JIT_TRACE_INIT_CALL && (p+1)->func) { - if (!zend_jit_init_fcall_guard(&dasm_state, opline, (p+1)->func, opline+1)) { + if (!zend_jit_init_fcall_guard(&dasm_state, (p+1)->func, opline+1)) { goto jit_failure; } } @@ -4261,7 +4260,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if ((opline->op1_type != IS_CONST || opline->op2_type != IS_CONST) && (p+1)->op == ZEND_JIT_TRACE_INIT_CALL && (p+1)->func) { - if (!zend_jit_init_fcall_guard(&dasm_state, opline, (p+1)->func, opline+1)) { + if (!zend_jit_init_fcall_guard(&dasm_state, (p+1)->func, opline+1)) { goto jit_failure; } } @@ -4272,7 +4271,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par } if (opline->op2_type != IS_CONST && (p+1)->op == ZEND_JIT_TRACE_INIT_CALL && (p+1)->func) { - if (!zend_jit_init_fcall_guard(&dasm_state, opline, (p+1)->func, opline+1)) { + if (!zend_jit_init_fcall_guard(&dasm_state, (p+1)->func, opline+1)) { goto jit_failure; } } @@ -4284,7 +4283,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if (opline->op1_type != IS_CONST && (p+1)->op == ZEND_JIT_TRACE_INIT_CALL && (p+1)->func) { SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->result.var), IS_OBJECT); - if (!zend_jit_init_fcall_guard(&dasm_state, opline, (p+1)->func, opline+1)) { + if (!zend_jit_init_fcall_guard(&dasm_state, (p+1)->func, opline+1)) { goto jit_failure; } } @@ -4522,7 +4521,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if ((p+1)->op == ZEND_JIT_TRACE_END) { p++; - zend_jit_set_opline(&dasm_state, p->opline); + zend_jit_set_opline(p->opline); break; } op_array = (zend_op_array*)p->op_array; @@ -4550,7 +4549,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par } } } - zend_jit_set_opline(&dasm_state, (p+1)->opline); + zend_jit_set_opline((p+1)->opline); } else if (p->op == ZEND_JIT_TRACE_BACK) { op_array = (zend_op_array*)p->op_array; jit_extension = @@ -4691,7 +4690,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par opline = q->opline; ZEND_ASSERT(opline != NULL); } - if (!zend_jit_init_fcall_guard(&dasm_state, NULL, p->func, opline)) { + if (!zend_jit_init_fcall_guard(&dasm_state, p->func, opline)) { goto jit_failure; } } diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index 1cf4183b618cc..121dd62719c8c 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -1419,7 +1419,7 @@ static void* dasm_labels[zend_lb_MAX]; || } |.endmacro -|.macro FREE_OP, op_type, op, op_info, cold, op_array, opline +|.macro FREE_OP, op_type, op, op_info, cold, opline || if (op_type & (IS_VAR|IS_TMP_VAR)) { | ZVAL_PTR_DTOR ZEND_ADDR_MEM_ZVAL(ZREG_FP, op.var), op_info, 0, cold, opline || } @@ -2945,7 +2945,7 @@ static int zend_jit_trace_begin(dasm_State **Dst, uint32_t trace_num, zend_jit_t static int zend_jit_trace_opline_guard(dasm_State **Dst, const zend_op *opline) { - uint32_t exit_point = zend_jit_trace_get_exit_point(NULL, NULL, NULL, 0); + uint32_t exit_point = zend_jit_trace_get_exit_point(NULL, 0); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -3223,7 +3223,7 @@ static int zend_jit_trace_return(dasm_State **Dst, zend_bool original_handler) static int zend_jit_type_guard(dasm_State **Dst, const zend_op *opline, uint32_t var, uint8_t type) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, 0); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, 0); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -3345,7 +3345,7 @@ static int zend_jit_trace_handler(dasm_State **Dst, const zend_op_array *op_arra old_res_info = STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var)); SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->result.var), IS_UNKNOWN); } - exit_point = zend_jit_trace_get_exit_point(opline, exit_opline, trace, 0); + exit_point = zend_jit_trace_get_exit_point(exit_opline, 0); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (opline->result_type == IS_VAR || opline->result_type == IS_TMP_VAR) { @@ -3454,18 +3454,16 @@ static int zend_jit_tail_handler(dasm_State **Dst, const zend_op *opline) return 1; } -static int zend_jit_set_opline(dasm_State **Dst, const zend_op *target_opline) +static void zend_jit_set_opline(const zend_op *target_opline) { if (!reuse_ip) { last_valid_opline = target_opline; } - return 1; } -static int zend_jit_reset_opline(dasm_State **Dst, const zend_op *target_opline) +static void zend_jit_reset_opline(void) { last_valid_opline = NULL; - return 1; } static void zend_jit_start_reuse_ip(void) { @@ -3689,7 +3687,7 @@ static int zend_jit_store_const(dasm_State **Dst, int var, zend_reg reg) return 1; } -static int zend_jit_inc_dec(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op1_def_info, zend_jit_addr op1_def_addr, uint32_t res_use_info, uint32_t res_info, zend_jit_addr res_addr, int may_overflow, int may_throw) +static int zend_jit_inc_dec(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op1_def_info, zend_jit_addr op1_def_addr, uint32_t res_use_info, uint32_t res_info, zend_jit_addr res_addr, int may_overflow, int may_throw) { if (op1_info & ((MAY_BE_UNDEF|MAY_BE_ANY)-MAY_BE_LONG)) { | IF_NOT_ZVAL_TYPE op1_addr, IS_LONG, >2 @@ -3739,7 +3737,7 @@ static int zend_jit_inc_dec(dasm_State **Dst, const zend_op *opline, const zend_ } } - exit_point = zend_jit_trace_get_exit_point(opline, opline + 1, NULL, 0); + exit_point = zend_jit_trace_get_exit_point(opline + 1, 0); exit_addr = zend_jit_trace_get_exit_addr(exit_point); | jo &exit_addr @@ -3922,7 +3920,6 @@ static int zend_jit_inc_dec(dasm_State **Dst, const zend_op *opline, const zend_ } static int zend_jit_math_long_long(dasm_State **Dst, - const zend_op_array *op_array, const zend_op *opline, zend_uchar opcode, zend_jit_addr op1_addr, @@ -3992,7 +3989,7 @@ static int zend_jit_math_long_long(dasm_State **Dst, } if (may_overflow) { if (res_info & MAY_BE_GUARD) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, 0); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, 0); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); | jo &exit_addr } else { @@ -4239,7 +4236,6 @@ static int zend_jit_math_double_double(dasm_State **Dst, static int zend_jit_math_helper(dasm_State **Dst, const zend_op *opline, zend_uchar opcode, - const zend_op_array *op_array, zend_uchar op1_type, znode_op op1, zend_jit_addr op1_addr, @@ -4283,7 +4279,7 @@ static int zend_jit_math_helper(dasm_State **Dst, | IF_NOT_ZVAL_TYPE op2_addr, IS_LONG, >6 } } - if (!zend_jit_math_long_long(Dst, op_array, opline, opcode, op1_addr, op2_addr, res_addr, res_info, res_use_info, may_overflow)) { + if (!zend_jit_math_long_long(Dst, opline, opcode, op1_addr, op2_addr, res_addr, res_info, res_use_info, may_overflow)) { return 0; } if (op1_info & MAY_BE_DOUBLE) { @@ -4438,8 +4434,8 @@ static int zend_jit_math_helper(dasm_State **Dst, |.if not(X64) | add r4, 12 |.endif - | FREE_OP op1_type, op1, op1_info, 0, op_array, opline - | FREE_OP op2_type, op2, op2_info, 0, op_array, opline + | FREE_OP op1_type, op1, op1_info, 0, opline + | FREE_OP op2_type, op2, op2_info, 0, opline if (may_throw) { zend_jit_check_exception(Dst); } @@ -4459,7 +4455,7 @@ static int zend_jit_math_helper(dasm_State **Dst, return 1; } -static int zend_jit_math(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op2_info, zend_jit_addr op2_addr, uint32_t res_use_info, uint32_t res_info, zend_jit_addr res_addr, zend_bool send_result, int may_overflow, int may_throw) +static int zend_jit_math(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op2_info, zend_jit_addr op2_addr, uint32_t res_use_info, uint32_t res_info, zend_jit_addr res_addr, zend_bool send_result, int may_overflow, int may_throw) { ZEND_ASSERT(!(op1_info & MAY_BE_UNDEF) && !(op2_info & MAY_BE_UNDEF)); ZEND_ASSERT((op1_info & (MAY_BE_LONG|MAY_BE_DOUBLE)) && @@ -4474,7 +4470,7 @@ static int zend_jit_math(dasm_State **Dst, const zend_op *opline, const zend_op_ res_addr = ZEND_ADDR_MEM_ZVAL(ZREG_RX, (opline+1)->result.var); } - if (!zend_jit_math_helper(Dst, opline, opline->opcode, op_array, opline->op1_type, opline->op1, op1_addr, op1_info, opline->op2_type, opline->op2, op2_addr, op2_info, opline->result.var, res_addr, res_info, res_use_info, may_overflow, may_throw)) { + if (!zend_jit_math_helper(Dst, opline, opline->opcode, opline->op1_type, opline->op1, op1_addr, op1_info, opline->op2_type, opline->op2, op2_addr, op2_info, opline->result.var, res_addr, res_info, res_use_info, may_overflow, may_throw)) { return 0; } if (!zend_jit_store_var_if_necessary(Dst, opline->result.var, res_addr, res_info)) { @@ -4483,7 +4479,7 @@ static int zend_jit_math(dasm_State **Dst, const zend_op *opline, const zend_op_ return 1; } -static int zend_jit_add_arrays(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, uint32_t op2_info) +static int zend_jit_add_arrays(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, uint32_t op2_info) { zend_jit_addr op1_addr = OP1_ADDR(); zend_jit_addr op2_addr = OP2_ADDR(); @@ -4494,15 +4490,14 @@ static int zend_jit_add_arrays(dasm_State **Dst, const zend_op *opline, const ze | EXT_CALL zend_jit_add_arrays_helper, r0 | SET_ZVAL_PTR res_addr, r0 | SET_ZVAL_TYPE_INFO res_addr, IS_ARRAY_EX - | FREE_OP opline->op1_type, opline->op1, op1_info, 0, op_array, opline - | FREE_OP opline->op2_type, opline->op2, op2_info, 0, op_array, opline + | FREE_OP opline->op1_type, opline->op1, op1_info, 0, opline + | FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline return 1; } static int zend_jit_long_math_helper(dasm_State **Dst, const zend_op *opline, zend_uchar opcode, - const zend_op_array *op_array, zend_uchar op1_type, znode_op op1, zend_jit_addr op1_addr, @@ -4767,8 +4762,8 @@ static int zend_jit_long_math_helper(dasm_State **Dst, |.if not(X64) | add r4, 12 |.endif - | FREE_OP op1_type, op1, op1_info, 0, op_array, opline - | FREE_OP op2_type, op2, op2_info, 0, op_array, opline + | FREE_OP op1_type, op1, op1_info, 0, opline + | FREE_OP op2_type, op2, op2_info, 0, opline if (may_throw) { zend_jit_check_exception(Dst); } @@ -4789,7 +4784,7 @@ static int zend_jit_long_math_helper(dasm_State **Dst, return 1; } -static int zend_jit_long_math(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_ssa_range *op1_range, zend_jit_addr op1_addr, uint32_t op2_info, zend_ssa_range *op2_range, zend_jit_addr op2_addr, uint32_t res_use_info, uint32_t res_info, zend_jit_addr res_addr, zend_bool send_result, int may_throw) +static int zend_jit_long_math(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_ssa_range *op1_range, zend_jit_addr op1_addr, uint32_t op2_info, zend_ssa_range *op2_range, zend_jit_addr op2_addr, uint32_t res_use_info, uint32_t res_info, zend_jit_addr res_addr, zend_bool send_result, int may_throw) { ZEND_ASSERT(!(op1_info & MAY_BE_UNDEF) && !(op2_info & MAY_BE_UNDEF)); ZEND_ASSERT((op1_info & MAY_BE_LONG) && (op2_info & MAY_BE_LONG)); @@ -4803,7 +4798,7 @@ static int zend_jit_long_math(dasm_State **Dst, const zend_op *opline, const zen res_addr = ZEND_ADDR_MEM_ZVAL(ZREG_RX, (opline+1)->result.var); } - if (!zend_jit_long_math_helper(Dst, opline, opline->opcode, op_array, + if (!zend_jit_long_math_helper(Dst, opline, opline->opcode, opline->op1_type, opline->op1, op1_addr, op1_info, op1_range, opline->op2_type, opline->op2, op2_addr, op2_info, op2_range, opline->result.var, res_addr, res_info, res_use_info, may_throw)) { @@ -4817,7 +4812,6 @@ static int zend_jit_long_math(dasm_State **Dst, const zend_op *opline, const zen static int zend_jit_concat_helper(dasm_State **Dst, const zend_op *opline, - const zend_op_array *op_array, zend_uchar op1_type, znode_op op1, zend_jit_addr op1_addr, @@ -4827,7 +4821,6 @@ static int zend_jit_concat_helper(dasm_State **Dst, zend_jit_addr op2_addr, uint32_t op2_info, zend_jit_addr res_addr, - uint32_t res_info, int may_throw) { #if 1 @@ -4860,8 +4853,8 @@ static int zend_jit_concat_helper(dasm_State **Dst, | add r4, 12 |.endif } - | FREE_OP op1_type, op1, op1_info, 0, op_array, opline - | FREE_OP op2_type, op2, op2_info, 0, op_array, opline + | FREE_OP op1_type, op1, op1_info, 0, opline + | FREE_OP op2_type, op2, op2_info, 0, opline |5: } if ((op1_info & ((MAY_BE_UNDEF|MAY_BE_ANY|MAY_BE_REF) - MAY_BE_STRING)) || @@ -4886,8 +4879,8 @@ static int zend_jit_concat_helper(dasm_State **Dst, |.if not(X64) | add r4, 12 |.endif - | FREE_OP op1_type, op1, op1_info, 0, op_array, opline - | FREE_OP op2_type, op2, op2_info, 0, op_array, opline + | FREE_OP op1_type, op1, op1_info, 0, opline + | FREE_OP op2_type, op2, op2_info, 0, opline if (may_throw) { zend_jit_check_exception(Dst); } @@ -4902,7 +4895,7 @@ static int zend_jit_concat_helper(dasm_State **Dst, return 1; } -static int zend_jit_concat(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, uint32_t op2_info, uint32_t res_info, zend_bool send_result, int may_throw) +static int zend_jit_concat(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, uint32_t op2_info, zend_bool send_result, int may_throw) { zend_jit_addr op1_addr, op2_addr, res_addr; @@ -4922,10 +4915,10 @@ static int zend_jit_concat(dasm_State **Dst, const zend_op *opline, const zend_o } else { res_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->result.var); } - return zend_jit_concat_helper(Dst, opline, op_array, opline->op1_type, opline->op1, op1_addr, op1_info, opline->op2_type, opline->op2, op2_addr, op2_info, res_addr, res_info, may_throw); + return zend_jit_concat_helper(Dst, opline, opline->op1_type, opline->op1, op1_addr, op1_info, opline->op2_type, opline->op2, op2_addr, op2_info, res_addr, may_throw); } -static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_op *opline, uint32_t type, uint32_t op1_info, uint32_t op2_info, uint32_t found, uint32_t not_found, const void *found_exit_addr, const void *not_found_exit_addr, const void *exit_addr) +static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_op *opline, uint32_t type, uint32_t op1_info, uint32_t op2_info, const void *found_exit_addr, const void *not_found_exit_addr, const void *exit_addr) /* Labels: 1,2,3,4,5 */ { zend_jit_addr op2_addr = OP2_ADDR(); @@ -4934,7 +4927,7 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE && type == BP_VAR_R && !exit_addr) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { return 0; @@ -5362,7 +5355,6 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o static int zend_jit_simple_assign(dasm_State **Dst, const zend_op *opline, - const zend_op_array *op_array, zend_jit_addr var_addr, uint32_t var_info, uint32_t var_def_info, @@ -5501,7 +5493,6 @@ static int zend_jit_simple_assign(dasm_State **Dst, static int zend_jit_assign_to_typed_ref(dasm_State **Dst, const zend_op *opline, - const zend_op_array *op_array, zend_uchar val_type, zend_jit_addr val_addr, zend_bool check_exception) @@ -5539,7 +5530,6 @@ static int zend_jit_assign_to_typed_ref(dasm_State **Dst, static int zend_jit_assign_to_variable(dasm_State **Dst, const zend_op *opline, - const zend_op_array *op_array, zend_jit_addr var_use_addr, zend_jit_addr var_addr, uint32_t var_info, @@ -5563,7 +5553,7 @@ static int zend_jit_assign_to_variable(dasm_State **Dst, | IF_NOT_Z_TYPE, FCARG1a, IS_REFERENCE, >1 | // if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(Z_REF_P(variable_ptr)))) { | GET_Z_PTR FCARG1a, FCARG1a - if (!zend_jit_assign_to_typed_ref(Dst, opline, op_array, val_type, val_addr, check_exception)) { + if (!zend_jit_assign_to_typed_ref(Dst, opline, val_type, val_addr, check_exception)) { return 0; } | add FCARG1a, offsetof(zend_reference, val) @@ -5583,7 +5573,7 @@ static int zend_jit_assign_to_variable(dasm_State **Dst, if (Z_REG(var_use_addr) == ZREG_FCARG1a) { | GET_ZVAL_PTR r0, var_use_addr | mov aword T1, r0 // save - if (!zend_jit_simple_assign(Dst, opline, op_array, var_addr, var_info, var_def_info, val_type, val, val_addr, val_info, res_addr, in_cold, 0)) { + if (!zend_jit_simple_assign(Dst, opline, var_addr, var_info, var_def_info, val_type, val, val_addr, val_info, res_addr, in_cold, 0)) { return 0; } if (Z_REG(var_use_addr) == ZREG_FCARG1a) { @@ -5591,7 +5581,7 @@ static int zend_jit_assign_to_variable(dasm_State **Dst, } } else { | GET_ZVAL_PTR FCARG1a, var_use_addr - if (!zend_jit_simple_assign(Dst, opline, op_array, var_addr, var_info, var_def_info, val_type, val, val_addr, val_info, res_addr, in_cold, 1)) { + if (!zend_jit_simple_assign(Dst, opline, var_addr, var_info, var_def_info, val_type, val, val_addr, val_info, res_addr, in_cold, 1)) { return 0; } } @@ -5653,7 +5643,7 @@ static int zend_jit_assign_to_variable(dasm_State **Dst, } } - if (!done && !zend_jit_simple_assign(Dst, opline, op_array, var_addr, var_info, var_def_info, val_type, val, val_addr, val_info, res_addr, 0, 0)) { + if (!done && !zend_jit_simple_assign(Dst, opline, var_addr, var_info, var_def_info, val_type, val, val_addr, val_info, res_addr, 0, 0)) { return 0; } @@ -5662,7 +5652,7 @@ static int zend_jit_assign_to_variable(dasm_State **Dst, return 1; } -static int zend_jit_assign_dim(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op2_info, uint32_t val_info, int may_throw) +static int zend_jit_assign_dim(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op2_info, uint32_t val_info, int may_throw) { zend_jit_addr op2_addr, op3_addr, res_addr; @@ -5741,14 +5731,14 @@ static int zend_jit_assign_dim(dasm_State **Dst, const zend_op *opline, const ze |.code | mov FCARG1a, r0 - if (!zend_jit_simple_assign(Dst, opline, op_array, var_addr, var_info, -1, (opline+1)->op1_type, (opline+1)->op1, op3_addr, val_info, res_addr, 0, 0)) { + if (!zend_jit_simple_assign(Dst, opline, var_addr, var_info, -1, (opline+1)->op1_type, (opline+1)->op1, op3_addr, val_info, res_addr, 0, 0)) { return 0; } } else { uint32_t var_info = zend_array_element_type(op1_info, opline->op1_type, 0, 0); zend_jit_addr var_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, 0); - if (!zend_jit_fetch_dimension_address_inner(Dst, opline, BP_VAR_W, op1_info, op2_info, 8, 8, NULL, NULL, NULL)) { + if (!zend_jit_fetch_dimension_address_inner(Dst, opline, BP_VAR_W, op1_info, op2_info, NULL, NULL, NULL)) { return 0; } @@ -5762,7 +5752,7 @@ static int zend_jit_assign_dim(dasm_State **Dst, const zend_op *opline, const ze var_info |= MAY_BE_RC1; } | // value = zend_assign_to_variable(variable_ptr, value, OP_DATA_TYPE); - if (!zend_jit_assign_to_variable(Dst, opline, op_array, var_addr, var_addr, var_info, -1, (opline+1)->op1_type, (opline+1)->op1, op3_addr, val_info, res_addr, 0)) { + if (!zend_jit_assign_to_variable(Dst, opline, var_addr, var_addr, var_info, -1, (opline+1)->op1_type, (opline+1)->op1, op3_addr, val_info, res_addr, 0)) { return 0; } } @@ -5844,7 +5834,7 @@ static int zend_jit_assign_dim(dasm_State **Dst, const zend_op *opline, const ze } #endif - | FREE_OP (opline+1)->op1_type, (opline+1)->op1, val_info, 0, op_array, opline + | FREE_OP (opline+1)->op1_type, (opline+1)->op1, val_info, 0, opline } if (op1_info & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_ARRAY)) { @@ -5863,7 +5853,7 @@ static int zend_jit_assign_dim(dasm_State **Dst, const zend_op *opline, const ze #endif |9: - | FREE_OP opline->op2_type, opline->op2, op2_info, 0, op_array, opline + | FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline if (may_throw) { zend_jit_check_exception(Dst); @@ -5872,7 +5862,7 @@ static int zend_jit_assign_dim(dasm_State **Dst, const zend_op *opline, const ze return 1; } -static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, uint32_t op1_def_info, zend_jit_addr op1_addr, uint32_t op2_info, uint32_t op1_data_info, zend_ssa_range *op1_data_range, int may_throw) +static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, uint32_t op1_def_info, zend_jit_addr op1_addr, uint32_t op2_info, uint32_t op1_data_info, zend_ssa_range *op1_data_range, int may_throw) { zend_jit_addr op2_addr, op3_addr, var_addr; @@ -5975,7 +5965,7 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, const var_info |= MAY_BE_RC1; } - if (!zend_jit_fetch_dimension_address_inner(Dst, opline, BP_VAR_RW, op1_info, op2_info, 8, 8, NULL, NULL, NULL)) { + if (!zend_jit_fetch_dimension_address_inner(Dst, opline, BP_VAR_RW, op1_info, op2_info, NULL, NULL, NULL)) { return 0; } @@ -6015,7 +6005,7 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, const case ZEND_SUB: case ZEND_MUL: case ZEND_DIV: - if (!zend_jit_math_helper(Dst, opline, opline->extended_value, op_array, IS_CV, opline->op1, var_addr, var_info, (opline+1)->op1_type, (opline+1)->op1, op3_addr, op1_data_info, 0, var_addr, var_def_info, var_info, + if (!zend_jit_math_helper(Dst, opline, opline->extended_value, IS_CV, opline->op1, var_addr, var_info, (opline+1)->op1_type, (opline+1)->op1, op3_addr, op1_data_info, 0, var_addr, var_def_info, var_info, 1 /* may overflow */, may_throw)) { return 0; } @@ -6026,7 +6016,7 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, const case ZEND_SL: case ZEND_SR: case ZEND_MOD: - if (!zend_jit_long_math_helper(Dst, opline, opline->extended_value, op_array, + if (!zend_jit_long_math_helper(Dst, opline, opline->extended_value, IS_CV, opline->op1, var_addr, var_info, NULL, (opline+1)->op1_type, (opline+1)->op1, op3_addr, op1_data_info, op1_data_range, @@ -6035,7 +6025,7 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, const } break; case ZEND_CONCAT: - if (!zend_jit_concat_helper(Dst, opline, op_array, IS_CV, opline->op1, var_addr, var_info, (opline+1)->op1_type, (opline+1)->op1, op3_addr, op1_data_info, var_addr, op1_def_info, + if (!zend_jit_concat_helper(Dst, opline, IS_CV, opline->op1, var_addr, var_info, (opline+1)->op1_type, (opline+1)->op1, op3_addr, op1_data_info, var_addr, may_throw)) { return 0; } @@ -6093,7 +6083,7 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, const return 1; } -static int zend_jit_assign_op(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, uint32_t op1_def_info, zend_ssa_range *op1_range, uint32_t op2_info, zend_ssa_range *op2_range, int may_overflow, int may_throw) +static int zend_jit_assign_op(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, uint32_t op1_def_info, zend_ssa_range *op1_range, uint32_t op2_info, zend_ssa_range *op2_range, int may_overflow, int may_throw) { zend_jit_addr op1_addr, op2_addr; @@ -6138,7 +6128,7 @@ static int zend_jit_assign_op(dasm_State **Dst, const zend_op *opline, const zen case ZEND_SUB: case ZEND_MUL: case ZEND_DIV: - result = zend_jit_math_helper(Dst, opline, opline->extended_value, op_array, opline->op1_type, opline->op1, op1_addr, op1_info, opline->op2_type, opline->op2, op2_addr, op2_info, opline->op1.var, op1_addr, op1_def_info, op1_info, may_overflow, may_throw); + result = zend_jit_math_helper(Dst, opline, opline->extended_value, opline->op1_type, opline->op1, op1_addr, op1_info, opline->op2_type, opline->op2, op2_addr, op2_info, opline->op1.var, op1_addr, op1_def_info, op1_info, may_overflow, may_throw); break; case ZEND_BW_OR: case ZEND_BW_AND: @@ -6146,13 +6136,13 @@ static int zend_jit_assign_op(dasm_State **Dst, const zend_op *opline, const zen case ZEND_SL: case ZEND_SR: case ZEND_MOD: - result = zend_jit_long_math_helper(Dst, opline, opline->extended_value, op_array, + result = zend_jit_long_math_helper(Dst, opline, opline->extended_value, opline->op1_type, opline->op1, op1_addr, op1_info, op1_range, opline->op2_type, opline->op2, op2_addr, op2_info, op2_range, opline->op1.var, op1_addr, op1_def_info, op1_info, may_throw); break; case ZEND_CONCAT: - result = zend_jit_concat_helper(Dst, opline, op_array, opline->op1_type, opline->op1, op1_addr, op1_info, opline->op2_type, opline->op2, op2_addr, op2_info, op1_addr, op1_def_info, may_throw); + result = zend_jit_concat_helper(Dst, opline, opline->op1_type, opline->op1, op1_addr, op1_info, opline->op2_type, opline->op2, op2_addr, op2_info, op1_addr, may_throw); break; default: ZEND_UNREACHABLE(); @@ -6928,7 +6918,7 @@ static int zend_jit_cmp_slow(dasm_State **Dst, const zend_op *opline, zend_jit_a return 1; } -static int zend_jit_cmp(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op2_info, zend_jit_addr op2_addr, zend_jit_addr res_addr, int may_throw, zend_uchar smart_branch_opcode, uint32_t target_label, uint32_t target_label2, const void *exit_addr) +static int zend_jit_cmp(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op2_info, zend_jit_addr op2_addr, zend_jit_addr res_addr, int may_throw, zend_uchar smart_branch_opcode, uint32_t target_label, uint32_t target_label2, const void *exit_addr) { zend_bool same_ops = (opline->op1_type == opline->op2_type) && (opline->op1.var == opline->op2.var); zend_bool has_slow; @@ -7133,9 +7123,9 @@ static int zend_jit_cmp(dasm_State **Dst, const zend_op *opline, const zend_op_a | add r4, 12 |.endif if (opline->opcode != ZEND_CASE) { - | FREE_OP opline->op1_type, opline->op1, op1_info, 0, op_array, opline + | FREE_OP opline->op1_type, opline->op1, op1_info, 0, opline } - | FREE_OP opline->op2_type, opline->op2, op2_info, 0, op_array, opline + | FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline if (may_throw) { zend_jit_check_exception_undef_result(Dst, opline); } @@ -7153,7 +7143,7 @@ static int zend_jit_cmp(dasm_State **Dst, const zend_op *opline, const zend_op_a return 1; } -static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op2_info, zend_jit_addr op2_addr, zend_jit_addr res_addr, int may_throw, zend_uchar smart_branch_opcode, uint32_t target_label, uint32_t target_label2, const void *exit_addr) +static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op2_info, zend_jit_addr op2_addr, zend_jit_addr res_addr, int may_throw, zend_uchar smart_branch_opcode, uint32_t target_label, uint32_t target_label2, const void *exit_addr) { uint32_t identical_label = (uint32_t)-1; uint32_t not_identical_label = (uint32_t)-1; @@ -7310,8 +7300,8 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, const zen ((opline->op2_type & (IS_VAR|IS_TMP_VAR)) && (op2_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)))) { | SAVE_VALID_OPLINE opline, r0 - | FREE_OP opline->op1_type, opline->op1, op1_info, 1, op_array, opline - | FREE_OP opline->op2_type, opline->op2, op2_info, 1, op_array, opline + | FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline + | FREE_OP opline->op2_type, opline->op2, op2_info, 1, opline } if (smart_branch_opcode) { zend_jit_check_exception_undef_result(Dst, opline); @@ -7375,7 +7365,7 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, const zen if (opline->op2_type == IS_VAR && (op2_info & MAY_BE_REF)) { | jne >8 | SAVE_VALID_OPLINE opline, r0 - | FREE_OP opline->op2_type, opline->op2, op2_info, 1, op_array, opline + | FREE_OP opline->op2_type, opline->op2, op2_info, 1, opline zend_jit_check_exception_undef_result(Dst, opline); if (exit_addr && smart_branch_opcode == ZEND_JMPNZ) { | jmp &exit_addr @@ -7405,7 +7395,7 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, const zen if ((opline->op2_type & (IS_VAR|IS_TMP_VAR)) && (op2_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF))) { | SAVE_VALID_OPLINE opline, r0 - | FREE_OP opline->op2_type, opline->op2, op2_info, 1, op_array, opline + | FREE_OP opline->op2_type, opline->op2, op2_info, 1, opline zend_jit_check_exception_undef_result(Dst, opline); } if (exit_addr) { @@ -7423,7 +7413,7 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, const zen if (opline->op1_type == IS_VAR && (op1_info & MAY_BE_REF)) { | jne >8 | SAVE_VALID_OPLINE opline, r0 - | FREE_OP opline->op1_type, opline->op1, op1_info, 1, op_array, opline + | FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline zend_jit_check_exception_undef_result(Dst, opline); if (exit_addr && smart_branch_opcode == ZEND_JMPNZ) { | jmp &exit_addr @@ -7453,7 +7443,7 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, const zen if ((opline->op1_type & (IS_VAR|IS_TMP_VAR)) && (op1_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF))) { | SAVE_VALID_OPLINE opline, r0 - | FREE_OP opline->op1_type, opline->op1, op1_info, 1, op_array, opline + | FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline zend_jit_check_exception_undef_result(Dst, opline); } if (smart_branch_opcode) { @@ -7479,8 +7469,8 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, const zen (op2_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)))) { | mov aword T1, r0 // save | SAVE_VALID_OPLINE opline, r0 - | FREE_OP opline->op1_type, opline->op1, op1_info, 1, op_array, opline - | FREE_OP opline->op2_type, opline->op2, op2_info, 1, op_array, opline + | FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline + | FREE_OP opline->op2_type, opline->op2, op2_info, 1, opline zend_jit_check_exception_undef_result(Dst, opline); | mov r0, aword T1 // restore } @@ -7519,7 +7509,7 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, const zen return 1; } -static int zend_jit_bool_jmpznz(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_jit_addr op1_addr, zend_jit_addr res_addr, uint32_t target_label, uint32_t target_label2, int may_throw, zend_uchar branch_opcode, const void *exit_addr) +static int zend_jit_bool_jmpznz(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_jit_addr op1_addr, zend_jit_addr res_addr, uint32_t target_label, uint32_t target_label2, int may_throw, zend_uchar branch_opcode, const void *exit_addr) { uint32_t true_label = -1; uint32_t false_label = -1; @@ -7984,7 +7974,7 @@ static int zend_jit_bool_jmpznz(dasm_State **Dst, const zend_op *opline, const z return 1; } -static int zend_jit_qm_assign(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_jit_addr op1_addr, zend_jit_addr op1_def_addr, uint32_t res_info, zend_jit_addr res_addr) +static int zend_jit_qm_assign(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_jit_addr op1_addr, zend_jit_addr op1_def_addr, uint32_t res_info, zend_jit_addr res_addr) { if (op1_addr != op1_def_addr) { if (!zend_jit_update_regs(Dst, op1_addr, op1_def_addr, op1_info)) { @@ -7995,7 +7985,7 @@ static int zend_jit_qm_assign(dasm_State **Dst, const zend_op *opline, const zen } } - if (!zend_jit_simple_assign(Dst, opline, op_array, res_addr, -1, -1, opline->op1_type, opline->op1, op1_addr, op1_info, 0, 0, 0)) { + if (!zend_jit_simple_assign(Dst, opline, res_addr, -1, -1, opline->op1_type, opline->op1, op1_addr, op1_info, 0, 0, 0)) { return 0; } if (!zend_jit_store_var_if_necessary(Dst, opline->result.var, res_addr, res_info)) { @@ -8004,7 +7994,7 @@ static int zend_jit_qm_assign(dasm_State **Dst, const zend_op *opline, const zen return 1; } -static int zend_jit_assign(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_jit_addr op1_use_addr, uint32_t op1_def_info, zend_jit_addr op1_addr, uint32_t op2_info, zend_jit_addr op2_addr, zend_jit_addr op2_def_addr, uint32_t res_info, zend_jit_addr res_addr, int may_throw) +static int zend_jit_assign(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_jit_addr op1_use_addr, uint32_t op1_def_info, zend_jit_addr op1_addr, uint32_t op2_info, zend_jit_addr op2_addr, zend_jit_addr op2_def_addr, uint32_t res_info, zend_jit_addr res_addr, int may_throw) { ZEND_ASSERT(opline->op1_type == IS_CV); @@ -8024,7 +8014,7 @@ static int zend_jit_assign(dasm_State **Dst, const zend_op *opline, const zend_o /* Force type update */ op1_info |= MAY_BE_UNDEF; } - if (!zend_jit_assign_to_variable(Dst, opline, op_array, op1_use_addr, op1_addr, op1_info, op1_def_info, opline->op2_type, opline->op2, op2_addr, op2_info, res_addr, + if (!zend_jit_assign_to_variable(Dst, opline, op1_use_addr, op1_addr, op1_info, op1_def_info, opline->op2_type, opline->op2, op2_addr, op2_info, res_addr, may_throw)) { return 0; } @@ -8040,7 +8030,7 @@ static int zend_jit_assign(dasm_State **Dst, const zend_op *opline, const zend_o return 1; } -static int zend_jit_push_call_frame(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, zend_function *func) +static int zend_jit_push_call_frame(dasm_State **Dst, const zend_op *opline, zend_function *func) { uint32_t used_stack; @@ -8081,7 +8071,7 @@ static int zend_jit_push_call_frame(dasm_State **Dst, const zend_op *opline, con } if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -8318,7 +8308,7 @@ static int zend_jit_needs_call_chain(zend_call_info *call_info, uint32_t b, cons } } -static int zend_jit_init_fcall_guard(dasm_State **Dst, const zend_op *opline, const zend_function *func, const zend_op *to_opline) +static int zend_jit_init_fcall_guard(dasm_State **Dst, const zend_function *func, const zend_op *to_opline) { int32_t exit_point; const void *exit_addr; @@ -8338,7 +8328,7 @@ static int zend_jit_init_fcall_guard(dasm_State **Dst, const zend_op *opline, co return 0; } - exit_point = zend_jit_trace_get_exit_point(opline, to_opline, NULL, ZEND_JIT_EXIT_POLYMORPHISM); + exit_point = zend_jit_trace_get_exit_point(to_opline, ZEND_JIT_EXIT_POLYMORPHISM); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { return 0; @@ -8465,7 +8455,7 @@ static int zend_jit_init_fcall(dasm_State **Dst, const zend_op *opline, uint32_t | mov r1, EX->run_time_cache | mov aword [r1 + opline->result.num], r0 if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, 0); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, 0); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -8516,7 +8506,7 @@ static int zend_jit_init_fcall(dasm_State **Dst, const zend_op *opline, uint32_t |3: } - if (!zend_jit_push_call_frame(Dst, opline, op_array, func)) { + if (!zend_jit_push_call_frame(Dst, opline, func)) { return 0; } @@ -8654,7 +8644,7 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend if (opline->opcode == ZEND_DO_FCALL) { if (!func) { if (trace) { - uint32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM); + uint32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -8972,7 +8962,7 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend if (opline->opcode == ZEND_DO_FCALL_BY_NAME) { if (!func) { if (trace) { - uint32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM); + uint32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -9020,7 +9010,7 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend | // EG(current_execute_data) = execute_data; | MEM_OP2_1_ZTS mov, aword, executor_globals, current_execute_data, RX, r1 - zend_jit_reset_opline(Dst, NULL); + zend_jit_reset_opline(); | // fbc->internal_function.handler(call, ret); | mov FCARG1a, RX @@ -9119,7 +9109,7 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend // TODO: Can we avoid checking for interrupts after each call ??? if (trace && last_valid_opline != opline) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline + 1, NULL, ZEND_JIT_EXIT_TO_VM); + int32_t exit_point = zend_jit_trace_get_exit_point(opline + 1, ZEND_JIT_EXIT_TO_VM); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -9148,7 +9138,7 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend return 1; } -static int zend_jit_send_val(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_jit_addr op1_addr) +static int zend_jit_send_val(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_jit_addr op1_addr) { uint32_t arg_num = opline->op2.num; zend_jit_addr arg_addr; @@ -9175,7 +9165,7 @@ static int zend_jit_send_val(dasm_State **Dst, const zend_op *opline, const zend return 0; } } else if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { return 0; @@ -9304,7 +9294,7 @@ static int zend_jit_send_ref(dasm_State **Dst, const zend_op *opline, const zend } |6: - | FREE_OP opline->op1_type, opline->op1, op1_info, !cold, op_array, opline + | FREE_OP opline->op1_type, opline->op1, op1_info, !cold, opline |7: return 1; @@ -9366,7 +9356,7 @@ static int zend_jit_send_var(dasm_State **Dst, const zend_op *opline, const zend /* Don't generate code that always throws exception */ return 0; } else { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { return 0; @@ -9396,7 +9386,7 @@ static int zend_jit_send_var(dasm_State **Dst, const zend_op *opline, const zend | test dword [r0 + offsetof(zend_function, quick_arg_flags)], mask | jnz >7 if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { return 0; @@ -9468,7 +9458,7 @@ static int zend_jit_send_var(dasm_State **Dst, const zend_op *opline, const zend | je >7 } if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { return 0; @@ -9533,7 +9523,7 @@ static int zend_jit_send_var(dasm_State **Dst, const zend_op *opline, const zend return 1; } -static int zend_jit_check_func_arg(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array) +static int zend_jit_check_func_arg(dasm_State **Dst, const zend_op *opline) { uint32_t arg_num = opline->op2.num; @@ -9642,7 +9632,7 @@ static int zend_jit_smart_false(dasm_State **Dst, const zend_op *opline, int jmp return 1; } -static int zend_jit_defined(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, zend_uchar smart_branch_opcode, uint32_t target_label, uint32_t target_label2, const void *exit_addr) +static int zend_jit_defined(dasm_State **Dst, const zend_op *opline, zend_uchar smart_branch_opcode, uint32_t target_label, uint32_t target_label2, const void *exit_addr) { uint32_t defined_label = (uint32_t)-1; uint32_t undefined_label = (uint32_t)-1; @@ -9738,7 +9728,7 @@ static int zend_jit_defined(dasm_State **Dst, const zend_op *opline, const zend_ return 1; } -static int zend_jit_type_check(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_uchar smart_branch_opcode, uint32_t target_label, uint32_t target_label2, const void *exit_addr) +static int zend_jit_type_check(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_uchar smart_branch_opcode, uint32_t target_label, uint32_t target_label2, const void *exit_addr) { uint32_t mask; zend_uchar type; @@ -9799,7 +9789,7 @@ static int zend_jit_type_check(dasm_State **Dst, const zend_op *opline, const ze } if (!(op1_info & MAY_BE_GUARD) && !(op1_info & (MAY_BE_ANY - mask))) { - | FREE_OP opline->op1_type, opline->op1, op1_info, 1, op_array, opline + | FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline if (exit_addr) { if (smart_branch_opcode == ZEND_JMPNZ) { | jmp &exit_addr @@ -9808,7 +9798,7 @@ static int zend_jit_type_check(dasm_State **Dst, const zend_op *opline, const ze return 0; } } else if (!(op1_info & MAY_BE_GUARD) && !(op1_info & mask)) { - | FREE_OP opline->op1_type, opline->op1, op1_info, 1, op_array, opline + | FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline if (exit_addr) { if (smart_branch_opcode == ZEND_JMPZ) { | jmp &exit_addr @@ -9896,7 +9886,7 @@ static int zend_jit_type_check(dasm_State **Dst, const zend_op *opline, const ze | movzx eax, al | add eax, 2 | SET_ZVAL_TYPE_INFO res_addr, eax - | FREE_OP opline->op1_type, opline->op1, op1_info, 1, op_array, opline + | FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline } } else { if (smart_branch_opcode && @@ -9971,7 +9961,7 @@ static int zend_jit_type_check(dasm_State **Dst, const zend_op *opline, const ze | movzx eax, al | add eax, 2 | SET_ZVAL_TYPE_INFO res_addr, eax - | FREE_OP opline->op1_type, opline->op1, op1_info, 1, op_array, opline + | FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline } } } @@ -9982,7 +9972,7 @@ static int zend_jit_type_check(dasm_State **Dst, const zend_op *opline, const ze return 1; } -static uint32_t zend_ssa_cv_info(const zend_op *opline, const zend_op_array *op_array, zend_ssa *ssa, uint32_t var) +static uint32_t zend_ssa_cv_info(const zend_op_array *op_array, zend_ssa *ssa, uint32_t var) { uint32_t j, info; @@ -10028,7 +10018,7 @@ static int zend_jit_leave_frame(dasm_State **Dst) return 1; } -static int zend_jit_free_cv(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t info, uint32_t var) +static int zend_jit_free_cv(dasm_State **Dst, uint32_t info, uint32_t var) { if (info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)) { uint32_t offset = EX_NUM_TO_VAR(var); @@ -10037,7 +10027,7 @@ static int zend_jit_free_cv(dasm_State **Dst, const zend_op *opline, const zend_ return 1; } -static int zend_jit_free_op(dasm_State **Dst, const zend_op *opline, /*const zend_op_array *op_array, */uint32_t info, uint32_t var_offset) +static int zend_jit_free_op(dasm_State **Dst, const zend_op *opline, uint32_t info, uint32_t var_offset) { if (info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)) { | ZVAL_PTR_DTOR ZEND_ADDR_MEM_ZVAL(ZREG_FP, var_offset), info, 0, 1, opline @@ -10045,7 +10035,7 @@ static int zend_jit_free_op(dasm_State **Dst, const zend_op *opline, /*const zen return 1; } -static int zend_jit_leave_func(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, zend_jit_trace_rec *trace, zend_jit_trace_info *trace_info, int may_throw) +static int zend_jit_leave_func(dasm_State **Dst, const zend_op_array *op_array, zend_jit_trace_rec *trace, zend_jit_trace_info *trace_info, int may_throw) { /* ZEND_CALL_FAKE_CLOSURE handled on slow path to eliminate check for ZEND_CALL_CLOSURE on fast path */ | mov FCARG1d, dword [FP + offsetof(zend_execute_data, This.u1.type_info)] @@ -10114,7 +10104,7 @@ static int zend_jit_leave_func(dasm_State **Dst, const zend_op *opline, const ze if (trace) { if (trace->op != ZEND_JIT_TRACE_END && (JIT_G(current_frame) && !TRACE_FRAME_IS_UNKNOWN_RETURN(JIT_G(current_frame)))) { - zend_jit_reset_opline(Dst, NULL); + zend_jit_reset_opline(); } else { | LOAD_OPLINE | ADD_IP sizeof(zend_op) @@ -10145,7 +10135,7 @@ static int zend_jit_leave_func(dasm_State **Dst, const zend_op *opline, const ze ZEND_ASSERT(next_opline != NULL); current_frame = JIT_G(current_frame); JIT_G(current_frame) = NULL; - exit_point = zend_jit_trace_get_exit_point(opline, NULL, trace, 0); + exit_point = zend_jit_trace_get_exit_point(NULL, 0); JIT_G(current_frame) = current_frame; exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -10441,7 +10431,7 @@ static zend_bool zend_jit_may_avoid_refcounting(const zend_op *opline) return 0; } -static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, zend_ssa *ssa, const zend_ssa_op *ssa_op, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op2_info, uint32_t res_info, zend_jit_addr res_addr, int may_throw) +static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, zend_ssa *ssa, const zend_ssa_op *ssa_op, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op2_info, uint32_t res_info, zend_jit_addr res_addr, int may_throw) { zend_jit_addr orig_op1_addr, op2_addr; const void *exit_addr = NULL; @@ -10453,7 +10443,7 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, cons if (opline->opcode != ZEND_FETCH_DIM_IS && JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { return 0; @@ -10494,7 +10484,7 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, cons old_info = STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var)); SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->result.var), IS_UNKNOWN); SET_STACK_REG(stack, EX_VAR_TO_NUM(opline->result.var), ZREG_ZVAL_COPY_R0); - exit_point = zend_jit_trace_get_exit_point(opline, opline+1, NULL, flags); + exit_point = zend_jit_trace_get_exit_point(opline+1, flags); SET_STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var), old_info); res_exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!res_exit_addr) { @@ -10509,7 +10499,7 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, cons old_info = STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var)); SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->result.var), IS_NULL); SET_STACK_REG(stack, EX_VAR_TO_NUM(opline->result.var), ZREG_NULL); - exit_point = zend_jit_trace_get_exit_point(opline, opline+1, NULL, flags); + exit_point = zend_jit_trace_get_exit_point(opline+1, flags); SET_STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var), old_info); not_found_exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!not_found_exit_addr) { @@ -10533,7 +10523,7 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, cons } } | GET_ZVAL_LVAL ZREG_FCARG1a, op1_addr - if (!zend_jit_fetch_dimension_address_inner(Dst, opline, (opline->opcode != ZEND_FETCH_DIM_IS) ? BP_VAR_R : BP_VAR_IS, op1_info, op2_info, 8, 9, NULL, not_found_exit_addr, exit_addr)) { + if (!zend_jit_fetch_dimension_address_inner(Dst, opline, (opline->opcode != ZEND_FETCH_DIM_IS) ? BP_VAR_R : BP_VAR_IS, op1_info, op2_info, NULL, not_found_exit_addr, exit_addr)) { return 0; } } @@ -10712,9 +10702,9 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, cons } #endif - | FREE_OP opline->op2_type, opline->op2, op2_info, 0, op_array, opline + | FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline if (!(op1_info & AVOID_REFCOUNTING)) { - | FREE_OP opline->op1_type, opline->op1, op1_info, 0, op_array, opline + | FREE_OP opline->op1_type, opline->op1, op1_info, 0, opline } if (may_throw) { @@ -10726,7 +10716,7 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, cons return 1; } -static int zend_jit_isset_isempty_dim(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op2_info, int may_throw, zend_uchar smart_branch_opcode, uint32_t target_label, uint32_t target_label2, const void *exit_addr) +static int zend_jit_isset_isempty_dim(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op2_info, int may_throw, zend_uchar smart_branch_opcode, uint32_t target_label, uint32_t target_label2, const void *exit_addr) { zend_jit_addr op2_addr, res_addr; @@ -10761,7 +10751,7 @@ static int zend_jit_isset_isempty_dim(dasm_State **Dst, const zend_op *opline, c not_found_exit_addr = exit_addr; } } - if (!zend_jit_fetch_dimension_address_inner(Dst, opline, BP_JIT_IS, op1_info, op2_info, 8, 9, found_exit_addr, not_found_exit_addr, NULL)) { + if (!zend_jit_fetch_dimension_address_inner(Dst, opline, BP_JIT_IS, op1_info, op2_info, found_exit_addr, not_found_exit_addr, NULL)) { return 0; } @@ -10820,9 +10810,9 @@ static int zend_jit_isset_isempty_dim(dasm_State **Dst, const zend_op *opline, c #endif |8: - | FREE_OP opline->op2_type, opline->op2, op2_info, 0, op_array, opline + | FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline if (!(op1_info & AVOID_REFCOUNTING)) { - | FREE_OP opline->op1_type, opline->op1, op1_info, 0, op_array, opline + | FREE_OP opline->op1_type, opline->op1, op1_info, 0, opline } if (may_throw) { if (!zend_jit_check_exception_undef_result(Dst, opline)) { @@ -10856,9 +10846,9 @@ static int zend_jit_isset_isempty_dim(dasm_State **Dst, const zend_op *opline, c } |9: // not found - | FREE_OP opline->op2_type, opline->op2, op2_info, 0, op_array, opline + | FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline if (!(op1_info & AVOID_REFCOUNTING)) { - | FREE_OP opline->op1_type, opline->op1, op1_info, 0, op_array, opline + | FREE_OP opline->op1_type, opline->op1, op1_info, 0, opline } if (may_throw) { if (!zend_jit_check_exception_undef_result(Dst, opline)) { @@ -10892,7 +10882,7 @@ static int zend_jit_isset_isempty_dim(dasm_State **Dst, const zend_op *opline, c return 1; } -static int zend_jit_bind_global(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info) +static int zend_jit_bind_global(dasm_State **Dst, const zend_op *opline, uint32_t op1_info) { zend_jit_addr op1_addr = OP1_ADDR(); zend_string *varname = Z_STR_P(RT_CONSTANT(opline, opline->op2)); @@ -11060,7 +11050,7 @@ static int zend_jit_recv(dasm_State **Dst, const zend_op *opline, const zend_op_ if (arg_info || (opline+1)->opcode != ZEND_RECV) { | cmp dword EX->This.u2.num_args, arg_num if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -11260,7 +11250,7 @@ static zend_bool zend_may_be_dynamic_property(zend_class_entry *ce, zend_string static int zend_jit_class_guard(dasm_State **Dst, const zend_op *opline, zend_class_entry *ce) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, 0); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, 0); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -11320,7 +11310,7 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen } if (op1_info & ((MAY_BE_UNDEF|MAY_BE_ANY)- MAY_BE_OBJECT)) { if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -11403,7 +11393,7 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen prop_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, prop_info->offset); | mov edx, dword [FCARG1a + prop_info->offset + 8] if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -11497,7 +11487,7 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen old_info = STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var)); SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->result.var), IS_UNKNOWN); SET_STACK_REG(stack, EX_VAR_TO_NUM(opline->result.var), ZREG_ZVAL_COPY_R0); - exit_point = zend_jit_trace_get_exit_point(opline, opline+1, NULL, flags); + exit_point = zend_jit_trace_get_exit_point(opline+1, flags); SET_STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var), old_info); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -11615,7 +11605,7 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen | EXT_CALL zend_jit_extract_helper, r0 |1: } else if (!(op1_info & AVOID_REFCOUNTING)) { - | FREE_OP opline->op1_type, opline->op1, op1_info, 1, op_array, opline + | FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline } } @@ -11635,7 +11625,7 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen return 1; } -static int zend_jit_free(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, int may_throw) +static int zend_jit_free(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, int may_throw) { zend_jit_addr op1_addr = OP1_ADDR(); @@ -11664,7 +11654,7 @@ static int zend_jit_free(dasm_State **Dst, const zend_op *opline, const zend_op_ return 1; } -static int zend_jit_echo(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info) +static int zend_jit_echo(dasm_State **Dst, const zend_op *opline, uint32_t op1_info) { if (opline->op1_type == IS_CONST) { zval *zv; @@ -11722,7 +11712,7 @@ static int zend_jit_echo(dasm_State **Dst, const zend_op *opline, const zend_op_ return 1; } -static int zend_jit_strlen(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info) +static int zend_jit_strlen(dasm_State **Dst, const zend_op *opline, uint32_t op1_info) { zend_jit_addr res_addr = RES_ADDR(); @@ -11771,7 +11761,7 @@ static int zend_jit_fetch_this(dasm_State **Dst, const zend_op *opline, const ze if (!JIT_G(current_frame) || !TRACE_FRAME_IS_THIS_CHECKED(JIT_G(current_frame))) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); | cmp byte EX->This.u1.v.type, IS_OBJECT @@ -11876,11 +11866,11 @@ static int zend_jit_switch(dasm_State **Dst, const zend_op *opline, const zend_o if (next_opline) { if (next_opline != opline + 1) { - exit_point = zend_jit_trace_get_exit_point(opline, opline + 1, NULL, 0); + exit_point = zend_jit_trace_get_exit_point(opline + 1, 0); fallback_label = zend_jit_trace_get_exit_addr(exit_point); } if (next_opline != default_opline) { - exit_point = zend_jit_trace_get_exit_point(opline, default_opline, NULL, 0); + exit_point = zend_jit_trace_get_exit_point(default_opline, 0); default_label = zend_jit_trace_get_exit_addr(exit_point); } } @@ -11964,7 +11954,7 @@ static int zend_jit_switch(dasm_State **Dst, const zend_op *opline, const zend_o } else if (next_opline == target) { | .aword >3 } else { - exit_point = zend_jit_trace_get_exit_point(opline, target, NULL, 0); + exit_point = zend_jit_trace_get_exit_point(target, 0); exit_addr = zend_jit_trace_get_exit_addr(exit_point); | .aword &exit_addr } @@ -12018,7 +12008,7 @@ static int zend_jit_switch(dasm_State **Dst, const zend_op *opline, const zend_o } else if (next_opline == target) { | .aword >3 } else { - exit_point = zend_jit_trace_get_exit_point(opline, target, NULL, 0); + exit_point = zend_jit_trace_get_exit_point(target, 0); exit_addr = zend_jit_trace_get_exit_addr(exit_point); | .aword &exit_addr } @@ -12103,7 +12093,7 @@ static int zend_jit_switch(dasm_State **Dst, const zend_op *opline, const zend_o } else if (next_opline == target) { | .aword >3 } else { - exit_point = zend_jit_trace_get_exit_point(opline, target, NULL, 0); + exit_point = zend_jit_trace_get_exit_point(target, 0); exit_addr = zend_jit_trace_get_exit_addr(exit_point); | .aword &exit_addr } @@ -12174,7 +12164,7 @@ static zend_bool zend_jit_verify_return_type(dasm_State **Dst, const zend_op *op return 1; } -static int zend_jit_isset_isempty_cv(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_jit_addr op1_addr, zend_uchar smart_branch_opcode, uint32_t target_label, uint32_t target_label2, const void *exit_addr) +static int zend_jit_isset_isempty_cv(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_jit_addr op1_addr, zend_uchar smart_branch_opcode, uint32_t target_label, uint32_t target_label2, const void *exit_addr) { zend_jit_addr res_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->result.var); @@ -12245,7 +12235,7 @@ static int zend_jit_isset_isempty_cv(dasm_State **Dst, const zend_op *opline, co static zend_bool zend_jit_noref_guard(dasm_State **Dst, const zend_op *opline, zend_jit_addr var_addr) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, 0); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, 0); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -12260,7 +12250,7 @@ static zend_bool zend_jit_fetch_reference(dasm_State **Dst, const zend_op *oplin { zend_jit_addr var_addr = *var_addr_ptr; uint32_t var_info = *var_info_ptr; - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, 0); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, 0); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -12301,7 +12291,7 @@ static zend_bool zend_jit_fetch_indirect_var(dasm_State **Dst, const zend_op *op { zend_jit_addr var_addr = *var_addr_ptr; uint32_t var_info = *var_info_ptr; - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, 0); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, 0); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -12317,7 +12307,7 @@ static zend_bool zend_jit_fetch_indirect_var(dasm_State **Dst, const zend_op *op if (!(var_type & IS_TRACE_REFERENCE) && var_type != IS_UNKNOWN && (var_info & (MAY_BE_ANY|MAY_BE_UNDEF)) != (1 << var_type)) { - exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, 0); + exit_point = zend_jit_trace_get_exit_point(opline, 0); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { From 35a3e450bc334fdf4b2f595cf8f01e5ec1b4b858 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 21 Aug 2020 01:57:03 +0300 Subject: [PATCH 033/170] Better registers usage --- ext/opcache/jit/zend_jit_x86.dasc | 152 +++++++++++++++++++----------- 1 file changed, 95 insertions(+), 57 deletions(-) diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index 121dd62719c8c..096d017840ebb 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -894,8 +894,8 @@ static void* dasm_labels[zend_lb_MAX]; || } | .if X64 || } else if (!IS_32BIT(zv)) { -| mov64 tmp_reg, ((uintptr_t)zv) -| SSE_AVX_INS movsd, vmovsd, xmm(dst_reg-ZREG_XMM0), qword [tmp_reg] +| mov64 Ra(tmp_reg), ((uintptr_t)zv) +| SSE_AVX_INS movsd, vmovsd, xmm(dst_reg-ZREG_XMM0), qword [Ra(tmp_reg)] | .endif || } else { | SSE_AVX_INS movsd, vmovsd, xmm(dst_reg-ZREG_XMM0), qword [((uint32_t)(uintptr_t)zv)] @@ -913,8 +913,8 @@ static void* dasm_labels[zend_lb_MAX]; || if (Z_MODE(dst_addr) == IS_REG) { | mov64 Ra(Z_REG(dst_addr)), ((uintptr_t)Z_LVAL_P(zv)) || } else { -| mov64 tmp_reg, ((uintptr_t)Z_LVAL_P(zv)) -| SET_ZVAL_LVAL dst_addr, tmp_reg +| mov64 Ra(tmp_reg), ((uintptr_t)Z_LVAL_P(zv)) +| SET_ZVAL_LVAL dst_addr, Ra(tmp_reg) || } || } else { | SET_ZVAL_LVAL dst_addr, Z_LVAL_P(zv) @@ -948,8 +948,8 @@ static void* dasm_labels[zend_lb_MAX]; || } | .if X64 || } else if (!IS_32BIT(zv)) { -| mov64 tmp_reg, ((uintptr_t)zv) -| SSE_AVX_INS movsd, vmovsd, xmm(dst_reg-ZREG_XMM0), qword [tmp_reg] +| mov64 Ra(tmp_reg), ((uintptr_t)zv) +| SSE_AVX_INS movsd, vmovsd, xmm(dst_reg-ZREG_XMM0), qword [Ra(tmp_reg)] | .endif || } else { | SSE_AVX_INS movsd, vmovsd, xmm(dst_reg-ZREG_XMM0), qword [((uint32_t)(uintptr_t)zv)] @@ -986,9 +986,9 @@ static void* dasm_labels[zend_lb_MAX]; | mov64 Ra(Z_REG(res_addr)), ((uintptr_t)Z_LVAL_P(zv)) | SET_ZVAL_LVAL dst_addr, Ra(Z_REG(res_addr)) || } else { -| mov64 tmp_reg, ((uintptr_t)Z_LVAL_P(zv)) -| SET_ZVAL_LVAL dst_addr, tmp_reg -| SET_ZVAL_LVAL res_addr, tmp_reg +| mov64 Ra(tmp_reg), ((uintptr_t)Z_LVAL_P(zv)) +| SET_ZVAL_LVAL dst_addr, Ra(tmp_reg) +| SET_ZVAL_LVAL res_addr, Ra(tmp_reg) || } || } else if (Z_MODE(dst_addr) == IS_REG) { | SET_ZVAL_LVAL dst_addr, Z_LVAL_P(zv) @@ -5367,20 +5367,28 @@ static int zend_jit_simple_assign(dasm_State **Dst, int save_r1) /* Labels: 1,2,3 */ { - ZEND_ASSERT(Z_MODE(var_addr) == IS_REG || Z_REG(var_addr) != ZREG_R0); + zend_reg tmp_reg; + + if (Z_MODE(var_addr) == IS_REG || Z_REG(var_addr) != ZREG_R0) { + tmp_reg = ZREG_R0; + } else { + /* ASSIGN_DIM */ + tmp_reg = ZREG_FCARG1a; + } + if (Z_MODE(val_addr) == IS_CONST_ZVAL) { zval *zv = Z_ZV(val_addr); if (!res_addr) { - | ZVAL_COPY_CONST var_addr, var_info, var_def_info, zv, r0 + | ZVAL_COPY_CONST var_addr, var_info, var_def_info, zv, tmp_reg } else { - | ZVAL_COPY_CONST_2 var_addr, res_addr, var_info, var_def_info, zv, r0 + | ZVAL_COPY_CONST_2 var_addr, res_addr, var_info, var_def_info, zv, tmp_reg } if (Z_REFCOUNTED_P(zv)) { if (!res_addr) { - | ADDREF_CONST zv, r0 + | ADDREF_CONST zv, Ra(tmp_reg) } else { - | ADDREF_CONST_2 zv, r0 + | ADDREF_CONST_2 zv, Ra(tmp_reg) } } } else { @@ -5400,7 +5408,7 @@ static int zend_jit_simple_assign(dasm_State **Dst, if (res_addr) { | SET_ZVAL_TYPE_INFO res_addr, IS_NULL } - | SAVE_VALID_OPLINE opline, r0 + | SAVE_VALID_OPLINE opline, Ra(tmp_reg) | mov FCARG1d, val.var | EXT_CALL zend_jit_undefined_op_helper, r0 if (save_r1) { @@ -5435,22 +5443,22 @@ static int zend_jit_simple_assign(dasm_State **Dst, | // ZVAL_COPY_VALUE(return_value, &ref->value); ref_addr = ZEND_ADDR_MEM_ZVAL(ZREG_R2, 8); if (!res_addr) { - | ZVAL_COPY_VALUE var_addr, var_info, ref_addr, val_info, ZREG_R2, ZREG_R0 + | ZVAL_COPY_VALUE var_addr, var_info, ref_addr, val_info, ZREG_R2, tmp_reg } else { - | ZVAL_COPY_VALUE_2 var_addr, var_info, res_addr, ref_addr, val_info, ZREG_R2, ZREG_R0 + | ZVAL_COPY_VALUE_2 var_addr, var_info, res_addr, ref_addr, val_info, ZREG_R2, tmp_reg } | je >2 | IF_NOT_REFCOUNTED dh, >3 if (!res_addr) { - | GC_ADDREF r0 + | GC_ADDREF Ra(tmp_reg) } else { - | add dword [r0], 2 + | add dword [Ra(tmp_reg)], 2 } | jmp >3 |2: if (res_addr) { | IF_NOT_REFCOUNTED dh, >2 - | GC_ADDREF r0 + | GC_ADDREF Ra(tmp_reg) |2: } if (save_r1) { @@ -5470,20 +5478,20 @@ static int zend_jit_simple_assign(dasm_State **Dst, } if (!res_addr) { - | ZVAL_COPY_VALUE var_addr, var_info, val_addr, val_info, ZREG_R2, ZREG_R0 + | ZVAL_COPY_VALUE var_addr, var_info, val_addr, val_info, ZREG_R2, tmp_reg } else { - | ZVAL_COPY_VALUE_2 var_addr, var_info, res_addr, val_addr, val_info, ZREG_R2, ZREG_R0 + | ZVAL_COPY_VALUE_2 var_addr, var_info, res_addr, val_addr, val_info, ZREG_R2, tmp_reg } if (val_type == IS_CV) { if (!res_addr) { - | TRY_ADDREF val_info, dh, r0 + | TRY_ADDREF val_info, dh, Ra(tmp_reg) } else { - | TRY_ADDREF_2 val_info, dh, r0 + | TRY_ADDREF_2 val_info, dh, Ra(tmp_reg) } } else { if (res_addr) { - | TRY_ADDREF val_info, dh, r0 + | TRY_ADDREF val_info, dh, Ra(tmp_reg) } } |3: @@ -5543,24 +5551,33 @@ static int zend_jit_assign_to_variable(dasm_State **Dst, /* Labels: 1,2,3,4,5,8 */ { int done = 0; + zend_reg ref_reg, tmp_reg; + + if (Z_MODE(var_addr) == IS_REG || Z_REG(var_use_addr) != ZREG_R0) { + ref_reg = ZREG_FCARG1a; + tmp_reg = ZREG_R0; + } else { + /* ASSIGN_DIM */ + ref_reg = ZREG_R0; + tmp_reg = ZREG_FCARG1a; + } if (var_info & MAY_BE_REF) { - if (Z_MODE(var_use_addr) != IS_MEM_ZVAL || Z_REG(var_use_addr) != ZREG_FCARG1a || Z_OFFSET(var_use_addr) != 0) { - | LOAD_ZVAL_ADDR FCARG1a, var_use_addr - var_addr = var_use_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, 0); + if (Z_MODE(var_use_addr) != IS_MEM_ZVAL || Z_REG(var_use_addr) != ref_reg || Z_OFFSET(var_use_addr) != 0) { + | LOAD_ZVAL_ADDR Ra(ref_reg), var_use_addr + var_addr = var_use_addr = ZEND_ADDR_MEM_ZVAL(ref_reg, 0); } | // if (Z_ISREF_P(variable_ptr)) { - | IF_NOT_Z_TYPE, FCARG1a, IS_REFERENCE, >1 + | IF_NOT_Z_TYPE, Ra(ref_reg), IS_REFERENCE, >1 | // if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(Z_REF_P(variable_ptr)))) { - | GET_Z_PTR FCARG1a, FCARG1a + | GET_Z_PTR FCARG1a, Ra(ref_reg) if (!zend_jit_assign_to_typed_ref(Dst, opline, val_type, val_addr, check_exception)) { return 0; } - | add FCARG1a, offsetof(zend_reference, val) + | lea Ra(ref_reg), [FCARG1a + offsetof(zend_reference, val)] |1: } if (var_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) { - ZEND_ASSERT(Z_REG(var_use_addr) != ZREG_R0); if (RC_MAY_BE_1(var_info)) { int in_cold = 0; @@ -5570,13 +5587,42 @@ static int zend_jit_assign_to_variable(dasm_State **Dst, |1: in_cold = 1; } - if (Z_REG(var_use_addr) == ZREG_FCARG1a) { - | GET_ZVAL_PTR r0, var_use_addr - | mov aword T1, r0 // save + if (Z_REG(var_use_addr) == ZREG_FCARG1a || Z_REG(var_use_addr) == ZREG_R0) { + zend_bool keep_gc = 0; + + | GET_ZVAL_PTR Ra(tmp_reg), var_use_addr + if (tmp_reg == ZREG_FCARG1a) { + if (Z_MODE(val_addr) == IS_REG) { + keep_gc = 1; + } else if ((val_info & ((MAY_BE_UNDEF|MAY_BE_ANY|MAY_BE_GUARD)-(MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE))) == 0) { + keep_gc = 1; + } else if (Z_MODE(val_addr) == IS_CONST_ZVAL) { + if (sizeof(void*) == 4) { + keep_gc = 1; + } else { + zval *zv = Z_ZV(val_addr); + + if (Z_TYPE_P(zv) == IS_DOUBLE) { + if (Z_DVAL_P(zv) == 0 || IS_32BIT(zv)) { + keep_gc = 1; + } + } else if (IS_SIGNED_32BIT(Z_LVAL_P(zv))) { + keep_gc = 1; + } + } + } else if (Z_MODE(val_addr) == IS_MEM_ZVAL) { + if ((val_info & (MAY_BE_UNDEF|MAY_BE_ANY|MAY_BE_GUARD)) == MAY_BE_DOUBLE) { + keep_gc = 1; + } + } + } + if (!keep_gc) { + | mov aword T1, Ra(tmp_reg) // save + } if (!zend_jit_simple_assign(Dst, opline, var_addr, var_info, var_def_info, val_type, val, val_addr, val_info, res_addr, in_cold, 0)) { return 0; } - if (Z_REG(var_use_addr) == ZREG_FCARG1a) { + if (!keep_gc) { | mov FCARG1a, aword T1 // restore } } else { @@ -5618,26 +5664,20 @@ static int zend_jit_assign_to_variable(dasm_State **Dst, if (var_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_OBJECT|MAY_BE_RESOURCE))) { | IF_NOT_ZVAL_REFCOUNTED var_use_addr, >5 } - | GET_ZVAL_PTR r0, var_use_addr - | GC_DELREF r0 if (var_info & (MAY_BE_ARRAY|MAY_BE_OBJECT)) { if (Z_REG(var_use_addr) == ZREG_FP) { - | GET_ZVAL_PTR FCARG1a, var_use_addr - | IF_GC_MAY_NOT_LEAK FCARG1a, >5 - } else if (Z_REG(var_use_addr) != ZREG_FCARG1a) { - | GET_ZVAL_PTR FCARG1a, var_use_addr - | IF_GC_MAY_NOT_LEAK FCARG1a, >5 - | mov T1, Ra(Z_REG(var_use_addr)) // save - } else { - | GET_ZVAL_PTR r0, var_use_addr - | IF_GC_MAY_NOT_LEAK r0, >5 | mov T1, Ra(Z_REG(var_use_addr)) // save - | GET_ZVAL_PTR FCARG1a, var_use_addr } + | GET_ZVAL_PTR FCARG1a, var_use_addr + | GC_DELREF FCARG1a + | IF_GC_MAY_NOT_LEAK FCARG1a, >5 | EXT_CALL gc_possible_root, r0 if (Z_REG(var_use_addr) != ZREG_FP) { | mov Ra(Z_REG(var_use_addr)), T1 // restore } + } else { + | GET_ZVAL_PTR Ra(tmp_reg), var_use_addr + | GC_DELREF Ra(tmp_reg) } |5: } @@ -5714,7 +5754,7 @@ static int zend_jit_assign_dim(dasm_State **Dst, const zend_op *opline, uint32_t |6: if (opline->op2_type == IS_UNUSED) { uint32_t var_info = MAY_BE_NULL; - zend_jit_addr var_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, 0); + zend_jit_addr var_addr = ZEND_ADDR_MEM_ZVAL(ZREG_R0, 0); | // var_ptr = zend_hash_next_index_insert(Z_ARRVAL_P(container), &EG(uninitialized_zval)); | LOAD_ADDR_ZTS FCARG2a, executor_globals, uninitialized_zval @@ -5729,28 +5769,26 @@ static int zend_jit_assign_dim(dasm_State **Dst, const zend_op *opline, uint32_t | //ZEND_VM_C_GOTO(assign_dim_op_ret_null); | jmp >9 |.code - | mov FCARG1a, r0 if (!zend_jit_simple_assign(Dst, opline, var_addr, var_info, -1, (opline+1)->op1_type, (opline+1)->op1, op3_addr, val_info, res_addr, 0, 0)) { return 0; } } else { uint32_t var_info = zend_array_element_type(op1_info, opline->op1_type, 0, 0); - zend_jit_addr var_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, 0); + zend_jit_addr var_addr = ZEND_ADDR_MEM_ZVAL(ZREG_R0, 0); if (!zend_jit_fetch_dimension_address_inner(Dst, opline, BP_VAR_W, op1_info, op2_info, NULL, NULL, NULL)) { return 0; } - |8: - | mov FCARG1a, r0 - if (op1_info & (MAY_BE_ARRAY_OF_REF|MAY_BE_OBJECT)) { var_info |= MAY_BE_REF; } if (var_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) { var_info |= MAY_BE_RC1; } + + |8: | // value = zend_assign_to_variable(variable_ptr, value, OP_DATA_TYPE); if (!zend_jit_assign_to_variable(Dst, opline, var_addr, var_addr, var_info, -1, (opline+1)->op1_type, (opline+1)->op1, op3_addr, val_info, res_addr, 0)) { return 0; @@ -9191,7 +9229,7 @@ static int zend_jit_send_val(dasm_State **Dst, const zend_op *opline, uint32_t o if (opline->op1_type == IS_CONST) { zval *zv = RT_CONSTANT(opline, opline->op1); - | ZVAL_COPY_CONST arg_addr, MAY_BE_ANY, MAY_BE_ANY, zv, r0 + | ZVAL_COPY_CONST arg_addr, MAY_BE_ANY, MAY_BE_ANY, zv, ZREG_R0 if (Z_REFCOUNTED_P(zv)) { | ADDREF_CONST zv, r0 } @@ -10297,7 +10335,7 @@ static int zend_jit_return(dasm_State **Dst, const zend_op *opline, const zend_o if (opline->op1_type == IS_CONST) { zval *zv = RT_CONSTANT(opline, opline->op1); - | ZVAL_COPY_CONST ret_addr, MAY_BE_ANY, MAY_BE_ANY, zv, r0 + | ZVAL_COPY_CONST ret_addr, MAY_BE_ANY, MAY_BE_ANY, zv, ZREG_R0 if (Z_REFCOUNTED_P(zv)) { | ADDREF_CONST zv, r0 } @@ -11102,7 +11140,7 @@ static int zend_jit_recv_init(dasm_State **Dst, const zend_op *opline, const zen | cmp dword EX->This.u2.num_args, arg_num | jae >5 } - | ZVAL_COPY_CONST res_addr, -1, -1, zv, r0 + | ZVAL_COPY_CONST res_addr, -1, -1, zv, ZREG_R0 if (Z_REFCOUNTED_P(zv)) { | ADDREF_CONST zv, r0 } From 8095a0ef7f9a78ccee408839c188a83ef69eb909 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 21 Aug 2020 09:50:28 +0300 Subject: [PATCH 034/170] Better register usage for ASSIGN_DIM_OP --- ext/opcache/jit/zend_jit_x86.dasc | 32 ++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index 096d017840ebb..49459267e7e24 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -3936,8 +3936,11 @@ static int zend_jit_math_long_long(dasm_State **Dst, result_reg = Z_REG(res_addr); } else if (Z_MODE(op1_addr) == IS_REG && Z_LAST_USE(op1_addr)) { result_reg = Z_REG(op1_addr); - } else { + } else if (Z_REG(res_addr) != ZREG_R0) { result_reg = ZREG_R0; + } else { + /* ASSIGN_DIM_OP */ + result_reg = ZREG_FCARG1a; } if (opcode == ZEND_MUL && @@ -4392,7 +4395,6 @@ static int zend_jit_math_helper(dasm_State **Dst, |.cold_code } |6: - | SAVE_VALID_OPLINE opline, r0 if (Z_MODE(res_addr) == IS_REG) { zend_jit_addr real_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, res_var); | LOAD_ZVAL_ADDR FCARG1a, real_addr @@ -4420,6 +4422,7 @@ static int zend_jit_math_helper(dasm_State **Dst, | sub r4, 12 | PUSH_ZVAL_ADDR op2_addr, r0 |.endif + | SAVE_VALID_OPLINE opline, r0 if (opcode == ZEND_ADD) { | EXT_CALL add_function, r0 } else if (opcode == ZEND_SUB) { @@ -4545,8 +4548,17 @@ static int zend_jit_long_math_helper(dasm_State **Dst, result_reg = Z_REG(res_addr); } else if (Z_MODE(op1_addr) == IS_REG && Z_LAST_USE(op1_addr)) { result_reg = Z_REG(op1_addr); - } else { + } else if (Z_REG(res_addr) != ZREG_R0) { result_reg = ZREG_R0; + } else { + /* ASSIGN_DIM_OP */ + if (sizeof(void*) == 4 + && (opcode == ZEND_SL || opcode == ZEND_SR) + && Z_MODE(op2_addr) != IS_CONST_ZVAL) { + result_reg = ZREG_R2; + } else { + result_reg = ZREG_FCARG1a; + } } if (opcode == ZEND_SL) { @@ -4716,7 +4728,6 @@ static int zend_jit_long_math_helper(dasm_State **Dst, |.cold_code } |6: - | SAVE_VALID_OPLINE opline, r0 if (Z_MODE(res_addr) == IS_REG) { zend_jit_addr real_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, res_var); | LOAD_ZVAL_ADDR FCARG1a, real_addr @@ -4744,6 +4755,7 @@ static int zend_jit_long_math_helper(dasm_State **Dst, | sub r4, 12 | PUSH_ZVAL_ADDR op2_addr, r0 |.endif + | SAVE_VALID_OPLINE opline, r0 if (opcode == ZEND_BW_OR) { | EXT_CALL bitwise_or_function, r0 } else if (opcode == ZEND_BW_AND) { @@ -4864,7 +4876,6 @@ static int zend_jit_concat_helper(dasm_State **Dst, |6: } #endif - | SAVE_VALID_OPLINE opline, r0 if (Z_REG(res_addr) != ZREG_FCARG1a || Z_OFFSET(res_addr) != 0) { | LOAD_ZVAL_ADDR FCARG1a, res_addr } @@ -4875,6 +4886,7 @@ static int zend_jit_concat_helper(dasm_State **Dst, | sub r4, 12 | PUSH_ZVAL_ADDR op2_addr, r0 |.endif + | SAVE_VALID_OPLINE opline, r0 | EXT_CALL concat_function, r0 |.if not(X64) | add r4, 12 @@ -5993,7 +6005,6 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, uint3 | //ZEND_VM_C_GOTO(assign_dim_op_ret_null); | jmp >9 |.code - | mov FCARG1a, r0 } else { var_info = zend_array_element_type(op1_info, opline->op1_type, 0, 0); if (op1_info & (MAY_BE_ARRAY_OF_REF|MAY_BE_OBJECT)) { @@ -6008,14 +6019,13 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, uint3 } |8: - | mov FCARG1a, r0 if (op1_info & (MAY_BE_ARRAY_OF_REF)) { binary_op_type binary_op = get_binary_op(opline->extended_value); - | IF_NOT_Z_TYPE, FCARG1a, IS_REFERENCE, >1 - | GET_Z_PTR FCARG1a, FCARG1a + | IF_NOT_Z_TYPE, r0, IS_REFERENCE, >1 + | GET_Z_PTR FCARG1a, r0 | cmp aword [FCARG1a + offsetof(zend_reference, sources.ptr)], 0 | jnz >2 - | add FCARG1a, offsetof(zend_reference, val) + | lea r0, aword [FCARG1a + offsetof(zend_reference, val)] |.cold_code |2: | LOAD_ZVAL_ADDR FCARG2a, op3_addr @@ -6037,7 +6047,7 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, uint3 } } - var_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, 0); + var_addr = ZEND_ADDR_MEM_ZVAL(ZREG_R0, 0); switch (opline->extended_value) { case ZEND_ADD: case ZEND_SUB: From ff66e4945ef1936a02ea149e03925a9e01b606e0 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Fri, 21 Aug 2020 17:46:16 +1000 Subject: [PATCH 035/170] OCI8 classes were already renamed in 8; this now follows the new-new standard --- UPGRADING | 3 + ext/oci8/oci8.c | 4 +- ext/oci8/oci8.stub.php | 96 +++++++-------- ext/oci8/oci8_arginfo.h | 188 ++++++++++++++--------------- ext/oci8/package.xml | 4 +- ext/oci8/tests/bug35973.phpt | 2 +- ext/oci8/tests/bug44008.phpt | 4 +- ext/oci8/tests/coll_001.phpt | 2 +- ext/oci8/tests/coll_002.phpt | 4 +- ext/oci8/tests/coll_002_func.phpt | 2 +- ext/oci8/tests/coll_003.phpt | 2 +- ext/oci8/tests/coll_009.phpt | 2 +- ext/oci8/tests/coll_016.phpt | 4 +- ext/oci8/tests/coll_019.phpt | 14 +-- ext/oci8/tests/define3.phpt | 4 +- ext/oci8/tests/descriptors.phpt | 2 +- ext/oci8/tests/fetch_object_2.phpt | 6 +- ext/oci8/tests/lob_001.phpt | Bin 2099 -> 2098 bytes ext/oci8/tests/lob_002.phpt | 2 +- ext/oci8/tests/lob_003.phpt | Bin 1656 -> 1652 bytes ext/oci8/tests/lob_004.phpt | 6 +- ext/oci8/tests/lob_005.phpt | 4 +- ext/oci8/tests/lob_006.phpt | Bin 1724 -> 1721 bytes ext/oci8/tests/lob_007.phpt | 6 +- ext/oci8/tests/lob_008.phpt | 6 +- ext/oci8/tests/lob_009.phpt | 6 +- ext/oci8/tests/lob_016.phpt | 4 +- ext/oci8/tests/lob_017.phpt | 4 +- ext/oci8/tests/lob_019.phpt | Bin 1576 -> 1573 bytes ext/oci8/tests/lob_020.phpt | Bin 2852 -> 2845 bytes ext/oci8/tests/lob_021.phpt | 2 +- ext/oci8/tests/lob_022.phpt | 2 +- ext/oci8/tests/lob_023.phpt | 6 +- ext/oci8/tests/lob_024.phpt | 6 +- ext/oci8/tests/lob_025.phpt | 4 +- ext/oci8/tests/lob_026.phpt | 6 +- ext/oci8/tests/lob_027.phpt | 10 +- ext/oci8/tests/lob_028.phpt | 12 +- ext/oci8/tests/lob_032.phpt | 2 +- ext/oci8/tests/lob_033.phpt | 2 +- ext/oci8/tests/lob_034.phpt | 2 +- ext/oci8/tests/lob_038.phpt | 12 +- ext/oci8/tests/lob_041.phpt | 4 +- ext/oci8/tests/lob_042.phpt | 14 +-- ext/oci8/tests/null_byte_1.phpt | 4 +- ext/oci8/tests/xmltype_02.phpt | 2 +- 46 files changed, 237 insertions(+), 234 deletions(-) diff --git a/UPGRADING b/UPGRADING index 54993d77a9713..9cb89cf9695f5 100644 --- a/UPGRADING +++ b/UPGRADING @@ -381,6 +381,9 @@ PHP 8.0 UPGRADE NOTES removed. - OCI8: + . The OCI-Lob class is now called OCILob, and the OCI-Collection class is now + called OCICollection for name compliance enforced by PHP 8 arginfo + type annotation tooling. . Several alias functions have been marked as deprecated. . oci_internal_debug() and its alias ociinternaldebug() have been removed. diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index 06ea6adcc797d..b83ec33f0404d 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -291,8 +291,8 @@ PHP_MINIT_FUNCTION(oci) le_descriptor = zend_register_list_destructors_ex(php_oci_descriptor_list_dtor, NULL, "oci8 descriptor", module_number); le_collection = zend_register_list_destructors_ex(php_oci_collection_list_dtor, NULL, "oci8 collection", module_number); - INIT_CLASS_ENTRY(oci_lob_class_entry, "OCI_Lob", class_OCI_Lob_methods); - INIT_CLASS_ENTRY(oci_coll_class_entry, "OCI_Collection", class_OCI_Collection_methods); + INIT_CLASS_ENTRY(oci_lob_class_entry, "OCILob", class_OCILob_methods); + INIT_CLASS_ENTRY(oci_coll_class_entry, "OCICollection", class_OCICollection_methods); oci_lob_class_entry_ptr = zend_register_internal_class(&oci_lob_class_entry); oci_coll_class_entry_ptr = zend_register_internal_class(&oci_coll_class_entry); diff --git a/ext/oci8/oci8.stub.php b/ext/oci8/oci8.stub.php index d53caed69b348..f73226bb53b1d 100644 --- a/ext/oci8/oci8.stub.php +++ b/ext/oci8/oci8.stub.php @@ -36,87 +36,87 @@ function ocibindbyname($statement_resource, string $column_name, &$variable, int */ function oci_bind_array_by_name($statement_resource, string $column_name, &$variable, int $maximum_array_length, int $maximum_item_length = -1, int $type = SQLT_AFC): bool {} -function oci_free_descriptor(OCI_Lob $lob_descriptor): bool {} +function oci_free_descriptor(OCILob $lob_descriptor): bool {} /** * @alias oci_free_descriptor * @deprecated */ -function ocifreedesc(OCI_Lob $lob_descriptor): bool {} +function ocifreedesc(OCILob $lob_descriptor): bool {} -function oci_lob_save(OCI_Lob $lob_descriptor, string $data, int $offset = 0): bool {} +function oci_lob_save(OCILob $lob_descriptor, string $data, int $offset = 0): bool {} /** * @alias oci_lob_save * @deprecated */ -function ocisavelob(OCI_Lob $lob_descriptor, string $data, int $offset = 0): bool {} +function ocisavelob(OCILob $lob_descriptor, string $data, int $offset = 0): bool {} -function oci_lob_import(OCI_Lob $lob_descriptor, string $filename): bool {} +function oci_lob_import(OCILob $lob_descriptor, string $filename): bool {} /** * @alias oci_lob_import * @deprecated */ -function ocisavelobfile(OCI_Lob $lob_descriptor, string $filename): bool {} +function ocisavelobfile(OCILob $lob_descriptor, string $filename): bool {} -function oci_lob_load(OCI_Lob $lob_descriptor): string|false {} +function oci_lob_load(OCILob $lob_descriptor): string|false {} /** * @alias oci_lob_load * @deprecated */ -function ociloadlob(OCI_Lob $lob_descriptor): string|false {} +function ociloadlob(OCILob $lob_descriptor): string|false {} -function oci_lob_read(OCI_Lob $lob_descriptor, int $length): string|false {} +function oci_lob_read(OCILob $lob_descriptor, int $length): string|false {} -function oci_lob_eof(OCI_Lob $lob_descriptor): bool {} +function oci_lob_eof(OCILob $lob_descriptor): bool {} -function oci_lob_tell(OCI_Lob $lob_descriptor): int|false {} +function oci_lob_tell(OCILob $lob_descriptor): int|false {} -function oci_lob_rewind(OCI_Lob $lob_descriptor): bool {} +function oci_lob_rewind(OCILob $lob_descriptor): bool {} -function oci_lob_seek(OCI_Lob $lob_descriptor, int $offset, int $whence = OCI_SEEK_SET): bool {} +function oci_lob_seek(OCILob $lob_descriptor, int $offset, int $whence = OCI_SEEK_SET): bool {} -function oci_lob_size(OCI_Lob $lob_descriptor): int|false {} +function oci_lob_size(OCILob $lob_descriptor): int|false {} -function oci_lob_write(OCI_Lob $lob_descriptor, string $string, int $length = UNKNOWN): int|false {} +function oci_lob_write(OCILob $lob_descriptor, string $string, int $length = UNKNOWN): int|false {} -function oci_lob_append(OCI_Lob $lob_descriptor_to, OCI_Lob $lob_descriptor_from): bool {} +function oci_lob_append(OCILob $lob_descriptor_to, OCILob $lob_descriptor_from): bool {} -function oci_lob_truncate(OCI_Lob $lob_descriptor, int $length = 0): bool {} +function oci_lob_truncate(OCILob $lob_descriptor, int $length = 0): bool {} -function oci_lob_erase(OCI_Lob $lob_descriptor, int $offset = UNKNOWN, int $length = UNKNOWN): int|false {} +function oci_lob_erase(OCILob $lob_descriptor, int $offset = UNKNOWN, int $length = UNKNOWN): int|false {} -function oci_lob_flush(OCI_Lob $lob_descriptor, int $flag = 0): bool {} +function oci_lob_flush(OCILob $lob_descriptor, int $flag = 0): bool {} -function ocisetbufferinglob(OCI_Lob $lob_descriptor, bool $mode): bool {} +function ocisetbufferinglob(OCILob $lob_descriptor, bool $mode): bool {} -function ocigetbufferinglob(OCI_Lob $lob_descriptor): bool {} +function ocigetbufferinglob(OCILob $lob_descriptor): bool {} -function oci_lob_copy(OCI_Lob $lob_descriptor_to, OCI_Lob $lob_descriptor_from, int $length = UNKNOWN): bool {} +function oci_lob_copy(OCILob $lob_descriptor_to, OCILob $lob_descriptor_from, int $length = UNKNOWN): bool {} -function oci_lob_is_equal(OCI_Lob $lob_descriptor_first, OCI_Lob $lob_descriptor_second): bool {} +function oci_lob_is_equal(OCILob $lob_descriptor_first, OCILob $lob_descriptor_second): bool {} -function oci_lob_export(OCI_Lob $lob_descriptor, string $path, int $start = UNKNOWN, int $length = UNKNOWN): bool {} +function oci_lob_export(OCILob $lob_descriptor, string $path, int $start = UNKNOWN, int $length = UNKNOWN): bool {} /** * @alias oci_lob_export * @deprecated */ -function ociwritelobtofile(OCI_Lob $lob_descriptor, string $path, int $start = UNKNOWN, int $length = UNKNOWN): bool {} +function ociwritelobtofile(OCILob $lob_descriptor, string $path, int $start = UNKNOWN, int $length = UNKNOWN): bool {} /** * @param resource $connection_resource */ -function oci_new_descriptor($connection_resource, int $type = OCI_DTYPE_LOB): ?OCI_Lob {} +function oci_new_descriptor($connection_resource, int $type = OCI_DTYPE_LOB): ?OCILob {} /** * @param resource $connection_resource * @alias oci_new_descriptor * @deprecated */ -function ocinewdescriptor($connection_resource, int $type = OCI_DTYPE_LOB): ?OCI_Lob {} +function ocinewdescriptor($connection_resource, int $type = OCI_DTYPE_LOB): ?OCILob {} /** * @param resource $connection_resource @@ -542,75 +542,75 @@ function oci_num_rows($statement_resource): int|false {} */ function ocirowcount($statement_resource): int|false {} -function oci_free_collection(OCI_Collection $collection): bool {} +function oci_free_collection(OCICollection $collection): bool {} /** * @alias oci_free_collection * @deprecated */ -function ocifreecollection(OCI_Collection $collection): bool {} +function ocifreecollection(OCICollection $collection): bool {} -function oci_collection_append(OCI_Collection $collection, string $value): bool {} +function oci_collection_append(OCICollection $collection, string $value): bool {} /** * @alias oci_collection_append * @deprecated */ -function ocicollappend(OCI_Collection $collection, string $value): bool {} +function ocicollappend(OCICollection $collection, string $value): bool {} -function oci_collection_element_get(OCI_Collection $collection, int $index): string|float|null|false {} +function oci_collection_element_get(OCICollection $collection, int $index): string|float|null|false {} /** * @alias oci_collection_element_get * @deprecated */ -function ocicollgetelem(OCI_Collection $collection, int $index): string|float|null|false {} +function ocicollgetelem(OCICollection $collection, int $index): string|float|null|false {} -function oci_collection_assign(OCI_Collection $collection_to, OCI_Collection $collection_from): bool {} +function oci_collection_assign(OCICollection $collection_to, OCICollection $collection_from): bool {} -function oci_collection_element_assign(OCI_Collection $collection, int $index, string $value): bool {} +function oci_collection_element_assign(OCICollection $collection, int $index, string $value): bool {} /** * @alias oci_collection_element_assign * @deprecated */ -function ocicollassignelem(OCI_Collection $collection, int $index, string $value): bool {} +function ocicollassignelem(OCICollection $collection, int $index, string $value): bool {} -function oci_collection_size(OCI_Collection $collection): int|false {} +function oci_collection_size(OCICollection $collection): int|false {} /** * @alias oci_collection_size * @deprecated */ -function ocicollsize(OCI_Collection $collection): int|false {} +function ocicollsize(OCICollection $collection): int|false {} -function oci_collection_max(OCI_Collection $collection): int|false {} +function oci_collection_max(OCICollection $collection): int|false {} /** * @alias oci_collection_max * @deprecated */ -function ocicollmax(OCI_Collection $collection): int|false {} +function ocicollmax(OCICollection $collection): int|false {} -function oci_collection_trim(OCI_Collection $collection, int $number): bool {} +function oci_collection_trim(OCICollection $collection, int $number): bool {} /** * @alias oci_collection_trim * @deprecated */ -function ocicolltrim(OCI_Collection $collection, int $number): bool {} +function ocicolltrim(OCICollection $collection, int $number): bool {} /** * @param resource $connection_resource */ -function oci_new_collection($connection_resource, string $type_name, string $schema_name = UNKNOWN): OCI_Collection|false {} +function oci_new_collection($connection_resource, string $type_name, string $schema_name = UNKNOWN): OCICollection|false {} /** * @param resource $connection_resource * @alias oci_new_collection * @deprecated */ -function ocinewcollection($connection_resource, string $type_name, string $schema_name = UNKNOWN): OCI_Collection|false {} +function ocinewcollection($connection_resource, string $type_name, string $schema_name = UNKNOWN): OCICollection|false {} /** * @param resource $connection_resource @@ -622,7 +622,7 @@ function oci_register_taf_callback($connection_resource, ?callable $function_nam */ function oci_unregister_taf_callback($connection_resource): bool {} -class OCI_Lob { +class OCILob { /** * @alias oci_lob_save * @return bool @@ -693,7 +693,7 @@ public function write(string $string, int $length = UNKNOWN) {} * @alias oci_lob_append * @return bool */ - public function append(OCI_Lob $lob_descriptor_from) {} + public function append(OCILob $lob_descriptor_from) {} /** * @alias oci_lob_truncate @@ -756,7 +756,7 @@ public function close() {} public function free() {} } -class OCI_Collection { +class OCICollection { /** * @alias oci_free_collection * @return bool @@ -779,7 +779,7 @@ public function getElem(int $index) {} * @alias oci_collection_assign * @return bool */ - public function assign(OCI_Collection $collection_from) {} + public function assign(OCICollection $collection_from) {} /** * @alias oci_collection_element_assign diff --git a/ext/oci8/oci8_arginfo.h b/ext/oci8/oci8_arginfo.h index c82656f205bc3..4ebacd5260fbe 100644 --- a/ext/oci8/oci8_arginfo.h +++ b/ext/oci8/oci8_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 4a4e86dc175542bbf0bc29c9a957c5dfec834f93 */ + * Stub hash: 1c1a73f6a4de5fa2ca9595125822d65bc4f5fc55 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_define_by_name, 0, 3, _IS_BOOL, 0) ZEND_ARG_INFO(0, statement_resource) @@ -30,13 +30,13 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_bind_array_by_name, 0, 4, _I ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_free_descriptor, 0, 1, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0) ZEND_END_ARG_INFO() #define arginfo_ocifreedesc arginfo_oci_free_descriptor ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_lob_save, 0, 2, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, offset, IS_LONG, 0, "0") ZEND_END_ARG_INFO() @@ -44,33 +44,33 @@ ZEND_END_ARG_INFO() #define arginfo_ocisavelob arginfo_oci_lob_save ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_lob_import, 0, 2, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) ZEND_END_ARG_INFO() #define arginfo_ocisavelobfile arginfo_oci_lob_import ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_oci_lob_load, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) - ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0) ZEND_END_ARG_INFO() #define arginfo_ociloadlob arginfo_oci_lob_load ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_oci_lob_read, 0, 2, MAY_BE_STRING|MAY_BE_FALSE) - ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0) ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0) ZEND_END_ARG_INFO() #define arginfo_oci_lob_eof arginfo_oci_free_descriptor ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_oci_lob_tell, 0, 1, MAY_BE_LONG|MAY_BE_FALSE) - ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0) ZEND_END_ARG_INFO() #define arginfo_oci_lob_rewind arginfo_oci_free_descriptor ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_lob_seek, 0, 2, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0) ZEND_ARG_TYPE_INFO(0, offset, IS_LONG, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, whence, IS_LONG, 0, "OCI_SEEK_SET") ZEND_END_ARG_INFO() @@ -78,52 +78,52 @@ ZEND_END_ARG_INFO() #define arginfo_oci_lob_size arginfo_oci_lob_tell ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_oci_lob_write, 0, 2, MAY_BE_LONG|MAY_BE_FALSE) - ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0) ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_lob_append, 0, 2, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor_to, OCI_Lob, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor_from, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor_to, OCILob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor_from, OCILob, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_lob_truncate, 0, 1, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 0, "0") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_oci_lob_erase, 0, 1, MAY_BE_LONG|MAY_BE_FALSE) - ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0) ZEND_ARG_TYPE_INFO(0, offset, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_lob_flush, 0, 1, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flag, IS_LONG, 0, "0") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ocisetbufferinglob, 0, 2, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0) ZEND_ARG_TYPE_INFO(0, mode, _IS_BOOL, 0) ZEND_END_ARG_INFO() #define arginfo_ocigetbufferinglob arginfo_oci_free_descriptor ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_lob_copy, 0, 2, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor_to, OCI_Lob, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor_from, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor_to, OCILob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor_from, OCILob, 0) ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_lob_is_equal, 0, 2, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor_first, OCI_Lob, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor_second, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor_first, OCILob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor_second, OCILob, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_lob_export, 0, 2, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0) ZEND_ARG_TYPE_INFO(0, path, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, start, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0) @@ -131,7 +131,7 @@ ZEND_END_ARG_INFO() #define arginfo_ociwritelobtofile arginfo_oci_lob_export -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_oci_new_descriptor, 0, 1, OCI_Lob, 1) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_oci_new_descriptor, 0, 1, OCILob, 1) ZEND_ARG_INFO(0, connection_resource) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, type, IS_LONG, 0, "OCI_DTYPE_LOB") ZEND_END_ARG_INFO() @@ -374,32 +374,32 @@ ZEND_END_ARG_INFO() #define arginfo_ocirowcount arginfo_oci_num_rows ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_free_collection, 0, 1, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, collection, OCI_Collection, 0) + ZEND_ARG_OBJ_INFO(0, collection, OCICollection, 0) ZEND_END_ARG_INFO() #define arginfo_ocifreecollection arginfo_oci_free_collection ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_collection_append, 0, 2, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, collection, OCI_Collection, 0) + ZEND_ARG_OBJ_INFO(0, collection, OCICollection, 0) ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0) ZEND_END_ARG_INFO() #define arginfo_ocicollappend arginfo_oci_collection_append ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_oci_collection_element_get, 0, 2, MAY_BE_STRING|MAY_BE_DOUBLE|MAY_BE_NULL|MAY_BE_FALSE) - ZEND_ARG_OBJ_INFO(0, collection, OCI_Collection, 0) + ZEND_ARG_OBJ_INFO(0, collection, OCICollection, 0) ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0) ZEND_END_ARG_INFO() #define arginfo_ocicollgetelem arginfo_oci_collection_element_get ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_collection_assign, 0, 2, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, collection_to, OCI_Collection, 0) - ZEND_ARG_OBJ_INFO(0, collection_from, OCI_Collection, 0) + ZEND_ARG_OBJ_INFO(0, collection_to, OCICollection, 0) + ZEND_ARG_OBJ_INFO(0, collection_from, OCICollection, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_collection_element_assign, 0, 3, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, collection, OCI_Collection, 0) + ZEND_ARG_OBJ_INFO(0, collection, OCICollection, 0) ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0) ZEND_END_ARG_INFO() @@ -407,7 +407,7 @@ ZEND_END_ARG_INFO() #define arginfo_ocicollassignelem arginfo_oci_collection_element_assign ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_oci_collection_size, 0, 1, MAY_BE_LONG|MAY_BE_FALSE) - ZEND_ARG_OBJ_INFO(0, collection, OCI_Collection, 0) + ZEND_ARG_OBJ_INFO(0, collection, OCICollection, 0) ZEND_END_ARG_INFO() #define arginfo_ocicollsize arginfo_oci_collection_size @@ -417,13 +417,13 @@ ZEND_END_ARG_INFO() #define arginfo_ocicollmax arginfo_oci_collection_size ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_collection_trim, 0, 2, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, collection, OCI_Collection, 0) + ZEND_ARG_OBJ_INFO(0, collection, OCICollection, 0) ZEND_ARG_TYPE_INFO(0, number, IS_LONG, 0) ZEND_END_ARG_INFO() #define arginfo_ocicolltrim arginfo_oci_collection_trim -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_oci_new_collection, 0, 2, OCI_Collection, MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_oci_new_collection, 0, 2, OCICollection, MAY_BE_FALSE) ZEND_ARG_INFO(0, connection_resource) ZEND_ARG_TYPE_INFO(0, type_name, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, schema_name, IS_STRING, 0) @@ -438,106 +438,106 @@ ZEND_END_ARG_INFO() #define arginfo_oci_unregister_taf_callback arginfo_oci_rollback -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Lob_save, 0, 0, 1) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCILob_save, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, offset, IS_LONG, 0, "0") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Lob_import, 0, 0, 1) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCILob_import, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) ZEND_END_ARG_INFO() -#define arginfo_class_OCI_Lob_savefile arginfo_class_OCI_Lob_import +#define arginfo_class_OCILob_savefile arginfo_class_OCILob_import -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Lob_load, 0, 0, 0) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCILob_load, 0, 0, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Lob_read, 0, 0, 1) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCILob_read, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0) ZEND_END_ARG_INFO() -#define arginfo_class_OCI_Lob_eof arginfo_class_OCI_Lob_load +#define arginfo_class_OCILob_eof arginfo_class_OCILob_load -#define arginfo_class_OCI_Lob_tell arginfo_class_OCI_Lob_load +#define arginfo_class_OCILob_tell arginfo_class_OCILob_load -#define arginfo_class_OCI_Lob_rewind arginfo_class_OCI_Lob_load +#define arginfo_class_OCILob_rewind arginfo_class_OCILob_load -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Lob_seek, 0, 0, 1) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCILob_seek, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, offset, IS_LONG, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, whence, IS_LONG, 0, "OCI_SEEK_SET") ZEND_END_ARG_INFO() -#define arginfo_class_OCI_Lob_size arginfo_class_OCI_Lob_load +#define arginfo_class_OCILob_size arginfo_class_OCILob_load -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Lob_write, 0, 0, 1) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCILob_write, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Lob_append, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, lob_descriptor_from, OCI_Lob, 0) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCILob_append, 0, 0, 1) + ZEND_ARG_OBJ_INFO(0, lob_descriptor_from, OCILob, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Lob_truncate, 0, 0, 0) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCILob_truncate, 0, 0, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 0, "0") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Lob_erase, 0, 0, 0) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCILob_erase, 0, 0, 0) ZEND_ARG_TYPE_INFO(0, offset, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_OCI_Lob_flush, 0, 0, _IS_BOOL, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_OCILob_flush, 0, 0, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flag, IS_LONG, 0, "0") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Lob_setbuffering, 0, 0, 1) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCILob_setbuffering, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, mode, _IS_BOOL, 0) ZEND_END_ARG_INFO() -#define arginfo_class_OCI_Lob_getbuffering arginfo_class_OCI_Lob_load +#define arginfo_class_OCILob_getbuffering arginfo_class_OCILob_load -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Lob_writetofile, 0, 0, 1) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCILob_writetofile, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, path, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, start, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0) ZEND_END_ARG_INFO() -#define arginfo_class_OCI_Lob_export arginfo_class_OCI_Lob_writetofile +#define arginfo_class_OCILob_export arginfo_class_OCILob_writetofile -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Lob_writetemporary, 0, 0, 1) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCILob_writetemporary, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, type, IS_LONG, 0, "OCI_TEMP_CLOB") ZEND_END_ARG_INFO() -#define arginfo_class_OCI_Lob_close arginfo_class_OCI_Lob_load +#define arginfo_class_OCILob_close arginfo_class_OCILob_load -#define arginfo_class_OCI_Lob_free arginfo_class_OCI_Lob_load +#define arginfo_class_OCILob_free arginfo_class_OCILob_load -#define arginfo_class_OCI_Collection_free arginfo_class_OCI_Lob_load +#define arginfo_class_OCICollection_free arginfo_class_OCILob_load -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Collection_append, 0, 0, 1) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCICollection_append, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Collection_getElem, 0, 0, 1) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCICollection_getElem, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Collection_assign, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, collection_from, OCI_Collection, 0) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCICollection_assign, 0, 0, 1) + ZEND_ARG_OBJ_INFO(0, collection_from, OCICollection, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Collection_assignelem, 0, 0, 2) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCICollection_assignelem, 0, 0, 2) ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0) ZEND_END_ARG_INFO() -#define arginfo_class_OCI_Collection_size arginfo_class_OCI_Lob_load +#define arginfo_class_OCICollection_size arginfo_class_OCILob_load -#define arginfo_class_OCI_Collection_max arginfo_class_OCI_Lob_load +#define arginfo_class_OCICollection_max arginfo_class_OCILob_load -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Collection_trim, 0, 0, 1) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCICollection_trim, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, number, IS_LONG, 0) ZEND_END_ARG_INFO() @@ -751,41 +751,41 @@ static const zend_function_entry ext_functions[] = { }; -static const zend_function_entry class_OCI_Lob_methods[] = { - ZEND_ME_MAPPING(save, oci_lob_save, arginfo_class_OCI_Lob_save, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(import, oci_lob_import, arginfo_class_OCI_Lob_import, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(savefile, oci_lob_import, arginfo_class_OCI_Lob_savefile, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(load, oci_lob_load, arginfo_class_OCI_Lob_load, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(read, oci_lob_read, arginfo_class_OCI_Lob_read, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(eof, oci_lob_eof, arginfo_class_OCI_Lob_eof, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(tell, oci_lob_tell, arginfo_class_OCI_Lob_tell, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(rewind, oci_lob_rewind, arginfo_class_OCI_Lob_rewind, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(seek, oci_lob_seek, arginfo_class_OCI_Lob_seek, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(size, oci_lob_size, arginfo_class_OCI_Lob_size, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(write, oci_lob_write, arginfo_class_OCI_Lob_write, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(append, oci_lob_append, arginfo_class_OCI_Lob_append, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(truncate, oci_lob_truncate, arginfo_class_OCI_Lob_truncate, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(erase, oci_lob_erase, arginfo_class_OCI_Lob_erase, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(flush, oci_lob_flush, arginfo_class_OCI_Lob_flush, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(setbuffering, ocisetbufferinglob, arginfo_class_OCI_Lob_setbuffering, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(getbuffering, ocigetbufferinglob, arginfo_class_OCI_Lob_getbuffering, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(writetofile, oci_lob_export, arginfo_class_OCI_Lob_writetofile, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(export, oci_lob_export, arginfo_class_OCI_Lob_export, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(writetemporary, oci_lob_write_temporary, arginfo_class_OCI_Lob_writetemporary, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(close, oci_lob_close, arginfo_class_OCI_Lob_close, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(free, oci_free_descriptor, arginfo_class_OCI_Lob_free, ZEND_ACC_PUBLIC) +static const zend_function_entry class_OCILob_methods[] = { + ZEND_ME_MAPPING(save, oci_lob_save, arginfo_class_OCILob_save, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(import, oci_lob_import, arginfo_class_OCILob_import, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(savefile, oci_lob_import, arginfo_class_OCILob_savefile, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(load, oci_lob_load, arginfo_class_OCILob_load, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(read, oci_lob_read, arginfo_class_OCILob_read, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(eof, oci_lob_eof, arginfo_class_OCILob_eof, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(tell, oci_lob_tell, arginfo_class_OCILob_tell, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(rewind, oci_lob_rewind, arginfo_class_OCILob_rewind, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(seek, oci_lob_seek, arginfo_class_OCILob_seek, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(size, oci_lob_size, arginfo_class_OCILob_size, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(write, oci_lob_write, arginfo_class_OCILob_write, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(append, oci_lob_append, arginfo_class_OCILob_append, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(truncate, oci_lob_truncate, arginfo_class_OCILob_truncate, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(erase, oci_lob_erase, arginfo_class_OCILob_erase, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(flush, oci_lob_flush, arginfo_class_OCILob_flush, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(setbuffering, ocisetbufferinglob, arginfo_class_OCILob_setbuffering, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(getbuffering, ocigetbufferinglob, arginfo_class_OCILob_getbuffering, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(writetofile, oci_lob_export, arginfo_class_OCILob_writetofile, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(export, oci_lob_export, arginfo_class_OCILob_export, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(writetemporary, oci_lob_write_temporary, arginfo_class_OCILob_writetemporary, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(close, oci_lob_close, arginfo_class_OCILob_close, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(free, oci_free_descriptor, arginfo_class_OCILob_free, ZEND_ACC_PUBLIC) ZEND_FE_END }; -static const zend_function_entry class_OCI_Collection_methods[] = { - ZEND_ME_MAPPING(free, oci_free_collection, arginfo_class_OCI_Collection_free, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(append, oci_collection_append, arginfo_class_OCI_Collection_append, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(getElem, oci_collection_element_get, arginfo_class_OCI_Collection_getElem, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(assign, oci_collection_assign, arginfo_class_OCI_Collection_assign, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(assignelem, oci_collection_element_assign, arginfo_class_OCI_Collection_assignelem, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(size, oci_collection_size, arginfo_class_OCI_Collection_size, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(max, oci_collection_max, arginfo_class_OCI_Collection_max, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(trim, oci_collection_trim, arginfo_class_OCI_Collection_trim, ZEND_ACC_PUBLIC) +static const zend_function_entry class_OCICollection_methods[] = { + ZEND_ME_MAPPING(free, oci_free_collection, arginfo_class_OCICollection_free, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(append, oci_collection_append, arginfo_class_OCICollection_append, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(getElem, oci_collection_element_get, arginfo_class_OCICollection_getElem, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(assign, oci_collection_assign, arginfo_class_OCICollection_assign, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(assignelem, oci_collection_element_assign, arginfo_class_OCICollection_assignelem, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(size, oci_collection_size, arginfo_class_OCICollection_size, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(max, oci_collection_max, arginfo_class_OCICollection_max, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(trim, oci_collection_trim, arginfo_class_OCICollection_trim, ZEND_ACC_PUBLIC) ZEND_FE_END }; diff --git a/ext/oci8/package.xml b/ext/oci8/package.xml index 930ccb25802fb..eb6007dca9feb 100644 --- a/ext/oci8/package.xml +++ b/ext/oci8/package.xml @@ -72,9 +72,9 @@ Oracle's standard cross-version connectivity applies. For example, PHP OCI8 lin Removed obsolete no-op function oci_internal_debug(). (Jens de Nies) - The OCI-Lob class is now called OCI_Lob. + The OCI-Lob class is now called OCILob for standards compliance. - The OCI-Collection calls is now called OCI_Collection. + The OCI-Collection class is now called OCICollection for standards compliance. Generate arginfo from function stubs. (Jens de Nies) diff --git a/ext/oci8/tests/bug35973.phpt b/ext/oci8/tests/bug35973.phpt index 2eec32db837b8..53c43d41d5070 100644 --- a/ext/oci8/tests/bug35973.phpt +++ b/ext/oci8/tests/bug35973.phpt @@ -36,7 +36,7 @@ echo "Done\n"; --EXPECTF-- array(1) { ["NC"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/bug44008.phpt b/ext/oci8/tests/bug44008.phpt index d8120325cfcc2..d3b9cafdd41a5 100644 --- a/ext/oci8/tests/bug44008.phpt +++ b/ext/oci8/tests/bug44008.phpt @@ -1,5 +1,5 @@ --TEST-- -Bug #44008 (Incorrect usage of OCI_Lob->close crashes PHP) +Bug #44008 (Incorrect usage of OCILob->close crashes PHP) --SKIPIF-- true, 'timesten' => false); // test runs on these DBs @@ -30,7 +30,7 @@ $r = $textLob->load(); echo "$r\n"; // Incorrectly closing the lob doesn't cause a crash. -// OCI-LOB->close() is documented for use only with OCI_Lob->writeTemporary() +// OCI-LOB->close() is documented for use only with OCILob->writeTemporary() $textLob->close(); // Cleanup diff --git a/ext/oci8/tests/coll_001.phpt b/ext/oci8/tests/coll_001.phpt index fdf17f1647c10..f4863013d51bc 100644 --- a/ext/oci8/tests/coll_001.phpt +++ b/ext/oci8/tests/coll_001.phpt @@ -20,7 +20,7 @@ require __DIR__."/drop_type.inc"; ?> --EXPECTF-- -object(OCI_Collection)#%d (1) { +object(OCICollection)#%d (1) { ["collection"]=> resource(%d) of type (oci8 collection) } diff --git a/ext/oci8/tests/coll_002.phpt b/ext/oci8/tests/coll_002.phpt index d466e8ee29e0f..2eabc209150b6 100644 --- a/ext/oci8/tests/coll_002.phpt +++ b/ext/oci8/tests/coll_002.phpt @@ -28,12 +28,12 @@ require __DIR__."/drop_type.inc"; ?> --EXPECTF-- -object(OCI_Collection)#%d (1) { +object(OCICollection)#%d (1) { ["collection"]=> resource(%d) of type (oci8 collection) } bool(true) -string(%d) "OCI_Collection::size(): supplied resource is not a valid oci8 collection resource" +string(%d) "OCICollection::size(): supplied resource is not a valid oci8 collection resource" Warning: oci_new_collection(): OCI-22303: type ""."NONEXISTENT" not found in %s on line %d bool(false) diff --git a/ext/oci8/tests/coll_002_func.phpt b/ext/oci8/tests/coll_002_func.phpt index 1cd6070d76934..0e931ddd4d796 100644 --- a/ext/oci8/tests/coll_002_func.phpt +++ b/ext/oci8/tests/coll_002_func.phpt @@ -27,7 +27,7 @@ require __DIR__."/drop_type.inc"; ?> --EXPECTF-- -object(OCI_Collection)#%d (1) { +object(OCICollection)#%d (1) { ["collection"]=> resource(%d) of type (oci8 collection) } diff --git a/ext/oci8/tests/coll_003.phpt b/ext/oci8/tests/coll_003.phpt index 1d47681fe7d7e..1608ee81fed05 100644 --- a/ext/oci8/tests/coll_003.phpt +++ b/ext/oci8/tests/coll_003.phpt @@ -29,7 +29,7 @@ require __DIR__."/drop_type.inc"; int(0) int(0) -Warning: OCI_Collection::trim(): OCI-22167: given trim size [3] must be less than or equal to [0] in %s on line %d +Warning: OCICollection::trim(): OCI-22167: given trim size [3] must be less than or equal to [0] in %s on line %d bool(false) bool(true) float(1) diff --git a/ext/oci8/tests/coll_009.phpt b/ext/oci8/tests/coll_009.phpt index c293a8d64ff9b..6f00f6d9c56bd 100644 --- a/ext/oci8/tests/coll_009.phpt +++ b/ext/oci8/tests/coll_009.phpt @@ -38,7 +38,7 @@ require __DIR__."/drop_type.inc"; ?> --EXPECTF-- -Warning: OCI_Collection::append(): OCI-01861: literal does not match format string in %s on line %d +Warning: OCICollection::append(): OCI-01861: literal does not match format string in %s on line %d bool(false) bool(true) bool(false) diff --git a/ext/oci8/tests/coll_016.phpt b/ext/oci8/tests/coll_016.phpt index 5eab7d4d23fd5..342af18f10193 100644 --- a/ext/oci8/tests/coll_016.phpt +++ b/ext/oci8/tests/coll_016.phpt @@ -40,10 +40,10 @@ require __DIR__."/drop_type.inc"; --EXPECTF-- bool(true) -Warning: OCI_Collection::assignelem(): OCI-22165: given index [%d] must be in the range of %s to [0] in %s on line %d +Warning: OCICollection::assignelem(): OCI-22165: given index [%d] must be in the range of %s to [0] in %s on line %d bool(false) -Warning: OCI_Collection::assignelem(): OCI-22165: given index [5000] must be in the range of %s to [0] in %s on line %d +Warning: OCICollection::assignelem(): OCI-22165: given index [5000] must be in the range of %s to [0] in %s on line %d bool(false) bool(false) bool(false) diff --git a/ext/oci8/tests/coll_019.phpt b/ext/oci8/tests/coll_019.phpt index 64b2bc31d6823..be79e98aab800 100644 --- a/ext/oci8/tests/coll_019.phpt +++ b/ext/oci8/tests/coll_019.phpt @@ -75,33 +75,33 @@ echo "Done\n"; --EXPECTF-- Test 0 -Notice: OCI_Collection::append(): Unknown or unsupported type of element: 113 in %s on line %d +Notice: OCICollection::append(): Unknown or unsupported type of element: 113 in %s on line %d bool(false) -Notice: OCI_Collection::assignelem(): Unknown or unsupported type of element: 113 in %s on line %d +Notice: OCICollection::assignelem(): Unknown or unsupported type of element: 113 in %s on line %d bool(false) bool(false) Test 1 -Warning: OCI_Collection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d +Warning: OCICollection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d bool(false) bool(false) Test 2 -Warning: OCI_Collection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d +Warning: OCICollection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d bool(false) bool(false) Test 3 -Warning: OCI_Collection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d +Warning: OCICollection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d bool(false) bool(false) Test 4 -Warning: OCI_Collection::append(): OCI-01840: input value not long enough for date format in %s on line %d +Warning: OCICollection::append(): OCI-01840: input value not long enough for date format in %s on line %d bool(false) -Warning: OCI_Collection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d +Warning: OCICollection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d bool(false) bool(false) Done diff --git a/ext/oci8/tests/define3.phpt b/ext/oci8/tests/define3.phpt index 520748f3d8245..69fb5a48c11f7 100644 --- a/ext/oci8/tests/define3.phpt +++ b/ext/oci8/tests/define3.phpt @@ -89,12 +89,12 @@ string(32) "614fcbba1effb7caa27ef0ef25c27fcf" string(32) "06d4f219d946c74d748d43932cd9dcb2" Test 1 bool(true) -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } file md5:614fcbba1effb7caa27ef0ef25c27fcf -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/descriptors.phpt b/ext/oci8/tests/descriptors.phpt index 8a5b42e791e0c..6b1e47d7a9f47 100644 --- a/ext/oci8/tests/descriptors.phpt +++ b/ext/oci8/tests/descriptors.phpt @@ -44,7 +44,7 @@ echo "Done\n"; --EXPECTF-- array(1) { ["BLOB"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/fetch_object_2.phpt b/ext/oci8/tests/fetch_object_2.phpt index 27f558e4b08e9..fcf80fd853364 100644 --- a/ext/oci8/tests/fetch_object_2.phpt +++ b/ext/oci8/tests/fetch_object_2.phpt @@ -69,7 +69,7 @@ object(stdClass)#%d (3) { ["COL1"]=> string(3) "123" ["COL2"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -80,7 +80,7 @@ object(stdClass)#%d (3) { ["COL1"]=> string(3) "456" ["COL2"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -91,7 +91,7 @@ object(stdClass)#%d (3) { ["COL1"]=> string(3) "789" ["COL2"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_001.phpt b/ext/oci8/tests/lob_001.phpt index 51e8c076732032120a0100e906b8832115733b5d..c94f5201e790ae173490f6d8ff86686860e455c9 100644 GIT binary patch delta 12 Tcmdliut{LUTDHyW*jgC@B3A^~ delta 14 VcmdlauvuWkS~kY`&1>0O838I}1vLNw diff --git a/ext/oci8/tests/lob_002.phpt b/ext/oci8/tests/lob_002.phpt index 78b10f21e057b..a4714caceaaae 100644 --- a/ext/oci8/tests/lob_002.phpt +++ b/ext/oci8/tests/lob_002.phpt @@ -52,7 +52,7 @@ oci8_test_sql_execute($c, $stmtarray); ?> --EXPECTF-- -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_003.phpt b/ext/oci8/tests/lob_003.phpt index fef078a26f589bc77bbabd00eb9853565314dffc..80bead5964bd291cbe7f9d8bb66d433ddb58daf4 100644 GIT binary patch delta 27 icmeyt^Mz-_43^0=S*A}mWX%TRpvmu9`6vHptpos}_6rRF delta 35 lcmeyu^Mhx@3>L=t$un4{14(_>Y%m!#`3);SkoB9j5&-H}41oXu diff --git a/ext/oci8/tests/lob_004.phpt b/ext/oci8/tests/lob_004.phpt index 4ff1a8b65ec26..ead1bc0e2ac8b 100644 --- a/ext/oci8/tests/lob_004.phpt +++ b/ext/oci8/tests/lob_004.phpt @@ -57,7 +57,7 @@ echo "Done\n"; ?> --EXPECTF-- -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -67,12 +67,12 @@ int(3) bool(true) array(2) { [0]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } ["BLOB"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_005.phpt b/ext/oci8/tests/lob_005.phpt index 317c8d5be9ff8..9e656bea7a23a 100644 --- a/ext/oci8/tests/lob_005.phpt +++ b/ext/oci8/tests/lob_005.phpt @@ -41,12 +41,12 @@ echo "Done\n"; --EXPECTF-- array(2) { [0]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } ["BLOB"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_006.phpt b/ext/oci8/tests/lob_006.phpt index 9f2c310fef5824710f5fe1d9cdbaf0a3b1699cc3..748283870a21bd07f29b1f4a1858f2732732acbf 100644 GIT binary patch delta 23 dcmdnPyOVc=9P4Cx)&-Lfux0~s(BwKcI{;_v2z&ql delta 29 gcmdnVyN7p!94lk|WI5IaKyn{zHkb^WT+L<&0FSr{lmGw# diff --git a/ext/oci8/tests/lob_007.phpt b/ext/oci8/tests/lob_007.phpt index fcf23472da6a6..3a3137ae03702 100644 --- a/ext/oci8/tests/lob_007.phpt +++ b/ext/oci8/tests/lob_007.phpt @@ -45,7 +45,7 @@ echo "Done\n"; ?> --EXPECTF-- -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -54,12 +54,12 @@ int(7000) int(7000) array(2) { [0]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } ["BLOB"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_008.phpt b/ext/oci8/tests/lob_008.phpt index 87257224b8fb8..15b300df86cf2 100644 --- a/ext/oci8/tests/lob_008.phpt +++ b/ext/oci8/tests/lob_008.phpt @@ -47,19 +47,19 @@ echo "Done\n"; ?> --EXPECTF-- -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } int(7000) array(2) { [0]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } ["BLOB"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_009.phpt b/ext/oci8/tests/lob_009.phpt index 872f94d4fa71d..5e0d2afaab49d 100644 --- a/ext/oci8/tests/lob_009.phpt +++ b/ext/oci8/tests/lob_009.phpt @@ -44,7 +44,7 @@ echo "Done\n"; ?> --EXPECTF-- -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -52,12 +52,12 @@ bool(true) bool(true) array(2) { [0]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } ["BLOB"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_016.phpt b/ext/oci8/tests/lob_016.phpt index 757224e0a54dc..24000f36f90d7 100644 --- a/ext/oci8/tests/lob_016.phpt +++ b/ext/oci8/tests/lob_016.phpt @@ -55,12 +55,12 @@ echo "Done\n"; --EXPECTF-- array(2) { ["LOB_1"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } ["LOB_2"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_017.phpt b/ext/oci8/tests/lob_017.phpt index 8e656f809d5e0..15c336c9d7761 100644 --- a/ext/oci8/tests/lob_017.phpt +++ b/ext/oci8/tests/lob_017.phpt @@ -57,12 +57,12 @@ echo "Done\n"; --EXPECTF-- array(2) { ["LOB_1"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } ["LOB_2"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_019.phpt b/ext/oci8/tests/lob_019.phpt index b41167b4e3ed32f2b9b1edb9f4bbf01a10174fcb..248bff70d59b1b0c455dc31abf5d2c7cdb73a33e 100644 GIT binary patch delta 23 dcmZ3%vy^AU2A0ViS*j=NvStHu(B#*wwg7Aq2$TQ- delta 29 gcmZ3=vw~;C1{TKn$s1UzfuuHTHkb^W{DRdM0G84TtN;K2 diff --git a/ext/oci8/tests/lob_020.phpt b/ext/oci8/tests/lob_020.phpt index 01db85a01fae3ca9f035bfedbebf9274e5083b01..affdef912634d259fff24e1f081288bad00c5ff5 100644 GIT binary patch delta 44 zcmZ1?Hdkx|3)^H?w(7}^Y}r5@G})fLVDbj`%*hWp;+g%OJtx<4ByE1c;lcy}R0R(~ delta 57 zcmbO$wnS_L3maqnWEQq+AX(3r4JLyo+pre^S!>ucf#gk&cou(W&-lsZ97&Avn{RTs GFaZGf5)r`w diff --git a/ext/oci8/tests/lob_021.phpt b/ext/oci8/tests/lob_021.phpt index 49dc1a7a9506c..0833715569a40 100644 --- a/ext/oci8/tests/lob_021.phpt +++ b/ext/oci8/tests/lob_021.phpt @@ -62,7 +62,7 @@ int(4) bool(true) int(4) bool(true) -string(%d) "OCI_Lob::write(): %s is not a valid oci8 descriptor resource" +string(%d) "OCILob::write(): %s is not a valid oci8 descriptor resource" string(%d) "oci_free_descriptor(): %s is not a valid oci8 descriptor resource" Warning: oci_free_descriptor(): Unable to find descriptor property in %s on line %d diff --git a/ext/oci8/tests/lob_022.phpt b/ext/oci8/tests/lob_022.phpt index 768dbe7ebfdb6..dba5adcbe36cd 100644 --- a/ext/oci8/tests/lob_022.phpt +++ b/ext/oci8/tests/lob_022.phpt @@ -67,7 +67,7 @@ echo "Done\n"; ?> --EXPECTF-- -Warning: OCI_Lob::save(): Offset parameter must be greater than or equal to 0 in %s on line %d +Warning: OCILob::save(): Offset parameter must be greater than or equal to 0 in %s on line %d string(4) "data" string(9) "long data" string(9) "long data" diff --git a/ext/oci8/tests/lob_023.phpt b/ext/oci8/tests/lob_023.phpt index 6eb1b85ac9af1..1c45e8d8d801a 100644 --- a/ext/oci8/tests/lob_023.phpt +++ b/ext/oci8/tests/lob_023.phpt @@ -47,7 +47,7 @@ echo "Done\n"; ?> --EXPECTF-- -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -59,12 +59,12 @@ Warning: oci_lob_import(): Unable to find descriptor property in %s on line %d bool(false) array(2) { [0]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } ["BLOB"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_024.phpt b/ext/oci8/tests/lob_024.phpt index 4ce0154c6450f..b4c44d6b7217e 100644 --- a/ext/oci8/tests/lob_024.phpt +++ b/ext/oci8/tests/lob_024.phpt @@ -47,7 +47,7 @@ echo "Done\n"; ?> --EXPECTF-- -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -56,12 +56,12 @@ int(7000) int(7000) array(2) { [0]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } ["BLOB"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_025.phpt b/ext/oci8/tests/lob_025.phpt index f4ee78c11b833..897e3c73742ad 100644 --- a/ext/oci8/tests/lob_025.phpt +++ b/ext/oci8/tests/lob_025.phpt @@ -52,12 +52,12 @@ int(7000) int(7000) array(2) { [0]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } ["BLOB"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_026.phpt b/ext/oci8/tests/lob_026.phpt index e1c624124a42b..ee52a9c816f0f 100644 --- a/ext/oci8/tests/lob_026.phpt +++ b/ext/oci8/tests/lob_026.phpt @@ -56,7 +56,7 @@ echo "Done\n"; ?> --EXPECTF-- -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -66,12 +66,12 @@ int(3) bool(true) array(2) { [0]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } ["BLOB"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_027.phpt b/ext/oci8/tests/lob_027.phpt index d3639ca2e4512..05390d1403df0 100644 --- a/ext/oci8/tests/lob_027.phpt +++ b/ext/oci8/tests/lob_027.phpt @@ -67,19 +67,19 @@ echo "Done\n"; ?> --EXPECTF-- -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } int(72) array(2) { [0]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } ["BLOB"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -96,11 +96,11 @@ string(10) "this is a " bool(true) string(0) "" -Warning: OCI_Lob::truncate(): Length must be greater than or equal to zero in %s on line %d +Warning: OCILob::truncate(): Length must be greater than or equal to zero in %s on line %d bool(false) string(0) "" -Warning: OCI_Lob::truncate(): Length must be greater than or equal to zero in %s on line %d +Warning: OCILob::truncate(): Length must be greater than or equal to zero in %s on line %d bool(false) bool(true) Done diff --git a/ext/oci8/tests/lob_028.phpt b/ext/oci8/tests/lob_028.phpt index b81c8179eb3ca..9d05f8c712365 100644 --- a/ext/oci8/tests/lob_028.phpt +++ b/ext/oci8/tests/lob_028.phpt @@ -48,27 +48,27 @@ echo "Done\n"; ?> --EXPECTF-- -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_032.phpt b/ext/oci8/tests/lob_032.phpt index ff1a7c840769d..6b66ae9cbe6c5 100644 --- a/ext/oci8/tests/lob_032.phpt +++ b/ext/oci8/tests/lob_032.phpt @@ -32,5 +32,5 @@ echo "Done\n"; ?> --EXPECTF-- -Warning: OCI_Lob::write(): ORA-22990: %s in %s on line 19 +Warning: OCILob::write(): ORA-22990: %s in %s on line 19 Done diff --git a/ext/oci8/tests/lob_033.phpt b/ext/oci8/tests/lob_033.phpt index 82fa51b6cf476..35f0f1275ebd0 100644 --- a/ext/oci8/tests/lob_033.phpt +++ b/ext/oci8/tests/lob_033.phpt @@ -35,7 +35,7 @@ echo "Done\n"; ?> --EXPECTF-- -Warning: OCI_Lob::save(): OCI_INVALID_HANDLE in %s on line %d +Warning: OCILob::save(): OCI_INVALID_HANDLE in %s on line %d bool(true) bool(true) Done diff --git a/ext/oci8/tests/lob_034.phpt b/ext/oci8/tests/lob_034.phpt index 511750eaf558f..b19b38dac71cb 100644 --- a/ext/oci8/tests/lob_034.phpt +++ b/ext/oci8/tests/lob_034.phpt @@ -48,6 +48,6 @@ bool(true) bool(true) bool(true) -Warning: OCI_Lob::flush(): Invalid flag value: -1 in %s on line %d +Warning: OCILob::flush(): Invalid flag value: -1 in %s on line %d bool(false) Done diff --git a/ext/oci8/tests/lob_038.phpt b/ext/oci8/tests/lob_038.phpt index 924e776200547..1ea912df92798 100644 --- a/ext/oci8/tests/lob_038.phpt +++ b/ext/oci8/tests/lob_038.phpt @@ -125,7 +125,7 @@ Test 1b bool(true) array(1) { ["CLOB"]=> - object(OCI_Lob)#2 (1) { + object(OCILob)#2 (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -133,7 +133,7 @@ array(1) { string(11) "clob test 1" array(1) { ["CLOB"]=> - object(OCI_Lob)#3 (1) { + object(OCILob)#3 (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -141,7 +141,7 @@ array(1) { string(11) "clob test 2" array(1) { ["CLOB"]=> - object(OCI_Lob)#2 (1) { + object(OCILob)#2 (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -167,7 +167,7 @@ Test 2b bool(true) array(1) { ["BLOB"]=> - object(OCI_Lob)#3 (1) { + object(OCILob)#3 (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -175,7 +175,7 @@ array(1) { string(11) "blob test 1" array(1) { ["BLOB"]=> - object(OCI_Lob)#4 (1) { + object(OCILob)#4 (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -183,7 +183,7 @@ array(1) { string(11) "blob test 2" array(1) { ["BLOB"]=> - object(OCI_Lob)#3 (1) { + object(OCILob)#3 (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_041.phpt b/ext/oci8/tests/lob_041.phpt index a81fc56da8c60..cc15989a2e0a2 100644 --- a/ext/oci8/tests/lob_041.phpt +++ b/ext/oci8/tests/lob_041.phpt @@ -69,7 +69,7 @@ test data Test 2 - implicit statement close test data -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (Unknown) } @@ -78,7 +78,7 @@ Test 3 - no preallocated descriptor test data array(1) { ["C1"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_042.phpt b/ext/oci8/tests/lob_042.phpt index e0393eeafb2a0..eb447f22afd80 100644 --- a/ext/oci8/tests/lob_042.phpt +++ b/ext/oci8/tests/lob_042.phpt @@ -44,29 +44,29 @@ echo "Done\n"; ?> --EXPECTF-- -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } -Warning: OCI_Lob::writetemporary(): Invalid temporary lob type: %d in %s on line %d +Warning: OCILob::writetemporary(): Invalid temporary lob type: %d in %s on line %d bool(false) int(6) bool(true) bool(true) -Warning: OCI_Lob::truncate(): Size must be less than or equal to the current LOB size in %s on line %d +Warning: OCILob::truncate(): Size must be less than or equal to the current LOB size in %s on line %d bool(false) -Warning: OCI_Lob::truncate(): Length must be greater than or equal to zero in %s on line %d +Warning: OCILob::truncate(): Length must be greater than or equal to zero in %s on line %d bool(false) -Warning: OCI_Lob::read(): Offset must be less than size of the LOB in %s on line %d +Warning: OCILob::read(): Offset must be less than size of the LOB in %s on line %d bool(false) -Warning: OCI_Lob::import(): Can't open file %s in %s on line %d +Warning: OCILob::import(): Can't open file %s in %s on line %d bool(false) -Warning: OCI_Lob::savefile(): Can't open file %s in %s on line %d +Warning: OCILob::savefile(): Can't open file %s in %s on line %d bool(false) Done diff --git a/ext/oci8/tests/null_byte_1.phpt b/ext/oci8/tests/null_byte_1.phpt index 50cc9fb5d65cb..06abe04957a29 100644 --- a/ext/oci8/tests/null_byte_1.phpt +++ b/ext/oci8/tests/null_byte_1.phpt @@ -35,9 +35,9 @@ var_dump($r); --EXPECTF-- Test 1: Import -Warning: OCI_Lob::savefile(): Argument #1 ($function) must be a valid path, string given in %snull_byte_1.php on line %d +Warning: OCILob::savefile(): Argument #1 ($function) must be a valid path, string given in %snull_byte_1.php on line %d NULL Test 2: Export -Warning: OCI_Lob::export(): Argument #1 ($function) must be a valid path, string given in %snull_byte_1.php on line %d +Warning: OCILob::export(): Argument #1 ($function) must be a valid path, string given in %snull_byte_1.php on line %d NULL diff --git a/ext/oci8/tests/xmltype_02.phpt b/ext/oci8/tests/xmltype_02.phpt index 6294c1783126b..962c4c5697433 100644 --- a/ext/oci8/tests/xmltype_02.phpt +++ b/ext/oci8/tests/xmltype_02.phpt @@ -111,7 +111,7 @@ oci8_test_sql_execute($c, $stmtarray); Test 1 Insert new XML data using a temporary CLOB array(1) { [0]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } From 8c57474e35fa1ae9c256ac224ea646673c9d404c Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Fri, 21 Aug 2020 14:41:35 +0200 Subject: [PATCH 036/170] ensure installed ini don't interfere --- sapi/cli/tests/bug62294.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sapi/cli/tests/bug62294.phpt b/sapi/cli/tests/bug62294.phpt index b300729939f07..04d0d8b60e4d7 100644 --- a/sapi/cli/tests/bug62294.phpt +++ b/sapi/cli/tests/bug62294.phpt @@ -4,7 +4,7 @@ Bug #62294: register_shutdown_function() does not handle exit code correctly From 46d62e5464ece54066ae36b3fc567f0c5eb41640 Mon Sep 17 00:00:00 2001 From: Manuel Mausz Date: Fri, 21 Aug 2020 11:53:40 +0000 Subject: [PATCH 037/170] Fix wrong datatype ini_entry->modifiable is of type uint8_t and so should be the temp. variable. Especially important after 4b77a158. Closes GH-6028 --- Zend/zend_ini.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_ini.c b/Zend/zend_ini.c index b8185950ae235..afc8f24e62569 100644 --- a/Zend/zend_ini.c +++ b/Zend/zend_ini.c @@ -334,7 +334,7 @@ ZEND_API int zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, { zend_ini_entry *ini_entry; zend_string *duplicate; - zend_bool modifiable; + uint8_t modifiable; zend_bool modified; if ((ini_entry = zend_hash_find_ptr(EG(ini_directives), name)) == NULL) { From 1b21b560741373638b8d1ffe2a4a672717cb6656 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 15 Aug 2020 14:11:51 +0100 Subject: [PATCH 038/170] sqlite3 linkage issue on some systems/package combination fix. Checking the version is not enough, the function might be available but the symbols are not present still. Closes GH-5993 --- ext/sqlite3/config.w32 | 1 + ext/sqlite3/config0.m4 | 4 ++++ ext/sqlite3/sqlite3.c | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ext/sqlite3/config.w32 b/ext/sqlite3/config.w32 index 41eccb5af94ea..ab54989e1c403 100644 --- a/ext/sqlite3/config.w32 +++ b/ext/sqlite3/config.w32 @@ -8,6 +8,7 @@ if (PHP_SQLITE3 != "no") { AC_DEFINE("HAVE_SQLITE3", 1, "SQLite support"); AC_DEFINE("HAVE_SQLITE3_ERRSTR", 1, "have sqlite3_errstr function"); + AC_DEFINE("HAVE_SQLITE3_EXPANDED_SQL", 1, "have sqlite3_expanded_sql function"); } else { WARNING("sqlite3 not enabled; libraries and/or headers not found"); } diff --git a/ext/sqlite3/config0.m4 b/ext/sqlite3/config0.m4 index 0d607593b742b..e83ec5f224fca 100644 --- a/ext/sqlite3/config0.m4 +++ b/ext/sqlite3/config0.m4 @@ -15,6 +15,10 @@ if test $PHP_SQLITE3 != "no"; then AC_DEFINE(HAVE_SQLITE3_ERRSTR, 1, [have sqlite3_errstr function]) ], [], [$SQLITE3_SHARED_LIBADD]) + PHP_CHECK_LIBRARY(sqlite3, sqlite3_expanded_sql, [ + AC_DEFINE(HAVE_SQLITE3_EXPANDED_SQL, 1, [have sqlite3_expanded_sql function]) + ], [], [$SQLITE3_SHARED_LIBADD]) + PHP_CHECK_LIBRARY(sqlite3,sqlite3_load_extension, [], [AC_DEFINE(SQLITE_OMIT_LOAD_EXTENSION, 1, [have sqlite3 with extension support])], diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 80f57a450868c..f4d8066ac8913 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -1651,7 +1651,7 @@ PHP_METHOD(sqlite3stmt, getSQL) } if (expanded) { -#if SQLITE_VERSION_NUMBER >= 3014000 +#ifdef HAVE_SQLITE3_EXPANDED_SQL char *sql = sqlite3_expanded_sql(stmt_obj->stmt); RETVAL_STRING(sql); sqlite3_free(sql); From f32653accc0fc2401aca91f9590272b8d95ef426 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Thu, 13 Aug 2020 09:40:24 +0000 Subject: [PATCH 039/170] fileinfo build fix proposal for haiku. Haiku already defines a unichar type and different than the fileinfo's anyway. Closed GH-5983 --- ext/fileinfo/libmagic.patch | 265 ++++++++++++++++++++++++++++--- ext/fileinfo/libmagic/ascmagic.c | 8 +- ext/fileinfo/libmagic/encoding.c | 60 +++---- ext/fileinfo/libmagic/file.h | 8 +- 4 files changed, 278 insertions(+), 63 deletions(-) diff --git a/ext/fileinfo/libmagic.patch b/ext/fileinfo/libmagic.patch index 5eac52463428a..e2d4fcc0092dc 100644 --- a/ext/fileinfo/libmagic.patch +++ b/ext/fileinfo/libmagic.patch @@ -1,6 +1,6 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c --- libmagic.orig/apprentice.c 2019-02-20 03:35:27.000000000 +0100 -+++ libmagic/apprentice.c 2020-04-07 22:25:10.486120900 +0200 ++++ libmagic/apprentice.c 2020-08-21 15:28:20.802569900 +0200 @@ -29,6 +29,8 @@ * apprentice - make one pass through /etc/magic, learning its secrets. */ @@ -974,8 +974,26 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c } diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c --- libmagic.orig/ascmagic.c 2019-05-07 04:27:11.000000000 +0200 -+++ libmagic/ascmagic.c 2020-04-07 22:25:10.501740300 +0200 -@@ -96,7 +96,7 @@ ++++ libmagic/ascmagic.c 2020-08-21 16:09:54.656316500 +0200 +@@ -51,7 +51,7 @@ + #define ISSPC(x) ((x) == ' ' || (x) == '\t' || (x) == '\r' || (x) == '\n' \ + || (x) == 0x85 || (x) == '\f') + +-private unsigned char *encode_utf8(unsigned char *, size_t, unichar *, size_t); ++private unsigned char *encode_utf8(unsigned char *, size_t, unicodechar *, size_t); + private size_t trim_nuls(const unsigned char *, size_t); + + /* +@@ -70,7 +70,7 @@ + protected int + file_ascmagic(struct magic_set *ms, const struct buffer *b, int text) + { +- unichar *ubuf = NULL; ++ unicodechar *ubuf = NULL; + size_t ulen = 0; + int rv = 1; + struct buffer bb; +@@ -96,14 +96,14 @@ rv = file_ascmagic_with_encoding(ms, &bb, ubuf, ulen, code, type, text); @@ -984,6 +1002,14 @@ diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c return rv; } + + protected int + file_ascmagic_with_encoding(struct magic_set *ms, +- const struct buffer *b, unichar *ubuf, size_t ulen, const char *code, ++ const struct buffer *b, unicodechar *ubuf, size_t ulen, const char *code, + const char *type, int text) + { + struct buffer bb; @@ -144,7 +144,7 @@ /* malloc size is a conservative overestimate; could be improved, or at least realloced after conversion. */ @@ -1003,9 +1029,18 @@ diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c return rv; } +@@ -337,7 +338,7 @@ + * after end of string, or NULL if an invalid character is found. + */ + private unsigned char * +-encode_utf8(unsigned char *buf, size_t len, unichar *ubuf, size_t ulen) ++encode_utf8(unsigned char *buf, size_t len, unicodechar *ubuf, size_t ulen) + { + size_t i; + unsigned char *end = buf + len; diff -u libmagic.orig/buffer.c libmagic/buffer.c --- libmagic.orig/buffer.c 2019-05-07 04:27:11.000000000 +0200 -+++ libmagic/buffer.c 2020-04-07 22:25:10.501740300 +0200 ++++ libmagic/buffer.c 2020-08-21 15:28:20.802569900 +0200 @@ -31,19 +31,23 @@ #endif /* lint */ @@ -1062,7 +1097,7 @@ diff -u libmagic.orig/buffer.c libmagic/buffer.c diff -u libmagic.orig/cdf.c libmagic/cdf.c --- libmagic.orig/cdf.c 2019-02-20 03:35:27.000000000 +0100 -+++ libmagic/cdf.c 2020-05-05 20:05:37.698461100 +0200 ++++ libmagic/cdf.c 2020-08-21 15:28:20.802569900 +0200 @@ -43,7 +43,17 @@ #include #endif @@ -1341,7 +1376,7 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c #endif diff -u libmagic.orig/cdf.h libmagic/cdf.h --- libmagic.orig/cdf.h 2019-02-20 02:24:19.000000000 +0100 -+++ libmagic/cdf.h 2020-04-07 22:25:10.517321000 +0200 ++++ libmagic/cdf.h 2020-08-21 15:28:20.802569900 +0200 @@ -35,10 +35,10 @@ #ifndef _H_CDF_ #define _H_CDF_ @@ -1366,7 +1401,7 @@ diff -u libmagic.orig/cdf.h libmagic/cdf.h #define CDF_SECID_FREE -1 diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c --- libmagic.orig/cdf_time.c 2019-03-12 21:43:05.000000000 +0100 -+++ libmagic/cdf_time.c 2020-04-07 22:25:10.517321000 +0200 ++++ libmagic/cdf_time.c 2020-08-21 15:28:20.802569900 +0200 @@ -23,6 +23,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. @@ -1395,7 +1430,7 @@ diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c (void)snprintf(buf, 26, "*Bad* %#16.16" INT64_T_FORMAT "x\n", diff -u libmagic.orig/compress.c libmagic/compress.c --- libmagic.orig/compress.c 2019-05-07 04:27:11.000000000 +0200 -+++ libmagic/compress.c 2020-06-17 02:13:31.620121400 +0200 ++++ libmagic/compress.c 2020-08-21 15:28:20.802569900 +0200 @@ -45,13 +45,11 @@ #endif #include @@ -1545,7 +1580,7 @@ diff -u libmagic.orig/compress.c libmagic/compress.c +#endif diff -u libmagic.orig/der.c libmagic/der.c --- libmagic.orig/der.c 2019-02-20 03:35:27.000000000 +0100 -+++ libmagic/der.c 2020-04-07 22:25:10.517321000 +0200 ++++ libmagic/der.c 2020-08-21 15:28:20.802569900 +0200 @@ -51,7 +51,9 @@ #include "magic.h" #include "der.h" @@ -1575,7 +1610,7 @@ diff -u libmagic.orig/der.c libmagic/der.c snprintf(buf + z, blen - z, "%.2x", d[i]); diff -u libmagic.orig/elfclass.h libmagic/elfclass.h --- libmagic.orig/elfclass.h 2019-02-20 02:30:19.000000000 +0100 -+++ libmagic/elfclass.h 2020-04-07 22:25:10.517321000 +0200 ++++ libmagic/elfclass.h 2020-08-21 15:28:20.802569900 +0200 @@ -41,7 +41,7 @@ return toomany(ms, "program headers", phnum); flags |= FLAGS_IS_CORE; @@ -1605,13 +1640,58 @@ diff -u libmagic.orig/elfclass.h libmagic/elfclass.h CAST(int, elf_getu16(swap, elfhdr.e_shstrndx)), diff -u libmagic.orig/encoding.c libmagic/encoding.c --- libmagic.orig/encoding.c 2019-04-15 18:48:41.000000000 +0200 -+++ libmagic/encoding.c 2020-04-07 22:25:10.517321000 +0200 ++++ libmagic/encoding.c 2020-08-21 16:09:54.670315100 +0200 +@@ -44,14 +44,14 @@ + #include + + +-private int looks_ascii(const unsigned char *, size_t, unichar *, size_t *); +-private int looks_utf8_with_BOM(const unsigned char *, size_t, unichar *, ++private int looks_ascii(const unsigned char *, size_t, unicodechar *, size_t *); ++private int looks_utf8_with_BOM(const unsigned char *, size_t, unicodechar *, + size_t *); +-private int looks_utf7(const unsigned char *, size_t, unichar *, size_t *); +-private int looks_ucs16(const unsigned char *, size_t, unichar *, size_t *); +-private int looks_ucs32(const unsigned char *, size_t, unichar *, size_t *); +-private int looks_latin1(const unsigned char *, size_t, unichar *, size_t *); +-private int looks_extended(const unsigned char *, size_t, unichar *, size_t *); ++private int looks_utf7(const unsigned char *, size_t, unicodechar *, size_t *); ++private int looks_ucs16(const unsigned char *, size_t, unicodechar *, size_t *); ++private int looks_ucs32(const unsigned char *, size_t, unicodechar *, size_t *); ++private int looks_latin1(const unsigned char *, size_t, unicodechar *, size_t *); ++private int looks_extended(const unsigned char *, size_t, unicodechar *, size_t *); + private void from_ebcdic(const unsigned char *, size_t, unsigned char *); + + #ifdef DEBUG_ENCODING +@@ -63,11 +63,11 @@ + /* + * Try to determine whether text is in some character code we can + * identify. Each of these tests, if it succeeds, will leave +- * the text converted into one-unichar-per-character Unicode in ++ * the text converted into one-unicodechar-per-character Unicode in + * ubuf, and the number of characters converted in ulen. + */ + protected int +-file_encoding(struct magic_set *ms, const struct buffer *b, unichar **ubuf, ++file_encoding(struct magic_set *ms, const struct buffer *b, unicodechar **ubuf, + size_t *ulen, const char **code, const char **code_mime, const char **type) + { + const unsigned char *buf = CAST(const unsigned char *, b->fbuf); +@@ -75,7 +75,7 @@ + size_t mlen; + int rv = 1, ucs_type; + unsigned char *nbuf = NULL; +- unichar *udefbuf; ++ unicodechar *udefbuf; + size_t udeflen; + + if (ubuf == NULL) @@ -89,13 +89,13 @@ *code_mime = "binary"; mlen = (nbytes + 1) * sizeof((*ubuf)[0]); - if ((*ubuf = CAST(unichar *, calloc(CAST(size_t, 1), mlen))) == NULL) { -+ if ((*ubuf = CAST(unichar *, ecalloc(CAST(size_t, 1), mlen))) == NULL) { ++ if ((*ubuf = CAST(unicodechar *, ecalloc(CAST(size_t, 1), mlen))) == NULL) { file_oomem(ms, mlen); goto done; } @@ -1634,9 +1714,123 @@ diff -u libmagic.orig/encoding.c libmagic/encoding.c return rv; } +@@ -251,7 +251,7 @@ + }; + + private int +-looks_ascii(const unsigned char *buf, size_t nbytes, unichar *ubuf, ++looks_ascii(const unsigned char *buf, size_t nbytes, unicodechar *ubuf, + size_t *ulen) + { + size_t i; +@@ -271,7 +271,7 @@ + } + + private int +-looks_latin1(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen) ++looks_latin1(const unsigned char *buf, size_t nbytes, unicodechar *ubuf, size_t *ulen) + { + size_t i; + +@@ -290,7 +290,7 @@ + } + + private int +-looks_extended(const unsigned char *buf, size_t nbytes, unichar *ubuf, ++looks_extended(const unsigned char *buf, size_t nbytes, unicodechar *ubuf, + size_t *ulen) + { + size_t i; +@@ -321,11 +321,11 @@ + * ubuf must be big enough! + */ + protected int +-file_looks_utf8(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen) ++file_looks_utf8(const unsigned char *buf, size_t nbytes, unicodechar *ubuf, size_t *ulen) + { + size_t i; + int n; +- unichar c; ++ unicodechar c; + int gotone = 0, ctrl = 0; + + if (ubuf) +@@ -392,7 +392,7 @@ + * rest of the text. + */ + private int +-looks_utf8_with_BOM(const unsigned char *buf, size_t nbytes, unichar *ubuf, ++looks_utf8_with_BOM(const unsigned char *buf, size_t nbytes, unicodechar *ubuf, + size_t *ulen) + { + if (nbytes > 3 && buf[0] == 0xef && buf[1] == 0xbb && buf[2] == 0xbf) +@@ -402,7 +402,7 @@ + } + + private int +-looks_utf7(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen) ++looks_utf7(const unsigned char *buf, size_t nbytes, unicodechar *ubuf, size_t *ulen) + { + if (nbytes > 4 && buf[0] == '+' && buf[1] == '/' && buf[2] == 'v') + switch (buf[3]) { +@@ -421,7 +421,7 @@ + } + + private int +-looks_ucs16(const unsigned char *bf, size_t nbytes, unichar *ubf, ++looks_ucs16(const unsigned char *bf, size_t nbytes, unicodechar *ubf, + size_t *ulen) + { + int bigend; +@@ -444,10 +444,10 @@ + + if (bigend) + ubf[(*ulen)++] = bf[i + 1] +- | (CAST(unichar, bf[i]) << 8); ++ | (CAST(unicodechar, bf[i]) << 8); + else + ubf[(*ulen)++] = bf[i] +- | (CAST(unichar, bf[i + 1]) << 8); ++ | (CAST(unicodechar, bf[i + 1]) << 8); + + if (ubf[*ulen - 1] == 0xfffe) + return 0; +@@ -460,7 +460,7 @@ + } + + private int +-looks_ucs32(const unsigned char *bf, size_t nbytes, unichar *ubf, ++looks_ucs32(const unsigned char *bf, size_t nbytes, unicodechar *ubf, + size_t *ulen) + { + int bigend; +@@ -482,15 +482,15 @@ + /* XXX fix to properly handle chars > 65536 */ + + if (bigend) +- ubf[(*ulen)++] = CAST(unichar, bf[i + 3]) +- | (CAST(unichar, bf[i + 2]) << 8) +- | (CAST(unichar, bf[i + 1]) << 16) +- | (CAST(unichar, bf[i]) << 24); ++ ubf[(*ulen)++] = CAST(unicodechar, bf[i + 3]) ++ | (CAST(unicodechar, bf[i + 2]) << 8) ++ | (CAST(unicodechar, bf[i + 1]) << 16) ++ | (CAST(unicodechar, bf[i]) << 24); + else +- ubf[(*ulen)++] = CAST(unichar, bf[i + 0]) +- | (CAST(unichar, bf[i + 1]) << 8) +- | (CAST(unichar, bf[i + 2]) << 16) +- | (CAST(unichar, bf[i + 3]) << 24); ++ ubf[(*ulen)++] = CAST(unicodechar, bf[i + 0]) ++ | (CAST(unicodechar, bf[i + 1]) << 8) ++ | (CAST(unicodechar, bf[i + 2]) << 16) ++ | (CAST(unicodechar, bf[i + 3]) << 24); + + if (ubf[*ulen - 1] == 0xfffe) + return 0; diff -u libmagic.orig/file.h libmagic/file.h --- libmagic.orig/file.h 2019-05-07 04:27:11.000000000 +0200 -+++ libmagic/file.h 2020-06-21 00:23:48.421548900 +0200 ++++ libmagic/file.h 2020-08-21 16:09:54.697579400 +0200 @@ -33,18 +33,9 @@ #ifndef __file_h__ #define __file_h__ @@ -1738,9 +1932,12 @@ diff -u libmagic.orig/file.h libmagic/file.h ((t) == FILE_STRING || \ (t) == FILE_PSTRING || \ (t) == FILE_BESTRING16 || \ -@@ -447,28 +441,23 @@ +@@ -445,39 +439,34 @@ + }; + /* Type for Unicode characters */ - typedef unsigned long unichar; +-typedef unsigned long unichar; ++typedef unsigned long unicodechar; -struct stat; #define FILE_T_LOCAL 1 @@ -1772,7 +1969,18 @@ diff -u libmagic.orig/file.h libmagic/file.h protected int file_zmagic(struct magic_set *, const struct buffer *, const char *); #endif -@@ -491,13 +480,9 @@ + protected int file_ascmagic(struct magic_set *, const struct buffer *, + int); + protected int file_ascmagic_with_encoding(struct magic_set *, +- const struct buffer *, unichar *, size_t, const char *, const char *, int); ++ const struct buffer *, unicodechar *, size_t, const char *, const char *, int); + protected int file_encoding(struct magic_set *, const struct buffer *, +- unichar **, size_t *, const char **, const char **, const char **); ++ unicodechar **, size_t *, const char **, const char **, const char **); + protected int file_is_json(struct magic_set *, const struct buffer *); + protected int file_is_tar(struct magic_set *, const struct buffer *); + protected int file_softmagic(struct magic_set *, const struct buffer *, +@@ -491,19 +480,15 @@ protected void file_badread(struct magic_set *); protected void file_badseek(struct magic_set *); protected void file_oomem(struct magic_set *, size_t); @@ -1789,6 +1997,13 @@ diff -u libmagic.orig/file.h libmagic/file.h protected void file_showstr(FILE *, const char *, size_t); protected size_t file_mbswidth(const char *); protected const char *file_getbuffer(struct magic_set *); + protected ssize_t sread(int, void *, size_t, int); + protected int file_check_mem(struct magic_set *, unsigned int); +-protected int file_looks_utf8(const unsigned char *, size_t, unichar *, ++protected int file_looks_utf8(const unsigned char *, size_t, unicodechar *, + size_t *); + protected size_t file_pstring_length_size(const struct magic *); + protected size_t file_pstring_get_length(const struct magic *, const char *); @@ -513,34 +498,13 @@ size_t); #endif /* __EMX__ */ @@ -1919,7 +2134,7 @@ diff -u libmagic.orig/file.h libmagic/file.h #endif diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c --- libmagic.orig/fsmagic.c 2019-05-07 04:26:48.000000000 +0200 -+++ libmagic/fsmagic.c 2020-04-07 22:25:10.532971400 +0200 ++++ libmagic/fsmagic.c 2020-08-21 15:28:20.802569900 +0200 @@ -66,26 +66,10 @@ # define minor(dev) ((dev) & 0xff) #endif @@ -2212,7 +2427,7 @@ diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c case S_IFSOCK: diff -u libmagic.orig/funcs.c libmagic/funcs.c --- libmagic.orig/funcs.c 2019-05-07 04:27:11.000000000 +0200 -+++ libmagic/funcs.c 2020-06-17 02:13:31.651362400 +0200 ++++ libmagic/funcs.c 2020-08-21 15:46:02.589327200 +0200 @@ -31,87 +31,80 @@ #endif /* lint */ @@ -2584,7 +2799,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c diff -u libmagic.orig/magic.c libmagic/magic.c --- libmagic.orig/magic.c 2019-05-07 04:27:11.000000000 +0200 -+++ libmagic/magic.c 2020-04-07 22:25:10.532971400 +0200 ++++ libmagic/magic.c 2020-08-21 15:28:20.818197700 +0200 @@ -25,11 +25,6 @@ * SUCH DAMAGE. */ @@ -3048,8 +3263,8 @@ diff -u libmagic.orig/magic.c libmagic/magic.c public const char * magic_error(struct magic_set *ms) diff -u libmagic.orig/magic.h libmagic/magic.h ---- libmagic.orig/magic.h 2020-07-08 18:10:37.403232400 +0200 -+++ libmagic/magic.h 2020-04-07 22:25:10.548560600 +0200 +--- libmagic.orig/magic.h 2020-08-21 16:11:36.790038600 +0200 ++++ libmagic/magic.h 2020-08-21 15:28:20.818197700 +0200 @@ -124,6 +124,7 @@ const char *magic_getpath(const char *, int); @@ -3060,7 +3275,7 @@ diff -u libmagic.orig/magic.h libmagic/magic.h diff -u libmagic.orig/print.c libmagic/print.c --- libmagic.orig/print.c 2019-03-12 21:43:05.000000000 +0100 -+++ libmagic/print.c 2020-07-08 18:05:40.114527900 +0200 ++++ libmagic/print.c 2020-08-21 15:46:02.589327200 +0200 @@ -28,6 +28,7 @@ /* * print.c - debugging printout routines @@ -3134,7 +3349,7 @@ diff -u libmagic.orig/print.c libmagic/print.c goto out; diff -u libmagic.orig/readcdf.c libmagic/readcdf.c --- libmagic.orig/readcdf.c 2019-03-12 21:43:05.000000000 +0100 -+++ libmagic/readcdf.c 2020-04-07 22:25:10.548560600 +0200 ++++ libmagic/readcdf.c 2020-08-21 15:28:20.818197700 +0200 @@ -31,7 +31,11 @@ #include @@ -3253,7 +3468,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c if (i != -1) diff -u libmagic.orig/softmagic.c libmagic/softmagic.c --- libmagic.orig/softmagic.c 2019-05-17 04:24:59.000000000 +0200 -+++ libmagic/softmagic.c 2020-04-26 00:43:35.734037100 +0200 ++++ libmagic/softmagic.c 2020-08-21 15:28:20.818197700 +0200 @@ -43,6 +43,10 @@ #include #include "der.h" @@ -3620,7 +3835,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c case FILE_INDIRECT: diff -u libmagic.orig/strcasestr.c libmagic/strcasestr.c --- libmagic.orig/strcasestr.c 2014-09-11 17:05:33.000000000 +0200 -+++ libmagic/strcasestr.c 2019-12-19 20:37:55.833385900 +0100 ++++ libmagic/strcasestr.c 2020-06-15 11:16:08.173462200 +0200 @@ -39,6 +39,8 @@ #include "file.h" diff --git a/ext/fileinfo/libmagic/ascmagic.c b/ext/fileinfo/libmagic/ascmagic.c index 0bc0cce1de4e8..348f6d6bd71bc 100644 --- a/ext/fileinfo/libmagic/ascmagic.c +++ b/ext/fileinfo/libmagic/ascmagic.c @@ -51,7 +51,7 @@ FILE_RCSID("@(#)$File: ascmagic.c,v 1.104 2019/05/07 02:27:11 christos Exp $") #define ISSPC(x) ((x) == ' ' || (x) == '\t' || (x) == '\r' || (x) == '\n' \ || (x) == 0x85 || (x) == '\f') -private unsigned char *encode_utf8(unsigned char *, size_t, unichar *, size_t); +private unsigned char *encode_utf8(unsigned char *, size_t, unicodechar *, size_t); private size_t trim_nuls(const unsigned char *, size_t); /* @@ -70,7 +70,7 @@ trim_nuls(const unsigned char *buf, size_t nbytes) protected int file_ascmagic(struct magic_set *ms, const struct buffer *b, int text) { - unichar *ubuf = NULL; + unicodechar *ubuf = NULL; size_t ulen = 0; int rv = 1; struct buffer bb; @@ -103,7 +103,7 @@ file_ascmagic(struct magic_set *ms, const struct buffer *b, int text) protected int file_ascmagic_with_encoding(struct magic_set *ms, - const struct buffer *b, unichar *ubuf, size_t ulen, const char *code, + const struct buffer *b, unicodechar *ubuf, size_t ulen, const char *code, const char *type, int text) { struct buffer bb; @@ -338,7 +338,7 @@ file_ascmagic_with_encoding(struct magic_set *ms, * after end of string, or NULL if an invalid character is found. */ private unsigned char * -encode_utf8(unsigned char *buf, size_t len, unichar *ubuf, size_t ulen) +encode_utf8(unsigned char *buf, size_t len, unicodechar *ubuf, size_t ulen) { size_t i; unsigned char *end = buf + len; diff --git a/ext/fileinfo/libmagic/encoding.c b/ext/fileinfo/libmagic/encoding.c index 121bbd71438da..8d0e6012e5862 100644 --- a/ext/fileinfo/libmagic/encoding.c +++ b/ext/fileinfo/libmagic/encoding.c @@ -44,14 +44,14 @@ FILE_RCSID("@(#)$File: encoding.c,v 1.20 2019/04/15 16:48:41 christos Exp $") #include -private int looks_ascii(const unsigned char *, size_t, unichar *, size_t *); -private int looks_utf8_with_BOM(const unsigned char *, size_t, unichar *, +private int looks_ascii(const unsigned char *, size_t, unicodechar *, size_t *); +private int looks_utf8_with_BOM(const unsigned char *, size_t, unicodechar *, size_t *); -private int looks_utf7(const unsigned char *, size_t, unichar *, size_t *); -private int looks_ucs16(const unsigned char *, size_t, unichar *, size_t *); -private int looks_ucs32(const unsigned char *, size_t, unichar *, size_t *); -private int looks_latin1(const unsigned char *, size_t, unichar *, size_t *); -private int looks_extended(const unsigned char *, size_t, unichar *, size_t *); +private int looks_utf7(const unsigned char *, size_t, unicodechar *, size_t *); +private int looks_ucs16(const unsigned char *, size_t, unicodechar *, size_t *); +private int looks_ucs32(const unsigned char *, size_t, unicodechar *, size_t *); +private int looks_latin1(const unsigned char *, size_t, unicodechar *, size_t *); +private int looks_extended(const unsigned char *, size_t, unicodechar *, size_t *); private void from_ebcdic(const unsigned char *, size_t, unsigned char *); #ifdef DEBUG_ENCODING @@ -63,11 +63,11 @@ private void from_ebcdic(const unsigned char *, size_t, unsigned char *); /* * Try to determine whether text is in some character code we can * identify. Each of these tests, if it succeeds, will leave - * the text converted into one-unichar-per-character Unicode in + * the text converted into one-unicodechar-per-character Unicode in * ubuf, and the number of characters converted in ulen. */ protected int -file_encoding(struct magic_set *ms, const struct buffer *b, unichar **ubuf, +file_encoding(struct magic_set *ms, const struct buffer *b, unicodechar **ubuf, size_t *ulen, const char **code, const char **code_mime, const char **type) { const unsigned char *buf = CAST(const unsigned char *, b->fbuf); @@ -75,7 +75,7 @@ file_encoding(struct magic_set *ms, const struct buffer *b, unichar **ubuf, size_t mlen; int rv = 1, ucs_type; unsigned char *nbuf = NULL; - unichar *udefbuf; + unicodechar *udefbuf; size_t udeflen; if (ubuf == NULL) @@ -89,7 +89,7 @@ file_encoding(struct magic_set *ms, const struct buffer *b, unichar **ubuf, *code_mime = "binary"; mlen = (nbytes + 1) * sizeof((*ubuf)[0]); - if ((*ubuf = CAST(unichar *, ecalloc(CAST(size_t, 1), mlen))) == NULL) { + if ((*ubuf = CAST(unicodechar *, ecalloc(CAST(size_t, 1), mlen))) == NULL) { file_oomem(ms, mlen); goto done; } @@ -251,7 +251,7 @@ private char text_chars[256] = { }; private int -looks_ascii(const unsigned char *buf, size_t nbytes, unichar *ubuf, +looks_ascii(const unsigned char *buf, size_t nbytes, unicodechar *ubuf, size_t *ulen) { size_t i; @@ -271,7 +271,7 @@ looks_ascii(const unsigned char *buf, size_t nbytes, unichar *ubuf, } private int -looks_latin1(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen) +looks_latin1(const unsigned char *buf, size_t nbytes, unicodechar *ubuf, size_t *ulen) { size_t i; @@ -290,7 +290,7 @@ looks_latin1(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ule } private int -looks_extended(const unsigned char *buf, size_t nbytes, unichar *ubuf, +looks_extended(const unsigned char *buf, size_t nbytes, unicodechar *ubuf, size_t *ulen) { size_t i; @@ -321,11 +321,11 @@ looks_extended(const unsigned char *buf, size_t nbytes, unichar *ubuf, * ubuf must be big enough! */ protected int -file_looks_utf8(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen) +file_looks_utf8(const unsigned char *buf, size_t nbytes, unicodechar *ubuf, size_t *ulen) { size_t i; int n; - unichar c; + unicodechar c; int gotone = 0, ctrl = 0; if (ubuf) @@ -392,7 +392,7 @@ file_looks_utf8(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t * * rest of the text. */ private int -looks_utf8_with_BOM(const unsigned char *buf, size_t nbytes, unichar *ubuf, +looks_utf8_with_BOM(const unsigned char *buf, size_t nbytes, unicodechar *ubuf, size_t *ulen) { if (nbytes > 3 && buf[0] == 0xef && buf[1] == 0xbb && buf[2] == 0xbf) @@ -402,7 +402,7 @@ looks_utf8_with_BOM(const unsigned char *buf, size_t nbytes, unichar *ubuf, } private int -looks_utf7(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen) +looks_utf7(const unsigned char *buf, size_t nbytes, unicodechar *ubuf, size_t *ulen) { if (nbytes > 4 && buf[0] == '+' && buf[1] == '/' && buf[2] == 'v') switch (buf[3]) { @@ -421,7 +421,7 @@ looks_utf7(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen) } private int -looks_ucs16(const unsigned char *bf, size_t nbytes, unichar *ubf, +looks_ucs16(const unsigned char *bf, size_t nbytes, unicodechar *ubf, size_t *ulen) { int bigend; @@ -444,10 +444,10 @@ looks_ucs16(const unsigned char *bf, size_t nbytes, unichar *ubf, if (bigend) ubf[(*ulen)++] = bf[i + 1] - | (CAST(unichar, bf[i]) << 8); + | (CAST(unicodechar, bf[i]) << 8); else ubf[(*ulen)++] = bf[i] - | (CAST(unichar, bf[i + 1]) << 8); + | (CAST(unicodechar, bf[i + 1]) << 8); if (ubf[*ulen - 1] == 0xfffe) return 0; @@ -460,7 +460,7 @@ looks_ucs16(const unsigned char *bf, size_t nbytes, unichar *ubf, } private int -looks_ucs32(const unsigned char *bf, size_t nbytes, unichar *ubf, +looks_ucs32(const unsigned char *bf, size_t nbytes, unicodechar *ubf, size_t *ulen) { int bigend; @@ -482,15 +482,15 @@ looks_ucs32(const unsigned char *bf, size_t nbytes, unichar *ubf, /* XXX fix to properly handle chars > 65536 */ if (bigend) - ubf[(*ulen)++] = CAST(unichar, bf[i + 3]) - | (CAST(unichar, bf[i + 2]) << 8) - | (CAST(unichar, bf[i + 1]) << 16) - | (CAST(unichar, bf[i]) << 24); + ubf[(*ulen)++] = CAST(unicodechar, bf[i + 3]) + | (CAST(unicodechar, bf[i + 2]) << 8) + | (CAST(unicodechar, bf[i + 1]) << 16) + | (CAST(unicodechar, bf[i]) << 24); else - ubf[(*ulen)++] = CAST(unichar, bf[i + 0]) - | (CAST(unichar, bf[i + 1]) << 8) - | (CAST(unichar, bf[i + 2]) << 16) - | (CAST(unichar, bf[i + 3]) << 24); + ubf[(*ulen)++] = CAST(unicodechar, bf[i + 0]) + | (CAST(unicodechar, bf[i + 1]) << 8) + | (CAST(unicodechar, bf[i + 2]) << 16) + | (CAST(unicodechar, bf[i + 3]) << 24); if (ubf[*ulen - 1] == 0xfffe) return 0; diff --git a/ext/fileinfo/libmagic/file.h b/ext/fileinfo/libmagic/file.h index 3450f745bd36f..b588efcadb65b 100644 --- a/ext/fileinfo/libmagic/file.h +++ b/ext/fileinfo/libmagic/file.h @@ -439,7 +439,7 @@ struct magic_set { }; /* Type for Unicode characters */ -typedef unsigned long unichar; +typedef unsigned long unicodechar; #define FILE_T_LOCAL 1 #define FILE_T_WINDOWS 2 @@ -464,9 +464,9 @@ protected int file_zmagic(struct magic_set *, const struct buffer *, protected int file_ascmagic(struct magic_set *, const struct buffer *, int); protected int file_ascmagic_with_encoding(struct magic_set *, - const struct buffer *, unichar *, size_t, const char *, const char *, int); + const struct buffer *, unicodechar *, size_t, const char *, const char *, int); protected int file_encoding(struct magic_set *, const struct buffer *, - unichar **, size_t *, const char **, const char **, const char **); + unicodechar **, size_t *, const char **, const char **, const char **); protected int file_is_json(struct magic_set *, const struct buffer *); protected int file_is_tar(struct magic_set *, const struct buffer *); protected int file_softmagic(struct magic_set *, const struct buffer *, @@ -488,7 +488,7 @@ protected size_t file_mbswidth(const char *); protected const char *file_getbuffer(struct magic_set *); protected ssize_t sread(int, void *, size_t, int); protected int file_check_mem(struct magic_set *, unsigned int); -protected int file_looks_utf8(const unsigned char *, size_t, unichar *, +protected int file_looks_utf8(const unsigned char *, size_t, unicodechar *, size_t *); protected size_t file_pstring_length_size(const struct magic *); protected size_t file_pstring_get_length(const struct magic *, const char *); From 47c787ff5b80764b59dead181633ec45dbd2d70c Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Sat, 22 Aug 2020 11:37:23 +1000 Subject: [PATCH 040/170] Squash a Linux compile warning --- ext/oci8/oci8.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index b83ec33f0404d..f9e65939a527d 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -917,7 +917,7 @@ void php_oci_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent, int exclus php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char *password, int password_len, char *new_password, int new_password_len, char *dbname, int dbname_len, char *charset, zend_long session_mode, int persistent, int exclusive) { zval *zvp; - zend_resource *le; + zend_resource *le = NULL; zend_resource new_le; php_oci_connection *connection = NULL; smart_str hashed_details = {0}; @@ -1163,7 +1163,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char /* We have to do a hash_del but need to preserve the resource if there is a positive * refcount. Set the data pointer in the list entry to NULL */ - if (connection == connection->id->ptr) { + if (connection == connection->id->ptr && le) { le->ptr = NULL; } From b2a33ab06bab4f2d79634e294632bebebd04acdb Mon Sep 17 00:00:00 2001 From: Andy Postnikov Date: Sat, 22 Aug 2020 02:44:48 +0300 Subject: [PATCH 041/170] Fix #80007: Potential type confusion in unixtojd() parameter parsing Also it fixes test on 32-bit armv7 and x86 - Test unixtojd() function : error conditions [ext/calendar/tests/unixtojd_error1.phpt] Closes GH-6033 --- NEWS | 3 +++ ext/calendar/cal_unix.c | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 4748996c26c83..49ac4c5a69966 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,9 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 7.3.23 +- Calendar: + . Fixed bug #80007 (Potential type confusion in unixtojd() parameter parsing). + (Andy Postnikov) 03 Sep 2020, PHP 7.3.22 diff --git a/ext/calendar/cal_unix.c b/ext/calendar/cal_unix.c index a8e81eb5414b8..da6a184e6c17a 100644 --- a/ext/calendar/cal_unix.c +++ b/ext/calendar/cal_unix.c @@ -28,15 +28,18 @@ PHP_FUNCTION(unixtojd) { time_t ts = 0; + zend_long tl = 0; struct tm *ta, tmbuf; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &ts) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &tl) == FAILURE) { return; } - if (!ts) { + if (!tl) { ts = time(NULL); - } else if (ts < 0) { + } else if (tl >= 0) { + ts = (time_t) tl; + } else { RETURN_FALSE; } From e6044d4455d7fbaced7f3a6ac28172d963017e51 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Thu, 6 Aug 2020 18:57:18 +0200 Subject: [PATCH 042/170] Fix #55847: DOTNET .NET 4.0 GAC new location If we do not specify the exact version of the .NET framework to use, the default CLR is loaded, which is typically CLR 2, which is very old. Therefore, we introduce a `PHP_INI_SYSTEM` setting, which allows users to choose the desired .NET framework version. The value of the setting are the first three parts of the framework's version number, separated by dots, and prefixed with "v", e.g. "v4.0.30319". If the value of the INI setting is `NULL` (the default) or an empty string, the default CLR is used. Internally, we switch from the most generic `CoCreateInstance()` to `CorBindToRuntime()` which is implemented in mscoree.dll. To avoid the hard dependency to that library, we load dynamically. So this fix is supposed to be fully backwards compatible. Closes GH-5949 --- NEWS | 3 +++ UPGRADING | 4 ++++ ext/com_dotnet/com_dotnet.c | 44 ++++++++++++++++++++++++++++++---- ext/com_dotnet/com_extension.c | 1 + php.ini-development | 4 ++++ php.ini-production | 4 ++++ 6 files changed, 56 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 65395d8f2bb58..8d81c0cd5cc5a 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,9 @@ PHP NEWS . Fixed bug #80007 (Potential type confusion in unixtojd() parameter parsing). (Andy Postnikov) +- COM: + . Fixed bug #55847 (DOTNET .NET 4.0 GAC new location). (cmb) + - DOM: . Fixed bug #79968 (DOMChildNode API crash on unattached nodes). (Benjamin) diff --git a/UPGRADING b/UPGRADING index 9cb89cf9695f5..2412b60865f5e 100644 --- a/UPGRADING +++ b/UPGRADING @@ -1048,6 +1048,10 @@ PHP 8.0 UPGRADE NOTES . New INI directive to set the maximum string length in an argument of a stringified stack strace. +- com.dotnet_version + . New INI directive to choose the version of the .NET framework to use for + dotnet objects. + ======================================== 12. Windows Support ======================================== diff --git a/ext/com_dotnet/com_dotnet.c b/ext/com_dotnet/com_dotnet.c index 6bd492ef1d9b9..1b0ba2220c3a0 100644 --- a/ext/com_dotnet/com_dotnet.c +++ b/ext/com_dotnet/com_dotnet.c @@ -117,6 +117,44 @@ struct dotnet_runtime_stuff { DISPID create_instance; }; +/* We link dynamically to mscoree.dll to avoid the hard dependency on .NET + * framework, which is only required if a dotnet instance is to be created. + */ +static HRESULT dotnet_bind_runtime(LPVOID FAR *ppv) +{ + HRESULT hr; + HMODULE mscoree; + typedef HRESULT (STDAPICALLTYPE *cbtr_t)(LPCWSTR pwszVersion, LPCWSTR pwszBuildFlavor, REFCLSID rclsid, REFIID riid, LPVOID FAR *ppv); + cbtr_t CorBindToRuntime; + OLECHAR *oleversion; + char *version; + + mscoree = LoadLibraryA("mscoree.dll"); + if (mscoree == NULL) { + return S_FALSE; + } + + CorBindToRuntime = (cbtr_t) GetProcAddress(mscoree, "CorBindToRuntime"); + if (CorBindToRuntime == NULL) { + FreeLibrary(mscoree); + return S_FALSE; + } + + version = INI_STR("com.dotnet_version"); + if (version == NULL || *version == '\0') { + oleversion = NULL; + } else { + oleversion = php_com_string_to_olestring(version, strlen(version), COMG(code_page)); + } + + hr = CorBindToRuntime(oleversion, NULL, &CLSID_CorRuntimeHost, &IID_ICorRuntimeHost, ppv); + + efree(oleversion); + FreeLibrary(mscoree); + + return hr; +} + static HRESULT dotnet_init(char **p_where) { HRESULT hr; @@ -130,10 +168,8 @@ static HRESULT dotnet_init(char **p_where) } memset(stuff, 0, sizeof(*stuff)); - where = "CoCreateInstance"; - hr = CoCreateInstance(&CLSID_CorRuntimeHost, NULL, CLSCTX_ALL, - &IID_ICorRuntimeHost, (LPVOID*)&stuff->dotnet_host); - + where = "dotnet_bind_runtime"; + hr = dotnet_bind_runtime((LPVOID*)&stuff->dotnet_host); if (FAILED(hr)) goto out; diff --git a/ext/com_dotnet/com_extension.c b/ext/com_dotnet/com_extension.c index 0535509412e0c..5e2c1f69de7fb 100644 --- a/ext/com_dotnet/com_extension.c +++ b/ext/com_dotnet/com_extension.c @@ -141,6 +141,7 @@ PHP_INI_BEGIN() STD_PHP_INI_ENTRY("com.autoregister_casesensitive", "1", PHP_INI_ALL, OnAutoregisterCasesensitive, autoreg_case_sensitive, zend_com_dotnet_globals, com_dotnet_globals) STD_PHP_INI_ENTRY("com.code_page", "", PHP_INI_ALL, OnUpdateLong, code_page, zend_com_dotnet_globals, com_dotnet_globals) PHP_INI_ENTRY("com.typelib_file", "", PHP_INI_SYSTEM, OnTypeLibFileUpdate) + PHP_INI_ENTRY("com.dotnet_version", NULL, PHP_INI_SYSTEM, NULL) PHP_INI_END() /* }}} */ diff --git a/php.ini-development b/php.ini-development index b352f5056fbb7..54006830a2c06 100644 --- a/php.ini-development +++ b/php.ini-development @@ -1614,6 +1614,10 @@ zend.assertions = 1 ; Default: system ANSI code page ;com.code_page= +; The version of the .NET framework to use. The value of the setting are the first three parts +; of the framework's version number, separated by dots, and prefixed with "v", e.g. "v4.0.30319". +;com.dotnet_version= + [mbstring] ; language for internal character representation. ; This affects mb_send_mail() and mbstring.detect_order. diff --git a/php.ini-production b/php.ini-production index 61960ef807c5f..47a5c5e13b20b 100644 --- a/php.ini-production +++ b/php.ini-production @@ -1618,6 +1618,10 @@ zend.assertions = -1 ; Default: system ANSI code page ;com.code_page= +; The version of the .NET framework to use. The value of the setting are the first three parts +; of the framework's version number, separated by dots, and prefixed with "v", e.g. "v4.0.30319". +;com.dotnet_version= + [mbstring] ; language for internal character representation. ; This affects mb_send_mail() and mbstring.detect_order. From 4bba59d4913c0904cce186d50b0343f567093a20 Mon Sep 17 00:00:00 2001 From: Tyson Andre Date: Sun, 23 Aug 2020 11:12:44 -0400 Subject: [PATCH 043/170] Update PHP-Parser from 4.3.0 to 4.9.0 PHP-Parser 4.3.0 failed to recognize that the `match` keyword could be used as a class constant name. 4.9.0 also adds support for keywords in namespaced names. See https://github.com/nikic/PHP-Parser/releases So forcing regeneration of spl_iterators.stub.php failed. PECL extensions using gen_stub.php would also be affected by the same issue. ``` ext/spl/spl_iterators.stub.php public function __construct(Iterator $iterator, string $regex, int $mode = self::MATCH, int $flags = 0, int $preg_flags = 0) {} ``` Testing: I successfully regenerated stubs by setting forceRegeneration to true and running `touch **/*.stub.php; make`. The stubs did not change, as expected. Closes GH-6036 --- build/gen_stub.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/gen_stub.php b/build/gen_stub.php index 0584ecc710d25..24e34430bdefb 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -1105,7 +1105,7 @@ function initPhpParser() { } $isInitialized = true; - $version = "4.3.0"; + $version = "4.9.0"; $phpParserDir = __DIR__ . "/PHP-Parser-$version"; if (!is_dir($phpParserDir)) { installPhpParser($version, $phpParserDir); From 118406a31cb8a599bbce41710b608315ec67c943 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Sun, 23 Aug 2020 21:17:05 +0200 Subject: [PATCH 044/170] Remove custom hacks from gen_stub.php after PHP-Parser upgrade --- build/gen_stub.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/build/gen_stub.php b/build/gen_stub.php index 24e34430bdefb..fb79255e84948 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -80,10 +80,6 @@ public function __construct(string $name, bool $isBuiltin) { public static function fromNode(Node $node) { if ($node instanceof Node\Name) { - if ($node->toString() === "mixed") { - return new SimpleType($node->toString(), true); - } - assert($node->isFullyQualified()); return new SimpleType($node->toString(), false); } @@ -680,7 +676,7 @@ function parseFunctionLike( $type && !$type->isNullable() ) { $simpleType = $type->tryToSimpleType(); - if ($simpleType === null || $simpleType->name !== "mixed") { + if ($simpleType === null) { throw new Exception( "Parameter $varName of function $name has null default, but is not nullable"); } From 5c18ee58b952f23b51ac3f3af972ce72b469e4ed Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 24 Aug 2020 09:50:54 +0300 Subject: [PATCH 045/170] Fixed use-after-free introduced by aed1f785159e7c9e81da8f2e2e06df9a6ee0d809 --- Zend/zend_vm_def.h | 10 ++-- Zend/zend_vm_execute.h | 120 ++++++++++++++++++++++++++++------------- 2 files changed, 91 insertions(+), 39 deletions(-) diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 55a1e9ba8671c..b92928e3b0dd0 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -3424,14 +3424,19 @@ ZEND_VM_HOT_OBJ_HANDLER(112, ZEND_INIT_METHOD_CALL, CONST|TMPVAR|UNUSED|THIS|CV, } while (0); } - if (OP1_TYPE != IS_UNUSED) { + if (OP1_TYPE == IS_UNUSED) { + obj = Z_OBJ_P(object); + } else { do { - if (OP1_TYPE == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + if (OP1_TYPE != IS_CONST && EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + } else { if ((OP1_TYPE & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { zend_reference *ref = Z_REF_P(object); object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); if (OP1_TYPE & IS_VAR) { if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); @@ -3462,7 +3467,6 @@ ZEND_VM_HOT_OBJ_HANDLER(112, ZEND_INIT_METHOD_CALL, CONST|TMPVAR|UNUSED|THIS|CV, } while (0); } - obj = Z_OBJ_P(object); called_scope = obj->ce; if (OP2_TYPE == IS_CONST && diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 70506a6e1417b..7a50d99d299e8 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -5739,14 +5739,19 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ } while (0); } - if (IS_CONST != IS_UNUSED) { + if (IS_CONST == IS_UNUSED) { + obj = Z_OBJ_P(object); + } else { do { - if (IS_CONST == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + if (IS_CONST != IS_CONST && EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + } else { if ((IS_CONST & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { zend_reference *ref = Z_REF_P(object); object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); if (IS_CONST & IS_VAR) { if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); @@ -5777,7 +5782,6 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ } while (0); } - obj = Z_OBJ_P(object); called_scope = obj->ce; if (IS_CONST == IS_CONST && @@ -8023,14 +8027,19 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ } while (0); } - if (IS_CONST != IS_UNUSED) { + if (IS_CONST == IS_UNUSED) { + obj = Z_OBJ_P(object); + } else { do { - if (IS_CONST == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + if (IS_CONST != IS_CONST && EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + } else { if ((IS_CONST & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { zend_reference *ref = Z_REF_P(object); object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); if (IS_CONST & IS_VAR) { if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); @@ -8061,7 +8070,6 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ } while (0); } - obj = Z_OBJ_P(object); called_scope = obj->ce; if ((IS_TMP_VAR|IS_VAR) == IS_CONST && @@ -10400,14 +10408,19 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ } while (0); } - if (IS_CONST != IS_UNUSED) { + if (IS_CONST == IS_UNUSED) { + obj = Z_OBJ_P(object); + } else { do { - if (IS_CONST == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + if (IS_CONST != IS_CONST && EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + } else { if ((IS_CONST & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { zend_reference *ref = Z_REF_P(object); object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); if (IS_CONST & IS_VAR) { if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); @@ -10438,7 +10451,6 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ } while (0); } - obj = Z_OBJ_P(object); called_scope = obj->ce; if (IS_CV == IS_CONST && @@ -14769,14 +14781,19 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C } while (0); } - if ((IS_TMP_VAR|IS_VAR) != IS_UNUSED) { + if ((IS_TMP_VAR|IS_VAR) == IS_UNUSED) { + obj = Z_OBJ_P(object); + } else { do { - if ((IS_TMP_VAR|IS_VAR) == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + if ((IS_TMP_VAR|IS_VAR) != IS_CONST && EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + } else { if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { zend_reference *ref = Z_REF_P(object); object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); if ((IS_TMP_VAR|IS_VAR) & IS_VAR) { if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); @@ -14807,7 +14824,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C } while (0); } - obj = Z_OBJ_P(object); called_scope = obj->ce; if (IS_CONST == IS_CONST && @@ -16184,14 +16200,19 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_T } while (0); } - if ((IS_TMP_VAR|IS_VAR) != IS_UNUSED) { + if ((IS_TMP_VAR|IS_VAR) == IS_UNUSED) { + obj = Z_OBJ_P(object); + } else { do { - if ((IS_TMP_VAR|IS_VAR) == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + if ((IS_TMP_VAR|IS_VAR) != IS_CONST && EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + } else { if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { zend_reference *ref = Z_REF_P(object); object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); if ((IS_TMP_VAR|IS_VAR) & IS_VAR) { if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); @@ -16222,7 +16243,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_T } while (0); } - obj = Z_OBJ_P(object); called_scope = obj->ce; if ((IS_TMP_VAR|IS_VAR) == IS_CONST && @@ -17492,14 +17512,19 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C } while (0); } - if ((IS_TMP_VAR|IS_VAR) != IS_UNUSED) { + if ((IS_TMP_VAR|IS_VAR) == IS_UNUSED) { + obj = Z_OBJ_P(object); + } else { do { - if ((IS_TMP_VAR|IS_VAR) == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + if ((IS_TMP_VAR|IS_VAR) != IS_CONST && EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + } else { if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { zend_reference *ref = Z_REF_P(object); object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); if ((IS_TMP_VAR|IS_VAR) & IS_VAR) { if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); @@ -17530,7 +17555,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C } while (0); } - obj = Z_OBJ_P(object); called_scope = obj->ce; if (IS_CV == IS_CONST && @@ -31525,14 +31549,19 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S } while (0); } - if (IS_UNUSED != IS_UNUSED) { + if (IS_UNUSED == IS_UNUSED) { + obj = Z_OBJ_P(object); + } else { do { - if (IS_UNUSED == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + if (IS_UNUSED != IS_CONST && EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + } else { if ((IS_UNUSED & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { zend_reference *ref = Z_REF_P(object); object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); if (IS_UNUSED & IS_VAR) { if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); @@ -31563,7 +31592,6 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S } while (0); } - obj = Z_OBJ_P(object); called_scope = obj->ce; if (IS_CONST == IS_CONST && @@ -33430,14 +33458,19 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_T } while (0); } - if (IS_UNUSED != IS_UNUSED) { + if (IS_UNUSED == IS_UNUSED) { + obj = Z_OBJ_P(object); + } else { do { - if (IS_UNUSED == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + if (IS_UNUSED != IS_CONST && EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + } else { if ((IS_UNUSED & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { zend_reference *ref = Z_REF_P(object); object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); if (IS_UNUSED & IS_VAR) { if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); @@ -33468,7 +33501,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_T } while (0); } - obj = Z_OBJ_P(object); called_scope = obj->ce; if ((IS_TMP_VAR|IS_VAR) == IS_CONST && @@ -35913,14 +35945,19 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_C } while (0); } - if (IS_UNUSED != IS_UNUSED) { + if (IS_UNUSED == IS_UNUSED) { + obj = Z_OBJ_P(object); + } else { do { - if (IS_UNUSED == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + if (IS_UNUSED != IS_CONST && EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + } else { if ((IS_UNUSED & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { zend_reference *ref = Z_REF_P(object); object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); if (IS_UNUSED & IS_VAR) { if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); @@ -35951,7 +35988,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_C } while (0); } - obj = Z_OBJ_P(object); called_scope = obj->ce; if (IS_CV == IS_CONST && @@ -40588,14 +40624,19 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S } while (0); } - if (IS_CV != IS_UNUSED) { + if (IS_CV == IS_UNUSED) { + obj = Z_OBJ_P(object); + } else { do { - if (IS_CV == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + if (IS_CV != IS_CONST && EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + } else { if ((IS_CV & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { zend_reference *ref = Z_REF_P(object); object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); if (IS_CV & IS_VAR) { if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); @@ -40626,7 +40667,6 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S } while (0); } - obj = Z_OBJ_P(object); called_scope = obj->ce; if (IS_CONST == IS_CONST && @@ -44169,14 +44209,19 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_TMPVA } while (0); } - if (IS_CV != IS_UNUSED) { + if (IS_CV == IS_UNUSED) { + obj = Z_OBJ_P(object); + } else { do { - if (IS_CV == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + if (IS_CV != IS_CONST && EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + } else { if ((IS_CV & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { zend_reference *ref = Z_REF_P(object); object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); if (IS_CV & IS_VAR) { if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); @@ -44207,7 +44252,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_TMPVA } while (0); } - obj = Z_OBJ_P(object); called_scope = obj->ce; if ((IS_TMP_VAR|IS_VAR) == IS_CONST && @@ -49287,14 +49331,19 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CV_HA } while (0); } - if (IS_CV != IS_UNUSED) { + if (IS_CV == IS_UNUSED) { + obj = Z_OBJ_P(object); + } else { do { - if (IS_CV == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + if (IS_CV != IS_CONST && EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + } else { if ((IS_CV & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { zend_reference *ref = Z_REF_P(object); object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); if (IS_CV & IS_VAR) { if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); @@ -49325,7 +49374,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CV_HA } while (0); } - obj = Z_OBJ_P(object); called_scope = obj->ce; if (IS_CV == IS_CONST && From 2c2bb5098400bcd1dede34881766fb16665b3f7f Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Sun, 23 Aug 2020 08:39:53 -0700 Subject: [PATCH 046/170] sapi/fpm/config.m4: check for libapparmor's aa_change_profile() The fpm code actually uses aa_change_profile(), not change_hat(). Test for the correct function. (libapparmor always has both, so this is just a correctness fix.) Closes GH-6037. --- sapi/fpm/config.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sapi/fpm/config.m4 b/sapi/fpm/config.m4 index 9d2b8c7349c25..7c2fdec122028 100644 --- a/sapi/fpm/config.m4 +++ b/sapi/fpm/config.m4 @@ -571,7 +571,7 @@ if test "$PHP_FPM" != "no"; then if test "x$PHP_FPM_APPARMOR" != "xno" ; then AC_CHECK_HEADERS([sys/apparmor.h]) - AC_CHECK_LIB(apparmor, change_hat, [ + AC_CHECK_LIB(apparmor, aa_change_profile, [ PHP_ADD_LIBRARY(apparmor) AC_DEFINE(HAVE_APPARMOR, 1, [ AppArmor confinement available ]) ],[ From 9395e01e3d5b7e34e788c2f1c84252be9c80bf1f Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 24 Aug 2020 10:15:57 +0200 Subject: [PATCH 047/170] Check variadic parameter for type and duplicate name Set HAS_TYPE_HINTS flag if the variadic parameter is types as well, and make sure it has a distinct name. This was previously missed, because the variadic parameter is not part of num_args. --- Zend/zend_API.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 03b65779da2c8..de6e6d2b3daee 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -2371,10 +2371,16 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio break; } + /* Get parameter count including variadic parameter. */ + uint32_t num_args = reg_function->common.num_args; + if (reg_function->common.fn_flags & ZEND_ACC_VARIADIC) { + num_args++; + } + /* If types of arguments have to be checked */ - if (reg_function->common.arg_info && reg_function->common.num_args) { + if (reg_function->common.arg_info && num_args) { uint32_t i; - for (i = 0; i < reg_function->common.num_args; i++) { + for (i = 0; i < num_args; i++) { zend_internal_arg_info *arg_info = ®_function->internal_function.arg_info[i]; ZEND_ASSERT(arg_info->name && "Parameter must have a name"); if (ZEND_TYPE_IS_SET(arg_info->type)) { @@ -2396,13 +2402,11 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio (reg_function->common.fn_flags & (ZEND_ACC_HAS_RETURN_TYPE|ZEND_ACC_HAS_TYPE_HINTS))) { /* convert "const char*" class type names into "zend_string*" */ uint32_t i; - uint32_t num_args = reg_function->common.num_args + 1; zend_arg_info *arg_info = reg_function->common.arg_info - 1; zend_arg_info *new_arg_info; - if (reg_function->common.fn_flags & ZEND_ACC_VARIADIC) { - num_args++; - } + /* Treat return type as an extra argument */ + num_args++; new_arg_info = malloc(sizeof(zend_arg_info) * num_args); memcpy(new_arg_info, arg_info, sizeof(zend_arg_info) * num_args); reg_function->common.arg_info = new_arg_info + 1; From fcd26ffcc3f3a1ce5e5bd78afd89c484e206e3ea Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Thu, 20 Aug 2020 11:20:03 +0200 Subject: [PATCH 048/170] Fix #80002: calc free space for new interned string is wrong We need to calculate the free size in bytes. Patch contributed by t-matsuno. Closes GH-6024 --- NEWS | 4 ++++ ext/opcache/ZendAccelerator.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 49ac4c5a69966..2dfd4e2fcb78f 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,10 @@ PHP NEWS . Fixed bug #80007 (Potential type confusion in unixtojd() parameter parsing). (Andy Postnikov) +- OPcache: + . Fixed bug #80002 (calc free space for new interned string is wrong). + (t-matsuno) + 03 Sep 2020, PHP 7.3.22 - Core: diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 80f94eaf28f2a..dd4808bb17f70 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -487,7 +487,7 @@ zend_string* ZEND_FASTCALL accel_new_interned_string(zend_string *str) } while (pos != STRTAB_INVALID_POS); } - if (UNEXPECTED(ZCSG(interned_strings).end - ZCSG(interned_strings).top < STRTAB_STR_SIZE(str))) { + if (UNEXPECTED((char*)ZCSG(interned_strings).end - (char*)ZCSG(interned_strings).top < STRTAB_STR_SIZE(str))) { /* no memory, return the same non-interned string */ zend_accel_error(ACCEL_LOG_WARNING, "Interned string buffer overflow"); return str; From 844a2dd6ac9e411e4f24d3a0beab9a23e820325c Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 18 Aug 2020 13:24:17 +0200 Subject: [PATCH 049/170] Fix #79986: str_ireplace bug with diacritics characters `tolower()` returns an `int`, so we must not convert to `char` which may be `signed` and as such may be subject to overflow (actually, implementation defined behavior). Closes GH-6007 --- NEWS | 3 +++ ext/standard/string.c | 2 +- ext/standard/tests/strings/bug79986.phpt | 13 +++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 ext/standard/tests/strings/bug79986.phpt diff --git a/NEWS b/NEWS index 2dfd4e2fcb78f..9666878056632 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,9 @@ PHP NEWS . Fixed bug #80002 (calc free space for new interned string is wrong). (t-matsuno) +- Standard: + . Fixed bug #79986 (str_ireplace bug with diacritics characters). (cmb) + 03 Sep 2020, PHP 7.3.22 - Core: diff --git a/ext/standard/string.c b/ext/standard/string.c index b070a5e827fd5..e4361a111460f 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -3156,7 +3156,7 @@ static zend_string* php_char_to_str_ex(zend_string *str, char from, char *to, si { zend_string *result; size_t char_count = 0; - char lc_from = 0; + int lc_from = 0; const char *source, *source_end= ZSTR_VAL(str) + ZSTR_LEN(str); char *target; diff --git a/ext/standard/tests/strings/bug79986.phpt b/ext/standard/tests/strings/bug79986.phpt new file mode 100644 index 0000000000000..fcbc72148c242 --- /dev/null +++ b/ext/standard/tests/strings/bug79986.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #79986 (str_ireplace bug with diacritics characters) +--SKIPIF-- + +--FILE-- + +--EXPECT-- +11 22 33 From 32c6a0bbbbeddc93d14273326ecd3604961d3f0d Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 16 Aug 2020 17:30:24 +0000 Subject: [PATCH 050/170] further network libraries detection for Haiku system. Closes GH-5997. --- configure.ac | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 45614f858102d..116bb6031f405 100644 --- a/configure.ac +++ b/configure.ac @@ -342,13 +342,13 @@ dnl Some systems (OpenServer 5) dislike -lsocket -lnsl, so we try to avoid -lnsl dnl checks, if we already have the functions which are usually in libnsl. Also, dnl uClibc will bark at linking with glibc's libnsl. -PHP_CHECK_FUNC(socket, socket) -PHP_CHECK_FUNC(socketpair, socket) -PHP_CHECK_FUNC(htonl, socket) -PHP_CHECK_FUNC(gethostname, nsl) -PHP_CHECK_FUNC(gethostbyaddr, nsl) -PHP_CHECK_FUNC(dlopen, dl) -PHP_CHECK_FUNC(dlsym, dl) +PHP_CHECK_FUNC(socket, socket, network) +PHP_CHECK_FUNC(socketpair, socket, network) +PHP_CHECK_FUNC(htonl, socket, network) +PHP_CHECK_FUNC(gethostname, nsl, network) +PHP_CHECK_FUNC(gethostbyaddr, nsl, network) +PHP_CHECK_FUNC(dlopen, dl, root) +PHP_CHECK_FUNC(dlsym, dl, root) if test "$ac_cv_func_dlopen" = "yes"; then AC_DEFINE(HAVE_LIBDL, 1, [ ]) fi From bfeb2f6abc35309f25074410ee7eb61f59c22274 Mon Sep 17 00:00:00 2001 From: Berbe <4251220+Berbe@users.noreply.github.com> Date: Wed, 19 Aug 2020 02:44:53 +0200 Subject: [PATCH 051/170] Fix: Gracefully handle empty user input in run-tests.php Closes GH-6016. --- run-tests.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-tests.php b/run-tests.php index af9f309bc6dac..8d62c8337599c 100755 --- a/run-tests.php +++ b/run-tests.php @@ -942,7 +942,7 @@ function save_or_mail_results(): void flush(); $user_input = fgets($fp, 10); - $just_save_results = (strtolower($user_input[0]) == 's'); + $just_save_results = (!empty($user_input) && strtolower($user_input[0]) === 's'); } if ($just_save_results || !getenv('NO_INTERACTION') || TRAVIS_CI) { From 6b6c2c003c69729832a7804c76bff6e230b73c91 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Mon, 24 Aug 2020 11:47:31 +0200 Subject: [PATCH 052/170] Fix #79979: passing value to by-ref param via CUFA crashes If a by-val send is not allowed, we must not do so. Instead we wrap the value in a temporary reference. Closes GH-6000 --- NEWS | 4 ++++ Zend/tests/bug79979.phpt | 17 +++++++++++++++++ Zend/zend_execute_API.c | 10 ++++++++-- Zend/zend_vm_def.h | 16 ++++++++++++++-- Zend/zend_vm_execute.h | 16 ++++++++++++++-- 5 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 Zend/tests/bug79979.phpt diff --git a/NEWS b/NEWS index 4342041a8dac4..58b0359c2844b 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,10 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2020, PHP 7.4.11 +- Core: + . Fixed bug #79979 (passing value to by-ref param via CUFA crashes). (cmb, + Nikita) + - Calendar: . Fixed bug #80007 (Potential type confusion in unixtojd() parameter parsing). (Andy Postnikov) diff --git a/Zend/tests/bug79979.phpt b/Zend/tests/bug79979.phpt new file mode 100644 index 0000000000000..8d7f30b7c83f0 --- /dev/null +++ b/Zend/tests/bug79979.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #79979 (passing value to by-ref param via CUF(A) crashes) +--FILE-- + +--EXPECTF-- +Warning: Parameter 4 to str_replace() expected to be a reference, value given in %s on line %d + +Warning: Parameter 4 to str_replace() expected to be a reference, value given in %s on line %d + +Warning: Parameter 4 to str_replace() expected to be a reference, value given in %s on line %d diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index f2881f70543c9..78a041d6ce2a7 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -757,6 +757,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / for (i=0; iparam_count; i++) { zval *param; zval *arg = &fci->params[i]; + zend_bool must_wrap = 0; if (ARG_SHOULD_BE_SENT_BY_REF(func, i + 1)) { if (UNEXPECTED(!Z_ISREF_P(arg))) { @@ -765,12 +766,13 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / ZVAL_NEW_REF(arg, arg); } else if (!ARG_MAY_BE_SENT_BY_REF(func, i + 1)) { /* By-value send is not allowed -- emit a warning, - * but still perform the call with a by-value send. */ + * and perform the call with the value wrapped in a reference. */ zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given", i+1, func->common.scope ? ZSTR_VAL(func->common.scope->name) : "", func->common.scope ? "::" : "", ZSTR_VAL(func->common.function_name)); + must_wrap = 1; if (UNEXPECTED(EG(exception))) { ZEND_CALL_NUM_ARGS(call) = i; zend_vm_stack_free_args(call); @@ -791,7 +793,11 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / } param = ZEND_CALL_ARG(call, i+1); - ZVAL_COPY(param, arg); + if (EXPECTED(!must_wrap)) { + ZVAL_COPY(param, arg); + } else { + ZVAL_NEW_REF(param, arg); + } } if (UNEXPECTED(func->op_array.fn_flags & ZEND_ACC_CLOSURE)) { diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index a5a2070b437b2..fa70bf9f966ad 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -5128,6 +5128,7 @@ ZEND_VM_C_LABEL(send_array): arg_num = 1; param = ZEND_CALL_ARG(EX(call), 1); ZEND_HASH_FOREACH_VAL(ht, arg) { + zend_bool must_wrap = 0; if (skip > 0) { skip--; continue; @@ -5139,6 +5140,7 @@ ZEND_VM_C_LABEL(send_array): /* By-value send is not allowed -- emit a warning, * but still perform the call. */ zend_param_must_be_ref(EX(call)->func, arg_num); + must_wrap = 1; } } } else { @@ -5148,7 +5150,11 @@ ZEND_VM_C_LABEL(send_array): arg = Z_REFVAL_P(arg); } } - ZVAL_COPY(param, arg); + if (EXPECTED(!must_wrap)) { + ZVAL_COPY(param, arg); + } else { + ZVAL_NEW_REF(param, arg); + } ZEND_CALL_NUM_ARGS(EX(call))++; arg_num++; param++; @@ -5160,12 +5166,14 @@ ZEND_VM_C_LABEL(send_array): arg_num = 1; param = ZEND_CALL_ARG(EX(call), 1); ZEND_HASH_FOREACH_VAL(ht, arg) { + zend_bool must_wrap = 0; if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) { if (UNEXPECTED(!Z_ISREF_P(arg))) { if (!ARG_MAY_BE_SENT_BY_REF(EX(call)->func, arg_num)) { /* By-value send is not allowed -- emit a warning, * but still perform the call. */ zend_param_must_be_ref(EX(call)->func, arg_num); + must_wrap = 1; } } } else { @@ -5175,7 +5183,11 @@ ZEND_VM_C_LABEL(send_array): arg = Z_REFVAL_P(arg); } } - ZVAL_COPY(param, arg); + if (EXPECTED(!must_wrap)) { + ZVAL_COPY(param, arg); + } else { + ZVAL_NEW_REF(param, arg); + } ZEND_CALL_NUM_ARGS(EX(call))++; arg_num++; param++; diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 6aa34bbd1094f..02b0ff24d15b6 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -2072,6 +2072,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_ARRAY_SPEC_HANDLER(ZEND_O arg_num = 1; param = ZEND_CALL_ARG(EX(call), 1); ZEND_HASH_FOREACH_VAL(ht, arg) { + zend_bool must_wrap = 0; if (skip > 0) { skip--; continue; @@ -2083,6 +2084,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_ARRAY_SPEC_HANDLER(ZEND_O /* By-value send is not allowed -- emit a warning, * but still perform the call. */ zend_param_must_be_ref(EX(call)->func, arg_num); + must_wrap = 1; } } } else { @@ -2092,7 +2094,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_ARRAY_SPEC_HANDLER(ZEND_O arg = Z_REFVAL_P(arg); } } - ZVAL_COPY(param, arg); + if (EXPECTED(!must_wrap)) { + ZVAL_COPY(param, arg); + } else { + ZVAL_NEW_REF(param, arg); + } ZEND_CALL_NUM_ARGS(EX(call))++; arg_num++; param++; @@ -2104,12 +2110,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_ARRAY_SPEC_HANDLER(ZEND_O arg_num = 1; param = ZEND_CALL_ARG(EX(call), 1); ZEND_HASH_FOREACH_VAL(ht, arg) { + zend_bool must_wrap = 0; if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) { if (UNEXPECTED(!Z_ISREF_P(arg))) { if (!ARG_MAY_BE_SENT_BY_REF(EX(call)->func, arg_num)) { /* By-value send is not allowed -- emit a warning, * but still perform the call. */ zend_param_must_be_ref(EX(call)->func, arg_num); + must_wrap = 1; } } } else { @@ -2119,7 +2127,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_ARRAY_SPEC_HANDLER(ZEND_O arg = Z_REFVAL_P(arg); } } - ZVAL_COPY(param, arg); + if (EXPECTED(!must_wrap)) { + ZVAL_COPY(param, arg); + } else { + ZVAL_NEW_REF(param, arg); + } ZEND_CALL_NUM_ARGS(EX(call))++; arg_num++; param++; From e056e2dae900775a4a8694279a2d92dedf3e65cd Mon Sep 17 00:00:00 2001 From: Tyson Andre Date: Sun, 23 Aug 2020 10:46:40 -0400 Subject: [PATCH 053/170] Check for duplicate names in gen_stub.php With named arguments in php 8.0, it's important that php's modules or PECL extensions using gen_stub.php don't generate functions with duplicate names. Warn if a parameter name is repeated, even if the last occurrence is a variadic parameter Closes GH-6035 --- build/gen_stub.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build/gen_stub.php b/build/gen_stub.php index fb79255e84948..214d1f563e737 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -646,6 +646,7 @@ function parseFunctionLike( } } + $varNameSet = []; $args = []; $numRequiredArgs = 0; $foundVariadic = false; @@ -654,6 +655,11 @@ function parseFunctionLike( $preferRef = !empty($paramMeta[$varName]['preferRef']); unset($paramMeta[$varName]); + if (isset($varNameSet[$varName])) { + throw new Exception("Duplicate parameter name $varName for function $name"); + } + $varNameSet[$varName] = true; + if ($preferRef) { $sendBy = ArgInfo::SEND_PREFER_REF; } else if ($param->byRef) { From bb54694f4fe3ec4637cae22a118d6f5738d831d2 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 24 Aug 2020 16:23:19 +0200 Subject: [PATCH 054/170] Fix refcounting --- Zend/zend_execute_API.c | 1 + Zend/zend_vm_def.h | 2 ++ Zend/zend_vm_execute.h | 2 ++ 3 files changed, 5 insertions(+) diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 78a041d6ce2a7..a62b9292ece54 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -796,6 +796,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / if (EXPECTED(!must_wrap)) { ZVAL_COPY(param, arg); } else { + Z_TRY_ADDREF_P(arg); ZVAL_NEW_REF(param, arg); } } diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index fa70bf9f966ad..233138cded1db 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -5153,6 +5153,7 @@ ZEND_VM_C_LABEL(send_array): if (EXPECTED(!must_wrap)) { ZVAL_COPY(param, arg); } else { + Z_TRY_ADDREF_P(arg); ZVAL_NEW_REF(param, arg); } ZEND_CALL_NUM_ARGS(EX(call))++; @@ -5186,6 +5187,7 @@ ZEND_VM_C_LABEL(send_array): if (EXPECTED(!must_wrap)) { ZVAL_COPY(param, arg); } else { + Z_TRY_ADDREF_P(arg); ZVAL_NEW_REF(param, arg); } ZEND_CALL_NUM_ARGS(EX(call))++; diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 02b0ff24d15b6..941c1c48f66c7 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -2097,6 +2097,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_ARRAY_SPEC_HANDLER(ZEND_O if (EXPECTED(!must_wrap)) { ZVAL_COPY(param, arg); } else { + Z_TRY_ADDREF_P(arg); ZVAL_NEW_REF(param, arg); } ZEND_CALL_NUM_ARGS(EX(call))++; @@ -2130,6 +2131,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_ARRAY_SPEC_HANDLER(ZEND_O if (EXPECTED(!must_wrap)) { ZVAL_COPY(param, arg); } else { + Z_TRY_ADDREF_P(arg); ZVAL_NEW_REF(param, arg); } ZEND_CALL_NUM_ARGS(EX(call))++; From 7a6ae9b14801f9f1745034888d3ed54b0b124b34 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 24 Aug 2020 16:30:49 +0200 Subject: [PATCH 055/170] Fix refcounting for the named params case as well Adjust the test case to pass a refcounted value and to also check the named params case. --- Zend/tests/bug79979.phpt | 13 +++++++++---- Zend/zend_execute_API.c | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Zend/tests/bug79979.phpt b/Zend/tests/bug79979.phpt index c41d3889e965e..d655a0edce577 100644 --- a/Zend/tests/bug79979.phpt +++ b/Zend/tests/bug79979.phpt @@ -2,12 +2,15 @@ Bug #79979 (passing value to by-ref param via CUF(A) crashes) --FILE-- new \stdClass]); + +\call_user_func_array("str_replace", ["a", "b", "c", new \stdClass]); +\call_user_func_array("str_replace", ["a", "b", "c", "replace_count" => new \stdClass]); -call_user_func_array($cufa, ["str_replace", ["a", "b", "c", 0]]); ?> --EXPECTF-- Warning: str_replace(): Argument #4 ($replace_count) must be passed by reference, value given in %s on line %d @@ -15,3 +18,5 @@ Warning: str_replace(): Argument #4 ($replace_count) must be passed by reference Warning: str_replace(): Argument #4 ($replace_count) must be passed by reference, value given in %s on line %d Warning: str_replace(): Argument #4 ($replace_count) must be passed by reference, value given in %s on line %d + +Warning: str_replace(): Argument #4 ($replace_count) must be passed by reference, value given in %s on line %d diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 5a0e2a48f1e2d..0e721c451e9a6 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -826,6 +826,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / if (EXPECTED(!must_wrap)) { ZVAL_COPY(target, arg); } else { + Z_TRY_ADDREF_P(arg); ZVAL_NEW_REF(target, arg); } if (!name) { From 8c3574bd6cc492d7e21e0f8b265a98817e3bb98a Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 24 Aug 2020 16:49:37 +0200 Subject: [PATCH 056/170] Remove php_my_setlocale workaround This works around a macro-expansion issue that is no longer relevant in PHP 8. --- ext/standard/string.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/ext/standard/string.c b/ext/standard/string.c index bf64fcdea885a..9c5830623fb11 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -26,19 +26,8 @@ # include #endif -/* - * This define is here because some versions of libintl redefine setlocale - * to point to libintl_setlocale. That's a ridiculous thing to do as far - * as I am concerned, but with this define and the subsequent undef we - * limit the damage to just the actual setlocale() call in this file - * without turning zif_setlocale into zif_libintl_setlocale. -Rasmus - */ -#define php_my_setlocale setlocale #ifdef HAVE_LIBINTL # include /* For LC_MESSAGES */ - #ifdef setlocale - # undef setlocale - #endif #endif #include "scanf.h" @@ -4661,7 +4650,7 @@ PHP_FUNCTION(setlocale) } # ifndef PHP_WIN32 - retval = php_my_setlocale(cat, loc ? ZSTR_VAL(loc) : NULL); + retval = setlocale(cat, loc ? ZSTR_VAL(loc) : NULL); # else if (loc) { /* BC: don't try /^[a-z]{2}_[A-Z]{2}($|\..*)/ except for /^u[ks]_U[KS]$/ */ @@ -4676,10 +4665,10 @@ PHP_FUNCTION(setlocale) ) { retval = NULL; } else { - retval = php_my_setlocale(cat, ZSTR_VAL(loc)); + retval = setlocale(cat, ZSTR_VAL(loc)); } } else { - retval = php_my_setlocale(cat, NULL); + retval = setlocale(cat, NULL); } # endif zend_update_current_locale(); From 9feb98859f12a119b7292bfc3ce9dd58f3c338e7 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 24 Aug 2020 17:09:33 +0200 Subject: [PATCH 057/170] Clean up setlocale implementation Factor out the core logic into a separate function and drop the "clever" code that combines iteration through variadic arguments and arrays. This fixes bug #79829 as a side effect. --- ext/standard/string.c | 188 +++++++++++++++++++++--------------------- 1 file changed, 92 insertions(+), 96 deletions(-) diff --git a/ext/standard/string.c b/ext/standard/string.c index 9c5830623fb11..c61d9911128d5 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -4600,116 +4600,112 @@ PHP_FUNCTION(strip_tags) } /* }}} */ -/* {{{ Set locale information */ -PHP_FUNCTION(setlocale) -{ - zval *args = NULL; - zval *plocale; - zend_string *loc; +static zend_string *try_setlocale_str(zend_long cat, zend_string *loc) { const char *retval; - zend_long cat; - int num_args, i = 0; - uint32_t idx; - ZEND_PARSE_PARAMETERS_START(2, -1) - Z_PARAM_LONG(cat) - Z_PARAM_VARIADIC('+', args, num_args) - ZEND_PARSE_PARAMETERS_END(); - - idx = 0; - while (1) { - if (Z_TYPE(args[0]) == IS_ARRAY) { - while (idx < Z_ARRVAL(args[0])->nNumUsed) { - plocale = &Z_ARRVAL(args[0])->arData[idx].val; - if (Z_TYPE_P(plocale) != IS_UNDEF) { - break; - } - idx++; - } - if (idx >= Z_ARRVAL(args[0])->nNumUsed) { - break; - } - } else { - plocale = &args[i]; - } - - loc = zval_try_get_string(plocale); - if (UNEXPECTED(!loc)) { - return; - } - - if (!strcmp("0", ZSTR_VAL(loc))) { - zend_string_release_ex(loc, 0); - loc = NULL; - } else { - if (ZSTR_LEN(loc) >= 255) { - php_error_docref(NULL, E_WARNING, "Specified locale name is too long"); - zend_string_release_ex(loc, 0); - break; - } + if (!strcmp("0", ZSTR_VAL(loc))) { + loc = NULL; + } else { + if (ZSTR_LEN(loc) >= 255) { + php_error_docref(NULL, E_WARNING, "Specified locale name is too long"); + return NULL; } + } # ifndef PHP_WIN32 - retval = setlocale(cat, loc ? ZSTR_VAL(loc) : NULL); + retval = setlocale(cat, loc ? ZSTR_VAL(loc) : NULL); # else - if (loc) { - /* BC: don't try /^[a-z]{2}_[A-Z]{2}($|\..*)/ except for /^u[ks]_U[KS]$/ */ - char *locp = ZSTR_VAL(loc); - if (ZSTR_LEN(loc) >= 5 && locp[2] == '_' - && locp[0] >= 'a' && locp[0] <= 'z' && locp[1] >= 'a' && locp[1] <= 'z' - && locp[3] >= 'A' && locp[3] <= 'Z' && locp[4] >= 'A' && locp[4] <= 'Z' - && (locp[5] == '\0' || locp[5] == '.') - && !(locp[0] == 'u' && (locp[1] == 'k' || locp[1] == 's') - && locp[3] == 'U' && (locp[4] == 'K' || locp[4] == 'S') - && locp[5] == '\0') - ) { - retval = NULL; - } else { - retval = setlocale(cat, ZSTR_VAL(loc)); - } + if (loc) { + /* BC: don't try /^[a-z]{2}_[A-Z]{2}($|\..*)/ except for /^u[ks]_U[KS]$/ */ + char *locp = ZSTR_VAL(loc); + if (ZSTR_LEN(loc) >= 5 && locp[2] == '_' + && locp[0] >= 'a' && locp[0] <= 'z' && locp[1] >= 'a' && locp[1] <= 'z' + && locp[3] >= 'A' && locp[3] <= 'Z' && locp[4] >= 'A' && locp[4] <= 'Z' + && (locp[5] == '\0' || locp[5] == '.') + && !(locp[0] == 'u' && (locp[1] == 'k' || locp[1] == 's') + && locp[3] == 'U' && (locp[4] == 'K' || locp[4] == 'S') + && locp[5] == '\0') + ) { + retval = NULL; } else { - retval = setlocale(cat, NULL); + retval = setlocale(cat, ZSTR_VAL(loc)); } + } else { + retval = setlocale(cat, NULL); + } # endif - zend_update_current_locale(); - if (retval) { - if (loc) { - /* Remember if locale was changed */ - size_t len = strlen(retval); - - BG(locale_changed) = 1; - if (cat == LC_CTYPE || cat == LC_ALL) { - if (BG(ctype_string)) { - zend_string_release_ex(BG(ctype_string), 0); - } - if (len == 1 && *retval == 'C') { - /* C locale is represented as NULL. */ - BG(ctype_string) = NULL; - zend_string_release_ex(loc, 0); - RETURN_CHAR('C'); - } else if (len == ZSTR_LEN(loc) && !memcmp(ZSTR_VAL(loc), retval, len)) { - BG(ctype_string) = zend_string_copy(loc); - RETURN_STR(BG(ctype_string)); - } else { - BG(ctype_string) = zend_string_init(retval, len, 0); - zend_string_release_ex(loc, 0); - RETURN_STR_COPY(BG(ctype_string)); - } - } else if (len == ZSTR_LEN(loc) && !memcmp(ZSTR_VAL(loc), retval, len)) { - RETURN_STR(loc); - } + zend_update_current_locale(); + if (!retval) { + return NULL; + } + + if (loc) { + /* Remember if locale was changed */ + size_t len = strlen(retval); + + BG(locale_changed) = 1; + if (cat == LC_CTYPE || cat == LC_ALL) { + if (BG(ctype_string)) { + zend_string_release_ex(BG(ctype_string), 0); + } + if (len == 1 && *retval == 'C') { + /* C locale is represented as NULL. */ + BG(ctype_string) = NULL; zend_string_release_ex(loc, 0); + return ZSTR_CHAR('C'); + } else if (len == ZSTR_LEN(loc) && !memcmp(ZSTR_VAL(loc), retval, len)) { + BG(ctype_string) = zend_string_copy(loc); + return zend_string_copy(BG(ctype_string)); + } else { + BG(ctype_string) = zend_string_init(retval, len, 0); + return zend_string_copy(BG(ctype_string)); } - RETURN_STRING(retval); - } - if (loc) { - zend_string_release_ex(loc, 0); + } else if (len == ZSTR_LEN(loc) && !memcmp(ZSTR_VAL(loc), retval, len)) { + return zend_string_copy(loc); } + } + return zend_string_init(retval, strlen(retval), 0); +} + +static zend_string *try_setlocale_zval(zend_long cat, zval *loc_zv) { + zend_string *loc_str = zval_try_get_string(loc_zv); + zend_string *result = try_setlocale_str(cat, loc_str); + zend_string_release_ex(loc_str, 0); + return result; +} + +/* {{{ Set locale information */ +PHP_FUNCTION(setlocale) +{ + zend_long cat; + zval *args = NULL; + int num_args; + + ZEND_PARSE_PARAMETERS_START(2, -1) + Z_PARAM_LONG(cat) + Z_PARAM_VARIADIC('+', args, num_args) + ZEND_PARSE_PARAMETERS_END(); - if (Z_TYPE(args[0]) == IS_ARRAY) { - idx++; + for (uint32_t i = 0; i < num_args; i++) { + if (Z_TYPE(args[i]) == IS_ARRAY) { + zval *elem; + ZEND_HASH_FOREACH_VAL_IND(Z_ARRVAL(args[i]), elem) { + zend_string *result = try_setlocale_zval(cat, elem); + if (EG(exception)) { + RETURN_THROWS(); + } + if (result) { + RETURN_STR(result); + } + } ZEND_HASH_FOREACH_END(); } else { - if (++i >= num_args) break; + zend_string *result = try_setlocale_zval(cat, &args[i]); + if (EG(exception)) { + RETURN_THROWS(); + } + if (result) { + RETURN_STR(result); + } } } From c557c410af5bd039175e531769d8882e486bcd62 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 24 Aug 2020 17:30:31 +0200 Subject: [PATCH 058/170] Drop a spurious zend_string_release This should have been dropped in the refactoring. --- ext/standard/string.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ext/standard/string.c b/ext/standard/string.c index c61d9911128d5..b8572671fa2bf 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -4651,7 +4651,6 @@ static zend_string *try_setlocale_str(zend_long cat, zend_string *loc) { if (len == 1 && *retval == 'C') { /* C locale is represented as NULL. */ BG(ctype_string) = NULL; - zend_string_release_ex(loc, 0); return ZSTR_CHAR('C'); } else if (len == ZSTR_LEN(loc) && !memcmp(ZSTR_VAL(loc), retval, len)) { BG(ctype_string) = zend_string_copy(loc); From cc35cfd2eb95eeacfa11e9f4b824d0ec1c43ec39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Mon, 10 Aug 2020 19:06:55 +0200 Subject: [PATCH 059/170] Promote warnings to exceptions in ext/filter Closes GH-5970 --- ext/filter/callback_filter.c | 2 +- ext/filter/filter.c | 23 +++++++++++++++-------- ext/filter/filter_private.h | 15 +++++++++------ ext/filter/logical_filters.c | 8 ++++---- ext/filter/tests/017.phpt | 12 +++++++----- ext/filter/tests/029.phpt | 33 +++++++++++++++++++++------------ ext/filter/tests/031.phpt | 13 +++++++------ ext/filter/tests/039.phpt | 23 +++++++++++++---------- ext/filter/tests/040.phpt | 13 ++++++++----- ext/filter/tests/055.phpt | 16 ++++++++-------- ext/filter/tests/bug51368.phpt | 14 +++++++++----- 11 files changed, 102 insertions(+), 70 deletions(-) diff --git a/ext/filter/callback_filter.c b/ext/filter/callback_filter.c index edba63e5627dd..68b69e9680c09 100644 --- a/ext/filter/callback_filter.c +++ b/ext/filter/callback_filter.c @@ -23,7 +23,7 @@ void php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL) int status; if (!option_array || !zend_is_callable(option_array, 0, NULL)) { - php_error_docref(NULL, E_WARNING, "First argument is expected to be a valid callback"); + zend_type_error("%s(): Option must be a valid callback", get_active_function_name()); zval_ptr_dtor(value); ZVAL_NULL(value); return; diff --git a/ext/filter/filter.c b/ext/filter/filter.c index d049c34c4fbe2..37fac29de93d8 100644 --- a/ext/filter/filter.c +++ b/ext/filter/filter.c @@ -487,8 +487,8 @@ static zval *php_filter_get_storage(zend_long arg)/* {{{ */ array_ptr = !Z_ISUNDEF(IF_G(env_array)) ? &IF_G(env_array) : &PG(http_globals)[TRACK_VARS_ENV]; break; default: - php_error_docref(NULL, E_WARNING, "Unknown source"); - break; + zend_argument_value_error(1, "must be an INPUT_* constant"); + return NULL; } if (array_ptr && Z_TYPE_P(array_ptr) != IS_ARRAY) { @@ -512,6 +512,9 @@ PHP_FUNCTION(filter_has_var) } array_ptr = php_filter_get_storage(arg); + if (EG(exception)) { + RETURN_THROWS(); + } if (array_ptr && zend_hash_exists(Z_ARRVAL_P(array_ptr), var)) { RETURN_TRUE; @@ -614,14 +617,12 @@ static void php_filter_array_handler(zval *input, zval *op, zval *return_value, ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(op), arg_key, arg_elm) { if (arg_key == NULL) { - php_error_docref(NULL, E_WARNING, "Numeric keys are not allowed in the definition array"); - zval_ptr_dtor(return_value); - RETURN_FALSE; + zend_argument_type_error(2, "must contain only string keys"); + RETURN_THROWS(); } if (ZSTR_LEN(arg_key) == 0) { - php_error_docref(NULL, E_WARNING, "Empty keys are not allowed in the definition array"); - zval_ptr_dtor(return_value); - RETURN_FALSE; + zend_argument_value_error(2, "cannot contain empty keys"); + RETURN_THROWS(); } if ((tmp = zend_hash_find(Z_ARRVAL_P(input), arg_key)) == NULL) { if (add_empty) { @@ -658,6 +659,9 @@ PHP_FUNCTION(filter_input) } input = php_filter_get_storage(fetch_from); + if (EG(exception)) { + RETURN_THROWS(); + } if (!input || (tmp = zend_hash_find(Z_ARRVAL_P(input), var)) == NULL) { zend_long filter_flags = 0; @@ -731,6 +735,9 @@ PHP_FUNCTION(filter_input_array) } array_input = php_filter_get_storage(fetch_from); + if (EG(exception)) { + RETURN_THROWS(); + } if (!array_input) { zend_long filter_flags = 0; diff --git a/ext/filter/filter_private.h b/ext/filter/filter_private.h index f8a02a4907797..0db29dc698d92 100644 --- a/ext/filter/filter_private.h +++ b/ext/filter/filter_private.h @@ -92,12 +92,15 @@ || (id >= FILTER_VALIDATE_ALL && id <= FILTER_VALIDATE_LAST) \ || id == FILTER_CALLBACK) -#define RETURN_VALIDATION_FAILED \ - zval_ptr_dtor(value); \ - if (flags & FILTER_NULL_ON_FAILURE) { \ - ZVAL_NULL(value); \ - } else { \ - ZVAL_FALSE(value); \ +#define RETURN_VALIDATION_FAILED \ + if (EG(exception)) { \ + return; \ + } else if (flags & FILTER_NULL_ON_FAILURE) { \ + zval_ptr_dtor(value); \ + ZVAL_NULL(value); \ + } else { \ + zval_ptr_dtor(value); \ + ZVAL_FALSE(value); \ } \ return; \ diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c index 76b0b977b37e7..a9fcc01d01972 100644 --- a/ext/filter/logical_filters.c +++ b/ext/filter/logical_filters.c @@ -360,7 +360,7 @@ void php_filter_float(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ if (decimal_set) { if (decimal_len != 1) { - php_error_docref(NULL, E_WARNING, "Decimal separator must be one char"); + zend_value_error("%s(): \"decimal\" option must be one character long", get_active_function_name()); RETURN_VALIDATION_FAILED } else { dec_sep = *decimal; @@ -371,7 +371,7 @@ void php_filter_float(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ if (thousand_set) { if (thousand_len < 1) { - php_error_docref(NULL, E_WARNING, "Thousand separator must be at least one char"); + zend_value_error("%s(): \"thousand\" option cannot be empty", get_active_function_name()); RETURN_VALIDATION_FAILED } else { tsd_sep = thousand; @@ -472,7 +472,7 @@ void php_filter_validate_regexp(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ FETCH_STR_OPTION(regexp, "regexp"); if (!regexp_set) { - php_error_docref(NULL, E_WARNING, "'regexp' option missing"); + zend_value_error("%s(): \"regexp\" option is missing", get_active_function_name()); RETURN_VALIDATION_FAILED } @@ -919,7 +919,7 @@ void php_filter_validate_mac(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ FETCH_STRING_OPTION(exp_separator, "separator"); if (exp_separator_set && exp_separator_len != 1) { - php_error_docref(NULL, E_WARNING, "Separator must be exactly one character long"); + zend_value_error("%s(): \"separator\" option must be one character long", get_active_function_name()); RETURN_VALIDATION_FAILED; } diff --git a/ext/filter/tests/017.phpt b/ext/filter/tests/017.phpt index d11688ecebeb1..c641e3cedcf39 100644 --- a/ext/filter/tests/017.phpt +++ b/ext/filter/tests/017.phpt @@ -10,17 +10,19 @@ var_dump(filter_var("data", FILTER_VALIDATE_REGEXP, array("options"=>array("rege var_dump(filter_var("data", FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>'/^d(.*)/')))); var_dump(filter_var("data", FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>'/blah/')))); var_dump(filter_var("data", FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>'/\[/')))); -var_dump(filter_var("data", FILTER_VALIDATE_REGEXP)); +try { + filter_var("data", FILTER_VALIDATE_REGEXP); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- string(4) "data" bool(false) string(4) "data" bool(false) bool(false) - -Warning: filter_var(): 'regexp' option missing in %s on line %d -bool(false) +filter_var(): "regexp" option is missing Done diff --git a/ext/filter/tests/029.phpt b/ext/filter/tests/029.phpt index fc191f1710aa0..53d7dd77f37fc 100644 --- a/ext/filter/tests/029.phpt +++ b/ext/filter/tests/029.phpt @@ -13,9 +13,24 @@ function test($var) { var_dump(filter_var("data", FILTER_CALLBACK, array("options"=>"test"))); var_dump(filter_var("~!@#$%^&*()_QWERTYUIOPASDFGHJKLZXCVBNM<>>?\"}{:", FILTER_CALLBACK, array("options"=>"test"))); var_dump(filter_var("", FILTER_CALLBACK, array("options"=>"test"))); -var_dump(filter_var("qwe", FILTER_CALLBACK, array("options"=>"no such func"))); -var_dump(filter_var("qwe", FILTER_CALLBACK, array("options"=>""))); -var_dump(filter_var("qwe", FILTER_CALLBACK)); + +try { + filter_var("qwe", FILTER_CALLBACK, array("options"=>"no such func")); +} catch (TypeError $exception) { + echo $exception->getMessage() . "\n"; +} + +try { + filter_var("qwe", FILTER_CALLBACK, array("options"=>"")); +} catch (TypeError $exception) { + echo $exception->getMessage() . "\n"; +} + +try { + filter_var("qwe", FILTER_CALLBACK); +} catch (TypeError $exception) { + echo $exception->getMessage() . "\n"; +} /* Simple class method callback */ class test_class { @@ -62,15 +77,9 @@ echo "Done\n"; string(4) "DATA" string(46) "~!@#$%^&*()_QWERTYUIOPASDFGHJKLZXCVBNM<>>?"}{:" string(0) "" - -Warning: filter_var(): First argument is expected to be a valid callback in %s on line %d -NULL - -Warning: filter_var(): First argument is expected to be a valid callback in %s on line %d -NULL - -Warning: filter_var(): First argument is expected to be a valid callback in %s on line %d -NULL +filter_var(): Option must be a valid callback +filter_var(): Option must be a valid callback +filter_var(): Option must be a valid callback string(4) "data" string(46) "~!@#$%^&*()_qwertyuiopasdfghjklzxcvbnm<>>?"}{:" string(0) "" diff --git a/ext/filter/tests/031.phpt b/ext/filter/tests/031.phpt index 2968decafc763..0ef9f68930e67 100644 --- a/ext/filter/tests/031.phpt +++ b/ext/filter/tests/031.phpt @@ -33,12 +33,15 @@ $floats = array( echo "\ncustom decimal:\n"; foreach ($floats as $float => $dec) { - $out = filter_var($float, FILTER_VALIDATE_FLOAT, array("options"=>array('decimal' => $dec))); - var_dump($out); + try { + var_dump(filter_var($float, FILTER_VALIDATE_FLOAT, array("options"=>array('decimal' => $dec)))); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } ?> ---EXPECTF-- +--EXPECT-- float(1.234) float(1.234) float(1.234) @@ -52,7 +55,5 @@ custom decimal: bool(false) float(1.234) float(1.234) - -Warning: filter_var(): Decimal separator must be one char in %s on line %d -bool(false) +filter_var(): "decimal" option must be one character long bool(false) diff --git a/ext/filter/tests/039.phpt b/ext/filter/tests/039.phpt index bdd090ae86f8e..f5a1cf2fe7c22 100644 --- a/ext/filter/tests/039.phpt +++ b/ext/filter/tests/039.phpt @@ -30,9 +30,16 @@ var_dump(filter_var_array(array(), array("var_name"=>-1))); var_dump(filter_var_array(array("var_name"=>""), array("var_name"=>-1))); echo "-- (5)\n"; -var_dump(filter_var_array(array("var_name"=>""), array("var_name"=>-1, "asdas"=>"asdasd", "qwe"=>"rty", ""=>""))); -var_dump(filter_var_array(array("asdas"=>"text"), array("var_name"=>-1, "asdas"=>"asdasd", "qwe"=>"rty", ""=>""))); - +try { + filter_var_array(array("var_name"=>""), array("var_name"=>-1, "asdas"=>"asdasd", "qwe"=>"rty", ""=>"")); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} +try { + filter_var_array(array("asdas"=>"text"), array("var_name"=>-1, "asdas"=>"asdasd", "qwe"=>"rty", ""=>"")); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} $a = array(""=>""); $b = -1; var_dump(filter_var_array($a, $b)); @@ -48,7 +55,7 @@ var_dump($a, $b); echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- -- (1) array(0) { } @@ -86,12 +93,8 @@ array(1) { string(0) "" } -- (5) - -Warning: filter_var_array(): Empty keys are not allowed in the definition array in %s on line %d -bool(false) - -Warning: filter_var_array(): Empty keys are not allowed in the definition array in %s on line %d -bool(false) +filter_var_array(): Argument #2 ($options) cannot contain empty keys +filter_var_array(): Argument #2 ($options) cannot contain empty keys bool(false) array(1) { [""]=> diff --git a/ext/filter/tests/040.phpt b/ext/filter/tests/040.phpt index f6de3eb84cf6e..6f0a79199f2ef 100644 --- a/ext/filter/tests/040.phpt +++ b/ext/filter/tests/040.phpt @@ -16,12 +16,17 @@ var_dump(filter_has_var(INPUT_GET, "a")); var_dump(filter_has_var(INPUT_GET, "c")); var_dump(filter_has_var(INPUT_GET, "abc")); var_dump(filter_has_var(INPUT_GET, "cc")); -var_dump(filter_has_var(-1, "cc")); +try { + filter_has_var(-1, "cc"); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + var_dump(filter_has_var(0, "cc")); echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- bool(false) bool(true) bool(true) @@ -29,8 +34,6 @@ bool(true) bool(true) bool(false) bool(false) - -Warning: filter_has_var(): Unknown source in %s on line %d -bool(false) +filter_has_var(): Argument #1 ($type) must be an INPUT_* constant bool(false) Done diff --git a/ext/filter/tests/055.phpt b/ext/filter/tests/055.phpt index 896dda833825b..0edc241efdc6a 100644 --- a/ext/filter/tests/055.phpt +++ b/ext/filter/tests/055.phpt @@ -21,12 +21,16 @@ $values = Array( array("01-23-45-67-89-ab", array("options" => array("separator" => ""))), ); foreach ($values as $value) { - var_dump(filter_var($value[0], FILTER_VALIDATE_MAC, $value[1])); + try { + var_dump(filter_var($value[0], FILTER_VALIDATE_MAC, $value[1])); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- string(17) "01-23-45-67-89-ab" string(17) "01-23-45-67-89-ab" bool(false) @@ -39,10 +43,6 @@ string(17) "01:23:45:67:89:aB" bool(false) bool(false) string(14) "0123.4567.89ab" - -Warning: filter_var(): Separator must be exactly one character long in %s055.php on line %d -bool(false) - -Warning: filter_var(): Separator must be exactly one character long in %s055.php on line %d -bool(false) +filter_var(): "separator" option must be one character long +filter_var(): "separator" option must be one character long Done diff --git a/ext/filter/tests/bug51368.phpt b/ext/filter/tests/bug51368.phpt index 38ae03ca95909..ebe33a104183d 100644 --- a/ext/filter/tests/bug51368.phpt +++ b/ext/filter/tests/bug51368.phpt @@ -12,11 +12,15 @@ var_dump( filter_var('1 234.567', FILTER_VALIDATE_FLOAT, $options) ); $options = ['flags' => FILTER_FLAG_ALLOW_THOUSAND, 'options' => ['thousand' => '']]; -var_dump(filter_var('12345', FILTER_VALIDATE_FLOAT, $options)); + +try { + filter_var('12345', FILTER_VALIDATE_FLOAT, $options); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + ?> ---EXPECTF-- +--EXPECT-- float(1000) float(1234.567) - -Warning: filter_var(): Thousand separator must be at least one char in %s on line %d -bool(false) +filter_var(): "thousand" option cannot be empty From ffff23749744bc5390459987c90e9a7fb8a289d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Tue, 18 Aug 2020 14:24:46 +0200 Subject: [PATCH 060/170] Promote warning to exception in ext/posix Closes GH-6009 --- ext/posix/posix.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/ext/posix/posix.c b/ext/posix/posix.c index cc3dd42cbc75c..bb86b5324b59b 100644 --- a/ext/posix/posix.c +++ b/ext/posix/posix.c @@ -655,14 +655,9 @@ PHP_FUNCTION(posix_mknod) } if ((mode & S_IFCHR) || (mode & S_IFBLK)) { - if (ZEND_NUM_ARGS() == 2) { - php_error_docref(NULL, E_WARNING, "For S_IFCHR and S_IFBLK you need to pass a major device kernel identifier"); - RETURN_FALSE; - } if (major == 0) { - php_error_docref(NULL, E_WARNING, - "Expects argument 3 to be non-zero for POSIX_S_IFCHR and POSIX_S_IFBLK"); - RETURN_FALSE; + zend_argument_value_error(3, "cannot be 0 for the POSIX_S_IFCHR and POSIX_S_IFBLK modes"); + RETURN_THROWS(); } else { #if defined(HAVE_MAKEDEV) || defined(makedev) php_dev = makedev(major, minor); From 74de17f2ea9c7485701ada23fa935f9800b5b275 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Mon, 24 Aug 2020 17:32:06 +0200 Subject: [PATCH 061/170] Fix potential integer overflow detected by oss-fuzz We port the respective fix from upstream[1]. [1] --- ext/gd/libgd/gd.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index 3e3b359666d6a..29ad19aa34d0d 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -1463,6 +1463,8 @@ void gdImageChar (gdImagePtr im, gdFontPtr f, int x, int y, int c, int color) int cx, cy; int px, py; int fline; + const int xuppper = (x > INT_MAX - f->w) ? INT_MAX : x + f->w; + const int yuppper = (y > INT_MAX - f->h) ? INT_MAX : y + f->h; cx = 0; cy = 0; #ifdef CHARSET_EBCDIC @@ -1472,8 +1474,8 @@ void gdImageChar (gdImagePtr im, gdFontPtr f, int x, int y, int c, int color) return; } fline = (c - f->offset) * f->h * f->w; - for (py = y; (py < (y + f->h)); py++) { - for (px = x; (px < (x + f->w)); px++) { + for (py = y; py < yuppper; py++) { + for (px = x; px < xuppper; px++) { if (f->data[fline + cy * f->w + cx]) { gdImageSetPixel(im, px, py, color); } @@ -1489,6 +1491,8 @@ void gdImageCharUp (gdImagePtr im, gdFontPtr f, int x, int y, int c, int color) int cx, cy; int px, py; int fline; + const int xuppper = (x > INT_MAX - f->h) ? INT_MAX : x + f->h; + const int ylower = (y < INT_MIN + f->w) ? INT_MIN : y - f->w; cx = 0; cy = 0; #ifdef CHARSET_EBCDIC @@ -1498,8 +1502,8 @@ void gdImageCharUp (gdImagePtr im, gdFontPtr f, int x, int y, int c, int color) return; } fline = (c - f->offset) * f->h * f->w; - for (py = y; py > (y - f->w); py--) { - for (px = x; px < (x + f->h); px++) { + for (py = y; py > ylower; py--) { + for (px = x; px < xuppper; px++) { if (f->data[fline + cy * f->w + cx]) { gdImageSetPixel(im, px, py, color); } From 1fb66b811445755cf50303589ce2c45111644165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 19 Aug 2020 22:43:07 +0200 Subject: [PATCH 062/170] Promote warning to exception in ext/enchant Closes GH-6022 --- ext/enchant/enchant.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/enchant/enchant.c b/ext/enchant/enchant.c index 3ebb76e910f3a..566197582073c 100644 --- a/ext/enchant/enchant.c +++ b/ext/enchant/enchant.c @@ -307,8 +307,8 @@ PHP_FUNCTION(enchant_broker_free) PHP_ENCHANT_GET_BROKER; if (pbroker->nb_dict > 0) { - php_error_docref(NULL, E_WARNING, "Cannot free EnchantBroker object with open EnchantDictionary objects"); - RETURN_FALSE; + zend_throw_error(NULL, "Cannot free EnchantBroker object with open EnchantDictionary objects"); + RETURN_THROWS(); } if (pbroker->pbroker) { enchant_broker_free(pbroker->pbroker); From ef7904b35c55c49f9a94e9baec4cf8a25d5772e4 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 24 Aug 2020 15:22:52 +0300 Subject: [PATCH 063/170] JIT for MATCH and CASE_STRICT instructions --- ext/opcache/jit/zend_jit.c | 1 + ext/opcache/jit/zend_jit_trace.c | 3 + ext/opcache/jit/zend_jit_x86.dasc | 324 ++++++++++++++++++------------ 3 files changed, 196 insertions(+), 132 deletions(-) diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index 2956591490d3c..fdce38f4d656a 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -2633,6 +2633,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op } case ZEND_IS_IDENTICAL: case ZEND_IS_NOT_IDENTICAL: + case ZEND_CASE_STRICT: if ((opline->result_type & IS_TMP_VAR) && (i + 1) <= end && ((opline+1)->opcode == ZEND_JMPZ diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index 6ad080003693a..62b0b9d6a1675 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -257,6 +257,7 @@ static int zend_jit_trace_may_exit(const zend_op_array *op_array, const zend_op case ZEND_IS_SMALLER: case ZEND_IS_SMALLER_OR_EQUAL: case ZEND_CASE: + case ZEND_CASE_STRICT: case ZEND_ISSET_ISEMPTY_CV: case ZEND_ISSET_ISEMPTY_VAR: case ZEND_ISSET_ISEMPTY_DIM_OBJ: @@ -1420,6 +1421,7 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin case ZEND_CASE: case ZEND_IS_IDENTICAL: case ZEND_IS_NOT_IDENTICAL: + case ZEND_CASE_STRICT: case ZEND_FETCH_DIM_R: case ZEND_FETCH_DIM_IS: case ZEND_BW_OR: @@ -3726,6 +3728,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par goto done; case ZEND_IS_IDENTICAL: case ZEND_IS_NOT_IDENTICAL: + case ZEND_CASE_STRICT: op1_info = OP1_INFO(); CHECK_OP1_TRACE_TYPE(); op2_info = OP2_INFO(); diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index 49459267e7e24..ffe96e65bb2f0 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -7197,7 +7197,7 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, uint32_t uint32_t not_identical_label = (uint32_t)-1; if (smart_branch_opcode && !exit_addr) { - if (opline->opcode == ZEND_IS_IDENTICAL) { + if (opline->opcode != ZEND_IS_NOT_IDENTICAL) { if (smart_branch_opcode == ZEND_JMPZ) { not_identical_label = target_label; } else if (smart_branch_opcode == ZEND_JMPNZ) { @@ -7208,7 +7208,7 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, uint32_t } else { ZEND_UNREACHABLE(); } - } else if (opline->opcode == ZEND_IS_NOT_IDENTICAL) { + } else { if (smart_branch_opcode == ZEND_JMPZ) { identical_label = target_label; } else if (smart_branch_opcode == ZEND_JMPNZ) { @@ -7219,8 +7219,6 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, uint32_t } else { ZEND_UNREACHABLE(); } - } else { - ZEND_UNREACHABLE(); } } @@ -7343,12 +7341,15 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, uint32_t } if ((op1_info & op2_info & MAY_BE_ANY) == 0) { - if (((opline->op1_type & (IS_VAR|IS_TMP_VAR)) && + if ((opline->opcode != ZEND_CASE_STRICT && + (opline->op1_type & (IS_VAR|IS_TMP_VAR)) && (op1_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF))) || ((opline->op2_type & (IS_VAR|IS_TMP_VAR)) && (op2_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)))) { | SAVE_VALID_OPLINE opline, r0 - | FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline + if (opline->opcode != ZEND_CASE_STRICT) { + | FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline + } | FREE_OP opline->op2_type, opline->op2, op2_info, 1, opline } if (smart_branch_opcode) { @@ -7458,7 +7459,8 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, uint32_t | cmp byte [FCARG1a + offsetof(zval, u1.v.type)], Z_TYPE_P(val) if (smart_branch_opcode) { - if (opline->op1_type == IS_VAR && (op1_info & MAY_BE_REF)) { + if (opline->opcode != ZEND_CASE_STRICT + && opline->op1_type == IS_VAR && (op1_info & MAY_BE_REF)) { | jne >8 | SAVE_VALID_OPLINE opline, r0 | FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline @@ -7488,7 +7490,8 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, uint32_t | lea eax, [eax + 2] | SET_ZVAL_TYPE_INFO res_addr, eax } - if ((opline->op1_type & (IS_VAR|IS_TMP_VAR)) && + if (opline->opcode != ZEND_CASE_STRICT + && (opline->op1_type & (IS_VAR|IS_TMP_VAR)) && (op1_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF))) { | SAVE_VALID_OPLINE opline, r0 | FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline @@ -7511,13 +7514,16 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, uint32_t | LOAD_ZVAL_ADDR FCARG2a, op2_addr } | EXT_CALL zend_is_identical, r0 - if (((opline->op1_type & (IS_VAR|IS_TMP_VAR)) && + if ((opline->opcode != ZEND_CASE_STRICT && + (opline->op1_type & (IS_VAR|IS_TMP_VAR)) && (op1_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF))) || ((opline->op2_type & (IS_VAR|IS_TMP_VAR)) && (op2_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)))) { | mov aword T1, r0 // save | SAVE_VALID_OPLINE opline, r0 - | FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline + if (opline->opcode != ZEND_CASE_STRICT) { + | FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline + } | FREE_OP opline->op2_type, opline->op2, op2_info, 1, opline zend_jit_check_exception_undef_result(Dst, opline); | mov r0, aword T1 // restore @@ -11840,6 +11846,81 @@ static int zend_jit_fetch_this(dasm_State **Dst, const zend_op *opline, const ze return 1; } +static int zend_jit_hash_jmp(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, zend_ssa *ssa, HashTable *jumptable, int default_b, const void *default_label, const zend_op *next_opline, zend_jit_trace_info *trace_info) +{ + uint32_t count; + Bucket *p; + const zend_op *target; + int b; + int32_t exit_point; + const void *exit_addr; + + | test r0, r0 + if (default_label) { + | jz &default_label + } else if (next_opline) { + | jz >3 + } else { + | jz =>default_b + } + | LOAD_ADDR FCARG1a, jumptable + | sub r0, aword [FCARG1a + offsetof(HashTable, arData)] + | mov FCARG1a, (sizeof(Bucket) / sizeof(void*)) + |.if X64 + | cqo + |.else + | cdq + |.endif + | idiv FCARG1a + |.if X64 + if (!IS_32BIT(dasm_end)) { + | lea FCARG1a, aword [>4] + | jmp aword [FCARG1a + r0] + } else { + | jmp aword [r0 + >4] + } + |.else + | jmp aword [r0 + >4] + |.endif + |.jmp_table + |.align aword + |4: + if (trace_info) { + trace_info->jmp_table_size += zend_hash_num_elements(jumptable); + } + + count = jumptable->nNumUsed; + p = jumptable->arData; + do { + if (Z_TYPE(p->val) == IS_UNDEF) { + if (default_label) { + | .aword &default_label + } else if (next_opline) { + | .aword >3 + } else { + | .aword =>default_b + } + } else { + target = ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL(p->val)); + if (!next_opline) { + b = ssa->cfg.map[target - op_array->opcodes]; + | .aword =>b + } else if (next_opline == target) { + | .aword >3 + } else { + exit_point = zend_jit_trace_get_exit_point(target, 0); + exit_addr = zend_jit_trace_get_exit_addr(exit_point); + | .aword &exit_addr + } + } + p++; + count--; + } while (count); + |.code + + return 1; +} + static int zend_jit_switch(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, zend_ssa *ssa, zend_jit_trace_rec *trace, zend_jit_trace_info *trace_info) { HashTable *jumptable = Z_ARRVAL_P(RT_CONSTANT(opline, opline->op2)); @@ -11851,53 +11932,45 @@ static int zend_jit_switch(dasm_State **Dst, const zend_op *opline, const zend_o next_opline = trace->opline; } - // TODO: Implement for match instructions - if (opline->opcode == ZEND_MATCH) { - // Since the match expression doesn't have a IS_IDENTICAL/JMPNZ chain - // we can't skip the jumptable and thus can't JIT the function - return 0; - } - if (opline->op1_type == IS_CONST) { zval *zv = RT_CONSTANT(opline, opline->op1); - zval *jump_zv; + zval *jump_zv = NULL; int b; if (opline->opcode == ZEND_SWITCH_LONG) { if (Z_TYPE_P(zv) == IS_LONG) { jump_zv = zend_hash_index_find(jumptable, Z_LVAL_P(zv)); - if (next_opline) { - const zend_op *target = ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL_P(jump_zv)); - - ZEND_ASSERT(target == next_opline); - } else { - if (jump_zv != NULL) { - b = ssa->cfg.map[ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL_P(jump_zv)) - op_array->opcodes]; - } else { - b = ssa->cfg.map[ZEND_OFFSET_TO_OPLINE(opline, opline->extended_value) - op_array->opcodes]; - } - | jmp =>b - } } } else if (opline->opcode == ZEND_SWITCH_STRING) { if (Z_TYPE_P(zv) == IS_STRING) { jump_zv = zend_hash_find_ex(jumptable, Z_STR_P(zv), 1); - if (next_opline) { - const zend_op *target = ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL_P(jump_zv)); - - ZEND_ASSERT(target == next_opline); - } else { - if (jump_zv != NULL) { - b = ssa->cfg.map[ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL_P(jump_zv)) - op_array->opcodes]; - } else { - b = ssa->cfg.map[ZEND_OFFSET_TO_OPLINE(opline, opline->extended_value) - op_array->opcodes]; - } - | jmp =>b - } + } + } else if (opline->opcode == ZEND_MATCH) { + if (Z_TYPE_P(zv) == IS_LONG) { + jump_zv = zend_hash_index_find(jumptable, Z_LVAL_P(zv)); + } else if (Z_TYPE_P(zv) == IS_STRING) { + jump_zv = zend_hash_find_ex(jumptable, Z_STR_P(zv), 1); } } else { ZEND_UNREACHABLE(); } + if (next_opline) { + const zend_op *target; + + if (jump_zv != NULL) { + target = ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL_P(jump_zv)); + } else { + target = ZEND_OFFSET_TO_OPLINE(opline, opline->extended_value); + } + ZEND_ASSERT(target == next_opline); + } else { + if (jump_zv != NULL) { + b = ssa->cfg.map[ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL_P(jump_zv)) - op_array->opcodes]; + } else { + b = ssa->cfg.map[ZEND_OFFSET_TO_OPLINE(opline, opline->extended_value) - op_array->opcodes]; + } + | jmp =>b + } } else { zend_ssa_op *ssa_op = &ssa->ops[opline - op_array->opcodes]; uint32_t op1_info = OP1_INFO(); @@ -11906,7 +11979,6 @@ static int zend_jit_switch(dasm_State **Dst, const zend_op *opline, const zend_o const zend_op *target; int default_b = next_opline ? -1 : ssa->cfg.map[default_opline - op_array->opcodes]; int b; - zval *val; int32_t exit_point; const void *fallback_label = NULL; const void *default_label = NULL; @@ -12015,53 +12087,9 @@ static int zend_jit_switch(dasm_State **Dst, const zend_op *opline, const zend_o } else { | LOAD_ADDR FCARG1a, jumptable | EXT_CALL zend_hash_index_find, r0 - | test r0, r0 - if (default_label) { - | jz &default_label - } else if (next_opline) { - | jz >3 - } else { - | jz =>default_b - } - | LOAD_ADDR FCARG1a, jumptable - | sub r0, aword [FCARG1a + offsetof(HashTable, arData)] - | mov FCARG1a, (sizeof(Bucket) / sizeof(void*)) - |.if X64 - | cqo - |.else - | cdq - |.endif - | idiv FCARG1a - |.if X64 - if (!IS_32BIT(dasm_end)) { - | lea FCARG1a, aword [>4] - | jmp aword [FCARG1a + r0] - } else { - | jmp aword [r0 + >4] - } - |.else - | jmp aword [r0 + >4] - |.endif - |.jmp_table - |.align aword - |4: - if (trace_info) { - trace_info->jmp_table_size += zend_hash_num_elements(jumptable); + if (!zend_jit_hash_jmp(Dst, opline, op_array, ssa, jumptable, default_b, default_label, next_opline, trace_info)) { + return 0; } - ZEND_HASH_FOREACH_VAL(jumptable, val) { - target = ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL_P(val)); - if (!next_opline) { - b = ssa->cfg.map[target - op_array->opcodes]; - | .aword =>b - } else if (next_opline == target) { - | .aword >3 - } else { - exit_point = zend_jit_trace_get_exit_point(target, 0); - exit_addr = zend_jit_trace_get_exit_addr(exit_point); - | .aword &exit_addr - } - } ZEND_HASH_FOREACH_END(); - |.code |3: } } @@ -12100,55 +12128,87 @@ static int zend_jit_switch(dasm_State **Dst, const zend_op *opline, const zend_o } | LOAD_ADDR FCARG1a, jumptable | EXT_CALL zend_hash_find, r0 - | test r0, r0 - if (default_label) { - | jz &default_label - } else if (next_opline) { - | jz >3 - } else { - | jz =>default_b + if (!zend_jit_hash_jmp(Dst, opline, op_array, ssa, jumptable, default_b, default_label, next_opline, trace_info)) { + return 0; + } + |3: + } + } else if (opline->opcode == ZEND_MATCH) { + if (op1_info & (MAY_BE_LONG|MAY_BE_STRING)) { + if (op1_info & MAY_BE_REF) { + | LOAD_ZVAL_ADDR FCARG2a, op1_addr + | ZVAL_DEREF FCARG2a, op1_info + op1_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG2a, 0); } | LOAD_ADDR FCARG1a, jumptable - | sub r0, aword [FCARG1a + offsetof(HashTable, arData)] - | mov FCARG1a, (sizeof(Bucket) / sizeof(void*)) - |.if X64 - | cqo - |.else - | cdq - |.endif - | idiv FCARG1a - |.if X64 - if (!IS_32BIT(dasm_end)) { - | lea FCARG1a, aword [>4] - | jmp aword [FCARG1a + r0] - } else { - | jmp aword [r0 + >4] + if (op1_info & MAY_BE_LONG) { + if (op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-MAY_BE_LONG)) { + if (op1_info & MAY_BE_STRING) { + | IF_NOT_ZVAL_TYPE op1_addr, IS_LONG, >5 + } else if (op1_info & MAY_BE_UNDEF) { + | IF_NOT_ZVAL_TYPE op1_addr, IS_LONG, >6 + } else if (default_label) { + | IF_NOT_ZVAL_TYPE op1_addr, IS_LONG, &default_label + } else if (next_opline) { + | IF_NOT_ZVAL_TYPE op1_addr, IS_LONG, >3 + } else { + | IF_NOT_ZVAL_TYPE op1_addr, IS_LONG, =>default_b + } + } + | GET_ZVAL_LVAL ZREG_FCARG2a, op1_addr + | EXT_CALL zend_hash_index_find, r0 + if (op1_info & MAY_BE_STRING) { + | jmp >2 + } } - |.else - | jmp aword [r0 + >4] - |.endif - |.jmp_table - |.align aword - |4: - if (trace_info) { - trace_info->jmp_table_size += zend_hash_num_elements(jumptable); - } - ZEND_HASH_FOREACH_VAL(jumptable, val) { - target = ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL_P(val)); - if (!next_opline) { - b = ssa->cfg.map[target - op_array->opcodes]; - | .aword =>b - } else if (next_opline == target) { - | .aword >3 + if (op1_info & MAY_BE_STRING) { + |5: + if (op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_LONG|MAY_BE_STRING))) { + if (op1_info & MAY_BE_UNDEF) { + | IF_NOT_ZVAL_TYPE op1_addr, IS_STRING, >6 + } else if (default_label) { + | IF_NOT_ZVAL_TYPE op1_addr, IS_STRING, &default_label + } else if (next_opline) { + | IF_NOT_ZVAL_TYPE op1_addr, IS_STRING, >3 + } else { + | IF_NOT_ZVAL_TYPE op1_addr, IS_STRING, =>default_b + } + } + | GET_ZVAL_PTR FCARG2a, op1_addr + | EXT_CALL zend_hash_find, r0 + } + |2: + if (!zend_jit_hash_jmp(Dst, opline, op_array, ssa, jumptable, default_b, default_label, next_opline, trace_info)) { + return 0; + } + } + if (op1_info & MAY_BE_UNDEF) { + |6: + if (op1_info & (MAY_BE_ANY-(MAY_BE_LONG|MAY_BE_STRING))) { + if (default_label) { + | IF_NOT_ZVAL_TYPE op1_addr, IS_UNDEF, &default_label + } else if (next_opline) { + | IF_NOT_ZVAL_TYPE op1_addr, IS_UNDEF, >3 } else { - exit_point = zend_jit_trace_get_exit_point(target, 0); - exit_addr = zend_jit_trace_get_exit_addr(exit_point); - | .aword &exit_addr + | IF_NOT_ZVAL_TYPE op1_addr, IS_UNDEF, =>default_b } - } ZEND_HASH_FOREACH_END(); - |.code - |3: + } + | // zend_error(E_WARNING, "Undefined variable $%s", ZSTR_VAL(CV_DEF_OF(EX_VAR_TO_NUM(opline->op1.var)))); + | SAVE_VALID_OPLINE opline, r0 + | mov FCARG1d, opline->op1.var + | EXT_CALL zend_jit_undefined_op_helper, r0 + if (!zend_jit_check_exception_undef_result(Dst, opline)) { + return 0; + } } + if (default_label) { + | jmp &default_label + } else if (next_opline) { + | jmp >3 + } else { + | jmp =>default_b + } + |3: } else { ZEND_UNREACHABLE(); } From 54fd1fcd27f0191e6d551f046cb76b2004c809e2 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 24 Aug 2020 16:47:20 +0300 Subject: [PATCH 064/170] Support for CASE_STRICT --- ext/opcache/jit/zend_jit_x86.dasc | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index ffe96e65bb2f0..cffa3772bd6b0 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -6238,6 +6238,7 @@ static int zend_jit_cmp_long_long(dasm_State **Dst, const zend_op *opline, zend_ case ZEND_IS_EQUAL: case ZEND_IS_IDENTICAL: case ZEND_CASE: + case ZEND_CASE_STRICT: | sete al break; case ZEND_IS_NOT_EQUAL: @@ -6271,6 +6272,7 @@ static int zend_jit_cmp_long_long(dasm_State **Dst, const zend_op *opline, zend_ case ZEND_IS_EQUAL: case ZEND_IS_IDENTICAL: case ZEND_CASE: + case ZEND_CASE_STRICT: if (exit_addr) { | jne &exit_addr } else { @@ -6330,6 +6332,7 @@ static int zend_jit_cmp_long_long(dasm_State **Dst, const zend_op *opline, zend_ case ZEND_IS_EQUAL: case ZEND_IS_IDENTICAL: case ZEND_CASE: + case ZEND_CASE_STRICT: if (exit_addr) { | je &exit_addr } else { @@ -6388,6 +6391,7 @@ static int zend_jit_cmp_long_long(dasm_State **Dst, const zend_op *opline, zend_ case ZEND_IS_EQUAL: case ZEND_IS_IDENTICAL: case ZEND_CASE: + case ZEND_CASE_STRICT: | jne => target_label break; case ZEND_IS_NOT_EQUAL: @@ -6420,6 +6424,7 @@ static int zend_jit_cmp_long_long(dasm_State **Dst, const zend_op *opline, zend_ case ZEND_IS_EQUAL: case ZEND_IS_IDENTICAL: case ZEND_CASE: + case ZEND_CASE_STRICT: | sete al break; case ZEND_IS_NOT_EQUAL: @@ -6459,6 +6464,7 @@ static int zend_jit_cmp_double_common(dasm_State **Dst, const zend_op *opline, z case ZEND_IS_EQUAL: case ZEND_IS_IDENTICAL: case ZEND_CASE: + case ZEND_CASE_STRICT: if (exit_addr) { | jne &exit_addr | jp &exit_addr @@ -6528,6 +6534,7 @@ static int zend_jit_cmp_double_common(dasm_State **Dst, const zend_op *opline, z case ZEND_IS_EQUAL: case ZEND_IS_IDENTICAL: case ZEND_CASE: + case ZEND_CASE_STRICT: | jp >1 if (exit_addr) { | je &exit_addr @@ -6597,6 +6604,7 @@ static int zend_jit_cmp_double_common(dasm_State **Dst, const zend_op *opline, z case ZEND_IS_EQUAL: case ZEND_IS_IDENTICAL: case ZEND_CASE: + case ZEND_CASE_STRICT: | jne => target_label | jp => target_label break; @@ -6630,6 +6638,7 @@ static int zend_jit_cmp_double_common(dasm_State **Dst, const zend_op *opline, z case ZEND_IS_EQUAL: case ZEND_IS_IDENTICAL: case ZEND_CASE: + case ZEND_CASE_STRICT: | SET_ZVAL_TYPE_INFO res_addr, IS_FALSE | jne => target_label | jp => target_label @@ -6675,6 +6684,7 @@ static int zend_jit_cmp_double_common(dasm_State **Dst, const zend_op *opline, z case ZEND_IS_EQUAL: case ZEND_IS_IDENTICAL: case ZEND_CASE: + case ZEND_CASE_STRICT: | jp >1 | SET_ZVAL_TYPE_INFO res_addr, IS_TRUE | je => target_label @@ -6729,6 +6739,7 @@ static int zend_jit_cmp_double_common(dasm_State **Dst, const zend_op *opline, z case ZEND_IS_EQUAL: case ZEND_IS_IDENTICAL: case ZEND_CASE: + case ZEND_CASE_STRICT: | jp >1 | mov eax, IS_TRUE | je >2 @@ -7362,7 +7373,7 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, uint32_t | jmp =>not_identical_label } } else { - | SET_ZVAL_TYPE_INFO res_addr, (opline->opcode == ZEND_IS_IDENTICAL ? IS_FALSE : IS_TRUE) + | SET_ZVAL_TYPE_INFO res_addr, (opline->opcode != ZEND_IS_NOT_IDENTICAL ? IS_FALSE : IS_TRUE) zend_jit_check_exception(Dst); } } else if (has_concrete_type(op1_info) && @@ -7378,7 +7389,7 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, uint32_t | jmp =>identical_label } } else { - | SET_ZVAL_TYPE_INFO res_addr, (opline->opcode == ZEND_IS_IDENTICAL ? IS_TRUE : IS_FALSE) + | SET_ZVAL_TYPE_INFO res_addr, (opline->opcode != ZEND_IS_NOT_IDENTICAL ? IS_TRUE : IS_FALSE) } } else if (Z_MODE(op1_addr) == IS_CONST_ZVAL && Z_MODE(op2_addr) == IS_CONST_ZVAL) { if (zend_is_identical(Z_ZV(op1_addr), Z_ZV(op2_addr))) { @@ -7391,7 +7402,7 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, uint32_t | jmp =>identical_label } } else { - | SET_ZVAL_TYPE_INFO res_addr, (opline->opcode == ZEND_IS_IDENTICAL ? IS_TRUE : IS_FALSE) + | SET_ZVAL_TYPE_INFO res_addr, (opline->opcode != ZEND_IS_NOT_IDENTICAL ? IS_TRUE : IS_FALSE) } } else { if (smart_branch_opcode) { @@ -7403,7 +7414,7 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, uint32_t | jmp =>not_identical_label } } else { - | SET_ZVAL_TYPE_INFO res_addr, (opline->opcode == ZEND_IS_IDENTICAL ? IS_FALSE : IS_TRUE) + | SET_ZVAL_TYPE_INFO res_addr, (opline->opcode != ZEND_IS_NOT_IDENTICAL ? IS_FALSE : IS_TRUE) } } } else if (Z_MODE(op1_addr) == IS_CONST_ZVAL && Z_TYPE_P(Z_ZV(op1_addr)) <= IS_TRUE) { @@ -7432,7 +7443,7 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, uint32_t | je >9 } } else { - if (opline->opcode == ZEND_IS_IDENTICAL) { + if (opline->opcode != ZEND_IS_NOT_IDENTICAL) { | sete al } else { | setne al @@ -7481,7 +7492,7 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, uint32_t | je >9 } } else { - if (opline->opcode == ZEND_IS_IDENTICAL) { + if (opline->opcode != ZEND_IS_NOT_IDENTICAL) { | sete al } else { | setne al @@ -7546,7 +7557,7 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, uint32_t } } else { | movzx eax, al - if (opline->opcode == ZEND_IS_IDENTICAL) { + if (opline->opcode != ZEND_IS_NOT_IDENTICAL) { | lea eax, [eax + 2] } else { | neg eax From d3845378591869e781b8b9c4c1b8e0823c402799 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 25 Aug 2020 11:37:30 +0300 Subject: [PATCH 065/170] Move AVOID_REFCOUNTING type info flag into a separate bit --- ext/opcache/Optimizer/zend_inference.h | 1 - ext/opcache/Optimizer/zend_ssa.h | 1 + ext/opcache/jit/zend_jit.c | 8 +-- ext/opcache/jit/zend_jit_trace.c | 15 ++++-- ext/opcache/jit/zend_jit_x86.dasc | 71 +++++++++++++++++++------- 5 files changed, 69 insertions(+), 27 deletions(-) diff --git a/ext/opcache/Optimizer/zend_inference.h b/ext/opcache/Optimizer/zend_inference.h index 3d8a0a0dcf169..0708d5df94516 100644 --- a/ext/opcache/Optimizer/zend_inference.h +++ b/ext/opcache/Optimizer/zend_inference.h @@ -26,7 +26,6 @@ /* Bitmask for type inference (zend_ssa_var_info.type) */ #include "zend_type_info.h" -#define AVOID_REFCOUNTING (1<<26) /* avoid reference counting */ #define MAY_BE_CLASS_GUARD (1<<27) /* needs class guard */ #define MAY_BE_GUARD (1<<28) /* needs type guard */ #define MAY_BE_IN_REG (1<<29) /* value allocated in CPU register */ diff --git a/ext/opcache/Optimizer/zend_ssa.h b/ext/opcache/Optimizer/zend_ssa.h index 7d065ac42ab42..e7190da3f8ddb 100644 --- a/ext/opcache/Optimizer/zend_ssa.h +++ b/ext/opcache/Optimizer/zend_ssa.h @@ -128,6 +128,7 @@ typedef struct _zend_ssa_var_info { unsigned int recursive : 1; unsigned int use_as_double : 1; unsigned int delayed_fetch_this : 1; + unsigned int avoid_refcounting : 1; } zend_ssa_var_info; typedef struct _zend_ssa { diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index 2956591490d3c..5073894dbe17b 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -2817,7 +2817,8 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op break; } if (!zend_jit_fetch_dim_read(&dasm_state, opline, ssa, ssa_op, - OP1_INFO(), OP1_REG_ADDR(), OP2_INFO(), RES_INFO(), RES_REG_ADDR(), + OP1_INFO(), OP1_REG_ADDR(), 0, + OP2_INFO(), RES_INFO(), RES_REG_ADDR(), zend_may_throw(opline, ssa_op, op_array, ssa))) { goto jit_failure; } @@ -2846,7 +2847,8 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op target_label = target_label2 = (uint32_t)-1; } if (!zend_jit_isset_isempty_dim(&dasm_state, opline, - OP1_INFO(), OP1_REG_ADDR(), OP2_INFO(), + OP1_INFO(), OP1_REG_ADDR(), 0, + OP2_INFO(), zend_may_throw(opline, ssa_op, op_array, ssa), smart_branch_opcode, target_label, target_label2, NULL)) { @@ -2886,7 +2888,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op } } if (!zend_jit_fetch_obj(&dasm_state, opline, op_array, ssa, ssa_op, - op1_info, op1_addr, 0, ce, ce_is_instanceof, 0, NULL, + op1_info, op1_addr, 0, ce, ce_is_instanceof, 0, 0, NULL, zend_may_throw(opline, ssa_op, op_array, ssa))) { goto jit_failure; } diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index 6ad080003693a..9e40661b0c617 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -2895,6 +2895,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par zend_class_entry *ce; zend_bool ce_is_instanceof; zend_bool delayed_fetch_this = 0; + zend_bool avoid_refcounting = 0; uint32_t i; zend_jit_trace_stack_frame *frame, *top, *call; zend_jit_trace_stack *stack; @@ -4011,7 +4012,8 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par CHECK_OP2_TRACE_TYPE(); res_info = RES_INFO(); if (!zend_jit_fetch_dim_read(&dasm_state, opline, ssa, ssa_op, - op1_info, op1_addr, op2_info, res_info, RES_REG_ADDR(), + op1_info, op1_addr, ssa->var_info[ssa_op->op1_use].avoid_refcounting, + op2_info, res_info, RES_REG_ADDR(), ( (op1_info & MAY_BE_ANY) != MAY_BE_ARRAY || (op2_info & (MAY_BE_ANY - (MAY_BE_LONG|MAY_BE_STRING))) != 0 || @@ -4052,7 +4054,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if (ra) { zend_jit_trace_clenup_stack(stack, opline, ssa_op, ssa, ra); } - if (op1_info & AVOID_REFCOUNTING) { + if (ssa->var_info[ssa_op->op1_use].avoid_refcounting) { /* Temporary reset ZREG_ZVAL_TRY_ADDREF */ zend_jit_trace_stack *stack = JIT_G(current_frame)->stack; uint32_t old_info = STACK_INFO(stack, EX_VAR_TO_NUM(opline->op1.var)); @@ -4073,7 +4075,8 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par exit_addr = NULL; } if (!zend_jit_isset_isempty_dim(&dasm_state, opline, - op1_info, op1_addr, op2_info, + op1_info, op1_addr, ssa->var_info[ssa_op->op1_use].avoid_refcounting, + op2_info, zend_may_throw_ex(opline, ssa_op, op_array, ssa, op1_info, op2_info), smart_branch_opcode, -1, -1, exit_addr)) { @@ -4092,6 +4095,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par case ZEND_FETCH_OBJ_IS: case ZEND_FETCH_OBJ_W: delayed_fetch_this = 0; + avoid_refcounting = 0; if (opline->op2_type != IS_CONST || Z_TYPE_P(RT_CONSTANT(opline, opline->op2)) != IS_STRING || Z_STRVAL_P(RT_CONSTANT(opline, opline->op2))[0] == '\0') { @@ -4140,11 +4144,12 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par } if (ssa_op->op1_use >= 0) { delayed_fetch_this = ssa->var_info[ssa_op->op1_use].delayed_fetch_this; + avoid_refcounting = ssa->var_info[ssa_op->op1_use].avoid_refcounting; } } if (!zend_jit_fetch_obj(&dasm_state, opline, op_array, ssa, ssa_op, op1_info, op1_addr, op1_indirect, ce, ce_is_instanceof, - delayed_fetch_this, op1_ce, + delayed_fetch_this, avoid_refcounting, op1_ce, zend_may_throw_ex(opline, ssa_op, op_array, ssa, op1_info, MAY_BE_STRING))) { goto jit_failure; } @@ -4353,7 +4358,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if (opline->opcode == ZEND_FETCH_THIS && delayed_fetch_this) { SET_STACK_REG(stack, EX_VAR_TO_NUM(opline->result.var), ZREG_THIS); - } else if (ssa->var_info[ssa_op->result_def].type & AVOID_REFCOUNTING) { + } else if (ssa->var_info[ssa_op->result_def].avoid_refcounting) { SET_STACK_REG(stack, EX_VAR_TO_NUM(opline->result.var), ZREG_ZVAL_TRY_ADDREF); } else if (ra && ra[ssa_op->result_def]) { SET_STACK_REG(stack, EX_VAR_TO_NUM(opline->result.var), ra[ssa_op->result_def]->reg); diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index 49459267e7e24..84c7c091285bf 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -10479,12 +10479,23 @@ static zend_bool zend_jit_may_avoid_refcounting(const zend_op *opline) return 0; } -static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, zend_ssa *ssa, const zend_ssa_op *ssa_op, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op2_info, uint32_t res_info, zend_jit_addr res_addr, int may_throw) +static int zend_jit_fetch_dim_read(dasm_State **Dst, + const zend_op *opline, + zend_ssa *ssa, + const zend_ssa_op *ssa_op, + uint32_t op1_info, + zend_jit_addr op1_addr, + zend_bool op1_avoid_refcounting, + uint32_t op2_info, + uint32_t res_info, + zend_jit_addr res_addr, + int may_throw) { zend_jit_addr orig_op1_addr, op2_addr; const void *exit_addr = NULL; const void *not_found_exit_addr = NULL; const void *res_exit_addr = NULL; + zend_bool result_avoid_refcounting = 0; orig_op1_addr = OP1_ADDR(); op2_addr = OP2_ADDR(); @@ -10498,7 +10509,7 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, zend } } - if (op1_info & AVOID_REFCOUNTING) { + if (op1_avoid_refcounting) { SET_STACK_REG(JIT_G(current_frame)->stack, EX_VAR_TO_NUM(opline->op1.var), ZREG_NONE); } @@ -10512,7 +10523,7 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, zend int32_t exit_point; if ((opline->op1_type & (IS_VAR|IS_TMP_VAR)) - && !(op1_info & AVOID_REFCOUNTING)) { + && !op1_avoid_refcounting) { flags |= ZEND_JIT_EXIT_FREE_OP1; } if ((opline->op2_type & (IS_VAR|IS_TMP_VAR)) @@ -10524,8 +10535,8 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, zend && (ssa_op+1)->op1_use == ssa_op->result_def && !(op2_info & ((MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_REF) - (MAY_BE_STRING|MAY_BE_LONG))) && zend_jit_may_avoid_refcounting(opline+1)) { - res_info |= AVOID_REFCOUNTING; - ssa->var_info[ssa_op->result_def].type |= AVOID_REFCOUNTING; + result_avoid_refcounting = 1; + ssa->var_info[ssa_op->result_def].avoid_refcounting = 1; } if (!(op2_info & ((MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_REF) - (MAY_BE_STRING|MAY_BE_LONG)))) { @@ -10722,7 +10733,7 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, zend | SET_ZVAL_TYPE_INFO res_addr, type } else { | SET_ZVAL_TYPE_INFO res_addr, edx - if (!(res_info & AVOID_REFCOUNTING)) { + if (!result_avoid_refcounting) { | TRY_ADDREF res_info, dh, r1 } } @@ -10751,7 +10762,7 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, zend #endif | FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline - if (!(op1_info & AVOID_REFCOUNTING)) { + if (!op1_avoid_refcounting) { | FREE_OP opline->op1_type, opline->op1, op1_info, 0, opline } @@ -10764,7 +10775,17 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, zend return 1; } -static int zend_jit_isset_isempty_dim(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op2_info, int may_throw, zend_uchar smart_branch_opcode, uint32_t target_label, uint32_t target_label2, const void *exit_addr) +static int zend_jit_isset_isempty_dim(dasm_State **Dst, + const zend_op *opline, + uint32_t op1_info, + zend_jit_addr op1_addr, + zend_bool op1_avoid_refcounting, + uint32_t op2_info, + int may_throw, + zend_uchar smart_branch_opcode, + uint32_t target_label, + uint32_t target_label2, + const void *exit_addr) { zend_jit_addr op2_addr, res_addr; @@ -10791,7 +10812,7 @@ static int zend_jit_isset_isempty_dim(dasm_State **Dst, const zend_op *opline, u if (exit_addr && !(op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-MAY_BE_ARRAY)) && !may_throw - && (!(opline->op1_type & (IS_TMP_VAR|IS_VAR)) || (op1_info & AVOID_REFCOUNTING)) + && (!(opline->op1_type & (IS_TMP_VAR|IS_VAR)) || op1_avoid_refcounting) && (!(opline->op2_type & (IS_TMP_VAR|IS_VAR)) || !(op2_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-MAY_BE_LONG)))) { if (smart_branch_opcode == ZEND_JMPNZ) { found_exit_addr = exit_addr; @@ -10859,7 +10880,7 @@ static int zend_jit_isset_isempty_dim(dasm_State **Dst, const zend_op *opline, u |8: | FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline - if (!(op1_info & AVOID_REFCOUNTING)) { + if (!op1_avoid_refcounting) { | FREE_OP opline->op1_type, opline->op1, op1_info, 0, opline } if (may_throw) { @@ -10895,7 +10916,7 @@ static int zend_jit_isset_isempty_dim(dasm_State **Dst, const zend_op *opline, u |9: // not found | FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline - if (!(op1_info & AVOID_REFCOUNTING)) { + if (!op1_avoid_refcounting) { | FREE_OP opline->op1_type, opline->op1, op1_info, 0, opline } if (may_throw) { @@ -11320,7 +11341,20 @@ static int zend_jit_class_guard(dasm_State **Dst, const zend_op *opline, zend_cl return 1; } -static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, zend_ssa *ssa, const zend_ssa_op *ssa_op, uint32_t op1_info, zend_jit_addr op1_addr, zend_bool op1_indirect, zend_class_entry *ce, zend_bool ce_is_instanceof, zend_bool use_this, zend_class_entry *trace_ce, int may_throw) +static int zend_jit_fetch_obj(dasm_State **Dst, + const zend_op *opline, + const zend_op_array *op_array, + zend_ssa *ssa, + const zend_ssa_op *ssa_op, + uint32_t op1_info, + zend_jit_addr op1_addr, + zend_bool op1_indirect, + zend_class_entry *ce, + zend_bool ce_is_instanceof, + zend_bool use_this, + zend_bool op1_avoid_refcounting, + zend_class_entry *trace_ce, + int may_throw) { zval *member; zend_property_info *prop_info; @@ -11494,7 +11528,7 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen } } } - if (op1_info & AVOID_REFCOUNTING) { + if (op1_avoid_refcounting) { SET_STACK_REG(JIT_G(current_frame)->stack, EX_VAR_TO_NUM(opline->op1.var), ZREG_NONE); } @@ -11506,6 +11540,7 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen | SET_ZVAL_TYPE_INFO res_addr, IS_INDIRECT } else { uint32_t res_info = RES_INFO(); + zend_bool result_avoid_refcounting = 0; if ((res_info & MAY_BE_GUARD) && JIT_G(current_frame) && prop_info) { uint32_t flags = 0; @@ -11518,7 +11553,7 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen if ((opline->op1_type & (IS_VAR|IS_TMP_VAR)) && !use_this - && !(op1_info & AVOID_REFCOUNTING)) { + && !op1_avoid_refcounting) { flags = ZEND_JIT_EXIT_FREE_OP1; } @@ -11528,8 +11563,8 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen && (res_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) && (ssa_op+1)->op1_use == ssa_op->result_def && zend_jit_may_avoid_refcounting(opline+1)) { - res_info |= AVOID_REFCOUNTING; - ssa->var_info[ssa_op->result_def].type |= AVOID_REFCOUNTING; + result_avoid_refcounting = 1; + ssa->var_info[ssa_op->result_def].avoid_refcounting = 1; } old_info = STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var)); @@ -11564,7 +11599,7 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen | SET_ZVAL_TYPE_INFO res_addr, type } else { | SET_ZVAL_TYPE_INFO res_addr, edx - if (!(res_info & AVOID_REFCOUNTING)) { + if (!result_avoid_refcounting) { | TRY_ADDREF res_info, dh, r1 } } @@ -11652,7 +11687,7 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen | SAVE_VALID_OPLINE opline, r0 | EXT_CALL zend_jit_extract_helper, r0 |1: - } else if (!(op1_info & AVOID_REFCOUNTING)) { + } else if (!op1_avoid_refcounting) { | FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline } } From afde6dcf5f3c82aa4a03f1acdd0a17daa6bc644a Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 25 Aug 2020 11:01:22 +0200 Subject: [PATCH 066/170] Simplify change_node_zval implementation At this point, the value has already been converted into a string. --- ext/simplexml/simplexml.c | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index afd655aeedd73..42a7ccb192d5b 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -377,31 +377,12 @@ static zval *sxe_dimension_read(zend_object *object, zval *offset, int type, zva static void change_node_zval(xmlNodePtr node, zval *value) { xmlChar *buffer; - - if (!value) - { - xmlNodeSetContentLen(node, (xmlChar *)"", 0); - return; - } - switch (Z_TYPE_P(value)) { - case IS_LONG: - case IS_FALSE: - case IS_TRUE: - case IS_DOUBLE: - case IS_NULL: - convert_to_string(value); - /* break missing intentionally */ - case IS_STRING: - buffer = xmlEncodeEntitiesReentrant(node->doc, (xmlChar *)Z_STRVAL_P(value)); - /* check for NULL buffer in case of memory error in xmlEncodeEntitiesReentrant */ - if (buffer) { - xmlNodeSetContent(node, buffer); - xmlFree(buffer); - } - break; - default: - php_error_docref(NULL, E_WARNING, "It is not possible to assign complex types to nodes"); - break; + ZEND_ASSERT(Z_TYPE_P(value) == IS_STRING); + buffer = xmlEncodeEntitiesReentrant(node->doc, (xmlChar *)Z_STRVAL_P(value)); + /* check for NULL buffer in case of memory error in xmlEncodeEntitiesReentrant */ + if (buffer) { + xmlNodeSetContent(node, buffer); + xmlFree(buffer); } } /* }}} */ From f4e9d0e32508249aca195b177c943d63c420666f Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 25 Aug 2020 11:27:58 +0200 Subject: [PATCH 067/170] Don't return temporary from SXE write_property handler Return the original value. If we don't return the original value, we need to own the zval, which we don't. For clarity also switch things to work on a zend_string* value instead of a zval*. --- ext/simplexml/simplexml.c | 41 +++++++++++++++--------------------- ext/simplexml/tests/038.phpt | 14 ++++++++++++ 2 files changed, 31 insertions(+), 24 deletions(-) create mode 100644 ext/simplexml/tests/038.phpt diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 42a7ccb192d5b..f788502703b08 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -374,11 +374,9 @@ static zval *sxe_dimension_read(zend_object *object, zval *offset, int type, zva /* }}} */ /* {{{ change_node_zval() */ -static void change_node_zval(xmlNodePtr node, zval *value) +static void change_node_zval(xmlNodePtr node, zend_string *value) { - xmlChar *buffer; - ZEND_ASSERT(Z_TYPE_P(value) == IS_STRING); - buffer = xmlEncodeEntitiesReentrant(node->doc, (xmlChar *)Z_STRVAL_P(value)); + xmlChar *buffer = xmlEncodeEntitiesReentrant(node->doc, (xmlChar *)ZSTR_VAL(value)); /* check for NULL buffer in case of memory error in xmlEncodeEntitiesReentrant */ if (buffer) { xmlNodeSetContent(node, buffer); @@ -400,10 +398,10 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value, int is_attr = 0; int nodendx = 0; int test = 0; - int new_value = 0; zend_long cnt = 0; - zval tmp_zv, zval_copy; + zval tmp_zv; zend_string *trim_str; + zend_string *value_str = NULL; sxe = php_sxe_fetch_object(object); @@ -484,23 +482,18 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value, case IS_TRUE: case IS_DOUBLE: case IS_NULL: - if (Z_TYPE_P(value) != IS_STRING) { - ZVAL_STR(&zval_copy, zval_get_string_func(value)); - value = &zval_copy; - new_value = 1; - } - break; case IS_STRING: + value_str = zval_get_string(value); break; case IS_OBJECT: if (Z_OBJCE_P(value) == sxe_class_entry) { + zval zval_copy; if (sxe_object_cast_ex(Z_OBJ_P(value), &zval_copy, IS_STRING) == FAILURE) { zend_error(E_ERROR, "Unable to cast node to string"); /* FIXME: Should not be fatal */ } - value = &zval_copy; - new_value = 1; + value_str = Z_STR(zval_copy); break; } /* break is missing intentionally */ @@ -544,8 +537,8 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value, if (!member || Z_TYPE_P(member) == IS_LONG) { if (node->type == XML_ATTRIBUTE_NODE) { zend_throw_error(NULL, "Cannot create duplicate attribute"); - if (new_value) { - zval_ptr_dtor(value); + if (value_str) { + zend_string_release(value_str); } return &EG(error_zval); } @@ -583,12 +576,12 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value, if (is_attr) { newnode = (xmlNodePtr) attr; } - if (value) { + if (value_str) { while ((tempnode = (xmlNodePtr) newnode->children)) { xmlUnlinkNode(tempnode); php_libxml_node_free_resource((xmlNodePtr) tempnode); } - change_node_zval(newnode, value); + change_node_zval(newnode, value_str); } } else if (counter > 1) { php_error_docref(NULL, E_WARNING, "Cannot assign to an array of nodes (duplicate subnodes or attr detected)"); @@ -596,21 +589,21 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value, } else if (elements) { if (!node) { if (!member || Z_TYPE_P(member) == IS_LONG) { - newnode = xmlNewTextChild(mynode->parent, mynode->ns, mynode->name, value ? (xmlChar *)Z_STRVAL_P(value) : NULL); + newnode = xmlNewTextChild(mynode->parent, mynode->ns, mynode->name, value_str ? (xmlChar *)ZSTR_VAL(value_str) : NULL); } else { - newnode = xmlNewTextChild(mynode, mynode->ns, (xmlChar *)Z_STRVAL_P(member), value ? (xmlChar *)Z_STRVAL_P(value) : NULL); + newnode = xmlNewTextChild(mynode, mynode->ns, (xmlChar *)Z_STRVAL_P(member), value_str ? (xmlChar *)ZSTR_VAL(value_str) : NULL); } } else if (!member || Z_TYPE_P(member) == IS_LONG) { if (member && cnt < Z_LVAL_P(member)) { php_error_docref(NULL, E_WARNING, "Cannot add element %s number " ZEND_LONG_FMT " when only " ZEND_LONG_FMT " such elements exist", mynode->name, Z_LVAL_P(member), cnt); } - newnode = xmlNewTextChild(mynode->parent, mynode->ns, mynode->name, value ? (xmlChar *)Z_STRVAL_P(value) : NULL); + newnode = xmlNewTextChild(mynode->parent, mynode->ns, mynode->name, value_str ? (xmlChar *)ZSTR_VAL(value_str) : NULL); } } else if (attribs) { if (Z_TYPE_P(member) == IS_LONG) { php_error_docref(NULL, E_WARNING, "Cannot change attribute number " ZEND_LONG_FMT " when only %d attributes exist", Z_LVAL_P(member), nodendx); } else { - newnode = (xmlNodePtr)xmlNewProp(node, (xmlChar *)Z_STRVAL_P(member), value ? (xmlChar *)Z_STRVAL_P(value) : NULL); + newnode = (xmlNodePtr)xmlNewProp(node, (xmlChar *)Z_STRVAL_P(member), value_str ? (xmlChar *)ZSTR_VAL(value_str) : NULL); } } } @@ -621,8 +614,8 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value, if (pnewnode) { *pnewnode = newnode; } - if (new_value) { - zval_ptr_dtor(value); + if (value_str) { + zend_string_release(value_str); } return value; } diff --git a/ext/simplexml/tests/038.phpt b/ext/simplexml/tests/038.phpt new file mode 100644 index 0000000000000..75d016a5ddf8e --- /dev/null +++ b/ext/simplexml/tests/038.phpt @@ -0,0 +1,14 @@ +--TEST-- +SimpleXML: Property assignment return value +--SKIPIF-- + +--FILE-- + +EOF; +$root = simplexml_load_string($xml); +var_dump($root->prop = 42); +?> +--EXPECT-- +int(42) From f068fbcf1fe1faa89827630131536f68af1a28b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 19 Aug 2020 22:35:22 +0200 Subject: [PATCH 068/170] Promote warnings to exceptions in ext/xmlreader Closes GH-6021 --- ext/xmlreader/php_xmlreader.c | 109 ++++++++++-------- ext/xmlreader/php_xmlreader.stub.php | 4 +- ext/xmlreader/php_xmlreader_arginfo.h | 2 +- ext/xmlreader/tests/001.phpt | 13 ++- ext/xmlreader/tests/002.phpt | 10 +- ext/xmlreader/tests/003-get-errors.phpt | 14 ++- ext/xmlreader/tests/003-move-errors.phpt | 14 ++- ext/xmlreader/tests/003.phpt | 12 +- ext/xmlreader/tests/007.phpt | 12 +- ext/xmlreader/tests/014.phpt | 28 +++-- ext/xmlreader/tests/015-get-errors.phpt | 13 ++- ext/xmlreader/tests/015-move-errors.phpt | 10 +- ext/xmlreader/tests/expand_error.phpt | 13 ++- ext/xmlreader/tests/next_basic.phpt | 22 +++- ext/xmlreader/tests/schema-bad.xsd | 1 + .../tests/setParserProperty_error.phpt | 11 +- ext/xmlreader/tests/setSchema_error.phpt | 38 ++++-- 17 files changed, 202 insertions(+), 124 deletions(-) create mode 100644 ext/xmlreader/tests/schema-bad.xsd diff --git a/ext/xmlreader/php_xmlreader.c b/ext/xmlreader/php_xmlreader.c index efed79a2395fd..7b2619540956e 100644 --- a/ext/xmlreader/php_xmlreader.c +++ b/ext/xmlreader/php_xmlreader.c @@ -175,7 +175,7 @@ zval *xmlreader_write_property(zend_object *object, zend_string *name, zval *val hnd = zend_hash_find_ptr(obj->prop_handler, name); } if (hnd != NULL) { - php_error_docref(NULL, E_WARNING, "Cannot write to read-only property"); + zend_throw_error(NULL, "Cannot write to read-only property"); } else { value = zend_std_write_property(object, name, value, cache_slot); } @@ -391,8 +391,8 @@ static void php_xmlreader_string_arg(INTERNAL_FUNCTION_PARAMETERS, xmlreader_rea } if (!name_len) { - php_error_docref(NULL, E_WARNING, "Argument cannot be an empty string"); - RETURN_FALSE; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } id = ZEND_THIS; @@ -480,8 +480,8 @@ static void php_xmlreader_set_relaxng_schema(INTERNAL_FUNCTION_PARAMETERS, int t } if (source != NULL && !source_len) { - php_error_docref(NULL, E_WARNING, "Schema data source is required"); - RETURN_FALSE; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } id = ZEND_THIS; @@ -506,15 +506,16 @@ static void php_xmlreader_set_relaxng_schema(INTERNAL_FUNCTION_PARAMETERS, int t intern->schema = schema; RETURN_TRUE; + } else { + php_error_docref(NULL, E_WARNING, "Schema contains errors"); + RETURN_FALSE; } + } else { + zend_throw_error(NULL, "Schema must be set prior to reading"); + RETURN_THROWS(); } - - php_error_docref(NULL, E_WARNING, "Unable to set schema. This must be set prior to reading or schema contains errors."); - - RETURN_FALSE; #else - php_error_docref(NULL, E_WARNING, "No Schema support built into libxml."); - + php_error_docref(NULL, E_WARNING, "No schema support built into libxml"); RETURN_FALSE; #endif } @@ -585,9 +586,14 @@ PHP_METHOD(XMLReader, getAttributeNs) RETURN_THROWS(); } - if (name_len == 0 || ns_uri_len == 0) { - php_error_docref(NULL, E_WARNING, "Attribute Name and Namespace URI cannot be empty"); - RETURN_FALSE; + if (name_len == 0) { + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); + } + + if (ns_uri_len == 0) { + zend_argument_value_error(2, "cannot be empty"); + RETURN_THROWS(); } id = ZEND_THIS; @@ -622,8 +628,8 @@ PHP_METHOD(XMLReader, getParserProperty) retval = xmlTextReaderGetParserProp(intern->ptr,property); } if (retval == -1) { - php_error_docref(NULL, E_WARNING, "Invalid parser property"); - RETURN_FALSE; + zend_argument_value_error(1, "must be a valid parser property"); + RETURN_THROWS(); } RETURN_BOOL(retval); @@ -660,8 +666,8 @@ PHP_METHOD(XMLReader, moveToAttribute) } if (name_len == 0) { - php_error_docref(NULL, E_WARNING, "Attribute Name is required"); - RETURN_FALSE; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } id = ZEND_THIS; @@ -719,9 +725,14 @@ PHP_METHOD(XMLReader, moveToAttributeNs) RETURN_THROWS(); } - if (name_len == 0 || ns_uri_len == 0) { - php_error_docref(NULL, E_WARNING, "Attribute Name and Namespace URI cannot be empty"); - RETURN_FALSE; + if (name_len == 0) { + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); + } + + if (ns_uri_len == 0) { + zend_argument_value_error(2, "cannot be empty"); + RETURN_THROWS(); } id = ZEND_THIS; @@ -772,17 +783,17 @@ PHP_METHOD(XMLReader, read) id = ZEND_THIS; intern = Z_XMLREADER_P(id); - if (intern != NULL && intern->ptr != NULL) { - retval = xmlTextReaderRead(intern->ptr); - if (retval == -1) { - RETURN_FALSE; - } else { - RETURN_BOOL(retval); - } + if (intern == NULL || intern->ptr == NULL) { + zend_throw_error(NULL, "Data must be loaded before reading"); + RETURN_THROWS(); } - php_error_docref(NULL, E_WARNING, "Load Data before trying to read"); - RETURN_FALSE; + retval = xmlTextReaderRead(intern->ptr); + if (retval == -1) { + RETURN_FALSE; + } else { + RETURN_BOOL(retval); + } } /* }}} */ @@ -816,8 +827,7 @@ PHP_METHOD(XMLReader, next) } } - php_error_docref(NULL, E_WARNING, "Load Data before trying to read"); - RETURN_FALSE; + zend_throw_error(NULL, "Data must be loaded before reading"); } /* }}} */ @@ -848,8 +858,8 @@ PHP_METHOD(XMLReader, open) } if (!source_len) { - php_error_docref(NULL, E_WARNING, "Empty string supplied as input"); - RETURN_FALSE; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } valid_file = _xmlreader_get_valid_file_path(source, resolved_path, MAXPATHLEN ); @@ -920,8 +930,8 @@ PHP_METHOD(XMLReader, setSchema) } if (source != NULL && !source_len) { - php_error_docref(NULL, E_WARNING, "Schema data source is required"); - RETURN_FALSE; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } id = ZEND_THIS; @@ -932,15 +942,16 @@ PHP_METHOD(XMLReader, setSchema) if (retval == 0) { RETURN_TRUE; + } else { + php_error_docref(NULL, E_WARNING, "Schema contains errors"); + RETURN_FALSE; } + } else { + zend_throw_error(NULL, "Schema must be set prior to reading"); + RETURN_THROWS(); } - - php_error_docref(NULL, E_WARNING, "Unable to set schema. This must be set prior to reading or schema contains errors."); - - RETURN_FALSE; #else - php_error_docref(NULL, E_WARNING, "No Schema support built into libxml."); - + php_error_docref(NULL, E_WARNING, "No schema support built into libxml"); RETURN_FALSE; #endif } @@ -967,8 +978,8 @@ PHP_METHOD(XMLReader, setParserProperty) retval = xmlTextReaderSetParserProp(intern->ptr,property, value); } if (retval == -1) { - php_error_docref(NULL, E_WARNING, "Invalid parser property"); - RETURN_FALSE; + zend_argument_value_error(1, "must be a valid parser property"); + RETURN_THROWS(); } RETURN_TRUE; @@ -1022,8 +1033,8 @@ PHP_METHOD(XMLReader, XML) } if (!source_len) { - php_error_docref(NULL, E_WARNING, "Empty string supplied as input"); - RETURN_FALSE; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } inputbfr = xmlParserInputBufferCreateMem(source, source_len, XML_CHAR_ENCODING_NONE); @@ -1105,7 +1116,7 @@ PHP_METHOD(XMLReader, expand) node = xmlTextReaderExpand(intern->ptr); if (node == NULL) { - php_error_docref(NULL, E_WARNING, "An Error Occurred while expanding "); + php_error_docref(NULL, E_WARNING, "An Error Occurred while expanding"); RETURN_FALSE; } else { nodec = xmlDocCopyNode(node, docp, 1); @@ -1117,8 +1128,8 @@ PHP_METHOD(XMLReader, expand) } } } else { - php_error_docref(NULL, E_WARNING, "Load Data before trying to expand"); - RETURN_FALSE; + zend_throw_error(NULL, "Data must be loaded before expanding"); + RETURN_THROWS(); } #else php_error(E_WARNING, "DOM support is not enabled"); diff --git a/ext/xmlreader/php_xmlreader.stub.php b/ext/xmlreader/php_xmlreader.stub.php index 9de30e5a7afd9..582919d49721f 100644 --- a/ext/xmlreader/php_xmlreader.stub.php +++ b/ext/xmlreader/php_xmlreader.stub.php @@ -7,7 +7,7 @@ class XMLReader /** @return bool */ public function close() {} - /** @return string|null|false */ + /** @return string|null */ public function getAttribute(string $name) {} /** @return string|null */ @@ -22,7 +22,7 @@ public function getParserProperty(int $property) {} /** @return bool */ public function isValid() {} - /** @return string|null|false */ + /** @return string|null */ public function lookupNamespace(string $prefix) {} /** @return bool */ diff --git a/ext/xmlreader/php_xmlreader_arginfo.h b/ext/xmlreader/php_xmlreader_arginfo.h index 749d8066f41cd..0690d414163e5 100644 --- a/ext/xmlreader/php_xmlreader_arginfo.h +++ b/ext/xmlreader/php_xmlreader_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 8bdec18c4ad8574fb1d3e4baca928949d5ec2438 */ + * Stub hash: 90e6d525ba87399c54f36965ebf18dbf65084617 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XMLReader_close, 0, 0, 0) ZEND_END_ARG_INFO() diff --git a/ext/xmlreader/tests/001.phpt b/ext/xmlreader/tests/001.phpt index c10c1a51635a9..cf255860556f4 100644 --- a/ext/xmlreader/tests/001.phpt +++ b/ext/xmlreader/tests/001.phpt @@ -17,10 +17,15 @@ while ($reader->read()) { } $xmlstring = ''; $reader = new XMLReader(); -$reader->XML($xmlstring); + +try { + $reader->XML($xmlstring); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + ?> ---EXPECTF-- +--EXPECT-- books books - -Warning: XMLReader::XML(): Empty string supplied as input in %s on line %d +XMLReader::XML(): Argument #1 ($source) cannot be empty diff --git a/ext/xmlreader/tests/002.phpt b/ext/xmlreader/tests/002.phpt index 6d12f02204759..803c8c7243aa6 100644 --- a/ext/xmlreader/tests/002.phpt +++ b/ext/xmlreader/tests/002.phpt @@ -10,7 +10,11 @@ $xmlstring = ' file_put_contents($filename, $xmlstring); $reader = new XMLReader(); -if ($reader->open('')) exit(); +try { + $reader->open(''); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} $reader = new XMLReader(); if (!$reader->open($filename)) { @@ -31,7 +35,7 @@ $reader->close(); unlink($filename); ?> ---EXPECTF-- -Warning: XMLReader::open(): Empty string supplied as input in %s on line %d +--EXPECT-- +XMLReader::open(): Argument #1 ($URI) cannot be empty books books diff --git a/ext/xmlreader/tests/003-get-errors.phpt b/ext/xmlreader/tests/003-get-errors.phpt index a10529118f87e..e616bbc63ce70 100644 --- a/ext/xmlreader/tests/003-get-errors.phpt +++ b/ext/xmlreader/tests/003-get-errors.phpt @@ -31,8 +31,12 @@ while ($reader->read()) { echo $reader->value . "\n"; // Test for call with an empty string argument - $attr = $reader->getAttribute(''); - var_dump($attr); + try { + $reader->getAttribute(''); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } + // Ensure that node pointer has not changed position echo $reader->name . ": "; echo $reader->value . "\n"; @@ -61,13 +65,11 @@ $reader->close(); ---EXPECTF-- +--EXPECT-- book bool(true) num: 1 - -Warning: XMLReader::getAttribute(): Argument cannot be an empty string in %s on line %d -bool(false) +XMLReader::getAttribute(): Argument #1 ($name) cannot be empty num: 1 NULL num: 1 diff --git a/ext/xmlreader/tests/003-move-errors.phpt b/ext/xmlreader/tests/003-move-errors.phpt index a00dbaf52442b..24431b6a7e2a0 100644 --- a/ext/xmlreader/tests/003-move-errors.phpt +++ b/ext/xmlreader/tests/003-move-errors.phpt @@ -31,8 +31,12 @@ while ($reader->read()) { echo $reader->value . "\n"; // Test for call with an empty string argument - $attr = $reader->moveToAttribute(''); - var_dump($attr); + try { + $reader->moveToAttribute(''); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } + // Ensure that node pointer has not changed position echo $reader->name . ": "; echo $reader->value . "\n"; @@ -60,13 +64,11 @@ $reader->close(); ---EXPECTF-- +--EXPECT-- book bool(true) num: 1 - -Warning: XMLReader::moveToAttribute(): Attribute Name is required in %s on line %d -bool(false) +XMLReader::moveToAttribute(): Argument #1 ($name) cannot be empty num: 1 bool(false) num: 1 diff --git a/ext/xmlreader/tests/003.phpt b/ext/xmlreader/tests/003.phpt index c52c932c974a2..9ecf9d62da7ca 100644 --- a/ext/xmlreader/tests/003.phpt +++ b/ext/xmlreader/tests/003.phpt @@ -68,14 +68,18 @@ while ($reader->read()) { var_dump($reader->moveToAttributeNo(20)); var_dump($reader->moveToAttribute('missing-attribute')); - var_dump($reader->moveToAttribute('')); + try { + $reader->moveToAttribute(''); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } } } $reader->close(); unlink($filename); ?> ---EXPECTF-- +--EXPECT-- num: 1 idx: 2 num: 1 @@ -84,6 +88,4 @@ num: 1 idx: 2 bool(false) bool(false) - -Warning: XMLReader::moveToAttribute(): Attribute Name is required in %s on line %d -bool(false) +XMLReader::moveToAttribute(): Argument #1 ($name) cannot be empty diff --git a/ext/xmlreader/tests/007.phpt b/ext/xmlreader/tests/007.phpt index 796b9fa05c9d4..6b8cab43f0f7f 100644 --- a/ext/xmlreader/tests/007.phpt +++ b/ext/xmlreader/tests/007.phpt @@ -42,13 +42,15 @@ $reader->close(); $reader = new XMLReader(); $reader->XML($xmlstring); -if ($reader->setRelaxNGSchema('')) { - echo 'failed'; +try { + $reader->setRelaxNGSchema(''); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; } + $reader->close(); ?> ---EXPECTF-- +--EXPECT-- file relaxNG: ok string relaxNG: ok - -Warning: XMLReader::setRelaxNGSchema(): Schema data source is required in %s on line %d +XMLReader::setRelaxNGSchema(): Argument #1 ($filename) cannot be empty diff --git a/ext/xmlreader/tests/014.phpt b/ext/xmlreader/tests/014.phpt index fca94d2b1f3ef..67c0e9fb93a6c 100644 --- a/ext/xmlreader/tests/014.phpt +++ b/ext/xmlreader/tests/014.phpt @@ -24,12 +24,24 @@ while ($reader->read()) { // Find a node to try modifying if ($reader->nodeType == XMLREADER::ELEMENT && $reader->name == 'book') { // Try to set the value of the element from book1 to movie1 - $reader->value = 'movie1'; + try { + $reader->value = 'movie1'; + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } // Try to set the value of the first "num" attribute from "1" to "num attribute 1" $attr = $reader->moveToFirstAttribute(); - $reader->value = 'num attribute 1'; + try { + $reader->value = 'num attribute 1'; + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } // Try to set the name of the first attribute from "num" to "number" - $reader->name = 'number'; + try { + $reader->name = 'number'; + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } } } } @@ -41,9 +53,7 @@ $reader->close(); ---EXPECTF-- -Warning: main(): Cannot write to read-only property in %s on line %d - -Warning: main(): Cannot write to read-only property in %s on line %d - -Warning: main(): Cannot write to read-only property in %s on line %d +--EXPECT-- +Cannot write to read-only property +Cannot write to read-only property +Cannot write to read-only property diff --git a/ext/xmlreader/tests/015-get-errors.phpt b/ext/xmlreader/tests/015-get-errors.phpt index 5f17326b1b6aa..850d042a4b0c8 100644 --- a/ext/xmlreader/tests/015-get-errors.phpt +++ b/ext/xmlreader/tests/015-get-errors.phpt @@ -26,8 +26,12 @@ while ($reader->read()) { $attr = $reader->moveToNextAttribute(); // Test for missing namespace argument - $attr = $reader->getAttributeNs('idx', null); - var_dump($attr); + try { + $attr = $reader->getAttributeNs('idx', null); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } + echo $reader->name . ": "; echo $reader->value . "\n"; } @@ -41,7 +45,6 @@ $reader->close(); ---EXPECTF-- -Warning: XMLReader::getAttributeNs(): Attribute Name and Namespace URI cannot be empty in %s on line %d -bool(false) +--EXPECT-- +XMLReader::getAttributeNs(): Argument #2 ($namespaceURI) cannot be empty ns1:num: 1 diff --git a/ext/xmlreader/tests/015-move-errors.phpt b/ext/xmlreader/tests/015-move-errors.phpt index 5263b555b6ea8..2b5580d7ea4fd 100644 --- a/ext/xmlreader/tests/015-move-errors.phpt +++ b/ext/xmlreader/tests/015-move-errors.phpt @@ -24,7 +24,11 @@ while ($reader->read()) { // Find the book node if ($reader->nodeType == XMLREADER::ELEMENT && $reader->name == 'book') { // Test for missing namespace argument - $attr = $reader->moveToAttributeNs('idx', null); + try { + $reader->moveToAttributeNs('idx', null); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } } } @@ -36,5 +40,5 @@ $reader->close(); ---EXPECTF-- -Warning: XMLReader::moveToAttributeNs(): Attribute Name and Namespace URI cannot be empty in %s on line %d +--EXPECT-- +XMLReader::moveToAttributeNs(): Argument #2 ($namespaceURI) cannot be empty diff --git a/ext/xmlreader/tests/expand_error.phpt b/ext/xmlreader/tests/expand_error.phpt index 2813e836d9f76..59ab0365b6043 100644 --- a/ext/xmlreader/tests/expand_error.phpt +++ b/ext/xmlreader/tests/expand_error.phpt @@ -13,7 +13,13 @@ $xmlstring = ' new book'; $reader = new XMLReader(); -var_dump($reader->expand()); + +try { + $reader->expand(); +} catch (Error $exception) { + echo $exception->getMessage() . "\n"; +} + $reader->close(); $reader = new XMLReader(); @@ -22,8 +28,7 @@ var_dump($reader->expand()); $reader->close(); ?> --EXPECTF-- -Warning: XMLReader::expand(): Load Data before trying to expand in %s on line %d -bool(false) +Data must be loaded before expanding -Warning: XMLReader::expand(): An Error Occurred while expanding in %s on line %d +Warning: XMLReader::expand(): An Error Occurred while expanding in %s on line %d bool(false) diff --git a/ext/xmlreader/tests/next_basic.phpt b/ext/xmlreader/tests/next_basic.phpt index e0663c23d3509..70d540c2c20ba 100644 --- a/ext/xmlreader/tests/next_basic.phpt +++ b/ext/xmlreader/tests/next_basic.phpt @@ -9,8 +9,19 @@ $xml = ' '; $reader = new XMLReader(); -$reader->read(); -$reader->next(); + +try { + $reader->read(); +} catch (Error $exception) { + echo $exception->getMessage() . "\n"; +} + +try { + $reader->next(); +} catch (Error $exception) { + echo $exception->getMessage() . "\n"; +} + $reader->close(); $reader->XML($xml); @@ -28,10 +39,9 @@ echo $reader->name . PHP_EOL; $reader->close(); ?> ---EXPECTF-- -Warning: XMLReader::read(): Load Data before trying to read in %s on line %d - -Warning: XMLReader::next(): Load Data before trying to read in %s on line %d +--EXPECT-- +Data must be loaded before reading +Data must be loaded before reading node1 bool(true) node3 diff --git a/ext/xmlreader/tests/schema-bad.xsd b/ext/xmlreader/tests/schema-bad.xsd new file mode 100644 index 0000000000000..d72af314604e3 --- /dev/null +++ b/ext/xmlreader/tests/schema-bad.xsd @@ -0,0 +1 @@ +asd diff --git a/ext/xmlreader/tests/setParserProperty_error.phpt b/ext/xmlreader/tests/setParserProperty_error.phpt index 755a4e4772c4b..9bdb0baa03259 100644 --- a/ext/xmlreader/tests/setParserProperty_error.phpt +++ b/ext/xmlreader/tests/setParserProperty_error.phpt @@ -10,9 +10,12 @@ $xml = 'new bookXML($xml); -var_dump($reader->setParserProperty(-1, true)); +try { + $reader->setParserProperty(-1, true); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} $reader->close(); ?> ---EXPECTF-- -Warning: XMLReader::setParserProperty(): Invalid parser property in %s on line %d -bool(false) +--EXPECT-- +XMLReader::setParserProperty(): Argument #1 ($property) must be a valid parser property diff --git a/ext/xmlreader/tests/setSchema_error.phpt b/ext/xmlreader/tests/setSchema_error.phpt index 31bd4d6e3ed96..2984455de8bba 100644 --- a/ext/xmlreader/tests/setSchema_error.phpt +++ b/ext/xmlreader/tests/setSchema_error.phpt @@ -6,24 +6,38 @@ XMLReader: setSchema Error setSchema('')); +try { + $reader->setSchema(''); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} $reader->close(); $reader = new XMLReader(); -var_dump($reader->setSchema('schema-missing-file.xsd')); +try { + $reader->setSchema('schema-missing-file.xsd'); +} catch (Error $exception) { + echo $exception->getMessage() . "\n"; +} $reader->close(); $reader = new XMLReader(); -var_dump($reader->setSchema('schema-empty.xsd')); +try { + $reader->setSchema('schema-empty.xsd'); +} catch (Error $exception) { + echo $exception->getMessage() . "\n"; +} + +$reader = new XMLReader(); +$reader->XML(<< + +EOF); +var_dump(@$reader->setSchema('schema-bad.xsd')); $reader->close(); ?> ---EXPECTF-- - -Warning: XMLReader::setSchema(): Schema data source is required in %s on line %d -bool(false) - -Warning: XMLReader::setSchema(): Unable to set schema. This must be set prior to reading or schema contains errors. in %s on line %d -bool(false) - -Warning: XMLReader::setSchema(): Unable to set schema. This must be set prior to reading or schema contains errors. in %s on line %d +--EXPECT-- +XMLReader::setSchema(): Argument #1 ($filename) cannot be empty +Schema must be set prior to reading +Schema must be set prior to reading bool(false) From be5ba2013275bc569e9f3987278bc4908f8d8f3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Tue, 18 Aug 2020 13:38:18 +0200 Subject: [PATCH 069/170] Promote warnings to exceptions in ext/phar Closes GH-6008 --- ext/phar/func_interceptors.c | 15 ++++++++---- ext/phar/phar_object.c | 8 +++--- ext/phar/phar_object.stub.php | 4 +-- ext/phar/phar_object_arginfo.h | 4 +-- ext/phar/tests/fgc_edgecases.phpt | 27 ++++++++++++++++----- ext/phar/tests/tar/phar_setdefaultstub.phpt | 20 ++++++++++----- ext/phar/tests/zip/phar_setdefaultstub.phpt | 18 ++++++++++---- 7 files changed, 66 insertions(+), 30 deletions(-) diff --git a/ext/phar/func_interceptors.c b/ext/phar/func_interceptors.c index b3eea43ec8ace..f7cfe2249f777 100644 --- a/ext/phar/func_interceptors.c +++ b/ext/phar/func_interceptors.c @@ -97,7 +97,8 @@ PHAR_FUNC(phar_file_get_contents) /* {{{ */ zend_bool use_include_path = 0; php_stream *stream; zend_long offset = -1; - zend_long maxlen = PHP_STREAM_COPY_ALL; + zend_long maxlen; + zend_bool maxlen_is_null = 1; zval *zcontext = NULL; if (!PHAR_G(intercepted)) { @@ -110,10 +111,14 @@ PHAR_FUNC(phar_file_get_contents) /* {{{ */ } /* Parse arguments */ - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "p|br!ll", &filename, &filename_len, &use_include_path, &zcontext, &offset, &maxlen) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "p|br!ll!", &filename, &filename_len, &use_include_path, &zcontext, &offset, &maxlen, &maxlen_is_null) == FAILURE) { goto skip_phar; } + if (maxlen_is_null) { + maxlen = (ssize_t) PHP_STREAM_COPY_ALL; + } + if (use_include_path || (!IS_ABSOLUTE_PATH(filename, filename_len) && !strstr(filename, "://"))) { char *arch, *entry, *fname; zend_string *entry_str = NULL; @@ -135,10 +140,10 @@ PHAR_FUNC(phar_file_get_contents) /* {{{ */ /* fopen within phar, if :// is not in the url, then prepend phar:/// */ entry_len = filename_len; - if (ZEND_NUM_ARGS() == 5 && maxlen < 0) { + if (!maxlen_is_null && maxlen < 0) { efree(arch); - php_error_docref(NULL, E_WARNING, "Length must be greater than or equal to zero"); - RETURN_FALSE; + zend_argument_value_error(5, "must be greater than or equal to 0"); + RETURN_THROWS(); } /* retrieving a file defaults to within the current directory, so use this if possible */ diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 97be3e900c117..efb7048cf6ab5 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -2918,7 +2918,7 @@ PHP_METHOD(Phar, setDefaultStub) size_t index_len = 0, webindex_len = 0; int created_stub = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s", &index, &index_len, &webindex, &webindex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!", &index, &index_len, &webindex, &webindex_len) == FAILURE) { RETURN_THROWS(); } @@ -2935,9 +2935,9 @@ PHP_METHOD(Phar, setDefaultStub) RETURN_THROWS(); } - if (ZEND_NUM_ARGS() > 0 && (phar_obj->archive->is_tar || phar_obj->archive->is_zip)) { - php_error_docref(NULL, E_WARNING, "Method accepts no arguments for a tar- or zip-based phar stub, %d given", ZEND_NUM_ARGS()); - RETURN_FALSE; + if ((index || webindex) && (phar_obj->archive->is_tar || phar_obj->archive->is_zip)) { + zend_argument_value_error(index ? 1 : 2, "must be null for a tar- or zip-based phar stub, string given"); + RETURN_THROWS(); } if (PHAR_G(readonly)) { diff --git a/ext/phar/phar_object.stub.php b/ext/phar/phar_object.stub.php index 7f0eca1034f8f..d9b69f784f4d2 100644 --- a/ext/phar/phar_object.stub.php +++ b/ext/phar/phar_object.stub.php @@ -125,7 +125,7 @@ public function offsetUnset($entry) {} public function setAlias(string $alias) {} /** @return bool */ - public function setDefaultStub(?string $index = null, string $webindex = UNKNOWN) {} + public function setDefaultStub(?string $index = null, ?string $webindex = null) {} /** * @param mixed $metadata @@ -398,7 +398,7 @@ public function setAlias(string $alias) {} * @return bool * @alias Phar::setDefaultStub */ - public function setDefaultStub(?string $index = null, string $webindex = UNKNOWN) {} + public function setDefaultStub(?string $index = null, ?string $webindex = null) {} /** * @param mixed $metadata diff --git a/ext/phar/phar_object_arginfo.h b/ext/phar/phar_object_arginfo.h index 67b5ba558029f..95799bd487822 100644 --- a/ext/phar/phar_object_arginfo.h +++ b/ext/phar/phar_object_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: f25efd47b496a7d06a30c77911a565a49e383bce */ + * Stub hash: be0f8bcd0ef8fdac59700160dff7d0beb210aa48 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) @@ -125,7 +125,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_setDefaultStub, 0, 0, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, index, IS_STRING, 1, "null") - ZEND_ARG_TYPE_INFO(0, webindex, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, webindex, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_setMetadata, 0, 0, 1) diff --git a/ext/phar/tests/fgc_edgecases.phpt b/ext/phar/tests/fgc_edgecases.phpt index a902b669c9aa7..38ff03cce8b0e 100644 --- a/ext/phar/tests/fgc_edgecases.phpt +++ b/ext/phar/tests/fgc_edgecases.phpt @@ -29,7 +29,11 @@ mkdir($pname . '/oops'); file_put_contents($pname . '/foo/hi', 'getMessage() . "\n"; +} echo file_get_contents("fgc_edgecases.txt"); set_include_path("' . addslashes(__DIR__) . '"); echo file_get_contents("fgc_edgecases.txt", true); @@ -53,7 +57,11 @@ blah getMessage() . "\n"; +} echo file_get_contents("fgc_edgecases.txt"); set_include_path("%stests"); echo file_get_contents("fgc_edgecases.txt", true); @@ -63,14 +71,17 @@ echo file_get_contents("./hi", 0, $context, 50000); echo file_get_contents("./hi"); echo file_get_contents("./hi", 0, $context, 0, 0); ?> - -Warning: file_get_contents(): Length must be greater than or equal to zero in phar://%sfgc_edgecases.phar.php/foo/hi on line %d +file_get_contents(): Argument #5 ($maxlen) must be greater than or equal to 0 test test getMessage() . "\n"; +} echo file_get_contents("fgc_edgecases.txt"); set_include_path("%stests"); echo file_get_contents("fgc_edgecases.txt", true); @@ -87,7 +98,11 @@ Warning: file_get_contents(): Failed to seek to position 50000 in the stream in getMessage() . "\n"; +} echo file_get_contents("fgc_edgecases.txt"); set_include_path("%stests"); echo file_get_contents("fgc_edgecases.txt", true); diff --git a/ext/phar/tests/tar/phar_setdefaultstub.phpt b/ext/phar/tests/tar/phar_setdefaultstub.phpt index 6811c4c59dd26..7404a5851eb89 100644 --- a/ext/phar/tests/tar/phar_setdefaultstub.phpt +++ b/ext/phar/tests/tar/phar_setdefaultstub.phpt @@ -33,18 +33,28 @@ echo "========================================================================== try { $phar->setDefaultStub('my/custom/thingy.php'); +} catch(ValueError $e) { + echo $e->getMessage(). "\n"; +} + +try { $phar->stopBuffering(); } catch(Exception $e) { echo $e->getMessage(). "\n"; } - var_dump($phar->getStub()); echo "============================================================================\n"; echo "============================================================================\n"; + try { $phar->setDefaultStub('my/custom/thingy.php', 'the/web.php'); +} catch(ValueError $e) { + echo $e->getMessage(). "\n"; +} + +try { $phar->stopBuffering(); } catch(Exception $e) { echo $e->getMessage(). "\n"; @@ -57,7 +67,7 @@ var_dump($phar->getStub()); ---EXPECTF-- +--EXPECT-- string(51) " " ============================================================================ @@ -66,13 +76,11 @@ string(60) "setDefaultStub('my/custom/thingy.php'); +} catch(Error $e) { + echo $e->getMessage(). "\n"; +} + +try { $phar->stopBuffering(); } catch(Exception $e) { echo $e->getMessage(). "\n"; @@ -45,6 +50,11 @@ echo "========================================================================== try { $phar->setDefaultStub('my/custom/thingy.php', 'the/web.php'); +} catch(ValueError $e) { + echo $e->getMessage(). "\n"; +} + +try { $phar->stopBuffering(); } catch(Exception $e) { echo $e->getMessage(). "\n"; @@ -57,7 +67,7 @@ var_dump($phar->getStub()); ---EXPECTF-- +--EXPECT-- string(51) " " ============================================================================ @@ -66,13 +76,11 @@ string(60) " Date: Tue, 25 Aug 2020 18:02:38 +0800 Subject: [PATCH 070/170] Remove useless same_zval function Closes GH-6039. --- Zend/zend_API.c | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/Zend/zend_API.c b/Zend/zend_API.c index de6e6d2b3daee..92879137723bb 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -4260,44 +4260,15 @@ ZEND_API void zend_replace_error_handling(zend_error_handling_t error_handling, } /* }}} */ -static int same_zval(zval *zv1, zval *zv2) /* {{{ */ -{ - if (Z_TYPE_P(zv1) != Z_TYPE_P(zv2)) { - return 0; - } - switch (Z_TYPE_P(zv1)) { - case IS_UNDEF: - case IS_NULL: - case IS_FALSE: - case IS_TRUE: - return 1; - case IS_LONG: - return Z_LVAL_P(zv1) == Z_LVAL_P(zv2); - case IS_DOUBLE: - return Z_LVAL_P(zv1) == Z_LVAL_P(zv2); - case IS_STRING: - case IS_ARRAY: - case IS_OBJECT: - case IS_RESOURCE: - return Z_COUNTED_P(zv1) == Z_COUNTED_P(zv2); - default: - return 0; - } -} -/* }}} */ - ZEND_API void zend_restore_error_handling(zend_error_handling *saved) /* {{{ */ { EG(error_handling) = saved->handling; EG(exception_class) = saved->handling == EH_THROW ? saved->exception : NULL; - if (Z_TYPE(saved->user_handler) != IS_UNDEF - && !same_zval(&saved->user_handler, &EG(user_error_handler))) { + if (Z_TYPE(saved->user_handler) != IS_UNDEF) { zval_ptr_dtor(&EG(user_error_handler)); ZVAL_COPY_VALUE(&EG(user_error_handler), &saved->user_handler); - } else if (Z_TYPE(saved->user_handler)) { - zval_ptr_dtor(&saved->user_handler); + ZVAL_UNDEF(&saved->user_handler); } - ZVAL_UNDEF(&saved->user_handler); } /* }}} */ From 063082043adf6fd5363078a3c04f7977ac22d73d Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 25 Aug 2020 12:34:32 +0200 Subject: [PATCH 071/170] Remove bogus REGISTER_LONG_CONSTANT This shouldn't be in this function, probably a copy/paste mistake... --- ext/mysqli/mysqli_api.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index 8632971893a79..27cf68d70037f 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -1729,16 +1729,13 @@ static int mysqli_options_get_option_zval_type(int option) #ifdef MYSQL_OPT_COMPRESS case MYSQL_OPT_COMPRESS: #endif /* mysqlnd @ PHP 5.3.2 */ -#ifdef MYSQL_OPT_SSL_VERIFY_SERVER_CERT - REGISTER_LONG_CONSTANT("MYSQLI_OPT_SSL_VERIFY_SERVER_CERT", MYSQL_OPT_SSL_VERIFY_SERVER_CERT, CONST_CS | CONST_PERSISTENT); -#endif /* MySQL 5.1.1., mysqlnd @ PHP 5.3.3 */ #if (MYSQL_VERSION_ID >= 50611 && defined(CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS)) || defined(MYSQLI_USE_MYSQLND) case MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS: #endif return IS_LONG; #ifdef MYSQL_SHARED_MEMORY_BASE_NAME - case MYSQL_SHARED_MEMORY_BASE_NAME: + case MYSQL_SHARED_MEMORY_BASE_NAME: #endif /* MySQL 4.1.0 */ #ifdef MYSQL_SET_CLIENT_IP case MYSQL_SET_CLIENT_IP: From 3df306de94dd94d6520c6f95e96c692c3aa8173a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Mon, 17 Aug 2020 22:37:20 +0200 Subject: [PATCH 072/170] Promote warnings to exceptions in ext/pcntl Closes GH-6004 --- ext/pcntl/pcntl.c | 39 +++++++++++--------- ext/pcntl/pcntl.stub.php | 2 +- ext/pcntl/pcntl_arginfo.h | 2 +- ext/pcntl/tests/pcntl_getpriority_error.phpt | 23 ++++++++++++ ext/pcntl/tests/pcntl_setpriority_error.phpt | 23 ++++++++++++ ext/pcntl/tests/pcntl_signal.phpt | 32 ++++++++++------ ext/pcntl/tests/pcntl_unshare_01.phpt | 4 +- ext/pcntl/tests/pcntl_unshare_02.phpt | 2 +- ext/pcntl/tests/pcntl_unshare_04.phpt | 20 ++++++++++ 9 files changed, 113 insertions(+), 34 deletions(-) create mode 100644 ext/pcntl/tests/pcntl_getpriority_error.phpt create mode 100644 ext/pcntl/tests/pcntl_setpriority_error.phpt create mode 100644 ext/pcntl/tests/pcntl_unshare_04.phpt diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index 624f2f0db3d5b..0df11aa3887c9 100644 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -892,9 +892,14 @@ PHP_FUNCTION(pcntl_signal) RETURN_THROWS(); } - if (signo < 1 || signo >= NSIG) { - php_error_docref(NULL, E_WARNING, "Invalid signal"); - RETURN_FALSE; + if (signo < 1) { + zend_argument_value_error(1, "must be greater than or equal to 1"); + RETURN_THROWS(); + } + + if (signo >= NSIG) { + zend_argument_value_error(1, "must be less than %d", NSIG); + RETURN_THROWS(); } if (!PCNTL_G(spares)) { @@ -920,8 +925,8 @@ PHP_FUNCTION(pcntl_signal) /* Special long value case for SIG_DFL and SIG_IGN */ if (Z_TYPE_P(handle) == IS_LONG) { if (Z_LVAL_P(handle) != (zend_long) SIG_DFL && Z_LVAL_P(handle) != (zend_long) SIG_IGN) { - php_error_docref(NULL, E_WARNING, "Invalid value for handle argument specified"); - RETURN_FALSE; + zend_argument_value_error(2, "must be either SIG_DFL or SIG_IGN when an integer value is given"); + RETURN_THROWS(); } if (php_signal(signo, (Sigfunc *) Z_LVAL_P(handle), (int) restart_syscalls) == (void *)SIG_ERR) { PCNTL_G(last_error) = errno; @@ -935,10 +940,11 @@ PHP_FUNCTION(pcntl_signal) if (!zend_is_callable_ex(handle, NULL, 0, NULL, NULL, &error)) { zend_string *func_name = zend_get_callable_name(handle); PCNTL_G(last_error) = EINVAL; - php_error_docref(NULL, E_WARNING, "Specified handler \"%s\" is not callable (%s)", ZSTR_VAL(func_name), error); + + zend_argument_type_error(2, "must be of type callable|int, %s given", zend_zval_type_name(handle)); zend_string_release_ex(func_name, 0); efree(error); - RETURN_FALSE; + RETURN_THROWS(); } ZEND_ASSERT(!error); @@ -966,8 +972,8 @@ PHP_FUNCTION(pcntl_signal_get_handler) } if (signo < 1 || signo > 32) { - php_error_docref(NULL, E_WARNING, "Invalid signal"); - RETURN_FALSE; + zend_argument_value_error(1, "must be between 1 and 32"); + RETURN_THROWS(); } if ((prev_handle = zend_hash_index_find(&PCNTL_G(php_signal_table), signo)) != NULL) { @@ -1197,8 +1203,8 @@ PHP_FUNCTION(pcntl_getpriority) php_error_docref(NULL, E_WARNING, "Error %d: No process was located using the given parameters", errno); break; case EINVAL: - php_error_docref(NULL, E_WARNING, "Error %d: Invalid identifier flag", errno); - break; + zend_argument_value_error(2, "must be one of PRIO_PGRP, PRIO_USER, or PRIO_PROCESS"); + RETURN_THROWS(); default: php_error_docref(NULL, E_WARNING, "Unknown error %d has occurred", errno); break; @@ -1231,8 +1237,8 @@ PHP_FUNCTION(pcntl_setpriority) php_error_docref(NULL, E_WARNING, "Error %d: No process was located using the given parameters", errno); break; case EINVAL: - php_error_docref(NULL, E_WARNING, "Error %d: Invalid identifier flag", errno); - break; + zend_argument_value_error(3, "must be one of PRIO_PGRP, PRIO_USER, or PRIO_PROCESS"); + RETURN_THROWS(); case EPERM: php_error_docref(NULL, E_WARNING, "Error %d: A process was located, but neither its effective nor real user ID matched the effective user ID of the caller", errno); break; @@ -1400,19 +1406,18 @@ PHP_FUNCTION(pcntl_async_signals) PHP_FUNCTION(pcntl_unshare) { zend_long flags; - int ret; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_LONG(flags) ZEND_PARSE_PARAMETERS_END(); - ret = unshare(flags); - if (ret == -1) { + if (unshare(flags) == -1) { PCNTL_G(last_error) = errno; switch (errno) { #ifdef EINVAL case EINVAL: - php_error_docref(NULL, E_WARNING, "Error %d: Invalid flag specified", errno); + zend_argument_value_error(1, "must be a combination of CLONE_* flags"); + RETURN_THROWS(); break; #endif #ifdef ENOMEM diff --git a/ext/pcntl/pcntl.stub.php b/ext/pcntl/pcntl.stub.php index 0c56b04966543..2c3cd64aad170 100644 --- a/ext/pcntl/pcntl.stub.php +++ b/ext/pcntl/pcntl.stub.php @@ -19,7 +19,7 @@ function pcntl_wait(&$status, int $options = 0, &$rusage = []): int {} /** @param callable|int $handler */ function pcntl_signal(int $signo, $handler, bool $restart_syscalls = true): bool {} -/** @return mixed */ +/** @return callable|int */ function pcntl_signal_get_handler(int $signo) {} function pcntl_signal_dispatch(): bool {} diff --git a/ext/pcntl/pcntl_arginfo.h b/ext/pcntl/pcntl_arginfo.h index 4c34a762c81e8..fb0fe5fa08049 100644 --- a/ext/pcntl/pcntl_arginfo.h +++ b/ext/pcntl/pcntl_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: df744f88533ce9b84864fa2aa4dd7a5b7373231d */ + * Stub hash: 306208d94ba3bf6f8112f868a332e99717bc07fa */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcntl_fork, 0, 0, IS_LONG, 0) ZEND_END_ARG_INFO() diff --git a/ext/pcntl/tests/pcntl_getpriority_error.phpt b/ext/pcntl/tests/pcntl_getpriority_error.phpt new file mode 100644 index 0000000000000..5276d4df77f6e --- /dev/null +++ b/ext/pcntl/tests/pcntl_getpriority_error.phpt @@ -0,0 +1,23 @@ +--TEST-- +pcntl_getpriority() - Wrong process identifier +--SKIPIF-- + +--FILE-- +getMessage() . "\n"; +} + +?> +--EXPECT-- +pcntl_getpriority(): Argument #2 ($process_identifier) must be one of PRIO_PGRP, PRIO_USER, or PRIO_PROCESS diff --git a/ext/pcntl/tests/pcntl_setpriority_error.phpt b/ext/pcntl/tests/pcntl_setpriority_error.phpt new file mode 100644 index 0000000000000..d354ab2bc5c14 --- /dev/null +++ b/ext/pcntl/tests/pcntl_setpriority_error.phpt @@ -0,0 +1,23 @@ +--TEST-- +pcntl_setpriority() - Wrong process identifier +--SKIPIF-- + +--FILE-- +getMessage() . "\n"; +} + +?> +--EXPECT-- +pcntl_setpriority(): Argument #3 ($process_identifier) must be one of PRIO_PGRP, PRIO_USER, or PRIO_PROCESS diff --git a/ext/pcntl/tests/pcntl_signal.phpt b/ext/pcntl/tests/pcntl_signal.phpt index cd55d9ad96739..4b94064e2a973 100644 --- a/ext/pcntl/tests/pcntl_signal.phpt +++ b/ext/pcntl/tests/pcntl_signal.phpt @@ -18,10 +18,24 @@ posix_kill(posix_getpid(), SIGUSR1); pcntl_signal_dispatch(); var_dump(pcntl_signal(SIGALRM, SIG_IGN)); -var_dump(pcntl_signal(-1, -1)); -var_dump(pcntl_signal(-1, function(){})); -var_dump(pcntl_signal(SIGALRM, "not callable")); +try { + pcntl_signal(-1, -1); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + +try { + pcntl_signal(-1, function(){}); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + +try { + pcntl_signal(SIGALRM, "not callable"); +} catch (TypeError $exception) { + echo $exception->getMessage() . "\n"; +} /* test freeing queue in RSHUTDOWN */ posix_kill(posix_getpid(), SIGTERM); @@ -31,13 +45,7 @@ echo "ok\n"; signal dispatched got signal from %r\d+|nobody%r bool(true) - -Warning: pcntl_signal(): Invalid signal %s -bool(false) - -Warning: pcntl_signal(): Invalid signal %s -bool(false) - -Warning: pcntl_signal(): Specified handler "not callable" is not callable (%s) in %s -bool(false) +pcntl_signal(): Argument #1 ($signo) must be greater than or equal to 1 +pcntl_signal(): Argument #1 ($signo) must be greater than or equal to 1 +pcntl_signal(): Argument #2 ($handler) must be of type callable|int, string given ok diff --git a/ext/pcntl/tests/pcntl_unshare_01.phpt b/ext/pcntl/tests/pcntl_unshare_01.phpt index 6debaace58a3e..fcbf112e4d6f4 100644 --- a/ext/pcntl/tests/pcntl_unshare_01.phpt +++ b/ext/pcntl/tests/pcntl_unshare_01.phpt @@ -7,9 +7,9 @@ if (!extension_loaded("posix")) die("skip posix extension not available"); if (!function_exists("pcntl_unshare")) die("skip pcntl_unshare is not available"); if (!defined("CLONE_NEWUSER")) die("skip flag unavailable"); if (@pcntl_unshare(CLONE_NEWUSER) == false && pcntl_get_last_error() == PCNTL_EPERM) { - die("skip Insufficient previleges to use CLONE_NEWUSER"); + die("skip Insufficient privileges to use CLONE_NEWUSER"); } - +?> --FILE-- --FILE-- +--FILE-- +getMessage() . "\n"; +} + +?> +--EXPECT-- +pcntl_unshare(): Argument #1 ($flags) must be a combination of CLONE_* flags From d54bc295409663abc6ef940e24c35896e56e3372 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Fri, 14 Aug 2020 00:32:36 +0200 Subject: [PATCH 073/170] Promote warnings to exceptions in ext/shmop Closes GH-5986 --- ext/shmop/shmop.c | 32 ++++++------ ext/shmop/shmop.stub.php | 4 +- ext/shmop/shmop_arginfo.h | 6 +-- ext/shmop/tests/001.phpt | 15 +++--- ext/shmop/tests/002.phpt | 100 +++++++++++++++++++++++--------------- 5 files changed, 92 insertions(+), 65 deletions(-) diff --git a/ext/shmop/shmop.c b/ext/shmop/shmop.c index 7cd66f830016f..3d8975e76fae5 100644 --- a/ext/shmop/shmop.c +++ b/ext/shmop/shmop.c @@ -149,8 +149,8 @@ PHP_FUNCTION(shmop_open) } if (flags_len != 1) { - php_error_docref(NULL, E_WARNING, "%s is not a valid flag", flags); - RETURN_FALSE; + zend_argument_value_error(2, "must be a valid access mode"); + RETURN_THROWS(); } object_init_ex(return_value, shmop_ce); @@ -178,35 +178,35 @@ PHP_FUNCTION(shmop_open) */ break; default: - php_error_docref(NULL, E_WARNING, "Invalid access mode"); + zend_argument_value_error(2, "must be a valid access mode"); goto err; } if (shmop->shmflg & IPC_CREAT && shmop->size < 1) { - php_error_docref(NULL, E_WARNING, "Shared memory segment size must be greater than zero"); + zend_argument_value_error(4, "must be greater than 0 for the \"c\" and \"n\" access modes"); goto err; } shmop->shmid = shmget(shmop->key, shmop->size, shmop->shmflg); if (shmop->shmid == -1) { - php_error_docref(NULL, E_WARNING, "Unable to attach or create shared memory segment '%s'", strerror(errno)); + php_error_docref(NULL, E_WARNING, "Unable to attach or create shared memory segment \"%s\"", strerror(errno)); goto err; } if (shmctl(shmop->shmid, IPC_STAT, &shm)) { /* please do not add coverage here: the segment would be leaked and impossible to delete via php */ - php_error_docref(NULL, E_WARNING, "Unable to get shared memory segment information '%s'", strerror(errno)); + php_error_docref(NULL, E_WARNING, "Unable to get shared memory segment information \"%s\"", strerror(errno)); goto err; } if (shm.shm_segsz > ZEND_LONG_MAX) { - php_error_docref(NULL, E_WARNING, "shared memory segment too large to attach"); + zend_argument_value_error(4, "is too large"); goto err; } shmop->addr = shmat(shmop->shmid, 0, shmop->shmatflg); if (shmop->addr == (char*) -1) { - php_error_docref(NULL, E_WARNING, "Unable to attach to shared memory segment '%s'", strerror(errno)); + php_error_docref(NULL, E_WARNING, "Unable to attach to shared memory segment \"%s\"", strerror(errno)); goto err; } @@ -236,13 +236,13 @@ PHP_FUNCTION(shmop_read) shmop = Z_SHMOP_P(shmid); if (start < 0 || start > shmop->size) { - php_error_docref(NULL, E_WARNING, "Start is out of range"); - RETURN_FALSE; + zend_argument_value_error(2, "must be between 0 and the segment size"); + RETURN_THROWS(); } if (count < 0 || start > (INT_MAX - count) || start + count > shmop->size) { - php_error_docref(NULL, E_WARNING, "Count is out of range"); - RETURN_FALSE; + zend_argument_value_error(3, "is out of range"); + RETURN_THROWS(); } startaddr = shmop->addr + start; @@ -297,13 +297,13 @@ PHP_FUNCTION(shmop_write) shmop = Z_SHMOP_P(shmid); if ((shmop->shmatflg & SHM_RDONLY) == SHM_RDONLY) { - php_error_docref(NULL, E_WARNING, "Trying to write to a read only segment"); - RETURN_FALSE; + zend_throw_error(NULL, "Read-only segment cannot be written"); + RETURN_THROWS(); } if (offset < 0 || offset > shmop->size) { - php_error_docref(NULL, E_WARNING, "Offset out of range"); - RETURN_FALSE; + zend_argument_value_error(3, "is out of range"); + RETURN_THROWS(); } writesize = ((zend_long)ZSTR_LEN(data) < shmop->size - offset) ? (zend_long)ZSTR_LEN(data) : shmop->size - offset; diff --git a/ext/shmop/shmop.stub.php b/ext/shmop/shmop.stub.php index c19cbc26f0e07..cddb9c64f4892 100644 --- a/ext/shmop/shmop.stub.php +++ b/ext/shmop/shmop.stub.php @@ -6,13 +6,13 @@ final class Shmop {} function shmop_open(int $key, string $flags, int $mode, int $size): Shmop|false {} -function shmop_read(Shmop $shmid, int $start, int $count): string|false {} +function shmop_read(Shmop $shmid, int $start, int $count): string {} /** @deprecated */ function shmop_close(Shmop $shmid): void {} function shmop_size(Shmop $shmid): int {} -function shmop_write(Shmop $shmid, string $data, int $offset): int|false {} +function shmop_write(Shmop $shmid, string $data, int $offset): int {} function shmop_delete(Shmop $shmid): bool {} diff --git a/ext/shmop/shmop_arginfo.h b/ext/shmop/shmop_arginfo.h index 494559e4f5b72..211204720ad0a 100644 --- a/ext/shmop/shmop_arginfo.h +++ b/ext/shmop/shmop_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: e451ccfbe66fc2b6fc0dae6e7e5710ededaf7b0c */ + * Stub hash: 1fe8d001718e20ca915480d1ab6cb6996115b547 */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_shmop_open, 0, 4, Shmop, MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, key, IS_LONG, 0) @@ -8,7 +8,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_shmop_open, 0, 4, Shmop, MAY ZEND_ARG_TYPE_INFO(0, size, IS_LONG, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_shmop_read, 0, 3, MAY_BE_STRING|MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_shmop_read, 0, 3, IS_STRING, 0) ZEND_ARG_OBJ_INFO(0, shmid, Shmop, 0) ZEND_ARG_TYPE_INFO(0, start, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, count, IS_LONG, 0) @@ -22,7 +22,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_shmop_size, 0, 1, IS_LONG, 0) ZEND_ARG_OBJ_INFO(0, shmid, Shmop, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_shmop_write, 0, 3, MAY_BE_LONG|MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_shmop_write, 0, 3, IS_LONG, 0) ZEND_ARG_OBJ_INFO(0, shmid, Shmop, 0) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, offset, IS_LONG, 0) diff --git a/ext/shmop/tests/001.phpt b/ext/shmop/tests/001.phpt index 55e8476b844a2..4cac82d2f0c8b 100644 --- a/ext/shmop/tests/001.phpt +++ b/ext/shmop/tests/001.phpt @@ -43,7 +43,11 @@ shmop extension test echo "data in memory is: " . shmop_read($shm_id, 0, $written) . "\n"; /* try to append data to the shared memory segment, this should fail */ - shmop_write($shm_id, $write_d1, $written); + try { + shmop_write($shm_id, $write_d1, $written); + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } echo "shm open for read only: "; $shm_id = shmop_open($hex_shm_id, "w", 0644, 1024); @@ -53,7 +57,7 @@ shmop extension test echo "ok\n"; } - echo "shm write test #1: "; + echo "shm write test #2: "; $written = shmop_write($shm_id, $write_d2, $written); if ($written != strlen($write_d2)) { die("failed\n"); @@ -70,16 +74,15 @@ shmop extension test echo "ok\n"; } ?> ---EXPECTF-- +--EXPECT-- shm open for create: ok shm size is: 1024 shm write test #1: ok data in memory is: test #1 of the shmop() extension shm open for read only: ok data in memory is: test #1 of the shmop() extension - -Warning: shmop_write(): Trying to write to a read only segment in %s on line %d +Read-only segment cannot be written shm open for read only: ok -shm write test #1: ok +shm write test #2: ok data in memory is: test #1 of the shmop() extensiontest #2 append data to shared memory segment deletion of shm segment: ok diff --git a/ext/shmop/tests/002.phpt b/ext/shmop/tests/002.phpt index f1f084fdbf8b7..6b82fc27c0582 100644 --- a/ext/shmop/tests/002.phpt +++ b/ext/shmop/tests/002.phpt @@ -11,57 +11,81 @@ edgarsandi - --FILE-- getMessage() . "\n"; +} - // warning outputs: unable to attach or create shared memory segment - var_dump(shmop_open(null, 'a', 0644, 1024)); +try { + shmop_open(1338, 'b', 0644, 1024); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} - // warning outputs: Shared memory segment size must be greater than zero - var_dump(shmop_open(1338, "c", 0666, 0)); +// Warning outputs: Unable to attach or create shared memory segment +var_dump(shmop_open(null, 'a', 0644, 1024)); -echo PHP_EOL, '## shmop_read function tests ##'; - // warning outputs: start is out of range - $shm_id = shmop_open(1338, 'n', 0600, 1024); - var_dump(shmop_read($shm_id, -10, 0)); - shmop_delete($shm_id); +// Shared memory segment size must be greater than zero +try { + shmop_open(null, 'a', 0644, 1024); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} - // warning outputs: count is out of range - $shm_id = shmop_open(1339, 'n', 0600, 1024); - var_dump(shmop_read($shm_id, 0, -10)); - shmop_delete($shm_id); +//Shared memory segment size must be greater than zero +try { + shmop_open(1338, "c", 0666, 0); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} -echo PHP_EOL, '## shmop_write function tests ##'; - // warning outputs: offset out of range - $shm_id = shmop_open(1340, 'n', 0600, 1024); - var_dump(shmop_write($shm_id, 'text to try write', -10)); - shmop_delete($shm_id); +echo PHP_EOL, '## shmop_read function tests ##', PHP_EOL; +// Start is out of range +$shm_id = shmop_open(1338, 'n', 0600, 1024); +try { + shmop_read($shm_id, -10, 0); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} +shmop_delete($shm_id); + +// Count is out of range +$shm_id = shmop_open(1339, 'n', 0600, 1024); +try { + shmop_read($shm_id, 0, -10); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} +shmop_delete($shm_id); + +echo PHP_EOL, '## shmop_write function tests ##', PHP_EOL; +// Offset out of range +$shm_id = shmop_open(1340, 'n', 0600, 1024); +try { + shmop_write($shm_id, 'text to try write', -10); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} +shmop_delete($shm_id); ?> --EXPECTF-- ## shmop_open function tests ## -Warning: shmop_open(): is not a valid flag in %s on line %d -bool(false) - -Warning: shmop_open(): Invalid access mode in %s on line %d -bool(false) +shmop_open(): Argument #2 ($flags) must be a valid access mode +shmop_open(): Argument #2 ($flags) must be a valid access mode -Warning: shmop_open(): Unable to attach or create shared memory segment '%s' in %s on line %d +Warning: shmop_open(): Unable to attach or create shared memory segment "%s" in %s on line %d bool(false) -Warning: shmop_open(): Shared memory segment size must be greater than zero in %s on line %d -bool(false) +Warning: shmop_open(): Unable to attach or create shared memory segment "%s" in %s on line %d +shmop_open(): Argument #4 ($size) must be greater than 0 for the "c" and "n" access modes ## shmop_read function tests ## -Warning: shmop_read(): Start is out of range in %s on line %d -bool(false) - -Warning: shmop_read(): Count is out of range in %s on line %d -bool(false) +shmop_read(): Argument #2 ($start) must be between 0 and the segment size +shmop_read(): Argument #3 ($count) is out of range ## shmop_write function tests ## -Warning: shmop_write(): Offset out of range in %s on line %d -bool(false) +shmop_write(): Argument #3 ($offset) is out of range From 3324bb893e965010cdac9b029a74f26072b5f540 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 25 Aug 2020 13:07:29 +0200 Subject: [PATCH 074/170] Avoid double-free As of commit b2e3fd1[1] the `authid.User` is no longer newly allocated, so we must not free it. [1] --- ext/com_dotnet/com_com.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ext/com_dotnet/com_com.c b/ext/com_dotnet/com_com.c index af72db63b188c..c9962835d14c7 100644 --- a/ext/com_dotnet/com_com.c +++ b/ext/com_dotnet/com_com.c @@ -221,7 +221,6 @@ PHP_FUNCTION(com_create_instance) if (server_name) { if (info.pwszName) efree(info.pwszName); - if (authid.User) efree(authid.User); } efree(moniker); From 5ecefd07608df0fe706eb9cc829f4d26cc44972b Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 25 Aug 2020 13:09:38 +0200 Subject: [PATCH 075/170] Fix XMLWriter::writeDtdEntity() stub $isparam is optional. --- ext/xmlwriter/php_xmlwriter.stub.php | 2 +- ext/xmlwriter/php_xmlwriter_arginfo.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/xmlwriter/php_xmlwriter.stub.php b/ext/xmlwriter/php_xmlwriter.stub.php index ee4a85eb4dd3d..54cdd4ff5607c 100644 --- a/ext/xmlwriter/php_xmlwriter.stub.php +++ b/ext/xmlwriter/php_xmlwriter.stub.php @@ -206,7 +206,7 @@ public function startDtdEntity(string $name, bool $isparam): bool {} public function endDtdEntity(): bool {} /** @alias xmlwriter_write_dtd_entity */ - public function writeDtdEntity(string $name, string $content, bool $isparam, string $publicId = UNKNOWN, string $systemId = UNKNOWN, string $ndataid = UNKNOWN): bool {} + public function writeDtdEntity(string $name, string $content, bool $isparam = false, string $publicId = UNKNOWN, string $systemId = UNKNOWN, string $ndataid = UNKNOWN): bool {} /** @alias xmlwriter_output_memory */ public function outputMemory(bool $flush = true): string {} diff --git a/ext/xmlwriter/php_xmlwriter_arginfo.h b/ext/xmlwriter/php_xmlwriter_arginfo.h index c59a4e6073fed..cebddf6372fb1 100644 --- a/ext/xmlwriter/php_xmlwriter_arginfo.h +++ b/ext/xmlwriter/php_xmlwriter_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: c4717d4f5dafe071fb78799993db1e733d45470a */ + * Stub hash: 9323f768ddea26f104b699a9c0ce54e3560b3b32 */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_xmlwriter_open_uri, 0, 1, XMLWriter, MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, uri, IS_STRING, 0) @@ -310,10 +310,10 @@ ZEND_END_ARG_INFO() #define arginfo_class_XMLWriter_endDtdEntity arginfo_class_XMLWriter_openMemory -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_XMLWriter_writeDtdEntity, 0, 3, _IS_BOOL, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_XMLWriter_writeDtdEntity, 0, 2, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, content, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, isparam, _IS_BOOL, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, isparam, _IS_BOOL, 0, "false") ZEND_ARG_TYPE_INFO(0, publicId, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, systemId, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, ndataid, IS_STRING, 0) From 259d050a39cf24c21237055598b5c5a52aea2565 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 14 Aug 2020 16:56:25 +0200 Subject: [PATCH 076/170] Clean up BreakIterator create_object handler Use standard zend_object_alloc() function and fix the object_init_properties() call (which works out okay because there are no properties). --- ext/intl/breakiterator/breakiterator_class.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/intl/breakiterator/breakiterator_class.cpp b/ext/intl/breakiterator/breakiterator_class.cpp index 2114ada558825..3f236db2d470a 100644 --- a/ext/intl/breakiterator/breakiterator_class.cpp +++ b/ext/intl/breakiterator/breakiterator_class.cpp @@ -69,7 +69,7 @@ U_CFUNC void breakiterator_object_construct(zval *object, BreakIterator_object *bio; BREAKITER_METHOD_FETCH_OBJECT_NO_CHECK; //populate to from object - assert(bio->biter == NULL); + ZEND_ASSERT(bio->biter == NULL); bio->biter = biter; } @@ -203,10 +203,10 @@ static zend_object *BreakIterator_object_create(zend_class_entry *ce) { BreakIterator_object* intern; - intern = (BreakIterator_object*)ecalloc(1, sizeof(BreakIterator_object) + sizeof(zval) * (ce->default_properties_count - 1)); + intern = (BreakIterator_object*) zend_object_alloc(sizeof(BreakIterator_object), ce); zend_object_std_init(&intern->zo, ce); - object_properties_init((zend_object*) intern, ce); + object_properties_init(&intern->zo, ce); breakiterator_object_init(intern); intern->zo.handlers = &BreakIterator_handlers; From f77200f5c6cbca064070bd0de555665d767673be Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 25 Aug 2020 16:08:33 +0300 Subject: [PATCH 077/170] Fixed JIT failure on "$a = []; $a[1] += 2;" --- ext/opcache/jit/zend_jit_x86.dasc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index 84c7c091285bf..f655c1616d423 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -5123,13 +5123,11 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o break; case BP_VAR_RW: |2: - if (op1_info & MAY_BE_ARRAY_KEY_LONG) { - |4: - | SAVE_VALID_OPLINE opline, r0 - | EXT_CALL zend_jit_hash_index_lookup_rw, r0 - | test r0, r0 - | jz >9 - } + |4: + | SAVE_VALID_OPLINE opline, r0 + | EXT_CALL zend_jit_hash_index_lookup_rw, r0 + | test r0, r0 + | jz >9 break; case BP_VAR_W: |2: From 6c8fb123d25235b08908c4d69b5056143f64e696 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Tue, 18 Aug 2020 19:20:56 +0200 Subject: [PATCH 078/170] Promote warnings to exceptions in ext/simplexml Closes GH-6011 Co-authored-by: Nikita Popov --- Zend/zend_object_handlers.h | 8 +++- ext/simplexml/simplexml.c | 38 +++++++++---------- ext/simplexml/simplexml.stub.php | 4 +- ext/simplexml/simplexml_arginfo.h | 2 +- ext/simplexml/tests/012.phpt | 22 ++++++----- ..._addAttribute_required_attribute_name.phpt | 12 ++++-- .../tests/SimpleXMLElement_xpath_4.phpt | 13 ++++--- ext/simplexml/tests/bug37076_1.phpt | 15 +++++--- ext/simplexml/tests/bug38406.phpt | 10 +++-- 9 files changed, 76 insertions(+), 48 deletions(-) diff --git a/Zend/zend_object_handlers.h b/Zend/zend_object_handlers.h index b401d72ca294a..fedc70cc80997 100644 --- a/Zend/zend_object_handlers.h +++ b/Zend/zend_object_handlers.h @@ -60,7 +60,13 @@ typedef zval *(*zend_object_write_property_t)(zend_object *object, zend_string * typedef void (*zend_object_write_dimension_t)(zend_object *object, zval *offset, zval *value); -/* Used to create pointer to the property of the object, for future direct r/w access */ +/* Used to create pointer to the property of the object, for future direct r/w access. + * May return one of: + * * A zval pointer, without incrementing the reference count. + * * &EG(error_zval), if an exception has been thrown. + * * NULL, if acquiring a direct pointer is not possible. + * In this case, the VM will fall back to using read_property and write_property. + */ typedef zval *(*zend_object_get_property_ptr_ptr_t)(zend_object *object, zend_string *member, int type, void **cache_slot); /* Used to check if a property of the object exists */ diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index f788502703b08..1944ecf797819 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -411,7 +411,7 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value, * and could also be E_PARSE, but we use this only during parsing * and this is during runtime. */ - zend_throw_error(NULL, "Cannot create unnamed attribute"); + zend_throw_error(NULL, "Cannot append to an attribute list"); return &EG(error_zval); } goto long_dim; @@ -436,7 +436,7 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value, } if (!Z_STRLEN_P(member)) { - php_error_docref(NULL, E_WARNING, "Cannot write or create unnamed %s", attribs ? "attribute" : "element"); + zend_value_error("Cannot create %s with an empty name", attribs ? "attribute" : "element"); if (member == &tmp_zv) { zval_ptr_dtor_str(&tmp_zv); } @@ -464,7 +464,7 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value, * and could also be E_PARSE, but we use this only during parsing * and this is during runtime. */ - zend_throw_error(NULL, "Cannot create unnamed attribute"); + zend_value_error("Cannot append to an attribute list"); return &EG(error_zval); } if (attribs && !node && sxe->iter.type == SXE_ITER_ELEMENT) { @@ -489,8 +489,8 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value, if (Z_OBJCE_P(value) == sxe_class_entry) { zval zval_copy; if (sxe_object_cast_ex(Z_OBJ_P(value), &zval_copy, IS_STRING) == FAILURE) { - zend_error(E_ERROR, "Unable to cast node to string"); - /* FIXME: Should not be fatal */ + zend_throw_error(NULL, "Unable to cast node to string"); + return &EG(error_zval); } value_str = Z_STR(zval_copy); @@ -501,7 +501,7 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value, if (member == &tmp_zv) { zval_ptr_dtor_str(&tmp_zv); } - zend_error(E_WARNING, "It is not yet possible to assign complex types to %s", attribs ? "attributes" : "properties"); + zend_type_error("It's not possible to assign a complex type to %s, %s given", attribs ? "attributes" : "properties", zend_zval_type_name(value)); return &EG(error_zval); } } @@ -656,7 +656,7 @@ static zval *sxe_property_get_adr(zend_object *object, zend_string *zname, int f } ZVAL_STR(&member, zname); if (sxe_prop_dim_write(object, &member, NULL, 1, 0, &node) == &EG(error_zval)) { - return NULL; + return &EG(error_zval); } type = SXE_ITER_NONE; name = NULL; @@ -1684,8 +1684,8 @@ SXE_METHOD(addChild) } if (qname_len == 0) { - php_error_docref(NULL, E_WARNING, "Element name is required"); - return; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } sxe = Z_SXEOBJ_P(ZEND_THIS); @@ -1749,8 +1749,8 @@ SXE_METHOD(addAttribute) } if (qname_len == 0) { - php_error_docref(NULL, E_WARNING, "Attribute name is required"); - return; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } sxe = Z_SXEOBJ_P(ZEND_THIS); @@ -2274,8 +2274,8 @@ PHP_FUNCTION(simplexml_load_file) } if (ZEND_LONG_EXCEEDS_INT(options)) { - php_error_docref(NULL, E_WARNING, "Invalid options"); - RETURN_FALSE; + zend_argument_value_error(3, "is too large"); + RETURN_THROWS(); } docp = xmlReadFile(filename, NULL, (int)options); @@ -2319,16 +2319,16 @@ PHP_FUNCTION(simplexml_load_string) } if (ZEND_SIZE_T_INT_OVFL(data_len)) { - php_error_docref(NULL, E_WARNING, "Data is too long"); - RETURN_FALSE; + zend_argument_value_error(1, "is too long"); + RETURN_THROWS(); } if (ZEND_SIZE_T_INT_OVFL(ns_len)) { - php_error_docref(NULL, E_WARNING, "Namespace is too long"); - RETURN_FALSE; + zend_argument_value_error(4, "is too long"); + RETURN_THROWS(); } if (ZEND_LONG_EXCEEDS_INT(options)) { - php_error_docref(NULL, E_WARNING, "Invalid options"); - RETURN_FALSE; + zend_argument_value_error(3, "is too large"); + RETURN_THROWS(); } docp = xmlReadMemory(data, (int)data_len, NULL, NULL, (int)options); diff --git a/ext/simplexml/simplexml.stub.php b/ext/simplexml/simplexml.stub.php index d3e48b0e6aaf7..18cddf2886162 100644 --- a/ext/simplexml/simplexml.stub.php +++ b/ext/simplexml/simplexml.stub.php @@ -59,7 +59,7 @@ public function rewind() {} /** @return bool */ public function valid() {} - /** @return ?SimpleXMLElement */ + /** @return SimpleXMLElement|null */ public function current() {} /** @return string|false */ @@ -71,7 +71,7 @@ public function next() {} /** @return bool */ public function hasChildren() {} - /** @return ?SimpleXMLElement */ + /** @return SimpleXMLElement|null */ public function getChildren() {} } diff --git a/ext/simplexml/simplexml_arginfo.h b/ext/simplexml/simplexml_arginfo.h index dc369e03212d8..5aa6d50ba1d03 100644 --- a/ext/simplexml/simplexml_arginfo.h +++ b/ext/simplexml/simplexml_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: fbe25d8a7a0a1de0cbd5dc9118e77a2e8d5dbd67 */ + * Stub hash: 953089f230247acf18b9ac48c0a4c516d144a987 */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_simplexml_load_file, 0, 1, SimpleXMLElement, MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) diff --git a/ext/simplexml/tests/012.phpt b/ext/simplexml/tests/012.phpt index b687b71988198..307f8219cd70e 100644 --- a/ext/simplexml/tests/012.phpt +++ b/ext/simplexml/tests/012.phpt @@ -14,8 +14,12 @@ EOF; $sxe = simplexml_load_string($xml); +try { + $sxe[""] = "value"; +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} -$sxe[""] = "warning"; $sxe["attr"] = "value"; echo $sxe->asXML(); @@ -24,19 +28,19 @@ $sxe["attr"] = "new value"; echo $sxe->asXML(); -$sxe[] = "error"; +try { + $sxe[] = "error"; +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} __HALT_COMPILER(); ?> ===DONE=== ---EXPECTF-- -Warning: main(): Cannot write or create unnamed attribute in %s012.php on line %d +--EXPECT-- +Cannot create attribute with an empty name - -Fatal error: Uncaught Error: Cannot create unnamed attribute in %s012.php:%d -Stack trace: -#0 {main} - thrown in %s012.php on line %d +Cannot append to an attribute list diff --git a/ext/simplexml/tests/SimpleXMLElement_addAttribute_required_attribute_name.phpt b/ext/simplexml/tests/SimpleXMLElement_addAttribute_required_attribute_name.phpt index 34e2e683195b0..50928ff55e553 100644 --- a/ext/simplexml/tests/SimpleXMLElement_addAttribute_required_attribute_name.phpt +++ b/ext/simplexml/tests/SimpleXMLElement_addAttribute_required_attribute_name.phpt @@ -8,10 +8,16 @@ Havard Eide --FILE-- testfest"); -$a->addAttribute( "", "" ); + +try { + $a->addAttribute( "", "" ); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + echo $a->asXML(); ?> ---EXPECTF-- -Warning: SimpleXMLElement::addAttribute(): Attribute name is required in %s on line %d +--EXPECT-- +SimpleXMLElement::addAttribute(): Argument #1 ($qualifiedName) cannot be empty testfest diff --git a/ext/simplexml/tests/SimpleXMLElement_xpath_4.phpt b/ext/simplexml/tests/SimpleXMLElement_xpath_4.phpt index b389bcfc582f0..bcff7db2db06a 100644 --- a/ext/simplexml/tests/SimpleXMLElement_xpath_4.phpt +++ b/ext/simplexml/tests/SimpleXMLElement_xpath_4.phpt @@ -7,11 +7,14 @@ if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platforms only"); ?> --FILE-- getMessage() . "\n"; +} + ?> --EXPECTF-- Warning: Undefined variable $x in %s on line %d - -Warning: simplexml_load_string(): Invalid options in %s on line %d -bool(false) +simplexml_load_string(): Argument #3 ($options) is too large diff --git a/ext/simplexml/tests/bug37076_1.phpt b/ext/simplexml/tests/bug37076_1.phpt index 019915a1b4ee5..d002c93f08562 100644 --- a/ext/simplexml/tests/bug37076_1.phpt +++ b/ext/simplexml/tests/bug37076_1.phpt @@ -4,13 +4,18 @@ Bug #37076 (SimpleXML ignores .=) (appending to unnamed attribute) --FILE-- "); -$xml->{""} .= "bar"; + +try { + $xml->{""} .= "bar"; +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + print $xml->asXML(); ?> ---EXPECTF-- -Warning: main(): Cannot write or create unnamed element in %s on line %d - -Warning: main(): Cannot write or create unnamed element in %s on line %d +--EXPECT-- +Cannot create element with an empty name diff --git a/ext/simplexml/tests/bug38406.phpt b/ext/simplexml/tests/bug38406.phpt index 51a716cbd352e..7e20c7e70447f 100644 --- a/ext/simplexml/tests/bug38406.phpt +++ b/ext/simplexml/tests/bug38406.phpt @@ -13,7 +13,12 @@ $item->otherAttribute = $item->attribute; var_dump($item->otherAttribute); $a = array(); -$item->$a = new stdclass; + +try { + $item->$a = new stdclass; +} catch (TypeError $exception) { + echo $exception->getMessage() . "\n"; +} echo "Done\n"; ?> @@ -28,6 +33,5 @@ object(SimpleXMLElement)#%d (1) { } Warning: Array to string conversion in %s on line %d - -Warning: It is not yet possible to assign complex types to properties in %s on line %d +It's not possible to assign a complex type to properties, stdClass given Done From 647fb38d587ec048a723b36bbf196fe38d341ff8 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 25 Aug 2020 15:28:58 +0200 Subject: [PATCH 079/170] Ensure RuleBasedBreakIterator constructor throws on failure Constructors must throw on failure indepdendent of the configured intl error mode. --- .../rulebasedbreakiterator_methods.cpp | 26 +++++++++---------- .../tests/breakiter___construct_error.phpt | 5 ++-- ext/intl/tests/rbbiter___construct_basic.phpt | 6 ++--- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp index 67fb2b502ea67..476873330d83b 100644 --- a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp +++ b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp @@ -52,33 +52,33 @@ static void _php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAMETERS) UParseError parseError = UParseError(); if (intl_stringFromChar(rulesStr, rules, rules_len, &status) == FAILURE) { - intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "rbbi_create_instance: rules were not a valid UTF-8 string", - 0); - RETURN_NULL(); + zend_throw_exception(IntlException_ce_ptr, + "IntlRuleBasedBreakIterator::__construct(): " + "rules were not a valid UTF-8 string", 0); + RETURN_THROWS(); } rbbi = new RuleBasedBreakIterator(rulesStr, parseError, status); intl_error_set_code(NULL, status); if (U_FAILURE(status)) { - char *msg; smart_str parse_error_str; parse_error_str = intl_parse_error_to_string(&parseError); - spprintf(&msg, 0, "rbbi_create_instance: unable to create " - "RuleBasedBreakIterator from rules (%s)", parse_error_str.s? ZSTR_VAL(parse_error_str.s) : ""); + zend_throw_exception_ex(IntlException_ce_ptr, 0, + "IntlRuleBasedBreakIterator::__construct(): " + "unable to create RuleBasedBreakIterator from rules (%s)", + parse_error_str.s ? ZSTR_VAL(parse_error_str.s) : ""); smart_str_free(&parse_error_str); - intl_error_set_custom_msg(NULL, msg, 1); - efree(msg); delete rbbi; - return; + RETURN_THROWS(); } } else { // compiled rbbi = new RuleBasedBreakIterator((uint8_t*)rules, rules_len, status); if (U_FAILURE(status)) { - intl_error_set(NULL, status, "rbbi_create_instance: unable to " - "create instance from compiled rules", 0); + zend_throw_exception(IntlException_ce_ptr, + "IntlRuleBasedBreakIterator::__construct(): " + "unable to create instance from compiled rules", 0); delete rbbi; - return; + RETURN_THROWS(); } } diff --git a/ext/intl/tests/breakiter___construct_error.phpt b/ext/intl/tests/breakiter___construct_error.phpt index a18d8d5a5d4d4..57952766ec94f 100644 --- a/ext/intl/tests/breakiter___construct_error.phpt +++ b/ext/intl/tests/breakiter___construct_error.phpt @@ -4,7 +4,6 @@ IntlRuleBasedBreakIterator::__construct(): arg errors --FILE-- getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n"; @@ -38,7 +37,7 @@ try { } ?> --EXPECTF-- -Exception: IntlRuleBasedBreakIterator::__construct(): rbbi_create_instance: unable to create RuleBasedBreakIterator from rules (parse error on line 1, offset 31) in %s on line %d +Exception: IntlRuleBasedBreakIterator::__construct(): unable to create RuleBasedBreakIterator from rules (parse error on line 1, offset 31) in %s on line %d Exception: IntlRuleBasedBreakIterator::__construct() expects at least 1 parameter, 0 given in %s on line %d @@ -46,4 +45,4 @@ Exception: IntlRuleBasedBreakIterator::__construct() expects at most 2 parameter Exception: IntlRuleBasedBreakIterator::__construct(): Argument #2 ($areCompiled) must be of type bool, array given in %s on line %d -Exception: IntlRuleBasedBreakIterator::__construct(): rbbi_create_instance: unable to create instance from compiled rules in %s on line %d +Exception: IntlRuleBasedBreakIterator::__construct(): unable to create instance from compiled rules in %s on line %d diff --git a/ext/intl/tests/rbbiter___construct_basic.phpt b/ext/intl/tests/rbbiter___construct_basic.phpt index 9f20806fa50a7..def14d25da907 100644 --- a/ext/intl/tests/rbbiter___construct_basic.phpt +++ b/ext/intl/tests/rbbiter___construct_basic.phpt @@ -6,7 +6,6 @@ if (!extension_loaded('intl')) die('skip intl extension not enabled'); --FILE-- getMessage(), "\n"; } ?> --EXPECT-- string(26) "IntlRuleBasedBreakIterator" -int(1) -string(93) "rbbi_create_instance: unable to create instance from compiled rules: U_ILLEGAL_ARGUMENT_ERROR" +IntlRuleBasedBreakIterator::__construct(): unable to create instance from compiled rules From 2369f48092a15a42731a4c1d1d8a1c770517a780 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 25 Aug 2020 18:28:23 +0300 Subject: [PATCH 080/170] Infer information about packed/hash arrays and use it for JIT --- Zend/zend_type_info.h | 15 +++- ext/opcache/Optimizer/zend_func_info.c | 4 +- ext/opcache/Optimizer/zend_inference.c | 4 +- ext/opcache/Optimizer/zend_inference.h | 3 + ext/opcache/jit/zend_jit_x86.dasc | 104 ++++++++++++++----------- 5 files changed, 75 insertions(+), 55 deletions(-) diff --git a/Zend/zend_type_info.h b/Zend/zend_type_info.h index 9dc90d142b4ed..a0fc698ebe5ee 100644 --- a/Zend/zend_type_info.h +++ b/Zend/zend_type_info.h @@ -56,11 +56,18 @@ #define MAY_BE_ARRAY_OF_ANY (MAY_BE_ANY << MAY_BE_ARRAY_SHIFT) #define MAY_BE_ARRAY_OF_REF (MAY_BE_REF << MAY_BE_ARRAY_SHIFT) -#define MAY_BE_ARRAY_KEY_LONG (1<<21) -#define MAY_BE_ARRAY_KEY_STRING (1<<22) +#define MAY_BE_ARRAY_PACKED (1<<21) +#define MAY_BE_ARRAY_HASH (1<<22) /* hash with numeric keys */ + +#define MAY_BE_ARRAY_KEY_LONG (MAY_BE_ARRAY_PACKED | MAY_BE_ARRAY_HASH) +#define MAY_BE_ARRAY_KEY_STRING (1<<23) #define MAY_BE_ARRAY_KEY_ANY (MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_KEY_STRING) -#define MAY_BE_CLASS (1<<23) -#define MAY_BE_INDIRECT (1<<24) +#define MAY_BE_CLASS (1<<24) +#define MAY_BE_INDIRECT (1<<25) + + +#define MAY_BE_ANY_ARRAY \ + (MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_ANY|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF) #endif /* ZEND_TYPE_INFO_H */ diff --git a/ext/opcache/Optimizer/zend_func_info.c b/ext/opcache/Optimizer/zend_func_info.c index 47c4af5115c45..a387942919cb6 100644 --- a/ext/opcache/Optimizer/zend_func_info.c +++ b/ext/opcache/Optimizer/zend_func_info.c @@ -64,7 +64,7 @@ static uint32_t zend_range_info(const zend_call_info *call_info, const zend_ssa uint32_t t2 = _ssa_op1_info(op_array, ssa, call_info->arg_info[1].opline, &ssa->ops[call_info->arg_info[1].opline - op_array->opcodes]); uint32_t t3 = 0; - uint32_t tmp = MAY_BE_RC1 | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG; + uint32_t tmp = MAY_BE_RC1 | MAY_BE_ARRAY | MAY_BE_ARRAY_PACKED; if (call_info->num_args == 3) { t3 = _ssa_op1_info(op_array, ssa, call_info->arg_info[2].opline, @@ -86,7 +86,7 @@ static uint32_t zend_range_info(const zend_call_info *call_info, const zend_ssa return tmp; } else { /* May throw */ - return MAY_BE_RC1 | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_DOUBLE | MAY_BE_ARRAY_OF_STRING; + return MAY_BE_RC1 | MAY_BE_ARRAY | MAY_BE_ARRAY_PACKED | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_DOUBLE | MAY_BE_ARRAY_OF_STRING; } } diff --git a/ext/opcache/Optimizer/zend_inference.c b/ext/opcache/Optimizer/zend_inference.c index ab8b751acc461..9a66c91d64cb9 100644 --- a/ext/opcache/Optimizer/zend_inference.c +++ b/ext/opcache/Optimizer/zend_inference.c @@ -2454,7 +2454,7 @@ static zend_always_inline int _zend_update_type_info( if (t1 & MAY_BE_OBJECT) { tmp |= MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF; } else { - tmp |= ((t1 & MAY_BE_ANY) << MAY_BE_ARRAY_SHIFT) | ((t1 & MAY_BE_ANY)? MAY_BE_ARRAY_KEY_LONG : 0); + tmp |= ((t1 & MAY_BE_ANY) << MAY_BE_ARRAY_SHIFT) | ((t1 & MAY_BE_ANY) ? MAY_BE_ARRAY_PACKED : 0); } } UPDATE_SSA_TYPE(tmp, ssa_op->result_def); @@ -3474,7 +3474,7 @@ static zend_always_inline int _zend_update_type_info( UPDATE_SSA_TYPE(MAY_BE_LONG, ssa_op->result_def); break; case ZEND_FUNC_GET_ARGS: - UPDATE_SSA_TYPE(MAY_BE_RC1|MAY_BE_RCN| MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ANY, ssa_op->result_def); + UPDATE_SSA_TYPE(MAY_BE_RC1|MAY_BE_RCN| MAY_BE_ARRAY | MAY_BE_ARRAY_PACKED | MAY_BE_ARRAY_OF_ANY, ssa_op->result_def); break; case ZEND_GET_CLASS: case ZEND_GET_CALLED_CLASS: diff --git a/ext/opcache/Optimizer/zend_inference.h b/ext/opcache/Optimizer/zend_inference.h index 0708d5df94516..e4c8598ce41ea 100644 --- a/ext/opcache/Optimizer/zend_inference.h +++ b/ext/opcache/Optimizer/zend_inference.h @@ -178,6 +178,9 @@ static zend_always_inline uint32_t _const_op_type(const zval *zv) { } tmp |= 1 << (Z_TYPE_P(val) + MAY_BE_ARRAY_SHIFT); } ZEND_HASH_FOREACH_END(); + if (HT_IS_PACKED(ht)) { + tmp &= ~MAY_BE_ARRAY_HASH; + } return tmp; } else { uint32_t tmp = (1 << Z_TYPE_P(zv)); diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index f655c1616d423..f761c851bf6a3 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -4947,21 +4947,26 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o } if (op2_info & MAY_BE_LONG) { + zend_bool op2_loaded = 0; + if (op2_info & ((MAY_BE_ANY|MAY_BE_UNDEF) - MAY_BE_LONG)) { | // if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) | IF_NOT_ZVAL_TYPE op2_addr, IS_LONG, >3 } - if (type == BP_VAR_W || type == BP_VAR_RW) { + if (type == BP_VAR_W) { | // hval = Z_LVAL_P(dim); | GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr + op2_loaded = 1; } - if (op1_info & MAY_BE_ARRAY_KEY_LONG) { + if ((op1_info & MAY_BE_ARRAY_KEY_LONG) && (op1_info & MAY_BE_ARRAY_PACKED)) { if (Z_MODE(op2_addr) == IS_CONST_ZVAL) { zend_long val = Z_LVAL_P(Z_ZV(op2_addr)); if (val >= 0 && val < HT_MAX_SIZE) { | // ZEND_HASH_INDEX_FIND(ht, hval, retval, num_undef); - | test dword [FCARG1a + offsetof(zend_array, u.flags)], HASH_FLAG_PACKED - | jz >4 // HASH_FIND + if (op1_info & MAY_BE_ARRAY_HASH) { + | test dword [FCARG1a + offsetof(zend_array, u.flags)], HASH_FLAG_PACKED + | jz >4 // HASH_FIND + } | // if (EXPECTED((zend_ulong)(_h) < (zend_ulong)(_ht)->nNumUsed)) |.if X64 | movsxd r0, dword [FCARG1a + offsetof(zend_array, nNumUsed)] @@ -4998,13 +5003,16 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o } } } else { - if (type != BP_VAR_W && type != BP_VAR_RW) { + if (!op2_loaded) { | // hval = Z_LVAL_P(dim); | GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr + op2_loaded = 1; } | // ZEND_HASH_INDEX_FIND(ht, hval, retval, num_undef); - | test dword [FCARG1a + offsetof(zend_array, u.flags)], HASH_FLAG_PACKED - | jz >4 // HASH_FIND + if (op1_info & MAY_BE_ARRAY_HASH) { + | test dword [FCARG1a + offsetof(zend_array, u.flags)], HASH_FLAG_PACKED + | jz >4 // HASH_FIND + } | // if (EXPECTED((zend_ulong)(_h) < (zend_ulong)(_ht)->nNumUsed)) |.if X64 | movsxd r0, dword [FCARG1a + offsetof(zend_array, nNumUsed)] @@ -5042,60 +5050,58 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o } switch (type) { case BP_JIT_IS: - if (op1_info & MAY_BE_ARRAY_KEY_LONG) { + if ((op1_info & MAY_BE_ARRAY_KEY_LONG) && (op1_info & MAY_BE_ARRAY_HASH)) { |4: - } - if (Z_MODE(op2_addr) == IS_CONST_ZVAL) { - | // hval = Z_LVAL_P(dim); - | GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr - } - | EXT_CALL _zend_hash_index_find, r0 - | test r0, r0 - if (not_found_exit_addr) { - | jz ¬_found_exit_addr + if (!op2_loaded) { + | // hval = Z_LVAL_P(dim); + | GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr + } + | EXT_CALL _zend_hash_index_find, r0 + | test r0, r0 + if (not_found_exit_addr) { + | jz ¬_found_exit_addr + } else { + | jz >9 // NOT_FOUND + } + if (op2_info & MAY_BE_STRING) { + | jmp >5 + } + } else if (not_found_exit_addr) { + | jmp ¬_found_exit_addr } else { - | jz >9 // NOT_FOUND - } - if (op2_info & MAY_BE_STRING) { - | jmp >5 + | jmp >9 // NOT_FOUND } break; case BP_VAR_R: case BP_VAR_IS: case BP_VAR_UNSET: - if (op1_info & MAY_BE_ARRAY_KEY_LONG) { - if (Z_MODE(op2_addr) == IS_CONST_ZVAL) { - zend_long val = Z_LVAL_P(Z_ZV(op2_addr)); - if (val >= 0 && val < HT_MAX_SIZE) { - if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE && type == BP_VAR_R) { - | jmp &exit_addr - } else if (type == BP_VAR_IS && not_found_exit_addr) { - | jmp ¬_found_exit_addr - } else { - | jmp >2 // NOT_FOUND - } - } - } else if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE && type == BP_VAR_R) { + if (!(op1_info & MAY_BE_ARRAY_KEY_LONG) || + !(op1_info & MAY_BE_ARRAY_HASH) || + Z_MODE(op2_addr) != IS_CONST_ZVAL || + (Z_LVAL_P(Z_ZV(op2_addr)) >= 0 && Z_LVAL_P(Z_ZV(op2_addr)) < HT_MAX_SIZE)) { + if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE && type == BP_VAR_R) { | jmp &exit_addr } else if (type == BP_VAR_IS && not_found_exit_addr) { | jmp ¬_found_exit_addr } else { | jmp >2 // NOT_FOUND } - |4: } - if (Z_MODE(op2_addr) == IS_CONST_ZVAL) { - | // hval = Z_LVAL_P(dim); - | GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr - } - | EXT_CALL _zend_hash_index_find, r0 - | test r0, r0 - if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE && type == BP_VAR_R) { - | jz &exit_addr - } else if (type == BP_VAR_IS && not_found_exit_addr) { - | jz ¬_found_exit_addr - } else { - | jz >2 // NOT_FOUND + if ((op1_info & MAY_BE_ARRAY_KEY_LONG) && (op1_info & MAY_BE_ARRAY_HASH)) { + |4: + if (!op2_loaded) { + | // hval = Z_LVAL_P(dim); + | GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr + } + | EXT_CALL _zend_hash_index_find, r0 + | test r0, r0 + if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE && type == BP_VAR_R) { + | jz &exit_addr + } else if (type == BP_VAR_IS && not_found_exit_addr) { + | jz ¬_found_exit_addr + } else { + | jz >2 // NOT_FOUND + } } |.cold_code |2: @@ -5124,6 +5130,10 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o case BP_VAR_RW: |2: |4: + if (!op2_loaded) { + | // hval = Z_LVAL_P(dim); + | GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr + } | SAVE_VALID_OPLINE opline, r0 | EXT_CALL zend_jit_hash_index_lookup_rw, r0 | test r0, r0 From ea87d0480fbfcdd1610bb56e680f64840b233b0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Tue, 25 Aug 2020 18:06:07 +0200 Subject: [PATCH 081/170] Promote warnings to exceptions in ext/pcre Closes GH-6006 --- ext/pcre/php_pcre.c | 8 +++----- ext/pcre/tests/002.phpt | 9 ++++++--- ext/pcre/tests/preg_replace_callback_array2.phpt | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index acaeb19dc68ca..801d19fc4f9a9 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -1193,8 +1193,8 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, zend_string *subject_str, } if ((global && (subpats_order < PREG_PATTERN_ORDER || subpats_order > PREG_SET_ORDER)) || (!global && subpats_order != 0)) { - php_error_docref(NULL, E_WARNING, "Invalid flags specified"); - return; + zend_argument_value_error(4, "must be a PREG_* constant"); + RETURN_THROWS(); } } else { offset_capture = 0; @@ -2410,9 +2410,7 @@ PHP_FUNCTION(preg_replace_callback_array) } if (!zend_is_callable_ex(replace, NULL, 0, NULL, &fcc, NULL)) { - zend_string *callback_name = zend_get_callable_name(replace); - zend_type_error("'%s' is not a valid callback", ZSTR_VAL(callback_name)); - zend_string_release_ex(callback_name, 0); + zend_argument_type_error(1, "must contain only valid callbacks"); RETURN_THROWS(); } diff --git a/ext/pcre/tests/002.phpt b/ext/pcre/tests/002.phpt index 073a7a8d566ef..641cffb05e971 100644 --- a/ext/pcre/tests/002.phpt +++ b/ext/pcre/tests/002.phpt @@ -3,7 +3,11 @@ preg_* with bogus vals --FILE-- getMessage() . "\n"; +} var_dump(preg_quote('')); @@ -13,8 +17,7 @@ var_dump(preg_replace('/(.)/e', 'for ($', 'abc')); ?> --EXPECTF-- -Warning: preg_match_all(): Invalid flags specified in %s002.php on line %d -NULL +preg_match_all(): Argument #4 ($flags) must be a PREG_* constant string(0) "" string(12) "a${1b${1c${1" diff --git a/ext/pcre/tests/preg_replace_callback_array2.phpt b/ext/pcre/tests/preg_replace_callback_array2.phpt index 679a4b0c54ec2..aca11dc19c6f5 100644 --- a/ext/pcre/tests/preg_replace_callback_array2.phpt +++ b/ext/pcre/tests/preg_replace_callback_array2.phpt @@ -30,7 +30,7 @@ try { echo "Done\n"; ?> --EXPECTF-- -'s' is not a valid callback +preg_replace_callback_array(): Argument #1 ($pattern) must contain only valid callbacks string(0) "" Warning: preg_replace_callback_array(): No ending delimiter '/' found in %spreg_replace_callback_array2.php on line %d From e86b5c872d02bff543f5ab3324282a72d4d8cd28 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 25 Aug 2020 19:39:42 +0300 Subject: [PATCH 082/170] Record information about packed arrays --- ext/opcache/jit/zend_jit_internal.h | 1 + ext/opcache/jit/zend_jit_trace.c | 10 ++++++++-- ext/opcache/jit/zend_jit_vm_helpers.c | 8 ++++++-- ext/opcache/jit/zend_jit_x86.dasc | 10 +++++++--- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/ext/opcache/jit/zend_jit_internal.h b/ext/opcache/jit/zend_jit_internal.h index b40553b03dbde..975a218e8063f 100644 --- a/ext/opcache/jit/zend_jit_internal.h +++ b/ext/opcache/jit/zend_jit_internal.h @@ -245,6 +245,7 @@ typedef enum _zend_jit_trace_op { } zend_jit_trace_op; #define IS_UNKNOWN 255 /* may be used for zend_jit_trace_rec.op?_type */ +#define IS_TRACE_PACKED (1<<4) #define IS_TRACE_REFERENCE (1<<5) #define IS_TRACE_INDIRECT (1<<6) diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index 9e40661b0c617..46d84bfa4e25d 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -1368,6 +1368,9 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin if (op1_type & (IS_TRACE_REFERENCE|IS_TRACE_INDIRECT)) { op1_type = IS_UNKNOWN; } + if (op1_type != IS_UNKNOWN) { + op1_type &= ~IS_TRACE_PACKED; + } if (op2_type & (IS_TRACE_REFERENCE|IS_TRACE_INDIRECT)) { op2_type = IS_UNKNOWN; } @@ -3122,6 +3125,9 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if (op1_type & (IS_TRACE_REFERENCE|IS_TRACE_INDIRECT)) { op1_type = IS_UNKNOWN; } + if (op1_type != IS_UNKNOWN) { + op1_type &= ~IS_TRACE_PACKED; + } if (op2_type & (IS_TRACE_REFERENCE|IS_TRACE_INDIRECT)) { op2_type = IS_UNKNOWN; } @@ -5134,8 +5140,8 @@ static void zend_jit_dump_trace(zend_jit_trace_rec *trace_buffer, zend_ssa *tssa fprintf(stderr, " op1(%sobject of class %s)", ref, ZSTR_VAL(p->ce->name)); } else { - const char *type = (op1_type == 0) ? "undef" : zend_get_type_by_const(op1_type & ~(IS_TRACE_REFERENCE|IS_TRACE_INDIRECT)); - fprintf(stderr, " op1(%s%s)", ref, type); + const char *type = (op1_type == 0) ? "undef" : zend_get_type_by_const(op1_type & ~(IS_TRACE_REFERENCE|IS_TRACE_INDIRECT|IS_TRACE_PACKED)); + fprintf(stderr, " op1(%s%s%s)", ref, (op1_type & IS_TRACE_PACKED) ? "packed " : "", type); } } if (op2_type != IS_UNKNOWN) { diff --git a/ext/opcache/jit/zend_jit_vm_helpers.c b/ext/opcache/jit/zend_jit_vm_helpers.c index f7704b72a40ff..dca5f97f04b42 100644 --- a/ext/opcache/jit/zend_jit_vm_helpers.c +++ b/ext/opcache/jit/zend_jit_vm_helpers.c @@ -659,10 +659,14 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex, op1_type = Z_TYPE_P(zv); flags |= IS_TRACE_REFERENCE; } - op1_type |= flags; if (Z_TYPE_P(zv) == IS_OBJECT) { ce1 = Z_OBJCE_P(zv); + } else if (Z_TYPE_P(zv) == IS_ARRAY) { + if (HT_IS_PACKED(Z_ARRVAL_P(zv))) { + flags |= IS_TRACE_PACKED; + } } + op1_type |= flags; } if (opline->op2_type & (IS_TMP_VAR|IS_VAR|IS_CV) && opline->opcode != ZEND_INSTANCEOF @@ -684,10 +688,10 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex, op2_type = Z_TYPE_P(zv); flags |= IS_TRACE_REFERENCE; } - op2_type |= flags; if (Z_TYPE_P(zv) == IS_OBJECT) { ce2 = Z_OBJCE_P(zv); } + op2_type |= flags; } if (opline->opcode == ZEND_ASSIGN_DIM || opline->opcode == ZEND_ASSIGN_OBJ || diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index f761c851bf6a3..6fc18bdd3d393 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -12354,7 +12354,9 @@ static zend_bool zend_jit_fetch_reference(dasm_State **Dst, const zend_op *oplin var_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, offsetof(zend_reference, val)); *var_addr_ptr = var_addr; - var_type &= ~(IS_TRACE_REFERENCE|IS_TRACE_INDIRECT); + if (var_type != IS_UNKNOWN) { + var_type &= ~(IS_TRACE_REFERENCE|IS_TRACE_INDIRECT|IS_TRACE_PACKED); + } if (add_type_guard && var_type != IS_UNKNOWN && (var_info & (MAY_BE_ANY|MAY_BE_UNDEF)) != (1 << var_type)) { @@ -12394,7 +12396,9 @@ static zend_bool zend_jit_fetch_indirect_var(dasm_State **Dst, const zend_op *op var_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, 0); *var_addr_ptr = var_addr; - var_type &= ~IS_TRACE_INDIRECT; + if (var_type != IS_UNKNOWN) { + var_type &= ~(IS_TRACE_INDIRECT|IS_TRACE_PACKED); + } if (!(var_type & IS_TRACE_REFERENCE) && var_type != IS_UNKNOWN && (var_info & (MAY_BE_ANY|MAY_BE_UNDEF)) != (1 << var_type)) { @@ -12514,7 +12518,7 @@ static zend_bool zend_jit_opline_supports_reg(const zend_op_array *op_array, zen op2_info = OP2_INFO(); if (trace && trace->op1_type != IS_UNKNOWN - && (trace->op1_type & ~(IS_TRACE_REFERENCE|IS_TRACE_INDIRECT)) == IS_ARRAY) { + && (trace->op1_type & ~(IS_TRACE_REFERENCE|IS_TRACE_INDIRECT|IS_TRACE_PACKED)) == IS_ARRAY) { op1_info &= ~((MAY_BE_ANY|MAY_BE_UNDEF) - MAY_BE_ARRAY); } return ((op1_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY) && From 571f6a598f315d163fa172aaf3c7bfb53a5eceb8 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 25 Aug 2020 20:25:07 +0200 Subject: [PATCH 083/170] Don't enable --with-mm in CI Turns out this has a large negative effect on startup time, making tests much slower. --- azure-pipelines.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index acdf32204ba64..688d36c148545 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -12,11 +12,10 @@ trigger: - UPGRADING.INTERNALS jobs: - # We specify --with-mm here, because it cannot be used together with --enable-maintainer-zts. - template: azure/job.yml parameters: configurationName: DEBUG_NTS - configurationParameters: '--enable-debug --disable-maintainer-zts --with-mm' + configurationParameters: '--enable-debug --disable-maintainer-zts' - template: azure/job.yml parameters: configurationName: RELEASE_ZTS @@ -37,7 +36,7 @@ jobs: - template: azure/job.yml parameters: configurationName: RELEASE_NTS - configurationParameters: '--disable-debug --disable-maintainer-zts --with-mm' + configurationParameters: '--disable-debug --disable-maintainer-zts' - template: azure/i386/job.yml parameters: configurationName: I386_DEBUG_NTS From e99954492e319fd3e09b7376767273fbc50aa05b Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 25 Aug 2020 21:38:23 +0300 Subject: [PATCH 084/170] Avoid priniting "array [long, string] of" --- ext/opcache/Optimizer/zend_dump.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/opcache/Optimizer/zend_dump.c b/ext/opcache/Optimizer/zend_dump.c index 51dcc2076cf43..f6d9bd519a505 100644 --- a/ext/opcache/Optimizer/zend_dump.c +++ b/ext/opcache/Optimizer/zend_dump.c @@ -234,7 +234,8 @@ static void zend_dump_type_info(uint32_t info, zend_class_entry *ce, int is_inst if (first) first = 0; else fprintf(stderr, ", "); fprintf(stderr, "array"); if ((info & MAY_BE_ARRAY_KEY_ANY) != 0 && - (info & MAY_BE_ARRAY_KEY_ANY) != MAY_BE_ARRAY_KEY_ANY) { + ((info & MAY_BE_ARRAY_KEY_LONG) == 0 || + (info & MAY_BE_ARRAY_KEY_STRING) == 0)) { int afirst = 1; fprintf(stderr, " ["); if (info & MAY_BE_ARRAY_KEY_LONG) { From 5948a6674a8a338c6834bc0a53d49ce0d91810af Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 26 Aug 2020 01:07:34 +0300 Subject: [PATCH 085/170] Prevent negative array index access --- ext/opcache/jit/zend_jit_trace.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index 3d6a7dd07cd19..483b94c4766a3 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -4020,8 +4020,11 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par op2_info = OP2_INFO(); CHECK_OP2_TRACE_TYPE(); res_info = RES_INFO(); + avoid_refcounting = + ssa_op->op1_use >= 0 && + ssa->var_info[ssa_op->op1_use].avoid_refcounting; if (!zend_jit_fetch_dim_read(&dasm_state, opline, ssa, ssa_op, - op1_info, op1_addr, ssa->var_info[ssa_op->op1_use].avoid_refcounting, + op1_info, op1_addr, avoid_refcounting, op2_info, res_info, RES_REG_ADDR(), ( (op1_info & MAY_BE_ANY) != MAY_BE_ARRAY || @@ -4063,7 +4066,8 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if (ra) { zend_jit_trace_clenup_stack(stack, opline, ssa_op, ssa, ra); } - if (ssa->var_info[ssa_op->op1_use].avoid_refcounting) { + if (ssa_op->op1_use >= 0 + && ssa->var_info[ssa_op->op1_use].avoid_refcounting) { /* Temporary reset ZREG_ZVAL_TRY_ADDREF */ zend_jit_trace_stack *stack = JIT_G(current_frame)->stack; uint32_t old_info = STACK_INFO(stack, EX_VAR_TO_NUM(opline->op1.var)); @@ -4083,8 +4087,11 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par smart_branch_opcode = 0; exit_addr = NULL; } + avoid_refcounting = + ssa_op->op1_use >= 0 && + ssa->var_info[ssa_op->op1_use].avoid_refcounting; if (!zend_jit_isset_isempty_dim(&dasm_state, opline, - op1_info, op1_addr, ssa->var_info[ssa_op->op1_use].avoid_refcounting, + op1_info, op1_addr, avoid_refcounting, op2_info, zend_may_throw_ex(opline, ssa_op, op_array, ssa, op1_info, op2_info), smart_branch_opcode, -1, -1, From d4383be6fab1505cf8dac09d487a321fee128b39 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 26 Aug 2020 02:34:31 +0300 Subject: [PATCH 086/170] Use guard to check if array is packed or hash --- ext/opcache/Optimizer/zend_inference.h | 1 + ext/opcache/jit/zend_jit_internal.h | 1 + ext/opcache/jit/zend_jit_trace.c | 52 ++++++++++++++-- ext/opcache/jit/zend_jit_x86.dasc | 83 +++++++++++++++++++------- 4 files changed, 113 insertions(+), 24 deletions(-) diff --git a/ext/opcache/Optimizer/zend_inference.h b/ext/opcache/Optimizer/zend_inference.h index e4c8598ce41ea..2bd120c882fbe 100644 --- a/ext/opcache/Optimizer/zend_inference.h +++ b/ext/opcache/Optimizer/zend_inference.h @@ -26,6 +26,7 @@ /* Bitmask for type inference (zend_ssa_var_info.type) */ #include "zend_type_info.h" +#define MAY_BE_PACKED_GUARD (1<<27) /* needs packed array guard */ #define MAY_BE_CLASS_GUARD (1<<27) /* needs class guard */ #define MAY_BE_GUARD (1<<28) /* needs type guard */ #define MAY_BE_IN_REG (1<<29) /* value allocated in CPU register */ diff --git a/ext/opcache/jit/zend_jit_internal.h b/ext/opcache/jit/zend_jit_internal.h index 975a218e8063f..0254c0daf8af7 100644 --- a/ext/opcache/jit/zend_jit_internal.h +++ b/ext/opcache/jit/zend_jit_internal.h @@ -210,6 +210,7 @@ typedef enum _zend_jit_trace_stop { #define ZEND_JIT_EXIT_POLYMORPHISM (1<<4) /* exit because of polymorphic call */ #define ZEND_JIT_EXIT_FREE_OP1 (1<<5) #define ZEND_JIT_EXIT_FREE_OP2 (1<<6) +#define ZEND_JIT_EXIT_PACKED_GUARD (1<<7) typedef union _zend_op_trace_info { zend_op dummy; /* the size of this structure must be the same as zend_op */ diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index 483b94c4766a3..2d9585e23f655 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -1358,12 +1358,12 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin level = 0; for (;;p++) { if (p->op == ZEND_JIT_TRACE_VM) { - uint8_t op1_type, op2_type, op3_type; + uint8_t orig_op1_type, op1_type, op2_type, op3_type; // TODO: range inference ??? opline = p->opline; - op1_type = p->op1_type; + op1_type = orig_op1_type = p->op1_type; op2_type = p->op2_type; op3_type = p->op3_type; if (op1_type & (IS_TRACE_REFERENCE|IS_TRACE_INDIRECT)) { @@ -1425,8 +1425,6 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin case ZEND_IS_IDENTICAL: case ZEND_IS_NOT_IDENTICAL: case ZEND_CASE_STRICT: - case ZEND_FETCH_DIM_R: - case ZEND_FETCH_DIM_IS: case ZEND_BW_OR: case ZEND_BW_AND: case ZEND_BW_XOR: @@ -1505,8 +1503,38 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin // TODO: support for empty() ??? break; } + /* break missing intentionally */ + case ZEND_FETCH_DIM_R: + case ZEND_FETCH_DIM_IS: ADD_OP1_TRACE_GUARD(); ADD_OP2_TRACE_GUARD(); + + if (opline->op1_type != IS_CONST + && op1_type == IS_ARRAY + && ((opline->op2_type == IS_CONST + && Z_TYPE_P(RT_CONSTANT(opline, opline->op2)) == IS_LONG) + || (opline->op2_type != IS_CONST + && op2_type == IS_LONG))) { + + zend_ssa_var_info *info = &tssa->var_info[tssa->ops[idx].op1_use]; + + if ((info->type & MAY_BE_ARRAY_PACKED) + && (info->type & MAY_BE_ARRAY_HASH) + && orig_op1_type != IS_UNKNOWN + && !(orig_op1_type & IS_TRACE_REFERENCE)) { + /* setup "packed" guards only for loop invariant or reused variables */ + if ((trace_buffer->stop == ZEND_JIT_TRACE_STOP_LOOP + && tssa->ops[idx].op1_use < trace_buffer->op_array->last_var) + || tssa->ops[idx].op1_use_chain >= 0) { + info->type |= MAY_BE_PACKED_GUARD; + if (orig_op1_type & IS_TRACE_PACKED) { + info->type &= ~MAY_BE_ARRAY_HASH; + } else { + info->type &= ~MAY_BE_ARRAY_PACKED; + } + } + } + } break; case ZEND_SEND_VAL_EX: case ZEND_SEND_VAR_EX: @@ -3023,6 +3051,16 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par } else { SET_STACK_TYPE(stack, i, IS_UNKNOWN); } + + if ((info & MAY_BE_PACKED_GUARD) != 0 + && trace_buffer->stop == ZEND_JIT_TRACE_STOP_LOOP + && ssa->vars[i].use_chain != -1) { + if (!zend_jit_packed_guard(&dasm_state, opline, EX_NUM_TO_VAR(i), info)) { + goto jit_failure; + } + info &= ~MAY_BE_PACKED_GUARD; + ssa->var_info[i].type = info; + } } if (parent_trace) { @@ -4023,6 +4061,9 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par avoid_refcounting = ssa_op->op1_use >= 0 && ssa->var_info[ssa_op->op1_use].avoid_refcounting; + if (op1_info & MAY_BE_PACKED_GUARD) { + ssa->var_info[ssa_op->op1_use].type &= ~MAY_BE_PACKED_GUARD; + } if (!zend_jit_fetch_dim_read(&dasm_state, opline, ssa, ssa_op, op1_info, op1_addr, avoid_refcounting, op2_info, res_info, RES_REG_ADDR(), @@ -4090,6 +4131,9 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par avoid_refcounting = ssa_op->op1_use >= 0 && ssa->var_info[ssa_op->op1_use].avoid_refcounting; + if (op1_info & MAY_BE_PACKED_GUARD) { + ssa->var_info[ssa_op->op1_use].type &= ~MAY_BE_PACKED_GUARD; + } if (!zend_jit_isset_isempty_dim(&dasm_state, opline, op1_info, op1_addr, avoid_refcounting, op2_info, diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index 812d1f5f569a6..75f34d8888434 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -3234,6 +3234,27 @@ static int zend_jit_type_guard(dasm_State **Dst, const zend_op *opline, uint32_t return 1; } +static int zend_jit_packed_guard(dasm_State **Dst, const zend_op *opline, uint32_t var, uint32_t op_info) +{ + int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_PACKED_GUARD); + const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); + + if (!exit_addr) { + return 0; + } + + | GET_ZVAL_LVAL ZREG_FCARG1a, ZEND_ADDR_MEM_ZVAL(ZREG_FP, var) + if (op_info & MAY_BE_ARRAY_PACKED) { + | test dword [FCARG1a + offsetof(zend_array, u.flags)], HASH_FLAG_PACKED + | jz &exit_addr + } else { + | test dword [FCARG1a + offsetof(zend_array, u.flags)], HASH_FLAG_PACKED + | jnz &exit_addr + } + + return 1; +} + static int zend_jit_trace_handler(dasm_State **Dst, const zend_op_array *op_array, const zend_op *opline, int may_throw, zend_jit_trace_rec *trace) { zend_jit_op_array_trace_extension *jit_extension = @@ -4953,12 +4974,27 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o | // if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) | IF_NOT_ZVAL_TYPE op2_addr, IS_LONG, >3 } + if (op1_info & MAY_BE_PACKED_GUARD) { + int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_PACKED_GUARD); + const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); + + if (!exit_addr) { + return 0; + } + if (op1_info & MAY_BE_ARRAY_PACKED) { + | test dword [FCARG1a + offsetof(zend_array, u.flags)], HASH_FLAG_PACKED + | jz &exit_addr + } else { + | test dword [FCARG1a + offsetof(zend_array, u.flags)], HASH_FLAG_PACKED + | jnz &exit_addr + } + } if (type == BP_VAR_W) { | // hval = Z_LVAL_P(dim); | GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr op2_loaded = 1; } - if ((op1_info & MAY_BE_ARRAY_KEY_LONG) && (op1_info & MAY_BE_ARRAY_PACKED)) { + if (op1_info & MAY_BE_ARRAY_PACKED) { if (Z_MODE(op2_addr) == IS_CONST_ZVAL) { zend_long val = Z_LVAL_P(Z_ZV(op2_addr)); if (val >= 0 && val < HT_MAX_SIZE) { @@ -5050,7 +5086,7 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o } switch (type) { case BP_JIT_IS: - if ((op1_info & MAY_BE_ARRAY_KEY_LONG) && (op1_info & MAY_BE_ARRAY_HASH)) { + if (op1_info & MAY_BE_ARRAY_HASH) { |4: if (!op2_loaded) { | // hval = Z_LVAL_P(dim); @@ -5076,9 +5112,9 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o case BP_VAR_IS: case BP_VAR_UNSET: if (!(op1_info & MAY_BE_ARRAY_KEY_LONG) || - !(op1_info & MAY_BE_ARRAY_HASH) || - Z_MODE(op2_addr) != IS_CONST_ZVAL || - (Z_LVAL_P(Z_ZV(op2_addr)) >= 0 && Z_LVAL_P(Z_ZV(op2_addr)) < HT_MAX_SIZE)) { + ((op1_info & MAY_BE_ARRAY_PACKED) && + (Z_MODE(op2_addr) != IS_CONST_ZVAL || + (Z_LVAL_P(Z_ZV(op2_addr)) >= 0 && Z_LVAL_P(Z_ZV(op2_addr)) < HT_MAX_SIZE)))) { if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE && type == BP_VAR_R) { | jmp &exit_addr } else if (type == BP_VAR_IS && not_found_exit_addr) { @@ -5087,7 +5123,7 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o | jmp >2 // NOT_FOUND } } - if ((op1_info & MAY_BE_ARRAY_KEY_LONG) && (op1_info & MAY_BE_ARRAY_HASH)) { + if (op1_info & MAY_BE_ARRAY_HASH) { |4: if (!op2_loaded) { | // hval = Z_LVAL_P(dim); @@ -5140,20 +5176,27 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o | jz >9 break; case BP_VAR_W: - |2: - | //retval = zend_hash_index_add_new(ht, hval, &EG(uninitialized_zval)); - |.if X64 - | LOAD_ADDR_ZTS CARG3, executor_globals, uninitialized_zval - |.else - | sub r4, 12 - | PUSH_ADDR_ZTS executor_globals, uninitialized_zval, r0 - |.endif - | EXT_CALL zend_hash_index_add_new, r0 - |.if not(X64) - | add r4, 12 - |.endif - if (op1_info & MAY_BE_ARRAY_KEY_LONG) { - | jmp >8 + if (!(op1_info & MAY_BE_ARRAY_KEY_LONG) || + ((op1_info & MAY_BE_ARRAY_PACKED) && + (Z_MODE(op2_addr) != IS_CONST_ZVAL || + (Z_LVAL_P(Z_ZV(op2_addr)) >= 0 && Z_LVAL_P(Z_ZV(op2_addr)) < HT_MAX_SIZE)))) { + |2: + | //retval = zend_hash_index_add_new(ht, hval, &EG(uninitialized_zval)); + |.if X64 + | LOAD_ADDR_ZTS CARG3, executor_globals, uninitialized_zval + |.else + | sub r4, 12 + | PUSH_ADDR_ZTS executor_globals, uninitialized_zval, r0 + |.endif + | EXT_CALL zend_hash_index_add_new, r0 + |.if not(X64) + | add r4, 12 + |.endif + if (op1_info & MAY_BE_ARRAY_HASH) { + | jmp >8 + } + } + if (op1_info & MAY_BE_ARRAY_HASH) { |4: | EXT_CALL zend_jit_hash_index_lookup_w, r0 } From f6e5cc3391244d52267e8c3a69d3180279afea4f Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 26 Aug 2020 10:03:11 +0200 Subject: [PATCH 087/170] Prevent double-construction of IntlRuleBasedBreakIterator --- .../breakiterator/rulebasedbreakiterator_methods.cpp | 9 ++++++++- ext/intl/tests/breakiter___construct_error.phpt | 9 +++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp index 476873330d83b..f17733da24351 100644 --- a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp +++ b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp @@ -37,13 +37,20 @@ static void _php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAMETERS) size_t rules_len; zend_bool compiled = 0; UErrorCode status = U_ZERO_ERROR; - intl_error_reset(NULL); + BREAKITER_METHOD_INIT_VARS; + object = ZEND_THIS; if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &rules, &rules_len, &compiled) == FAILURE) { RETURN_THROWS(); } + BREAKITER_METHOD_FETCH_OBJECT_NO_CHECK; + if (bio->biter) { + zend_throw_error(NULL, "IntlRuleBasedBreakIterator object is already constructed"); + RETURN_THROWS(); + } + // instantiation of ICU object RuleBasedBreakIterator *rbbi; diff --git a/ext/intl/tests/breakiter___construct_error.phpt b/ext/intl/tests/breakiter___construct_error.phpt index 57952766ec94f..7272d8c16b71c 100644 --- a/ext/intl/tests/breakiter___construct_error.phpt +++ b/ext/intl/tests/breakiter___construct_error.phpt @@ -35,6 +35,13 @@ try { } catch (IntlException $e) { print_exception($e); } + +$rbbi = new IntlRuleBasedBreakIterator(".;"); +try { + $rbbi->__construct(".;"); +} catch (Error $e) { + print_exception($e); +} ?> --EXPECTF-- Exception: IntlRuleBasedBreakIterator::__construct(): unable to create RuleBasedBreakIterator from rules (parse error on line 1, offset 31) in %s on line %d @@ -46,3 +53,5 @@ Exception: IntlRuleBasedBreakIterator::__construct() expects at most 2 parameter Exception: IntlRuleBasedBreakIterator::__construct(): Argument #2 ($areCompiled) must be of type bool, array given in %s on line %d Exception: IntlRuleBasedBreakIterator::__construct(): unable to create instance from compiled rules in %s on line %d + +Exception: IntlRuleBasedBreakIterator object is already constructed in %s on line %d From 72eaf509d3e56d3f4310243141f6df1aa4ae3427 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 26 Aug 2020 10:10:41 +0200 Subject: [PATCH 088/170] Prevent double-construction of IntlGregorianCalendar --- ext/intl/calendar/gregoriancalendar_methods.cpp | 9 +++++++-- ext/intl/tests/gregoriancalendar___construct_error.phpt | 8 ++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ext/intl/calendar/gregoriancalendar_methods.cpp b/ext/intl/calendar/gregoriancalendar_methods.cpp index 84d594185c46f..64b753978928a 100644 --- a/ext/intl/calendar/gregoriancalendar_methods.cpp +++ b/ext/intl/calendar/gregoriancalendar_methods.cpp @@ -85,8 +85,14 @@ static void _php_intlgregcal_constructor_body( } // instantion of ICU object + Calendar_object *co = Z_INTL_CALENDAR_P(return_value); GregorianCalendar *gcal = NULL; + if (co->ucal) { + zend_throw_error(NULL, "IntlGregorianCalendar object is already constructed"); + RETURN_THROWS(); + } + if (variant <= 2) { // From timezone and locale (0 to 2 arguments) TimeZone *tz = timezone_process_timezone_argument(tz_object, NULL, @@ -174,8 +180,7 @@ static void _php_intlgregcal_constructor_body( gcal->adoptTimeZone(tz); } - Calendar_object *co = Z_INTL_CALENDAR_P(return_value); - co->ucal = gcal; + co->ucal = gcal; } U_CFUNC PHP_FUNCTION(intlgregcal_create_instance) diff --git a/ext/intl/tests/gregoriancalendar___construct_error.phpt b/ext/intl/tests/gregoriancalendar___construct_error.phpt index 7e5ce659bf68a..92a7e5c30436c 100644 --- a/ext/intl/tests/gregoriancalendar___construct_error.phpt +++ b/ext/intl/tests/gregoriancalendar___construct_error.phpt @@ -33,6 +33,13 @@ try { } catch (TypeError $e) { echo $e->getMessage(), "\n"; } + +$cal = new IntlGregorianCalendar(); +try { + $cal->__construct(); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} ?> --EXPECT-- Too many arguments @@ -40,3 +47,4 @@ Too many arguments No variant with 4 arguments (excluding trailing NULLs) No variant with 4 arguments (excluding trailing NULLs) IntlGregorianCalendar::__construct(): Argument #6 ($second) must be of type int, array given +IntlGregorianCalendar object is already constructed From 6b554251f742a9389ca16f11f8ab618c10fde67d Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 26 Aug 2020 10:16:32 +0200 Subject: [PATCH 089/170] Prevent double-construction of NumberFormatter --- ext/intl/formatter/formatter_main.c | 4 ++++ ext/intl/tests/formatter_fail.phpt | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/ext/intl/formatter/formatter_main.c b/ext/intl/formatter/formatter_main.c index 80d99b3f01141..8f44f33fa369c 100644 --- a/ext/intl/formatter/formatter_main.c +++ b/ext/intl/formatter/formatter_main.c @@ -43,6 +43,10 @@ static int numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS) INTL_CHECK_LOCALE_LEN_OR_FAILURE(locale_len); object = return_value; FORMATTER_METHOD_FETCH_OBJECT_NO_CHECK; + if (FORMATTER_OBJECT(nfo)) { + zend_throw_error(NULL, "NumberFormatter object is already constructed"); + return FAILURE; + } /* Convert pattern (if specified) to UTF-16. */ if(pattern && pattern_len) { diff --git a/ext/intl/tests/formatter_fail.phpt b/ext/intl/tests/formatter_fail.phpt index 3201c9a82b108..15981178ac5b5 100644 --- a/ext/intl/tests/formatter_fail.phpt +++ b/ext/intl/tests/formatter_fail.phpt @@ -75,6 +75,15 @@ try { } err($fmt); +$fmt = new NumberFormatter('en_US', NumberFormatter::DECIMAL); +try { + $fmt->__construct('en_US', NumberFormatter::DECIMAL); +} catch (Error $e) { + print_exception($e); + $fmt = null; +} +err($fmt); + foreach($args as $arg) { $fmt = crt("O", $arg[0], $arg[1]); err($fmt); @@ -95,6 +104,9 @@ ArgumentCountError: numfmt_create() expects at least 2 parameters, 0 given in %s ArgumentCountError: NumberFormatter::create() expects at least 2 parameters, 0 given in %s on line %d 'U_ZERO_ERROR' +Error: NumberFormatter object is already constructed in %s on line %d +'U_ZERO_ERROR' + IntlException: Constructor failed in %s on line %d 'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR' 'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR' From f59301981959db5659333acd2eba5f057ef0b7be Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 26 Aug 2020 10:20:31 +0200 Subject: [PATCH 090/170] Prevent ResourceBundle double-construction --- ext/intl/resourcebundle/resourcebundle_class.c | 5 +++++ ext/intl/tests/resourcebundle_double_ctor.phpt | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 ext/intl/tests/resourcebundle_double_ctor.phpt diff --git a/ext/intl/resourcebundle/resourcebundle_class.c b/ext/intl/resourcebundle/resourcebundle_class.c index cd38b08c9bd5e..3a0fb22e08d80 100644 --- a/ext/intl/resourcebundle/resourcebundle_class.c +++ b/ext/intl/resourcebundle/resourcebundle_class.c @@ -93,6 +93,11 @@ static int resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS) return FAILURE; } + if (rb->me) { + zend_throw_error(NULL, "ResourceBundle object is already constructed"); + return FAILURE; + } + INTL_CHECK_LOCALE_LEN_OR_FAILURE(locale_len); if (locale == NULL) { diff --git a/ext/intl/tests/resourcebundle_double_ctor.phpt b/ext/intl/tests/resourcebundle_double_ctor.phpt new file mode 100644 index 0000000000000..8101130a4c90a --- /dev/null +++ b/ext/intl/tests/resourcebundle_double_ctor.phpt @@ -0,0 +1,18 @@ +--TEST-- +ResourceBundle double construction should not be allowed +--SKIPIF-- + +--FILE-- +__construct('en_US', BUNDLE); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +ResourceBundle object is already constructed From 1954aed745fc24cadf2667bebb74668ab194386e Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 26 Aug 2020 11:01:15 +0200 Subject: [PATCH 091/170] Fix over-eager named params optimization We can't relax a named param to a positional param if we encountered any unknown parameters in the meantime. --- Zend/tests/named_params/unknown_named_param.phpt | 7 +++++++ Zend/zend_compile.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Zend/tests/named_params/unknown_named_param.phpt b/Zend/tests/named_params/unknown_named_param.phpt index f43a40c69ca62..9e299dc953b91 100644 --- a/Zend/tests/named_params/unknown_named_param.phpt +++ b/Zend/tests/named_params/unknown_named_param.phpt @@ -15,6 +15,12 @@ try { echo $e->getMessage(), "\n"; } +try { + test(b: 2, a: 1); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} + try { test2(a: 42); } catch (Error $e) { @@ -24,3 +30,4 @@ try { ?> --EXPECT-- Unknown named parameter $b +Unknown named parameter $b diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 9c4853ae4eb11..11d7418b7ef21 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -3369,7 +3369,7 @@ uint32_t zend_compile_args( if (fbc) { arg_num = zend_get_arg_num(fbc, arg_name); - if (arg_num == arg_count + 1) { + if (arg_num == arg_count + 1 && !may_have_undef) { /* Using named arguments, but passing in order. */ arg_name = NULL; arg_count++; From d179e34e42e8e9cc5250ba2265fb50a8187bb6b1 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 26 Aug 2020 11:32:01 +0200 Subject: [PATCH 092/170] Fix memory leak when yielding from non-iterable --- .../generators/yield_from_non_iterable.phpt | 18 ++++++++++++++++++ Zend/zend_vm_def.h | 1 + Zend/zend_vm_execute.h | 4 ++++ 3 files changed, 23 insertions(+) create mode 100644 Zend/tests/generators/yield_from_non_iterable.phpt diff --git a/Zend/tests/generators/yield_from_non_iterable.phpt b/Zend/tests/generators/yield_from_non_iterable.phpt new file mode 100644 index 0000000000000..705bcaec3511e --- /dev/null +++ b/Zend/tests/generators/yield_from_non_iterable.phpt @@ -0,0 +1,18 @@ +--TEST-- +Yield from non-iterable +--FILE-- +current(); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +Can use "yield from" only with arrays and Traversables diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 9c46476b6add1..70e33039da0cb 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -7371,6 +7371,7 @@ ZEND_VM_HANDLER(142, ZEND_YIELD_FROM, CONST|TMP|VAR|CV, ANY) } } else { zend_throw_error(NULL, "Can use \"yield from\" only with arrays and Traversables"); + FREE_OP1(); UNDEF_RESULT(); HANDLE_EXCEPTION(); } diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index a84cfe3d4bb3f..9d7515e9d0527 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -3707,6 +3707,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_YIELD_FROM_SPEC_CONST_HANDLER( } } else { zend_throw_error(NULL, "Can use \"yield from\" only with arrays and Traversables"); + UNDEF_RESULT(); HANDLE_EXCEPTION(); } @@ -18346,6 +18347,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_YIELD_FROM_SPEC_TMP_HANDLER(ZE } } else { zend_throw_error(NULL, "Can use \"yield from\" only with arrays and Traversables"); + zval_ptr_dtor_nogc(free_op1); UNDEF_RESULT(); HANDLE_EXCEPTION(); } @@ -21672,6 +21674,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_YIELD_FROM_SPEC_VAR_HANDLER(ZE } } else { zend_throw_error(NULL, "Can use \"yield from\" only with arrays and Traversables"); + zval_ptr_dtor_nogc(free_op1); UNDEF_RESULT(); HANDLE_EXCEPTION(); } @@ -37896,6 +37899,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_YIELD_FROM_SPEC_CV_HANDLER(ZEN } } else { zend_throw_error(NULL, "Can use \"yield from\" only with arrays and Traversables"); + UNDEF_RESULT(); HANDLE_EXCEPTION(); } From 492621f99eb202c4782564334f2fe71aae43c84e Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 26 Aug 2020 11:44:15 +0200 Subject: [PATCH 093/170] Fix memory leak on unknown named param --- .../named_params/unknown_named_param.phpt | 7 +++++ Zend/zend_vm_def.h | 8 +++++ Zend/zend_vm_execute.h | 31 +++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/Zend/tests/named_params/unknown_named_param.phpt b/Zend/tests/named_params/unknown_named_param.phpt index 9e299dc953b91..79ca89169d0fd 100644 --- a/Zend/tests/named_params/unknown_named_param.phpt +++ b/Zend/tests/named_params/unknown_named_param.phpt @@ -15,6 +15,12 @@ try { echo $e->getMessage(), "\n"; } +try { + test(b: new stdClass); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} + try { test(b: 2, a: 1); } catch (Error $e) { @@ -31,3 +37,4 @@ try { --EXPECT-- Unknown named parameter $b Unknown named parameter $b +Unknown named parameter $b diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 1780f6bbe67ef..561c23af8c288 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -4570,6 +4570,7 @@ ZEND_VM_HOT_HANDLER(65, ZEND_SEND_VAL, CONST|TMPVAR, CONST|UNUSED|NUM) uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + FREE_OP1(); HANDLE_EXCEPTION(); } } else { @@ -4611,6 +4612,7 @@ ZEND_VM_HOT_SEND_HANDLER(116, ZEND_SEND_VAL_EX, CONST|TMP, CONST|UNUSED|NUM, SPE zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + FREE_OP1(); HANDLE_EXCEPTION(); } } else { @@ -4647,6 +4649,7 @@ ZEND_VM_HOT_HANDLER(117, ZEND_SEND_VAR, VAR|CV, CONST|UNUSED|NUM) uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + FREE_OP1(); HANDLE_EXCEPTION(); } } else { @@ -4693,6 +4696,7 @@ ZEND_VM_HANDLER(106, ZEND_SEND_VAR_NO_REF, VAR, CONST|UNUSED|NUM) uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + FREE_OP1(); HANDLE_EXCEPTION(); } } else { @@ -4723,6 +4727,7 @@ ZEND_VM_HOT_SEND_HANDLER(50, ZEND_SEND_VAR_NO_REF_EX, VAR, CONST|UNUSED|NUM, SPE zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + FREE_OP1(); HANDLE_EXCEPTION(); } } else { @@ -4790,6 +4795,7 @@ ZEND_VM_HANDLER(67, ZEND_SEND_REF, VAR|CV, CONST|UNUSED|NUM) uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + FREE_OP1(); HANDLE_EXCEPTION(); } } else { @@ -4819,6 +4825,7 @@ ZEND_VM_HOT_SEND_HANDLER(66, ZEND_SEND_VAR_EX, VAR|CV, CONST|UNUSED|NUM, SPEC(QU zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + FREE_OP1(); HANDLE_EXCEPTION(); } } else { @@ -4918,6 +4925,7 @@ ZEND_VM_HOT_HANDLER(185, ZEND_SEND_FUNC_ARG, VAR, CONST|UNUSED|NUM) uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + FREE_OP1(); HANDLE_EXCEPTION(); } } else { diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 34a90d00b0bd9..31325fb4ab70d 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -6072,6 +6072,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_SPEC_CONS uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + HANDLE_EXCEPTION(); } } else { @@ -6099,6 +6100,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SPEC_CONST_CONST_H zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + HANDLE_EXCEPTION(); } } else { @@ -9106,6 +9108,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_SPEC_CONS uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + HANDLE_EXCEPTION(); } } else { @@ -9133,6 +9136,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SPEC_CONST_UNUSED_ zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + HANDLE_EXCEPTION(); } } else { @@ -9169,6 +9173,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SPEC_C zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + HANDLE_EXCEPTION(); } } else { @@ -14922,6 +14927,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_SPEC_TMPV uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -16724,6 +16730,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_SPEC_TMPV uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -18609,6 +18616,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SPEC_TMP_CONST_HAN zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -19432,6 +19440,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SPEC_TMP_UNUSED_HA zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -19468,6 +19477,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SPEC_T zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -23147,6 +23157,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_SPEC_VAR_ uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -23193,6 +23204,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_NO_REF_SPEC_VAR_CONST uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -23223,6 +23235,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_NO_REF_EX_SPEC_VAR_CO zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -23290,6 +23303,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_REF_SPEC_VAR_CONST_HANDLE uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -23319,6 +23333,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SPEC_VAR_CONST_HAN zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -23386,6 +23401,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_FUNC_ARG_SPEC uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -27019,6 +27035,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_SPEC_VAR_ uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -27065,6 +27082,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_NO_REF_SPEC_VAR_UNUSE uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -27095,6 +27113,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_NO_REF_EX_SPEC_VAR_UN zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -27162,6 +27181,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_NO_REF_EX zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -27229,6 +27249,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_REF_SPEC_VAR_UNUSED_HANDL uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -27258,6 +27279,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SPEC_VAR_UNUSED_HA zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -27324,6 +27346,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SPEC_V zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -27391,6 +27414,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_FUNC_ARG_SPEC uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -40766,6 +40790,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_SPEC_CV_C uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + HANDLE_EXCEPTION(); } } else { @@ -40812,6 +40837,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_REF_SPEC_CV_CONST_HANDLER uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + HANDLE_EXCEPTION(); } } else { @@ -40840,6 +40866,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SPEC_CV_CONST_HAND zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + HANDLE_EXCEPTION(); } } else { @@ -45883,6 +45910,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_SPEC_CV_U uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + HANDLE_EXCEPTION(); } } else { @@ -45929,6 +45957,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_REF_SPEC_CV_UNUSED_HANDLE uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + HANDLE_EXCEPTION(); } } else { @@ -45957,6 +45986,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SPEC_CV_UNUSED_HAN zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + HANDLE_EXCEPTION(); } } else { @@ -46022,6 +46052,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SPEC_C zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + HANDLE_EXCEPTION(); } } else { From 1003ae2692ef76d34d75d417e913562b64695646 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 26 Aug 2020 11:52:45 +0200 Subject: [PATCH 094/170] Fix passing of undef var to named arg This needs to use the previously computed argument target. --- Zend/tests/named_params/undef_var.phpt | 17 +++++++++++++++++ Zend/zend_vm_def.h | 1 - Zend/zend_vm_execute.h | 6 ------ 3 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 Zend/tests/named_params/undef_var.phpt diff --git a/Zend/tests/named_params/undef_var.phpt b/Zend/tests/named_params/undef_var.phpt new file mode 100644 index 0000000000000..b1d5682434067 --- /dev/null +++ b/Zend/tests/named_params/undef_var.phpt @@ -0,0 +1,17 @@ +--TEST-- +Passing undefined variabled to named arg +--FILE-- + +--EXPECTF-- +Warning: Undefined variable $undef in %s on line %d +NULL + +Warning: Undefined variable $undef in %s on line %d +NULL diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 561c23af8c288..a0beebd9fac79 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -4855,7 +4855,6 @@ ZEND_VM_C_LABEL(send_var_by_ref): if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(varptr) == IS_UNDEF)) { SAVE_OPLINE(); ZVAL_UNDEFINED_OP1(); - arg = ZEND_CALL_VAR(EX(call), opline->result.var); ZVAL_NULL(arg); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 31325fb4ab70d..825c49c0b4d25 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -23363,7 +23363,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SPEC_VAR_CONST_HAN if (IS_VAR == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(varptr) == IS_UNDEF)) { SAVE_OPLINE(); ZVAL_UNDEFINED_OP1(); - arg = ZEND_CALL_VAR(EX(call), opline->result.var); ZVAL_NULL(arg); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } @@ -27309,7 +27308,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SPEC_VAR_UNUSED_HA if (IS_VAR == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(varptr) == IS_UNDEF)) { SAVE_OPLINE(); ZVAL_UNDEFINED_OP1(); - arg = ZEND_CALL_VAR(EX(call), opline->result.var); ZVAL_NULL(arg); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } @@ -27376,7 +27374,6 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SPEC_V if (IS_VAR == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(varptr) == IS_UNDEF)) { SAVE_OPLINE(); ZVAL_UNDEFINED_OP1(); - arg = ZEND_CALL_VAR(EX(call), opline->result.var); ZVAL_NULL(arg); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } @@ -40895,7 +40892,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SPEC_CV_CONST_HAND if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(varptr) == IS_UNDEF)) { SAVE_OPLINE(); ZVAL_UNDEFINED_OP1(); - arg = ZEND_CALL_VAR(EX(call), opline->result.var); ZVAL_NULL(arg); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } @@ -46015,7 +46011,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SPEC_CV_UNUSED_HAN if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(varptr) == IS_UNDEF)) { SAVE_OPLINE(); ZVAL_UNDEFINED_OP1(); - arg = ZEND_CALL_VAR(EX(call), opline->result.var); ZVAL_NULL(arg); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } @@ -46081,7 +46076,6 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SPEC_C if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(varptr) == IS_UNDEF)) { SAVE_OPLINE(); ZVAL_UNDEFINED_OP1(); - arg = ZEND_CALL_VAR(EX(call), opline->result.var); ZVAL_NULL(arg); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } From 083f5f2005e189076817368586abf49995d6ed06 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 26 Aug 2020 13:09:16 +0300 Subject: [PATCH 095/170] Improved JIT for FETCH_DIM_R/IS and ISSET_DIM_OBJ --- ext/opcache/jit/zend_jit_x86.dasc | 217 ++++++++++++++++-------------- 1 file changed, 118 insertions(+), 99 deletions(-) diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index 75f34d8888434..6cad84ffdf175 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -4969,6 +4969,7 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o if (op2_info & MAY_BE_LONG) { zend_bool op2_loaded = 0; + zend_bool packed_loaded = 0; if (op2_info & ((MAY_BE_ANY|MAY_BE_UNDEF) - MAY_BE_LONG)) { | // if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) @@ -4995,48 +4996,12 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o op2_loaded = 1; } if (op1_info & MAY_BE_ARRAY_PACKED) { + zend_long val = -1; + if (Z_MODE(op2_addr) == IS_CONST_ZVAL) { - zend_long val = Z_LVAL_P(Z_ZV(op2_addr)); + val = Z_LVAL_P(Z_ZV(op2_addr)); if (val >= 0 && val < HT_MAX_SIZE) { - | // ZEND_HASH_INDEX_FIND(ht, hval, retval, num_undef); - if (op1_info & MAY_BE_ARRAY_HASH) { - | test dword [FCARG1a + offsetof(zend_array, u.flags)], HASH_FLAG_PACKED - | jz >4 // HASH_FIND - } - | // if (EXPECTED((zend_ulong)(_h) < (zend_ulong)(_ht)->nNumUsed)) - |.if X64 - | movsxd r0, dword [FCARG1a + offsetof(zend_array, nNumUsed)] - if (val == 0) { - | test r0, r0 - } else { - | cmp r0, val - } - |.else - | cmp dword [FCARG1a + offsetof(zend_array, nNumUsed)], val - |.endif - if (type == BP_JIT_IS) { - if (not_found_exit_addr) { - | jbe ¬_found_exit_addr - } else { - | jbe >9 // NOT_FOUND - } - } else if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE && type == BP_VAR_R) { - | jbe &exit_addr - } else if (type == BP_VAR_IS && not_found_exit_addr) { - | jbe ¬_found_exit_addr - } else { - | jbe >2 // NOT_FOUND - } - | // _ret = &_ht->arData[_h].val; - | mov r0, aword [FCARG1a + offsetof(zend_array, arData)] - if (val != 0) { - | add r0, val * sizeof(Bucket) - } - if (type == BP_JIT_IS) { - | jmp >5 - } else { - | IF_NOT_Z_TYPE r0, IS_UNDEF, >8 - } + packed_loaded = 1; } } else { if (!op2_loaded) { @@ -5044,6 +5009,9 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o | GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr op2_loaded = 1; } + packed_loaded = 1; + } + if (packed_loaded) { | // ZEND_HASH_INDEX_FIND(ht, hval, retval, num_undef); if (op1_info & MAY_BE_ARRAY_HASH) { | test dword [FCARG1a + offsetof(zend_array, u.flags)], HASH_FLAG_PACKED @@ -5052,9 +5020,19 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o | // if (EXPECTED((zend_ulong)(_h) < (zend_ulong)(_ht)->nNumUsed)) |.if X64 | movsxd r0, dword [FCARG1a + offsetof(zend_array, nNumUsed)] - | cmp r0, FCARG2a + if (val == 0) { + | test r0, r0 + } else if (val > 0 && !op2_loaded) { + | cmp r0, val + } else { + | cmp r0, FCARG2a + } |.else - | cmp dword [FCARG1a + offsetof(zend_array, nNumUsed)], FCARG2a + if (val >= 0 && !op2_loaded) { + | cmp dword [FCARG1a + offsetof(zend_array, nNumUsed)], val + } else { + | cmp dword [FCARG1a + offsetof(zend_array, nNumUsed)], FCARG2a + } |.endif if (type == BP_JIT_IS) { if (not_found_exit_addr) { @@ -5066,27 +5044,34 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o | jbe &exit_addr } else if (type == BP_VAR_IS && not_found_exit_addr) { | jbe ¬_found_exit_addr + } else if (type == BP_VAR_IS && found_exit_addr) { + | jbe >7 // NOT_FOUND } else { | jbe >2 // NOT_FOUND } | // _ret = &_ht->arData[_h].val; - |.if X64 - | mov r0, FCARG2a - | shl r0, 5 - |.else - | imul r0, FCARG2a, sizeof(Bucket) - |.endif - | add r0, aword [FCARG1a + offsetof(zend_array, arData)] - if (type == BP_JIT_IS) { - | jmp >5 + if (val >= 0) { + | mov r0, aword [FCARG1a + offsetof(zend_array, arData)] + if (val != 0) { + | add r0, val * sizeof(Bucket) + } } else { - | IF_NOT_Z_TYPE r0, IS_UNDEF, >8 + |.if X64 + | mov r0, FCARG2a + | shl r0, 5 + |.else + | imul r0, FCARG2a, sizeof(Bucket) + |.endif + | add r0, aword [FCARG1a + offsetof(zend_array, arData)] } } } switch (type) { case BP_JIT_IS: if (op1_info & MAY_BE_ARRAY_HASH) { + if (packed_loaded) { + | jmp >5 + } |4: if (!op2_loaded) { | // hval = Z_LVAL_P(dim); @@ -5102,6 +5087,10 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o if (op2_info & MAY_BE_STRING) { | jmp >5 } + } else if (packed_loaded) { + if (op2_info & MAY_BE_STRING) { + | jmp >5 + } } else if (not_found_exit_addr) { | jmp ¬_found_exit_addr } else { @@ -5111,14 +5100,26 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o case BP_VAR_R: case BP_VAR_IS: case BP_VAR_UNSET: - if (!(op1_info & MAY_BE_ARRAY_KEY_LONG) || - ((op1_info & MAY_BE_ARRAY_PACKED) && - (Z_MODE(op2_addr) != IS_CONST_ZVAL || - (Z_LVAL_P(Z_ZV(op2_addr)) >= 0 && Z_LVAL_P(Z_ZV(op2_addr)) < HT_MAX_SIZE)))) { + if (packed_loaded) { + if (op1_info & MAY_BE_ARRAY_HASH) { + | IF_NOT_Z_TYPE r0, IS_UNDEF, >8 + } else if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE && type == BP_VAR_R) { + | IF_Z_TYPE r0, IS_UNDEF, &exit_addr + } else if (type == BP_VAR_IS && not_found_exit_addr) { + | IF_Z_TYPE r0, IS_UNDEF, ¬_found_exit_addr + } else if (type == BP_VAR_IS && found_exit_addr) { + | IF_Z_TYPE r0, IS_UNDEF, >7 // NOT_FOUND + } else { + | IF_Z_TYPE r0, IS_UNDEF, >2 // NOT_FOUND + } + } + if (!(op1_info & MAY_BE_ARRAY_KEY_LONG) || (packed_loaded && (op1_info & MAY_BE_ARRAY_HASH))) { if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE && type == BP_VAR_R) { | jmp &exit_addr } else if (type == BP_VAR_IS && not_found_exit_addr) { | jmp ¬_found_exit_addr + } else if (type == BP_VAR_IS && found_exit_addr) { + | jmp >7 // NOT_FOUND } else { | jmp >2 // NOT_FOUND } @@ -5135,6 +5136,8 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o | jz &exit_addr } else if (type == BP_VAR_IS && not_found_exit_addr) { | jz ¬_found_exit_addr + } else if (type == BP_VAR_IS && found_exit_addr) { + | jz >7 // NOT_FOUND } else { | jz >2 // NOT_FOUND } @@ -5152,7 +5155,7 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o break; case BP_VAR_IS: case BP_VAR_UNSET: - if (!not_found_exit_addr) { + if (!not_found_exit_addr && !found_exit_addr) { | // retval = &EG(uninitialized_zval); | SET_ZVAL_TYPE_INFO res_addr, IS_NULL | jmp >9 @@ -5164,6 +5167,9 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o |.code break; case BP_VAR_RW: + if (packed_loaded) { + | IF_NOT_Z_TYPE r0, IS_UNDEF, >8 + } |2: |4: if (!op2_loaded) { @@ -5176,12 +5182,16 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o | jz >9 break; case BP_VAR_W: - if (!(op1_info & MAY_BE_ARRAY_KEY_LONG) || - ((op1_info & MAY_BE_ARRAY_PACKED) && - (Z_MODE(op2_addr) != IS_CONST_ZVAL || - (Z_LVAL_P(Z_ZV(op2_addr)) >= 0 && Z_LVAL_P(Z_ZV(op2_addr)) < HT_MAX_SIZE)))) { + if (packed_loaded) { + | IF_NOT_Z_TYPE r0, IS_UNDEF, >8 + } + if (!(op1_info & MAY_BE_ARRAY_KEY_LONG) || packed_loaded) { |2: | //retval = zend_hash_index_add_new(ht, hval, &EG(uninitialized_zval)); + if (!op2_loaded) { + | // hval = Z_LVAL_P(dim); + | GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr + } |.if X64 | LOAD_ADDR_ZTS CARG3, executor_globals, uninitialized_zval |.else @@ -5198,6 +5208,10 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o } if (op1_info & MAY_BE_ARRAY_HASH) { |4: + if (!op2_loaded) { + | // hval = Z_LVAL_P(dim); + | GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr + } | EXT_CALL zend_jit_hash_index_lookup_w, r0 } break; @@ -5266,6 +5280,8 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o | jz &exit_addr } else if (type == BP_VAR_IS && not_found_exit_addr) { | jz ¬_found_exit_addr + } else if (type == BP_VAR_IS && found_exit_addr) { + | jz >7 // NOT_FOUND } else { | jz >2 // NOT_FOUND } @@ -5286,13 +5302,11 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o // zend_error(E_WARNING, "Undefined array key \"%s\"", ZSTR_VAL(offset_key)); | UNDEFINED_INDEX opline | jmp >9 - } else { - | jmp &exit_addr } break; case BP_VAR_IS: case BP_VAR_UNSET: - if (!not_found_exit_addr) { + if (!not_found_exit_addr && !found_exit_addr) { | // retval = &EG(uninitialized_zval); | SET_ZVAL_TYPE_INFO res_addr, IS_NULL | jmp >9 @@ -10650,7 +10664,7 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, } } | GET_ZVAL_LVAL ZREG_FCARG1a, op1_addr - if (!zend_jit_fetch_dimension_address_inner(Dst, opline, (opline->opcode != ZEND_FETCH_DIM_IS) ? BP_VAR_R : BP_VAR_IS, op1_info, op2_info, NULL, not_found_exit_addr, exit_addr)) { + if (!zend_jit_fetch_dimension_address_inner(Dst, opline, (opline->opcode != ZEND_FETCH_DIM_IS) ? BP_VAR_R : BP_VAR_IS, op1_info, op2_info, res_exit_addr, not_found_exit_addr, exit_addr)) { return 0; } } @@ -10795,6 +10809,7 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, | IF_NOT_TYPE dl, type, &res_exit_addr } | // ZVAL_COPY + |7: | ZVAL_COPY_VALUE_V res_addr, -1, val_addr, res_info, ZREG_R0, ZREG_R1 if (Z_MODE(res_addr) == IS_MEM_ZVAL) { if (type < IS_STRING) { @@ -10921,7 +10936,10 @@ static int zend_jit_isset_isempty_dim(dasm_State **Dst, | EXT_CALL zend_jit_isset_dim_helper, r0 | test r0, r0 | jz >9 - | jmp >8 + if (op1_info & MAY_BE_ARRAY) { + | jmp >8 + |.code + } } else { if (op2_info & MAY_BE_UNDEF) { if (op2_info & MAY_BE_ANY) { @@ -10931,11 +10949,10 @@ static int zend_jit_isset_isempty_dim(dasm_State **Dst, | EXT_CALL zend_jit_undefined_op_helper, r0 |1: } - | jmp >9 - } - - if (op1_info & MAY_BE_ARRAY) { - |.code + if (op1_info & MAY_BE_ARRAY) { + | jmp >9 + |.code + } } } @@ -10946,40 +10963,42 @@ static int zend_jit_isset_isempty_dim(dasm_State **Dst, } #endif - |8: - | FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline - if (!op1_avoid_refcounting) { - | FREE_OP opline->op1_type, opline->op1, op1_info, 0, opline - } - if (may_throw) { - if (!zend_jit_check_exception_undef_result(Dst, opline)) { - return 0; + if (op1_info & (MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_OBJECT)) { + |8: + | FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline + if (!op1_avoid_refcounting) { + | FREE_OP opline->op1_type, opline->op1, op1_info, 0, opline } - } - if (!(opline->extended_value & ZEND_ISEMPTY)) { - if (exit_addr) { - if (smart_branch_opcode == ZEND_JMPNZ) { - | jmp &exit_addr - } else { - | jmp >8 + if (may_throw) { + if (!zend_jit_check_exception_undef_result(Dst, opline)) { + return 0; } - } else if (smart_branch_opcode) { - if (smart_branch_opcode == ZEND_JMPZ) { - | jmp =>target_label2 - } else if (smart_branch_opcode == ZEND_JMPNZ) { - | jmp =>target_label - } else if (smart_branch_opcode == ZEND_JMPZNZ) { - | jmp =>target_label2 + } + if (!(opline->extended_value & ZEND_ISEMPTY)) { + if (exit_addr) { + if (smart_branch_opcode == ZEND_JMPNZ) { + | jmp &exit_addr + } else { + | jmp >8 + } + } else if (smart_branch_opcode) { + if (smart_branch_opcode == ZEND_JMPZ) { + | jmp =>target_label2 + } else if (smart_branch_opcode == ZEND_JMPNZ) { + | jmp =>target_label + } else if (smart_branch_opcode == ZEND_JMPZNZ) { + | jmp =>target_label2 + } else { + ZEND_UNREACHABLE(); + } } else { - ZEND_UNREACHABLE(); + | SET_ZVAL_TYPE_INFO res_addr, IS_TRUE + | jmp >8 } } else { - | SET_ZVAL_TYPE_INFO res_addr, IS_TRUE - | jmp >8 + | //???? + | int3 } - } else { - | //???? - | int3 } |9: // not found From 0487bcfac763453b3a386fe808d3ad58683936c9 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 26 Aug 2020 12:11:22 +0200 Subject: [PATCH 096/170] Avoid socket path clash in test --- ext/sockets/tests/socket_cmsg_credentials.phpt | 4 ++-- ext/sockets/tests/socket_cmsg_rights.phpt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/sockets/tests/socket_cmsg_credentials.phpt b/ext/sockets/tests/socket_cmsg_credentials.phpt index 09266e6cbd968..0472d3e001406 100644 --- a/ext/sockets/tests/socket_cmsg_credentials.phpt +++ b/ext/sockets/tests/socket_cmsg_credentials.phpt @@ -16,12 +16,12 @@ die('skip SO_PASSCRED is not defined'); } --CLEAN-- Date: Wed, 26 Aug 2020 12:19:17 +0200 Subject: [PATCH 097/170] Fix memory leak on unknown named param in iterator unpack --- Zend/tests/named_params/unknown_named_param.phpt | 7 +++++++ Zend/zend_vm_def.h | 1 + Zend/zend_vm_execute.h | 1 + 3 files changed, 9 insertions(+) diff --git a/Zend/tests/named_params/unknown_named_param.phpt b/Zend/tests/named_params/unknown_named_param.phpt index 79ca89169d0fd..5a18932ffd174 100644 --- a/Zend/tests/named_params/unknown_named_param.phpt +++ b/Zend/tests/named_params/unknown_named_param.phpt @@ -27,6 +27,12 @@ try { echo $e->getMessage(), "\n"; } +try { + test(...new ArrayIterator(['unknown' => 42])); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} + try { test2(a: 42); } catch (Error $e) { @@ -38,3 +44,4 @@ try { Unknown named parameter $b Unknown named parameter $b Unknown named parameter $b +Unknown named parameter $unknown diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index a0beebd9fac79..64c0ac61dbbb0 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -5107,6 +5107,7 @@ ZEND_VM_C_LABEL(send_again): have_named_params = 1; top = zend_handle_named_arg(&EX(call), name, &arg_num, cache_slot); if (UNEXPECTED(!top)) { + zend_string_release(name); break; } diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 825c49c0b4d25..efaed5e6f465d 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -1995,6 +1995,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_UNPACK_SPEC_HANDLER(ZEND_ have_named_params = 1; top = zend_handle_named_arg(&EX(call), name, &arg_num, cache_slot); if (UNEXPECTED(!top)) { + zend_string_release(name); break; } From 358721bcf75be6bd2020f8d65c19887823b49377 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 26 Aug 2020 12:32:06 +0200 Subject: [PATCH 098/170] Fix file name clash in test --- ext/standard/tests/file/stream_copy_to_stream.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/standard/tests/file/stream_copy_to_stream.phpt b/ext/standard/tests/file/stream_copy_to_stream.phpt index b0c2d1384665d..1f34b843347ca 100644 --- a/ext/standard/tests/file/stream_copy_to_stream.phpt +++ b/ext/standard/tests/file/stream_copy_to_stream.phpt @@ -5,7 +5,7 @@ stream_copy_to_stream() tests define('WIN', substr(PHP_OS, 0, 3) == 'WIN'); $initial_file = __DIR__.'/bug38086.txt'; -$new_file = __DIR__.'/bug38086_1.txt'; +$new_file = __DIR__.'/stream_copy_to_stream.txt'; $src = fopen($initial_file, 'r'); stream_filter_append($src, "string.rot13", STREAM_FILTER_READ); From 1b2ec73c1d9175769c3ad4dd40825546851287bc Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Wed, 26 Aug 2020 12:57:24 +0200 Subject: [PATCH 099/170] Drop various unused macros/APIs Also convert_libmagic_pattern() to return a zend_string* Closes GH-6029 --- UPGRADING.INTERNALS | 12 ++++ Zend/zend.c | 16 ++--- Zend/zend_compile.c | 6 +- Zend/zend_hash.h | 2 - Zend/zend_ini.c | 4 +- Zend/zend_language_scanner.l | 2 +- Zend/zend_list.c | 2 +- Zend/zend_ts_hash.c | 2 +- Zend/zend_ts_hash.h | 7 +-- Zend/zend_variables.h | 4 -- Zend/zend_vm_execute.h | 2 +- Zend/zend_vm_execute.skl | 2 +- ext/fileinfo/libmagic.patch | 94 +++++++++++++++--------------- ext/fileinfo/libmagic/apprentice.c | 10 ++-- ext/fileinfo/libmagic/file.h | 3 +- ext/fileinfo/libmagic/funcs.c | 10 ++-- ext/fileinfo/libmagic/softmagic.c | 19 +++--- ext/oci8/oci8_failover.c | 2 +- ext/pdo/pdo_dbh.c | 4 +- ext/pgsql/pgsql.c | 4 +- ext/standard/browscap.c | 4 +- ext/standard/password.c | 4 +- ext/standard/scanf.c | 2 +- ext/standard/var_unserializer.re | 2 +- main/SAPI.c | 2 +- win32/signal.c | 4 +- 26 files changed, 111 insertions(+), 114 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 711ba47604c0a..404f5f9c67de8 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -22,6 +22,7 @@ PHP 8.0 INTERNALS UPGRADE NOTES s. zend_fcall_info no_separation flag removed t. Signature changes u. Error Notification callbacks to replace zend_error_cb overwrite use-cases + v. Removed Zend APIs 2. Build system changes a. Abstract @@ -201,6 +202,17 @@ PHP 8.0 INTERNALS UPGRADE NOTES } zend_register_error_notify_callback(my_error_notify_cb); + v. The following APIs have been removed from the Zend Engine: + - zend_ts_hash_init_ex(), drop the last argument and use zend_ts_hash_init() instead + - zend_hash_init_ex(), drop the last argument and use zend_hash_init() instead + - zval_internal_dtor(), use zval_internal_ptr_dtor() instead + - zval_dtor_func(), use rc_dtor_func() instead + - zval_ptr_dtor_wrapper(), use zval_ptr_dtor() instead + - zval_internal_ptr_dtor_wrapper(), use zval_internal_ptr_dtor() instead + + w. The following APIs have been renamed: + - _zend_ts_hash_init() to zend_ts_hash_init() + ======================== 2. Build system changes ======================== diff --git a/Zend/zend.c b/Zend/zend.c index 2aa37b0536acc..775a1cdb69a43 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -650,17 +650,17 @@ static void compiler_globals_ctor(zend_compiler_globals *compiler_globals) /* {{ compiler_globals->compiled_filename = NULL; compiler_globals->function_table = (HashTable *) malloc(sizeof(HashTable)); - zend_hash_init_ex(compiler_globals->function_table, 1024, NULL, ZEND_FUNCTION_DTOR, 1, 0); + zend_hash_init(compiler_globals->function_table, 1024, NULL, ZEND_FUNCTION_DTOR, 1); zend_hash_copy(compiler_globals->function_table, global_function_table, function_copy_ctor); compiler_globals->class_table = (HashTable *) malloc(sizeof(HashTable)); - zend_hash_init_ex(compiler_globals->class_table, 64, NULL, ZEND_CLASS_DTOR, 1, 0); + zend_hash_init(compiler_globals->class_table, 64, NULL, ZEND_CLASS_DTOR, 1); zend_hash_copy(compiler_globals->class_table, global_class_table, zend_class_add_ref); zend_set_default_compile_time_values(); compiler_globals->auto_globals = (HashTable *) malloc(sizeof(HashTable)); - zend_hash_init_ex(compiler_globals->auto_globals, 8, NULL, auto_global_dtor, 1, 0); + zend_hash_init(compiler_globals->auto_globals, 8, NULL, auto_global_dtor, 1); zend_hash_copy(compiler_globals->auto_globals, global_auto_globals_table, auto_global_copy_ctor); compiler_globals->script_encoding_list = NULL; @@ -894,12 +894,12 @@ int zend_startup(zend_utility_functions *utility_functions) /* {{{ */ GLOBAL_AUTO_GLOBALS_TABLE = (HashTable *) malloc(sizeof(HashTable)); GLOBAL_CONSTANTS_TABLE = (HashTable *) malloc(sizeof(HashTable)); - zend_hash_init_ex(GLOBAL_FUNCTION_TABLE, 1024, NULL, ZEND_FUNCTION_DTOR, 1, 0); - zend_hash_init_ex(GLOBAL_CLASS_TABLE, 64, NULL, ZEND_CLASS_DTOR, 1, 0); - zend_hash_init_ex(GLOBAL_AUTO_GLOBALS_TABLE, 8, NULL, auto_global_dtor, 1, 0); - zend_hash_init_ex(GLOBAL_CONSTANTS_TABLE, 128, NULL, ZEND_CONSTANT_DTOR, 1, 0); + zend_hash_init(GLOBAL_FUNCTION_TABLE, 1024, NULL, ZEND_FUNCTION_DTOR, 1); + zend_hash_init(GLOBAL_CLASS_TABLE, 64, NULL, ZEND_CLASS_DTOR, 1); + zend_hash_init(GLOBAL_AUTO_GLOBALS_TABLE, 8, NULL, auto_global_dtor, 1); + zend_hash_init(GLOBAL_CONSTANTS_TABLE, 128, NULL, ZEND_CONSTANT_DTOR, 1); - zend_hash_init_ex(&module_registry, 32, NULL, module_destructor_zval, 1, 0); + zend_hash_init(&module_registry, 32, NULL, module_destructor_zval, 1); zend_init_rsrc_list_dtors(); #ifdef ZTS diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 11d7418b7ef21..a75c282d2d47e 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1810,9 +1810,9 @@ ZEND_API void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify ce->default_properties_table = NULL; ce->default_static_members_table = NULL; - zend_hash_init_ex(&ce->properties_info, 8, NULL, (persistent_hashes ? zend_destroy_property_info_internal : NULL), persistent_hashes, 0); - zend_hash_init_ex(&ce->constants_table, 8, NULL, NULL, persistent_hashes, 0); - zend_hash_init_ex(&ce->function_table, 8, NULL, ZEND_FUNCTION_DTOR, persistent_hashes, 0); + zend_hash_init(&ce->properties_info, 8, NULL, (persistent_hashes ? zend_destroy_property_info_internal : NULL), persistent_hashes); + zend_hash_init(&ce->constants_table, 8, NULL, NULL, persistent_hashes); + zend_hash_init(&ce->function_table, 8, NULL, ZEND_FUNCTION_DTOR, persistent_hashes); if (ce->type == ZEND_INTERNAL_CLASS) { ZEND_MAP_PTR_INIT(ce->static_members_table, NULL); diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h index 294a9c2c26389..a9684b1dc2a2c 100644 --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@ -103,8 +103,6 @@ ZEND_API void ZEND_FASTCALL zend_hash_clean(HashTable *ht); #define zend_hash_init(ht, nSize, pHashFunction, pDestructor, persistent) \ _zend_hash_init((ht), (nSize), (pDestructor), (persistent)) -#define zend_hash_init_ex(ht, nSize, pHashFunction, pDestructor, persistent, bApplyProtection) \ - _zend_hash_init((ht), (nSize), (pDestructor), (persistent)) ZEND_API void ZEND_FASTCALL zend_hash_real_init(HashTable *ht, zend_bool packed); ZEND_API void ZEND_FASTCALL zend_hash_real_init_packed(HashTable *ht); diff --git a/Zend/zend_ini.c b/Zend/zend_ini.c index eaa95621d406b..488468f0e0331 100644 --- a/Zend/zend_ini.c +++ b/Zend/zend_ini.c @@ -96,7 +96,7 @@ ZEND_API int zend_ini_startup(void) /* {{{ */ EG(ini_directives) = registered_zend_ini_directives; EG(modified_ini_directives) = NULL; EG(error_reporting_ini_entry) = NULL; - zend_hash_init_ex(registered_zend_ini_directives, 128, NULL, free_ini_entry, 1, 0); + zend_hash_init(registered_zend_ini_directives, 128, NULL, free_ini_entry, 1); return SUCCESS; } /* }}} */ @@ -164,7 +164,7 @@ ZEND_API int zend_copy_ini_directives(void) /* {{{ */ EG(modified_ini_directives) = NULL; EG(error_reporting_ini_entry) = NULL; EG(ini_directives) = (HashTable *) malloc(sizeof(HashTable)); - zend_hash_init_ex(EG(ini_directives), registered_zend_ini_directives->nNumOfElements, NULL, free_ini_entry, 1, 0); + zend_hash_init(EG(ini_directives), registered_zend_ini_directives->nNumOfElements, NULL, free_ini_entry, 1); zend_hash_copy(EG(ini_directives), registered_zend_ini_directives, copy_ini_entry); return SUCCESS; } diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index deee3ae3cf759..d16df9dbec0ec 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -699,7 +699,7 @@ ZEND_API zend_ast *zend_compile_string_to_ast( zend_restore_lexical_state(&original_lex_state); CG(in_compilation) = original_in_compilation; - zval_dtor(&code_zv); + zval_ptr_dtor_str(&code_zv); return ast; } diff --git a/Zend/zend_list.c b/Zend/zend_list.c index 3464ca27d524d..fd3db65395f7c 100644 --- a/Zend/zend_list.c +++ b/Zend/zend_list.c @@ -213,7 +213,7 @@ ZEND_API int zend_init_rsrc_list(void) int zend_init_rsrc_plist(void) { - zend_hash_init_ex(&EG(persistent_list), 8, NULL, plist_entry_destructor, 1, 0); + zend_hash_init(&EG(persistent_list), 8, NULL, plist_entry_destructor, 1); return SUCCESS; } diff --git a/Zend/zend_ts_hash.c b/Zend/zend_ts_hash.c index 34cc7419a841b..daa9aafefaef0 100644 --- a/Zend/zend_ts_hash.c +++ b/Zend/zend_ts_hash.c @@ -57,7 +57,7 @@ static void end_write(TsHashTable *ht) } /* delegates */ -ZEND_API void _zend_ts_hash_init(TsHashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent) +ZEND_API void zend_ts_hash_init(TsHashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent) { #ifdef ZTS ht->mx_reader = tsrm_mutex_alloc(); diff --git a/Zend/zend_ts_hash.h b/Zend/zend_ts_hash.h index e224d0217c7e9..3f245d21206e4 100644 --- a/Zend/zend_ts_hash.h +++ b/Zend/zend_ts_hash.h @@ -35,15 +35,10 @@ BEGIN_EXTERN_C() #define TS_HASH(table) (&(table->hash)) /* startup/shutdown */ -ZEND_API void _zend_ts_hash_init(TsHashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent); +ZEND_API void zend_ts_hash_init(TsHashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent); ZEND_API void zend_ts_hash_destroy(TsHashTable *ht); ZEND_API void zend_ts_hash_clean(TsHashTable *ht); -#define zend_ts_hash_init(ht, nSize, pHashFunction, pDestructor, persistent) \ - _zend_ts_hash_init(ht, nSize, pDestructor, persistent) -#define zend_ts_hash_init_ex(ht, nSize, pHashFunction, pDestructor, persistent, bApplyProtection) \ - _zend_ts_hash_init(ht, nSize, pDestructor, persistent) - /* additions/updates/changes */ ZEND_API zval *zend_ts_hash_update(TsHashTable *ht, zend_string *key, zval *pData); diff --git a/Zend/zend_variables.h b/Zend/zend_variables.h index bdee8b1879d5b..ea3fd9c5efcb8 100644 --- a/Zend/zend_variables.h +++ b/Zend/zend_variables.h @@ -81,10 +81,6 @@ ZEND_API void zval_internal_ptr_dtor(zval *zvalue); /* Kept for compatibility */ #define zval_dtor(zvalue) zval_ptr_dtor_nogc(zvalue) -#define zval_internal_dtor(zvalue) zval_internal_ptr_dtor(zvalue) -#define zval_dtor_func rc_dtor_func -#define zval_ptr_dtor_wrapper zval_ptr_dtor -#define zval_internal_ptr_dtor_wrapper zval_internal_ptr_dtor ZEND_API void zval_add_ref(zval *p); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index efaed5e6f465d..087d04931c572 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -61625,7 +61625,7 @@ static void init_opcode_serialiser(void) zval tmp; zend_handlers_table = malloc(sizeof(HashTable)); - zend_hash_init_ex(zend_handlers_table, zend_handlers_count, NULL, NULL, 1, 0); + zend_hash_init(zend_handlers_table, zend_handlers_count, NULL, NULL, 1); zend_hash_real_init(zend_handlers_table, 0); Z_TYPE_INFO(tmp) = IS_LONG; for (i = 0; i < zend_handlers_count; i++) { diff --git a/Zend/zend_vm_execute.skl b/Zend/zend_vm_execute.skl index 170fc300bbb8b..fcd52aba9c8da 100644 --- a/Zend/zend_vm_execute.skl +++ b/Zend/zend_vm_execute.skl @@ -85,7 +85,7 @@ static void init_opcode_serialiser(void) zval tmp; zend_handlers_table = malloc(sizeof(HashTable)); - zend_hash_init_ex(zend_handlers_table, zend_handlers_count, NULL, NULL, 1, 0); + zend_hash_init(zend_handlers_table, zend_handlers_count, NULL, NULL, 1); zend_hash_real_init(zend_handlers_table, 0); Z_TYPE_INFO(tmp) = IS_LONG; for (i = 0; i < zend_handlers_count; i++) { diff --git a/ext/fileinfo/libmagic.patch b/ext/fileinfo/libmagic.patch index e2d4fcc0092dc..5b33e42744bcb 100644 --- a/ext/fileinfo/libmagic.patch +++ b/ext/fileinfo/libmagic.patch @@ -1,6 +1,6 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c --- libmagic.orig/apprentice.c 2019-02-20 03:35:27.000000000 +0100 -+++ libmagic/apprentice.c 2020-08-21 15:28:20.802569900 +0200 ++++ libmagic/apprentice.c 2020-08-25 15:13:14.549715400 +0200 @@ -29,6 +29,8 @@ * apprentice - make one pass through /etc/magic, learning its secrets. */ @@ -635,19 +635,19 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c - if (rc) { - if (ms->flags & MAGIC_CHECK) - file_regerror(&rx, rc, ms); -+ zval pattern; ++ zend_string *pattern; + int options = 0; + pcre_cache_entry *pce; + -+ convert_libmagic_pattern(&pattern, m->value.s, strlen(m->value.s), options); ++ pattern = convert_libmagic_pattern(m->value.s, strlen(m->value.s), options); + -+ if ((pce = pcre_get_compiled_regex_cache(Z_STR(pattern))) == NULL) { -+ zval_dtor(&pattern); ++ if ((pce = pcre_get_compiled_regex_cache(pattern)) == NULL) { ++ zend_string_release(pattern); + return -1; } - file_regfree(&rx); - return rc ? -1 : 0; -+ zval_dtor(&pattern); ++ zend_string_release(pattern); + + return 0; } @@ -974,7 +974,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c } diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c --- libmagic.orig/ascmagic.c 2019-05-07 04:27:11.000000000 +0200 -+++ libmagic/ascmagic.c 2020-08-21 16:09:54.656316500 +0200 ++++ libmagic/ascmagic.c 2020-08-24 14:22:57.162970900 +0200 @@ -51,7 +51,7 @@ #define ISSPC(x) ((x) == ' ' || (x) == '\t' || (x) == '\r' || (x) == '\n' \ || (x) == 0x85 || (x) == '\f') @@ -1040,7 +1040,7 @@ diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c unsigned char *end = buf + len; diff -u libmagic.orig/buffer.c libmagic/buffer.c --- libmagic.orig/buffer.c 2019-05-07 04:27:11.000000000 +0200 -+++ libmagic/buffer.c 2020-08-21 15:28:20.802569900 +0200 ++++ libmagic/buffer.c 2020-04-07 22:25:10.501740300 +0200 @@ -31,19 +31,23 @@ #endif /* lint */ @@ -1097,7 +1097,7 @@ diff -u libmagic.orig/buffer.c libmagic/buffer.c diff -u libmagic.orig/cdf.c libmagic/cdf.c --- libmagic.orig/cdf.c 2019-02-20 03:35:27.000000000 +0100 -+++ libmagic/cdf.c 2020-08-21 15:28:20.802569900 +0200 ++++ libmagic/cdf.c 2020-05-05 20:05:37.698461100 +0200 @@ -43,7 +43,17 @@ #include #endif @@ -1376,7 +1376,7 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c #endif diff -u libmagic.orig/cdf.h libmagic/cdf.h --- libmagic.orig/cdf.h 2019-02-20 02:24:19.000000000 +0100 -+++ libmagic/cdf.h 2020-08-21 15:28:20.802569900 +0200 ++++ libmagic/cdf.h 2020-04-07 22:25:10.517321000 +0200 @@ -35,10 +35,10 @@ #ifndef _H_CDF_ #define _H_CDF_ @@ -1401,7 +1401,7 @@ diff -u libmagic.orig/cdf.h libmagic/cdf.h #define CDF_SECID_FREE -1 diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c --- libmagic.orig/cdf_time.c 2019-03-12 21:43:05.000000000 +0100 -+++ libmagic/cdf_time.c 2020-08-21 15:28:20.802569900 +0200 ++++ libmagic/cdf_time.c 2020-04-07 22:25:10.517321000 +0200 @@ -23,6 +23,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. @@ -1430,7 +1430,7 @@ diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c (void)snprintf(buf, 26, "*Bad* %#16.16" INT64_T_FORMAT "x\n", diff -u libmagic.orig/compress.c libmagic/compress.c --- libmagic.orig/compress.c 2019-05-07 04:27:11.000000000 +0200 -+++ libmagic/compress.c 2020-08-21 15:28:20.802569900 +0200 ++++ libmagic/compress.c 2020-08-07 20:46:25.154923400 +0200 @@ -45,13 +45,11 @@ #endif #include @@ -1580,7 +1580,7 @@ diff -u libmagic.orig/compress.c libmagic/compress.c +#endif diff -u libmagic.orig/der.c libmagic/der.c --- libmagic.orig/der.c 2019-02-20 03:35:27.000000000 +0100 -+++ libmagic/der.c 2020-08-21 15:28:20.802569900 +0200 ++++ libmagic/der.c 2020-04-07 22:25:10.517321000 +0200 @@ -51,7 +51,9 @@ #include "magic.h" #include "der.h" @@ -1610,7 +1610,7 @@ diff -u libmagic.orig/der.c libmagic/der.c snprintf(buf + z, blen - z, "%.2x", d[i]); diff -u libmagic.orig/elfclass.h libmagic/elfclass.h --- libmagic.orig/elfclass.h 2019-02-20 02:30:19.000000000 +0100 -+++ libmagic/elfclass.h 2020-08-21 15:28:20.802569900 +0200 ++++ libmagic/elfclass.h 2020-04-07 22:25:10.517321000 +0200 @@ -41,7 +41,7 @@ return toomany(ms, "program headers", phnum); flags |= FLAGS_IS_CORE; @@ -1640,7 +1640,7 @@ diff -u libmagic.orig/elfclass.h libmagic/elfclass.h CAST(int, elf_getu16(swap, elfhdr.e_shstrndx)), diff -u libmagic.orig/encoding.c libmagic/encoding.c --- libmagic.orig/encoding.c 2019-04-15 18:48:41.000000000 +0200 -+++ libmagic/encoding.c 2020-08-21 16:09:54.670315100 +0200 ++++ libmagic/encoding.c 2020-08-24 14:22:57.172802500 +0200 @@ -44,14 +44,14 @@ #include @@ -1830,7 +1830,7 @@ diff -u libmagic.orig/encoding.c libmagic/encoding.c return 0; diff -u libmagic.orig/file.h libmagic/file.h --- libmagic.orig/file.h 2019-05-07 04:27:11.000000000 +0200 -+++ libmagic/file.h 2020-08-21 16:09:54.697579400 +0200 ++++ libmagic/file.h 2020-08-25 15:11:06.907695900 +0200 @@ -33,18 +33,9 @@ #ifndef __file_h__ #define __file_h__ @@ -2004,7 +2004,7 @@ diff -u libmagic.orig/file.h libmagic/file.h size_t *); protected size_t file_pstring_length_size(const struct magic *); protected size_t file_pstring_get_length(const struct magic *, const char *); -@@ -513,34 +498,13 @@ +@@ -513,34 +498,12 @@ size_t); #endif /* __EMX__ */ @@ -2037,12 +2037,11 @@ diff -u libmagic.orig/file.h libmagic/file.h - int); -protected void file_regfree(file_regex_t *); -protected void file_regerror(file_regex_t *, int, struct magic_set *); -+public void -+convert_libmagic_pattern(zval *pattern, char *val, size_t len, uint32_t options); ++public zend_string* convert_libmagic_pattern(char *val, size_t len, uint32_t options); typedef struct { char *buf; -@@ -550,28 +514,13 @@ +@@ -550,28 +513,13 @@ protected file_pushbuf_t *file_push_buffer(struct magic_set *); protected char *file_pop_buffer(struct magic_set *, file_pushbuf_t *); @@ -2073,7 +2072,7 @@ diff -u libmagic.orig/file.h libmagic/file.h size_t strlcat(char *, const char *, size_t); #endif #ifndef HAVE_STRCASESTR -@@ -587,39 +536,6 @@ +@@ -587,39 +535,6 @@ #ifndef HAVE_ASCTIME_R char *asctime_r(const struct tm *, char *); #endif @@ -2113,7 +2112,7 @@ diff -u libmagic.orig/file.h libmagic/file.h #if defined(HAVE_MMAP) && defined(HAVE_SYS_MMAN_H) && !defined(QUICK) #define QUICK -@@ -645,6 +561,18 @@ +@@ -645,6 +560,18 @@ #else #define FILE_RCSID(id) #endif @@ -2134,7 +2133,7 @@ diff -u libmagic.orig/file.h libmagic/file.h #endif diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c --- libmagic.orig/fsmagic.c 2019-05-07 04:26:48.000000000 +0200 -+++ libmagic/fsmagic.c 2020-08-21 15:28:20.802569900 +0200 ++++ libmagic/fsmagic.c 2020-04-07 22:25:10.532971400 +0200 @@ -66,26 +66,10 @@ # define minor(dev) ((dev) & 0xff) #endif @@ -2427,7 +2426,7 @@ diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c case S_IFSOCK: diff -u libmagic.orig/funcs.c libmagic/funcs.c --- libmagic.orig/funcs.c 2019-05-07 04:27:11.000000000 +0200 -+++ libmagic/funcs.c 2020-08-21 15:46:02.589327200 +0200 ++++ libmagic/funcs.c 2020-08-25 15:11:06.872908800 +0200 @@ -31,87 +31,80 @@ #endif /* lint */ @@ -2686,7 +2685,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c - nm++; - } - rv = nm; -+ zval patt; ++ zend_string *pattern; + uint32_t opts = 0; + pcre_cache_entry *pce; + zend_string *res; @@ -2694,9 +2693,9 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c + size_t rep_cnt = 0; + + opts |= PCRE2_MULTILINE; -+ convert_libmagic_pattern(&patt, (char*)pat, strlen(pat), opts); -+ if ((pce = pcre_get_compiled_regex_cache_ex(Z_STR(patt), 0)) == NULL) { -+ zval_ptr_dtor(&patt); ++ pattern = convert_libmagic_pattern((char*)pat, strlen(pat), opts); ++ if ((pce = pcre_get_compiled_regex_cache_ex(pattern, 0)) == NULL) { ++ zend_string_release(pattern); + rep_cnt = -1; + goto out; } @@ -2704,7 +2703,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c - file_regfree(&rx); - return rv; -} -+ zval_ptr_dtor(&patt); ++ zend_string_release(pattern); -protected int -file_regcomp(file_regex_t *rx, const char *pat, int flags) @@ -2799,7 +2798,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c diff -u libmagic.orig/magic.c libmagic/magic.c --- libmagic.orig/magic.c 2019-05-07 04:27:11.000000000 +0200 -+++ libmagic/magic.c 2020-08-21 15:28:20.818197700 +0200 ++++ libmagic/magic.c 2020-04-07 22:25:10.532971400 +0200 @@ -25,11 +25,6 @@ * SUCH DAMAGE. */ @@ -3263,8 +3262,8 @@ diff -u libmagic.orig/magic.c libmagic/magic.c public const char * magic_error(struct magic_set *ms) diff -u libmagic.orig/magic.h libmagic/magic.h ---- libmagic.orig/magic.h 2020-08-21 16:11:36.790038600 +0200 -+++ libmagic/magic.h 2020-08-21 15:28:20.818197700 +0200 +--- libmagic.orig/magic.h 2020-08-25 15:19:32.346097700 +0200 ++++ libmagic/magic.h 2020-04-07 22:25:10.548560600 +0200 @@ -124,6 +124,7 @@ const char *magic_getpath(const char *, int); @@ -3275,7 +3274,7 @@ diff -u libmagic.orig/magic.h libmagic/magic.h diff -u libmagic.orig/print.c libmagic/print.c --- libmagic.orig/print.c 2019-03-12 21:43:05.000000000 +0100 -+++ libmagic/print.c 2020-08-21 15:46:02.589327200 +0200 ++++ libmagic/print.c 2020-08-22 19:28:45.849356800 +0200 @@ -28,6 +28,7 @@ /* * print.c - debugging printout routines @@ -3349,7 +3348,7 @@ diff -u libmagic.orig/print.c libmagic/print.c goto out; diff -u libmagic.orig/readcdf.c libmagic/readcdf.c --- libmagic.orig/readcdf.c 2019-03-12 21:43:05.000000000 +0100 -+++ libmagic/readcdf.c 2020-08-21 15:28:20.818197700 +0200 ++++ libmagic/readcdf.c 2020-04-07 22:25:10.548560600 +0200 @@ -31,7 +31,11 @@ #include @@ -3468,7 +3467,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c if (i != -1) diff -u libmagic.orig/softmagic.c libmagic/softmagic.c --- libmagic.orig/softmagic.c 2019-05-17 04:24:59.000000000 +0200 -+++ libmagic/softmagic.c 2020-08-21 15:28:20.818197700 +0200 ++++ libmagic/softmagic.c 2020-08-25 15:15:35.784945600 +0200 @@ -43,6 +43,10 @@ #include #include "der.h" @@ -3641,12 +3640,11 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c return rv; case FILE_USE: -@@ -1926,6 +1904,61 @@ +@@ -1926,6 +1904,60 @@ return file_strncmp(a, b, len, flags); } -+public void -+convert_libmagic_pattern(zval *pattern, char *val, size_t len, uint32_t options) ++public zend_string* convert_libmagic_pattern(char *val, size_t len, uint32_t options) +{ + int i, j; + zend_string *t; @@ -3697,20 +3695,20 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c + ZSTR_VAL(t)[j]='\0'; + ZSTR_LEN(t) = j; + -+ ZVAL_NEW_STR(pattern, t); ++ return t; +} + private int magiccheck(struct magic_set *ms, struct magic *m) { -@@ -2104,65 +2137,77 @@ +@@ -2104,65 +2136,77 @@ break; } case FILE_REGEX: { - int rc; - file_regex_t rx; - const char *search; -+ zval pattern; ++ zend_string *pattern; + uint32_t options = 0; + pcre_cache_entry *pce; @@ -3729,11 +3727,11 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c + options |= PCRE2_CASELESS; + } + -+ convert_libmagic_pattern(&pattern, (char *)m->value.s, m->vallen, options); ++ pattern = convert_libmagic_pattern((char *)m->value.s, m->vallen, options); + + l = v = 0; -+ if ((pce = pcre_get_compiled_regex_cache(Z_STR(pattern))) == NULL) { -+ zval_ptr_dtor(&pattern); ++ if ((pce = pcre_get_compiled_regex_cache(pattern)) == NULL) { ++ zend_string_release(pattern); + return -1; } else { - regmatch_t pmatch; @@ -3769,7 +3767,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c + + if (Z_LVAL(retval) < 0) { + zval_ptr_dtor(&subpats); -+ zval_ptr_dtor(&pattern); ++ zend_string_release(pattern); + return -1; + } else if ((Z_LVAL(retval) > 0) && (Z_TYPE(subpats) == IS_ARRAY)) { + /* Need to fetch global match which equals pmatch[0] */ @@ -3796,7 +3794,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c + } else { +error_out: + zval_ptr_dtor(&subpats); -+ zval_ptr_dtor(&pattern); ++ zend_string_release(pattern); + return -1; + } } else { @@ -3825,7 +3823,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c - break; } + zval_ptr_dtor(&subpats); -+ zval_ptr_dtor(&pattern); ++ zend_string_release(pattern); } - file_regfree(&rx); - if (v == CAST(uint64_t, -1)) @@ -3835,7 +3833,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c case FILE_INDIRECT: diff -u libmagic.orig/strcasestr.c libmagic/strcasestr.c --- libmagic.orig/strcasestr.c 2014-09-11 17:05:33.000000000 +0200 -+++ libmagic/strcasestr.c 2020-06-15 11:16:08.173462200 +0200 ++++ libmagic/strcasestr.c 2019-12-19 20:37:55.833385900 +0100 @@ -39,6 +39,8 @@ #include "file.h" diff --git a/ext/fileinfo/libmagic/apprentice.c b/ext/fileinfo/libmagic/apprentice.c index 03d5d89b061cd..f6ff1cf26e6e7 100644 --- a/ext/fileinfo/libmagic/apprentice.c +++ b/ext/fileinfo/libmagic/apprentice.c @@ -2590,17 +2590,17 @@ getvalue(struct magic_set *ms, struct magic *m, const char **p, int action) return -1; } if (m->type == FILE_REGEX) { - zval pattern; + zend_string *pattern; int options = 0; pcre_cache_entry *pce; - convert_libmagic_pattern(&pattern, m->value.s, strlen(m->value.s), options); + pattern = convert_libmagic_pattern(m->value.s, strlen(m->value.s), options); - if ((pce = pcre_get_compiled_regex_cache(Z_STR(pattern))) == NULL) { - zval_dtor(&pattern); + if ((pce = pcre_get_compiled_regex_cache(pattern)) == NULL) { + zend_string_release(pattern); return -1; } - zval_dtor(&pattern); + zend_string_release(pattern); return 0; } diff --git a/ext/fileinfo/libmagic/file.h b/ext/fileinfo/libmagic/file.h index b588efcadb65b..c74c159569adc 100644 --- a/ext/fileinfo/libmagic/file.h +++ b/ext/fileinfo/libmagic/file.h @@ -503,8 +503,7 @@ protected void buffer_init(struct buffer *, int, const zend_stat_t *, protected void buffer_fini(struct buffer *); protected int buffer_fill(const struct buffer *); -public void -convert_libmagic_pattern(zval *pattern, char *val, size_t len, uint32_t options); +public zend_string* convert_libmagic_pattern(char *val, size_t len, uint32_t options); typedef struct { char *buf; diff --git a/ext/fileinfo/libmagic/funcs.c b/ext/fileinfo/libmagic/funcs.c index 6561f7458b7c5..a21e85ffc084a 100644 --- a/ext/fileinfo/libmagic/funcs.c +++ b/ext/fileinfo/libmagic/funcs.c @@ -516,7 +516,7 @@ file_printedlen(const struct magic_set *ms) protected int file_replace(struct magic_set *ms, const char *pat, const char *rep) { - zval patt; + zend_string *pattern; uint32_t opts = 0; pcre_cache_entry *pce; zend_string *res; @@ -524,13 +524,13 @@ file_replace(struct magic_set *ms, const char *pat, const char *rep) size_t rep_cnt = 0; opts |= PCRE2_MULTILINE; - convert_libmagic_pattern(&patt, (char*)pat, strlen(pat), opts); - if ((pce = pcre_get_compiled_regex_cache_ex(Z_STR(patt), 0)) == NULL) { - zval_ptr_dtor(&patt); + pattern = convert_libmagic_pattern((char*)pat, strlen(pat), opts); + if ((pce = pcre_get_compiled_regex_cache_ex(pattern, 0)) == NULL) { + zend_string_release(pattern); rep_cnt = -1; goto out; } - zval_ptr_dtor(&patt); + zend_string_release(pattern); repl = zend_string_init(rep, strlen(rep), 0); res = php_pcre_replace_impl(pce, NULL, ms->o.buf, strlen(ms->o.buf), repl, -1, &rep_cnt); diff --git a/ext/fileinfo/libmagic/softmagic.c b/ext/fileinfo/libmagic/softmagic.c index d71801cea5a86..fa272f625d30b 100644 --- a/ext/fileinfo/libmagic/softmagic.c +++ b/ext/fileinfo/libmagic/softmagic.c @@ -1904,8 +1904,7 @@ file_strncmp16(const char *a, const char *b, size_t len, uint32_t flags) return file_strncmp(a, b, len, flags); } -public void -convert_libmagic_pattern(zval *pattern, char *val, size_t len, uint32_t options) +public zend_string* convert_libmagic_pattern(char *val, size_t len, uint32_t options) { int i, j; zend_string *t; @@ -1956,7 +1955,7 @@ convert_libmagic_pattern(zval *pattern, char *val, size_t len, uint32_t options) ZSTR_VAL(t)[j]='\0'; ZSTR_LEN(t) = j; - ZVAL_NEW_STR(pattern, t); + return t; } private int @@ -2137,7 +2136,7 @@ magiccheck(struct magic_set *ms, struct magic *m) break; } case FILE_REGEX: { - zval pattern; + zend_string *pattern; uint32_t options = 0; pcre_cache_entry *pce; @@ -2147,11 +2146,11 @@ magiccheck(struct magic_set *ms, struct magic *m) options |= PCRE2_CASELESS; } - convert_libmagic_pattern(&pattern, (char *)m->value.s, m->vallen, options); + pattern = convert_libmagic_pattern((char *)m->value.s, m->vallen, options); l = v = 0; - if ((pce = pcre_get_compiled_regex_cache(Z_STR(pattern))) == NULL) { - zval_ptr_dtor(&pattern); + if ((pce = pcre_get_compiled_regex_cache(pattern)) == NULL) { + zend_string_release(pattern); return -1; } else { /* pce now contains the compiled regex */ @@ -2172,7 +2171,7 @@ magiccheck(struct magic_set *ms, struct magic *m) if (Z_LVAL(retval) < 0) { zval_ptr_dtor(&subpats); - zval_ptr_dtor(&pattern); + zend_string_release(pattern); return -1; } else if ((Z_LVAL(retval) > 0) && (Z_TYPE(subpats) == IS_ARRAY)) { /* Need to fetch global match which equals pmatch[0] */ @@ -2199,14 +2198,14 @@ magiccheck(struct magic_set *ms, struct magic *m) } else { error_out: zval_ptr_dtor(&subpats); - zval_ptr_dtor(&pattern); + zend_string_release(pattern); return -1; } } else { v = 1; } zval_ptr_dtor(&subpats); - zval_ptr_dtor(&pattern); + zend_string_release(pattern); } break; } diff --git a/ext/oci8/oci8_failover.c b/ext/oci8/oci8_failover.c index 1d9c4e58cf11b..5bbf0108e7fa7 100644 --- a/ext/oci8/oci8_failover.c +++ b/ext/oci8/oci8_failover.c @@ -69,7 +69,7 @@ sb4 callback_fn(void *svchp, void *envhp, void *fo_ctx, ub4 fo_type, ub4 fo_even returnValue = (sb4) Z_LVAL(retval); } - /* Setting params[0] to null so resource isn't destroyed on zval_dtor */ + /* Setting params[0] to null so resource isn't destroyed on zval_ptr_dtor */ ZVAL_NULL(¶ms[0]); /* Cleanup */ diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index a7c383bd3ab80..780de94707b1e 100644 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -1207,8 +1207,8 @@ int pdo_hash_methods(pdo_dbh_object_t *dbh_obj, int kind) } dbh->cls_methods[kind] = pemalloc(sizeof(HashTable), dbh->is_persistent); - zend_hash_init_ex(dbh->cls_methods[kind], 8, NULL, - dbh->is_persistent? cls_method_pdtor : cls_method_dtor, dbh->is_persistent, 0); + zend_hash_init(dbh->cls_methods[kind], 8, NULL, + dbh->is_persistent? cls_method_pdtor : cls_method_dtor, dbh->is_persistent); memset(&func, 0, sizeof(func)); diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index d2876573bccc6..95acae32c5bf9 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -911,8 +911,8 @@ static PHP_GINIT_FUNCTION(pgsql) #endif memset(pgsql_globals, 0, sizeof(zend_pgsql_globals)); /* Initialize notice message hash at MINIT only */ - zend_hash_init_ex(&pgsql_globals->notices, 0, NULL, ZVAL_PTR_DTOR, 1, 0); - zend_hash_init_ex(&pgsql_globals->hashes, 0, NULL, ZVAL_PTR_DTOR, 1, 0); + zend_hash_init(&pgsql_globals->notices, 0, NULL, ZVAL_PTR_DTOR, 1); + zend_hash_init(&pgsql_globals->hashes, 0, NULL, ZVAL_PTR_DTOR, 1); } /* }}} */ diff --git a/ext/standard/browscap.c b/ext/standard/browscap.c index abb5d69df8d84..e9ee1b1f0e176 100644 --- a/ext/standard/browscap.c +++ b/ext/standard/browscap.c @@ -418,8 +418,8 @@ static int browscap_read_file(char *filename, browser_data *browdata, int persis } browdata->htab = pemalloc(sizeof *browdata->htab, persistent); - zend_hash_init_ex(browdata->htab, 0, NULL, - persistent ? browscap_entry_dtor_persistent : browscap_entry_dtor, persistent, 0); + zend_hash_init(browdata->htab, 0, NULL, + persistent ? browscap_entry_dtor_persistent : browscap_entry_dtor, persistent); browdata->kv_size = 16 * 1024; browdata->kv_used = 0; diff --git a/ext/standard/password.c b/ext/standard/password.c index ea28ee6145cf0..de21569a44c8a 100644 --- a/ext/standard/password.c +++ b/ext/standard/password.c @@ -592,8 +592,8 @@ PHP_FUNCTION(password_get_info) add_assoc_string(return_value, "algoName", algo->name); if (algo->get_info && (FAILURE == algo->get_info(&options, hash))) { - zval_dtor(&options); - zval_dtor(return_value); + zval_ptr_dtor_nogc(&options); + zval_ptr_dtor_nogc(return_value); RETURN_NULL(); } add_assoc_zval(return_value, "options", &options); diff --git a/ext/standard/scanf.c b/ext/standard/scanf.c index 1464008243fb9..9f6986ab166e7 100644 --- a/ext/standard/scanf.c +++ b/ext/standard/scanf.c @@ -906,7 +906,7 @@ PHPAPI int php_sscanf_internal( char *string, char *format, __buf[0] = sch; __buf[1] = '\0'; current = args[objIndex++]; - zval_dtor(*current); + zval_ptr_dtor_nogc(*current); ZVAL_STRINGL( *current, __buf, 1); } else { add_index_stringl(return_value, objIndex++, &sch, 1); diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re index 1fc0e0dcda9ba..e7a48d4d8e0d3 100644 --- a/ext/standard/var_unserializer.re +++ b/ext/standard/var_unserializer.re @@ -597,7 +597,7 @@ string_key: if (!zend_verify_prop_assignable_by_ref(info, data, /* strict */ 1)) { zval_ptr_dtor(data); ZVAL_UNDEF(data); - zval_dtor(&key); + zval_ptr_dtor_nogc(&key); goto failure; } if (Z_ISREF_P(data)) { diff --git a/main/SAPI.c b/main/SAPI.c index e30d8d780cbeb..01ec31f72218f 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -54,7 +54,7 @@ static void _type_dtor(zval *zv) static void sapi_globals_ctor(sapi_globals_struct *sapi_globals) { memset(sapi_globals, 0, sizeof(*sapi_globals)); - zend_hash_init_ex(&sapi_globals->known_post_content_types, 8, NULL, _type_dtor, 1, 0); + zend_hash_init(&sapi_globals->known_post_content_types, 8, NULL, _type_dtor, 1); php_setup_sapi_content_types(); } diff --git a/win32/signal.c b/win32/signal.c index 41936f840fe74..23a5acbff9ef7 100644 --- a/win32/signal.c +++ b/win32/signal.c @@ -110,7 +110,7 @@ PHP_FUNCTION(sapi_windows_set_ctrl_handler) } if (!ZEND_FCI_INITIALIZED(fci)) { - zval_dtor(&ctrl_handler); + zval_ptr_dtor(&ctrl_handler); ZVAL_UNDEF(&ctrl_handler); if (!SetConsoleCtrlHandler(NULL, add)) { RETURN_FALSE; @@ -125,7 +125,7 @@ PHP_FUNCTION(sapi_windows_set_ctrl_handler) RETURN_FALSE; } - zval_dtor(&ctrl_handler); + zval_ptr_dtor_nogc(&ctrl_handler); ZVAL_COPY(&ctrl_handler, &fci.function_name); RETURN_TRUE; From 5ff15e2651850ba30dde69056436b8774fac9166 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Wed, 26 Aug 2020 14:45:13 +0200 Subject: [PATCH 100/170] Fix #64130: COM obj parameters passed by reference are not updated `ITypeInfo_GetIDsOfNames()` is supposed to fail with `E_NOTIMPL` for out-of-process servers, thus we should not remove the already available typeinfo of the object in this case. We also properly free the `byref_vals`. --- NEWS | 4 ++++ ext/com_dotnet/com_com.c | 4 +++- ext/com_dotnet/tests/bug64130.phpt | 27 +++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 ext/com_dotnet/tests/bug64130.phpt diff --git a/NEWS b/NEWS index 9666878056632..722f0a7070576 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,10 @@ PHP NEWS . Fixed bug #80007 (Potential type confusion in unixtojd() parameter parsing). (Andy Postnikov) +- COM: + . Fixed bug #64130 (COM obj parameters passed by reference are not updated). + (cmb) + - OPcache: . Fixed bug #80002 (calc free space for new interned string is wrong). (t-matsuno) diff --git a/ext/com_dotnet/com_com.c b/ext/com_dotnet/com_com.c index c9962835d14c7..5c6cc5ab14a48 100644 --- a/ext/com_dotnet/com_com.c +++ b/ext/com_dotnet/com_com.c @@ -439,8 +439,9 @@ HRESULT php_com_get_id_of_name(php_com_dotnet_object *obj, char *name, if (obj->typeinfo) { hr = ITypeInfo_GetIDsOfNames(obj->typeinfo, &olename, 1, dispid); if (FAILED(hr)) { + HRESULT hr1 = hr; hr = IDispatch_GetIDsOfNames(V_DISPATCH(&obj->v), &IID_NULL, &olename, 1, LOCALE_SYSTEM_DEFAULT, dispid); - if (SUCCEEDED(hr)) { + if (SUCCEEDED(hr) && hr1 != E_NOTIMPL) { /* fall back on IDispatch direct */ ITypeInfo_Release(obj->typeinfo); obj->typeinfo = NULL; @@ -588,6 +589,7 @@ int php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_function * } } efree(vargs); + if (byref_vals) efree(byref_vals); } return SUCCEEDED(hr) ? SUCCESS : FAILURE; diff --git a/ext/com_dotnet/tests/bug64130.phpt b/ext/com_dotnet/tests/bug64130.phpt new file mode 100644 index 0000000000000..0f8e083295cc0 --- /dev/null +++ b/ext/com_dotnet/tests/bug64130.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #64130 (COM obj parameters passed by reference are not updated) +--SKIPIF-- +getMessage()}"); +} +$ie->quit(); +?> +--FILE-- +clientToWindow($x, $y); +} catch (com_exception $ex) {} +var_dump($x > 0, $y > 0); +$ie->quit(); +?> +--EXPECT-- +bool(true) +bool(true) From 75ac3f1cbabf0a88a092abcc31635a91215912de Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 25 Aug 2020 13:48:50 +0200 Subject: [PATCH 101/170] Separate COM::__construct()s $server_name array This may otherwise be modified. --- ext/com_dotnet/com_com.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/com_dotnet/com_com.c b/ext/com_dotnet/com_com.c index 5c6cc5ab14a48..2077e39c4affc 100644 --- a/ext/com_dotnet/com_com.c +++ b/ext/com_dotnet/com_com.c @@ -61,7 +61,7 @@ PHP_FUNCTION(com_create_instance) &module_name, &module_name_len, &server_name, &server_name_len, &cp, &typelib_name, &typelib_name_len) && FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, - ZEND_NUM_ARGS(), "sa|ls", + ZEND_NUM_ARGS(), "sa/|ls", &module_name, &module_name_len, &server_params, &cp, &typelib_name, &typelib_name_len)) { From 86cd009718bddfaabfcf87f0a18f78a381ede465 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 26 Aug 2020 15:09:42 +0200 Subject: [PATCH 102/170] Fix pass by ref error for named params --- .../named_params/cannot_pass_by_ref.phpt | 13 ++++++++++ Zend/zend_vm_def.h | 15 +++++------ Zend/zend_vm_execute.h | 25 ++++++++----------- 3 files changed, 30 insertions(+), 23 deletions(-) create mode 100644 Zend/tests/named_params/cannot_pass_by_ref.phpt diff --git a/Zend/tests/named_params/cannot_pass_by_ref.phpt b/Zend/tests/named_params/cannot_pass_by_ref.phpt new file mode 100644 index 0000000000000..395ee8fa5aa71 --- /dev/null +++ b/Zend/tests/named_params/cannot_pass_by_ref.phpt @@ -0,0 +1,13 @@ +--TEST-- +Cannot pass by reference error with named parameters +--FILE-- +getMessage(), "\n"; +} +?> +--EXPECT-- +Cannot pass parameter 2 by reference diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 64c0ac61dbbb0..4d72cf31ad7a9 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -4587,17 +4587,14 @@ ZEND_VM_HOT_HANDLER(65, ZEND_SEND_VAL, CONST|TMPVAR, CONST|UNUSED|NUM) ZEND_VM_NEXT_OPCODE(); } -ZEND_VM_COLD_HELPER(zend_cannot_pass_by_ref_helper, ANY, ANY) +ZEND_VM_COLD_HELPER(zend_cannot_pass_by_ref_helper, ANY, ANY, uint32_t _arg_num, zval *_arg) { USE_OPLINE - zval *arg; - uint32_t arg_num = opline->op2.num; SAVE_OPLINE(); - zend_throw_error(NULL, "Cannot pass parameter %d by reference", arg_num); + zend_throw_error(NULL, "Cannot pass parameter %d by reference", _arg_num); FREE_OP1(); - arg = ZEND_CALL_VAR(EX(call), opline->result.var); - ZVAL_UNDEF(arg); + ZVAL_UNDEF(_arg); HANDLE_EXCEPTION(); } @@ -4626,7 +4623,7 @@ ZEND_VM_HOT_SEND_HANDLER(116, ZEND_SEND_VAL_EX, CONST|TMP, CONST|UNUSED|NUM, SPE } } else if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) { ZEND_VM_C_LABEL(send_val_by_ref): - ZEND_VM_DISPATCH_TO_HELPER(zend_cannot_pass_by_ref_helper); + ZEND_VM_DISPATCH_TO_HELPER(zend_cannot_pass_by_ref_helper, _arg_num, arg_num, _arg, arg); } value = GET_OP1_ZVAL_PTR(BP_VAR_R); ZVAL_COPY_VALUE(arg, value); @@ -9564,11 +9561,11 @@ ZEND_VM_HOT_TYPE_SPEC_HANDLER(ZEND_SEND_VAL_EX, op->op2_type == IS_UNUSED && op- zval *value, *arg; uint32_t arg_num = opline->op2.num; + arg = ZEND_CALL_VAR(EX(call), opline->result.var); if (QUICK_ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) { - ZEND_VM_DISPATCH_TO_HELPER(zend_cannot_pass_by_ref_helper); + ZEND_VM_DISPATCH_TO_HELPER(zend_cannot_pass_by_ref_helper, _arg_num, arg_num, _arg, arg); } value = GET_OP1_ZVAL_PTR(BP_VAR_R); - arg = ZEND_CALL_VAR(EX(call), opline->result.var); ZVAL_COPY_VALUE(arg, value); ZEND_VM_NEXT_OPCODE(); } diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 087d04931c572..a46b39d027a50 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -1837,17 +1837,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_GENERATOR_CREATE_SPEC_HANDLER( } } -static zend_never_inline ZEND_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_cannot_pass_by_ref_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS) +static zend_never_inline ZEND_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_cannot_pass_by_ref_helper_SPEC(uint32_t _arg_num, zval *_arg ZEND_OPCODE_HANDLER_ARGS_DC) { USE_OPLINE - zval *arg; - uint32_t arg_num = opline->op2.num; SAVE_OPLINE(); - zend_throw_error(NULL, "Cannot pass parameter %d by reference", arg_num); + zend_throw_error(NULL, "Cannot pass parameter %d by reference", _arg_num); FREE_OP(opline->op1_type, opline->op1.var); - arg = ZEND_CALL_VAR(EX(call), opline->result.var); - ZVAL_UNDEF(arg); + ZVAL_UNDEF(_arg); HANDLE_EXCEPTION(); } @@ -4727,11 +4724,11 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SIMPLE zval *value, *arg; uint32_t arg_num = opline->op2.num; + arg = ZEND_CALL_VAR(EX(call), opline->result.var); if (QUICK_ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) { - ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)); + ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(arg_num, arg ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC)); } value = RT_CONSTANT(opline, opline->op1); - arg = ZEND_CALL_VAR(EX(call), opline->result.var); ZVAL_COPY_VALUE(arg, value); ZEND_VM_NEXT_OPCODE(); } @@ -6115,7 +6112,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SPEC_CONST_CONST_H } } else if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) { send_val_by_ref: - ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)); + ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(arg_num, arg ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC)); } value = RT_CONSTANT(opline, opline->op1); ZVAL_COPY_VALUE(arg, value); @@ -9151,7 +9148,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SPEC_CONST_UNUSED_ } } else if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) { send_val_by_ref: - ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)); + ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(arg_num, arg ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC)); } value = RT_CONSTANT(opline, opline->op1); ZVAL_COPY_VALUE(arg, value); @@ -9188,7 +9185,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SPEC_C } } else if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) { send_val_by_ref: - ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)); + ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(arg_num, arg ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC)); } value = RT_CONSTANT(opline, opline->op1); ZVAL_COPY_VALUE(arg, value); @@ -18631,7 +18628,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SPEC_TMP_CONST_HAN } } else if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) { send_val_by_ref: - ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)); + ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(arg_num, arg ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC)); } value = _get_zval_ptr_tmp(opline->op1.var EXECUTE_DATA_CC); ZVAL_COPY_VALUE(arg, value); @@ -19455,7 +19452,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SPEC_TMP_UNUSED_HA } } else if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) { send_val_by_ref: - ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)); + ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(arg_num, arg ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC)); } value = _get_zval_ptr_tmp(opline->op1.var EXECUTE_DATA_CC); ZVAL_COPY_VALUE(arg, value); @@ -19492,7 +19489,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SPEC_T } } else if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) { send_val_by_ref: - ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)); + ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(arg_num, arg ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC)); } value = _get_zval_ptr_tmp(opline->op1.var EXECUTE_DATA_CC); ZVAL_COPY_VALUE(arg, value); From 55798e0e391d18d7e7d321c1149b12aa89d7d4ff Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 26 Aug 2020 15:19:23 +0200 Subject: [PATCH 103/170] Lowercase method name in zend_call_method() --- Zend/zend_interfaces.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c index 16c193e42060e..808de7c170dac 100644 --- a/Zend/zend_interfaces.c +++ b/Zend/zend_interfaces.c @@ -53,7 +53,7 @@ ZEND_API zval* zend_call_method(zend_object *object, zend_class_entry *obj_ce, z } if (!fn_proxy || !*fn_proxy) { if (EXPECTED(obj_ce)) { - fn = zend_hash_str_find_ptr( + fn = zend_hash_str_find_ptr_lc( &obj_ce->function_table, function_name, function_name_len); if (UNEXPECTED(fn == NULL)) { /* error at c-level */ From 1b7ee6db884b7574893bc737a6f7fb5fdf9d619b Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Wed, 26 Aug 2020 15:31:26 +0200 Subject: [PATCH 104/170] Fix com_safearray_proxy related memory management issues --- ext/com_dotnet/com_saproxy.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ext/com_dotnet/com_saproxy.c b/ext/com_dotnet/com_saproxy.c index bde1986992137..fa6ee347622ea 100644 --- a/ext/com_dotnet/com_saproxy.c +++ b/ext/com_dotnet/com_saproxy.c @@ -114,6 +114,8 @@ static zval *saproxy_read_dimension(zval *object, zval *offset, int type, zval * Z_STRLEN(proxy->indices[0]), DISPATCH_METHOD|DISPATCH_PROPERTYGET, &v, proxy->dimensions, args, 0); + efree(args); + if (res == SUCCESS) { php_com_zval_from_variant(rv, &v, proxy->obj->code_page); VariantClear(&v); @@ -387,7 +389,7 @@ static zend_object* saproxy_clone(zval *object) memcpy(cloneproxy, proxy, sizeof(*cloneproxy)); Z_ADDREF_P(cloneproxy->zobj); - cloneproxy->indices = safe_emalloc(cloneproxy->dimensions, sizeof(zval *), 0); + cloneproxy->indices = safe_emalloc(cloneproxy->dimensions, sizeof(zval), 0); clone_indices(cloneproxy, proxy, proxy->dimensions); return &cloneproxy->std; @@ -437,7 +439,7 @@ int php_com_saproxy_create(zval *com_object, zval *proxy_out, zval *index) } Z_ADDREF_P(proxy->zobj); - proxy->indices = safe_emalloc(proxy->dimensions, sizeof(zval *), 0); + proxy->indices = safe_emalloc(proxy->dimensions, sizeof(zval), 0); if (rel) { clone_indices(proxy, rel, rel->dimensions); From 247105ae1ae2a04608078f7fcfe88dacab9f55a4 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 26 Aug 2020 16:10:29 +0200 Subject: [PATCH 105/170] Property handle read_property exception in fetch_property_address Otherwise we leak (and corrupt uninitialized_zval). --- ...ception_during_by_reference_magic_get.phpt | 23 +++++++++++++++++++ Zend/zend_execute.c | 4 ++++ 2 files changed, 27 insertions(+) create mode 100644 Zend/tests/exception_during_by_reference_magic_get.phpt diff --git a/Zend/tests/exception_during_by_reference_magic_get.phpt b/Zend/tests/exception_during_by_reference_magic_get.phpt new file mode 100644 index 0000000000000..5732e8cc5af79 --- /dev/null +++ b/Zend/tests/exception_during_by_reference_magic_get.phpt @@ -0,0 +1,23 @@ +--TEST-- +Exception thrown by __get() during =& assignment +--FILE-- +x =& $y; +} catch (Exception $e) { + echo $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +Foobar diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index c5b502501e7d5..6a6ad61094ed6 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -2872,6 +2872,10 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c } return; } + if (UNEXPECTED(EG(exception))) { + ZVAL_ERROR(result); + return; + } } else if (UNEXPECTED(Z_ISERROR_P(ptr))) { ZVAL_ERROR(result); return; From 9e58187e9b750e9b0c9d43b99915ba1eaafcce0c Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 15 Aug 2020 20:01:10 +0200 Subject: [PATCH 106/170] Voidify functions in zend.c --- Zend/zend.c | 4 +--- Zend/zend.h | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Zend/zend.c b/Zend/zend.c index 775a1cdb69a43..d32b1e2b7e133 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -803,7 +803,7 @@ static zend_bool php_auto_globals_create_globals(zend_string *name) /* {{{ */ } /* }}} */ -int zend_startup(zend_utility_functions *utility_functions) /* {{{ */ +void zend_startup(zend_utility_functions *utility_functions) /* {{{ */ { #ifdef ZTS zend_compiler_globals *compiler_globals; @@ -969,8 +969,6 @@ int zend_startup(zend_utility_functions *utility_functions) /* {{{ */ tsrm_set_new_thread_end_handler(zend_new_thread_end_handler); tsrm_set_shutdown_handler(zend_interned_strings_dtor); #endif - - return SUCCESS; } /* }}} */ diff --git a/Zend/zend.h b/Zend/zend.h index 5963ca7d9a7ac..690b2743a9464 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -227,7 +227,7 @@ typedef size_t (*zend_write_func_t)(const char *str, size_t str_length); #define zend_first_try EG(bailout)=NULL; zend_try BEGIN_EXTERN_C() -int zend_startup(zend_utility_functions *utility_functions); +void zend_startup(zend_utility_functions *utility_functions); void zend_shutdown(void); void zend_register_standard_ini_entries(void); int zend_post_startup(void); From 826c7880830a789c15afd93ef86b636dbb645269 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 15 Aug 2020 20:16:58 +0200 Subject: [PATCH 107/170] Boolify functions in zend.c --- Zend/zend.c | 16 ++++----- Zend/zend.h | 12 +++---- Zend/zend_compile.c | 80 ++++++++++++++++++++++----------------------- Zend/zend_compile.h | 16 ++++----- main/main.c | 4 +-- 5 files changed, 64 insertions(+), 64 deletions(-) diff --git a/Zend/zend.c b/Zend/zend.c index d32b1e2b7e133..34de8ff88ec13 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -74,7 +74,7 @@ ZEND_API zend_class_entry *zend_standard_class_def = NULL; ZEND_API size_t (*zend_printf)(const char *format, ...); ZEND_API zend_write_func_t zend_write; ZEND_API FILE *(*zend_fopen)(const char *filename, zend_string **opened_path); -ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle); +ZEND_API ZEND_RESULT_CODE (*zend_stream_open_function)(const char *filename, zend_file_handle *handle); ZEND_API void (*zend_ticks_function)(int ticks); ZEND_API void (*zend_interrupt_function)(zend_execute_data *execute_data); ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message); @@ -82,9 +82,9 @@ void (*zend_printf_to_smart_string)(smart_string *buf, const char *format, va_li void (*zend_printf_to_smart_str)(smart_str *buf, const char *format, va_list ap); ZEND_API char *(*zend_getenv)(const char *name, size_t name_len); ZEND_API zend_string *(*zend_resolve_path)(const char *filename, size_t filename_len); -ZEND_API int (*zend_post_startup_cb)(void) = NULL; +ZEND_API ZEND_RESULT_CODE (*zend_post_startup_cb)(void) = NULL; ZEND_API void (*zend_post_shutdown_cb)(void) = NULL; -ZEND_API int (*zend_preload_autoload)(zend_string *filename) = NULL; +ZEND_API ZEND_RESULT_CODE (*zend_preload_autoload)(zend_string *filename) = NULL; /* This callback must be signal handler safe! */ void (*zend_on_timeout)(int seconds); @@ -365,7 +365,7 @@ static void print_flat_hash(HashTable *ht) /* {{{ */ } /* }}} */ -ZEND_API int zend_make_printable_zval(zval *expr, zval *expr_copy) /* {{{ */ +ZEND_API bool zend_make_printable_zval(zval *expr, zval *expr_copy) /* {{{ */ { if (Z_TYPE_P(expr) == IS_STRING) { return 0; @@ -1019,7 +1019,7 @@ static void zend_resolve_property_types(void) /* {{{ */ /* Unlink the global (r/o) copies of the class, function and constant tables, * and use a fresh r/w copy for the startup thread */ -int zend_post_startup(void) /* {{{ */ +ZEND_RESULT_CODE zend_post_startup(void) /* {{{ */ { #ifdef ZTS zend_encoding **script_encoding_list; @@ -1031,7 +1031,7 @@ int zend_post_startup(void) /* {{{ */ zend_resolve_property_types(); if (zend_post_startup_cb) { - int (*cb)(void) = zend_post_startup_cb; + ZEND_RESULT_CODE (*cb)(void) = zend_post_startup_cb; zend_post_startup_cb = NULL; if (cb() != SUCCESS) { @@ -1663,13 +1663,13 @@ ZEND_API ZEND_COLD void zend_user_exception_handler(void) /* {{{ */ } } /* }}} */ -ZEND_API int zend_execute_scripts(int type, zval *retval, int file_count, ...) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_execute_scripts(int type, zval *retval, int file_count, ...) /* {{{ */ { va_list files; int i; zend_file_handle *file_handle; zend_op_array *op_array; - int ret = SUCCESS; + ZEND_RESULT_CODE ret = SUCCESS; va_start(files, file_count); for (i = 0; i < file_count; i++) { diff --git a/Zend/zend.h b/Zend/zend.h index 690b2743a9464..fba45e0270c1d 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -195,7 +195,7 @@ typedef struct _zend_utility_functions { zval *(*get_configuration_directive)(zend_string *name); void (*ticks_function)(int ticks); void (*on_timeout)(int seconds); - int (*stream_open_function)(const char *filename, zend_file_handle *handle); + ZEND_RESULT_CODE (*stream_open_function)(const char *filename, zend_file_handle *handle); void (*printf_to_smart_string_function)(smart_string *buf, const char *format, va_list ap); void (*printf_to_smart_str_function)(smart_str *buf, const char *format, va_list ap); char *(*getenv_function)(const char *name, size_t name_len); @@ -230,7 +230,7 @@ BEGIN_EXTERN_C() void zend_startup(zend_utility_functions *utility_functions); void zend_shutdown(void); void zend_register_standard_ini_entries(void); -int zend_post_startup(void); +ZEND_RESULT_CODE zend_post_startup(void); void zend_set_utility_values(zend_utility_values *utility_values); ZEND_API ZEND_COLD ZEND_NORETURN void _zend_bailout(const char *filename, uint32_t lineno); @@ -246,7 +246,7 @@ ZEND_API size_t zend_spprintf_unchecked(char **message, size_t max_len, const ch ZEND_API zend_string *zend_strpprintf_unchecked(size_t max_len, const char *format, ...); ZEND_API const char *get_zend_version(void); -ZEND_API int zend_make_printable_zval(zval *expr, zval *expr_copy); +ZEND_API bool zend_make_printable_zval(zval *expr, zval *expr_copy); ZEND_API size_t zend_print_zval(zval *expr, int indent); ZEND_API void zend_print_zval_r(zval *expr, int indent); ZEND_API zend_string *zend_print_zval_r_to_str(zval *expr, int indent); @@ -283,18 +283,18 @@ extern ZEND_API void (*zend_ticks_function)(int ticks); extern ZEND_API void (*zend_interrupt_function)(zend_execute_data *execute_data); extern ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message); extern ZEND_API void (*zend_on_timeout)(int seconds); -extern ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle); +extern ZEND_API ZEND_RESULT_CODE (*zend_stream_open_function)(const char *filename, zend_file_handle *handle); extern void (*zend_printf_to_smart_string)(smart_string *buf, const char *format, va_list ap); extern void (*zend_printf_to_smart_str)(smart_str *buf, const char *format, va_list ap); extern ZEND_API char *(*zend_getenv)(const char *name, size_t name_len); extern ZEND_API zend_string *(*zend_resolve_path)(const char *filename, size_t filename_len); /* These two callbacks are especially for opcache */ -extern ZEND_API int (*zend_post_startup_cb)(void); +extern ZEND_API ZEND_RESULT_CODE (*zend_post_startup_cb)(void); extern ZEND_API void (*zend_post_shutdown_cb)(void); /* Callback for loading of not preloaded part of the script */ -extern ZEND_API int (*zend_preload_autoload)(zend_string *filename); +extern ZEND_API ZEND_RESULT_CODE (*zend_preload_autoload)(zend_string *filename); ZEND_API ZEND_COLD void zend_error(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3); ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_noreturn(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3); diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index a75c282d2d47e..3396c933e6658 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1076,7 +1076,7 @@ static zend_never_inline ZEND_COLD ZEND_NORETURN void do_bind_function_error(zen } } -ZEND_API int do_bind_function(zval *lcname) /* {{{ */ +ZEND_API ZEND_RESULT_CODE do_bind_function(zval *lcname) /* {{{ */ { zend_function *function; zval *rtd_key, *zv; @@ -1097,7 +1097,7 @@ ZEND_API int do_bind_function(zval *lcname) /* {{{ */ } /* }}} */ -ZEND_API int do_bind_class(zval *lcname, zend_string *lc_parent_name) /* {{{ */ +ZEND_API ZEND_RESULT_CODE do_bind_class(zval *lcname, zend_string *lc_parent_name) /* {{{ */ { zend_class_entry *ce; zval *rtd_key, *zv; @@ -1356,7 +1356,7 @@ ZEND_API void zend_do_delayed_early_binding(zend_op_array *op_array, uint32_t fi } /* }}} */ -ZEND_API zend_string *zend_mangle_property_name(const char *src1, size_t src1_length, const char *src2, size_t src2_length, int internal) /* {{{ */ +ZEND_API zend_string *zend_mangle_property_name(const char *src1, size_t src1_length, const char *src2, size_t src2_length, bool internal) /* {{{ */ { size_t prop_name_length = 1 + src1_length + 1 + src2_length; zend_string *prop_name = zend_string_alloc(prop_name_length, internal); @@ -1376,7 +1376,7 @@ static zend_always_inline size_t zend_strnlen(const char* s, size_t maxlen) /* { } /* }}} */ -ZEND_API int zend_unmangle_property_name_ex(const zend_string *name, const char **class_name, const char **prop_name, size_t *prop_len) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_unmangle_property_name_ex(const zend_string *name, const char **class_name, const char **prop_name, size_t *prop_len) /* {{{ */ { size_t class_name_len; size_t anonclass_src_len; @@ -1749,10 +1749,10 @@ zend_bool zend_is_auto_global(zend_string *name) /* {{{ */ } /* }}} */ -int zend_register_auto_global(zend_string *name, zend_bool jit, zend_auto_global_callback auto_global_callback) /* {{{ */ +ZEND_RESULT_CODE zend_register_auto_global(zend_string *name, zend_bool jit, zend_auto_global_callback auto_global_callback) /* {{{ */ { zend_auto_global auto_global; - int retval; + ZEND_RESULT_CODE retval; auto_global.name = name; auto_global.auto_global_callback = auto_global_callback; @@ -2105,7 +2105,7 @@ static inline uint32_t zend_emit_jump(uint32_t opnum_target) /* {{{ */ } /* }}} */ -ZEND_API int zend_is_smart_branch(const zend_op *opline) /* {{{ */ +ZEND_API bool zend_is_smart_branch(const zend_op *opline) /* {{{ */ { switch (opline->opcode) { case ZEND_IS_IDENTICAL: @@ -2419,7 +2419,7 @@ static void zend_emit_return_type_check( } /* }}} */ -void zend_emit_final_return(int return_one) /* {{{ */ +void zend_emit_final_return(bool return_one) /* {{{ */ { znode zn; zend_op *ret; @@ -2597,7 +2597,7 @@ static void zend_compile_class_ref(znode *result, zend_ast *name_ast, uint32_t f } /* }}} */ -static int zend_try_compile_cv(znode *result, zend_ast *ast) /* {{{ */ +static ZEND_RESULT_CODE zend_try_compile_cv(znode *result, zend_ast *ast) /* {{{ */ { zend_ast *name_ast = ast->child[0]; if (name_ast->kind == ZEND_AST_ZVAL) { @@ -2628,7 +2628,7 @@ static int zend_try_compile_cv(znode *result, zend_ast *ast) /* {{{ */ } /* }}} */ -static zend_op *zend_compile_simple_var_no_cv(znode *result, zend_ast *ast, uint32_t type, int delayed) /* {{{ */ +static zend_op *zend_compile_simple_var_no_cv(znode *result, zend_ast *ast, uint32_t type, bool delayed) /* {{{ */ { zend_ast *name_ast = ast->child[0]; znode name_node; @@ -2679,7 +2679,7 @@ static zend_bool this_guaranteed_exists() /* {{{ */ } /* }}} */ -static zend_op *zend_compile_simple_var(znode *result, zend_ast *ast, uint32_t type, int delayed) /* {{{ */ +static zend_op *zend_compile_simple_var(znode *result, zend_ast *ast, uint32_t type, bool delayed) /* {{{ */ { if (is_this_fetch(ast)) { zend_op *opline = zend_emit_op(result, ZEND_FETCH_THIS, NULL, NULL); @@ -2814,7 +2814,7 @@ static zend_op *zend_delayed_compile_prop(znode *result, zend_ast *ast, uint32_t } /* }}} */ -static zend_op *zend_compile_prop(znode *result, zend_ast *ast, uint32_t type, int by_ref) /* {{{ */ +static zend_op *zend_compile_prop(znode *result, zend_ast *ast, uint32_t type, bool by_ref) /* {{{ */ { uint32_t offset = zend_delayed_compile_begin(); zend_op *opline = zend_delayed_compile_prop(result, ast, type); @@ -2825,7 +2825,7 @@ static zend_op *zend_compile_prop(znode *result, zend_ast *ast, uint32_t type, i } /* }}} */ -zend_op *zend_compile_static_prop(znode *result, zend_ast *ast, uint32_t type, int by_ref, int delayed) /* {{{ */ +zend_op *zend_compile_static_prop(znode *result, zend_ast *ast, uint32_t type, bool by_ref, bool delayed) /* {{{ */ { zend_ast *class_ast = ast->child[0]; zend_ast *prop_ast = ast->child[1]; @@ -3637,7 +3637,7 @@ static inline zend_bool zend_args_contain_unpack_or_named(zend_ast_list *args) / } /* }}} */ -int zend_compile_func_strlen(znode *result, zend_ast_list *args) /* {{{ */ +ZEND_RESULT_CODE zend_compile_func_strlen(znode *result, zend_ast_list *args) /* {{{ */ { znode arg_node; @@ -3657,7 +3657,7 @@ int zend_compile_func_strlen(znode *result, zend_ast_list *args) /* {{{ */ } /* }}} */ -int zend_compile_func_typecheck(znode *result, zend_ast_list *args, uint32_t type) /* {{{ */ +ZEND_RESULT_CODE zend_compile_func_typecheck(znode *result, zend_ast_list *args, uint32_t type) /* {{{ */ { znode arg_node; zend_op *opline; @@ -3677,7 +3677,7 @@ int zend_compile_func_typecheck(znode *result, zend_ast_list *args, uint32_t typ } /* }}} */ -static int zend_compile_func_is_scalar(znode *result, zend_ast_list *args) /* {{{ */ +static ZEND_RESULT_CODE zend_compile_func_is_scalar(znode *result, zend_ast_list *args) /* {{{ */ { znode arg_node; zend_op *opline; @@ -3692,7 +3692,7 @@ static int zend_compile_func_is_scalar(znode *result, zend_ast_list *args) /* {{ return SUCCESS; } -int zend_compile_func_cast(znode *result, zend_ast_list *args, uint32_t type) /* {{{ */ +ZEND_RESULT_CODE zend_compile_func_cast(znode *result, zend_ast_list *args, uint32_t type) /* {{{ */ { znode arg_node; zend_op *opline; @@ -3712,7 +3712,7 @@ int zend_compile_func_cast(znode *result, zend_ast_list *args, uint32_t type) /* } /* }}} */ -int zend_compile_func_defined(znode *result, zend_ast_list *args) /* {{{ */ +ZEND_RESULT_CODE zend_compile_func_defined(znode *result, zend_ast_list *args) /* {{{ */ { zend_string *name; zend_op *opline; @@ -3744,7 +3744,7 @@ int zend_compile_func_defined(znode *result, zend_ast_list *args) /* {{{ */ } /* }}} */ -int zend_compile_func_chr(znode *result, zend_ast_list *args) /* {{{ */ +ZEND_RESULT_CODE zend_compile_func_chr(znode *result, zend_ast_list *args) /* {{{ */ { if (args->children == 1 && @@ -3762,7 +3762,7 @@ int zend_compile_func_chr(znode *result, zend_ast_list *args) /* {{{ */ } /* }}} */ -int zend_compile_func_ord(znode *result, zend_ast_list *args) /* {{{ */ +ZEND_RESULT_CODE zend_compile_func_ord(znode *result, zend_ast_list *args) /* {{{ */ { if (args->children == 1 && args->child[0]->kind == ZEND_AST_ZVAL && @@ -3784,7 +3784,7 @@ static zend_bool fbc_is_finalized(zend_function *fbc) { return !ZEND_USER_CODE(fbc->type) || (fbc->common.fn_flags & ZEND_ACC_DONE_PASS_TWO); } -static int zend_try_compile_ct_bound_init_user_func(zend_ast *name_ast, uint32_t num_args) /* {{{ */ +static ZEND_RESULT_CODE zend_try_compile_ct_bound_init_user_func(zend_ast *name_ast, uint32_t num_args) /* {{{ */ { zend_string *name, *lcname; zend_function *fbc; @@ -3837,7 +3837,7 @@ static void zend_compile_init_user_func(zend_ast *name_ast, uint32_t num_args, z /* }}} */ /* cufa = call_user_func_array */ -int zend_compile_func_cufa(znode *result, zend_ast_list *args, zend_string *lcname) /* {{{ */ +ZEND_RESULT_CODE zend_compile_func_cufa(znode *result, zend_ast_list *args, zend_string *lcname) /* {{{ */ { znode arg_node; @@ -3887,7 +3887,7 @@ int zend_compile_func_cufa(znode *result, zend_ast_list *args, zend_string *lcna /* }}} */ /* cuf = call_user_func */ -int zend_compile_func_cuf(znode *result, zend_ast_list *args, zend_string *lcname) /* {{{ */ +ZEND_RESULT_CODE zend_compile_func_cuf(znode *result, zend_ast_list *args, zend_string *lcname) /* {{{ */ { uint32_t i; @@ -3958,7 +3958,7 @@ static void zend_compile_assert(znode *result, zend_ast_list *args, zend_string } /* }}} */ -static int zend_compile_func_in_array(znode *result, zend_ast_list *args) /* {{{ */ +static ZEND_RESULT_CODE zend_compile_func_in_array(znode *result, zend_ast_list *args) /* {{{ */ { zend_bool strict = 0; znode array, needly; @@ -4043,7 +4043,7 @@ static int zend_compile_func_in_array(znode *result, zend_ast_list *args) /* {{{ } /* }}} */ -int zend_compile_func_count(znode *result, zend_ast_list *args, zend_string *lcname) /* {{{ */ +ZEND_RESULT_CODE zend_compile_func_count(znode *result, zend_ast_list *args, zend_string *lcname) /* {{{ */ { znode arg_node; zend_op *opline; @@ -4060,7 +4060,7 @@ int zend_compile_func_count(znode *result, zend_ast_list *args, zend_string *lcn } /* }}} */ -int zend_compile_func_get_class(znode *result, zend_ast_list *args) /* {{{ */ +ZEND_RESULT_CODE zend_compile_func_get_class(znode *result, zend_ast_list *args) /* {{{ */ { if (args->children == 0) { zend_emit_op_tmp(result, ZEND_GET_CLASS, NULL, NULL); @@ -4078,7 +4078,7 @@ int zend_compile_func_get_class(znode *result, zend_ast_list *args) /* {{{ */ } /* }}} */ -int zend_compile_func_get_called_class(znode *result, zend_ast_list *args) /* {{{ */ +ZEND_RESULT_CODE zend_compile_func_get_called_class(znode *result, zend_ast_list *args) /* {{{ */ { if (args->children != 0) { return FAILURE; @@ -4089,7 +4089,7 @@ int zend_compile_func_get_called_class(znode *result, zend_ast_list *args) /* {{ } /* }}} */ -int zend_compile_func_gettype(znode *result, zend_ast_list *args) /* {{{ */ +ZEND_RESULT_CODE zend_compile_func_gettype(znode *result, zend_ast_list *args) /* {{{ */ { znode arg_node; @@ -4103,7 +4103,7 @@ int zend_compile_func_gettype(znode *result, zend_ast_list *args) /* {{{ */ } /* }}} */ -int zend_compile_func_num_args(znode *result, zend_ast_list *args) /* {{{ */ +ZEND_RESULT_CODE zend_compile_func_num_args(znode *result, zend_ast_list *args) /* {{{ */ { if (CG(active_op_array)->function_name && args->children == 0) { zend_emit_op_tmp(result, ZEND_FUNC_NUM_ARGS, NULL, NULL); @@ -4114,7 +4114,7 @@ int zend_compile_func_num_args(znode *result, zend_ast_list *args) /* {{{ */ } /* }}} */ -int zend_compile_func_get_args(znode *result, zend_ast_list *args) /* {{{ */ +ZEND_RESULT_CODE zend_compile_func_get_args(znode *result, zend_ast_list *args) /* {{{ */ { if (CG(active_op_array)->function_name && args->children == 0) { zend_emit_op_tmp(result, ZEND_FUNC_GET_ARGS, NULL, NULL); @@ -4125,7 +4125,7 @@ int zend_compile_func_get_args(znode *result, zend_ast_list *args) /* {{{ */ } /* }}} */ -int zend_compile_func_array_key_exists(znode *result, zend_ast_list *args) /* {{{ */ +ZEND_RESULT_CODE zend_compile_func_array_key_exists(znode *result, zend_ast_list *args) /* {{{ */ { znode subject, needle; @@ -4141,7 +4141,7 @@ int zend_compile_func_array_key_exists(znode *result, zend_ast_list *args) /* {{ } /* }}} */ -int zend_compile_func_array_slice(znode *result, zend_ast_list *args) /* {{{ */ +ZEND_RESULT_CODE zend_compile_func_array_slice(znode *result, zend_ast_list *args) /* {{{ */ { if (CG(active_op_array)->function_name && args->children == 2 @@ -4174,7 +4174,7 @@ int zend_compile_func_array_slice(znode *result, zend_ast_list *args) /* {{{ */ } /* }}} */ -int zend_try_compile_special_func(znode *result, zend_string *lcname, zend_ast_list *args, zend_function *fbc, uint32_t type) /* {{{ */ +ZEND_RESULT_CODE zend_try_compile_special_func(znode *result, zend_string *lcname, zend_ast_list *args, zend_function *fbc, uint32_t type) /* {{{ */ { if (CG(compiler_options) & ZEND_COMPILE_NO_BUILTINS) { return FAILURE; @@ -4641,7 +4641,7 @@ void zend_compile_unset(zend_ast *ast) /* {{{ */ } /* }}} */ -static int zend_handle_loops_and_finally_ex(zend_long depth, znode *return_value) /* {{{ */ +static bool zend_handle_loops_and_finally_ex(zend_long depth, znode *return_value) /* {{{ */ { zend_loop_var *base; zend_loop_var *loop_var = zend_stack_top(&CG(loop_var_stack)); @@ -4690,13 +4690,13 @@ static int zend_handle_loops_and_finally_ex(zend_long depth, znode *return_value } /* }}} */ -static int zend_handle_loops_and_finally(znode *return_value) /* {{{ */ +static bool zend_handle_loops_and_finally(znode *return_value) /* {{{ */ { return zend_handle_loops_and_finally_ex(zend_stack_count(&CG(loop_var_stack)) + 1, return_value); } /* }}} */ -static int zend_has_finally_ex(zend_long depth) /* {{{ */ +static bool zend_has_finally_ex(zend_long depth) /* {{{ */ { zend_loop_var *base; zend_loop_var *loop_var = zend_stack_top(&CG(loop_var_stack)); @@ -4722,7 +4722,7 @@ static int zend_has_finally_ex(zend_long depth) /* {{{ */ } /* }}} */ -static int zend_has_finally(void) /* {{{ */ +static bool zend_has_finally(void) /* {{{ */ { return zend_has_finally_ex(zend_stack_count(&CG(loop_var_stack)) + 1); } @@ -5859,7 +5859,7 @@ zend_bool zend_handle_encoding_declaration(zend_ast *ast) /* {{{ */ } /* }}} */ -static int zend_declare_is_first_statement(zend_ast *ast) /* {{{ */ +static ZEND_RESULT_CODE zend_declare_is_first_statement(zend_ast *ast) /* {{{ */ { uint32_t i = 0; zend_ast_list *file_ast = zend_ast_get_list(CG(ast)); @@ -9603,7 +9603,7 @@ void zend_compile_expr(znode *result, zend_ast *ast) zend_short_circuiting_commit(checkpoint, result, ast); } -static zend_op *zend_compile_var_inner(znode *result, zend_ast *ast, uint32_t type, int by_ref) +static zend_op *zend_compile_var_inner(znode *result, zend_ast *ast, uint32_t type, bool by_ref) { CG(zend_lineno) = zend_ast_get_lineno(ast); @@ -9641,7 +9641,7 @@ static zend_op *zend_compile_var_inner(znode *result, zend_ast *ast, uint32_t ty } } -zend_op *zend_compile_var(znode *result, zend_ast *ast, uint32_t type, int by_ref) /* {{{ */ +zend_op *zend_compile_var(znode *result, zend_ast *ast, uint32_t type, bool by_ref) /* {{{ */ { uint32_t checkpoint = zend_short_circuiting_checkpoint(); zend_op *opcode = zend_compile_var_inner(result, ast, type, by_ref); diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index df3171f76d1ef..2e3444863c6d8 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -133,7 +133,7 @@ typedef union _zend_parser_stack_elem { void zend_compile_top_stmt(zend_ast *ast); void zend_compile_stmt(zend_ast *ast); void zend_compile_expr(znode *node, zend_ast *ast); -zend_op *zend_compile_var(znode *node, zend_ast *ast, uint32_t type, int by_ref); +zend_op *zend_compile_var(znode *node, zend_ast *ast, uint32_t type, bool by_ref); void zend_eval_const_expr(zend_ast **ast_ptr); void zend_const_expr_to_zval(zval *result, zend_ast *ast); @@ -770,8 +770,8 @@ zend_bool zend_handle_encoding_declaration(zend_ast *ast); /* parser-driven code generators */ void zend_do_free(znode *op1); -ZEND_API int do_bind_function(zval *lcname); -ZEND_API int do_bind_class(zval *lcname, zend_string *lc_parent_name); +ZEND_API ZEND_RESULT_CODE do_bind_function(zval *lcname); +ZEND_API ZEND_RESULT_CODE do_bind_class(zval *lcname, zend_string *lc_parent_name); ZEND_API uint32_t zend_build_delayed_early_binding_list(const zend_op_array *op_array); ZEND_API void zend_do_delayed_early_binding(zend_op_array *op_array, uint32_t first_early_binding_opline); @@ -823,10 +823,10 @@ ZEND_API void zend_function_dtor(zval *zv); ZEND_API void destroy_zend_class(zval *zv); void zend_class_add_ref(zval *zv); -ZEND_API zend_string *zend_mangle_property_name(const char *src1, size_t src1_length, const char *src2, size_t src2_length, int internal); +ZEND_API zend_string *zend_mangle_property_name(const char *src1, size_t src1_length, const char *src2, size_t src2_length, bool internal); #define zend_unmangle_property_name(mangled_property, class_name, prop_name) \ zend_unmangle_property_name_ex(mangled_property, class_name, prop_name, NULL) -ZEND_API int zend_unmangle_property_name_ex(const zend_string *name, const char **class_name, const char **prop_name, size_t *prop_len); +ZEND_API ZEND_RESULT_CODE zend_unmangle_property_name_ex(const zend_string *name, const char **class_name, const char **prop_name, size_t *prop_len); static zend_always_inline const char *zend_get_unmangled_property_name(const zend_string *mangled_prop) { const char *class_name, *prop_name; @@ -847,7 +847,7 @@ ZEND_API char *zend_make_compiled_string_description(const char *name); ZEND_API void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify_handlers); uint32_t zend_get_class_fetch_type(zend_string *name); ZEND_API zend_uchar zend_get_call_op(const zend_op *init_op, zend_function *fbc); -ZEND_API int zend_is_smart_branch(const zend_op *opline); +ZEND_API ZEND_RESULT_CODE zend_is_smart_branch(const zend_op *opline); typedef zend_bool (*zend_auto_global_callback)(zend_string *name); typedef struct _zend_auto_global { @@ -857,7 +857,7 @@ typedef struct _zend_auto_global { zend_bool armed; } zend_auto_global; -ZEND_API int zend_register_auto_global(zend_string *name, zend_bool jit, zend_auto_global_callback auto_global_callback); +ZEND_API ZEND_RESULT_CODE zend_register_auto_global(zend_string *name, zend_bool jit, zend_auto_global_callback auto_global_callback); ZEND_API void zend_activate_auto_globals(void); ZEND_API zend_bool zend_is_auto_global(zend_string *name); ZEND_API zend_bool zend_is_auto_global_str(const char *name, size_t len); @@ -974,7 +974,7 @@ ZEND_API zend_string *zend_type_to_string(zend_type type); #define IS_CONSTANT_CLASS 0x400 /* __CLASS__ in trait */ #define IS_CONSTANT_UNQUALIFIED_IN_NAMESPACE 0x800 -static zend_always_inline int zend_check_arg_send_type(const zend_function *zf, uint32_t arg_num, uint32_t mask) +static zend_always_inline bool zend_check_arg_send_type(const zend_function *zf, uint32_t arg_num, uint32_t mask) { arg_num--; if (UNEXPECTED(arg_num >= zf->common.num_args)) { diff --git a/main/main.c b/main/main.c index 9ac65da922758..ce6b91a9ad355 100644 --- a/main/main.c +++ b/main/main.c @@ -1520,13 +1520,13 @@ static size_t php_zend_stream_fsizer(void *handle) /* {{{ */ } /* }}} */ -static int php_stream_open_for_zend(const char *filename, zend_file_handle *handle) /* {{{ */ +static ZEND_RESULT_CODE php_stream_open_for_zend(const char *filename, zend_file_handle *handle) /* {{{ */ { return php_stream_open_for_zend_ex(filename, handle, USE_PATH|REPORT_ERRORS|STREAM_OPEN_FOR_INCLUDE); } /* }}} */ -PHPAPI int php_stream_open_for_zend_ex(const char *filename, zend_file_handle *handle, int mode) /* {{{ */ +PHPAPI ZEND_RESULT_CODE php_stream_open_for_zend_ex(const char *filename, zend_file_handle *handle, int mode) /* {{{ */ { zend_string *opened_path; php_stream *stream = php_stream_open_wrapper((char *)filename, "rb", mode, &opened_path); From 976f9b19b77114308d655923a37d2139c638b889 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 15 Aug 2020 20:18:15 +0200 Subject: [PATCH 108/170] Voidify functions in zend_alloc.c --- Zend/zend_alloc.c | 3 +-- Zend/zend_alloc.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 2236cf0dbb037..dfc657ce898be 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -2657,12 +2657,11 @@ ZEND_API char* ZEND_FASTCALL zend_strndup(const char *s, size_t length) } -ZEND_API int zend_set_memory_limit(size_t memory_limit) +ZEND_API void zend_set_memory_limit(size_t memory_limit) { #if ZEND_MM_LIMIT AG(mm_heap)->limit = (memory_limit >= ZEND_MM_CHUNK_SIZE) ? memory_limit : ZEND_MM_CHUNK_SIZE; #endif - return SUCCESS; } ZEND_API size_t zend_memory_usage(int real_usage) diff --git a/Zend/zend_alloc.h b/Zend/zend_alloc.h index 8bb854328dbdd..a05915e8eb77e 100644 --- a/Zend/zend_alloc.h +++ b/Zend/zend_alloc.h @@ -219,7 +219,7 @@ ZEND_API void * __zend_realloc(void *p, size_t len) ZEND_ATTRIBUTE_ALLOC_SIZE(2) #define perealloc2_recoverable_rel(ptr, size, copy_size, persistent) ((persistent)?realloc((ptr), (size)):erealloc2_recoverable_rel((ptr), (size), (copy_size))) #define pestrdup_rel(s, persistent) ((persistent)?strdup(s):estrdup_rel(s)) -ZEND_API int zend_set_memory_limit(size_t memory_limit); +ZEND_API void zend_set_memory_limit(size_t memory_limit); ZEND_API void start_memory_manager(void); ZEND_API void shutdown_memory_manager(int silent, int full_shutdown); From 60019a936faf2d56e646d711dedc23f7d8640643 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 15 Aug 2020 21:12:00 +0200 Subject: [PATCH 109/170] Boolify functions in zend_alloc.c --- Zend/zend_alloc.c | 14 +++++++------- Zend/zend_alloc.h | 18 +++++++++--------- main/main.c | 3 ++- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index dfc657ce898be..b6c89eff3007f 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -2203,7 +2203,7 @@ static void *tracked_malloc(size_t size); static void tracked_free_all(); #endif -void zend_mm_shutdown(zend_mm_heap *heap, int full, int silent) +void zend_mm_shutdown(zend_mm_heap *heap, bool full, bool silent) { zend_mm_chunk *p; zend_mm_huge_list *list; @@ -2364,7 +2364,7 @@ static size_t alloc_globals_offset; static zend_alloc_globals alloc_globals; #endif -ZEND_API int is_zend_mm(void) +ZEND_API bool is_zend_mm(void) { #if ZEND_MM_CUSTOM return !AG(mm_heap)->use_custom_heap; @@ -2373,7 +2373,7 @@ ZEND_API int is_zend_mm(void) #endif } -ZEND_API int is_zend_ptr(const void *ptr) +ZEND_API bool is_zend_ptr(const void *ptr) { #if ZEND_MM_CUSTOM if (AG(mm_heap)->use_custom_heap) { @@ -2664,7 +2664,7 @@ ZEND_API void zend_set_memory_limit(size_t memory_limit) #endif } -ZEND_API size_t zend_memory_usage(int real_usage) +ZEND_API size_t zend_memory_usage(bool real_usage) { #if ZEND_MM_STAT if (real_usage) { @@ -2677,7 +2677,7 @@ ZEND_API size_t zend_memory_usage(int real_usage) return 0; } -ZEND_API size_t zend_memory_peak_usage(int real_usage) +ZEND_API size_t zend_memory_peak_usage(bool real_usage) { #if ZEND_MM_STAT if (real_usage) { @@ -2689,7 +2689,7 @@ ZEND_API size_t zend_memory_peak_usage(int real_usage) return 0; } -ZEND_API void shutdown_memory_manager(int silent, int full_shutdown) +ZEND_API void shutdown_memory_manager(bool silent, bool full_shutdown) { zend_mm_shutdown(AG(mm_heap), full_shutdown, silent); } @@ -2818,7 +2818,7 @@ ZEND_API zend_mm_heap *zend_mm_get_heap(void) return AG(mm_heap); } -ZEND_API int zend_mm_is_custom_heap(zend_mm_heap *new_heap) +ZEND_API bool zend_mm_is_custom_heap(zend_mm_heap *new_heap) { #if ZEND_MM_CUSTOM return AG(mm_heap)->use_custom_heap; diff --git a/Zend/zend_alloc.h b/Zend/zend_alloc.h index a05915e8eb77e..ef97766eb5372 100644 --- a/Zend/zend_alloc.h +++ b/Zend/zend_alloc.h @@ -222,12 +222,12 @@ ZEND_API void * __zend_realloc(void *p, size_t len) ZEND_ATTRIBUTE_ALLOC_SIZE(2) ZEND_API void zend_set_memory_limit(size_t memory_limit); ZEND_API void start_memory_manager(void); -ZEND_API void shutdown_memory_manager(int silent, int full_shutdown); -ZEND_API int is_zend_mm(void); -ZEND_API int is_zend_ptr(const void *ptr); +ZEND_API void shutdown_memory_manager(bool silent, bool full_shutdown); +ZEND_API bool is_zend_mm(void); +ZEND_API bool is_zend_ptr(const void *ptr); -ZEND_API size_t zend_memory_usage(int real_usage); -ZEND_API size_t zend_memory_peak_usage(int real_usage); +ZEND_API size_t zend_memory_usage(bool real_usage); +ZEND_API size_t zend_memory_peak_usage(bool real_usage); /* fast cache for HashTables */ #define ALLOC_HASHTABLE(ht) \ @@ -246,7 +246,7 @@ ZEND_API size_t zend_memory_peak_usage(int real_usage); typedef struct _zend_mm_heap zend_mm_heap; ZEND_API zend_mm_heap *zend_mm_startup(void); -ZEND_API void zend_mm_shutdown(zend_mm_heap *heap, int full_shutdown, int silent); +ZEND_API void zend_mm_shutdown(zend_mm_heap *heap, bool full_shutdown, bool silent); ZEND_API void* ZEND_FASTCALL _zend_mm_alloc(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC; ZEND_API void ZEND_FASTCALL _zend_mm_free(zend_mm_heap *heap, void *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); ZEND_API void* ZEND_FASTCALL _zend_mm_realloc(zend_mm_heap *heap, void *p, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); @@ -274,7 +274,7 @@ ZEND_API size_t zend_mm_gc(zend_mm_heap *heap); #define ZEND_MM_CUSTOM_HEAP_STD 1 #define ZEND_MM_CUSTOM_HEAP_DEBUG 2 -ZEND_API int zend_mm_is_custom_heap(zend_mm_heap *new_heap); +ZEND_API bool zend_mm_is_custom_heap(zend_mm_heap *new_heap); ZEND_API void zend_mm_set_custom_handlers(zend_mm_heap *heap, void* (*_malloc)(size_t), void (*_free)(void*), @@ -295,8 +295,8 @@ typedef struct _zend_mm_storage zend_mm_storage; typedef void* (*zend_mm_chunk_alloc_t)(zend_mm_storage *storage, size_t size, size_t alignment); typedef void (*zend_mm_chunk_free_t)(zend_mm_storage *storage, void *chunk, size_t size); -typedef int (*zend_mm_chunk_truncate_t)(zend_mm_storage *storage, void *chunk, size_t old_size, size_t new_size); -typedef int (*zend_mm_chunk_extend_t)(zend_mm_storage *storage, void *chunk, size_t old_size, size_t new_size); +typedef bool (*zend_mm_chunk_truncate_t)(zend_mm_storage *storage, void *chunk, size_t old_size, size_t new_size); +typedef bool (*zend_mm_chunk_extend_t)(zend_mm_storage *storage, void *chunk, size_t old_size, size_t new_size); typedef struct _zend_mm_handlers { zend_mm_chunk_alloc_t chunk_alloc; diff --git a/main/main.c b/main/main.c index ce6b91a9ad355..a02a6698918bb 100644 --- a/main/main.c +++ b/main/main.c @@ -268,7 +268,8 @@ static PHP_INI_MH(OnChangeMemoryLimit) } else { PG(memory_limit) = Z_L(1)<<30; /* effectively, no limit */ } - return zend_set_memory_limit(PG(memory_limit)); + zend_set_memory_limit(PG(memory_limit)); + return SUCCESS; } /* }}} */ From 31309767fc8d632d9ee9db1f8dae8ab0bc4a30a5 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 15 Aug 2020 22:19:38 +0200 Subject: [PATCH 110/170] Boolify functions in zend_API.c --- Zend/zend_API.c | 159 +++++++++++++++++------------------ Zend/zend_API.h | 210 +++++++++++++++++++++++------------------------ Zend/zend_hash.h | 44 +++++----- 3 files changed, 207 insertions(+), 206 deletions(-) diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 92879137723bb..78867b804318b 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -42,7 +42,7 @@ static zend_module_entry **module_post_deactivate_handlers; static zend_class_entry **class_cleanup_handlers; -ZEND_API int _zend_get_parameters_array_ex(uint32_t param_count, zval *argument_array) /* {{{ */ +ZEND_API ZEND_RESULT_CODE _zend_get_parameters_array_ex(uint32_t param_count, zval *argument_array) /* {{{ */ { zval *param_ptr; uint32_t arg_count; @@ -64,7 +64,7 @@ ZEND_API int _zend_get_parameters_array_ex(uint32_t param_count, zval *argument_ } /* }}} */ -ZEND_API int zend_copy_parameters_array(uint32_t param_count, zval *argument_array) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_copy_parameters_array(uint32_t param_count, zval *argument_array) /* {{{ */ { zval *param_ptr; uint32_t arg_count; @@ -369,7 +369,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_value_error(uint32_t arg_num } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **pce, uint32_t num, int check_null) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **pce, uint32_t num, int check_null) /* {{{ */ { zend_class_entry *ce_base = *pce; @@ -398,7 +398,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **pc } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_parse_arg_bool_weak(zval *arg, zend_bool *dest) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_weak(zval *arg, zend_bool *dest) /* {{{ */ { if (EXPECTED(Z_TYPE_P(arg) <= IS_STRING)) { *dest = zend_is_true(arg); @@ -409,7 +409,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_bool_weak(zval *arg, zend_bool *dest) } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_parse_arg_bool_slow(zval *arg, zend_bool *dest) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_slow(zval *arg, zend_bool *dest) /* {{{ */ { if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) { return 0; @@ -418,7 +418,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_bool_slow(zval *arg, zend_bool *dest) } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest) /* {{{ */ { if (EXPECTED(Z_TYPE_P(arg) == IS_DOUBLE)) { if (UNEXPECTED(zend_isnan(Z_DVAL_P(arg)))) { @@ -461,7 +461,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest) } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_parse_arg_long_slow(zval *arg, zend_long *dest) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_slow(zval *arg, zend_long *dest) /* {{{ */ { if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) { return 0; @@ -470,7 +470,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_long_slow(zval *arg, zend_long *dest) } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest) /* {{{ */ { if (EXPECTED(Z_TYPE_P(arg) == IS_LONG)) { *dest = (double)Z_LVAL_P(arg); @@ -499,7 +499,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest) / } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_parse_arg_double_slow(zval *arg, double *dest) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_slow(zval *arg, double *dest) /* {{{ */ { if (EXPECTED(Z_TYPE_P(arg) == IS_LONG)) { /* SSTH Exception: IS_LONG may be accepted instead as IS_DOUBLE */ @@ -511,7 +511,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_double_slow(zval *arg, double *dest) / } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_parse_arg_number_slow(zval *arg, zval **dest) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_slow(zval *arg, zval **dest) /* {{{ */ { if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) { return 0; @@ -541,7 +541,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_number_slow(zval *arg, zval **dest) /* } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **dest) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **dest) /* {{{ */ { if (EXPECTED(Z_TYPE_P(arg) < IS_STRING)) { convert_to_string(arg); @@ -563,7 +563,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **dest } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_parse_arg_str_slow(zval *arg, zend_string **dest) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_slow(zval *arg, zend_string **dest) /* {{{ */ { if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) { return 0; @@ -572,7 +572,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_str_slow(zval *arg, zend_string **dest } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_parse_arg_str_or_long_slow(zval *arg, zend_string **dest_str, zend_long *dest_long) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_or_long_slow(zval *arg, zend_string **dest_str, zend_long *dest_long) /* {{{ */ { if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) { return 0; @@ -858,7 +858,7 @@ static const char *zend_parse_arg_impl(zval *arg, va_list *va, const char **spec } /* }}} */ -static int zend_parse_arg(uint32_t arg_num, zval *arg, va_list *va, const char **spec, int flags) /* {{{ */ +static ZEND_RESULT_CODE zend_parse_arg(uint32_t arg_num, zval *arg, va_list *va, const char **spec, int flags) /* {{{ */ { const char *expected_type = NULL; char *error = NULL; @@ -886,10 +886,10 @@ static int zend_parse_arg(uint32_t arg_num, zval *arg, va_list *va, const char * } /* }}} */ -ZEND_API int zend_parse_parameter(int flags, uint32_t arg_num, zval *arg, const char *spec, ...) +ZEND_API ZEND_RESULT_CODE zend_parse_parameter(int flags, uint32_t arg_num, zval *arg, const char *spec, ...) { va_list va; - int ret; + ZEND_RESULT_CODE ret; va_start(va, spec); ret = zend_parse_arg(arg_num, arg, &va, &spec, flags); @@ -907,7 +907,7 @@ static ZEND_COLD void zend_parse_parameters_debug_error(const char *msg) { ZSTR_VAL(active_function->common.function_name), msg); } -static int zend_parse_va_args(uint32_t num_args, const char *type_spec, va_list *va, int flags) /* {{{ */ +static ZEND_RESULT_CODE zend_parse_va_args(uint32_t num_args, const char *type_spec, va_list *va, int flags) /* {{{ */ { const char *spec_walk; char c; @@ -1049,10 +1049,10 @@ static int zend_parse_va_args(uint32_t num_args, const char *type_spec, va_list } /* }}} */ -ZEND_API int zend_parse_parameters_ex(int flags, uint32_t num_args, const char *type_spec, ...) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_parse_parameters_ex(int flags, uint32_t num_args, const char *type_spec, ...) /* {{{ */ { va_list va; - int retval; + ZEND_RESULT_CODE retval; va_start(va, type_spec); retval = zend_parse_va_args(num_args, type_spec, &va, flags); @@ -1062,10 +1062,10 @@ ZEND_API int zend_parse_parameters_ex(int flags, uint32_t num_args, const char * } /* }}} */ -ZEND_API int zend_parse_parameters(uint32_t num_args, const char *type_spec, ...) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_parse_parameters(uint32_t num_args, const char *type_spec, ...) /* {{{ */ { va_list va; - int retval; + ZEND_RESULT_CODE retval; int flags = 0; va_start(va, type_spec); @@ -1076,10 +1076,10 @@ ZEND_API int zend_parse_parameters(uint32_t num_args, const char *type_spec, ... } /* }}} */ -ZEND_API int zend_parse_method_parameters(uint32_t num_args, zval *this_ptr, const char *type_spec, ...) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_parse_method_parameters(uint32_t num_args, zval *this_ptr, const char *type_spec, ...) /* {{{ */ { va_list va; - int retval; + ZEND_RESULT_CODE retval; int flags = 0; const char *p = type_spec; zval **object; @@ -1116,10 +1116,10 @@ ZEND_API int zend_parse_method_parameters(uint32_t num_args, zval *this_ptr, con } /* }}} */ -ZEND_API int zend_parse_method_parameters_ex(int flags, uint32_t num_args, zval *this_ptr, const char *type_spec, ...) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_parse_method_parameters_ex(int flags, uint32_t num_args, zval *this_ptr, const char *type_spec, ...) /* {{{ */ { va_list va; - int retval; + ZEND_RESULT_CODE retval; const char *p = type_spec; zval **object; zend_class_entry *ce; @@ -1172,7 +1172,7 @@ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties) /* {{{ */ } /* }}} */ -ZEND_API int zend_update_class_constants(zend_class_entry *class_type) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_update_class_constants(zend_class_entry *class_type) /* {{{ */ { if (!(class_type->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) { zend_class_constant *c; @@ -1361,7 +1361,7 @@ ZEND_API void object_properties_load(zend_object *object, HashTable *properties) * class and all props being public. If only a subset is given or the class * has protected members then you need to merge the properties separately by * calling zend_merge_properties(). */ -static zend_always_inline int _object_and_properties_init(zval *arg, zend_class_entry *class_type, HashTable *properties) /* {{{ */ +static zend_always_inline ZEND_RESULT_CODE _object_and_properties_init(zval *arg, zend_class_entry *class_type, HashTable *properties) /* {{{ */ { if (UNEXPECTED(class_type->ce_flags & (ZEND_ACC_INTERFACE|ZEND_ACC_TRAIT|ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS))) { if (class_type->ce_flags & ZEND_ACC_INTERFACE) { @@ -1400,13 +1400,13 @@ static zend_always_inline int _object_and_properties_init(zval *arg, zend_class_ } /* }}} */ -ZEND_API int object_and_properties_init(zval *arg, zend_class_entry *class_type, HashTable *properties) /* {{{ */ +ZEND_API ZEND_RESULT_CODE object_and_properties_init(zval *arg, zend_class_entry *class_type, HashTable *properties) /* {{{ */ { return _object_and_properties_init(arg, class_type, properties); } /* }}} */ -ZEND_API int object_init_ex(zval *arg, zend_class_entry *class_type) /* {{{ */ +ZEND_API ZEND_RESULT_CODE object_init_ex(zval *arg, zend_class_entry *class_type) /* {{{ */ { return _object_and_properties_init(arg, class_type, NULL); } @@ -1568,7 +1568,7 @@ ZEND_API void add_index_stringl(zval *arg, zend_ulong index, const char *str, si } /* }}} */ -ZEND_API int add_next_index_long(zval *arg, zend_long n) /* {{{ */ +ZEND_API ZEND_RESULT_CODE add_next_index_long(zval *arg, zend_long n) /* {{{ */ { zval tmp; @@ -1577,7 +1577,7 @@ ZEND_API int add_next_index_long(zval *arg, zend_long n) /* {{{ */ } /* }}} */ -ZEND_API int add_next_index_null(zval *arg) /* {{{ */ +ZEND_API ZEND_RESULT_CODE add_next_index_null(zval *arg) /* {{{ */ { zval tmp; @@ -1586,7 +1586,7 @@ ZEND_API int add_next_index_null(zval *arg) /* {{{ */ } /* }}} */ -ZEND_API int add_next_index_bool(zval *arg, zend_bool b) /* {{{ */ +ZEND_API ZEND_RESULT_CODE add_next_index_bool(zval *arg, zend_bool b) /* {{{ */ { zval tmp; @@ -1595,7 +1595,7 @@ ZEND_API int add_next_index_bool(zval *arg, zend_bool b) /* {{{ */ } /* }}} */ -ZEND_API int add_next_index_resource(zval *arg, zend_resource *r) /* {{{ */ +ZEND_API ZEND_RESULT_CODE add_next_index_resource(zval *arg, zend_resource *r) /* {{{ */ { zval tmp; @@ -1604,7 +1604,7 @@ ZEND_API int add_next_index_resource(zval *arg, zend_resource *r) /* {{{ */ } /* }}} */ -ZEND_API int add_next_index_double(zval *arg, double d) /* {{{ */ +ZEND_API ZEND_RESULT_CODE add_next_index_double(zval *arg, double d) /* {{{ */ { zval tmp; @@ -1613,7 +1613,7 @@ ZEND_API int add_next_index_double(zval *arg, double d) /* {{{ */ } /* }}} */ -ZEND_API int add_next_index_str(zval *arg, zend_string *str) /* {{{ */ +ZEND_API ZEND_RESULT_CODE add_next_index_str(zval *arg, zend_string *str) /* {{{ */ { zval tmp; @@ -1622,7 +1622,7 @@ ZEND_API int add_next_index_str(zval *arg, zend_string *str) /* {{{ */ } /* }}} */ -ZEND_API int add_next_index_string(zval *arg, const char *str) /* {{{ */ +ZEND_API ZEND_RESULT_CODE add_next_index_string(zval *arg, const char *str) /* {{{ */ { zval tmp; @@ -1631,7 +1631,7 @@ ZEND_API int add_next_index_string(zval *arg, const char *str) /* {{{ */ } /* }}} */ -ZEND_API int add_next_index_stringl(zval *arg, const char *str, size_t length) /* {{{ */ +ZEND_API ZEND_RESULT_CODE add_next_index_stringl(zval *arg, const char *str, size_t length) /* {{{ */ { zval tmp; @@ -1640,7 +1640,7 @@ ZEND_API int add_next_index_stringl(zval *arg, const char *str, size_t length) / } /* }}} */ -ZEND_API int array_set_zval_key(HashTable *ht, zval *key, zval *value) /* {{{ */ +ZEND_API ZEND_RESULT_CODE array_set_zval_key(HashTable *ht, zval *key, zval *value) /* {{{ */ { zval *result; @@ -1767,7 +1767,7 @@ ZEND_API void add_property_zval_ex(zval *arg, const char *key, size_t key_len, z } /* }}} */ -ZEND_API int zend_startup_module_ex(zend_module_entry *module) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_startup_module_ex(zend_module_entry *module) /* {{{ */ { size_t name_len; zend_string *lcname; @@ -2254,7 +2254,7 @@ ZEND_API void zend_add_magic_method(zend_class_entry *ce, zend_function *fptr, z } /* registers all functions in *library_functions in the function hash */ -ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_function_entry *functions, HashTable *function_table, int type) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_register_functions(zend_class_entry *scope, const zend_function_entry *functions, HashTable *function_table, int type) /* {{{ */ { const zend_function_entry *ptr = functions; zend_function function, *reg_function; @@ -2477,7 +2477,7 @@ ZEND_API void zend_unregister_functions(const zend_function_entry *functions, in } /* }}} */ -ZEND_API int zend_startup_module(zend_module_entry *module) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_startup_module(zend_module_entry *module) /* {{{ */ { if ((module = zend_register_internal_module(module)) != NULL && zend_startup_module_ex(module) == SUCCESS) { return SUCCESS; @@ -2486,7 +2486,7 @@ ZEND_API int zend_startup_module(zend_module_entry *module) /* {{{ */ } /* }}} */ -ZEND_API int zend_get_module_started(const char *module_name) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_get_module_started(const char *module_name) /* {{{ */ { zend_module_entry *module; @@ -2730,7 +2730,7 @@ ZEND_API zend_class_entry *zend_register_internal_interface(zend_class_entry *or } /* }}} */ -ZEND_API int zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce, int persistent) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce, bool persistent) /* {{{ */ { zend_string *lcname; zval zv, *ret; @@ -2765,7 +2765,8 @@ ZEND_API int zend_register_class_alias_ex(const char *name, size_t name_len, zen } /* }}} */ -ZEND_API int zend_set_hash_symbol(zval *symbol, const char *name, size_t name_length, zend_bool is_ref, int num_symbol_tables, ...) /* {{{ */ +// TODO num_symbol_tables as unsigned int? +ZEND_API ZEND_RESULT_CODE zend_set_hash_symbol(zval *symbol, const char *name, size_t name_length, zend_bool is_ref, int num_symbol_tables, ...) /* {{{ */ { HashTable *symbol_table; va_list symbol_table_list; @@ -2789,7 +2790,7 @@ ZEND_API int zend_set_hash_symbol(zval *symbol, const char *name, size_t name_le /* Disabled functions support */ -ZEND_API int zend_disable_function(const char *function_name, size_t function_name_length) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_disable_function(const char *function_name, size_t function_name_length) /* {{{ */ { return zend_hash_str_del(CG(function_table), function_name, function_name_length); } @@ -2826,7 +2827,7 @@ static const zend_function_entry disabled_class_new[] = { ZEND_FE_END }; -ZEND_API int zend_disable_class(const char *class_name, size_t class_name_length) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_disable_class(const char *class_name, size_t class_name_length) /* {{{ */ { zend_class_entry *disabled_class; zend_string *key; @@ -2859,9 +2860,9 @@ static zend_always_inline zend_class_entry *get_scope(zend_execute_data *frame) return frame && frame->func ? frame->func->common.scope : NULL; } -static int zend_is_callable_check_class(zend_string *name, zend_class_entry *scope, zend_execute_data *frame, zend_fcall_info_cache *fcc, int *strict_class, char **error) /* {{{ */ +static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *scope, zend_execute_data *frame, zend_fcall_info_cache *fcc, int *strict_class, char **error) /* {{{ */ { - int ret = 0; + bool ret = 0; zend_class_entry *ce; size_t name_len = ZSTR_LEN(name); zend_string *lcname; @@ -2948,10 +2949,10 @@ ZEND_API void zend_release_fcall_info_cache(zend_fcall_info_cache *fcc) { fcc->function_handler = NULL; } -static zend_always_inline int zend_is_callable_check_func(int check_flags, zval *callable, zend_execute_data *frame, zend_fcall_info_cache *fcc, int strict_class, char **error) /* {{{ */ +static zend_always_inline bool zend_is_callable_check_func(int check_flags, zval *callable, zend_execute_data *frame, zend_fcall_info_cache *fcc, int strict_class, char **error) /* {{{ */ { zend_class_entry *ce_org = fcc->calling_scope; - int retval = 0; + bool retval = 0; zend_string *mname, *cname; zend_string *lmname; const char *colon; @@ -3390,7 +3391,7 @@ ZEND_API zend_bool zend_make_callable(zval *callable, zend_string **callable_nam } /* }}} */ -ZEND_API int zend_fcall_info_init(zval *callable, uint32_t check_flags, zend_fcall_info *fci, zend_fcall_info_cache *fcc, zend_string **callable_name, char **error) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_fcall_info_init(zval *callable, uint32_t check_flags, zend_fcall_info *fci, zend_fcall_info_cache *fcc, zend_string **callable_name, char **error) /* {{{ */ { if (!zend_is_callable_ex(callable, NULL, check_flags, callable_name, fcc, error)) { return FAILURE; @@ -3444,7 +3445,7 @@ ZEND_API void zend_fcall_info_args_restore(zend_fcall_info *fci, uint32_t param_ } /* }}} */ -ZEND_API int zend_fcall_info_args_ex(zend_fcall_info *fci, zend_function *func, zval *args) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_fcall_info_args_ex(zend_fcall_info *fci, zend_function *func, zval *args) /* {{{ */ { zval *arg, *params; uint32_t n = 1; @@ -3477,7 +3478,7 @@ ZEND_API int zend_fcall_info_args_ex(zend_fcall_info *fci, zend_function *func, } /* }}} */ -ZEND_API int zend_fcall_info_args(zend_fcall_info *fci, zval *args) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_fcall_info_args(zend_fcall_info *fci, zval *args) /* {{{ */ { return zend_fcall_info_args_ex(fci, NULL, args); } @@ -3525,11 +3526,11 @@ ZEND_API void zend_fcall_info_argn(zend_fcall_info *fci, uint32_t argc, ...) /* } /* }}} */ -ZEND_API int zend_fcall_info_call(zend_fcall_info *fci, zend_fcall_info_cache *fcc, zval *retval_ptr, zval *args) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_fcall_info_call(zend_fcall_info *fci, zend_fcall_info_cache *fcc, zval *retval_ptr, zval *args) /* {{{ */ { zval retval, *org_params = NULL; uint32_t org_count = 0; - int result; + ZEND_RESULT_CODE result; fci->retval = retval_ptr ? retval_ptr : &retval; if (args) { @@ -3680,7 +3681,7 @@ ZEND_API zend_property_info *zend_declare_typed_property(zend_class_entry *ce, z } /* }}} */ -ZEND_API int zend_try_assign_typed_ref_ex(zend_reference *ref, zval *val, zend_bool strict) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_ex(zend_reference *ref, zval *val, zend_bool strict) /* {{{ */ { if (UNEXPECTED(!zend_verify_ref_assignable_zval(ref, val, strict))) { zval_ptr_dtor(val); @@ -3693,13 +3694,13 @@ ZEND_API int zend_try_assign_typed_ref_ex(zend_reference *ref, zval *val, zend_b } /* }}} */ -ZEND_API int zend_try_assign_typed_ref(zend_reference *ref, zval *val) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref(zend_reference *ref, zval *val) /* {{{ */ { return zend_try_assign_typed_ref_ex(ref, val, ZEND_ARG_USES_STRICT_TYPES()); } /* }}} */ -ZEND_API int zend_try_assign_typed_ref_null(zend_reference *ref) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_null(zend_reference *ref) /* {{{ */ { zval tmp; @@ -3708,7 +3709,7 @@ ZEND_API int zend_try_assign_typed_ref_null(zend_reference *ref) /* {{{ */ } /* }}} */ -ZEND_API int zend_try_assign_typed_ref_bool(zend_reference *ref, zend_bool val) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_bool(zend_reference *ref, zend_bool val) /* {{{ */ { zval tmp; @@ -3717,7 +3718,7 @@ ZEND_API int zend_try_assign_typed_ref_bool(zend_reference *ref, zend_bool val) } /* }}} */ -ZEND_API int zend_try_assign_typed_ref_long(zend_reference *ref, zend_long lval) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_long(zend_reference *ref, zend_long lval) /* {{{ */ { zval tmp; @@ -3726,7 +3727,7 @@ ZEND_API int zend_try_assign_typed_ref_long(zend_reference *ref, zend_long lval) } /* }}} */ -ZEND_API int zend_try_assign_typed_ref_double(zend_reference *ref, double dval) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_double(zend_reference *ref, double dval) /* {{{ */ { zval tmp; @@ -3735,7 +3736,7 @@ ZEND_API int zend_try_assign_typed_ref_double(zend_reference *ref, double dval) } /* }}} */ -ZEND_API int zend_try_assign_typed_ref_empty_string(zend_reference *ref) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_empty_string(zend_reference *ref) /* {{{ */ { zval tmp; @@ -3744,7 +3745,7 @@ ZEND_API int zend_try_assign_typed_ref_empty_string(zend_reference *ref) /* {{{ } /* }}} */ -ZEND_API int zend_try_assign_typed_ref_str(zend_reference *ref, zend_string *str) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_str(zend_reference *ref, zend_string *str) /* {{{ */ { zval tmp; @@ -3753,7 +3754,7 @@ ZEND_API int zend_try_assign_typed_ref_str(zend_reference *ref, zend_string *str } /* }}} */ -ZEND_API int zend_try_assign_typed_ref_string(zend_reference *ref, const char *string) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_string(zend_reference *ref, const char *string) /* {{{ */ { zval tmp; @@ -3762,7 +3763,7 @@ ZEND_API int zend_try_assign_typed_ref_string(zend_reference *ref, const char *s } /* }}} */ -ZEND_API int zend_try_assign_typed_ref_stringl(zend_reference *ref, const char *string, size_t len) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_stringl(zend_reference *ref, const char *string, size_t len) /* {{{ */ { zval tmp; @@ -3771,7 +3772,7 @@ ZEND_API int zend_try_assign_typed_ref_stringl(zend_reference *ref, const char * } /* }}} */ -ZEND_API int zend_try_assign_typed_ref_arr(zend_reference *ref, zend_array *arr) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_arr(zend_reference *ref, zend_array *arr) /* {{{ */ { zval tmp; @@ -3780,7 +3781,7 @@ ZEND_API int zend_try_assign_typed_ref_arr(zend_reference *ref, zend_array *arr) } /* }}} */ -ZEND_API int zend_try_assign_typed_ref_res(zend_reference *ref, zend_resource *res) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_res(zend_reference *ref, zend_resource *res) /* {{{ */ { zval tmp; @@ -3789,7 +3790,7 @@ ZEND_API int zend_try_assign_typed_ref_res(zend_reference *ref, zend_resource *r } /* }}} */ -ZEND_API int zend_try_assign_typed_ref_zval(zend_reference *ref, zval *zv) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_zval(zend_reference *ref, zval *zv) /* {{{ */ { zval tmp; @@ -3798,7 +3799,7 @@ ZEND_API int zend_try_assign_typed_ref_zval(zend_reference *ref, zval *zv) /* {{ } /* }}} */ -ZEND_API int zend_try_assign_typed_ref_zval_ex(zend_reference *ref, zval *zv, zend_bool strict) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_zval_ex(zend_reference *ref, zval *zv, zend_bool strict) /* {{{ */ { zval tmp; @@ -4089,7 +4090,7 @@ ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zend_object } /* }}} */ -ZEND_API int zend_update_static_property_ex(zend_class_entry *scope, zend_string *name, zval *value) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_update_static_property_ex(zend_class_entry *scope, zend_string *name, zval *value) /* {{{ */ { zval *property, tmp; zend_property_info *prop_info; @@ -4125,7 +4126,7 @@ ZEND_API int zend_update_static_property_ex(zend_class_entry *scope, zend_string } /* }}} */ -ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value) /* {{{ */ { zend_string *key = zend_string_init(name, name_length, 0); int retval = zend_update_static_property_ex(scope, key, value); @@ -4134,7 +4135,7 @@ ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *na } /* }}} */ -ZEND_API int zend_update_static_property_null(zend_class_entry *scope, const char *name, size_t name_length) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_update_static_property_null(zend_class_entry *scope, const char *name, size_t name_length) /* {{{ */ { zval tmp; @@ -4143,7 +4144,7 @@ ZEND_API int zend_update_static_property_null(zend_class_entry *scope, const cha } /* }}} */ -ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, size_t name_length, zend_long value) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_update_static_property_bool(zend_class_entry *scope, const char *name, size_t name_length, zend_long value) /* {{{ */ { zval tmp; @@ -4152,7 +4153,7 @@ ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const cha } /* }}} */ -ZEND_API int zend_update_static_property_long(zend_class_entry *scope, const char *name, size_t name_length, zend_long value) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_update_static_property_long(zend_class_entry *scope, const char *name, size_t name_length, zend_long value) /* {{{ */ { zval tmp; @@ -4161,7 +4162,7 @@ ZEND_API int zend_update_static_property_long(zend_class_entry *scope, const cha } /* }}} */ -ZEND_API int zend_update_static_property_double(zend_class_entry *scope, const char *name, size_t name_length, double value) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_update_static_property_double(zend_class_entry *scope, const char *name, size_t name_length, double value) /* {{{ */ { zval tmp; @@ -4170,7 +4171,7 @@ ZEND_API int zend_update_static_property_double(zend_class_entry *scope, const c } /* }}} */ -ZEND_API int zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value) /* {{{ */ { zval tmp; @@ -4180,7 +4181,7 @@ ZEND_API int zend_update_static_property_string(zend_class_entry *scope, const c } /* }}} */ -ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, const char *name, size_t name_length, const char *value, size_t value_len) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_update_static_property_stringl(zend_class_entry *scope, const char *name, size_t name_length, const char *value, size_t value_len) /* {{{ */ { zval tmp; @@ -4314,7 +4315,7 @@ ZEND_API zend_bool zend_is_countable(zval *countable) /* {{{ */ } /* }}} */ -static int get_default_via_ast(zval *default_value_zval, const char *default_value) { +static ZEND_RESULT_CODE get_default_via_ast(zval *default_value_zval, const char *default_value) { zend_ast *ast; zend_arena *ast_arena; @@ -4362,7 +4363,7 @@ static zend_string *try_parse_string(const char *str, size_t len, char quote) { return zend_string_init(str, len, 0); } -ZEND_API int zend_get_default_from_internal_arg_info( +ZEND_API ZEND_RESULT_CODE zend_get_default_from_internal_arg_info( zval *default_value_zval, zend_internal_arg_info *arg_info) { const char *default_value = arg_info->default_value; diff --git a/Zend/zend_API.h b/Zend/zend_API.h index adf84affd284f..feaeab2ea67c4 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -182,11 +182,11 @@ typedef struct _zend_fcall_info_cache { #define ZEND_MODULE_GLOBALS_DTOR_N(module) zm_globals_dtor_##module /* Declaration macros */ -#define ZEND_MODULE_STARTUP_D(module) int ZEND_MODULE_STARTUP_N(module)(INIT_FUNC_ARGS) -#define ZEND_MODULE_SHUTDOWN_D(module) int ZEND_MODULE_SHUTDOWN_N(module)(SHUTDOWN_FUNC_ARGS) -#define ZEND_MODULE_ACTIVATE_D(module) int ZEND_MODULE_ACTIVATE_N(module)(INIT_FUNC_ARGS) -#define ZEND_MODULE_DEACTIVATE_D(module) int ZEND_MODULE_DEACTIVATE_N(module)(SHUTDOWN_FUNC_ARGS) -#define ZEND_MODULE_POST_ZEND_DEACTIVATE_D(module) int ZEND_MODULE_POST_ZEND_DEACTIVATE_N(module)(void) +#define ZEND_MODULE_STARTUP_D(module) ZEND_RESULT_CODE ZEND_MODULE_STARTUP_N(module)(INIT_FUNC_ARGS) +#define ZEND_MODULE_SHUTDOWN_D(module) ZEND_RESULT_CODE ZEND_MODULE_SHUTDOWN_N(module)(SHUTDOWN_FUNC_ARGS) +#define ZEND_MODULE_ACTIVATE_D(module) ZEND_RESULT_CODE ZEND_MODULE_ACTIVATE_N(module)(INIT_FUNC_ARGS) +#define ZEND_MODULE_DEACTIVATE_D(module) ZEND_RESULT_CODE ZEND_MODULE_DEACTIVATE_N(module)(SHUTDOWN_FUNC_ARGS) +#define ZEND_MODULE_POST_ZEND_DEACTIVATE_D(module) ZEND_RESULT_CODE ZEND_MODULE_POST_ZEND_DEACTIVATE_N(module)(void) #define ZEND_MODULE_INFO_D(module) ZEND_COLD void ZEND_MODULE_INFO_N(module)(ZEND_MODULE_INFO_FUNC_ARGS) #define ZEND_MODULE_GLOBALS_CTOR_D(module) void ZEND_MODULE_GLOBALS_CTOR_N(module)(zend_##module##_globals *module##_globals) #define ZEND_MODULE_GLOBALS_DTOR_D(module) void ZEND_MODULE_GLOBALS_DTOR_N(module)(zend_##module##_globals *module##_globals) @@ -283,10 +283,10 @@ typedef struct _zend_fcall_info_cache { ZEND_API int zend_next_free_module(void); BEGIN_EXTERN_C() -ZEND_API int _zend_get_parameters_array_ex(uint32_t param_count, zval *argument_array); +ZEND_API ZEND_RESULT_CODE _zend_get_parameters_array_ex(uint32_t param_count, zval *argument_array); /* internal function to efficiently copy parameters when executing __call() */ -ZEND_API int zend_copy_parameters_array(uint32_t param_count, zval *argument_array); +ZEND_API ZEND_RESULT_CODE zend_copy_parameters_array(uint32_t param_count, zval *argument_array); #define zend_get_parameters_array(ht, param_count, argument_array) \ _zend_get_parameters_array_ex(param_count, argument_array) @@ -301,27 +301,27 @@ ZEND_API int zend_copy_parameters_array(uint32_t param_count, zval *argument_arr #define ZEND_PARSE_PARAMS_THROW 0 /* No longer used, zpp always uses exceptions */ #define ZEND_PARSE_PARAMS_QUIET (1<<1) -ZEND_API int zend_parse_parameters(uint32_t num_args, const char *type_spec, ...); -ZEND_API int zend_parse_parameters_ex(int flags, uint32_t num_args, const char *type_spec, ...); +ZEND_API ZEND_RESULT_CODE zend_parse_parameters(uint32_t num_args, const char *type_spec, ...); +ZEND_API ZEND_RESULT_CODE zend_parse_parameters_ex(int flags, uint32_t num_args, const char *type_spec, ...); /* NOTE: This must have at least one value in __VA_ARGS__ for the expression to be valid */ #define zend_parse_parameters_throw(num_args, ...) \ zend_parse_parameters(num_args, __VA_ARGS__) ZEND_API const char *zend_zval_type_name(const zval *arg); ZEND_API zend_string *zend_zval_get_legacy_type(const zval *arg); -ZEND_API int zend_parse_method_parameters(uint32_t num_args, zval *this_ptr, const char *type_spec, ...); -ZEND_API int zend_parse_method_parameters_ex(int flags, uint32_t num_args, zval *this_ptr, const char *type_spec, ...); +ZEND_API ZEND_RESULT_CODE zend_parse_method_parameters(uint32_t num_args, zval *this_ptr, const char *type_spec, ...); +ZEND_API ZEND_RESULT_CODE zend_parse_method_parameters_ex(int flags, uint32_t num_args, zval *this_ptr, const char *type_spec, ...); -ZEND_API int zend_parse_parameter(int flags, uint32_t arg_num, zval *arg, const char *spec, ...); +ZEND_API ZEND_RESULT_CODE zend_parse_parameter(int flags, uint32_t arg_num, zval *arg, const char *spec, ...); /* End of parameter parsing API -- andrei */ -ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_function_entry *functions, HashTable *function_table, int type); +ZEND_API ZEND_RESULT_CODE zend_register_functions(zend_class_entry *scope, const zend_function_entry *functions, HashTable *function_table, int type); ZEND_API void zend_unregister_functions(const zend_function_entry *functions, int count, HashTable *function_table); -ZEND_API int zend_startup_module(zend_module_entry *module_entry); +ZEND_API ZEND_RESULT_CODE zend_startup_module(zend_module_entry *module_entry); ZEND_API zend_module_entry* zend_register_internal_module(zend_module_entry *module_entry); ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module); -ZEND_API int zend_startup_module_ex(zend_module_entry *module); +ZEND_API ZEND_RESULT_CODE zend_startup_module_ex(zend_module_entry *module); ZEND_API void zend_startup_modules(void); ZEND_API void zend_collect_module_handlers(void); ZEND_API void zend_destroy_modules(void); @@ -334,15 +334,15 @@ ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *cla ZEND_API zend_class_entry *zend_register_internal_interface(zend_class_entry *orig_class_entry); ZEND_API void zend_class_implements(zend_class_entry *class_entry, int num_interfaces, ...); -ZEND_API int zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce, int persistent); +ZEND_API ZEND_RESULT_CODE zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce, bool persistent); #define zend_register_class_alias(name, ce) \ zend_register_class_alias_ex(name, sizeof(name)-1, ce, 1) #define zend_register_ns_class_alias(ns, name, ce) \ zend_register_class_alias_ex(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, ce, 1) -ZEND_API int zend_disable_function(const char *function_name, size_t function_name_length); -ZEND_API int zend_disable_class(const char *class_name, size_t class_name_length); +ZEND_API ZEND_RESULT_CODE zend_disable_function(const char *function_name, size_t function_name_length); +ZEND_API ZEND_RESULT_CODE zend_disable_class(const char *class_name, size_t class_name_length); ZEND_API ZEND_COLD void zend_wrong_param_count(void); @@ -378,7 +378,7 @@ ZEND_API void zend_declare_class_constant_double(zend_class_entry *ce, const cha ZEND_API void zend_declare_class_constant_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_length); ZEND_API void zend_declare_class_constant_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value); -ZEND_API int zend_update_class_constants(zend_class_entry *class_type); +ZEND_API ZEND_RESULT_CODE zend_update_class_constants(zend_class_entry *class_type); ZEND_API void zend_update_property_ex(zend_class_entry *scope, zend_object *object, zend_string *name, zval *value); ZEND_API void zend_update_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, zval *value); @@ -391,14 +391,14 @@ ZEND_API void zend_update_property_string(zend_class_entry *scope, zend_object * ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, const char *value, size_t value_length); ZEND_API void zend_unset_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length); -ZEND_API int zend_update_static_property_ex(zend_class_entry *scope, zend_string *name, zval *value); -ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value); -ZEND_API int zend_update_static_property_null(zend_class_entry *scope, const char *name, size_t name_length); -ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, size_t name_length, zend_long value); -ZEND_API int zend_update_static_property_long(zend_class_entry *scope, const char *name, size_t name_length, zend_long value); -ZEND_API int zend_update_static_property_double(zend_class_entry *scope, const char *name, size_t name_length, double value); -ZEND_API int zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value); -ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, const char *name, size_t name_length, const char *value, size_t value_length); +ZEND_API ZEND_RESULT_CODE zend_update_static_property_ex(zend_class_entry *scope, zend_string *name, zval *value); +ZEND_API ZEND_RESULT_CODE zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value); +ZEND_API ZEND_RESULT_CODE zend_update_static_property_null(zend_class_entry *scope, const char *name, size_t name_length); +ZEND_API ZEND_RESULT_CODE zend_update_static_property_bool(zend_class_entry *scope, const char *name, size_t name_length, zend_long value); +ZEND_API ZEND_RESULT_CODE zend_update_static_property_long(zend_class_entry *scope, const char *name, size_t name_length, zend_long value); +ZEND_API ZEND_RESULT_CODE zend_update_static_property_double(zend_class_entry *scope, const char *name, size_t name_length, double value); +ZEND_API ZEND_RESULT_CODE zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value); +ZEND_API ZEND_RESULT_CODE zend_update_static_property_stringl(zend_class_entry *scope, const char *name, size_t name_length, const char *value, size_t value_length); ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zend_object *object, zend_string *name, zend_bool silent, zval *rv); ZEND_API zval *zend_read_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, zend_bool silent, zval *rv); @@ -426,8 +426,8 @@ ZEND_API const char *zend_get_type_by_const(int type); #define array_init(arg) ZVAL_ARR((arg), zend_new_array(0)) #define array_init_size(arg, size) ZVAL_ARR((arg), zend_new_array(size)) ZEND_API void object_init(zval *arg); -ZEND_API int object_init_ex(zval *arg, zend_class_entry *ce); -ZEND_API int object_and_properties_init(zval *arg, zend_class_entry *ce, HashTable *properties); +ZEND_API ZEND_RESULT_CODE object_init_ex(zval *arg, zend_class_entry *ce); +ZEND_API ZEND_RESULT_CODE object_and_properties_init(zval *arg, zend_class_entry *ce, HashTable *properties); ZEND_API void object_properties_init(zend_object *object, zend_class_entry *class_type); ZEND_API void object_properties_init_ex(zend_object *object, HashTable *properties); ZEND_API void object_properties_load(zend_object *object, HashTable *properties); @@ -436,7 +436,7 @@ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties); ZEND_API void add_assoc_long_ex(zval *arg, const char *key, size_t key_len, zend_long n); ZEND_API void add_assoc_null_ex(zval *arg, const char *key, size_t key_len); -ZEND_API void add_assoc_bool_ex(zval *arg, const char *key, size_t key_len, int b); +ZEND_API void add_assoc_bool_ex(zval *arg, const char *key, size_t key_len, bool b); ZEND_API void add_assoc_resource_ex(zval *arg, const char *key, size_t key_len, zend_resource *r); ZEND_API void add_assoc_double_ex(zval *arg, const char *key, size_t key_len, double d); ZEND_API void add_assoc_str_ex(zval *arg, const char *key, size_t key_len, zend_string *str); @@ -456,33 +456,33 @@ ZEND_API void add_assoc_zval_ex(zval *arg, const char *key, size_t key_len, zval ZEND_API void add_index_long(zval *arg, zend_ulong index, zend_long n); ZEND_API void add_index_null(zval *arg, zend_ulong index); -ZEND_API void add_index_bool(zval *arg, zend_ulong index, int b); +ZEND_API void add_index_bool(zval *arg, zend_ulong index, bool b); ZEND_API void add_index_resource(zval *arg, zend_ulong index, zend_resource *r); ZEND_API void add_index_double(zval *arg, zend_ulong index, double d); ZEND_API void add_index_str(zval *arg, zend_ulong index, zend_string *str); ZEND_API void add_index_string(zval *arg, zend_ulong index, const char *str); ZEND_API void add_index_stringl(zval *arg, zend_ulong index, const char *str, size_t length); -static zend_always_inline int add_index_zval(zval *arg, zend_ulong index, zval *value) +static zend_always_inline ZEND_RESULT_CODE add_index_zval(zval *arg, zend_ulong index, zval *value) { return zend_hash_index_update(Z_ARRVAL_P(arg), index, value) ? SUCCESS : FAILURE; } -ZEND_API int add_next_index_long(zval *arg, zend_long n); -ZEND_API int add_next_index_null(zval *arg); -ZEND_API int add_next_index_bool(zval *arg, zend_bool b); -ZEND_API int add_next_index_resource(zval *arg, zend_resource *r); -ZEND_API int add_next_index_double(zval *arg, double d); -ZEND_API int add_next_index_str(zval *arg, zend_string *str); -ZEND_API int add_next_index_string(zval *arg, const char *str); -ZEND_API int add_next_index_stringl(zval *arg, const char *str, size_t length); +ZEND_API ZEND_RESULT_CODE add_next_index_long(zval *arg, zend_long n); +ZEND_API ZEND_RESULT_CODE add_next_index_null(zval *arg); +ZEND_API ZEND_RESULT_CODE add_next_index_bool(zval *arg, zend_bool b); +ZEND_API ZEND_RESULT_CODE add_next_index_resource(zval *arg, zend_resource *r); +ZEND_API ZEND_RESULT_CODE add_next_index_double(zval *arg, double d); +ZEND_API ZEND_RESULT_CODE add_next_index_str(zval *arg, zend_string *str); +ZEND_API ZEND_RESULT_CODE add_next_index_string(zval *arg, const char *str); +ZEND_API ZEND_RESULT_CODE add_next_index_stringl(zval *arg, const char *str, size_t length); -static zend_always_inline int add_next_index_zval(zval *arg, zval *value) +static zend_always_inline ZEND_RESULT_CODE add_next_index_zval(zval *arg, zval *value) { return zend_hash_next_index_insert(Z_ARRVAL_P(arg), value) ? SUCCESS : FAILURE; } -ZEND_API int array_set_zval_key(HashTable *ht, zval *key, zval *value); +ZEND_API ZEND_RESULT_CODE array_set_zval_key(HashTable *ht, zval *key, zval *value); ZEND_API void add_property_long_ex(zval *arg, const char *key, size_t key_len, zend_long l); ZEND_API void add_property_null_ex(zval *arg, const char *key, size_t key_len); @@ -505,7 +505,7 @@ ZEND_API void add_property_zval_ex(zval *arg, const char *key, size_t key_len, z #define add_property_zval(__arg, __key, __value) add_property_zval_ex(__arg, __key, strlen(__key), __value) -ZEND_API int _call_user_function_impl(zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], HashTable *named_params); +ZEND_API ZEND_RESULT_CODE _call_user_function_impl(zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], HashTable *named_params); #define call_user_function(function_table, object, function_name, retval_ptr, param_count, params) \ _call_user_function_impl(object, function_name, retval_ptr, param_count, params, NULL) @@ -524,12 +524,12 @@ ZEND_API extern const zend_fcall_info_cache empty_fcall_info_cache; * fci->params = NULL; * The callable_name argument may be NULL. */ -ZEND_API int zend_fcall_info_init(zval *callable, uint32_t check_flags, zend_fcall_info *fci, zend_fcall_info_cache *fcc, zend_string **callable_name, char **error); +ZEND_API ZEND_RESULT_CODE zend_fcall_info_init(zval *callable, uint32_t check_flags, zend_fcall_info *fci, zend_fcall_info_cache *fcc, zend_string **callable_name, char **error); /** Clear arguments connected with zend_fcall_info *fci * If free_mem is not zero then the params array gets free'd as well */ -ZEND_API void zend_fcall_info_args_clear(zend_fcall_info *fci, int free_mem); +ZEND_API void zend_fcall_info_args_clear(zend_fcall_info *fci, bool free_mem); /** Save current arguments from zend_fcall_info *fci * params array will be set to NULL @@ -543,8 +543,8 @@ ZEND_API void zend_fcall_info_args_restore(zend_fcall_info *fci, uint32_t param_ /** Set or clear the arguments in the zend_call_info struct taking care of * refcount. If args is NULL and arguments are set then those are cleared. */ -ZEND_API int zend_fcall_info_args(zend_fcall_info *fci, zval *args); -ZEND_API int zend_fcall_info_args_ex(zend_fcall_info *fci, zend_function *func, zval *args); +ZEND_API ZEND_RESULT_CODE zend_fcall_info_args(zend_fcall_info *fci, zval *args); +ZEND_API ZEND_RESULT_CODE zend_fcall_info_args_ex(zend_fcall_info *fci, zend_function *func, zval *args); /** Set arguments in the zend_fcall_info struct taking care of refcount. * If argc is 0 the arguments which are set will be cleared, else pass @@ -567,9 +567,9 @@ ZEND_API void zend_fcall_info_argn(zend_fcall_info *fci, uint32_t argc, ...); /** Call a function using information created by zend_fcall_info_init()/args(). * If args is given then those replace the argument info in fci is temporarily. */ -ZEND_API int zend_fcall_info_call(zend_fcall_info *fci, zend_fcall_info_cache *fcc, zval *retval, zval *args); +ZEND_API ZEND_RESULT_CODE zend_fcall_info_call(zend_fcall_info *fci, zend_fcall_info_cache *fcc, zval *retval, zval *args); -ZEND_API int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache); +ZEND_API ZEND_RESULT_CODE zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache); /* Call the provided zend_function with the given params. * If retval_ptr is NULL, the return value is discarded. @@ -602,17 +602,17 @@ static zend_always_inline void zend_call_known_instance_method_with_1_params( ZEND_API void zend_call_known_instance_method_with_2_params( zend_function *fn, zend_object *object, zval *retval_ptr, zval *param1, zval *param2); -ZEND_API int zend_set_hash_symbol(zval *symbol, const char *name, size_t name_length, zend_bool is_ref, int num_symbol_tables, ...); +ZEND_API ZEND_RESULT_CODE zend_set_hash_symbol(zval *symbol, const char *name, size_t name_length, zend_bool is_ref, int num_symbol_tables, ...); -ZEND_API int zend_delete_global_variable(zend_string *name); +ZEND_API ZEND_RESULT_CODE zend_delete_global_variable(zend_string *name); ZEND_API zend_array *zend_rebuild_symbol_table(void); ZEND_API void zend_attach_symbol_table(zend_execute_data *execute_data); ZEND_API void zend_detach_symbol_table(zend_execute_data *execute_data); -ZEND_API int zend_set_local_var(zend_string *name, zval *value, int force); -ZEND_API int zend_set_local_var_str(const char *name, size_t len, zval *value, int force); +ZEND_API ZEND_RESULT_CODE zend_set_local_var(zend_string *name, zval *value, bool force); +ZEND_API ZEND_RESULT_CODE zend_set_local_var_str(const char *name, size_t len, zval *value, bool force); -static zend_always_inline int zend_forbid_dynamic_call(const char *func_name) +static zend_always_inline ZEND_RESULT_CODE zend_forbid_dynamic_call(const char *func_name) { zend_execute_data *ex = EG(current_execute_data); ZEND_ASSERT(ex != NULL && ex->func != NULL); @@ -631,7 +631,7 @@ ZEND_API zend_bool zend_is_iterable(zval *iterable); ZEND_API zend_bool zend_is_countable(zval *countable); -ZEND_API int zend_get_default_from_internal_arg_info( +ZEND_API ZEND_RESULT_CODE zend_get_default_from_internal_arg_info( zval *default_value_zval, zend_internal_arg_info *arg_info); END_EXTERN_C() @@ -779,21 +779,21 @@ END_EXTERN_C() /* May modify arg in-place. Will free arg in failure case (and take ownership in success case). * Prefer using the ZEND_TRY_ASSIGN_* macros over these APIs. */ -ZEND_API int zend_try_assign_typed_ref_ex(zend_reference *ref, zval *zv, zend_bool strict); -ZEND_API int zend_try_assign_typed_ref(zend_reference *ref, zval *zv); - -ZEND_API int zend_try_assign_typed_ref_null(zend_reference *ref); -ZEND_API int zend_try_assign_typed_ref_bool(zend_reference *ref, zend_bool val); -ZEND_API int zend_try_assign_typed_ref_long(zend_reference *ref, zend_long lval); -ZEND_API int zend_try_assign_typed_ref_double(zend_reference *ref, double dval); -ZEND_API int zend_try_assign_typed_ref_empty_string(zend_reference *ref); -ZEND_API int zend_try_assign_typed_ref_str(zend_reference *ref, zend_string *str); -ZEND_API int zend_try_assign_typed_ref_string(zend_reference *ref, const char *string); -ZEND_API int zend_try_assign_typed_ref_stringl(zend_reference *ref, const char *string, size_t len); -ZEND_API int zend_try_assign_typed_ref_arr(zend_reference *ref, zend_array *arr); -ZEND_API int zend_try_assign_typed_ref_res(zend_reference *ref, zend_resource *res); -ZEND_API int zend_try_assign_typed_ref_zval(zend_reference *ref, zval *zv); -ZEND_API int zend_try_assign_typed_ref_zval_ex(zend_reference *ref, zval *zv, zend_bool strict); +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_ex(zend_reference *ref, zval *zv, zend_bool strict); +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref(zend_reference *ref, zval *zv); + +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_null(zend_reference *ref); +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_bool(zend_reference *ref, zend_bool val); +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_long(zend_reference *ref, zend_long lval); +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_double(zend_reference *ref, double dval); +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_empty_string(zend_reference *ref); +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_str(zend_reference *ref, zend_string *str); +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_string(zend_reference *ref, const char *string); +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_stringl(zend_reference *ref, const char *string, size_t len); +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_arr(zend_reference *ref, zend_array *arr); +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_res(zend_reference *ref, zend_resource *res); +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_zval(zend_reference *ref, zval *zv); +ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_zval_ex(zend_reference *ref, zval *zv, zend_bool strict); #define _ZEND_TRY_ASSIGN_NULL(zv, is_ref) do { \ zval *_zv = zv; \ @@ -1771,19 +1771,19 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_value_error(uint32_t arg_num /* Inlined implementations shared by new and old parameter parsing APIs */ -ZEND_API int ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **pce, uint32_t num, int check_null); -ZEND_API int ZEND_FASTCALL zend_parse_arg_bool_slow(zval *arg, zend_bool *dest); -ZEND_API int ZEND_FASTCALL zend_parse_arg_bool_weak(zval *arg, zend_bool *dest); -ZEND_API int ZEND_FASTCALL zend_parse_arg_long_slow(zval *arg, zend_long *dest); -ZEND_API int ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest); -ZEND_API int ZEND_FASTCALL zend_parse_arg_double_slow(zval *arg, double *dest); -ZEND_API int ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest); -ZEND_API int ZEND_FASTCALL zend_parse_arg_str_slow(zval *arg, zend_string **dest); -ZEND_API int ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **dest); -ZEND_API int ZEND_FASTCALL zend_parse_arg_number_slow(zval *arg, zval **dest); -ZEND_API int ZEND_FASTCALL zend_parse_arg_str_or_long_slow(zval *arg, zend_string **dest_str, zend_long *dest_long); - -static zend_always_inline int zend_parse_arg_bool(zval *arg, zend_bool *dest, zend_bool *is_null, int check_null) +ZEND_API bool ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **pce, uint32_t num, bool check_null); +ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_slow(zval *arg, zend_bool *dest); +ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_weak(zval *arg, zend_bool *dest); +ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_slow(zval *arg, zend_long *dest); +ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest); +ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_slow(zval *arg, double *dest); +ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest); +ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_slow(zval *arg, zend_string **dest); +ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **dest); +ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_slow(zval *arg, zval **dest); +ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_or_long_slow(zval *arg, zend_string **dest_str, zend_long *dest_long); + +static zend_always_inline bool zend_parse_arg_bool(zval *arg, zend_bool *dest, zend_bool *is_null, bool check_null) { if (check_null) { *is_null = 0; @@ -1801,7 +1801,7 @@ static zend_always_inline int zend_parse_arg_bool(zval *arg, zend_bool *dest, ze return 1; } -static zend_always_inline int zend_parse_arg_long(zval *arg, zend_long *dest, zend_bool *is_null, int check_null) +static zend_always_inline bool zend_parse_arg_long(zval *arg, zend_long *dest, zend_bool *is_null, bool check_null) { if (check_null) { *is_null = 0; @@ -1817,7 +1817,7 @@ static zend_always_inline int zend_parse_arg_long(zval *arg, zend_long *dest, ze return 1; } -static zend_always_inline int zend_parse_arg_double(zval *arg, double *dest, zend_bool *is_null, int check_null) +static zend_always_inline bool zend_parse_arg_double(zval *arg, double *dest, zend_bool *is_null, bool check_null) { if (check_null) { *is_null = 0; @@ -1833,7 +1833,7 @@ static zend_always_inline int zend_parse_arg_double(zval *arg, double *dest, zen return 1; } -static zend_always_inline int zend_parse_arg_number(zval *arg, zval **dest, int check_null) +static zend_always_inline bool zend_parse_arg_number(zval *arg, zval **dest, bool check_null) { if (EXPECTED(Z_TYPE_P(arg) == IS_LONG || Z_TYPE_P(arg) == IS_DOUBLE)) { *dest = arg; @@ -1845,7 +1845,7 @@ static zend_always_inline int zend_parse_arg_number(zval *arg, zval **dest, int return 1; } -static zend_always_inline int zend_parse_arg_str(zval *arg, zend_string **dest, int check_null) +static zend_always_inline bool zend_parse_arg_str(zval *arg, zend_string **dest, bool check_null) { if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) { *dest = Z_STR_P(arg); @@ -1857,7 +1857,7 @@ static zend_always_inline int zend_parse_arg_str(zval *arg, zend_string **dest, return 1; } -static zend_always_inline int zend_parse_arg_string(zval *arg, char **dest, size_t *dest_len, int check_null) +static zend_always_inline bool zend_parse_arg_string(zval *arg, char **dest, size_t *dest_len, bool check_null) { zend_string *str; @@ -1874,7 +1874,7 @@ static zend_always_inline int zend_parse_arg_string(zval *arg, char **dest, size return 1; } -static zend_always_inline int zend_parse_arg_path_str(zval *arg, zend_string **dest, int check_null) +static zend_always_inline bool zend_parse_arg_path_str(zval *arg, zend_string **dest, bool check_null) { if (!zend_parse_arg_str(arg, dest, check_null) || (*dest && UNEXPECTED(CHECK_NULL_PATH(ZSTR_VAL(*dest), ZSTR_LEN(*dest))))) { @@ -1883,7 +1883,7 @@ static zend_always_inline int zend_parse_arg_path_str(zval *arg, zend_string **d return 1; } -static zend_always_inline int zend_parse_arg_path(zval *arg, char **dest, size_t *dest_len, int check_null) +static zend_always_inline bool zend_parse_arg_path(zval *arg, char **dest, size_t *dest_len, bool check_null) { zend_string *str; @@ -1900,7 +1900,7 @@ static zend_always_inline int zend_parse_arg_path(zval *arg, char **dest, size_t return 1; } -static zend_always_inline int zend_parse_arg_array(zval *arg, zval **dest, int check_null, int or_object) +static zend_always_inline bool zend_parse_arg_array(zval *arg, zval **dest, bool check_null, bool or_object) { if (EXPECTED(Z_TYPE_P(arg) == IS_ARRAY) || (or_object && EXPECTED(Z_TYPE_P(arg) == IS_OBJECT))) { @@ -1913,7 +1913,7 @@ static zend_always_inline int zend_parse_arg_array(zval *arg, zval **dest, int c return 1; } -static zend_always_inline int zend_parse_arg_array_ht(zval *arg, HashTable **dest, int check_null, int or_object, int separate) +static zend_always_inline bool zend_parse_arg_array_ht(zval *arg, HashTable **dest, bool check_null, bool or_object, bool separate) { if (EXPECTED(Z_TYPE_P(arg) == IS_ARRAY)) { *dest = Z_ARRVAL_P(arg); @@ -1936,7 +1936,7 @@ static zend_always_inline int zend_parse_arg_array_ht(zval *arg, HashTable **des return 1; } -static zend_always_inline int zend_parse_arg_object(zval *arg, zval **dest, zend_class_entry *ce, int check_null) +static zend_always_inline bool zend_parse_arg_object(zval *arg, zval **dest, zend_class_entry *ce, bool check_null) { if (EXPECTED(Z_TYPE_P(arg) == IS_OBJECT) && (!ce || EXPECTED(instanceof_function(Z_OBJCE_P(arg), ce) != 0))) { @@ -1949,7 +1949,7 @@ static zend_always_inline int zend_parse_arg_object(zval *arg, zval **dest, zend return 1; } -static zend_always_inline int zend_parse_arg_resource(zval *arg, zval **dest, int check_null) +static zend_always_inline bool zend_parse_arg_resource(zval *arg, zval **dest, bool check_null) { if (EXPECTED(Z_TYPE_P(arg) == IS_RESOURCE)) { *dest = arg; @@ -1961,7 +1961,7 @@ static zend_always_inline int zend_parse_arg_resource(zval *arg, zval **dest, in return 1; } -static zend_always_inline int zend_parse_arg_func(zval *arg, zend_fcall_info *dest_fci, zend_fcall_info_cache *dest_fcc, int check_null, char **error) +static zend_always_inline bool zend_parse_arg_func(zval *arg, zend_fcall_info *dest_fci, zend_fcall_info_cache *dest_fcc, bool check_null, char **error) { if (check_null && UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) { dest_fci->size = 0; @@ -1973,7 +1973,7 @@ static zend_always_inline int zend_parse_arg_func(zval *arg, zend_fcall_info *de return 1; } -static zend_always_inline void zend_parse_arg_zval(zval *arg, zval **dest, int check_null) +static zend_always_inline void zend_parse_arg_zval(zval *arg, zval **dest, bool check_null) { *dest = (check_null && (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) || @@ -1981,13 +1981,13 @@ static zend_always_inline void zend_parse_arg_zval(zval *arg, zval **dest, int c UNEXPECTED(Z_TYPE_P(Z_REFVAL_P(arg)) == IS_NULL)))) ? NULL : arg; } -static zend_always_inline void zend_parse_arg_zval_deref(zval *arg, zval **dest, int check_null) +static zend_always_inline void zend_parse_arg_zval_deref(zval *arg, zval **dest, bool check_null) { *dest = (check_null && UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) ? NULL : arg; } -static zend_always_inline int zend_parse_arg_str_or_array_ht( - zval *arg, zend_string **dest_str, HashTable **dest_ht, int allow_null) +static zend_always_inline bool zend_parse_arg_str_or_array_ht( + zval *arg, zend_string **dest_str, HashTable **dest_ht, bool allow_null) { if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) { *dest_str = Z_STR_P(arg); @@ -2005,8 +2005,8 @@ static zend_always_inline int zend_parse_arg_str_or_array_ht( return 1; } -static zend_always_inline int zend_parse_arg_str_or_long(zval *arg, zend_string **dest_str, zend_long *dest_long, - zend_bool *is_null, int allow_null) +static zend_always_inline bool zend_parse_arg_str_or_long(zval *arg, zend_string **dest_str, zend_long *dest_long, + zend_bool *is_null, bool allow_null) { if (allow_null) { *is_null = 0; @@ -2025,8 +2025,8 @@ static zend_always_inline int zend_parse_arg_str_or_long(zval *arg, zend_string return 1; } -static zend_always_inline int zend_parse_arg_class_name_or_obj( - zval *arg, zend_class_entry **destination, int allow_null +static zend_always_inline bool zend_parse_arg_class_name_or_obj( + zval *arg, zend_class_entry **destination, bool allow_null ) { if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) { *destination = zend_lookup_class(Z_STR_P(arg)); @@ -2043,8 +2043,8 @@ static zend_always_inline int zend_parse_arg_class_name_or_obj( return 1; } -static zend_always_inline int zend_parse_arg_str_or_obj( - zval *arg, zend_string **destination_string, zend_object **destination_object, zend_class_entry *base_ce, int allow_null +static zend_always_inline bool zend_parse_arg_str_or_obj( + zval *arg, zend_string **destination_string, zend_object **destination_object, zend_class_entry *base_ce, bool allow_null ) { if (EXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) { if (!base_ce || EXPECTED(instanceof_function(Z_OBJCE_P(arg), base_ce))) { diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h index a9684b1dc2a2c..2dc4723978ddd 100644 --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@ -162,11 +162,11 @@ ZEND_API void ZEND_FASTCALL zend_hash_reverse_apply(HashTable *ht, apply_func_t /* Deletes */ -ZEND_API int ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key); -ZEND_API int ZEND_FASTCALL zend_hash_del_ind(HashTable *ht, zend_string *key); -ZEND_API int ZEND_FASTCALL zend_hash_str_del(HashTable *ht, const char *key, size_t len); -ZEND_API int ZEND_FASTCALL zend_hash_str_del_ind(HashTable *ht, const char *key, size_t len); -ZEND_API int ZEND_FASTCALL zend_hash_index_del(HashTable *ht, zend_ulong h); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_del_ind(HashTable *ht, zend_string *key); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_str_del(HashTable *ht, const char *key, size_t len); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_str_del_ind(HashTable *ht, const char *key, size_t len); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_index_del(HashTable *ht, zend_ulong h); ZEND_API void ZEND_FASTCALL zend_hash_del_bucket(HashTable *ht, Bucket *p); /* Data retrieval */ @@ -227,11 +227,11 @@ ZEND_API HashPosition ZEND_FASTCALL zend_hash_get_current_pos(const HashTable *h #define zend_hash_has_more_elements_ex(ht, pos) \ (zend_hash_get_current_key_type_ex(ht, pos) == HASH_KEY_NON_EXISTENT ? FAILURE : SUCCESS) -ZEND_API int ZEND_FASTCALL zend_hash_move_forward_ex(HashTable *ht, HashPosition *pos); -ZEND_API int ZEND_FASTCALL zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos); -ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, zend_ulong *num_index, HashPosition *pos); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_move_forward_ex(HashTable *ht, HashPosition *pos); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, zend_ulong *num_index, HashPosition *pos); ZEND_API void ZEND_FASTCALL zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, HashPosition *pos); -ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_type_ex(HashTable *ht, HashPosition *pos); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_get_current_key_type_ex(HashTable *ht, HashPosition *pos); ZEND_API zval* ZEND_FASTCALL zend_hash_get_current_data_ex(HashTable *ht, HashPosition *pos); ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_reset_ex(HashTable *ht, HashPosition *pos); ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_end_ex(HashTable *ht, HashPosition *pos); @@ -305,7 +305,7 @@ ZEND_API void ZEND_FASTCALL zend_symtable_clean(HashTable *ht); ZEND_API HashTable* ZEND_FASTCALL zend_symtable_to_proptable(HashTable *ht); ZEND_API HashTable* ZEND_FASTCALL zend_proptable_to_symtable(HashTable *ht, zend_bool always_duplicate); -ZEND_API int ZEND_FASTCALL _zend_handle_numeric_str_ex(const char *key, size_t length, zend_ulong *idx); +ZEND_API bool ZEND_FASTCALL _zend_handle_numeric_str_ex(const char *key, size_t length, zend_ulong *idx); ZEND_API uint32_t ZEND_FASTCALL zend_hash_iterator_add(HashTable *ht, HashPosition pos); ZEND_API HashPosition ZEND_FASTCALL zend_hash_iterator_pos(uint32_t idx, HashTable *ht); @@ -351,7 +351,7 @@ END_EXTERN_C() #define ZEND_INIT_SYMTABLE_EX(ht, n, persistent) \ zend_hash_init(ht, n, NULL, ZVAL_PTR_DTOR, persistent) -static zend_always_inline int _zend_handle_numeric_str(const char *key, size_t length, zend_ulong *idx) +static zend_always_inline bool _zend_handle_numeric_str(const char *key, size_t length, zend_ulong *idx) { const char *tmp = key; @@ -396,7 +396,7 @@ static zend_always_inline zval *zend_hash_find_ex_ind(const HashTable *ht, zend_ } -static zend_always_inline int zend_hash_exists_ind(const HashTable *ht, zend_string *key) +static zend_always_inline bool zend_hash_exists_ind(const HashTable *ht, zend_string *key) { zval *zv; @@ -416,7 +416,7 @@ static zend_always_inline zval *zend_hash_str_find_ind(const HashTable *ht, cons } -static zend_always_inline int zend_hash_str_exists_ind(const HashTable *ht, const char *str, size_t len) +static zend_always_inline bool zend_hash_str_exists_ind(const HashTable *ht, const char *str, size_t len) { zval *zv; @@ -460,7 +460,7 @@ static zend_always_inline zval *zend_symtable_update_ind(HashTable *ht, zend_str } -static zend_always_inline int zend_symtable_del(HashTable *ht, zend_string *key) +static zend_always_inline ZEND_RESULT_CODE zend_symtable_del(HashTable *ht, zend_string *key) { zend_ulong idx; @@ -472,7 +472,7 @@ static zend_always_inline int zend_symtable_del(HashTable *ht, zend_string *key) } -static zend_always_inline int zend_symtable_del_ind(HashTable *ht, zend_string *key) +static zend_always_inline ZEND_RESULT_CODE zend_symtable_del_ind(HashTable *ht, zend_string *key) { zend_ulong idx; @@ -508,7 +508,7 @@ static zend_always_inline zval *zend_symtable_find_ind(const HashTable *ht, zend } -static zend_always_inline int zend_symtable_exists(HashTable *ht, zend_string *key) +static zend_always_inline ZEND_RESULT_CODE zend_symtable_exists(HashTable *ht, zend_string *key) { zend_ulong idx; @@ -520,7 +520,7 @@ static zend_always_inline int zend_symtable_exists(HashTable *ht, zend_string *k } -static zend_always_inline int zend_symtable_exists_ind(HashTable *ht, zend_string *key) +static zend_always_inline ZEND_RESULT_CODE zend_symtable_exists_ind(HashTable *ht, zend_string *key) { zend_ulong idx; @@ -556,7 +556,7 @@ static zend_always_inline zval *zend_symtable_str_update_ind(HashTable *ht, cons } -static zend_always_inline int zend_symtable_str_del(HashTable *ht, const char *str, size_t len) +static zend_always_inline ZEND_RESULT_CODE zend_symtable_str_del(HashTable *ht, const char *str, size_t len) { zend_ulong idx; @@ -568,7 +568,7 @@ static zend_always_inline int zend_symtable_str_del(HashTable *ht, const char *s } -static zend_always_inline int zend_symtable_str_del_ind(HashTable *ht, const char *str, size_t len) +static zend_always_inline ZEND_RESULT_CODE zend_symtable_str_del_ind(HashTable *ht, const char *str, size_t len) { zend_ulong idx; @@ -592,7 +592,7 @@ static zend_always_inline zval *zend_symtable_str_find(HashTable *ht, const char } -static zend_always_inline int zend_symtable_str_exists(HashTable *ht, const char *str, size_t len) +static zend_always_inline ZEND_RESULT_CODE zend_symtable_str_exists(HashTable *ht, const char *str, size_t len) { zend_ulong idx; @@ -1149,7 +1149,7 @@ static zend_always_inline void *zend_hash_get_current_data_ptr_ex(HashTable *ht, ZEND_HASH_FILL_FINISH(); \ } while (0) -static zend_always_inline zval *_zend_hash_append_ex(HashTable *ht, zend_string *key, zval *zv, int interned) +static zend_always_inline zval *_zend_hash_append_ex(HashTable *ht, zend_string *key, zval *zv, bool interned) { uint32_t idx = ht->nNumUsed++; uint32_t nIndex; @@ -1175,7 +1175,7 @@ static zend_always_inline zval *_zend_hash_append(HashTable *ht, zend_string *ke return _zend_hash_append_ex(ht, key, zv, 0); } -static zend_always_inline zval *_zend_hash_append_ptr_ex(HashTable *ht, zend_string *key, void *ptr, int interned) +static zend_always_inline zval *_zend_hash_append_ptr_ex(HashTable *ht, zend_string *key, void *ptr, bool interned) { uint32_t idx = ht->nNumUsed++; uint32_t nIndex; From 26f0ad740099876cc3045797e34f519eccc19baf Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 15 Aug 2020 22:26:38 +0200 Subject: [PATCH 111/170] Boolify functions in zend_ast.c --- Zend/zend_API.c | 20 ++++++++++---------- Zend/zend_ast.c | 16 ++++++++-------- Zend/zend_ast.h | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 78867b804318b..98905939c142e 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -369,7 +369,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_value_error(uint32_t arg_num } /* }}} */ -ZEND_API bool ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **pce, uint32_t num, int check_null) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **pce, uint32_t num, bool check_null) /* {{{ */ { zend_class_entry *ce_base = *pce; @@ -593,8 +593,8 @@ static const char *zend_parse_arg_impl(zval *arg, va_list *va, const char **spec { const char *spec_walk = *spec; char c = *spec_walk++; - int check_null = 0; - int separate = 0; + bool check_null = 0; + bool separate = 0; zval *real_arg = arg; /* scan through modifiers */ @@ -1436,7 +1436,7 @@ ZEND_API void add_assoc_null_ex(zval *arg, const char *key, size_t key_len) /* { } /* }}} */ -ZEND_API void add_assoc_bool_ex(zval *arg, const char *key, size_t key_len, int b) /* {{{ */ +ZEND_API void add_assoc_bool_ex(zval *arg, const char *key, size_t key_len, bool b) /* {{{ */ { zval tmp; @@ -1514,7 +1514,7 @@ ZEND_API void add_index_null(zval *arg, zend_ulong index) /* {{{ */ } /* }}} */ -ZEND_API void add_index_bool(zval *arg, zend_ulong index, int b) /* {{{ */ +ZEND_API void add_index_bool(zval *arg, zend_ulong index, bool b) /* {{{ */ { zval tmp; @@ -2860,7 +2860,7 @@ static zend_always_inline zend_class_entry *get_scope(zend_execute_data *frame) return frame && frame->func ? frame->func->common.scope : NULL; } -static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *scope, zend_execute_data *frame, zend_fcall_info_cache *fcc, int *strict_class, char **error) /* {{{ */ +static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *scope, zend_execute_data *frame, zend_fcall_info_cache *fcc, bool *strict_class, char **error) /* {{{ */ { bool ret = 0; zend_class_entry *ce; @@ -2949,7 +2949,7 @@ ZEND_API void zend_release_fcall_info_cache(zend_fcall_info_cache *fcc) { fcc->function_handler = NULL; } -static zend_always_inline bool zend_is_callable_check_func(int check_flags, zval *callable, zend_execute_data *frame, zend_fcall_info_cache *fcc, int strict_class, char **error) /* {{{ */ +static zend_always_inline bool zend_is_callable_check_func(int check_flags, zval *callable, zend_execute_data *frame, zend_fcall_info_cache *fcc, bool strict_class, char **error) /* {{{ */ { zend_class_entry *ce_org = fcc->calling_scope; bool retval = 0; @@ -3237,7 +3237,7 @@ static zend_always_inline zend_bool zend_is_callable_impl( { zend_bool ret; zend_fcall_info_cache fcc_local; - int strict_class = 0; + bool strict_class = 0; if (fcc == NULL) { fcc = &fcc_local; @@ -3409,7 +3409,7 @@ ZEND_API ZEND_RESULT_CODE zend_fcall_info_init(zval *callable, uint32_t check_fl } /* }}} */ -ZEND_API void zend_fcall_info_args_clear(zend_fcall_info *fci, int free_mem) /* {{{ */ +ZEND_API void zend_fcall_info_args_clear(zend_fcall_info *fci, bool free_mem) /* {{{ */ { if (fci->params) { zval *p = fci->params; @@ -4129,7 +4129,7 @@ ZEND_API ZEND_RESULT_CODE zend_update_static_property_ex(zend_class_entry *scope ZEND_API ZEND_RESULT_CODE zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value) /* {{{ */ { zend_string *key = zend_string_init(name, name_length, 0); - int retval = zend_update_static_property_ex(scope, key, value); + bool retval = zend_update_static_property_ex(scope, key, value); zend_string_efree(key); return retval; } diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index e2a2aca698d48..c417189dd30fd 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -438,7 +438,7 @@ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_list_add(zend_ast *ast, zend_ast *op) return (zend_ast *) list; } -static int zend_ast_add_array_element(zval *result, zval *offset, zval *expr) +static ZEND_RESULT_CODE zend_ast_add_array_element(zval *result, zval *offset, zval *expr) { switch (Z_TYPE_P(offset)) { case IS_UNDEF: @@ -478,7 +478,7 @@ static int zend_ast_add_array_element(zval *result, zval *offset, zval *expr) return SUCCESS; } -static int zend_ast_add_unpacked_element(zval *result, zval *expr) { +static ZEND_RESULT_CODE zend_ast_add_unpacked_element(zval *result, zval *expr) { if (EXPECTED(Z_TYPE_P(expr) == IS_ARRAY)) { HashTable *ht = Z_ARRVAL_P(expr); zval *val; @@ -505,10 +505,10 @@ static int zend_ast_add_unpacked_element(zval *result, zval *expr) { return FAILURE; } -ZEND_API int ZEND_FASTCALL zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *scope) +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *scope) { zval op1, op2; - int ret = SUCCESS; + ZEND_RESULT_CODE ret = SUCCESS; switch (ast->kind) { case ZEND_AST_BINARY_OP: @@ -1059,7 +1059,7 @@ static ZEND_COLD void zend_ast_export_ns_name(smart_str *str, zend_ast *ast, int zend_ast_export_ex(str, ast, priority, indent); } -static ZEND_COLD int zend_ast_valid_var_char(char ch) +static ZEND_COLD bool zend_ast_valid_var_char(char ch) { unsigned char c = (unsigned char)ch; @@ -1072,7 +1072,7 @@ static ZEND_COLD int zend_ast_valid_var_char(char ch) return 1; } -static ZEND_COLD int zend_ast_valid_var_name(const char *s, size_t len) +static ZEND_COLD bool zend_ast_valid_var_name(const char *s, size_t len) { unsigned char c; size_t i; @@ -1098,7 +1098,7 @@ static ZEND_COLD int zend_ast_valid_var_name(const char *s, size_t len) return 1; } -static ZEND_COLD int zend_ast_var_needs_braces(char ch) +static ZEND_COLD bool zend_ast_var_needs_braces(char ch) { return ch == '[' || zend_ast_valid_var_char(ch); } @@ -1121,7 +1121,7 @@ static ZEND_COLD void zend_ast_export_var(smart_str *str, zend_ast *ast, int pri smart_str_appendc(str, '}'); } -static ZEND_COLD void zend_ast_export_list(smart_str *str, zend_ast_list *list, int separator, int priority, int indent) +static ZEND_COLD void zend_ast_export_list(smart_str *str, zend_ast_list *list, bool separator, int priority, int indent) { uint32_t i = 0; diff --git a/Zend/zend_ast.h b/Zend/zend_ast.h index 97236c5560c07..36f1ab665939f 100644 --- a/Zend/zend_ast.h +++ b/Zend/zend_ast.h @@ -290,7 +290,7 @@ ZEND_API zend_ast *zend_ast_create_decl( zend_string *name, zend_ast *child0, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4 ); -ZEND_API int ZEND_FASTCALL zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *scope); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *scope); ZEND_API zend_string *zend_ast_export(const char *prefix, zend_ast *ast, const char *suffix); ZEND_API zend_ast_ref * ZEND_FASTCALL zend_ast_copy(zend_ast *ast); From 06f1fba7b1032ab15160bbe87b08aa9328d32743 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 15 Aug 2020 22:27:40 +0200 Subject: [PATCH 112/170] Boolify functions in zend_attributes.c --- Zend/zend_attributes.c | 4 ++-- Zend/zend_attributes.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Zend/zend_attributes.c b/Zend/zend_attributes.c index e55f27f84a889..6ff35cbe4cd3c 100644 --- a/Zend/zend_attributes.c +++ b/Zend/zend_attributes.c @@ -116,7 +116,7 @@ ZEND_API zend_attribute *zend_get_parameter_attribute_str(HashTable *attributes, return get_attribute_str(attributes, str, len, offset + 1); } -ZEND_API int zend_get_attribute_value(zval *ret, zend_attribute *attr, uint32_t i, zend_class_entry *scope) +ZEND_API ZEND_RESULT_CODE zend_get_attribute_value(zval *ret, zend_attribute *attr, uint32_t i, zend_class_entry *scope) { if (i >= attr->argc) { return FAILURE; @@ -175,7 +175,7 @@ ZEND_API zend_bool zend_is_attribute_repeated(HashTable *attributes, zend_attrib return 0; } -static zend_always_inline void free_attribute(zend_attribute *attr, int persistent) +static zend_always_inline void free_attribute(zend_attribute *attr, bool persistent) { uint32_t i; diff --git a/Zend/zend_attributes.h b/Zend/zend_attributes.h index 6b7150a363dd9..02b0311a3465b 100644 --- a/Zend/zend_attributes.h +++ b/Zend/zend_attributes.h @@ -63,7 +63,7 @@ ZEND_API zend_attribute *zend_get_attribute_str(HashTable *attributes, const cha ZEND_API zend_attribute *zend_get_parameter_attribute(HashTable *attributes, zend_string *lcname, uint32_t offset); ZEND_API zend_attribute *zend_get_parameter_attribute_str(HashTable *attributes, const char *str, size_t len, uint32_t offset); -ZEND_API int zend_get_attribute_value(zval *ret, zend_attribute *attr, uint32_t i, zend_class_entry *scope); +ZEND_API ZEND_RESULT_CODE zend_get_attribute_value(zval *ret, zend_attribute *attr, uint32_t i, zend_class_entry *scope); ZEND_API zend_string *zend_get_attribute_target_names(uint32_t targets); ZEND_API zend_bool zend_is_attribute_repeated(HashTable *attributes, zend_attribute *attr); From 76e67628b85340cf1dcd009de15c0cd4238f0bbe Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 15 Aug 2020 22:29:07 +0200 Subject: [PATCH 113/170] Boolify functions in zend_bitset.h --- Zend/zend_bitset.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_bitset.h b/Zend/zend_bitset.h index 2a227e482277b..9e196713f06fe 100644 --- a/Zend/zend_bitset.h +++ b/Zend/zend_bitset.h @@ -102,7 +102,7 @@ static inline void zend_bitset_clear(zend_bitset set, uint32_t len) memset(set, 0, len * ZEND_BITSET_ELM_SIZE); } -static inline int zend_bitset_empty(zend_bitset set, uint32_t len) +static inline bool zend_bitset_empty(zend_bitset set, uint32_t len) { uint32_t i; for (i = 0; i < len; i++) { From 002c1f6205c116bbaaa2a1c1d289530074583211 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 15 Aug 2020 22:34:50 +0200 Subject: [PATCH 114/170] Boolify functions in zend_builtin_functions.c --- Zend/zend_builtin_functions.c | 14 +++++++------- Zend/zend_builtin_functions.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 588c3c33d7f71..ba10e62522259 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -57,7 +57,7 @@ zend_module_entry zend_builtin_module = { /* {{{ */ }; /* }}} */ -int zend_startup_builtin_functions(void) /* {{{ */ +ZEND_RESULT_CODE zend_startup_builtin_functions(void) /* {{{ */ { zend_builtin_module.module_number = 0; zend_builtin_module.type = MODULE_PERSISTENT; @@ -420,9 +420,9 @@ ZEND_FUNCTION(error_reporting) } /* }}} */ -static int validate_constant_array_argument(HashTable *ht, int argument_number) /* {{{ */ +static bool validate_constant_array_argument(HashTable *ht, int argument_number) /* {{{ */ { - int ret = 1; + bool ret = 1; zval *val; GC_PROTECT_RECURSION(ht); @@ -698,7 +698,7 @@ ZEND_FUNCTION(is_a) /* }}} */ /* {{{ add_class_vars */ -static void add_class_vars(zend_class_entry *scope, zend_class_entry *ce, int statics, zval *return_value) +static void add_class_vars(zend_class_entry *scope, zend_class_entry *ce, bool statics, zval *return_value) { zend_property_info *prop_info; zval *prop, prop_copy; @@ -865,10 +865,10 @@ ZEND_FUNCTION(get_mangled_object_vars) } /* }}} */ -static int same_name(zend_string *key, zend_string *name) /* {{{ */ +static bool same_name(zend_string *key, zend_string *name) /* {{{ */ { zend_string *lcname; - int ret; + bool ret; if (key == name) { return 1; @@ -2112,7 +2112,7 @@ ZEND_FUNCTION(get_extension_funcs) { zend_string *extension_name; zend_string *lcname; - int array; + bool array; zend_module_entry *module; zend_function *zif; diff --git a/Zend/zend_builtin_functions.h b/Zend/zend_builtin_functions.h index cfc347ed41ffc..4fda0e0abfa14 100644 --- a/Zend/zend_builtin_functions.h +++ b/Zend/zend_builtin_functions.h @@ -20,7 +20,7 @@ #ifndef ZEND_BUILTIN_FUNCTIONS_H #define ZEND_BUILTIN_FUNCTIONS_H -int zend_startup_builtin_functions(void); +ZEND_RESULT_CODE zend_startup_builtin_functions(void); BEGIN_EXTERN_C() ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int options, int limit); From a35d350e2070d98dae037989df5ac7f6fae8dcf5 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 15 Aug 2020 22:51:07 +0200 Subject: [PATCH 115/170] Boolify functions in zend_closure.c --- Zend/zend_closures.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index 6b36bede37cbe..b2d6456cf7727 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -273,7 +273,7 @@ static ZEND_NAMED_FUNCTION(zend_closure_call_magic) /* {{{ */ { } /* }}} */ -static int zend_create_closure_from_callable(zval *return_value, zval *callable, char **error) /* {{{ */ { +static ZEND_RESULT_CODE zend_create_closure_from_callable(zval *return_value, zval *callable, char **error) /* {{{ */ { zend_fcall_info_cache fcc; zend_function *mptr; zval instance; @@ -361,6 +361,7 @@ static ZEND_COLD zend_function *zend_closure_get_constructor(zend_object *object } /* }}} */ +/* int return due to Object Handler API */ static int zend_closure_compare(zval *o1, zval *o2) /* {{{ */ { ZEND_COMPARE_OBJECTS_FALLBACK(o1, o2); @@ -513,6 +514,7 @@ int zend_closure_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_f } /* }}} */ +/* *is_temp is int due to Object Handler API */ static HashTable *zend_closure_get_debug_info(zend_object *object, int *is_temp) /* {{{ */ { zend_closure *closure = (zend_closure *)object; From 640bb8b46a2fd6c2606c88633f00dd0a3a4aa426 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 15 Aug 2020 23:44:20 +0200 Subject: [PATCH 116/170] boolify zend_constant.c --- Zend/zend_constants.c | 15 ++++++--------- Zend/zend_constants.h | 8 ++++---- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c index fe37e3fbd0454..2858fc15000d0 100644 --- a/Zend/zend_constants.c +++ b/Zend/zend_constants.c @@ -98,12 +98,10 @@ void clean_module_constants(int module_number) zend_hash_apply_with_argument(EG(zend_constants), clean_module_constant, (void *) &module_number); } - -int zend_startup_constants(void) +void zend_startup_constants(void) { EG(zend_constants) = (HashTable *) malloc(sizeof(HashTable)); zend_hash_init(EG(zend_constants), 128, NULL, ZEND_CONSTANT_DTOR, 1); - return SUCCESS; } @@ -144,11 +142,10 @@ void zend_register_standard_constants(void) } -int zend_shutdown_constants(void) +void zend_shutdown_constants(void) { zend_hash_destroy(EG(zend_constants)); free(EG(zend_constants)); - return SUCCESS; } ZEND_API void zend_register_null_constant(const char *name, size_t name_len, int flags, int module_number) @@ -266,7 +263,7 @@ ZEND_API zend_constant *_zend_get_special_const(const char *name, size_t len) /* } /* }}} */ -ZEND_API int zend_verify_const_access(zend_class_constant *c, zend_class_entry *scope) /* {{{ */ +ZEND_API bool zend_verify_const_access(zend_class_constant *c, zend_class_entry *scope) /* {{{ */ { if (Z_ACCESS_FLAGS(c->value) & ZEND_ACC_PUBLIC) { return 1; @@ -396,7 +393,7 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope, } if (ret_constant && Z_TYPE_P(ret_constant) == IS_CONSTANT_AST) { - int ret; + ZEND_RESULT_CODE ret; if (IS_CONSTANT_VISITED(ret_constant)) { zend_throw_error(NULL, "Cannot declare self-referencing constant %s::%s", ZSTR_VAL(class_name), ZSTR_VAL(constant_name)); @@ -480,11 +477,11 @@ static void* zend_hash_add_constant(HashTable *ht, zend_string *key, zend_consta return ret; } -ZEND_API int zend_register_constant(zend_constant *c) +ZEND_API ZEND_RESULT_CODE zend_register_constant(zend_constant *c) { zend_string *lowercase_name = NULL; zend_string *name; - int ret = SUCCESS; + ZEND_RESULT_CODE ret = SUCCESS; zend_bool persistent = (ZEND_CONSTANT_FLAGS(c) & CONST_PERSISTENT) != 0; #if 0 diff --git a/Zend/zend_constants.h b/Zend/zend_constants.h index 9b5a63a0260d9..6090623c07820 100644 --- a/Zend/zend_constants.h +++ b/Zend/zend_constants.h @@ -69,10 +69,10 @@ typedef struct _zend_constant { BEGIN_EXTERN_C() void clean_module_constants(int module_number); void free_zend_constant(zval *zv); -int zend_startup_constants(void); -int zend_shutdown_constants(void); +void zend_startup_constants(void); +void zend_shutdown_constants(void); void zend_register_standard_constants(void); -ZEND_API int zend_verify_const_access(zend_class_constant *c, zend_class_entry *ce); +ZEND_API bool zend_verify_const_access(zend_class_constant *c, zend_class_entry *ce); ZEND_API zval *zend_get_constant(zend_string *name); ZEND_API zval *zend_get_constant_str(const char *name, size_t name_len); ZEND_API zval *zend_get_constant_ex(zend_string *name, zend_class_entry *scope, uint32_t flags); @@ -82,7 +82,7 @@ ZEND_API void zend_register_long_constant(const char *name, size_t name_len, zen ZEND_API void zend_register_double_constant(const char *name, size_t name_len, double dval, int flags, int module_number); ZEND_API void zend_register_string_constant(const char *name, size_t name_len, const char *strval, int flags, int module_number); ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len, const char *strval, size_t strlen, int flags, int module_number); -ZEND_API int zend_register_constant(zend_constant *c); +ZEND_API ZEND_RESULT_CODE zend_register_constant(zend_constant *c); #ifdef ZTS void zend_copy_constants(HashTable *target, HashTable *sourc); #endif From 88efdd17995153b3827410e5cd1e6fa4b662182d Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 15 Aug 2020 23:49:12 +0200 Subject: [PATCH 117/170] Boolify zend_exception.c --- Zend/zend_exceptions.c | 8 ++++---- Zend/zend_exceptions.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index 2923165e56651..7d709882eedce 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -50,7 +50,7 @@ ZEND_API void (*zend_throw_exception_hook)(zend_object *ex); static zend_object_handlers default_exception_handlers; /* {{{ zend_implement_throwable */ -static int zend_implement_throwable(zend_class_entry *interface, zend_class_entry *class_type) +static ZEND_RESULT_CODE zend_implement_throwable(zend_class_entry *interface, zend_class_entry *class_type) { if (instanceof_function(class_type, zend_ce_exception) || instanceof_function(class_type, zend_ce_error)) { return SUCCESS; @@ -213,7 +213,7 @@ ZEND_API void zend_clear_exception(void) /* {{{ */ } /* }}} */ -static zend_object *zend_default_exception_new_ex(zend_class_entry *class_type, int skip_top_traces) /* {{{ */ +static zend_object *zend_default_exception_new_ex(zend_class_entry *class_type, bool skip_top_traces) /* {{{ */ { zval tmp; zval trace; @@ -908,11 +908,11 @@ static void zend_error_va(int type, const char *file, uint32_t lineno, const cha /* }}} */ /* This function doesn't return if it uses E_ERROR */ -ZEND_API ZEND_COLD int zend_exception_error(zend_object *ex, int severity) /* {{{ */ +ZEND_API ZEND_COLD ZEND_RESULT_CODE zend_exception_error(zend_object *ex, int severity) /* {{{ */ { zval exception, rv; zend_class_entry *ce_exception; - int result = FAILURE; + ZEND_RESULT_CODE result = FAILURE; ZVAL_OBJ(&exception, ex); ce_exception = ex->ce; diff --git a/Zend/zend_exceptions.h b/Zend/zend_exceptions.h index 7e8c73b1e920a..78eff15a40e12 100644 --- a/Zend/zend_exceptions.h +++ b/Zend/zend_exceptions.h @@ -67,7 +67,7 @@ ZEND_API zend_object *zend_throw_error_exception(zend_class_entry *exception_ce, extern ZEND_API void (*zend_throw_exception_hook)(zend_object *ex); /* show an exception using zend_error(severity,...), severity should be E_ERROR */ -ZEND_API ZEND_COLD int zend_exception_error(zend_object *exception, int severity); +ZEND_API ZEND_COLD ZEND_RESULT_CODE zend_exception_error(zend_object *exception, int severity); ZEND_API ZEND_COLD void zend_throw_unwind_exit(void); ZEND_API zend_bool zend_is_unwind_exit(zend_object *ex); From efef6f7fe4e4604345e7716416181f1ea4cb4669 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 15 Aug 2020 23:51:42 +0200 Subject: [PATCH 118/170] Voidify zend_execute.c --- Zend/zend_execute.c | 39 ++++++++++++++++++--------------------- Zend/zend_execute.h | 10 +++++----- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 601b5221eef2c..0574c6196f60e 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1225,11 +1225,10 @@ static int zend_verify_internal_return_type(zend_function *zf, zval *ret) } #endif -static ZEND_COLD int zend_verify_missing_return_type(const zend_function *zf, void **cache_slot) +static ZEND_COLD void zend_verify_missing_return_type(const zend_function *zf, void **cache_slot) { /* VERIFY_RETURN_TYPE is not emitted for "void" functions, so this is always an error. */ zend_verify_return_error(zf, cache_slot, NULL); - return 0; } static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_use_object_as_array(void) @@ -1900,7 +1899,7 @@ static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_undefined_index(const zend_error(E_WARNING, "Undefined array key \"%s\"", ZSTR_VAL(offset)); } -ZEND_API ZEND_COLD int ZEND_FASTCALL zend_undefined_offset_write(HashTable *ht, zend_long lval) +ZEND_API ZEND_COLD ZEND_RESULT_CODE ZEND_FASTCALL zend_undefined_offset_write(HashTable *ht, zend_long lval) { /* The array may be destroyed while throwing the notice. * Temporarily increase the refcount to detect this situation. */ @@ -1918,7 +1917,7 @@ ZEND_API ZEND_COLD int ZEND_FASTCALL zend_undefined_offset_write(HashTable *ht, return SUCCESS; } -ZEND_API ZEND_COLD int ZEND_FASTCALL zend_undefined_index_write(HashTable *ht, zend_string *offset) +ZEND_API ZEND_COLD ZEND_RESULT_CODE ZEND_FASTCALL zend_undefined_index_write(HashTable *ht, zend_string *offset) { /* The array may be destroyed while throwing the notice. * Temporarily increase the refcount to detect this situation. */ @@ -2307,7 +2306,7 @@ static zend_never_inline void ZEND_FASTCALL zend_fetch_dimension_address_UNSET(z zend_fetch_dimension_address(result, container_ptr, dim, dim_type, BP_VAR_UNSET EXECUTE_DATA_CC); } -static zend_always_inline void zend_fetch_dimension_address_read(zval *result, zval *container, zval *dim, int dim_type, int type, int is_list, int slow EXECUTE_DATA_DC) +static zend_always_inline void zend_fetch_dimension_address_read(zval *result, zval *container, zval *dim, int dim_type, int type, bool is_list, int slow EXECUTE_DATA_DC) { zval *retval; @@ -2482,7 +2481,7 @@ static zend_never_inline zval* ZEND_FASTCALL zend_find_array_dim_slow(HashTable } } -static zend_never_inline int ZEND_FASTCALL zend_isset_dim_slow(zval *container, zval *offset EXECUTE_DATA_DC) +static zend_never_inline bool ZEND_FASTCALL zend_isset_dim_slow(zval *container, zval *offset EXECUTE_DATA_DC) { if (/*OP2_TYPE == IS_CV &&*/ UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) { offset = ZVAL_UNDEFINED_OP2(); @@ -2521,7 +2520,7 @@ static zend_never_inline int ZEND_FASTCALL zend_isset_dim_slow(zval *container, } } -static zend_never_inline int ZEND_FASTCALL zend_isempty_dim_slow(zval *container, zval *offset EXECUTE_DATA_DC) +static zend_never_inline bool ZEND_FASTCALL zend_isempty_dim_slow(zval *container, zval *offset EXECUTE_DATA_DC) { if (/*OP2_TYPE == IS_CV &&*/ UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) { offset = ZVAL_UNDEFINED_OP2(); @@ -2890,7 +2889,7 @@ static zend_never_inline void zend_assign_to_property_reference_var_var(zval *co OPLINE_CC EXECUTE_DATA_CC); } -static zend_never_inline int zend_fetch_static_property_address_ex(zval **retval, zend_property_info **prop_info, uint32_t cache_slot, int fetch_type OPLINE_DC EXECUTE_DATA_DC) { +static zend_never_inline ZEND_RESULT_CODE zend_fetch_static_property_address_ex(zval **retval, zend_property_info **prop_info, uint32_t cache_slot, int fetch_type OPLINE_DC EXECUTE_DATA_DC) { zend_string *name; zend_class_entry *ce; zend_property_info *property_info; @@ -2968,8 +2967,7 @@ static zend_never_inline int zend_fetch_static_property_address_ex(zval **retval } -static zend_always_inline int zend_fetch_static_property_address(zval **retval, zend_property_info **prop_info, uint32_t cache_slot, int fetch_type, int flags OPLINE_DC EXECUTE_DATA_DC) { - int success; +static zend_always_inline ZEND_RESULT_CODE zend_fetch_static_property_address(zval **retval, zend_property_info **prop_info, uint32_t cache_slot, int fetch_type, int flags OPLINE_DC EXECUTE_DATA_DC) { zend_property_info *property_info; if (opline->op1_type == IS_CONST && (opline->op2_type == IS_CONST || (opline->op2_type == IS_UNUSED && (opline->op2.num == ZEND_FETCH_CLASS_SELF || opline->op2.num == ZEND_FETCH_CLASS_PARENT))) && EXPECTED(CACHED_PTR(cache_slot) != NULL)) { @@ -2985,6 +2983,7 @@ static zend_always_inline int zend_fetch_static_property_address(zval **retval, return FAILURE; } } else { + ZEND_RESULT_CODE success; success = zend_fetch_static_property_address_ex(retval, &property_info, cache_slot, fetch_type OPLINE_CC EXECUTE_DATA_CC); if (UNEXPECTED(success != SUCCESS)) { return FAILURE; @@ -3046,7 +3045,7 @@ ZEND_API ZEND_COLD void zend_throw_conflicting_coercion_error(zend_property_info } /* 1: valid, 0: invalid, -1: may be valid after type coercion */ -static zend_always_inline int i_zend_verify_type_assignable_zval( +static zend_always_inline bool i_zend_verify_type_assignable_zval( zend_property_info *info, zval *zv, zend_bool strict) { zend_type type = info->type; uint32_t type_mask; @@ -3347,7 +3346,7 @@ static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_wrong_clone_call(zend zend_hash_apply(EX(symbol_table), zend_check_symbol); \ } -static int zend_check_symbol(zval *pz) +static void zend_check_symbol(zval *pz) { if (Z_TYPE_P(pz) == IS_INDIRECT) { pz = Z_INDIRECT_P(pz); @@ -3364,8 +3363,6 @@ static int zend_check_symbol(zval *pz) /* OBJ-TBI - doesn't support new object model! */ zend_hash_apply(Z_OBJPROP_P(pz), zend_check_symbol); } - - return 0; } @@ -4285,8 +4282,8 @@ static zend_never_inline zend_bool ZEND_FASTCALL zend_fe_reset_iterator(zval *ar } /* }}} */ -static zend_always_inline int _zend_quick_get_constant( - const zval *key, uint32_t flags, int check_defined_only OPLINE_DC EXECUTE_DATA_DC) /* {{{ */ +static zend_always_inline ZEND_RESULT_CODE _zend_quick_get_constant( + const zval *key, uint32_t flags, bool check_defined_only OPLINE_DC EXECUTE_DATA_DC) /* {{{ */ { zval *zv; zend_constant *c = NULL; @@ -4330,7 +4327,7 @@ static zend_never_inline void ZEND_FASTCALL zend_quick_get_constant( _zend_quick_get_constant(key, flags, 0 OPLINE_CC EXECUTE_DATA_CC); } /* }}} */ -static zend_never_inline int ZEND_FASTCALL zend_quick_check_constant( +static zend_never_inline ZEND_RESULT_CODE ZEND_FASTCALL zend_quick_check_constant( const zval *key OPLINE_DC EXECUTE_DATA_DC) /* {{{ */ { return _zend_quick_get_constant(key, 0, 1 OPLINE_CC EXECUTE_DATA_CC); @@ -4453,7 +4450,7 @@ static void end_fake_frame(zend_execute_data *call) { } } -ZEND_API int ZEND_FASTCALL zend_handle_undef_args(zend_execute_data *call) { +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_handle_undef_args(zend_execute_data *call) { zend_function *fbc = call->func; if (fbc->type == ZEND_USER_FUNCTION) { uint32_t num_args = ZEND_CALL_NUM_ARGS(call); @@ -4481,7 +4478,7 @@ ZEND_API int ZEND_FASTCALL zend_handle_undef_args(zend_execute_data *call) { zval tmp; ZVAL_COPY(&tmp, default_value); start_fake_frame(call, opline); - int ret = zval_update_constant_ex(&tmp, fbc->op_array.scope); + ZEND_RESULT_CODE ret = zval_update_constant_ex(&tmp, fbc->op_array.scope); end_fake_frame(call); if (UNEXPECTED(ret == FAILURE)) { zval_ptr_dtor_nogc(&tmp); @@ -4536,7 +4533,7 @@ ZEND_API int ZEND_FASTCALL zend_handle_undef_args(zend_execute_data *call) { if (Z_TYPE(default_value) == IS_CONSTANT_AST) { start_fake_frame(call, NULL); - int ret = zval_update_constant_ex(&default_value, fbc->common.scope); + ZEND_RESULT_CODE ret = zval_update_constant_ex(&default_value, fbc->common.scope); end_fake_frame(call); if (ret == FAILURE) { return FAILURE; @@ -4753,7 +4750,7 @@ static zend_always_inline zend_execute_data *_zend_vm_stack_push_call_frame(uint #include "zend_vm_execute.h" -ZEND_API int zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler_t handler) +ZEND_API ZEND_RESULT_CODE zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler_t handler) { if (opcode != ZEND_USER_OPCODE) { if (handler == NULL) { diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index f93a9f5e0e86a..dde45907ff3fd 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -64,8 +64,8 @@ ZEND_API zend_bool ZEND_FASTCALL zend_verify_prop_assignable_by_ref(zend_propert ZEND_API ZEND_COLD void zend_throw_ref_type_error_zval(zend_property_info *prop, zval *zv); ZEND_API ZEND_COLD void zend_throw_ref_type_error_type(zend_property_info *prop1, zend_property_info *prop2, zval *zv); -ZEND_API ZEND_COLD int ZEND_FASTCALL zend_undefined_offset_write(HashTable *ht, zend_long lval); -ZEND_API ZEND_COLD int ZEND_FASTCALL zend_undefined_index_write(HashTable *ht, zend_string *offset); +ZEND_API ZEND_COLD ZEND_RESULT_CODE ZEND_FASTCALL zend_undefined_offset_write(HashTable *ht, zend_long lval); +ZEND_API ZEND_COLD ZEND_RESULT_CODE ZEND_FASTCALL zend_undefined_index_write(HashTable *ht, zend_string *offset); ZEND_API zend_bool zend_verify_scalar_type_hint(uint32_t type_mask, zval *arg, zend_bool strict, zend_bool is_internal_arg); ZEND_API ZEND_COLD void zend_verify_arg_error( @@ -155,8 +155,8 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval return variable_ptr; } -ZEND_API int zval_update_constant(zval *pp); -ZEND_API int zval_update_constant_ex(zval *pp, zend_class_entry *scope); +ZEND_API ZEND_RESULT_CODE zval_update_constant(zval *pp); +ZEND_API ZEND_RESULT_CODE zval_update_constant_ex(zval *pp, zend_class_entry *scope); /* dedicated Zend executor functions - do not use! */ struct _zend_vm_stack { @@ -317,7 +317,7 @@ ZEND_API uint32_t zend_get_executed_lineno(void); ZEND_API zend_class_entry *zend_get_executed_scope(void); ZEND_API zend_bool zend_is_executing(void); -ZEND_API void zend_set_timeout(zend_long seconds, int reset_signals); +ZEND_API void zend_set_timeout(zend_long seconds, bool reset_signals); ZEND_API void zend_unset_timeout(void); ZEND_API ZEND_NORETURN void ZEND_FASTCALL zend_timeout(void); ZEND_API zend_class_entry *zend_fetch_class(zend_string *class_name, int fetch_type); From ef1fe7715d26850279fe6600885221890e8c6fe9 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 15 Aug 2020 23:50:43 +0200 Subject: [PATCH 119/170] Boolify zend_execute.c --- Zend/zend_execute.c | 12 ++++++------ Zend/zend_execute.h | 8 ++++---- Zend/zend_execute_API.c | 34 +++++++++++++++++----------------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 0574c6196f60e..8f69f0a0f08a9 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -568,7 +568,7 @@ static zend_never_inline zval* zend_assign_to_typed_property_reference(zend_prop return prop; } -static zend_never_inline ZEND_COLD int zend_wrong_assign_to_variable_reference(zval *variable_ptr, zval *value_ptr OPLINE_DC EXECUTE_DATA_DC) +static zend_never_inline ZEND_COLD bool zend_wrong_assign_to_variable_reference(zval *variable_ptr, zval *value_ptr OPLINE_DC EXECUTE_DATA_DC) { zend_error(E_NOTICE, "Only variables should be assigned by reference"); if (UNEXPECTED(EG(exception) != NULL)) { @@ -1035,7 +1035,7 @@ static zend_always_inline zend_bool zend_check_type( return zend_check_type_slow(type, arg, ref, cache_slot, scope, is_return_type, is_internal); } -static zend_always_inline int zend_verify_recv_arg_type(zend_function *zf, uint32_t arg_num, zval *arg, void **cache_slot) +static zend_always_inline bool zend_verify_recv_arg_type(zend_function *zf, uint32_t arg_num, zval *arg, void **cache_slot) { zend_arg_info *cur_arg_info; @@ -1051,7 +1051,7 @@ static zend_always_inline int zend_verify_recv_arg_type(zend_function *zf, uint3 return 1; } -static zend_always_inline int zend_verify_variadic_arg_type( +static zend_always_inline bool zend_verify_variadic_arg_type( zend_function *zf, zend_arg_info *arg_info, uint32_t arg_num, zval *arg, void **cache_slot) { ZEND_ASSERT(ZEND_TYPE_IS_SET(arg_info->type)); @@ -1063,7 +1063,7 @@ static zend_always_inline int zend_verify_variadic_arg_type( return 1; } -static zend_never_inline ZEND_ATTRIBUTE_UNUSED int zend_verify_internal_arg_types(zend_function *fbc, zend_execute_data *call) +static zend_never_inline ZEND_ATTRIBUTE_UNUSED bool zend_verify_internal_arg_types(zend_function *fbc, zend_execute_data *call) { uint32_t i; uint32_t num_args = ZEND_CALL_NUM_ARGS(call); @@ -1203,7 +1203,7 @@ static ZEND_COLD void zend_verify_void_return_error(const zend_function *zf, con fclass, fsep, fname, returned_msg, returned_kind); } -static int zend_verify_internal_return_type(zend_function *zf, zval *ret) +static bool zend_verify_internal_return_type(zend_function *zf, zval *ret) { zend_internal_arg_info *ret_info = zf->internal_function.arg_info - 1; void *dummy_cache_slot = NULL; @@ -3045,7 +3045,7 @@ ZEND_API ZEND_COLD void zend_throw_conflicting_coercion_error(zend_property_info } /* 1: valid, 0: invalid, -1: may be valid after type coercion */ -static zend_always_inline bool i_zend_verify_type_assignable_zval( +static zend_always_inline int i_zend_verify_type_assignable_zval( zend_property_info *info, zval *zv, zend_bool strict) { zend_type type = info->type; uint32_t type_mask; diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index dde45907ff3fd..9d94992586f3a 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -47,10 +47,10 @@ ZEND_API zend_class_entry *zend_lookup_class(zend_string *name); ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *lcname, uint32_t flags); ZEND_API zend_class_entry *zend_get_called_scope(zend_execute_data *ex); ZEND_API zend_object *zend_get_this_object(zend_execute_data *ex); -ZEND_API int zend_eval_string(const char *str, zval *retval_ptr, const char *string_name); -ZEND_API int zend_eval_stringl(const char *str, size_t str_len, zval *retval_ptr, const char *string_name); -ZEND_API int zend_eval_string_ex(const char *str, zval *retval_ptr, const char *string_name, int handle_exceptions); -ZEND_API int zend_eval_stringl_ex(const char *str, size_t str_len, zval *retval_ptr, const char *string_name, int handle_exceptions); +ZEND_API ZEND_RESULT_CODE zend_eval_string(const char *str, zval *retval_ptr, const char *string_name); +ZEND_API ZEND_RESULT_CODE zend_eval_stringl(const char *str, size_t str_len, zval *retval_ptr, const char *string_name); +ZEND_API ZEND_RESULT_CODE zend_eval_string_ex(const char *str, zval *retval_ptr, const char *string_name, bool handle_exceptions); +ZEND_API ZEND_RESULT_CODE zend_eval_stringl_ex(const char *str, size_t str_len, zval *retval_ptr, const char *string_name, bool handle_exceptions); /* export zend_pass_function to allow comparisons against it */ extern ZEND_API const zend_internal_function zend_pass_function; diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 0e721c451e9a6..3c642da21a166 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -585,7 +585,7 @@ ZEND_API zend_bool zend_is_executing(void) /* {{{ */ } /* }}} */ -ZEND_API int zval_update_constant_ex(zval *p, zend_class_entry *scope) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zval_update_constant_ex(zval *p, zend_class_entry *scope) /* {{{ */ { if (Z_TYPE_P(p) == IS_CONSTANT_AST) { zend_ast *ast = Z_ASTVAL_P(p); @@ -613,13 +613,13 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_class_entry *scope) /* {{{ */ } /* }}} */ -ZEND_API int zval_update_constant(zval *pp) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zval_update_constant(zval *pp) /* {{{ */ { return zval_update_constant_ex(pp, EG(current_execute_data) ? zend_get_executed_scope() : CG(active_class_entry)); } /* }}} */ -int _call_user_function_impl(zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], HashTable *named_params) /* {{{ */ +ZEND_RESULT_CODE _call_user_function_impl(zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], HashTable *named_params) /* {{{ */ { zend_fcall_info fci; @@ -635,7 +635,7 @@ int _call_user_function_impl(zval *object, zval *function_name, zval *retval_ptr } /* }}} */ -int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /* {{{ */ +ZEND_RESULT_CODE zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /* {{{ */ { uint32_t i; zend_execute_data *call, dummy_execute_data; @@ -956,7 +956,7 @@ ZEND_API void zend_call_known_function( fcic.object = object; fcic.called_scope = called_scope; - int result = zend_call_function(&fci, &fcic); + ZEND_RESULT_CODE result = zend_call_function(&fci, &fcic); if (UNEXPECTED(result == FAILURE)) { if (!EG(exception)) { zend_error_noreturn(E_CORE_ERROR, "Couldn't execute method %s%s%s", @@ -1134,12 +1134,12 @@ ZEND_API zend_object *zend_get_this_object(zend_execute_data *ex) /* {{{ */ } /* }}} */ -ZEND_API int zend_eval_stringl(const char *str, size_t str_len, zval *retval_ptr, const char *string_name) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_eval_stringl(const char *str, size_t str_len, zval *retval_ptr, const char *string_name) /* {{{ */ { zval pv; zend_op_array *new_op_array; uint32_t original_compiler_options; - int retval; + ZEND_RESULT_CODE retval; if (retval_ptr) { ZVAL_NEW_STR(&pv, zend_string_alloc(str_len + sizeof("return ;")-1, 0)); @@ -1198,15 +1198,15 @@ ZEND_API int zend_eval_stringl(const char *str, size_t str_len, zval *retval_ptr } /* }}} */ -ZEND_API int zend_eval_string(const char *str, zval *retval_ptr, const char *string_name) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_eval_string(const char *str, zval *retval_ptr, const char *string_name) /* {{{ */ { return zend_eval_stringl(str, strlen(str), retval_ptr, string_name); } /* }}} */ -ZEND_API int zend_eval_stringl_ex(const char *str, size_t str_len, zval *retval_ptr, const char *string_name, int handle_exceptions) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_eval_stringl_ex(const char *str, size_t str_len, zval *retval_ptr, const char *string_name, bool handle_exceptions) /* {{{ */ { - int result; + ZEND_RESULT_CODE result; result = zend_eval_stringl(str, str_len, retval_ptr, string_name); if (handle_exceptions && EG(exception)) { @@ -1216,13 +1216,13 @@ ZEND_API int zend_eval_stringl_ex(const char *str, size_t str_len, zval *retval_ } /* }}} */ -ZEND_API int zend_eval_string_ex(const char *str, zval *retval_ptr, const char *string_name, int handle_exceptions) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_eval_string_ex(const char *str, zval *retval_ptr, const char *string_name, bool handle_exceptions) /* {{{ */ { return zend_eval_stringl_ex(str, strlen(str), retval_ptr, string_name, handle_exceptions); } /* }}} */ -static void zend_set_timeout_ex(zend_long seconds, int reset_signals); +static void zend_set_timeout_ex(zend_long seconds, bool reset_signals); ZEND_API ZEND_NORETURN void ZEND_FASTCALL zend_timeout(void) /* {{{ */ { @@ -1322,7 +1322,7 @@ VOID CALLBACK tq_timer_cb(PVOID arg, BOOLEAN timed_out) #define SIGPROF 27 #endif -static void zend_set_timeout_ex(zend_long seconds, int reset_signals) /* {{{ */ +static void zend_set_timeout_ex(zend_long seconds, bool reset_signals) /* {{{ */ { #ifdef ZEND_WIN32 zend_executor_globals *eg; @@ -1394,7 +1394,7 @@ static void zend_set_timeout_ex(zend_long seconds, int reset_signals) /* {{{ */ } /* }}} */ -void zend_set_timeout(zend_long seconds, int reset_signals) /* {{{ */ +void zend_set_timeout(zend_long seconds, bool reset_signals) /* {{{ */ { EG(timeout_seconds) = seconds; @@ -1525,7 +1525,7 @@ zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, zend_string } /* }}} */ -ZEND_API int zend_delete_global_variable(zend_string *name) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_delete_global_variable(zend_string *name) /* {{{ */ { return zend_hash_del_ind(&EG(symbol_table), name); } @@ -1638,7 +1638,7 @@ ZEND_API void zend_detach_symbol_table(zend_execute_data *execute_data) /* {{{ * } /* }}} */ -ZEND_API int zend_set_local_var(zend_string *name, zval *value, int force) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_set_local_var(zend_string *name, zval *value, bool force) /* {{{ */ { zend_execute_data *execute_data = EG(current_execute_data); @@ -1681,7 +1681,7 @@ ZEND_API int zend_set_local_var(zend_string *name, zval *value, int force) /* {{ } /* }}} */ -ZEND_API int zend_set_local_var_str(const char *name, size_t len, zval *value, int force) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_set_local_var_str(const char *name, size_t len, zval *value, bool force) /* {{{ */ { zend_execute_data *execute_data = EG(current_execute_data); From 914125777292b052fa92fd860eadb2c0dc525eab Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 00:08:07 +0200 Subject: [PATCH 120/170] Drop zend_handle_sigsegv() unused var --- Zend/zend_execute_API.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 3c642da21a166..9059ce61841f2 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -56,7 +56,7 @@ ZEND_TLS HANDLE tq_timer = NULL; #if 0&&ZEND_DEBUG static void (*original_sigsegv_handler)(int); -static void zend_handle_sigsegv(int dummy) /* {{{ */ +static void zend_handle_sigsegv(void) /* {{{ */ { fflush(stdout); fflush(stderr); From 7f478fd7b17d1b9079378ed8ff404a595304ab26 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 00:10:12 +0200 Subject: [PATCH 121/170] Boolify zend_extensions.c --- Zend/zend_extensions.c | 6 +++--- Zend/zend_extensions.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Zend/zend_extensions.c b/Zend/zend_extensions.c index 2509daf3180c5..9c05c840033ab 100644 --- a/Zend/zend_extensions.c +++ b/Zend/zend_extensions.c @@ -24,7 +24,7 @@ ZEND_API uint32_t zend_extension_flags = 0; ZEND_API int zend_op_array_extension_handles = 0; static int last_resource_number; -int zend_load_extension(const char *path) +ZEND_RESULT_CODE zend_load_extension(const char *path) { #if ZEND_EXTENSIONS_SUPPORT DL_HANDLE handle; @@ -51,7 +51,7 @@ int zend_load_extension(const char *path) #endif } -int zend_load_extension_handle(DL_HANDLE handle, const char *path) +ZEND_RESULT_CODE zend_load_extension_handle(DL_HANDLE handle, const char *path) { #if ZEND_EXTENSIONS_SUPPORT zend_extension *new_extension; @@ -181,7 +181,7 @@ static void zend_extension_shutdown(zend_extension *extension) #endif } -static int zend_extension_startup(zend_extension *extension) +static bool zend_extension_startup(zend_extension *extension) { #if ZEND_EXTENSIONS_SUPPORT if (extension->startup) { diff --git a/Zend/zend_extensions.h b/Zend/zend_extensions.h index 59cd970b3a063..21a94a710da98 100644 --- a/Zend/zend_extensions.h +++ b/Zend/zend_extensions.h @@ -141,12 +141,12 @@ ZEND_API extern uint32_t zend_extension_flags; void zend_extension_dtor(zend_extension *extension); ZEND_API void zend_append_version_info(const zend_extension *extension); int zend_startup_extensions_mechanism(void); -int zend_startup_extensions(void); +bool zend_startup_extensions(void); void zend_shutdown_extensions(void); BEGIN_EXTERN_C() -ZEND_API int zend_load_extension(const char *path); -ZEND_API int zend_load_extension_handle(DL_HANDLE handle, const char *path); +ZEND_API ZEND_RESULT_CODE zend_load_extension(const char *path); +ZEND_API ZEND_RESULT_CODE zend_load_extension_handle(DL_HANDLE handle, const char *path); ZEND_API int zend_register_extension(zend_extension *new_extension, DL_HANDLE handle); ZEND_API zend_extension *zend_get_extension(const char *extension_name); ZEND_API size_t zend_extensions_op_array_persist_calc(zend_op_array *op_array); From 700448cc511aa5d079d8b24d44721b46412d02fe Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 00:11:03 +0200 Subject: [PATCH 122/170] Voidify zend_extensions.c --- Zend/zend_extensions.c | 10 +++------- Zend/zend_extensions.h | 4 ++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Zend/zend_extensions.c b/Zend/zend_extensions.c index 9c05c840033ab..9c3d5cc631e0c 100644 --- a/Zend/zend_extensions.c +++ b/Zend/zend_extensions.c @@ -138,7 +138,7 @@ ZEND_RESULT_CODE zend_load_extension_handle(DL_HANDLE handle, const char *path) } -int zend_register_extension(zend_extension *new_extension, DL_HANDLE handle) +void zend_register_extension(zend_extension *new_extension, DL_HANDLE handle) { #if ZEND_EXTENSIONS_SUPPORT zend_extension extension; @@ -167,8 +167,6 @@ int zend_register_extension(zend_extension *new_extension, DL_HANDLE handle) } /*fprintf(stderr, "Loaded %s, version %s\n", extension.name, extension.version);*/ #endif - - return SUCCESS; } @@ -195,20 +193,18 @@ static bool zend_extension_startup(zend_extension *extension) } -int zend_startup_extensions_mechanism() +void zend_startup_extensions_mechanism() { /* Startup extensions mechanism */ zend_llist_init(&zend_extensions, sizeof(zend_extension), (void (*)(void *)) zend_extension_dtor, 1); zend_op_array_extension_handles = 0; last_resource_number = 0; - return SUCCESS; } -int zend_startup_extensions() +void zend_startup_extensions() { zend_llist_apply_with_del(&zend_extensions, (int (*)(void *)) zend_extension_startup); - return SUCCESS; } diff --git a/Zend/zend_extensions.h b/Zend/zend_extensions.h index 21a94a710da98..ce72a80953646 100644 --- a/Zend/zend_extensions.h +++ b/Zend/zend_extensions.h @@ -140,14 +140,14 @@ ZEND_API extern uint32_t zend_extension_flags; void zend_extension_dtor(zend_extension *extension); ZEND_API void zend_append_version_info(const zend_extension *extension); -int zend_startup_extensions_mechanism(void); +void zend_startup_extensions_mechanism(void); bool zend_startup_extensions(void); void zend_shutdown_extensions(void); BEGIN_EXTERN_C() ZEND_API ZEND_RESULT_CODE zend_load_extension(const char *path); ZEND_API ZEND_RESULT_CODE zend_load_extension_handle(DL_HANDLE handle, const char *path); -ZEND_API int zend_register_extension(zend_extension *new_extension, DL_HANDLE handle); +ZEND_API void zend_register_extension(zend_extension *new_extension, DL_HANDLE handle); ZEND_API zend_extension *zend_get_extension(const char *extension_name); ZEND_API size_t zend_extensions_op_array_persist_calc(zend_op_array *op_array); ZEND_API size_t zend_extensions_op_array_persist(zend_op_array *op_array, void *mem); From b7d5d01b846559b71a88c40826132a8c545df0f2 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 15:27:50 +0200 Subject: [PATCH 123/170] Fix zend_extension --- Zend/zend_extensions.c | 3 ++- Zend/zend_extensions.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Zend/zend_extensions.c b/Zend/zend_extensions.c index 9c3d5cc631e0c..8ea36e081282f 100644 --- a/Zend/zend_extensions.c +++ b/Zend/zend_extensions.c @@ -126,7 +126,8 @@ ZEND_RESULT_CODE zend_load_extension_handle(DL_HANDLE handle, const char *path) return FAILURE; } - return zend_register_extension(new_extension, handle); + zend_register_extension(new_extension, handle); + return SUCCESS; #else fprintf(stderr, "Extensions are not supported on this platform.\n"); /* See http://support.microsoft.com/kb/190351 */ diff --git a/Zend/zend_extensions.h b/Zend/zend_extensions.h index ce72a80953646..02fd3bb6dc51a 100644 --- a/Zend/zend_extensions.h +++ b/Zend/zend_extensions.h @@ -141,7 +141,7 @@ ZEND_API extern uint32_t zend_extension_flags; void zend_extension_dtor(zend_extension *extension); ZEND_API void zend_append_version_info(const zend_extension *extension); void zend_startup_extensions_mechanism(void); -bool zend_startup_extensions(void); +void zend_startup_extensions(void); void zend_shutdown_extensions(void); BEGIN_EXTERN_C() From abcb59a35742f0562d5399ee7e6beef98a9b0358 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 00:14:45 +0200 Subject: [PATCH 124/170] Boolify zend_gdb.c --- Zend/zend_gdb.c | 6 +++--- Zend/zend_gdb.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Zend/zend_gdb.c b/Zend/zend_gdb.c index 0fff7420486ff..ce6dc6a7850f9 100644 --- a/Zend/zend_gdb.c +++ b/Zend/zend_gdb.c @@ -54,7 +54,7 @@ ZEND_API zend_never_inline void __jit_debug_register_code() __asm__ __volatile__(""); } -ZEND_API int zend_gdb_register_code(const void *object, size_t size) +ZEND_API bool zend_gdb_register_code(const void *object, size_t size) { zend_gdbjit_code_entry *entry; @@ -102,9 +102,9 @@ ZEND_API void zend_gdb_unregister_all(void) } } -ZEND_API int zend_gdb_present(void) +ZEND_API bool zend_gdb_present(void) { - int ret = 0; + bool ret = 0; int fd = open("/proc/self/status", O_RDONLY); if (fd > 0) { diff --git a/Zend/zend_gdb.h b/Zend/zend_gdb.h index 220b70888fc80..aad0fefb097b9 100644 --- a/Zend/zend_gdb.h +++ b/Zend/zend_gdb.h @@ -20,8 +20,8 @@ #ifndef ZEND_GDB #define ZEND_GDB -ZEND_API int zend_gdb_register_code(const void *object, size_t size); +ZEND_API bool zend_gdb_register_code(const void *object, size_t size); ZEND_API void zend_gdb_unregister_all(void); -ZEND_API int zend_gdb_present(void); +ZEND_API bool zend_gdb_present(void); #endif From 5d70fe827c499bddfda007bfda53c28eb9b934b5 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 00:15:43 +0200 Subject: [PATCH 125/170] Boolify zend_generator.c --- Zend/zend_generators.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index 040a213ce7491..f9a8fb4c09b2f 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -629,7 +629,7 @@ ZEND_API zend_generator *zend_generator_update_current(zend_generator *generator return root; } -static int zend_generator_get_next_delegated_value(zend_generator *generator) /* {{{ */ +static ZEND_RESULT_CODE zend_generator_get_next_delegated_value(zend_generator *generator) /* {{{ */ { zval *value; if (Z_TYPE(generator->values) == IS_ARRAY) { @@ -1027,7 +1027,7 @@ static void zend_generator_iterator_dtor(zend_object_iterator *iterator) /* {{{ } /* }}} */ -static int zend_generator_iterator_valid(zend_object_iterator *iterator) /* {{{ */ +static ZEND_RESULT_CODE zend_generator_iterator_valid(zend_object_iterator *iterator) /* {{{ */ { zend_generator *generator = (zend_generator*)Z_OBJ(iterator->data); @@ -1106,6 +1106,7 @@ static const zend_object_iterator_funcs zend_generator_iterator_functions = { zend_generator_iterator_get_gc, }; +/* by_ref is int due to Iterator API */ zend_object_iterator *zend_generator_get_iterator(zend_class_entry *ce, zval *object, int by_ref) /* {{{ */ { zend_object_iterator *iterator; From d70cbafd443b3c3846a3c5c8e527eea5700ae7d2 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 00:23:44 +0200 Subject: [PATCH 126/170] Boolify zend_hash.c --- Zend/zend_hash.c | 24 ++++++++++++------------ Zend/zend_hash.h | 6 +++--- Zend/zend_ts_hash.c | 12 ++++++------ Zend/zend_ts_hash.h | 14 +++++++------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index 365cf892beed8..5779a079232f1 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -218,7 +218,7 @@ static zend_always_inline void zend_hash_real_init_mixed_ex(HashTable *ht) HT_HASH_RESET(ht); } -static zend_always_inline void zend_hash_real_init_ex(HashTable *ht, int packed) +static zend_always_inline void zend_hash_real_init_ex(HashTable *ht, bool packed) { HT_ASSERT_RC1(ht); ZEND_ASSERT(HT_FLAGS(ht) & HASH_FLAG_UNINITIALIZED); @@ -1360,7 +1360,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_del_bucket(HashTable *ht, Bucket *p) _zend_hash_del_el(ht, HT_IDX_TO_HASH(p - ht->arData), p); } -ZEND_API int ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key) +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key) { zend_ulong h; uint32_t nIndex; @@ -1390,7 +1390,7 @@ ZEND_API int ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key) return FAILURE; } -ZEND_API int ZEND_FASTCALL zend_hash_del_ind(HashTable *ht, zend_string *key) +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_del_ind(HashTable *ht, zend_string *key) { zend_ulong h; uint32_t nIndex; @@ -1438,7 +1438,7 @@ ZEND_API int ZEND_FASTCALL zend_hash_del_ind(HashTable *ht, zend_string *key) return FAILURE; } -ZEND_API int ZEND_FASTCALL zend_hash_str_del_ind(HashTable *ht, const char *str, size_t len) +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_str_del_ind(HashTable *ht, const char *str, size_t len) { zend_ulong h; uint32_t nIndex; @@ -1482,7 +1482,7 @@ ZEND_API int ZEND_FASTCALL zend_hash_str_del_ind(HashTable *ht, const char *str, return FAILURE; } -ZEND_API int ZEND_FASTCALL zend_hash_str_del(HashTable *ht, const char *str, size_t len) +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_str_del(HashTable *ht, const char *str, size_t len) { zend_ulong h; uint32_t nIndex; @@ -1512,7 +1512,7 @@ ZEND_API int ZEND_FASTCALL zend_hash_str_del(HashTable *ht, const char *str, siz return FAILURE; } -ZEND_API int ZEND_FASTCALL zend_hash_index_del(HashTable *ht, zend_ulong h) +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_index_del(HashTable *ht, zend_ulong h) { uint32_t nIndex; uint32_t idx; @@ -1964,7 +1964,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_copy(HashTable *target, HashTable *source, } -static zend_always_inline int zend_array_dup_element(HashTable *source, HashTable *target, uint32_t idx, Bucket *p, Bucket *q, int packed, int static_keys, int with_holes) +static zend_always_inline bool zend_array_dup_element(HashTable *source, HashTable *target, uint32_t idx, Bucket *p, Bucket *q, bool packed, bool static_keys, bool with_holes) { zval *data = &p->val; @@ -2018,7 +2018,7 @@ static zend_always_inline int zend_array_dup_element(HashTable *source, HashTabl return 1; } -static zend_always_inline void zend_array_dup_packed_elements(HashTable *source, HashTable *target, int with_holes) +static zend_always_inline void zend_array_dup_packed_elements(HashTable *source, HashTable *target, bool with_holes) { Bucket *p = source->arData; Bucket *q = target->arData; @@ -2034,7 +2034,7 @@ static zend_always_inline void zend_array_dup_packed_elements(HashTable *source, } while (p != end); } -static zend_always_inline uint32_t zend_array_dup_elements(HashTable *source, HashTable *target, int static_keys, int with_holes) +static zend_always_inline uint32_t zend_array_dup_elements(HashTable *source, HashTable *target, bool static_keys, bool with_holes) { uint32_t idx = 0; Bucket *p = source->arData; @@ -2325,7 +2325,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_end_ex(HashTable *ht, Has } -ZEND_API int ZEND_FASTCALL zend_hash_move_forward_ex(HashTable *ht, HashPosition *pos) +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_move_forward_ex(HashTable *ht, HashPosition *pos) { uint32_t idx; @@ -2350,7 +2350,7 @@ ZEND_API int ZEND_FASTCALL zend_hash_move_forward_ex(HashTable *ht, HashPosition } } -ZEND_API int ZEND_FASTCALL zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos) +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos) { uint32_t idx = *pos; @@ -2707,7 +2707,7 @@ ZEND_API zval* ZEND_FASTCALL zend_hash_minmax(const HashTable *ht, bucket_compar return &res->val; } -ZEND_API int ZEND_FASTCALL _zend_handle_numeric_str_ex(const char *key, size_t length, zend_ulong *idx) +ZEND_API bool ZEND_FASTCALL _zend_handle_numeric_str_ex(const char *key, size_t length, zend_ulong *idx) { register const char *tmp = key; diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h index 2dc4723978ddd..bbd5205db3a9d 100644 --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@ -508,7 +508,7 @@ static zend_always_inline zval *zend_symtable_find_ind(const HashTable *ht, zend } -static zend_always_inline ZEND_RESULT_CODE zend_symtable_exists(HashTable *ht, zend_string *key) +static zend_always_inline bool zend_symtable_exists(HashTable *ht, zend_string *key) { zend_ulong idx; @@ -520,7 +520,7 @@ static zend_always_inline ZEND_RESULT_CODE zend_symtable_exists(HashTable *ht, z } -static zend_always_inline ZEND_RESULT_CODE zend_symtable_exists_ind(HashTable *ht, zend_string *key) +static zend_always_inline bool zend_symtable_exists_ind(HashTable *ht, zend_string *key) { zend_ulong idx; @@ -592,7 +592,7 @@ static zend_always_inline zval *zend_symtable_str_find(HashTable *ht, const char } -static zend_always_inline ZEND_RESULT_CODE zend_symtable_str_exists(HashTable *ht, const char *str, size_t len) +static zend_always_inline bool zend_symtable_str_exists(HashTable *ht, const char *str, size_t len) { zend_ulong idx; diff --git a/Zend/zend_ts_hash.c b/Zend/zend_ts_hash.c index daa9aafefaef0..425ee7d13289e 100644 --- a/Zend/zend_ts_hash.c +++ b/Zend/zend_ts_hash.c @@ -186,9 +186,9 @@ ZEND_API void zend_ts_hash_reverse_apply(TsHashTable *ht, apply_func_t apply_fun end_write(ht); } -ZEND_API int zend_ts_hash_del(TsHashTable *ht, zend_string *key) +ZEND_API ZEND_RESULT_CODE zend_ts_hash_del(TsHashTable *ht, zend_string *key) { - int retval; + ZEND_RESULT_CODE retval; begin_write(ht); retval = zend_hash_del(TS_HASH(ht), key); @@ -197,9 +197,9 @@ ZEND_API int zend_ts_hash_del(TsHashTable *ht, zend_string *key) return retval; } -ZEND_API int zend_ts_hash_index_del(TsHashTable *ht, zend_ulong h) +ZEND_API ZEND_RESULT_CODE zend_ts_hash_index_del(TsHashTable *ht, zend_ulong h) { - int retval; + ZEND_RESULT_CODE retval; begin_write(ht); retval = zend_hash_index_del(TS_HASH(ht), h); @@ -246,7 +246,7 @@ ZEND_API void zend_ts_hash_copy_to_hash(HashTable *target, TsHashTable *source, end_read(source); } -ZEND_API void zend_ts_hash_merge(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, int overwrite) +ZEND_API void zend_ts_hash_merge(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, bool overwrite) { begin_read(source); begin_write(target); @@ -264,7 +264,7 @@ ZEND_API void zend_ts_hash_merge_ex(TsHashTable *target, TsHashTable *source, co end_read(source); } -ZEND_API void zend_ts_hash_sort(TsHashTable *ht, sort_func_t sort_func, bucket_compare_func_t compare_func, int renumber) +ZEND_API void zend_ts_hash_sort(TsHashTable *ht, sort_func_t sort_func, bucket_compare_func_t compare_func, bool renumber) { begin_write(ht); zend_hash_sort_ex(TS_HASH(ht), sort_func, compare_func, renumber); diff --git a/Zend/zend_ts_hash.h b/Zend/zend_ts_hash.h index 3f245d21206e4..2f4e5575f19dd 100644 --- a/Zend/zend_ts_hash.h +++ b/Zend/zend_ts_hash.h @@ -56,8 +56,8 @@ ZEND_API void zend_ts_hash_reverse_apply(TsHashTable *ht, apply_func_t apply_fun /* Deletes */ -ZEND_API int zend_ts_hash_del(TsHashTable *ht, zend_string *key); -ZEND_API int zend_ts_hash_index_del(TsHashTable *ht, zend_ulong h); +ZEND_API ZEND_RESULT_CODE zend_ts_hash_del(TsHashTable *ht, zend_string *key); +ZEND_API ZEND_RESULT_CODE zend_ts_hash_index_del(TsHashTable *ht, zend_ulong h); /* Data retrieval */ ZEND_API zval *zend_ts_hash_find(TsHashTable *ht, zend_string *key); @@ -66,10 +66,10 @@ ZEND_API zval *zend_ts_hash_index_find(TsHashTable *ht, zend_ulong); /* Copying, merging and sorting */ ZEND_API void zend_ts_hash_copy(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor); ZEND_API void zend_ts_hash_copy_to_hash(HashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor); -ZEND_API void zend_ts_hash_merge(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, int overwrite); +ZEND_API void zend_ts_hash_merge(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, bool overwrite); ZEND_API void zend_ts_hash_merge_ex(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, merge_checker_func_t pMergeSource, void *pParam); -ZEND_API void zend_ts_hash_sort(TsHashTable *ht, sort_func_t sort_func, bucket_compare_func_t compare_func, int renumber); -ZEND_API int zend_ts_hash_compare(TsHashTable *ht1, TsHashTable *ht2, compare_func_t compar, zend_bool ordered); +ZEND_API void zend_ts_hash_sort(TsHashTable *ht, sort_func_t sort_func, bucket_compare_func_t compare_func, bool renumber); +ZEND_API int zend_ts_hash_compare(TsHashTable *ht1, TsHashTable *ht2, compare_func_t compar, zend_bool ordered); ZEND_API zval *zend_ts_hash_minmax(TsHashTable *ht, bucket_compare_func_t compar, int flag); ZEND_API int zend_ts_hash_num_elements(TsHashTable *ht); @@ -112,12 +112,12 @@ static zend_always_inline void *zend_ts_hash_str_add_ptr(TsHashTable *ht, const return zv ? Z_PTR_P(zv) : NULL; } -static zend_always_inline int zend_ts_hash_exists(TsHashTable *ht, zend_string *key) +static zend_always_inline bool zend_ts_hash_exists(TsHashTable *ht, zend_string *key) { return zend_ts_hash_find(ht, key) != NULL; } -static zend_always_inline int zend_ts_hash_index_exists(TsHashTable *ht, zend_ulong h) +static zend_always_inline bool zend_ts_hash_index_exists(TsHashTable *ht, zend_ulong h) { return zend_ts_hash_index_find(ht, h) != NULL; } From 2f7ed868ab3cae5c70ce2880d86dfad59204cdf7 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 00:43:46 +0200 Subject: [PATCH 127/170] Boolify zend_highlight.c --- Zend/zend_highlight.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Zend/zend_highlight.h b/Zend/zend_highlight.h index 8ea1518ca662f..99bacd19b4377 100644 --- a/Zend/zend_highlight.h +++ b/Zend/zend_highlight.h @@ -39,8 +39,8 @@ typedef struct _zend_syntax_highlighter_ini { BEGIN_EXTERN_C() ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini); ZEND_API void zend_strip(void); -ZEND_API int highlight_file(const char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini); -ZEND_API int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, const char *str_name); +ZEND_API ZEND_RESULT_CODE highlight_file(const char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini); +ZEND_API ZEND_RESULT_CODE highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, const char *str_name); ZEND_API void zend_html_putc(char c); ZEND_API void zend_html_puts(const char *s, size_t len); END_EXTERN_C() From 71b5d1b127f4d91ca2594e96330edd86c5cc0d6a Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 00:45:10 +0200 Subject: [PATCH 128/170] Boolify zend_inheritence.c --- Zend/zend_inheritance.c | 4 ++-- Zend/zend_inheritance.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 158b67ce38007..3054bd162135f 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -633,7 +633,7 @@ static inheritance_status zend_do_perform_implementation_check( /* }}} */ static ZEND_COLD void zend_append_type_hint( - smart_str *str, zend_class_entry *scope, zend_arg_info *arg_info, int return_hint) /* {{{ */ + smart_str *str, zend_class_entry *scope, zend_arg_info *arg_info, bool return_hint) /* {{{ */ { if (ZEND_TYPE_IS_SET(arg_info->type)) { zend_string *type_str = zend_type_to_string_resolved(arg_info->type, scope); @@ -2390,7 +2390,7 @@ static void check_unrecoverable_load_failure(zend_class_entry *ce) { } } -ZEND_API int zend_do_link_class(zend_class_entry *ce, zend_string *lc_parent_name) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_do_link_class(zend_class_entry *ce, zend_string *lc_parent_name) /* {{{ */ { /* Load parent/interface dependencies first, so we can still gracefully abort linking * with an exception and remove the class from the class table. This is only possible diff --git a/Zend/zend_inheritance.h b/Zend/zend_inheritance.h index 6cf2d1b78d874..067519c5f2347 100644 --- a/Zend/zend_inheritance.h +++ b/Zend/zend_inheritance.h @@ -30,7 +30,7 @@ ZEND_API void zend_do_inheritance_ex(zend_class_entry *ce, zend_class_entry *par #define zend_do_inheritance(ce, parent_ce) \ zend_do_inheritance_ex(ce, parent_ce, 0) -ZEND_API int zend_do_link_class(zend_class_entry *ce, zend_string *lc_parent_name); +ZEND_API ZEND_RESULT_CODE zend_do_link_class(zend_class_entry *ce, zend_string *lc_parent_name); void zend_verify_abstract_class(zend_class_entry *ce); void zend_build_properties_info_table(zend_class_entry *ce); From 315d298186f909f8a3cb118083a6cea17d1bdded Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 00:46:09 +0200 Subject: [PATCH 129/170] Boolify zend_ini.c --- Zend/zend_ini.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Zend/zend_ini.c b/Zend/zend_ini.c index 488468f0e0331..bfa8eebf7f339 100644 --- a/Zend/zend_ini.c +++ b/Zend/zend_ini.c @@ -41,9 +41,9 @@ static int zend_remove_ini_entries(zval *el, void *arg) /* {{{ */ } /* }}} */ -static int zend_restore_ini_entry_cb(zend_ini_entry *ini_entry, int stage) /* {{{ */ +static ZEND_RESULT_CODE zend_restore_ini_entry_cb(zend_ini_entry *ini_entry, int stage) /* {{{ */ { - int result = FAILURE; + ZEND_RESULT_CODE result = FAILURE; if (ini_entry->modified) { if (ini_entry->on_modify) { From ce33408df4aedeb065712c9c7ca9b48e2d283558 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 00:47:41 +0200 Subject: [PATCH 130/170] Voidify zend_ini.c --- Zend/zend_ini.c | 33 ++++++++++++++------------------- Zend/zend_ini.h | 24 ++++++++++++------------ Zend/zend_ini_parser.y | 4 ++-- Zend/zend_ini_scanner.h | 4 ++-- Zend/zend_ini_scanner.l | 8 ++++---- 5 files changed, 34 insertions(+), 39 deletions(-) diff --git a/Zend/zend_ini.c b/Zend/zend_ini.c index bfa8eebf7f339..0f4970a28909d 100644 --- a/Zend/zend_ini.c +++ b/Zend/zend_ini.c @@ -89,7 +89,7 @@ static void free_ini_entry(zval *zv) /* {{{ */ /* * Startup / shutdown */ -ZEND_API int zend_ini_startup(void) /* {{{ */ +ZEND_API void zend_ini_startup(void) /* {{{ */ { registered_zend_ini_directives = (HashTable *) malloc(sizeof(HashTable)); @@ -97,14 +97,12 @@ ZEND_API int zend_ini_startup(void) /* {{{ */ EG(modified_ini_directives) = NULL; EG(error_reporting_ini_entry) = NULL; zend_hash_init(registered_zend_ini_directives, 128, NULL, free_ini_entry, 1); - return SUCCESS; } /* }}} */ -ZEND_API int zend_ini_shutdown(void) /* {{{ */ +ZEND_API void zend_ini_shutdown(void) /* {{{ */ { zend_ini_dtor(EG(ini_directives)); - return SUCCESS; } /* }}} */ @@ -115,15 +113,14 @@ ZEND_API void zend_ini_dtor(HashTable *ini_directives) /* {{{ */ } /* }}} */ -ZEND_API int zend_ini_global_shutdown(void) /* {{{ */ +ZEND_API void zend_ini_global_shutdown(void) /* {{{ */ { zend_hash_destroy(registered_zend_ini_directives); free(registered_zend_ini_directives); - return SUCCESS; } /* }}} */ -ZEND_API int zend_ini_deactivate(void) /* {{{ */ +ZEND_API void zend_ini_deactivate(void) /* {{{ */ { if (EG(modified_ini_directives)) { zend_ini_entry *ini_entry; @@ -135,7 +132,6 @@ ZEND_API int zend_ini_deactivate(void) /* {{{ */ FREE_HASHTABLE(EG(modified_ini_directives)); EG(modified_ini_directives) = NULL; } - return SUCCESS; } /* }}} */ @@ -159,14 +155,13 @@ static void copy_ini_entry(zval *zv) /* {{{ */ } /* }}} */ -ZEND_API int zend_copy_ini_directives(void) /* {{{ */ +ZEND_API void zend_copy_ini_directives(void) /* {{{ */ { EG(modified_ini_directives) = NULL; EG(error_reporting_ini_entry) = NULL; EG(ini_directives) = (HashTable *) malloc(sizeof(HashTable)); zend_hash_init(EG(ini_directives), registered_zend_ini_directives->nNumOfElements, NULL, free_ini_entry, 1); zend_hash_copy(EG(ini_directives), registered_zend_ini_directives, copy_ini_entry); - return SUCCESS; } /* }}} */ #endif @@ -199,7 +194,7 @@ ZEND_API void zend_ini_sort_entries(void) /* {{{ */ /* * Registration / unregistration */ -ZEND_API int zend_register_ini_entries(const zend_ini_entry_def *ini_entry, int module_number) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_register_ini_entries(const zend_ini_entry_def *ini_entry, int module_number) /* {{{ */ { zend_ini_entry *p; zval *default_value; @@ -280,16 +275,16 @@ ZEND_API void zend_ini_refresh_caches(int stage) /* {{{ */ /* }}} */ #endif -ZEND_API int zend_alter_ini_entry(zend_string *name, zend_string *new_value, int modify_type, int stage) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_alter_ini_entry(zend_string *name, zend_string *new_value, int modify_type, int stage) /* {{{ */ { return zend_alter_ini_entry_ex(name, new_value, modify_type, stage, 0); } /* }}} */ -ZEND_API int zend_alter_ini_entry_chars(zend_string *name, const char *value, size_t value_length, int modify_type, int stage) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_alter_ini_entry_chars(zend_string *name, const char *value, size_t value_length, int modify_type, int stage) /* {{{ */ { - int ret; + ZEND_RESULT_CODE ret; zend_string *new_value; new_value = zend_string_init(value, value_length, !(stage & ZEND_INI_STAGE_IN_REQUEST)); @@ -299,9 +294,9 @@ ZEND_API int zend_alter_ini_entry_chars(zend_string *name, const char *value, si } /* }}} */ -ZEND_API int zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, int force_change) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, int force_change) /* {{{ */ { - int ret; + ZEND_RESULT_CODE ret; zend_string *new_value; new_value = zend_string_init(value, value_length, !(stage & ZEND_INI_STAGE_IN_REQUEST)); @@ -311,7 +306,7 @@ ZEND_API int zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, } /* }}} */ -ZEND_API int zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, int modify_type, int stage, int force_change) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, int modify_type, int stage, bool force_change) /* {{{ */ { zend_ini_entry *ini_entry; zend_string *duplicate; @@ -363,7 +358,7 @@ ZEND_API int zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, } /* }}} */ -ZEND_API int zend_restore_ini_entry(zend_string *name, int stage) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_restore_ini_entry(zend_string *name, int stage) /* {{{ */ { zend_ini_entry *ini_entry; @@ -384,7 +379,7 @@ ZEND_API int zend_restore_ini_entry(zend_string *name, int stage) /* {{{ */ } /* }}} */ -ZEND_API int zend_ini_register_displayer(const char *name, uint32_t name_length, void (*displayer)(zend_ini_entry *ini_entry, int type)) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_ini_register_displayer(const char *name, uint32_t name_length, void (*displayer)(zend_ini_entry *ini_entry, int type)) /* {{{ */ { zend_ini_entry *ini_entry; diff --git a/Zend/zend_ini.h b/Zend/zend_ini.h index 0289b322be1a2..99378298b2671 100644 --- a/Zend/zend_ini.h +++ b/Zend/zend_ini.h @@ -61,24 +61,24 @@ struct _zend_ini_entry { }; BEGIN_EXTERN_C() -ZEND_API int zend_ini_startup(void); -ZEND_API int zend_ini_shutdown(void); -ZEND_API int zend_ini_global_shutdown(void); -ZEND_API int zend_ini_deactivate(void); +ZEND_API void zend_ini_startup(void); +ZEND_API void zend_ini_shutdown(void); +ZEND_API void zend_ini_global_shutdown(void); +ZEND_API void zend_ini_deactivate(void); ZEND_API void zend_ini_dtor(HashTable *ini_directives); -ZEND_API int zend_copy_ini_directives(void); +ZEND_API void zend_copy_ini_directives(void); ZEND_API void zend_ini_sort_entries(void); -ZEND_API int zend_register_ini_entries(const zend_ini_entry_def *ini_entry, int module_number); +ZEND_API ZEND_RESULT_CODE zend_register_ini_entries(const zend_ini_entry_def *ini_entry, int module_number); ZEND_API void zend_unregister_ini_entries(int module_number); ZEND_API void zend_ini_refresh_caches(int stage); -ZEND_API int zend_alter_ini_entry(zend_string *name, zend_string *new_value, int modify_type, int stage); -ZEND_API int zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, int modify_type, int stage, int force_change); -ZEND_API int zend_alter_ini_entry_chars(zend_string *name, const char *value, size_t value_length, int modify_type, int stage); -ZEND_API int zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, int force_change); -ZEND_API int zend_restore_ini_entry(zend_string *name, int stage); +ZEND_API ZEND_RESULT_CODE zend_alter_ini_entry(zend_string *name, zend_string *new_value, int modify_type, int stage); +ZEND_API ZEND_RESULT_CODE zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, int modify_type, int stage, bool force_change); +ZEND_API ZEND_RESULT_CODE zend_alter_ini_entry_chars(zend_string *name, const char *value, size_t value_length, int modify_type, int stage); +ZEND_API ZEND_RESULT_CODE zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, int force_change); +ZEND_API ZEND_RESULT_CODE zend_restore_ini_entry(zend_string *name, int stage); ZEND_API void display_ini_entries(zend_module_entry *module); ZEND_API zend_long zend_ini_long(const char *name, size_t name_length, int orig); @@ -88,7 +88,7 @@ ZEND_API char *zend_ini_string_ex(const char *name, size_t name_length, int orig ZEND_API zend_string *zend_ini_get_value(zend_string *name); ZEND_API zend_bool zend_ini_parse_bool(zend_string *str); -ZEND_API int zend_ini_register_displayer(const char *name, uint32_t name_length, void (*displayer)(zend_ini_entry *ini_entry, int type)); +ZEND_API ZEND_RESULT_CODE zend_ini_register_displayer(const char *name, uint32_t name_length, void (*displayer)(zend_ini_entry *ini_entry, int type)); ZEND_API ZEND_INI_DISP(zend_ini_boolean_displayer_cb); ZEND_API ZEND_INI_DISP(zend_ini_color_displayer_cb); diff --git a/Zend/zend_ini_parser.y b/Zend/zend_ini_parser.y index 373dee7aeb16d..c65485d6f1933 100644 --- a/Zend/zend_ini_parser.y +++ b/Zend/zend_ini_parser.y @@ -212,7 +212,7 @@ static ZEND_COLD void ini_error(const char *msg) /* }}} */ /* {{{ zend_parse_ini_file() */ -ZEND_API int zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg) +ZEND_API ZEND_RESULT_CODE zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg) { int retval; zend_ini_parser_param ini_parser_param; @@ -240,7 +240,7 @@ ZEND_API int zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_erro /* }}} */ /* {{{ zend_parse_ini_string() */ -ZEND_API int zend_parse_ini_string(char *str, zend_bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg) +ZEND_API ZEND_RESULT_CODE zend_parse_ini_string(char *str, zend_bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg) { int retval; zend_ini_parser_param ini_parser_param; diff --git a/Zend/zend_ini_scanner.h b/Zend/zend_ini_scanner.h index ddb9247d3721d..6d5d2f5062b01 100644 --- a/Zend/zend_ini_scanner.h +++ b/Zend/zend_ini_scanner.h @@ -28,8 +28,8 @@ BEGIN_EXTERN_C() ZEND_COLD int zend_ini_scanner_get_lineno(void); ZEND_COLD char *zend_ini_scanner_get_filename(void); -int zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode); -int zend_ini_prepare_string_for_scanning(char *str, int scanner_mode); +ZEND_RESULT_CODE zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode); +ZEND_RESULT_CODE zend_ini_prepare_string_for_scanning(char *str, int scanner_mode); int ini_lex(zval *ini_lval); void shutdown_ini_scanner(void); END_EXTERN_C() diff --git a/Zend/zend_ini_scanner.l b/Zend/zend_ini_scanner.l index c8efb1f144d95..8324526419f12 100644 --- a/Zend/zend_ini_scanner.l +++ b/Zend/zend_ini_scanner.l @@ -151,7 +151,7 @@ ZEND_API zend_ini_scanner_globals ini_scanner_globals; return type; \ } -static inline int convert_to_number(zval *retval, const char *str, const int str_len) +static inline ZEND_RESULT_CODE convert_to_number(zval *retval, const char *str, const int str_len) { zend_uchar type; int overflow; @@ -218,7 +218,7 @@ static void yy_scan_buffer(char *str, unsigned int len) #define ini_filename SCNG(filename) /* {{{ init_ini_scanner() */ -static int init_ini_scanner(int scanner_mode, zend_file_handle *fh) +static ZEND_RESULT_CODE init_ini_scanner(int scanner_mode, zend_file_handle *fh) { /* Sanity check */ if (scanner_mode != ZEND_INI_SCANNER_NORMAL && scanner_mode != ZEND_INI_SCANNER_RAW && scanner_mode != ZEND_INI_SCANNER_TYPED) { @@ -268,7 +268,7 @@ ZEND_COLD char *zend_ini_scanner_get_filename(void) /* }}} */ /* {{{ zend_ini_open_file_for_scanning() */ -int zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode) +ZEND_RESULT_CODE zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode) { char *buf; size_t size; @@ -289,7 +289,7 @@ int zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode) /* }}} */ /* {{{ zend_ini_prepare_string_for_scanning() */ -int zend_ini_prepare_string_for_scanning(char *str, int scanner_mode) +ZEND_RESULT_CODE zend_ini_prepare_string_for_scanning(char *str, int scanner_mode) { int len = (int)strlen(str); From 801605f8521df37b2d0fa2b18ab852183622f221 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 15:05:15 +0200 Subject: [PATCH 131/170] Fix zend.c after voidification of zend_copy_ini_directives() --- Zend/zend.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Zend/zend.c b/Zend/zend.c index 34de8ff88ec13..354b9c3c5ea16 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -757,9 +757,8 @@ static void executor_globals_dtor(zend_executor_globals *executor_globals) /* {{ static void zend_new_thread_end_handler(THREAD_T thread_id) /* {{{ */ { - if (zend_copy_ini_directives() == SUCCESS) { - zend_ini_refresh_caches(ZEND_INI_STAGE_STARTUP); - } + zend_copy_ini_directives(); + zend_ini_refresh_caches(ZEND_INI_STAGE_STARTUP); } /* }}} */ #endif From 8d365469582781202df859ed7ded54bf89d98948 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 00:56:22 +0200 Subject: [PATCH 132/170] Boolify zend_interface.c --- Zend/zend_interfaces.c | 28 +++++++++++++++------------- Zend/zend_interfaces.h | 12 ++++++------ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c index 808de7c170dac..280af1cc3c41f 100644 --- a/Zend/zend_interfaces.c +++ b/Zend/zend_interfaces.c @@ -118,13 +118,13 @@ static void zend_user_it_dtor(zend_object_iterator *_iter) /* }}} */ /* {{{ zend_user_it_valid */ -ZEND_API int zend_user_it_valid(zend_object_iterator *_iter) +ZEND_API ZEND_RESULT_CODE zend_user_it_valid(zend_object_iterator *_iter) { if (_iter) { zend_user_iterator *iter = (zend_user_iterator*)_iter; zval *object = &iter->it.data; zval more; - int result; + bool result; zend_call_method_with_0_params(Z_OBJ_P(object), iter->ce, &iter->ce->iterator_funcs_ptr->zf_valid, "valid", &more); result = i_zend_is_true(&more); @@ -203,6 +203,7 @@ static const zend_object_iterator_funcs zend_interface_iterator_funcs_iterator = }; /* {{{ zend_user_it_get_iterator */ +/* by_ref is int due to Iterator API */ static zend_object_iterator *zend_user_it_get_iterator(zend_class_entry *ce, zval *object, int by_ref) { zend_user_iterator *iterator; @@ -225,6 +226,7 @@ static zend_object_iterator *zend_user_it_get_iterator(zend_class_entry *ce, zva /* }}} */ /* {{{ zend_user_it_get_new_iterator */ +/* by_ref is int due to Iterator API */ ZEND_API zend_object_iterator *zend_user_it_get_new_iterator(zend_class_entry *ce, zval *object, int by_ref) { zval iterator; @@ -249,7 +251,7 @@ ZEND_API zend_object_iterator *zend_user_it_get_new_iterator(zend_class_entry *c /* }}} */ /* {{{ zend_implement_traversable */ -static int zend_implement_traversable(zend_class_entry *interface, zend_class_entry *class_type) +static ZEND_RESULT_CODE zend_implement_traversable(zend_class_entry *interface, zend_class_entry *class_type) { /* Abstract class can implement Traversable only, in which case the extending class must * implement Iterator or IteratorAggregate. */ @@ -276,7 +278,7 @@ static int zend_implement_traversable(zend_class_entry *interface, zend_class_en /* }}} */ /* {{{ zend_implement_aggregate */ -static int zend_implement_aggregate(zend_class_entry *interface, zend_class_entry *class_type) +static ZEND_RESULT_CODE zend_implement_aggregate(zend_class_entry *interface, zend_class_entry *class_type) { if (zend_class_implements_interface(class_type, zend_ce_iterator)) { zend_error_noreturn(E_ERROR, @@ -316,7 +318,7 @@ static int zend_implement_aggregate(zend_class_entry *interface, zend_class_entr /* }}} */ /* {{{ zend_implement_iterator */ -static int zend_implement_iterator(zend_class_entry *interface, zend_class_entry *class_type) +static ZEND_RESULT_CODE zend_implement_iterator(zend_class_entry *interface, zend_class_entry *class_type) { if (zend_class_implements_interface(class_type, zend_ce_aggregate)) { zend_error_noreturn(E_ERROR, @@ -352,11 +354,11 @@ static int zend_implement_iterator(zend_class_entry *interface, zend_class_entry /* }}} */ /* {{{ zend_user_serialize */ -ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data) +ZEND_API ZEND_RESULT_CODE zend_user_serialize(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data) { zend_class_entry * ce = Z_OBJCE_P(object); zval retval; - int result; + ZEND_RESULT_CODE result; zend_call_method_with_0_params( Z_OBJ_P(object), Z_OBJCE_P(object), NULL, "serialize", &retval); @@ -389,7 +391,7 @@ ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, size_t *b /* }}} */ /* {{{ zend_user_unserialize */ -ZEND_API int zend_user_unserialize(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data) +ZEND_API ZEND_RESULT_CODE zend_user_unserialize(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data) { zval zdata; @@ -410,7 +412,7 @@ ZEND_API int zend_user_unserialize(zval *object, zend_class_entry *ce, const uns } /* }}} */ -ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_class_serialize_deny(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data) /* {{{ */ { zend_class_entry *ce = Z_OBJCE_P(object); zend_throw_exception_ex(NULL, 0, "Serialization of '%s' is not allowed", ZSTR_VAL(ce->name)); @@ -418,7 +420,7 @@ ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, siz } /* }}} */ -ZEND_API int zend_class_unserialize_deny(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_class_unserialize_deny(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data) /* {{{ */ { zend_throw_exception_ex(NULL, 0, "Unserialization of '%s' is not allowed", ZSTR_VAL(ce->name)); return FAILURE; @@ -426,7 +428,7 @@ ZEND_API int zend_class_unserialize_deny(zval *object, zend_class_entry *ce, con /* }}} */ /* {{{ zend_implement_serializable */ -static int zend_implement_serializable(zend_class_entry *interface, zend_class_entry *class_type) +static ZEND_RESULT_CODE zend_implement_serializable(zend_class_entry *interface, zend_class_entry *class_type) { if (class_type->parent && (class_type->parent->serialize || class_type->parent->unserialize) @@ -458,7 +460,7 @@ static zend_object *zend_internal_iterator_create(zend_class_entry *ce) { return &intern->std; } -ZEND_API int zend_create_internal_iterator_zval(zval *return_value, zval *obj) { +ZEND_API ZEND_RESULT_CODE zend_create_internal_iterator_zval(zval *return_value, zval *obj) { zend_class_entry *scope = EG(current_execute_data)->func->common.scope; ZEND_ASSERT(scope->get_iterator != zend_user_it_get_new_iterator); zend_object_iterator *iter = scope->get_iterator(Z_OBJCE_P(obj), obj, /* by_ref */ 0); @@ -492,7 +494,7 @@ static zend_internal_iterator *zend_internal_iterator_fetch(zval *This) { } /* Many iterators will not behave correctly if rewind() is not called, make sure it happens. */ -static int zend_internal_iterator_ensure_rewound(zend_internal_iterator *intern) { +static ZEND_RESULT_CODE zend_internal_iterator_ensure_rewound(zend_internal_iterator *intern) { if (!intern->rewind_called) { zend_object_iterator *iter = intern->iter; intern->rewind_called = 1; diff --git a/Zend/zend_interfaces.h b/Zend/zend_interfaces.h index 3f3f39b0877f4..bbc4ac5b49fda 100644 --- a/Zend/zend_interfaces.h +++ b/Zend/zend_interfaces.h @@ -61,7 +61,7 @@ ZEND_API zval* zend_call_method(zend_object *object, zend_class_entry *obj_ce, z zend_class_implements(zend_ce_ ## class_name, 1, zend_ce_ ## interface_name) ZEND_API void zend_user_it_rewind(zend_object_iterator *_iter); -ZEND_API int zend_user_it_valid(zend_object_iterator *_iter); +ZEND_API ZEND_RESULT_CODE zend_user_it_valid(zend_object_iterator *_iter); ZEND_API void zend_user_it_get_current_key(zend_object_iterator *_iter, zval *key); ZEND_API zval *zend_user_it_get_current_data(zend_object_iterator *_iter); ZEND_API void zend_user_it_move_forward(zend_object_iterator *_iter); @@ -72,13 +72,13 @@ ZEND_API zend_object_iterator *zend_user_it_get_new_iterator(zend_class_entry *c ZEND_API void zend_register_interfaces(void); -ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data); -ZEND_API int zend_user_unserialize(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data); +ZEND_API ZEND_RESULT_CODE zend_user_serialize(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data); +ZEND_API ZEND_RESULT_CODE zend_user_unserialize(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data); -ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data); -ZEND_API int zend_class_unserialize_deny(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data); +ZEND_API ZEND_RESULT_CODE zend_class_serialize_deny(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data); +ZEND_API ZEND_RESULT_CODE zend_class_unserialize_deny(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data); -ZEND_API int zend_create_internal_iterator_zval(zval *return_value, zval *obj); +ZEND_API ZEND_RESULT_CODE zend_create_internal_iterator_zval(zval *return_value, zval *obj); END_EXTERN_C() From 34766d70b3568fad24bcc1a527df5e58d6b75b9f Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 01:12:49 +0200 Subject: [PATCH 133/170] Boolify zend_language_scanner.l --- Zend/zend_compile.h | 4 +-- Zend/zend_language_scanner.h | 6 ++--- Zend/zend_language_scanner.l | 48 +++++++++++++++++------------------- 3 files changed, 28 insertions(+), 30 deletions(-) diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 2e3444863c6d8..0a4f628600e6f 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -758,7 +758,7 @@ ZEND_API unary_op_type get_unary_op(int opcode); ZEND_API binary_op_type get_binary_op(int opcode); void zend_stop_lexing(void); -void zend_emit_final_return(int return_one); +void zend_emit_final_return(bool return_one); /* Used during AST construction */ zend_ast *zend_ast_append_str(zend_ast *left, zend_ast *right); @@ -847,7 +847,7 @@ ZEND_API char *zend_make_compiled_string_description(const char *name); ZEND_API void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify_handlers); uint32_t zend_get_class_fetch_type(zend_string *name); ZEND_API zend_uchar zend_get_call_op(const zend_op *init_op, zend_function *fbc); -ZEND_API ZEND_RESULT_CODE zend_is_smart_branch(const zend_op *opline); +ZEND_API bool zend_is_smart_branch(const zend_op *opline); typedef zend_bool (*zend_auto_global_callback)(zend_string *name); typedef struct _zend_auto_global { diff --git a/Zend/zend_language_scanner.h b/Zend/zend_language_scanner.h index c15f11af2e51b..7af718c5a108b 100644 --- a/Zend/zend_language_scanner.h +++ b/Zend/zend_language_scanner.h @@ -75,10 +75,10 @@ typedef struct _zend_nest_location { BEGIN_EXTERN_C() ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state); ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state); -ZEND_API int zend_prepare_string_for_scanning(zval *str, const char *filename); +ZEND_API void zend_prepare_string_for_scanning(zval *str, const char *filename); ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter, const zend_encoding *old_encoding); -ZEND_API int zend_multibyte_set_filter(const zend_encoding *onetime_encoding); -ZEND_API int zend_lex_tstring(zval *zv, zend_lexer_ident_ref ident_ref); +ZEND_API ZEND_RESULT_CODE zend_multibyte_set_filter(const zend_encoding *onetime_encoding); +ZEND_API ZEND_RESULT_CODE zend_lex_tstring(zval *zv, zend_lexer_ident_ref ident_ref); END_EXTERN_C() diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index d16df9dbec0ec..027eea064e474 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -306,7 +306,7 @@ ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle) } } -ZEND_API int zend_lex_tstring(zval *zv, zend_lexer_ident_ref ident_ref) +ZEND_API ZEND_RESULT_CODE zend_lex_tstring(zval *zv, zend_lexer_ident_ref ident_ref) { char *ident = (char *) SCNG(yy_start) + ident_ref.offset; size_t length = ident_ref.len; @@ -486,7 +486,7 @@ static const zend_encoding* zend_multibyte_find_script_encoding(void) return CG(script_encoding_list)[0]; } -ZEND_API int zend_multibyte_set_filter(const zend_encoding *onetime_encoding) +ZEND_API ZEND_RESULT_CODE zend_multibyte_set_filter(const zend_encoding *onetime_encoding) { const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding(); const zend_encoding *script_encoding = onetime_encoding ? onetime_encoding: zend_multibyte_find_script_encoding(); @@ -524,10 +524,10 @@ ZEND_API int zend_multibyte_set_filter(const zend_encoding *onetime_encoding) LANG_SCNG(output_filter) = encoding_filter_intermediate_to_internal; } - return 0; + return SUCCESS; } -ZEND_API int open_file_for_scanning(zend_file_handle *file_handle) +ZEND_API ZEND_RESULT_CODE open_file_for_scanning(zend_file_handle *file_handle) { char *buf; size_t size; @@ -680,16 +680,15 @@ ZEND_API zend_ast *zend_compile_string_to_ast( CG(in_compilation) = 1; zend_save_lexical_state(&original_lex_state); - if (zend_prepare_string_for_scanning(&code_zv, filename) == SUCCESS) { - CG(ast) = NULL; - CG(ast_arena) = zend_arena_create(1024 * 32); - LANG_SCNG(yy_state) = yycINITIAL; + zend_prepare_string_for_scanning(&code_zv, filename); + CG(ast) = NULL; + CG(ast_arena) = zend_arena_create(1024 * 32); + LANG_SCNG(yy_state) = yycINITIAL; - if (zendparse() != 0) { - zend_ast_destroy(CG(ast)); - zend_arena_destroy(CG(ast_arena)); - CG(ast) = NULL; - } + if (zendparse() != 0) { + zend_ast_destroy(CG(ast)); + zend_arena_destroy(CG(ast_arena)); + CG(ast) = NULL; } /* restore_lexical_state changes CG(ast) and CG(ast_arena) */ @@ -737,7 +736,7 @@ zend_op_array *compile_filename(int type, zval *filename) return retval; } -ZEND_API int zend_prepare_string_for_scanning(zval *str, const char *filename) +ZEND_API void zend_prepare_string_for_scanning(zval *str, const char *filename) { char *buf; size_t size, old_len; @@ -780,7 +779,6 @@ ZEND_API int zend_prepare_string_for_scanning(zval *str, const char *filename) CG(zend_lineno) = 1; CG(increment_lineno) = 0; RESET_DOC_COMMENT(); - return SUCCESS; } @@ -836,7 +834,7 @@ zend_op_array *compile_string(zval *source_string, const char *filename) BEGIN_EXTERN_C() -int highlight_file(const char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini) +ZEND_RESULT_CODE highlight_file(const char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini) { zend_lex_state original_lex_state; zend_file_handle file_handle; @@ -858,7 +856,7 @@ int highlight_file(const char *filename, zend_syntax_highlighter_ini *syntax_hig return SUCCESS; } -int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, const char *str_name) +ZEND_RESULT_CODE highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, const char *str_name) { zend_lex_state original_lex_state; zval tmp; @@ -937,7 +935,7 @@ ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter ZVAL_STRINGL(zendlval, yytext, yyleng); \ } -static int zend_scan_escape_string(zval *zendlval, char *str, int len, char quote_type) +static ZEND_RESULT_CODE zend_scan_escape_string(zval *zendlval, char *str, int len, char quote_type) { register char *s, *t; char *end; @@ -1290,11 +1288,11 @@ static void enter_nesting(char opening) zend_stack_push(&SCNG(nest_location_stack), &nest_loc); } -static int exit_nesting(char closing) +static ZEND_RESULT_CODE exit_nesting(char closing) { if (zend_stack_is_empty(&SCNG(nest_location_stack))) { zend_throw_exception_ex(zend_ce_parse_error, 0, "Unmatched '%c'", closing); - return -1; + return FAILURE; } zend_nest_location *nest_loc = zend_stack_top(&SCNG(nest_location_stack)); @@ -1304,22 +1302,22 @@ static int exit_nesting(char closing) (opening == '[' && closing != ']') || (opening == '(' && closing != ')')) { report_bad_nesting(opening, nest_loc->lineno, closing); - return -1; + return FAILURE; } zend_stack_del_top(&SCNG(nest_location_stack)); - return 0; + return SUCCESS; } -static int check_nesting_at_end() +static ZEND_RESULT_CODE check_nesting_at_end() { if (!zend_stack_is_empty(&SCNG(nest_location_stack))) { zend_nest_location *nest_loc = zend_stack_top(&SCNG(nest_location_stack)); report_bad_nesting(nest_loc->text, nest_loc->lineno, 0); - return -1; + return FAILURE; } - return 0; + return SUCCESS; } #define PARSER_MODE() \ From c389890351f4a2d092eaf285feeb91725424cb5f Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 16:06:29 +0200 Subject: [PATCH 134/170] Voidify language_scanner.l --- Zend/zend_highlight.h | 2 +- Zend/zend_language_scanner.l | 18 +++++------------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/Zend/zend_highlight.h b/Zend/zend_highlight.h index 99bacd19b4377..6f8e5e51be57e 100644 --- a/Zend/zend_highlight.h +++ b/Zend/zend_highlight.h @@ -40,7 +40,7 @@ BEGIN_EXTERN_C() ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini); ZEND_API void zend_strip(void); ZEND_API ZEND_RESULT_CODE highlight_file(const char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini); -ZEND_API ZEND_RESULT_CODE highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, const char *str_name); +ZEND_API void highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, const char *str_name); ZEND_API void zend_html_putc(char c); ZEND_API void zend_html_puts(const char *s, size_t len); END_EXTERN_C() diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index 027eea064e474..7ebfe30b93ed4 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -821,10 +821,9 @@ zend_op_array *compile_string(zval *source_string, const char *filename) } zend_save_lexical_state(&original_lex_state); - if (zend_prepare_string_for_scanning(&tmp, filename) == SUCCESS) { - BEGIN(ST_IN_SCRIPTING); - op_array = zend_compile(ZEND_EVAL_CODE); - } + zend_prepare_string_for_scanning(&tmp, filename); + BEGIN(ST_IN_SCRIPTING); + op_array = zend_compile(ZEND_EVAL_CODE); zend_restore_lexical_state(&original_lex_state); zval_ptr_dtor(&tmp); @@ -856,7 +855,7 @@ ZEND_RESULT_CODE highlight_file(const char *filename, zend_syntax_highlighter_in return SUCCESS; } -ZEND_RESULT_CODE highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, const char *str_name) +void highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, const char *str_name) { zend_lex_state original_lex_state; zval tmp; @@ -866,13 +865,7 @@ ZEND_RESULT_CODE highlight_string(zval *str, zend_syntax_highlighter_ini *syntax str = &tmp; } zend_save_lexical_state(&original_lex_state); - if (zend_prepare_string_for_scanning(str, str_name)==FAILURE) { - zend_restore_lexical_state(&original_lex_state); - if (UNEXPECTED(str == &tmp)) { - zval_ptr_dtor(&tmp); - } - return FAILURE; - } + zend_prepare_string_for_scanning(str, str_name); BEGIN(INITIAL); zend_highlight(syntax_highlighter_ini); if (SCNG(script_filtered)) { @@ -883,7 +876,6 @@ ZEND_RESULT_CODE highlight_string(zval *str, zend_syntax_highlighter_ini *syntax if (UNEXPECTED(str == &tmp)) { zval_ptr_dtor(&tmp); } - return SUCCESS; } ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter, const zend_encoding *old_encoding) From b915d596c697fa2f81f99abea526ff6d57fe46a1 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 01:23:28 +0200 Subject: [PATCH 135/170] Voidify zend_list.c --- Zend/zend_list.c | 12 ++++-------- Zend/zend_list.h | 8 ++++---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Zend/zend_list.c b/Zend/zend_list.c index fd3db65395f7c..41a51de2e50d9 100644 --- a/Zend/zend_list.c +++ b/Zend/zend_list.c @@ -76,14 +76,13 @@ static void zend_resource_dtor(zend_resource *res) } -ZEND_API int ZEND_FASTCALL zend_list_close(zend_resource *res) +ZEND_API void ZEND_FASTCALL zend_list_close(zend_resource *res) { if (GC_REFCOUNT(res) <= 0) { zend_list_free(res); } else if (res->type >= 0) { zend_resource_dtor(res); } - return SUCCESS; } ZEND_API zend_resource* zend_register_resource(void *rsrc_pointer, int rsrc_type) @@ -203,18 +202,16 @@ void plist_entry_destructor(zval *zv) free(res); } -ZEND_API int zend_init_rsrc_list(void) +ZEND_API void zend_init_rsrc_list(void) { zend_hash_init(&EG(regular_list), 8, NULL, list_entry_destructor, 0); EG(regular_list).nNextFreeElement = 0; - return SUCCESS; } -int zend_init_rsrc_plist(void) +void zend_init_rsrc_plist(void) { zend_hash_init(&EG(persistent_list), 8, NULL, plist_entry_destructor, 1); - return SUCCESS; } @@ -299,11 +296,10 @@ static void list_destructors_dtor(zval *zv) free(Z_PTR_P(zv)); } -int zend_init_rsrc_list_dtors(void) +void zend_init_rsrc_list_dtors(void) { zend_hash_init(&list_destructors, 64, NULL, list_destructors_dtor, 1); list_destructors.nNextFreeElement=1; /* we don't want resource type 0 */ - return SUCCESS; } diff --git a/Zend/zend_list.h b/Zend/zend_list.h index 92fdd3d4178f3..680915121e2a6 100644 --- a/Zend/zend_list.h +++ b/Zend/zend_list.h @@ -45,17 +45,17 @@ void list_entry_destructor(zval *ptr); void plist_entry_destructor(zval *ptr); void zend_clean_module_rsrc_dtors(int module_number); -ZEND_API int zend_init_rsrc_list(void); /* Exported for phar hack */ -int zend_init_rsrc_plist(void); +ZEND_API void zend_init_rsrc_list(void); /* Exported for phar hack */ +void zend_init_rsrc_plist(void); void zend_close_rsrc_list(HashTable *ht); void zend_destroy_rsrc_list(HashTable *ht); -int zend_init_rsrc_list_dtors(void); +void zend_init_rsrc_list_dtors(void); void zend_destroy_rsrc_list_dtors(void); ZEND_API zval* ZEND_FASTCALL zend_list_insert(void *ptr, int type); ZEND_API void ZEND_FASTCALL zend_list_free(zend_resource *res); ZEND_API int ZEND_FASTCALL zend_list_delete(zend_resource *res); -ZEND_API int ZEND_FASTCALL zend_list_close(zend_resource *res); +ZEND_API void ZEND_FASTCALL zend_list_close(zend_resource *res); ZEND_API zend_resource *zend_register_resource(void *rsrc_pointer, int rsrc_type); ZEND_API void *zend_fetch_resource(zend_resource *res, const char *resource_type_name, int resource_type); From 18899010e5ce9a1112b77b6b2c80b1d8e3748b7e Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 01:18:02 +0200 Subject: [PATCH 136/170] Boolify zend_list.c --- Zend/zend_list.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Zend/zend_list.c b/Zend/zend_list.c index 41a51de2e50d9..ee0e7dcc56b39 100644 --- a/Zend/zend_list.c +++ b/Zend/zend_list.c @@ -42,7 +42,7 @@ ZEND_API zval* ZEND_FASTCALL zend_list_insert(void *ptr, int type) return zend_hash_index_add_new(&EG(regular_list), index, &zv); } -ZEND_API int ZEND_FASTCALL zend_list_delete(zend_resource *res) +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_list_delete(zend_resource *res) { if (GC_DELREF(res) <= 0) { return zend_hash_index_del(&EG(regular_list), res->handle); @@ -232,6 +232,7 @@ void zend_destroy_rsrc_list(HashTable *ht) zend_hash_graceful_reverse_destroy(ht); } +/* int return due to HashTable API */ static int clean_module_resource(zval *zv, void *arg) { int resource_id = *(int *)arg; @@ -239,7 +240,7 @@ static int clean_module_resource(zval *zv, void *arg) return Z_RES_TYPE_P(zv) == resource_id; } - +/* int return due to HashTable API */ static int zend_clean_module_rsrc_dtors_cb(zval *zv, void *arg) { zend_rsrc_list_dtors_entry *ld = (zend_rsrc_list_dtors_entry *)Z_PTR_P(zv); From 3542add16435cb0ba206f884f0fce982b7d371d7 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 01:31:26 +0200 Subject: [PATCH 137/170] Boolify zend_multibyte.c --- Zend/zend_multibyte.c | 14 +++++++------- Zend/zend_multibyte.h | 12 ++++++------ ext/mbstring/mbstring.c | 12 ++++++------ 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Zend/zend_multibyte.c b/Zend/zend_multibyte.c index 956ffbb74f841..cbf6213b1790c 100644 --- a/Zend/zend_multibyte.c +++ b/Zend/zend_multibyte.c @@ -33,7 +33,7 @@ static const char *dummy_encoding_name_getter(const zend_encoding *encoding) return (const char*)encoding; } -static int dummy_encoding_lexer_compatibility_checker(const zend_encoding *encoding) +static bool dummy_encoding_lexer_compatibility_checker(const zend_encoding *encoding) { return 0; } @@ -48,7 +48,7 @@ static size_t dummy_encoding_converter(unsigned char **to, size_t *to_length, co return (size_t)-1; } -static int dummy_encoding_list_parser(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, int persistent) +static ZEND_RESULT_CODE dummy_encoding_list_parser(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, bool persistent) { *return_list = pemalloc(0, persistent); *return_size = 0; @@ -60,7 +60,7 @@ static const zend_encoding *dummy_internal_encoding_getter(void) return NULL; } -static int dummy_internal_encoding_setter(const zend_encoding *encoding) +static ZEND_RESULT_CODE dummy_internal_encoding_setter(const zend_encoding *encoding) { return FAILURE; } @@ -84,7 +84,7 @@ ZEND_API const zend_encoding *zend_multibyte_encoding_utf16be = (const zend_enco ZEND_API const zend_encoding *zend_multibyte_encoding_utf16le = (const zend_encoding*)"UTF-32LE"; ZEND_API const zend_encoding *zend_multibyte_encoding_utf8 = (const zend_encoding*)"UTF-8"; -ZEND_API int zend_multibyte_set_functions(const zend_multibyte_functions *functions) +ZEND_API ZEND_RESULT_CODE zend_multibyte_set_functions(const zend_multibyte_functions *functions) { zend_multibyte_encoding_utf32be = functions->encoding_fetcher("UTF-32BE"); if (!zend_multibyte_encoding_utf32be) { @@ -155,7 +155,7 @@ ZEND_API size_t zend_multibyte_encoding_converter(unsigned char **to, size_t *to return multibyte_functions.encoding_converter(to, to_length, from, from_length, encoding_to, encoding_from); } -ZEND_API int zend_multibyte_parse_encoding_list(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, int persistent) +ZEND_API ZEND_RESULT_CODE zend_multibyte_parse_encoding_list(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, bool persistent) { return multibyte_functions.encoding_list_parser(encoding_list, encoding_list_len, return_list, return_size, persistent); } @@ -180,12 +180,12 @@ ZEND_API int zend_multibyte_set_script_encoding(const zend_encoding **encoding_l return SUCCESS; } -ZEND_API int zend_multibyte_set_internal_encoding(const zend_encoding *encoding) +ZEND_API ZEND_RESULT_CODE zend_multibyte_set_internal_encoding(const zend_encoding *encoding) { return multibyte_functions.internal_encoding_setter(encoding); } -ZEND_API int zend_multibyte_set_script_encoding_by_string(const char *new_value, size_t new_value_length) +ZEND_API ZEND_RESULT_CODE zend_multibyte_set_script_encoding_by_string(const char *new_value, size_t new_value_length) { const zend_encoding **list = 0; size_t size = 0; diff --git a/Zend/zend_multibyte.h b/Zend/zend_multibyte.h index 19444eda83592..2281fb5abfb28 100644 --- a/Zend/zend_multibyte.h +++ b/Zend/zend_multibyte.h @@ -26,12 +26,12 @@ typedef size_t (*zend_encoding_filter)(unsigned char **str, size_t *str_length, typedef const zend_encoding* (*zend_encoding_fetcher)(const char *encoding_name); typedef const char* (*zend_encoding_name_getter)(const zend_encoding *encoding); -typedef int (*zend_encoding_lexer_compatibility_checker)(const zend_encoding *encoding); +typedef bool (*zend_encoding_lexer_compatibility_checker)(const zend_encoding *encoding); typedef const zend_encoding *(*zend_encoding_detector)(const unsigned char *string, size_t length, const zend_encoding **list, size_t list_size); typedef size_t (*zend_encoding_converter)(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length, const zend_encoding *encoding_to, const zend_encoding *encoding_from); -typedef int (*zend_encoding_list_parser)(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, int persistent); +typedef ZEND_RESULT_CODE (*zend_encoding_list_parser)(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, bool persistent); typedef const zend_encoding *(*zend_encoding_internal_encoding_getter)(void); -typedef int (*zend_encoding_internal_encoding_setter)(const zend_encoding *encoding); +typedef ZEND_RESULT_CODE (*zend_encoding_internal_encoding_setter)(const zend_encoding *encoding); typedef struct _zend_multibyte_functions { const char *provider_name; @@ -57,7 +57,7 @@ ZEND_API extern const zend_encoding *zend_multibyte_encoding_utf16le; ZEND_API extern const zend_encoding *zend_multibyte_encoding_utf8; /* multibyte utility functions */ -ZEND_API int zend_multibyte_set_functions(const zend_multibyte_functions *functions); +ZEND_API ZEND_RESULT_CODE zend_multibyte_set_functions(const zend_multibyte_functions *functions); ZEND_API void zend_multibyte_restore_functions(void); ZEND_API const zend_multibyte_functions *zend_multibyte_get_functions(void); @@ -66,13 +66,13 @@ ZEND_API const char *zend_multibyte_get_encoding_name(const zend_encoding *encod ZEND_API int zend_multibyte_check_lexer_compatibility(const zend_encoding *encoding); ZEND_API const zend_encoding *zend_multibyte_encoding_detector(const unsigned char *string, size_t length, const zend_encoding **list, size_t list_size); ZEND_API size_t zend_multibyte_encoding_converter(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length, const zend_encoding *encoding_to, const zend_encoding *encoding_from); -ZEND_API int zend_multibyte_parse_encoding_list(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, int persistent); +ZEND_API int zend_multibyte_parse_encoding_list(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, bool persistent); ZEND_API const zend_encoding *zend_multibyte_get_internal_encoding(void); ZEND_API const zend_encoding *zend_multibyte_get_script_encoding(void); ZEND_API int zend_multibyte_set_script_encoding(const zend_encoding **encoding_list, size_t encoding_list_size); ZEND_API int zend_multibyte_set_internal_encoding(const zend_encoding *encoding); -ZEND_API int zend_multibyte_set_script_encoding_by_string(const char *new_value, size_t new_value_length); +ZEND_API ZEND_RESULT_CODE zend_multibyte_set_script_encoding_by_string(const char *new_value, size_t new_value_length); END_EXTERN_C() diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index 7bed59422c151..a650f99447f86 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -296,12 +296,12 @@ static size_t count_commas(const char *p, const char *end) { return count; } -/* {{{ static int php_mb_parse_encoding_list() +/* {{{ static ZEND_RESULT_CODE php_mb_parse_encoding_list() * Return FAILURE if input contains any illegal encoding, otherwise SUCCESS. * Emits a ValueError in function context and a warning in INI context, in INI context arg_num must be 0. */ -static int php_mb_parse_encoding_list(const char *value, size_t value_length, - const mbfl_encoding ***return_list, size_t *return_size, int persistent, uint32_t arg_num, +static ZEND_RESULT_CODE php_mb_parse_encoding_list(const char *value, size_t value_length, + const mbfl_encoding ***return_list, size_t *return_size, bool persistent, uint32_t arg_num, zend_bool allow_pass_encoding) { if (value == NULL || value_length == 0) { @@ -450,7 +450,7 @@ static const char *php_mb_zend_encoding_name_getter(const zend_encoding *encodin return ((const mbfl_encoding *)encoding)->name; } -static int php_mb_zend_encoding_lexer_compatibility_checker(const zend_encoding *_encoding) +static bool php_mb_zend_encoding_lexer_compatibility_checker(const zend_encoding *_encoding) { const mbfl_encoding *encoding = (const mbfl_encoding*)_encoding; if (encoding->flag & MBFL_ENCTYPE_SBCS) { @@ -521,7 +521,7 @@ static size_t php_mb_zend_encoding_converter(unsigned char **to, size_t *to_leng return loc; } -static int php_mb_zend_encoding_list_parser(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, int persistent) +static ZEND_RESULT_CODE php_mb_zend_encoding_list_parser(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, bool persistent) { return php_mb_parse_encoding_list( encoding_list, encoding_list_len, @@ -534,7 +534,7 @@ static const zend_encoding *php_mb_zend_internal_encoding_getter(void) return (const zend_encoding *)MBSTRG(internal_encoding); } -static int php_mb_zend_internal_encoding_setter(const zend_encoding *encoding) +static ZEND_RESULT_CODE php_mb_zend_internal_encoding_setter(const zend_encoding *encoding) { MBSTRG(internal_encoding) = (const mbfl_encoding *)encoding; return SUCCESS; From ba8a0a3e8b7d2fbc5e42a12fe50fe92026622ec4 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 01:51:14 +0200 Subject: [PATCH 138/170] Boolify zend_multiply.h --- Zend/zend_arena.h | 4 ++-- Zend/zend_multiply.h | 18 +++++++++--------- ext/opcache/Optimizer/sccp.c | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Zend/zend_arena.h b/Zend/zend_arena.h index 6ecc1fc85fb46..ff2d0a5fe60df 100644 --- a/Zend/zend_arena.h +++ b/Zend/zend_arena.h @@ -78,7 +78,7 @@ static zend_always_inline void* zend_arena_alloc(zend_arena **arena_ptr, size_t static zend_always_inline void* zend_arena_calloc(zend_arena **arena_ptr, size_t count, size_t unit_size) { - int overflow; + bool overflow; size_t size; void *ret; @@ -174,7 +174,7 @@ static zend_always_inline void *zend_arena_alloc(zend_arena **arena_ptr, size_t static zend_always_inline void* zend_arena_calloc(zend_arena **arena_ptr, size_t count, size_t unit_size) { - int overflow; + bool overflow; size_t size; void *ret; diff --git a/Zend/zend_multiply.h b/Zend/zend_multiply.h index a3827d25d128d..c6cd472a237b1 100644 --- a/Zend/zend_multiply.h +++ b/Zend/zend_multiply.h @@ -154,7 +154,7 @@ #if defined(__GNUC__) && (defined(__native_client__) || defined(i386)) -static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, int *overflow) +static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, bool *overflow) { size_t res = nmemb; size_t m_overflow = 0; @@ -182,7 +182,7 @@ static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, si #elif defined(__GNUC__) && defined(__x86_64__) -static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, int *overflow) +static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, bool *overflow) { size_t res = nmemb; zend_ulong m_overflow = 0; @@ -219,7 +219,7 @@ static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, si #elif defined(__GNUC__) && defined(__arm__) -static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, int *overflow) +static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, bool *overflow) { size_t res; zend_ulong m_overflow; @@ -241,7 +241,7 @@ static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, si #elif defined(__GNUC__) && defined(__aarch64__) -static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, int *overflow) +static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, bool *overflow) { size_t res; zend_ulong m_overflow; @@ -262,7 +262,7 @@ static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, si #elif defined(__GNUC__) && defined(__powerpc64__) -static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, int *overflow) +static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, bool *overflow) { size_t res; unsigned long m_overflow; @@ -286,7 +286,7 @@ static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, si #elif SIZEOF_SIZE_T == 4 -static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, int *overflow) +static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, bool *overflow) { uint64_t res = (uint64_t) nmemb * (uint64_t) size + (uint64_t) offset; @@ -300,7 +300,7 @@ static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, si #else -static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, int *overflow) +static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, bool *overflow) { size_t res = nmemb * size + offset; double _d = (double)nmemb * (double)size + (double)offset; @@ -317,7 +317,7 @@ static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, si static zend_always_inline size_t zend_safe_address_guarded(size_t nmemb, size_t size, size_t offset) { - int overflow; + bool overflow; size_t ret = zend_safe_address(nmemb, size, offset, &overflow); if (UNEXPECTED(overflow)) { @@ -330,7 +330,7 @@ static zend_always_inline size_t zend_safe_address_guarded(size_t nmemb, size_t /* A bit more generic version of the same */ static zend_always_inline size_t zend_safe_addmult(size_t nmemb, size_t size, size_t offset, const char *message) { - int overflow; + bool overflow; size_t ret = zend_safe_address(nmemb, size, offset, &overflow); if (UNEXPECTED(overflow)) { diff --git a/ext/opcache/Optimizer/sccp.c b/ext/opcache/Optimizer/sccp.c index 1615423abe017..d0dffc275da3e 100644 --- a/ext/opcache/Optimizer/sccp.c +++ b/ext/opcache/Optimizer/sccp.c @@ -788,7 +788,7 @@ static inline int ct_eval_func_call( uint32_t i; zend_execute_data *execute_data, *prev_execute_data; zend_function *func; - int overflow; + bool overflow; if (num_args == 0) { if (zend_string_equals_literal(name, "php_sapi_name") From b935df4d5ec74eaa714105c68897f98f6d889de5 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 01:59:40 +0200 Subject: [PATCH 139/170] Boolify zend_object_handler.c --- Zend/zend_object_handlers.c | 26 +++++++++++++------------- Zend/zend_object_handlers.h | 24 ++++++++++++------------ 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index b3eb2d1ba597b..5c9c6b8db7031 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -138,7 +138,7 @@ ZEND_API HashTable *zend_std_get_gc(zend_object *zobj, zval **table, int *n) /* } /* }}} */ -ZEND_API HashTable *zend_std_get_debug_info(zend_object *object, int *is_temp) /* {{{ */ +ZEND_API HashTable *zend_std_get_debug_info(zend_object *object, bool *is_temp) /* {{{ */ { zend_class_entry *ce = object->ce; zval retval; @@ -223,7 +223,7 @@ static zend_always_inline zend_bool is_derived_class(zend_class_entry *child_cla } /* }}} */ -static zend_never_inline int is_protected_compatible_scope(zend_class_entry *ce, zend_class_entry *scope) /* {{{ */ +static zend_never_inline bool is_protected_compatible_scope(zend_class_entry *ce, zend_class_entry *scope) /* {{{ */ { return scope && (is_derived_class(ce, scope) || is_derived_class(scope, ce)); @@ -267,7 +267,7 @@ static ZEND_COLD zend_never_inline void zend_forbidden_dynamic_property( ZSTR_VAL(ce->name), ZSTR_VAL(member)); } -static zend_always_inline uintptr_t zend_get_property_offset(zend_class_entry *ce, zend_string *member, int silent, void **cache_slot, zend_property_info **info_ptr) /* {{{ */ +static zend_always_inline uintptr_t zend_get_property_offset(zend_class_entry *ce, zend_string *member, bool silent, void **cache_slot, zend_property_info **info_ptr) /* {{{ */ { zval *zv; zend_property_info *property_info; @@ -443,7 +443,7 @@ ZEND_API zend_property_info *zend_get_property_info(zend_class_entry *ce, zend_s } /* }}} */ -ZEND_API int zend_check_property_access(zend_object *zobj, zend_string *prop_info_name, zend_bool is_dynamic) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_check_property_access(zend_object *zobj, zend_string *prop_info_name, zend_bool is_dynamic) /* {{{ */ { zend_property_info *property_info; const char *class_name = NULL; @@ -875,11 +875,11 @@ ZEND_API void zend_std_write_dimension(zend_object *object, zval *offset, zval * } /* }}} */ -ZEND_API int zend_std_has_dimension(zend_object *object, zval *offset, int check_empty) /* {{{ */ +ZEND_API bool zend_std_has_dimension(zend_object *object, zval *offset, bool check_empty) /* {{{ */ { zend_class_entry *ce = object->ce; zval retval, tmp_offset; - int result; + bool result; if (EXPECTED(zend_class_implements_interface(ce, zend_ce_arrayaccess) != 0)) { ZVAL_COPY_DEREF(&tmp_offset, offset); @@ -1074,7 +1074,7 @@ static zend_never_inline zend_function *zend_get_parent_private_method(zend_clas /* Ensures that we're allowed to call a protected method. */ -ZEND_API int zend_check_protected(zend_class_entry *ce, zend_class_entry *scope) /* {{{ */ +ZEND_API bool zend_check_protected(zend_class_entry *ce, zend_class_entry *scope) /* {{{ */ { zend_class_entry *fbc_scope = ce; @@ -1101,7 +1101,7 @@ ZEND_API int zend_check_protected(zend_class_entry *ce, zend_class_entry *scope) } /* }}} */ -ZEND_API zend_function *zend_get_call_trampoline_func(zend_class_entry *ce, zend_string *method_name, int is_static) /* {{{ */ +ZEND_API zend_function *zend_get_call_trampoline_func(zend_class_entry *ce, zend_string *method_name, bool is_static) /* {{{ */ { size_t mname_len; zend_op_array *func; @@ -1599,9 +1599,9 @@ ZEND_API int zend_std_compare_objects(zval *o1, zval *o2) /* {{{ */ } /* }}} */ -ZEND_API int zend_std_has_property(zend_object *zobj, zend_string *name, int has_set_exists, void **cache_slot) /* {{{ */ +ZEND_API bool zend_std_has_property(zend_object *zobj, zend_string *name, bool has_set_exists, void **cache_slot) /* {{{ */ { - int result; + bool result; zval *value = NULL; uintptr_t property_offset; zend_property_info *prop_info = NULL; @@ -1707,7 +1707,7 @@ ZEND_API zend_string *zend_std_get_class_name(const zend_object *zobj) /* {{{ */ } /* }}} */ -ZEND_API int zend_std_cast_object_tostring(zend_object *readobj, zval *writeobj, int type) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_std_cast_object_tostring(zend_object *readobj, zval *writeobj, int type) /* {{{ */ { switch (type) { case IS_STRING: { @@ -1737,7 +1737,7 @@ ZEND_API int zend_std_cast_object_tostring(zend_object *readobj, zval *writeobj, } /* }}} */ -ZEND_API int zend_std_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, zend_bool check_only) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_std_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, zend_bool check_only) /* {{{ */ { zval *func; zend_class_entry *ce = obj->ce; @@ -1766,7 +1766,7 @@ ZEND_API HashTable *zend_std_get_properties_for(zend_object *obj, zend_prop_purp switch (purpose) { case ZEND_PROP_PURPOSE_DEBUG: if (obj->handlers->get_debug_info) { - int is_temp; + bool is_temp; ht = obj->handlers->get_debug_info(obj, &is_temp); if (ht && !is_temp && !(GC_FLAGS(ht) & GC_IMMUTABLE)) { GC_ADDREF(ht); diff --git a/Zend/zend_object_handlers.h b/Zend/zend_object_handlers.h index fedc70cc80997..a6ce3a84d0010 100644 --- a/Zend/zend_object_handlers.h +++ b/Zend/zend_object_handlers.h @@ -75,10 +75,10 @@ typedef zval *(*zend_object_get_property_ptr_ptr_t)(zend_object *object, zend_st * 1 (set) whether property exists and is true * 2 (exists) whether property exists */ -typedef int (*zend_object_has_property_t)(zend_object *object, zend_string *member, int has_set_exists, void **cache_slot); +typedef int (*zend_object_has_property_t)(zend_object *object, zend_string *member, bool has_set_exists, void **cache_slot); /* Used to check if a dimension of the object exists */ -typedef int (*zend_object_has_dimension_t)(zend_object *object, zval *member, int check_empty); +typedef int (*zend_object_has_dimension_t)(zend_object *object, zval *member, bool check_empty); /* Used to remove a property of the object */ typedef void (*zend_object_unset_property_t)(zend_object *object, zend_string *member, void **cache_slot); @@ -89,7 +89,7 @@ typedef void (*zend_object_unset_dimension_t)(zend_object *object, zval *offset) /* Used to get hash of the properties of the object, as hash of zval's */ typedef HashTable *(*zend_object_get_properties_t)(zend_object *object); -typedef HashTable *(*zend_object_get_debug_info_t)(zend_object *object, int *is_temp); +typedef HashTable *(*zend_object_get_debug_info_t)(zend_object *object, bool *is_temp); typedef enum _zend_prop_purpose { /* Used for debugging. Supersedes get_debug_info handler. */ @@ -193,31 +193,31 @@ ZEND_API zval *zend_std_get_static_property_with_info(zend_class_entry *ce, zend ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *property_name, int type); ZEND_API ZEND_COLD zend_bool zend_std_unset_static_property(zend_class_entry *ce, zend_string *property_name); ZEND_API zend_function *zend_std_get_constructor(zend_object *object); -ZEND_API struct _zend_property_info *zend_get_property_info(zend_class_entry *ce, zend_string *member, int silent); +ZEND_API struct _zend_property_info *zend_get_property_info(zend_class_entry *ce, zend_string *member, bool silent); ZEND_API HashTable *zend_std_get_properties(zend_object *object); ZEND_API HashTable *zend_std_get_gc(zend_object *object, zval **table, int *n); -ZEND_API HashTable *zend_std_get_debug_info(zend_object *object, int *is_temp); -ZEND_API int zend_std_cast_object_tostring(zend_object *object, zval *writeobj, int type); +ZEND_API HashTable *zend_std_get_debug_info(zend_object *object, bool *is_temp); +ZEND_API ZEND_RESULT_CODE zend_std_cast_object_tostring(zend_object *object, zval *writeobj, int type); ZEND_API zval *zend_std_get_property_ptr_ptr(zend_object *object, zend_string *member, int type, void **cache_slot); ZEND_API zval *zend_std_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv); ZEND_API zval *zend_std_write_property(zend_object *object, zend_string *member, zval *value, void **cache_slot); -ZEND_API int zend_std_has_property(zend_object *object, zend_string *member, int has_set_exists, void **cache_slot); +ZEND_API bool zend_std_has_property(zend_object *object, zend_string *member, bool has_set_exists, void **cache_slot); ZEND_API void zend_std_unset_property(zend_object *object, zend_string *member, void **cache_slot); ZEND_API zval *zend_std_read_dimension(zend_object *object, zval *offset, int type, zval *rv); ZEND_API void zend_std_write_dimension(zend_object *object, zval *offset, zval *value); -ZEND_API int zend_std_has_dimension(zend_object *object, zval *offset, int check_empty); +ZEND_API bool zend_std_has_dimension(zend_object *object, zval *offset, bool check_empty); ZEND_API void zend_std_unset_dimension(zend_object *object, zval *offset); ZEND_API zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string *method_name, const zval *key); ZEND_API zend_string *zend_std_get_class_name(const zend_object *zobj); ZEND_API int zend_std_compare_objects(zval *o1, zval *o2); -ZEND_API int zend_std_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, zend_bool check_only); +ZEND_API ZEND_RESULT_CODE zend_std_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, zend_bool check_only); ZEND_API void rebuild_object_properties(zend_object *zobj); -ZEND_API int zend_check_protected(zend_class_entry *ce, zend_class_entry *scope); +ZEND_API bool zend_check_protected(zend_class_entry *ce, zend_class_entry *scope); -ZEND_API int zend_check_property_access(zend_object *zobj, zend_string *prop_info_name, zend_bool is_dynamic); +ZEND_API ZEND_RESULT_CODE zend_check_property_access(zend_object *zobj, zend_string *prop_info_name, zend_bool is_dynamic); -ZEND_API zend_function *zend_get_call_trampoline_func(zend_class_entry *ce, zend_string *method_name, int is_static); +ZEND_API zend_function *zend_get_call_trampoline_func(zend_class_entry *ce, zend_string *method_name, bool is_static); ZEND_API uint32_t *zend_get_property_guard(zend_object *zobj, zend_string *member); From b73b448781e5a1fd4b743985fc18bc2567c453be Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 03:49:34 +0200 Subject: [PATCH 140/170] Revert "Boolify zend_object_handler.c" Due to incompatible pointers This reverts commit 17eaad3caa225f44d88e246d0ec27694cdef40ad. --- Zend/zend_object_handlers.c | 26 +++++++++++++------------- Zend/zend_object_handlers.h | 24 ++++++++++++------------ 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 5c9c6b8db7031..b3eb2d1ba597b 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -138,7 +138,7 @@ ZEND_API HashTable *zend_std_get_gc(zend_object *zobj, zval **table, int *n) /* } /* }}} */ -ZEND_API HashTable *zend_std_get_debug_info(zend_object *object, bool *is_temp) /* {{{ */ +ZEND_API HashTable *zend_std_get_debug_info(zend_object *object, int *is_temp) /* {{{ */ { zend_class_entry *ce = object->ce; zval retval; @@ -223,7 +223,7 @@ static zend_always_inline zend_bool is_derived_class(zend_class_entry *child_cla } /* }}} */ -static zend_never_inline bool is_protected_compatible_scope(zend_class_entry *ce, zend_class_entry *scope) /* {{{ */ +static zend_never_inline int is_protected_compatible_scope(zend_class_entry *ce, zend_class_entry *scope) /* {{{ */ { return scope && (is_derived_class(ce, scope) || is_derived_class(scope, ce)); @@ -267,7 +267,7 @@ static ZEND_COLD zend_never_inline void zend_forbidden_dynamic_property( ZSTR_VAL(ce->name), ZSTR_VAL(member)); } -static zend_always_inline uintptr_t zend_get_property_offset(zend_class_entry *ce, zend_string *member, bool silent, void **cache_slot, zend_property_info **info_ptr) /* {{{ */ +static zend_always_inline uintptr_t zend_get_property_offset(zend_class_entry *ce, zend_string *member, int silent, void **cache_slot, zend_property_info **info_ptr) /* {{{ */ { zval *zv; zend_property_info *property_info; @@ -443,7 +443,7 @@ ZEND_API zend_property_info *zend_get_property_info(zend_class_entry *ce, zend_s } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_check_property_access(zend_object *zobj, zend_string *prop_info_name, zend_bool is_dynamic) /* {{{ */ +ZEND_API int zend_check_property_access(zend_object *zobj, zend_string *prop_info_name, zend_bool is_dynamic) /* {{{ */ { zend_property_info *property_info; const char *class_name = NULL; @@ -875,11 +875,11 @@ ZEND_API void zend_std_write_dimension(zend_object *object, zval *offset, zval * } /* }}} */ -ZEND_API bool zend_std_has_dimension(zend_object *object, zval *offset, bool check_empty) /* {{{ */ +ZEND_API int zend_std_has_dimension(zend_object *object, zval *offset, int check_empty) /* {{{ */ { zend_class_entry *ce = object->ce; zval retval, tmp_offset; - bool result; + int result; if (EXPECTED(zend_class_implements_interface(ce, zend_ce_arrayaccess) != 0)) { ZVAL_COPY_DEREF(&tmp_offset, offset); @@ -1074,7 +1074,7 @@ static zend_never_inline zend_function *zend_get_parent_private_method(zend_clas /* Ensures that we're allowed to call a protected method. */ -ZEND_API bool zend_check_protected(zend_class_entry *ce, zend_class_entry *scope) /* {{{ */ +ZEND_API int zend_check_protected(zend_class_entry *ce, zend_class_entry *scope) /* {{{ */ { zend_class_entry *fbc_scope = ce; @@ -1101,7 +1101,7 @@ ZEND_API bool zend_check_protected(zend_class_entry *ce, zend_class_entry *scope } /* }}} */ -ZEND_API zend_function *zend_get_call_trampoline_func(zend_class_entry *ce, zend_string *method_name, bool is_static) /* {{{ */ +ZEND_API zend_function *zend_get_call_trampoline_func(zend_class_entry *ce, zend_string *method_name, int is_static) /* {{{ */ { size_t mname_len; zend_op_array *func; @@ -1599,9 +1599,9 @@ ZEND_API int zend_std_compare_objects(zval *o1, zval *o2) /* {{{ */ } /* }}} */ -ZEND_API bool zend_std_has_property(zend_object *zobj, zend_string *name, bool has_set_exists, void **cache_slot) /* {{{ */ +ZEND_API int zend_std_has_property(zend_object *zobj, zend_string *name, int has_set_exists, void **cache_slot) /* {{{ */ { - bool result; + int result; zval *value = NULL; uintptr_t property_offset; zend_property_info *prop_info = NULL; @@ -1707,7 +1707,7 @@ ZEND_API zend_string *zend_std_get_class_name(const zend_object *zobj) /* {{{ */ } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_std_cast_object_tostring(zend_object *readobj, zval *writeobj, int type) /* {{{ */ +ZEND_API int zend_std_cast_object_tostring(zend_object *readobj, zval *writeobj, int type) /* {{{ */ { switch (type) { case IS_STRING: { @@ -1737,7 +1737,7 @@ ZEND_API ZEND_RESULT_CODE zend_std_cast_object_tostring(zend_object *readobj, zv } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_std_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, zend_bool check_only) /* {{{ */ +ZEND_API int zend_std_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, zend_bool check_only) /* {{{ */ { zval *func; zend_class_entry *ce = obj->ce; @@ -1766,7 +1766,7 @@ ZEND_API HashTable *zend_std_get_properties_for(zend_object *obj, zend_prop_purp switch (purpose) { case ZEND_PROP_PURPOSE_DEBUG: if (obj->handlers->get_debug_info) { - bool is_temp; + int is_temp; ht = obj->handlers->get_debug_info(obj, &is_temp); if (ht && !is_temp && !(GC_FLAGS(ht) & GC_IMMUTABLE)) { GC_ADDREF(ht); diff --git a/Zend/zend_object_handlers.h b/Zend/zend_object_handlers.h index a6ce3a84d0010..fedc70cc80997 100644 --- a/Zend/zend_object_handlers.h +++ b/Zend/zend_object_handlers.h @@ -75,10 +75,10 @@ typedef zval *(*zend_object_get_property_ptr_ptr_t)(zend_object *object, zend_st * 1 (set) whether property exists and is true * 2 (exists) whether property exists */ -typedef int (*zend_object_has_property_t)(zend_object *object, zend_string *member, bool has_set_exists, void **cache_slot); +typedef int (*zend_object_has_property_t)(zend_object *object, zend_string *member, int has_set_exists, void **cache_slot); /* Used to check if a dimension of the object exists */ -typedef int (*zend_object_has_dimension_t)(zend_object *object, zval *member, bool check_empty); +typedef int (*zend_object_has_dimension_t)(zend_object *object, zval *member, int check_empty); /* Used to remove a property of the object */ typedef void (*zend_object_unset_property_t)(zend_object *object, zend_string *member, void **cache_slot); @@ -89,7 +89,7 @@ typedef void (*zend_object_unset_dimension_t)(zend_object *object, zval *offset) /* Used to get hash of the properties of the object, as hash of zval's */ typedef HashTable *(*zend_object_get_properties_t)(zend_object *object); -typedef HashTable *(*zend_object_get_debug_info_t)(zend_object *object, bool *is_temp); +typedef HashTable *(*zend_object_get_debug_info_t)(zend_object *object, int *is_temp); typedef enum _zend_prop_purpose { /* Used for debugging. Supersedes get_debug_info handler. */ @@ -193,31 +193,31 @@ ZEND_API zval *zend_std_get_static_property_with_info(zend_class_entry *ce, zend ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *property_name, int type); ZEND_API ZEND_COLD zend_bool zend_std_unset_static_property(zend_class_entry *ce, zend_string *property_name); ZEND_API zend_function *zend_std_get_constructor(zend_object *object); -ZEND_API struct _zend_property_info *zend_get_property_info(zend_class_entry *ce, zend_string *member, bool silent); +ZEND_API struct _zend_property_info *zend_get_property_info(zend_class_entry *ce, zend_string *member, int silent); ZEND_API HashTable *zend_std_get_properties(zend_object *object); ZEND_API HashTable *zend_std_get_gc(zend_object *object, zval **table, int *n); -ZEND_API HashTable *zend_std_get_debug_info(zend_object *object, bool *is_temp); -ZEND_API ZEND_RESULT_CODE zend_std_cast_object_tostring(zend_object *object, zval *writeobj, int type); +ZEND_API HashTable *zend_std_get_debug_info(zend_object *object, int *is_temp); +ZEND_API int zend_std_cast_object_tostring(zend_object *object, zval *writeobj, int type); ZEND_API zval *zend_std_get_property_ptr_ptr(zend_object *object, zend_string *member, int type, void **cache_slot); ZEND_API zval *zend_std_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv); ZEND_API zval *zend_std_write_property(zend_object *object, zend_string *member, zval *value, void **cache_slot); -ZEND_API bool zend_std_has_property(zend_object *object, zend_string *member, bool has_set_exists, void **cache_slot); +ZEND_API int zend_std_has_property(zend_object *object, zend_string *member, int has_set_exists, void **cache_slot); ZEND_API void zend_std_unset_property(zend_object *object, zend_string *member, void **cache_slot); ZEND_API zval *zend_std_read_dimension(zend_object *object, zval *offset, int type, zval *rv); ZEND_API void zend_std_write_dimension(zend_object *object, zval *offset, zval *value); -ZEND_API bool zend_std_has_dimension(zend_object *object, zval *offset, bool check_empty); +ZEND_API int zend_std_has_dimension(zend_object *object, zval *offset, int check_empty); ZEND_API void zend_std_unset_dimension(zend_object *object, zval *offset); ZEND_API zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string *method_name, const zval *key); ZEND_API zend_string *zend_std_get_class_name(const zend_object *zobj); ZEND_API int zend_std_compare_objects(zval *o1, zval *o2); -ZEND_API ZEND_RESULT_CODE zend_std_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, zend_bool check_only); +ZEND_API int zend_std_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, zend_bool check_only); ZEND_API void rebuild_object_properties(zend_object *zobj); -ZEND_API bool zend_check_protected(zend_class_entry *ce, zend_class_entry *scope); +ZEND_API int zend_check_protected(zend_class_entry *ce, zend_class_entry *scope); -ZEND_API ZEND_RESULT_CODE zend_check_property_access(zend_object *zobj, zend_string *prop_info_name, zend_bool is_dynamic); +ZEND_API int zend_check_property_access(zend_object *zobj, zend_string *prop_info_name, zend_bool is_dynamic); -ZEND_API zend_function *zend_get_call_trampoline_func(zend_class_entry *ce, zend_string *method_name, bool is_static); +ZEND_API zend_function *zend_get_call_trampoline_func(zend_class_entry *ce, zend_string *method_name, int is_static); ZEND_API uint32_t *zend_get_property_guard(zend_object *zobj, zend_string *member); From 13b326ee619a8a4f857fe16f39414fca82d064fa Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 02:01:58 +0200 Subject: [PATCH 141/170] Voidify zend_opcode.c --- Zend/zend_compile.h | 2 +- Zend/zend_opcode.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 0a4f628600e6f..1010a250276f3 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -841,7 +841,7 @@ typedef zend_bool (*zend_needs_live_range_cb)(zend_op_array *op_array, zend_op * ZEND_API void zend_recalc_live_ranges( zend_op_array *op_array, zend_needs_live_range_cb needs_live_range); -ZEND_API int pass_two(zend_op_array *op_array); +ZEND_API void pass_two(zend_op_array *op_array); ZEND_API zend_bool zend_is_compiling(void); ZEND_API char *zend_make_compiled_string_description(const char *name); ZEND_API void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify_handlers); diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c index 14dd6e46db27d..a9236faf6a68c 100644 --- a/Zend/zend_opcode.c +++ b/Zend/zend_opcode.c @@ -907,12 +907,12 @@ ZEND_API void zend_recalc_live_ranges( zend_calc_live_ranges(op_array, needs_live_range); } -ZEND_API int pass_two(zend_op_array *op_array) +ZEND_API void pass_two(zend_op_array *op_array) { zend_op *opline, *end; if (!ZEND_USER_CODE(op_array->type)) { - return 0; + return; } if (CG(compiler_options) & ZEND_COMPILE_EXTENDED_STMT) { zend_update_extended_stmts(op_array); @@ -1074,7 +1074,7 @@ ZEND_API int pass_two(zend_op_array *op_array) zend_calc_live_ranges(op_array, NULL); - return 0; + return; } ZEND_API unary_op_type get_unary_op(int opcode) From 9d31dc9e3148c94ba7bd3b2cd0dc47fc1c8b0131 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 02:25:23 +0200 Subject: [PATCH 142/170] Boolify zend_operators.c --- Zend/zend_operators.c | 83 ++++++++++++++++++++++--------------------- Zend/zend_operators.h | 70 ++++++++++++++++++------------------ 2 files changed, 77 insertions(+), 76 deletions(-) diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index fba6c6337a7eb..9e91069e78b7c 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -232,7 +232,7 @@ static zend_never_inline zval* ZEND_FASTCALL _zendi_convert_scalar_to_number_sil } /* }}} */ -static zend_never_inline int ZEND_FASTCALL _zendi_try_convert_scalar_to_number(zval *op, zval *holder) /* {{{ */ +static zend_never_inline ZEND_RESULT_CODE ZEND_FASTCALL _zendi_try_convert_scalar_to_number(zval *op, zval *holder) /* {{{ */ { switch (Z_TYPE_P(op)) { case IS_NULL: @@ -274,7 +274,7 @@ static zend_never_inline int ZEND_FASTCALL _zendi_try_convert_scalar_to_number(z } /* }}} */ -static zend_always_inline int zendi_try_convert_scalar_to_number(zval *op, zval *holder) /* {{{ */ +static zend_always_inline ZEND_RESULT_CODE zendi_try_convert_scalar_to_number(zval *op, zval *holder) /* {{{ */ { if (Z_TYPE_P(op) == IS_LONG || Z_TYPE_P(op) == IS_DOUBLE) { ZVAL_COPY_VALUE(holder, op); @@ -559,7 +559,7 @@ ZEND_API void ZEND_FASTCALL convert_to_null(zval *op) /* {{{ */ ZEND_API void ZEND_FASTCALL convert_to_boolean(zval *op) /* {{{ */ { - int tmp; + bool tmp; try_again: switch (Z_TYPE_P(op)) { @@ -963,7 +963,7 @@ static zend_never_inline void ZEND_FASTCALL add_function_array(zval *result, zva } /* }}} */ -static zend_always_inline int add_function_fast(zval *result, zval *op1, zval *op2) /* {{{ */ +static zend_always_inline ZEND_RESULT_CODE add_function_fast(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_uchar type_pair = TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2)); @@ -987,7 +987,7 @@ static zend_always_inline int add_function_fast(zval *result, zval *op1, zval *o } } /* }}} */ -static zend_never_inline int ZEND_FASTCALL add_function_slow(zval *result, zval *op1, zval *op2) /* {{{ */ +static zend_never_inline ZEND_RESULT_CODE ZEND_FASTCALL add_function_slow(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_DEREF(op1); ZVAL_DEREF(op2); @@ -1019,7 +1019,7 @@ static zend_never_inline int ZEND_FASTCALL add_function_slow(zval *result, zval return FAILURE; } /* }}} */ -ZEND_API int ZEND_FASTCALL add_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL add_function(zval *result, zval *op1, zval *op2) /* {{{ */ { if (add_function_fast(result, op1, op2) == SUCCESS) { return SUCCESS; @@ -1029,7 +1029,7 @@ ZEND_API int ZEND_FASTCALL add_function(zval *result, zval *op1, zval *op2) /* { } /* }}} */ -static zend_always_inline int sub_function_fast(zval *result, zval *op1, zval *op2) /* {{{ */ +static zend_always_inline ZEND_RESULT_CODE sub_function_fast(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_uchar type_pair = TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2)); @@ -1051,7 +1051,7 @@ static zend_always_inline int sub_function_fast(zval *result, zval *op1, zval *o } /* }}} */ -static zend_never_inline int ZEND_FASTCALL sub_function_slow(zval *result, zval *op1, zval *op2) /* {{{ */ +static zend_never_inline ZEND_RESULT_CODE ZEND_FASTCALL sub_function_slow(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_DEREF(op1); ZVAL_DEREF(op2); @@ -1084,7 +1084,7 @@ static zend_never_inline int ZEND_FASTCALL sub_function_slow(zval *result, zval } /* }}} */ -ZEND_API int ZEND_FASTCALL sub_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL sub_function(zval *result, zval *op1, zval *op2) /* {{{ */ { if (sub_function_fast(result, op1, op2) == SUCCESS) { return SUCCESS; @@ -1094,7 +1094,7 @@ ZEND_API int ZEND_FASTCALL sub_function(zval *result, zval *op1, zval *op2) /* { } /* }}} */ -static zend_always_inline int mul_function_fast(zval *result, zval *op1, zval *op2) /* {{{ */ +static zend_always_inline ZEND_RESULT_CODE mul_function_fast(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_uchar type_pair = TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2)); @@ -1120,7 +1120,7 @@ static zend_always_inline int mul_function_fast(zval *result, zval *op1, zval *o } /* }}} */ -static zend_never_inline int ZEND_FASTCALL mul_function_slow(zval *result, zval *op1, zval *op2) /* {{{ */ +static zend_never_inline ZEND_RESULT_CODE ZEND_FASTCALL mul_function_slow(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_DEREF(op1); ZVAL_DEREF(op2); @@ -1153,7 +1153,7 @@ static zend_never_inline int ZEND_FASTCALL mul_function_slow(zval *result, zval } /* }}} */ -ZEND_API int ZEND_FASTCALL mul_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL mul_function(zval *result, zval *op1, zval *op2) /* {{{ */ { if (mul_function_fast(result, op1, op2) == SUCCESS) { return SUCCESS; @@ -1163,7 +1163,7 @@ ZEND_API int ZEND_FASTCALL mul_function(zval *result, zval *op1, zval *op2) /* { } /* }}} */ -static int ZEND_FASTCALL pow_function_base(zval *result, zval *op1, zval *op2) /* {{{ */ +static ZEND_RESULT_CODE ZEND_FASTCALL pow_function_base(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_uchar type_pair = TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2)); @@ -1220,7 +1220,7 @@ static int ZEND_FASTCALL pow_function_base(zval *result, zval *op1, zval *op2) / } /* }}} */ -ZEND_API int ZEND_FASTCALL pow_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL pow_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_DEREF(op1); ZVAL_DEREF(op2); @@ -1256,7 +1256,7 @@ ZEND_API int ZEND_FASTCALL pow_function(zval *result, zval *op1, zval *op2) /* { #ifdef __clang__ __attribute__((no_sanitize("float-divide-by-zero"))) #endif -static int ZEND_FASTCALL div_function_base(zval *result, zval *op1, zval *op2) /* {{{ */ +static ZEND_RESULT_CODE ZEND_FASTCALL div_function_base(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_uchar type_pair = TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2)); @@ -1300,7 +1300,7 @@ static int ZEND_FASTCALL div_function_base(zval *result, zval *op1, zval *op2) / } /* }}} */ -ZEND_API int ZEND_FASTCALL div_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL div_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_DEREF(op1); ZVAL_DEREF(op2); @@ -1333,7 +1333,7 @@ ZEND_API int ZEND_FASTCALL div_function(zval *result, zval *op1, zval *op2) /* { } /* }}} */ -ZEND_API int ZEND_FASTCALL mod_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL mod_function(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_long op1_lval, op2_lval; @@ -1367,7 +1367,7 @@ ZEND_API int ZEND_FASTCALL mod_function(zval *result, zval *op1, zval *op2) /* { } /* }}} */ -ZEND_API int ZEND_FASTCALL boolean_xor_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL boolean_xor_function(zval *result, zval *op1, zval *op2) /* {{{ */ { int op1_val, op2_val; @@ -1417,7 +1417,7 @@ ZEND_API int ZEND_FASTCALL boolean_xor_function(zval *result, zval *op1, zval *o } /* }}} */ -ZEND_API int ZEND_FASTCALL boolean_not_function(zval *result, zval *op1) /* {{{ */ +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL boolean_not_function(zval *result, zval *op1) /* {{{ */ { if (Z_TYPE_P(op1) < IS_TRUE) { ZVAL_TRUE(result); @@ -1442,7 +1442,7 @@ ZEND_API int ZEND_FASTCALL boolean_not_function(zval *result, zval *op1) /* {{{ } /* }}} */ -ZEND_API int ZEND_FASTCALL bitwise_not_function(zval *result, zval *op1) /* {{{ */ +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL bitwise_not_function(zval *result, zval *op1) /* {{{ */ { try_again: switch (Z_TYPE_P(op1)) { @@ -1482,7 +1482,7 @@ ZEND_API int ZEND_FASTCALL bitwise_not_function(zval *result, zval *op1) /* {{{ } /* }}} */ -ZEND_API int ZEND_FASTCALL bitwise_or_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL bitwise_or_function(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_long op1_lval, op2_lval; @@ -1564,7 +1564,7 @@ ZEND_API int ZEND_FASTCALL bitwise_or_function(zval *result, zval *op1, zval *op } /* }}} */ -ZEND_API int ZEND_FASTCALL bitwise_and_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL bitwise_and_function(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_long op1_lval, op2_lval; @@ -1646,7 +1646,7 @@ ZEND_API int ZEND_FASTCALL bitwise_and_function(zval *result, zval *op1, zval *o } /* }}} */ -ZEND_API int ZEND_FASTCALL bitwise_xor_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL bitwise_xor_function(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_long op1_lval, op2_lval; @@ -1728,7 +1728,7 @@ ZEND_API int ZEND_FASTCALL bitwise_xor_function(zval *result, zval *op1, zval *o } /* }}} */ -ZEND_API int ZEND_FASTCALL shift_left_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL shift_left_function(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_long op1_lval, op2_lval; @@ -1765,7 +1765,7 @@ ZEND_API int ZEND_FASTCALL shift_left_function(zval *result, zval *op1, zval *op } /* }}} */ -ZEND_API int ZEND_FASTCALL shift_right_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL shift_right_function(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_long op1_lval, op2_lval; @@ -1801,7 +1801,7 @@ ZEND_API int ZEND_FASTCALL shift_right_function(zval *result, zval *op1, zval *o } /* }}} */ -ZEND_API int ZEND_FASTCALL concat_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL concat_function(zval *result, zval *op1, zval *op2) /* {{{ */ { zval *orig_op1 = op1; zval op1_copy, op2_copy; @@ -1992,7 +1992,7 @@ ZEND_API int ZEND_FASTCALL numeric_compare_function(zval *op1, zval *op2) /* {{{ } /* }}} */ -ZEND_API int ZEND_FASTCALL compare_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL compare_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_LONG(result, zend_compare(op1, op2)); return SUCCESS; @@ -2175,6 +2175,7 @@ ZEND_API int ZEND_FASTCALL zend_compare(zval *op1, zval *op2) /* {{{ */ } /* }}} */ +/* return int to be compatible with compare_func_t */ static int hash_zval_identical_function(zval *z1, zval *z2) /* {{{ */ { /* is_identical_function() returns 1 in case of identity and 0 in case @@ -2217,42 +2218,42 @@ ZEND_API zend_bool ZEND_FASTCALL zend_is_identical(zval *op1, zval *op2) /* {{{ } /* }}} */ -ZEND_API int ZEND_FASTCALL is_identical_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL is_identical_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_BOOL(result, zend_is_identical(op1, op2)); return SUCCESS; } /* }}} */ -ZEND_API int ZEND_FASTCALL is_not_identical_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL is_not_identical_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_BOOL(result, !zend_is_identical(op1, op2)); return SUCCESS; } /* }}} */ -ZEND_API int ZEND_FASTCALL is_equal_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL is_equal_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_BOOL(result, zend_compare(op1, op2) == 0); return SUCCESS; } /* }}} */ -ZEND_API int ZEND_FASTCALL is_not_equal_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL is_not_equal_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_BOOL(result, (zend_compare(op1, op2) != 0)); return SUCCESS; } /* }}} */ -ZEND_API int ZEND_FASTCALL is_smaller_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL is_smaller_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_BOOL(result, (zend_compare(op1, op2) < 0)); return SUCCESS; } /* }}} */ -ZEND_API int ZEND_FASTCALL is_smaller_or_equal_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL is_smaller_or_equal_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_BOOL(result, (zend_compare(op1, op2) <= 0)); return SUCCESS; @@ -2395,7 +2396,7 @@ static void ZEND_FASTCALL increment_string(zval *str) /* {{{ */ } /* }}} */ -ZEND_API int ZEND_FASTCALL increment_function(zval *op1) /* {{{ */ +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL increment_function(zval *op1) /* {{{ */ { try_again: switch (Z_TYPE_P(op1)) { @@ -2460,7 +2461,7 @@ ZEND_API int ZEND_FASTCALL increment_function(zval *op1) /* {{{ */ } /* }}} */ -ZEND_API int ZEND_FASTCALL decrement_function(zval *op1) /* {{{ */ +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL decrement_function(zval *op1) /* {{{ */ { zend_long lval; double dval; @@ -2523,13 +2524,13 @@ ZEND_API int ZEND_FASTCALL decrement_function(zval *op1) /* {{{ */ } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_is_true(zval *op) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_is_true(zval *op) /* {{{ */ { return i_zend_is_true(op); } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_object_is_true(zval *op) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_object_is_true(zval *op) /* {{{ */ { zend_object *zobj = Z_OBJ_P(op); zval tmp; @@ -2621,7 +2622,7 @@ ZEND_API char* ZEND_FASTCALL zend_str_tolower_dup_ex(const char *source, size_t } /* }}} */ -ZEND_API zend_string* ZEND_FASTCALL zend_string_tolower_ex(zend_string *str, int persistent) /* {{{ */ +ZEND_API zend_string* ZEND_FASTCALL zend_string_tolower_ex(zend_string *str, bool persistent) /* {{{ */ { size_t length = ZSTR_LEN(str); unsigned char *p = (unsigned char *) ZSTR_VAL(str); @@ -2817,9 +2818,9 @@ ZEND_API int ZEND_FASTCALL zend_binary_zval_strncasecmp(zval *s1, zval *s2, zval } /* }}} */ -ZEND_API int ZEND_FASTCALL zendi_smart_streq(zend_string *s1, zend_string *s2) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zendi_smart_streq(zend_string *s1, zend_string *s2) /* {{{ */ { - int ret1, ret2; + zend_uchar ret1, ret2; int oflow1, oflow2; zend_long lval1 = 0, lval2 = 0; double dval1 = 0.0, dval2 = 0.0; @@ -2867,7 +2868,7 @@ ZEND_API int ZEND_FASTCALL zendi_smart_streq(zend_string *s1, zend_string *s2) / ZEND_API int ZEND_FASTCALL zendi_smart_strcmp(zend_string *s1, zend_string *s2) /* {{{ */ { - int ret1, ret2; + zend_uchar ret1, ret2; int oflow1, oflow2; zend_long lval1 = 0, lval2 = 0; double dval1 = 0.0, dval2 = 0.0; diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 9eb064b125d7a..76d0749703ee0 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -38,30 +38,30 @@ #define LONG_SIGN_MASK ZEND_LONG_MIN BEGIN_EXTERN_C() -ZEND_API int ZEND_FASTCALL add_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL sub_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL mul_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL pow_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL div_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL mod_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL boolean_xor_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL boolean_not_function(zval *result, zval *op1); -ZEND_API int ZEND_FASTCALL bitwise_not_function(zval *result, zval *op1); -ZEND_API int ZEND_FASTCALL bitwise_or_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL bitwise_and_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL bitwise_xor_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL shift_left_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL shift_right_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL concat_function(zval *result, zval *op1, zval *op2); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL add_function(zval *result, zval *op1, zval *op2); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL sub_function(zval *result, zval *op1, zval *op2); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL mul_function(zval *result, zval *op1, zval *op2); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL pow_function(zval *result, zval *op1, zval *op2); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL div_function(zval *result, zval *op1, zval *op2); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL mod_function(zval *result, zval *op1, zval *op2); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL boolean_xor_function(zval *result, zval *op1, zval *op2); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL boolean_not_function(zval *result, zval *op1); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL bitwise_not_function(zval *result, zval *op1); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL bitwise_or_function(zval *result, zval *op1, zval *op2); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL bitwise_and_function(zval *result, zval *op1, zval *op2); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL bitwise_xor_function(zval *result, zval *op1, zval *op2); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL shift_left_function(zval *result, zval *op1, zval *op2); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL shift_right_function(zval *result, zval *op1, zval *op2); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL concat_function(zval *result, zval *op1, zval *op2); ZEND_API zend_bool ZEND_FASTCALL zend_is_identical(zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL is_equal_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL is_identical_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL is_not_identical_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL is_not_equal_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL is_smaller_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL is_smaller_or_equal_function(zval *result, zval *op1, zval *op2); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL is_equal_function(zval *result, zval *op1, zval *op2); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL is_identical_function(zval *result, zval *op1, zval *op2); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL is_not_identical_function(zval *result, zval *op1, zval *op2); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL is_not_equal_function(zval *result, zval *op1, zval *op2); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL is_smaller_function(zval *result, zval *op1, zval *op2); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL is_smaller_or_equal_function(zval *result, zval *op1, zval *op2); ZEND_API zend_bool ZEND_FASTCALL zend_class_implements_interface(const zend_class_entry *class_ce, const zend_class_entry *interface_ce); ZEND_API zend_bool ZEND_FASTCALL instanceof_function_slow(const zend_class_entry *instance_ce, const zend_class_entry *ce); @@ -255,8 +255,8 @@ zend_memnrstr(const char *haystack, const char *needle, size_t needle_len, const } } -ZEND_API int ZEND_FASTCALL increment_function(zval *op1); -ZEND_API int ZEND_FASTCALL decrement_function(zval *op2); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL increment_function(zval *op1); +ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL decrement_function(zval *op2); ZEND_API void ZEND_FASTCALL convert_scalar_to_number(zval *op); ZEND_API void ZEND_FASTCALL _convert_to_string(zval *op); @@ -341,15 +341,15 @@ static zend_always_inline zend_bool try_convert_to_string(zval *op) { #define convert_to_string(op) if (Z_TYPE_P(op) != IS_STRING) { _convert_to_string((op)); } -ZEND_API int ZEND_FASTCALL zend_is_true(zval *op); -ZEND_API int ZEND_FASTCALL zend_object_is_true(zval *op); +ZEND_API bool ZEND_FASTCALL zend_is_true(zval *op); +ZEND_API bool ZEND_FASTCALL zend_object_is_true(zval *op); #define zval_is_true(op) \ zend_is_true(op) -static zend_always_inline int i_zend_is_true(zval *op) +static zend_always_inline bool i_zend_is_true(zval *op) { - int result = 0; + bool result = 0; again: switch (Z_TYPE_P(op)) { @@ -418,7 +418,7 @@ ZEND_API void ZEND_FASTCALL zend_str_tolower(char *str, size_t length); ZEND_API char* ZEND_FASTCALL zend_str_tolower_copy(char *dest, const char *source, size_t length); ZEND_API char* ZEND_FASTCALL zend_str_tolower_dup(const char *source, size_t length); ZEND_API char* ZEND_FASTCALL zend_str_tolower_dup_ex(const char *source, size_t length); -ZEND_API zend_string* ZEND_FASTCALL zend_string_tolower_ex(zend_string *str, int persistent); +ZEND_API zend_string* ZEND_FASTCALL zend_string_tolower_ex(zend_string *str, bool persistent); #define zend_string_tolower(str) zend_string_tolower_ex(str, 0) @@ -433,7 +433,7 @@ ZEND_API int ZEND_FASTCALL zend_binary_strncasecmp(const char *s1, size_t len1, ZEND_API int ZEND_FASTCALL zend_binary_strcasecmp_l(const char *s1, size_t len1, const char *s2, size_t len2); ZEND_API int ZEND_FASTCALL zend_binary_strncasecmp_l(const char *s1, size_t len1, const char *s2, size_t len2, size_t length); -ZEND_API int ZEND_FASTCALL zendi_smart_streq(zend_string *s1, zend_string *s2); +ZEND_API bool ZEND_FASTCALL zendi_smart_streq(zend_string *s1, zend_string *s2); ZEND_API int ZEND_FASTCALL zendi_smart_strcmp(zend_string *s1, zend_string *s2); ZEND_API int ZEND_FASTCALL zend_compare_symbol_tables(HashTable *ht1, HashTable *ht2); ZEND_API int ZEND_FASTCALL zend_compare_arrays(zval *a1, zval *a2); @@ -738,7 +738,7 @@ overflow: ZEND_ATTRIBUTE_COLD_LABEL #endif } -static zend_always_inline int fast_add_function(zval *result, zval *op1, zval *op2) +static zend_always_inline ZEND_RESULT_CODE fast_add_function(zval *result, zval *op1, zval *op2) { if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { @@ -842,12 +842,12 @@ overflow: ZEND_ATTRIBUTE_COLD_LABEL #endif } -static zend_always_inline int fast_div_function(zval *result, zval *op1, zval *op2) +static zend_always_inline ZEND_RESULT_CODE fast_div_function(zval *result, zval *op1, zval *op2) { return div_function(result, op1, op2); } -static zend_always_inline int zend_fast_equal_strings(zend_string *s1, zend_string *s2) +static zend_always_inline bool zend_fast_equal_strings(zend_string *s1, zend_string *s2) { if (s1 == s2) { return 1; @@ -858,7 +858,7 @@ static zend_always_inline int zend_fast_equal_strings(zend_string *s1, zend_stri } } -static zend_always_inline int fast_equal_check_function(zval *op1, zval *op2) +static zend_always_inline bool fast_equal_check_function(zval *op1, zval *op2) { if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { @@ -880,7 +880,7 @@ static zend_always_inline int fast_equal_check_function(zval *op1, zval *op2) return zend_compare(op1, op2) == 0; } -static zend_always_inline int fast_equal_check_long(zval *op1, zval *op2) +static zend_always_inline bool fast_equal_check_long(zval *op1, zval *op2) { if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { return Z_LVAL_P(op1) == Z_LVAL_P(op2); @@ -888,7 +888,7 @@ static zend_always_inline int fast_equal_check_long(zval *op1, zval *op2) return zend_compare(op1, op2) == 0; } -static zend_always_inline int fast_equal_check_string(zval *op1, zval *op2) +static zend_always_inline bool fast_equal_check_string(zval *op1, zval *op2) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { return zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); From 3a6fc73880aec11301f725d6dcf23de9a1133bea Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 04:13:14 +0200 Subject: [PATCH 143/170] Boolify zend_signal.c --- Zend/zend_signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_signal.c b/Zend/zend_signal.c index 2086f03dd881c..75cc994f69dd2 100644 --- a/Zend/zend_signal.c +++ b/Zend/zend_signal.c @@ -283,7 +283,7 @@ ZEND_API int zend_signal(int signo, void (*handler)(int)) * Set a handler for a signal we want to defer. * Previously set handler must have been saved before. */ -static int zend_signal_register(int signo, void (*handler)(int, siginfo_t*, void*)) +static ZEND_RESULT_CODE zend_signal_register(int signo, void (*handler)(int, siginfo_t*, void*)) { struct sigaction sa; From 9fdb0dcc822a5412cd8e13c888cfdeaea40c20e3 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 04:14:06 +0200 Subject: [PATCH 144/170] Voidify zend_signal.c --- Zend/zend_signal.c | 8 +++----- Zend/zend_signal.h | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Zend/zend_signal.c b/Zend/zend_signal.c index 75cc994f69dd2..79043b199ea60 100644 --- a/Zend/zend_signal.c +++ b/Zend/zend_signal.c @@ -223,7 +223,7 @@ static void zend_signal_handler(int signo, siginfo_t *siginfo, void *context) /* {{{ zend_sigaction * Register a signal handler that will be deferred in critical sections */ -ZEND_API int zend_sigaction(int signo, const struct sigaction *act, struct sigaction *oldact) +ZEND_API void zend_sigaction(int signo, const struct sigaction *act, struct sigaction *oldact) { struct sigaction sa; sigset_t sigset; @@ -259,14 +259,12 @@ ZEND_API int zend_sigaction(int signo, const struct sigaction *act, struct sigac sigaddset(&sigset, signo); zend_sigprocmask(SIG_UNBLOCK, &sigset, NULL); } - - return SUCCESS; } /* }}} */ /* {{{ zend_signal * Register a signal handler that will be deferred in critical sections */ -ZEND_API int zend_signal(int signo, void (*handler)(int)) +ZEND_API void zend_signal(int signo, void (*handler)(int)) { struct sigaction sa; @@ -275,7 +273,7 @@ ZEND_API int zend_signal(int signo, void (*handler)(int)) sa.sa_handler = handler; sa.sa_mask = global_sigmask; - return zend_sigaction(signo, &sa, NULL); + zend_sigaction(signo, &sa, NULL); } /* }}} */ diff --git a/Zend/zend_signal.h b/Zend/zend_signal.h index 0bb191db73245..08c9de20c76c3 100644 --- a/Zend/zend_signal.h +++ b/Zend/zend_signal.h @@ -91,8 +91,8 @@ ZEND_API void zend_signal_startup(void); END_EXTERN_C() void zend_signal_init(void); -ZEND_API int zend_signal(int signo, void (*handler)(int)); -ZEND_API int zend_sigaction(int signo, const struct sigaction *act, struct sigaction *oldact); +ZEND_API void zend_signal(int signo, void (*handler)(int)); +ZEND_API void zend_sigaction(int signo, const struct sigaction *act, struct sigaction *oldact); #else /* ZEND_SIGNALS */ From d476a97a077eec47d2cde7e50f43ecb1b0d413a9 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 04:27:05 +0200 Subject: [PATCH 145/170] Fix PCNTL Code due to zend_sigaction() voidification --- ext/pcntl/php_signal.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ext/pcntl/php_signal.c b/ext/pcntl/php_signal.c index 95b4a16d6df9e..d618800480827 100644 --- a/ext/pcntl/php_signal.c +++ b/ext/pcntl/php_signal.c @@ -48,9 +48,7 @@ Sigfunc *php_signal4(int signo, Sigfunc *func, int restart, int mask_all) act.sa_flags |= SA_RESTART; /* SVR4, 4.3+BSD */ #endif } - if (zend_sigaction(signo, &act, &oact) < 0) { - return (void*)SIG_ERR; - } + zend_sigaction(signo, &act, &oact); #ifdef HAVE_STRUCT_SIGINFO_T return oact.sa_sigaction; From 22e5f71382011856dbea948ec51cb904685d6f88 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 04:22:30 +0200 Subject: [PATCH 146/170] Voidify zend_stack.c --- Zend/zend_stack.c | 12 ++++-------- Zend/zend_stack.h | 8 ++++---- ext/mysqlnd/mysqlnd_debug.c | 3 ++- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Zend/zend_stack.c b/Zend/zend_stack.c index 51f68b5c9a2c9..1255c941a03d6 100644 --- a/Zend/zend_stack.c +++ b/Zend/zend_stack.c @@ -22,13 +22,12 @@ #define ZEND_STACK_ELEMENT(stack, n) ((void *)((char *) (stack)->elements + (stack)->size * (n))) -ZEND_API int zend_stack_init(zend_stack *stack, int size) +ZEND_API void zend_stack_init(zend_stack *stack, int size) { stack->size = size; stack->top = 0; stack->max = 0; stack->elements = NULL; - return SUCCESS; } ZEND_API int zend_stack_push(zend_stack *stack, const void *element) @@ -53,10 +52,9 @@ ZEND_API void *zend_stack_top(const zend_stack *stack) } -ZEND_API int zend_stack_del_top(zend_stack *stack) +ZEND_API void zend_stack_del_top(zend_stack *stack) { --stack->top; - return SUCCESS; } @@ -71,20 +69,18 @@ ZEND_API int zend_stack_int_top(const zend_stack *stack) } -ZEND_API int zend_stack_is_empty(const zend_stack *stack) +ZEND_API bool zend_stack_is_empty(const zend_stack *stack) { return stack->top == 0; } -ZEND_API int zend_stack_destroy(zend_stack *stack) +ZEND_API void zend_stack_destroy(zend_stack *stack) { if (stack->elements) { efree(stack->elements); stack->elements = NULL; } - - return SUCCESS; } diff --git a/Zend/zend_stack.h b/Zend/zend_stack.h index 912850a25e4c6..a5aa9622268b2 100644 --- a/Zend/zend_stack.h +++ b/Zend/zend_stack.h @@ -29,13 +29,13 @@ typedef struct _zend_stack { #define STACK_BLOCK_SIZE 16 BEGIN_EXTERN_C() -ZEND_API int zend_stack_init(zend_stack *stack, int size); +ZEND_API void zend_stack_init(zend_stack *stack, int size); ZEND_API int zend_stack_push(zend_stack *stack, const void *element); ZEND_API void *zend_stack_top(const zend_stack *stack); -ZEND_API int zend_stack_del_top(zend_stack *stack); +ZEND_API void zend_stack_del_top(zend_stack *stack); ZEND_API int zend_stack_int_top(const zend_stack *stack); -ZEND_API int zend_stack_is_empty(const zend_stack *stack); -ZEND_API int zend_stack_destroy(zend_stack *stack); +ZEND_API bool zend_stack_is_empty(const zend_stack *stack); +ZEND_API void zend_stack_destroy(zend_stack *stack); ZEND_API void *zend_stack_base(const zend_stack *stack); ZEND_API int zend_stack_count(const zend_stack *stack); ZEND_API void zend_stack_apply(zend_stack *stack, int type, int (*apply_function)(void *element)); diff --git a/ext/mysqlnd/mysqlnd_debug.c b/ext/mysqlnd/mysqlnd_debug.c index ec698a265dcf7..ab02d5645a7f9 100644 --- a/ext/mysqlnd/mysqlnd_debug.c +++ b/ext/mysqlnd/mysqlnd_debug.c @@ -412,7 +412,8 @@ MYSQLND_METHOD(mysqlnd_debug, func_leave)(MYSQLND_DEBUG * self, unsigned int lin #endif } - return zend_stack_del_top(&self->call_stack) == SUCCESS? PASS:FAIL; + zend_stack_del_top(&self->call_stack); + return PASS; } /* }}} */ From efdf2d1db9f8bc4812794d5931e920afc764fece Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 04:24:52 +0200 Subject: [PATCH 147/170] Boolify zend_stream.c --- Zend/zend_stream.c | 6 +++--- Zend/zend_stream.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Zend/zend_stream.c b/Zend/zend_stream.c index 38b145736bea2..87d90a7b9869c 100644 --- a/Zend/zend_stream.c +++ b/Zend/zend_stream.c @@ -73,7 +73,7 @@ ZEND_API void zend_stream_init_filename(zend_file_handle *handle, const char *fi handle->filename = filename; } -ZEND_API int zend_stream_open(const char *filename, zend_file_handle *handle) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_stream_open(const char *filename, zend_file_handle *handle) /* {{{ */ { zend_string *opened_path; if (zend_stream_open_function) { @@ -113,7 +113,7 @@ static ssize_t zend_stream_read(zend_file_handle *file_handle, char *buf, size_t return file_handle->handle.stream.reader(file_handle->handle.stream.handle, buf, len); } /* }}} */ -ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t *len) /* {{{ */ +ZEND_API ZEND_RESULT_CODE zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t *len) /* {{{ */ { size_t file_size; @@ -232,7 +232,7 @@ ZEND_API void zend_file_handle_dtor(zend_file_handle *fh) /* {{{ */ } /* }}} */ -ZEND_API int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2) /* {{{ */ +ZEND_API bool zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2) /* {{{ */ { if (fh1->type != fh2->type) { return 0; diff --git a/Zend/zend_stream.h b/Zend/zend_stream.h index 51651add38278..3f7df9d4e2ba9 100644 --- a/Zend/zend_stream.h +++ b/Zend/zend_stream.h @@ -66,10 +66,10 @@ typedef struct _zend_file_handle { BEGIN_EXTERN_C() ZEND_API void zend_stream_init_fp(zend_file_handle *handle, FILE *fp, const char *filename); ZEND_API void zend_stream_init_filename(zend_file_handle *handle, const char *filename); -ZEND_API int zend_stream_open(const char *filename, zend_file_handle *handle); -ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t *len); +ZEND_API ZEND_RESULT_CODE zend_stream_open(const char *filename, zend_file_handle *handle); +ZEND_API ZEND_RESULT_CODE zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t *len); ZEND_API void zend_file_handle_dtor(zend_file_handle *fh); -ZEND_API int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2); +ZEND_API bool zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2); END_EXTERN_C() #ifdef ZEND_WIN32 From 14e6f25cedb87a67ee69be29bd24615ecfbd3d91 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 04:28:37 +0200 Subject: [PATCH 148/170] Boolify zend_string.c --- Zend/zend_string.c | 10 +++++----- Zend/zend_string.h | 20 ++++++++++---------- ext/opcache/ZendAccelerator.c | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Zend/zend_string.c b/Zend/zend_string.c index 7eae674f08a21..570aeece61e22 100644 --- a/Zend/zend_string.c +++ b/Zend/zend_string.c @@ -28,8 +28,8 @@ ZEND_API zend_string_init_interned_func_t zend_string_init_interned; static zend_string* ZEND_FASTCALL zend_new_interned_string_permanent(zend_string *str); static zend_string* ZEND_FASTCALL zend_new_interned_string_request(zend_string *str); -static zend_string* ZEND_FASTCALL zend_string_init_interned_permanent(const char *str, size_t size, int permanent); -static zend_string* ZEND_FASTCALL zend_string_init_interned_request(const char *str, size_t size, int permanent); +static zend_string* ZEND_FASTCALL zend_string_init_interned_permanent(const char *str, size_t size, bool permanent); +static zend_string* ZEND_FASTCALL zend_string_init_interned_request(const char *str, size_t size, bool permanent); /* Any strings interned in the startup phase. Common to all the threads, won't be free'd until process exit. If we want an ability to @@ -67,7 +67,7 @@ ZEND_KNOWN_STRINGS(_ZEND_STR_DSC) NULL }; -static zend_always_inline void zend_init_interned_strings_ht(HashTable *interned_strings, int permanent) +static zend_always_inline void zend_init_interned_strings_ht(HashTable *interned_strings, bool permanent) { zend_hash_init(interned_strings, 1024, NULL, _str_dtor, permanent); if (permanent) { @@ -251,7 +251,7 @@ static zend_string* ZEND_FASTCALL zend_new_interned_string_request(zend_string * return ret; } -static zend_string* ZEND_FASTCALL zend_string_init_interned_permanent(const char *str, size_t size, int permanent) +static zend_string* ZEND_FASTCALL zend_string_init_interned_permanent(const char *str, size_t size, bool permanent) { zend_string *ret; zend_ulong h = zend_inline_hash_func(str, size); @@ -267,7 +267,7 @@ static zend_string* ZEND_FASTCALL zend_string_init_interned_permanent(const char return zend_add_interned_string(ret, &interned_strings_permanent, IS_STR_PERMANENT); } -static zend_string* ZEND_FASTCALL zend_string_init_interned_request(const char *str, size_t size, int permanent) +static zend_string* ZEND_FASTCALL zend_string_init_interned_request(const char *str, size_t size, bool permanent) { zend_string *ret; zend_ulong h = zend_inline_hash_func(str, size); diff --git a/Zend/zend_string.h b/Zend/zend_string.h index 98bd735976487..316d022e647a7 100644 --- a/Zend/zend_string.h +++ b/Zend/zend_string.h @@ -25,7 +25,7 @@ BEGIN_EXTERN_C() typedef void (*zend_string_copy_storage_func_t)(void); typedef zend_string *(ZEND_FASTCALL *zend_new_interned_string_func_t)(zend_string *str); -typedef zend_string *(ZEND_FASTCALL *zend_string_init_interned_func_t)(const char *str, size_t size, int permanent); +typedef zend_string *(ZEND_FASTCALL *zend_string_init_interned_func_t)(const char *str, size_t size, bool permanent); ZEND_API extern zend_new_interned_string_func_t zend_new_interned_string; ZEND_API extern zend_string_init_interned_func_t zend_string_init_interned; @@ -136,7 +136,7 @@ static zend_always_inline uint32_t zend_string_delref(zend_string *s) return 1; } -static zend_always_inline zend_string *zend_string_alloc(size_t len, int persistent) +static zend_always_inline zend_string *zend_string_alloc(size_t len, bool persistent) { zend_string *ret = (zend_string *)pemalloc(ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(len)), persistent); @@ -147,7 +147,7 @@ static zend_always_inline zend_string *zend_string_alloc(size_t len, int persist return ret; } -static zend_always_inline zend_string *zend_string_safe_alloc(size_t n, size_t m, size_t l, int persistent) +static zend_always_inline zend_string *zend_string_safe_alloc(size_t n, size_t m, size_t l, bool persistent) { zend_string *ret = (zend_string *)safe_pemalloc(n, m, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(l)), persistent); @@ -158,7 +158,7 @@ static zend_always_inline zend_string *zend_string_safe_alloc(size_t n, size_t m return ret; } -static zend_always_inline zend_string *zend_string_init(const char *str, size_t len, int persistent) +static zend_always_inline zend_string *zend_string_init(const char *str, size_t len, bool persistent) { zend_string *ret = zend_string_alloc(len, persistent); @@ -186,7 +186,7 @@ static zend_always_inline zend_string *zend_string_copy(zend_string *s) return s; } -static zend_always_inline zend_string *zend_string_dup(zend_string *s, int persistent) +static zend_always_inline zend_string *zend_string_dup(zend_string *s, bool persistent) { if (ZSTR_IS_INTERNED(s)) { return s; @@ -195,7 +195,7 @@ static zend_always_inline zend_string *zend_string_dup(zend_string *s, int persi } } -static zend_always_inline zend_string *zend_string_realloc(zend_string *s, size_t len, int persistent) +static zend_always_inline zend_string *zend_string_realloc(zend_string *s, size_t len, bool persistent) { zend_string *ret; @@ -214,7 +214,7 @@ static zend_always_inline zend_string *zend_string_realloc(zend_string *s, size_ return ret; } -static zend_always_inline zend_string *zend_string_extend(zend_string *s, size_t len, int persistent) +static zend_always_inline zend_string *zend_string_extend(zend_string *s, size_t len, bool persistent) { zend_string *ret; @@ -234,7 +234,7 @@ static zend_always_inline zend_string *zend_string_extend(zend_string *s, size_t return ret; } -static zend_always_inline zend_string *zend_string_truncate(zend_string *s, size_t len, int persistent) +static zend_always_inline zend_string *zend_string_truncate(zend_string *s, size_t len, bool persistent) { zend_string *ret; @@ -254,7 +254,7 @@ static zend_always_inline zend_string *zend_string_truncate(zend_string *s, size return ret; } -static zend_always_inline zend_string *zend_string_safe_realloc(zend_string *s, size_t n, size_t m, size_t l, int persistent) +static zend_always_inline zend_string *zend_string_safe_realloc(zend_string *s, size_t n, size_t m, size_t l, bool persistent) { zend_string *ret; @@ -298,7 +298,7 @@ static zend_always_inline void zend_string_release(zend_string *s) } } -static zend_always_inline void zend_string_release_ex(zend_string *s, int persistent) +static zend_always_inline void zend_string_release_ex(zend_string *s, bool persistent) { if (!ZSTR_IS_INTERNED(s)) { if (GC_DELREF(s) == 0) { diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index bde6e0eb7138a..f532596f0f9a7 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -551,7 +551,7 @@ static zend_always_inline zend_string *accel_find_interned_string_ex(zend_ulong return NULL; } -static zend_string* ZEND_FASTCALL accel_init_interned_string_for_php(const char *str, size_t size, int permanent) +static zend_string* ZEND_FASTCALL accel_init_interned_string_for_php(const char *str, size_t size, bool permanent) { if (ZCG(counted)) { zend_ulong h = zend_inline_hash_func(str, size); From d81edcb1f8f428041f21e3a5fbd66a619a64bb56 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 03:56:32 +0200 Subject: [PATCH 149/170] Update FTP code after zend_list_close() voidification --- ext/ftp/php_ftp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/ftp/php_ftp.c b/ext/ftp/php_ftp.c index 2da4769aa5172..b27fbef0128c3 100644 --- a/ext/ftp/php_ftp.c +++ b/ext/ftp/php_ftp.c @@ -1235,7 +1235,7 @@ PHP_FUNCTION(ftp_close) ftp_quit(ftp); - RETURN_BOOL(zend_list_close(Z_RES_P(z_ftp)) == SUCCESS); + RETURN_TRUE; } /* }}} */ From 73e6f4d0fe45332ae54e4560bd3e45867548afaa Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 04:18:39 +0200 Subject: [PATCH 150/170] Fix streamfuncs.c due to zend_list_close() voidification --- ext/standard/streamsfuncs.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index 1c49b26ac7db1..eb450efe5444c 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -1245,13 +1245,9 @@ PHP_FUNCTION(stream_filter_remove) RETURN_FALSE; } - if (zend_list_close(Z_RES_P(zfilter)) == FAILURE) { - php_error_docref(NULL, E_WARNING, "Could not invalidate filter, not removing"); - RETURN_FALSE; - } else { - php_stream_filter_remove(filter, 1); - RETURN_TRUE; - } + zend_list_close(Z_RES_P(zfilter)); + php_stream_filter_remove(filter, 1); + RETURN_TRUE; } /* }}} */ From 6d9a6c781e349b1f139f0ae7a0d0bc89013870ea Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 04:54:01 +0200 Subject: [PATCH 151/170] Fix ZIP after zend_list_close() voidification --- ext/zip/php_zip.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 43c2da9af6660..c1a569afec4a7 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -1290,7 +1290,8 @@ PHP_FUNCTION(zip_entry_close) RETURN_THROWS(); } - RETURN_BOOL(SUCCESS == zend_list_close(Z_RES_P(zip_entry))); + zend_list_close(Z_RES_P(zip_entry)); + RETURN_TRUE; } /* }}} */ From f93e1056b2ba2fc0fdb435889fb8617f6e3fa9a0 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 16:14:01 +0200 Subject: [PATCH 152/170] Fix Tokenizer extension after voidification of zend_prepare_string_for_scanning() --- ext/tokenizer/tokenizer.c | 42 ++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/ext/tokenizer/tokenizer.c b/ext/tokenizer/tokenizer.c index 2656ce8f73940..d12b5edba8ded 100644 --- a/ext/tokenizer/tokenizer.c +++ b/ext/tokenizer/tokenizer.c @@ -358,10 +358,7 @@ static zend_bool tokenize(zval *return_value, zend_string *source, zend_class_en ZVAL_STR_COPY(&source_zval, source); zend_save_lexical_state(&original_lex_state); - if (zend_prepare_string_for_scanning(&source_zval, "") == FAILURE) { - zend_restore_lexical_state(&original_lex_state); - return 0; - } + zend_prepare_string_for_scanning(&source_zval, ""); LANG_SCNG(yy_state) = yycINITIAL; zend_hash_init(&interned_strings, 0, NULL, NULL, 0); @@ -484,6 +481,8 @@ static zend_bool tokenize_parse( zval *return_value, zend_string *source, zend_class_entry *token_class) { zval source_zval; + struct event_context ctx; + zval token_stream; zend_lex_state original_lex_state; zend_bool original_in_compilation; zend_bool success; @@ -494,30 +493,27 @@ static zend_bool tokenize_parse( CG(in_compilation) = 1; zend_save_lexical_state(&original_lex_state); - if ((success = (zend_prepare_string_for_scanning(&source_zval, "") == SUCCESS))) { - struct event_context ctx; - zval token_stream; - array_init(&token_stream); - - ctx.tokens = &token_stream; - ctx.token_class = token_class; + zend_prepare_string_for_scanning(&source_zval, ""); + array_init(&token_stream); - CG(ast) = NULL; - CG(ast_arena) = zend_arena_create(1024 * 32); - LANG_SCNG(yy_state) = yycINITIAL; - LANG_SCNG(on_event) = on_event; - LANG_SCNG(on_event_context) = &ctx; + ctx.tokens = &token_stream; + ctx.token_class = token_class; - if((success = (zendparse() == SUCCESS))) { - ZVAL_COPY_VALUE(return_value, &token_stream); - } else { - zval_ptr_dtor(&token_stream); - } + CG(ast) = NULL; + CG(ast_arena) = zend_arena_create(1024 * 32); + LANG_SCNG(yy_state) = yycINITIAL; + LANG_SCNG(on_event) = on_event; + LANG_SCNG(on_event_context) = &ctx; - zend_ast_destroy(CG(ast)); - zend_arena_destroy(CG(ast_arena)); + if((success = (zendparse() == SUCCESS))) { + ZVAL_COPY_VALUE(return_value, &token_stream); + } else { + zval_ptr_dtor(&token_stream); } + zend_ast_destroy(CG(ast)); + zend_arena_destroy(CG(ast_arena)); + /* restore compiler and scanner global states */ zend_restore_lexical_state(&original_lex_state); CG(in_compilation) = original_in_compilation; From f4e9196569ee93c23fd48b8c61d573563fa8a024 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 17:24:05 +0200 Subject: [PATCH 153/170] Fix PHP_FUNCTION(highlight_string) after voidification of highlight_string --- ext/standard/basic_functions.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 51a44a3ffb15b..30080bcc36c56 100755 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -1989,14 +1989,7 @@ PHP_FUNCTION(highlight_string) hicompiled_string_description = zend_make_compiled_string_description("highlighted code"); - if (highlight_string(expr, &syntax_highlighter_ini, hicompiled_string_description) == FAILURE) { - efree(hicompiled_string_description); - EG(error_reporting) = old_error_reporting; - if (i) { - php_output_end(); - } - RETURN_FALSE; - } + highlight_string(expr, &syntax_highlighter_ini, hicompiled_string_description); efree(hicompiled_string_description); EG(error_reporting) = old_error_reporting; @@ -2006,6 +1999,7 @@ PHP_FUNCTION(highlight_string) php_output_discard(); ZEND_ASSERT(Z_TYPE_P(return_value) == IS_STRING); } else { + // TODO Make this function void? RETURN_TRUE; } } From 36b9243833413af4e3d0cf7fd99093c4aeab69b8 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 19:48:36 +0200 Subject: [PATCH 154/170] Boolify zend_virtual_cwd.c --- Zend/zend_virtual_cwd.c | 14 +++++++++----- Zend/zend_virtual_cwd.h | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Zend/zend_virtual_cwd.c b/Zend/zend_virtual_cwd.c index 61542bfce200e..dab7fdca3b0d0 100644 --- a/Zend/zend_virtual_cwd.c +++ b/Zend/zend_virtual_cwd.c @@ -483,7 +483,7 @@ CWD_API realpath_cache_bucket** realpath_cache_get_buckets(void) #undef LINK_MAX #define LINK_MAX 32 -static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, time_t *t, int use_realpath, int is_dir, int *link_is_dir) /* {{{ */ +static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, time_t *t, int use_realpath, bool is_dir, int *link_is_dir) /* {{{ */ { size_t i, j; int directory = 0, save; @@ -996,7 +996,7 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, tim /* }}} */ /* Resolve path relatively to state and put the real path into state */ -/* returns 0 for ok, 1 for error */ +/* returns 0 for ok, 1 for error, -1 if (path_length >= MAXPATHLEN-1) */ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath) /* {{{ */ { size_t path_length = strlen(path); @@ -1005,7 +1005,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func int ll = 0; time_t t; int ret; - int add_slash; + bool add_slash; void *tmp; if (!path_length || path_length >= MAXPATHLEN-1) { @@ -1178,12 +1178,14 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func } /* }}} */ -CWD_API int virtual_chdir(const char *path) /* {{{ */ +CWD_API ZEND_RESULT_CODE virtual_chdir(const char *path) /* {{{ */ { - return virtual_file_ex(&CWDG(cwd), path, php_is_dir_ok, CWD_REALPATH)?-1:0; + return virtual_file_ex(&CWDG(cwd), path, php_is_dir_ok, CWD_REALPATH) ? FAILURE : SUCCESS; } /* }}} */ + +/* returns 0 for ok, 1 for empty string, -1 on error */ CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path)) /* {{{ */ { size_t length = strlen(path); @@ -1255,6 +1257,7 @@ CWD_API char *virtual_realpath(const char *path, char *real_path) /* {{{ */ } /* }}} */ +/* returns 0 for ok, 1 for error, -1 if (path_length >= MAXPATHLEN-1) */ CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_func verify_path) /* {{{ */ { cwd_state new_state; @@ -1270,6 +1273,7 @@ CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_f } /* }}} */ +/* returns 0 for ok, 1 for error, -1 if (path_length >= MAXPATHLEN-1) */ CWD_API int virtual_filepath(const char *path, char **filepath) /* {{{ */ { return virtual_filepath_ex(path, filepath, php_is_file_ok); diff --git a/Zend/zend_virtual_cwd.h b/Zend/zend_virtual_cwd.h index 84a1562c7789f..dfaa95932c3b6 100644 --- a/Zend/zend_virtual_cwd.h +++ b/Zend/zend_virtual_cwd.h @@ -189,6 +189,7 @@ CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group, int li /* One of the following constants must be used as the last argument in virtual_file_ex() call. */ +// TODO Make this into an enum #define CWD_EXPAND 0 /* expand "." and ".." but don't resolve symlinks */ #define CWD_FILEPATH 1 /* resolve symlinks if file is exist otherwise expand */ #define CWD_REALPATH 2 /* call realpath(), resolve symlinks. File must exist */ From bcfa1f901e3274a5f3552d8e5932bab7ec0d1f5c Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 20:13:46 +0200 Subject: [PATCH 155/170] Boolify zend_weakref.c --- Zend/zend_weakrefs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Zend/zend_weakrefs.c b/Zend/zend_weakrefs.c index 8a444c214e9e1..e9133c694c6fa 100644 --- a/Zend/zend_weakrefs.c +++ b/Zend/zend_weakrefs.c @@ -340,6 +340,7 @@ static void zend_weakmap_write_dimension(zend_object *object, zval *offset, zval zend_hash_index_add_new(&wm->ht, (zend_ulong) obj_key, value); } +/* int return and check_empty due to Object Handler API */ static int zend_weakmap_has_dimension(zend_object *object, zval *offset, int check_empty) { if (Z_TYPE_P(offset) != IS_OBJECT) { @@ -371,7 +372,7 @@ static void zend_weakmap_unset_dimension(zend_object *object, zval *offset) zend_weakref_unregister(obj_key, ZEND_WEAKREF_ENCODE(wm, ZEND_WEAKREF_TAG_MAP)); } -static int zend_weakmap_count_elements(zend_object *object, zend_long *count) +static ZEND_RESULT_CODE zend_weakmap_count_elements(zend_object *object, zend_long *count) { zend_weakmap *wm = zend_weakmap_from(object); *count = zend_hash_num_elements(&wm->ht); @@ -503,6 +504,7 @@ static const zend_object_iterator_funcs zend_weakmap_iterator_funcs = { NULL, /* get_gc */ }; +/* by_ref is int due to Iterator API */ static zend_object_iterator *zend_weakmap_get_iterator( zend_class_entry *ce, zval *object, int by_ref) { From 7f20490a80f9295694bf82b628ea88700e0e40e7 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 16 Aug 2020 20:06:18 +0200 Subject: [PATCH 156/170] Boolify zend_VM --- Zend/zend_vm_def.h | 32 +++--- Zend/zend_vm_execute.h | 216 ++++++++++++++++++++--------------------- 2 files changed, 124 insertions(+), 124 deletions(-) diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 4d72cf31ad7a9..9f735c5a4c8ed 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -549,7 +549,7 @@ ZEND_VM_C_LABEL(is_equal_double): } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (OP1_TYPE & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -629,7 +629,7 @@ ZEND_VM_C_LABEL(is_not_equal_double): } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (OP1_TYPE & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -2993,7 +2993,7 @@ ZEND_VM_COLD_CONST_HANDLER(46, ZEND_JMPZ_EX, CONST|TMPVAR|CV, JMP_ADDR) { USE_OPLINE zval *val; - int ret; + bool ret; val = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); @@ -3029,7 +3029,7 @@ ZEND_VM_COLD_CONST_HANDLER(47, ZEND_JMPNZ_EX, CONST|TMPVAR|CV, JMP_ADDR) { USE_OPLINE zval *val; - int ret; + bool ret; val = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); @@ -4982,7 +4982,7 @@ ZEND_VM_C_LABEL(send_again): // TODO: Speed this up using a flag that specifies whether there are any ref parameters. if ((OP1_TYPE & (IS_VAR|IS_CV)) && Z_REFCOUNT_P(args) > 1) { uint32_t tmp_arg_num = arg_num; - int separate = 0; + bool separate = 0; /* check if any of arguments are going to be passed by reference */ ZEND_HASH_FOREACH_STR_KEY_VAL(ht, name, arg) { @@ -5591,7 +5591,7 @@ ZEND_VM_C_LABEL(case_double): } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); FREE_OP2(); if (result) { ZEND_VM_C_GOTO(case_true); @@ -6950,7 +6950,7 @@ ZEND_VM_HOT_HANDLER(154, ZEND_ISSET_ISEMPTY_CV, CV, UNUSED, ISSET, SPEC(ISSET)) ZEND_VM_SMART_BRANCH_FALSE(); } } else { - int result; + bool result; SAVE_OPLINE(); result = !i_zend_is_true(value); @@ -7267,7 +7267,7 @@ ZEND_VM_COLD_CONST_HANDLER(152, ZEND_JMP_SET, CONST|TMP|VAR|CV, JMP_ADDR) USE_OPLINE zval *value; zval *ref = NULL; - int ret; + bool ret; SAVE_OPLINE(); value = GET_OP1_ZVAL_PTR(BP_VAR_R); @@ -9206,7 +9206,7 @@ ZEND_VM_HOT_TYPE_SPEC_HANDLER(ZEND_IS_EQUAL|ZEND_IS_IDENTICAL, (op1_info == MAY_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R); @@ -9218,7 +9218,7 @@ ZEND_VM_HOT_TYPE_SPEC_HANDLER(ZEND_IS_EQUAL|ZEND_IS_IDENTICAL, (op1_info == MAY_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R); @@ -9230,7 +9230,7 @@ ZEND_VM_HOT_TYPE_SPEC_HANDLER(ZEND_IS_NOT_EQUAL|ZEND_IS_NOT_IDENTICAL, (op1_info { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R); @@ -9242,7 +9242,7 @@ ZEND_VM_HOT_TYPE_SPEC_HANDLER(ZEND_IS_NOT_EQUAL|ZEND_IS_NOT_IDENTICAL, (op1_info { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R); @@ -9283,7 +9283,7 @@ ZEND_VM_HOT_TYPE_SPEC_HANDLER(ZEND_IS_SMALLER, (op1_info == MAY_BE_LONG && op2_i { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R); @@ -9295,7 +9295,7 @@ ZEND_VM_HOT_TYPE_SPEC_HANDLER(ZEND_IS_SMALLER, (op1_info == MAY_BE_DOUBLE && op2 { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R); @@ -9307,7 +9307,7 @@ ZEND_VM_HOT_TYPE_SPEC_HANDLER(ZEND_IS_SMALLER_OR_EQUAL, (op1_info == MAY_BE_LONG { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R); @@ -9319,7 +9319,7 @@ ZEND_VM_HOT_TYPE_SPEC_HANDLER(ZEND_IS_SMALLER_OR_EQUAL, (op1_info == MAY_BE_DOUB { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index a46b39d027a50..1e0bfabe381cd 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -1870,7 +1870,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_UNPACK_SPEC_HANDLER(ZEND_ // TODO: Speed this up using a flag that specifies whether there are any ref parameters. if ((opline->op1_type & (IS_VAR|IS_CV)) && Z_REFCOUNT_P(args) > 1) { uint32_t tmp_arg_num = arg_num; - int separate = 0; + bool separate = 0; /* check if any of arguments are going to be passed by reference */ ZEND_HASH_FOREACH_STR_KEY_VAL(ht, name, arg) { @@ -3554,7 +3554,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMPZ_EX_SPEC_CONS { USE_OPLINE zval *val; - int ret; + bool ret; val = RT_CONSTANT(opline, opline->op1); @@ -3590,7 +3590,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMPNZ_EX_SPEC_CON { USE_OPLINE zval *val; - int ret; + bool ret; val = RT_CONSTANT(opline, opline->op1); @@ -4300,7 +4300,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMP_SET_SPEC_CONS USE_OPLINE zval *value; zval *ref = NULL; - int ret; + bool ret; SAVE_OPLINE(); value = RT_CONSTANT(opline, opline->op1); @@ -5016,7 +5016,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CON } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CONST & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -5074,7 +5074,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CONST & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -7248,7 +7248,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_LONG_SPEC_CONST_TMP { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = RT_CONSTANT(opline, opline->op1); op2 = EX_VAR(opline->op2.var); @@ -7260,7 +7260,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_LONG_SP { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = RT_CONSTANT(opline, opline->op1); op2 = EX_VAR(opline->op2.var); @@ -7272,7 +7272,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_LONG_SP { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = RT_CONSTANT(opline, opline->op1); op2 = EX_VAR(opline->op2.var); @@ -7284,7 +7284,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_DOUBLE_SPEC_CONST_T { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = RT_CONSTANT(opline, opline->op1); op2 = EX_VAR(opline->op2.var); @@ -7296,7 +7296,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_DOUBLE_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = RT_CONSTANT(opline, opline->op1); op2 = EX_VAR(opline->op2.var); @@ -7308,7 +7308,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_DOUBLE_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = RT_CONSTANT(opline, opline->op1); op2 = EX_VAR(opline->op2.var); @@ -7320,7 +7320,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_LONG_SPEC_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = RT_CONSTANT(opline, opline->op1); op2 = EX_VAR(opline->op2.var); @@ -7332,7 +7332,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = RT_CONSTANT(opline, opline->op1); op2 = EX_VAR(opline->op2.var); @@ -7344,7 +7344,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = RT_CONSTANT(opline, opline->op1); op2 = EX_VAR(opline->op2.var); @@ -7356,7 +7356,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_DOUBLE_SPE { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = RT_CONSTANT(opline, opline->op1); op2 = EX_VAR(opline->op2.var); @@ -7368,7 +7368,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = RT_CONSTANT(opline, opline->op1); op2 = EX_VAR(opline->op2.var); @@ -7380,7 +7380,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = RT_CONSTANT(opline, opline->op1); op2 = EX_VAR(opline->op2.var); @@ -11951,7 +11951,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_LONG_SPEC_TMPVARCV_CO { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -11963,7 +11963,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_LONG_SPEC { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -11975,7 +11975,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_LONG_SPEC { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -11987,7 +11987,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_DOUBLE_SPEC_TMPVARCV_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -11999,7 +11999,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_DOUBLE_SP { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12011,7 +12011,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_DOUBLE_SP { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12023,7 +12023,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_LONG_SPEC_TMPVARC { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12035,7 +12035,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_LONG_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12047,7 +12047,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_LONG_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12059,7 +12059,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_DOUBLE_SPEC_TMPVA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12071,7 +12071,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_DOUBL { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12083,7 +12083,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_DOUBL { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12095,7 +12095,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_LONG_SPEC_TMPVARCV_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12107,7 +12107,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_LONG_SP { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12119,7 +12119,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_LONG_SP { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12131,7 +12131,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_DOUBLE_SPEC_TMPVARC { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12143,7 +12143,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_DOUBLE_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12155,7 +12155,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_DOUBLE_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12167,7 +12167,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_LONG_SPEC_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12179,7 +12179,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12191,7 +12191,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12203,7 +12203,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_DOUBLE_SPE { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12215,7 +12215,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12227,7 +12227,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12857,7 +12857,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_LONG_SPEC_TMPVARCV_TM { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12869,7 +12869,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_LONG_SPEC { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12881,7 +12881,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_LONG_SPEC { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12893,7 +12893,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_DOUBLE_SPEC_TMPVARCV_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12905,7 +12905,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_DOUBLE_SP { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12917,7 +12917,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_DOUBLE_SP { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12929,7 +12929,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_LONG_SPEC_TMPVARC { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12941,7 +12941,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_LONG_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12953,7 +12953,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_LONG_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12965,7 +12965,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_DOUBLE_SPEC_TMPVA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12977,7 +12977,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_DOUBL { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12989,7 +12989,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_DOUBL { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -13001,7 +13001,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_LONG_SPEC_TMPVARCV_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -13013,7 +13013,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_LONG_SP { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -13025,7 +13025,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_LONG_SP { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -13037,7 +13037,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_DOUBLE_SPEC_TMPVARC { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -13049,7 +13049,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_DOUBLE_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -13061,7 +13061,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_DOUBLE_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -13073,7 +13073,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_LONG_SPEC_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -13085,7 +13085,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -13097,7 +13097,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -13109,7 +13109,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_DOUBLE_SPE { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -13121,7 +13121,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -13133,7 +13133,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -13338,7 +13338,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMPZ_EX_SPEC_TMPVAR_HANDLER(ZE { USE_OPLINE zval *val; - int ret; + bool ret; val = _get_zval_ptr_var(opline->op1.var EXECUTE_DATA_CC); @@ -13374,7 +13374,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMPNZ_EX_SPEC_TMPVAR_HANDLER(Z { USE_OPLINE zval *val; - int ret; + bool ret; val = _get_zval_ptr_var(opline->op1.var EXECUTE_DATA_CC); @@ -14024,7 +14024,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_TMPVAR_CONST_HAN } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if ((IS_TMP_VAR|IS_VAR) & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -14082,7 +14082,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_TMPVAR_CONST_JMP } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if ((IS_TMP_VAR|IS_VAR) & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -14140,7 +14140,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_TMPVAR_CONST_JMP } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if ((IS_TMP_VAR|IS_VAR) & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -14198,7 +14198,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_TMPVAR_CONST } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if ((IS_TMP_VAR|IS_VAR) & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -14256,7 +14256,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_TMPVAR_CONST } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if ((IS_TMP_VAR|IS_VAR) & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -14314,7 +14314,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_TMPVAR_CONST } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if ((IS_TMP_VAR|IS_VAR) & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -14981,7 +14981,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CASE_SPEC_TMPVAR_CONST_HANDLER } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (result) { goto case_true; @@ -15444,7 +15444,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_TMPVAR_TMPVAR_HA } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if ((IS_TMP_VAR|IS_VAR) & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -15502,7 +15502,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_TMPVAR_TMPVAR_JM } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if ((IS_TMP_VAR|IS_VAR) & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -15560,7 +15560,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_TMPVAR_TMPVAR_JM } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if ((IS_TMP_VAR|IS_VAR) & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -15618,7 +15618,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_TMPVAR_TMPVA } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if ((IS_TMP_VAR|IS_VAR) & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -15676,7 +15676,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_TMPVAR_TMPVA } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if ((IS_TMP_VAR|IS_VAR) & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -15734,7 +15734,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_TMPVAR_TMPVA } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if ((IS_TMP_VAR|IS_VAR) & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -16373,7 +16373,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CASE_SPEC_TMPVAR_TMPVAR_HANDLE } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); zval_ptr_dtor_nogc(EX_VAR(opline->op2.var)); if (result) { goto case_true; @@ -17686,7 +17686,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CASE_SPEC_TMPVAR_CV_HANDLER(ZE } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (result) { goto case_true; @@ -18311,7 +18311,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMP_SET_SPEC_TMP_HANDLER(ZEND_ USE_OPLINE zval *value; zval *ref = NULL; - int ret; + bool ret; SAVE_OPLINE(); value = _get_zval_ptr_tmp(opline->op1.var EXECUTE_DATA_CC); @@ -21184,7 +21184,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMP_SET_SPEC_VAR_HANDLER(ZEND_ USE_OPLINE zval *value; zval *ref = NULL; - int ret; + bool ret; SAVE_OPLINE(); value = _get_zval_ptr_var(opline->op1.var EXECUTE_DATA_CC); @@ -36856,7 +36856,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMPZ_EX_SPEC_CV_HANDLER(ZEND_O { USE_OPLINE zval *val; - int ret; + bool ret; val = EX_VAR(opline->op1.var); @@ -36892,7 +36892,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMPNZ_EX_SPEC_CV_HANDLER(ZEND_ { USE_OPLINE zval *val; - int ret; + bool ret; val = EX_VAR(opline->op1.var); @@ -37551,7 +37551,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMP_SET_SPEC_CV_HANDLER(ZEND_O USE_OPLINE zval *value; zval *ref = NULL; - int ret; + bool ret; SAVE_OPLINE(); value = _get_zval_ptr_cv_BP_VAR_R(opline->op1.var EXECUTE_DATA_CC); @@ -38257,7 +38257,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CV_CONST_HANDLER } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -38315,7 +38315,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CV_CONST_JMPZ_HA } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -38373,7 +38373,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CV_CONST_JMPNZ_H } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -38431,7 +38431,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CV_CONST_HAN } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -38489,7 +38489,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CV_CONST_JMP } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -38547,7 +38547,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CV_CONST_JMP } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -41885,7 +41885,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CV_TMPVAR_HANDLE } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -41943,7 +41943,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CV_TMPVAR_JMPZ_H } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -42001,7 +42001,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CV_TMPVAR_JMPNZ_ } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -42059,7 +42059,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CV_TMPVAR_HA } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -42117,7 +42117,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CV_TMPVAR_JM } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -42175,7 +42175,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CV_TMPVAR_JM } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -46290,7 +46290,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_CV_S ZEND_VM_SMART_BRANCH_FALSE(); } } else { - int result; + bool result; SAVE_OPLINE(); result = !i_zend_is_true(value); @@ -46312,7 +46312,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_CV_S ZEND_VM_SMART_BRANCH_FALSE(); } } else { - int result; + bool result; SAVE_OPLINE(); result = !i_zend_is_true(value); @@ -46939,7 +46939,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CV_CV_HANDLER(ZE } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -46997,7 +46997,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CV_CV_JMPZ_HANDL } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -47055,7 +47055,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CV_CV_JMPNZ_HAND } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -47113,7 +47113,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CV_CV_HANDLE } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -47171,7 +47171,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CV_CV_JMPZ_H } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -47229,7 +47229,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CV_CV_JMPNZ_ } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } From ce59e42e147840c1e960750b90721520320eeb8c Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Mon, 17 Aug 2020 00:55:10 +0200 Subject: [PATCH 157/170] Zend_API.h slight teak --- Zend/zend_API.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_API.h b/Zend/zend_API.h index feaeab2ea67c4..5f3d9b8553087 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -1176,7 +1176,7 @@ static zend_always_inline zval *zend_try_array_init_size(zval *zv, uint32_t size if (EXPECTED(Z_ISREF_P(zv))) { zend_reference *ref = Z_REF_P(zv); if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(ref))) { - if (zend_try_assign_typed_ref_arr(ref, arr) != SUCCESS) { + if (zend_try_assign_typed_ref_arr(ref, arr) == FAILURE) { return NULL; } return &ref->val; From 32149e494f41c65199a498a6601b4d798d6f4797 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Mon, 17 Aug 2020 01:24:21 +0200 Subject: [PATCH 158/170] Fix zend_extension incompatible function pointer --- Zend/zend_extensions.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Zend/zend_extensions.c b/Zend/zend_extensions.c index 8ea36e081282f..a547ede770071 100644 --- a/Zend/zend_extensions.c +++ b/Zend/zend_extensions.c @@ -180,7 +180,8 @@ static void zend_extension_shutdown(zend_extension *extension) #endif } -static bool zend_extension_startup(zend_extension *extension) +/* int return due to zend linked list API */ +static int zend_extension_startup(zend_extension *extension) { #if ZEND_EXTENSIONS_SUPPORT if (extension->startup) { From 0001c4bc1493cb1e295cebbab04d92d6f98854c9 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Mon, 17 Aug 2020 01:40:41 +0200 Subject: [PATCH 159/170] Fix zend_stream function to be compatible for Zend LList --- Zend/zend_stream.c | 3 ++- Zend/zend_stream.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Zend/zend_stream.c b/Zend/zend_stream.c index 87d90a7b9869c..18419457b1376 100644 --- a/Zend/zend_stream.c +++ b/Zend/zend_stream.c @@ -232,7 +232,8 @@ ZEND_API void zend_file_handle_dtor(zend_file_handle *fh) /* {{{ */ } /* }}} */ -ZEND_API bool zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2) /* {{{ */ +/* return int to be compatible with Zend linked list API */ +ZEND_API int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2) /* {{{ */ { if (fh1->type != fh2->type) { return 0; diff --git a/Zend/zend_stream.h b/Zend/zend_stream.h index 3f7df9d4e2ba9..57ddc3df15f43 100644 --- a/Zend/zend_stream.h +++ b/Zend/zend_stream.h @@ -69,7 +69,7 @@ ZEND_API void zend_stream_init_filename(zend_file_handle *handle, const char *fi ZEND_API ZEND_RESULT_CODE zend_stream_open(const char *filename, zend_file_handle *handle); ZEND_API ZEND_RESULT_CODE zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t *len); ZEND_API void zend_file_handle_dtor(zend_file_handle *fh); -ZEND_API bool zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2); +ZEND_API int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2); END_EXTERN_C() #ifdef ZEND_WIN32 From 06c577928bc9f73a44f6caa0a5b6e7185ae67867 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Tue, 18 Aug 2020 19:59:42 +0200 Subject: [PATCH 160/170] Fix zend_module_entry enum due to zend_API changes --- Zend/zend_modules.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Zend/zend_modules.h b/Zend/zend_modules.h index c7e279a40849d..05f7085190c8f 100644 --- a/Zend/zend_modules.h +++ b/Zend/zend_modules.h @@ -77,10 +77,10 @@ struct _zend_module_entry { const struct _zend_module_dep *deps; const char *name; const struct _zend_function_entry *functions; - int (*module_startup_func)(INIT_FUNC_ARGS); - int (*module_shutdown_func)(SHUTDOWN_FUNC_ARGS); - int (*request_startup_func)(INIT_FUNC_ARGS); - int (*request_shutdown_func)(SHUTDOWN_FUNC_ARGS); + ZEND_RESULT_CODE (*module_startup_func)(INIT_FUNC_ARGS); + ZEND_RESULT_CODE (*module_shutdown_func)(SHUTDOWN_FUNC_ARGS); + ZEND_RESULT_CODE (*request_startup_func)(INIT_FUNC_ARGS); + ZEND_RESULT_CODE (*request_shutdown_func)(SHUTDOWN_FUNC_ARGS); void (*info_func)(ZEND_MODULE_INFO_FUNC_ARGS); const char *version; size_t globals_size; From 45aef0fe4b1f3c7e927c073046f857f889faac16 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Thu, 20 Aug 2020 11:26:00 +0200 Subject: [PATCH 161/170] Fix incompatible pointer error for Zend object handlers. --- Zend/zend_compile.h | 4 ++-- Zend/zend_exceptions.c | 4 ++-- Zend/zend_generators.c | 2 +- Zend/zend_interfaces.c | 18 +++++++++--------- Zend/zend_interfaces.h | 8 ++++---- Zend/zend_weakrefs.c | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 1010a250276f3..6dee886022832 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -751,8 +751,8 @@ const char *zend_get_zendtext(void); int zend_get_zendleng(void); #endif -typedef int (ZEND_FASTCALL *unary_op_type)(zval *, zval *); -typedef int (ZEND_FASTCALL *binary_op_type)(zval *, zval *, zval *); +typedef ZEND_RESULT_CODE (ZEND_FASTCALL *unary_op_type)(zval *, zval *); +typedef ZEND_RESULT_CODE (ZEND_FASTCALL *binary_op_type)(zval *, zval *, zval *); ZEND_API unary_op_type get_unary_op(int opcode); ZEND_API binary_op_type get_binary_op(int opcode); diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index 7d709882eedce..ee3a63a50ddeb 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -1,4 +1,4 @@ -/* + /* +----------------------------------------------------------------------+ | Zend Engine | +----------------------------------------------------------------------+ @@ -50,7 +50,7 @@ ZEND_API void (*zend_throw_exception_hook)(zend_object *ex); static zend_object_handlers default_exception_handlers; /* {{{ zend_implement_throwable */ -static ZEND_RESULT_CODE zend_implement_throwable(zend_class_entry *interface, zend_class_entry *class_type) +static int zend_implement_throwable(zend_class_entry *interface, zend_class_entry *class_type) { if (instanceof_function(class_type, zend_ce_exception) || instanceof_function(class_type, zend_ce_error)) { return SUCCESS; diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index f9a8fb4c09b2f..590508dd4f474 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -1027,7 +1027,7 @@ static void zend_generator_iterator_dtor(zend_object_iterator *iterator) /* {{{ } /* }}} */ -static ZEND_RESULT_CODE zend_generator_iterator_valid(zend_object_iterator *iterator) /* {{{ */ +static int zend_generator_iterator_valid(zend_object_iterator *iterator) /* {{{ */ { zend_generator *generator = (zend_generator*)Z_OBJ(iterator->data); diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c index 280af1cc3c41f..3d44b4769b29b 100644 --- a/Zend/zend_interfaces.c +++ b/Zend/zend_interfaces.c @@ -118,7 +118,7 @@ static void zend_user_it_dtor(zend_object_iterator *_iter) /* }}} */ /* {{{ zend_user_it_valid */ -ZEND_API ZEND_RESULT_CODE zend_user_it_valid(zend_object_iterator *_iter) +ZEND_API int zend_user_it_valid(zend_object_iterator *_iter) { if (_iter) { zend_user_iterator *iter = (zend_user_iterator*)_iter; @@ -251,7 +251,7 @@ ZEND_API zend_object_iterator *zend_user_it_get_new_iterator(zend_class_entry *c /* }}} */ /* {{{ zend_implement_traversable */ -static ZEND_RESULT_CODE zend_implement_traversable(zend_class_entry *interface, zend_class_entry *class_type) +static int zend_implement_traversable(zend_class_entry *interface, zend_class_entry *class_type) { /* Abstract class can implement Traversable only, in which case the extending class must * implement Iterator or IteratorAggregate. */ @@ -278,7 +278,7 @@ static ZEND_RESULT_CODE zend_implement_traversable(zend_class_entry *interface, /* }}} */ /* {{{ zend_implement_aggregate */ -static ZEND_RESULT_CODE zend_implement_aggregate(zend_class_entry *interface, zend_class_entry *class_type) +static int zend_implement_aggregate(zend_class_entry *interface, zend_class_entry *class_type) { if (zend_class_implements_interface(class_type, zend_ce_iterator)) { zend_error_noreturn(E_ERROR, @@ -318,7 +318,7 @@ static ZEND_RESULT_CODE zend_implement_aggregate(zend_class_entry *interface, ze /* }}} */ /* {{{ zend_implement_iterator */ -static ZEND_RESULT_CODE zend_implement_iterator(zend_class_entry *interface, zend_class_entry *class_type) +static int zend_implement_iterator(zend_class_entry *interface, zend_class_entry *class_type) { if (zend_class_implements_interface(class_type, zend_ce_aggregate)) { zend_error_noreturn(E_ERROR, @@ -354,7 +354,7 @@ static ZEND_RESULT_CODE zend_implement_iterator(zend_class_entry *interface, zen /* }}} */ /* {{{ zend_user_serialize */ -ZEND_API ZEND_RESULT_CODE zend_user_serialize(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data) +ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data) { zend_class_entry * ce = Z_OBJCE_P(object); zval retval; @@ -391,7 +391,7 @@ ZEND_API ZEND_RESULT_CODE zend_user_serialize(zval *object, unsigned char **buff /* }}} */ /* {{{ zend_user_unserialize */ -ZEND_API ZEND_RESULT_CODE zend_user_unserialize(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data) +ZEND_API int zend_user_unserialize(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data) { zval zdata; @@ -412,7 +412,7 @@ ZEND_API ZEND_RESULT_CODE zend_user_unserialize(zval *object, zend_class_entry * } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_class_serialize_deny(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data) /* {{{ */ +ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data) /* {{{ */ { zend_class_entry *ce = Z_OBJCE_P(object); zend_throw_exception_ex(NULL, 0, "Serialization of '%s' is not allowed", ZSTR_VAL(ce->name)); @@ -420,7 +420,7 @@ ZEND_API ZEND_RESULT_CODE zend_class_serialize_deny(zval *object, unsigned char } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_class_unserialize_deny(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data) /* {{{ */ +ZEND_API int zend_class_unserialize_deny(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data) /* {{{ */ { zend_throw_exception_ex(NULL, 0, "Unserialization of '%s' is not allowed", ZSTR_VAL(ce->name)); return FAILURE; @@ -428,7 +428,7 @@ ZEND_API ZEND_RESULT_CODE zend_class_unserialize_deny(zval *object, zend_class_e /* }}} */ /* {{{ zend_implement_serializable */ -static ZEND_RESULT_CODE zend_implement_serializable(zend_class_entry *interface, zend_class_entry *class_type) +static int zend_implement_serializable(zend_class_entry *interface, zend_class_entry *class_type) { if (class_type->parent && (class_type->parent->serialize || class_type->parent->unserialize) diff --git a/Zend/zend_interfaces.h b/Zend/zend_interfaces.h index bbc4ac5b49fda..2f09402c90e5c 100644 --- a/Zend/zend_interfaces.h +++ b/Zend/zend_interfaces.h @@ -72,11 +72,11 @@ ZEND_API zend_object_iterator *zend_user_it_get_new_iterator(zend_class_entry *c ZEND_API void zend_register_interfaces(void); -ZEND_API ZEND_RESULT_CODE zend_user_serialize(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data); -ZEND_API ZEND_RESULT_CODE zend_user_unserialize(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data); +ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data); +ZEND_API int zend_user_unserialize(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data); -ZEND_API ZEND_RESULT_CODE zend_class_serialize_deny(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data); -ZEND_API ZEND_RESULT_CODE zend_class_unserialize_deny(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data); +ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data); +ZEND_API int zend_class_unserialize_deny(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data); ZEND_API ZEND_RESULT_CODE zend_create_internal_iterator_zval(zval *return_value, zval *obj); diff --git a/Zend/zend_weakrefs.c b/Zend/zend_weakrefs.c index e9133c694c6fa..a4bf195a07060 100644 --- a/Zend/zend_weakrefs.c +++ b/Zend/zend_weakrefs.c @@ -372,7 +372,7 @@ static void zend_weakmap_unset_dimension(zend_object *object, zval *offset) zend_weakref_unregister(obj_key, ZEND_WEAKREF_ENCODE(wm, ZEND_WEAKREF_TAG_MAP)); } -static ZEND_RESULT_CODE zend_weakmap_count_elements(zend_object *object, zend_long *count) +static int zend_weakmap_count_elements(zend_object *object, zend_long *count) { zend_weakmap *wm = zend_weakmap_from(object); *count = zend_hash_num_elements(&wm->ht); From 4f8829ac17304fa491ff51eee7a221e115c393d0 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Thu, 20 Aug 2020 17:51:50 +0200 Subject: [PATCH 162/170] Fix OpCache --- ext/opcache/ZendAccelerator.c | 18 +++++++++--------- ext/opcache/ZendAccelerator.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index f532596f0f9a7..9bd2ab15e1386 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -119,15 +119,15 @@ zend_bool fallback_process = 0; /* process uses file cache fallback */ #endif static zend_op_array *(*accelerator_orig_compile_file)(zend_file_handle *file_handle, int type); -static int (*accelerator_orig_zend_stream_open_function)(const char *filename, zend_file_handle *handle ); +static ZEND_RESULT_CODE (*accelerator_orig_zend_stream_open_function)(const char *filename, zend_file_handle *handle ); static zend_string *(*accelerator_orig_zend_resolve_path)(const char *filename, size_t filename_len); static void (*accelerator_orig_zend_error_cb)(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message); static zif_handler orig_chdir = NULL; static ZEND_INI_MH((*orig_include_path_on_modify)) = NULL; -static int (*orig_post_startup_cb)(void); +static ZEND_RESULT_CODE (*orig_post_startup_cb)(void); static void accel_gen_system_id(void); -static int accel_post_startup(void); +static ZEND_RESULT_CODE accel_post_startup(void); static int accel_finish_startup(void); static void preload_shutdown(void); @@ -304,7 +304,7 @@ static inline int accel_restart_is_active(void) } /* Creates a read lock for SHM access */ -static inline int accel_activate_add(void) +static inline ZEND_RESULT_CODE accel_activate_add(void) { #ifdef ZEND_WIN32 SHM_UNPROTECT(); @@ -2269,7 +2269,7 @@ static int accel_gen_uname_id(void) #endif /* zend_stream_open_function() replacement for PHP 5.3 and above */ -static int persistent_stream_open_function(const char *filename, zend_file_handle *handle) +static ZEND_RESULT_CODE persistent_stream_open_function(const char *filename, zend_file_handle *handle) { if (ZCG(cache_persistent_script)) { /* check if callback is called from include_once or it's a main request */ @@ -2400,7 +2400,7 @@ static void accel_reset_pcre_cache(void) } ZEND_HASH_FOREACH_END(); } -int accel_activate(INIT_FUNC_ARGS) +ZEND_RESULT_CODE accel_activate(INIT_FUNC_ARGS) { if (!ZCG(enabled) || !accel_startup_ok) { ZCG(accelerator_enabled) = 0; @@ -2963,13 +2963,13 @@ static int accel_startup(zend_extension *extension) return SUCCESS; } -static int accel_post_startup(void) +static ZEND_RESULT_CODE accel_post_startup(void) { zend_function *func; zend_ini_entry *ini_entry; if (orig_post_startup_cb) { - int (*cb)(void) = orig_post_startup_cb; + ZEND_RESULT_CODE (*cb)(void) = orig_post_startup_cb; orig_post_startup_cb = NULL; if (cb() != SUCCESS) { @@ -4368,7 +4368,7 @@ static void preload_load(void) } } -static int preload_autoload(zend_string *filename) +static ZEND_RESULT_CODE preload_autoload(zend_string *filename) { zend_persistent_script *persistent_script; zend_op_array *op_array; diff --git a/ext/opcache/ZendAccelerator.h b/ext/opcache/ZendAccelerator.h index 05a05fa1b68a4..a0749cb22d33a 100644 --- a/ext/opcache/ZendAccelerator.h +++ b/ext/opcache/ZendAccelerator.h @@ -316,7 +316,7 @@ extern zend_accel_globals accel_globals; extern char *zps_api_failure_reason; void accel_shutdown(void); -int accel_activate(INIT_FUNC_ARGS); +ZEND_RESULT_CODE accel_activate(INIT_FUNC_ARGS); int accel_post_deactivate(void); void zend_accel_schedule_restart(zend_accel_restart_reason reason); void zend_accel_schedule_restart_if_necessary(zend_accel_restart_reason reason); From d276dceca84b663f18214e434c6226e59ffdac14 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 22 Aug 2020 00:50:34 +0200 Subject: [PATCH 163/170] Shot in the dark to fix the JIT --- Zend/zend_operators.c | 4 ++-- Zend/zend_operators.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 9e91069e78b7c..fea8ae3340275 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -2524,13 +2524,13 @@ ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL decrement_function(zval *op1) /* {{{ */ } /* }}} */ -ZEND_API bool ZEND_FASTCALL zend_is_true(zval *op) /* {{{ */ +ZEND_API int ZEND_FASTCALL zend_is_true(zval *op) /* {{{ */ { return i_zend_is_true(op); } /* }}} */ -ZEND_API bool ZEND_FASTCALL zend_object_is_true(zval *op) /* {{{ */ +ZEND_API int ZEND_FASTCALL zend_object_is_true(zval *op) /* {{{ */ { zend_object *zobj = Z_OBJ_P(op); zval tmp; diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 76d0749703ee0..4c09ce3761624 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -341,15 +341,15 @@ static zend_always_inline zend_bool try_convert_to_string(zval *op) { #define convert_to_string(op) if (Z_TYPE_P(op) != IS_STRING) { _convert_to_string((op)); } -ZEND_API bool ZEND_FASTCALL zend_is_true(zval *op); -ZEND_API bool ZEND_FASTCALL zend_object_is_true(zval *op); +ZEND_API int ZEND_FASTCALL zend_is_true(zval *op); +ZEND_API int ZEND_FASTCALL zend_object_is_true(zval *op); #define zval_is_true(op) \ zend_is_true(op) -static zend_always_inline bool i_zend_is_true(zval *op) +static zend_always_inline int i_zend_is_true(zval *op) { - bool result = 0; + int result = 0; again: switch (Z_TYPE_P(op)) { From 39cc10b838505aba65e3160720f452d8a5e278fd Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Mon, 24 Aug 2020 14:43:42 +0200 Subject: [PATCH 164/170] Typedef ZEND_RESULT_CODE to zend_result --- Zend/zend_types.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Zend/zend_types.h b/Zend/zend_types.h index 7796979ed842f..745be6e93830c 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -55,6 +55,8 @@ typedef enum { FAILURE = -1, /* this MUST stay a negative number, or it may affect functions! */ } ZEND_RESULT_CODE; +typedef ZEND_RESULT_CODE zend_result; + #ifdef ZEND_ENABLE_ZVAL_LONG64 # ifdef ZEND_WIN32 # define ZEND_SIZE_MAX _UI64_MAX From b548cdbde6077449ce250e682cfceba29705c485 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Mon, 24 Aug 2020 14:52:42 +0200 Subject: [PATCH 165/170] Use zend_result instead of ZEND_RESULT_CODE --- Zend/zend.c | 14 ++-- Zend/zend.h | 10 +-- Zend/zend_API.c | 128 ++++++++++++++++---------------- Zend/zend_API.h | 134 +++++++++++++++++----------------- Zend/zend_ast.c | 8 +- Zend/zend_ast.h | 2 +- Zend/zend_attributes.c | 2 +- Zend/zend_attributes.h | 2 +- Zend/zend_builtin_functions.c | 2 +- Zend/zend_builtin_functions.h | 2 +- Zend/zend_closures.c | 2 +- Zend/zend_compile.c | 54 +++++++------- Zend/zend_compile.h | 12 +-- Zend/zend_constants.c | 6 +- Zend/zend_constants.h | 2 +- Zend/zend_exceptions.c | 4 +- Zend/zend_exceptions.h | 2 +- Zend/zend_execute.c | 22 +++--- Zend/zend_execute.h | 16 ++-- Zend/zend_execute_API.c | 28 +++---- Zend/zend_extensions.c | 4 +- Zend/zend_extensions.h | 4 +- Zend/zend_generators.c | 2 +- Zend/zend_hash.c | 14 ++-- Zend/zend_hash.h | 26 +++---- Zend/zend_highlight.h | 2 +- Zend/zend_inheritance.c | 2 +- Zend/zend_inheritance.h | 2 +- Zend/zend_ini.c | 22 +++--- Zend/zend_ini.h | 14 ++-- Zend/zend_ini_parser.y | 4 +- Zend/zend_ini_scanner.h | 4 +- Zend/zend_ini_scanner.l | 8 +- Zend/zend_interfaces.c | 6 +- Zend/zend_interfaces.h | 4 +- Zend/zend_language_scanner.h | 4 +- Zend/zend_language_scanner.l | 14 ++-- Zend/zend_list.c | 2 +- Zend/zend_modules.h | 8 +- Zend/zend_multibyte.c | 12 +-- Zend/zend_multibyte.h | 8 +- Zend/zend_operators.c | 68 ++++++++--------- Zend/zend_operators.h | 50 ++++++------- Zend/zend_signal.c | 2 +- Zend/zend_stream.c | 4 +- Zend/zend_stream.h | 4 +- Zend/zend_ts_hash.c | 8 +- Zend/zend_ts_hash.h | 4 +- Zend/zend_virtual_cwd.c | 2 +- ext/mbstring/mbstring.c | 8 +- ext/opcache/ZendAccelerator.c | 18 ++--- ext/opcache/ZendAccelerator.h | 2 +- main/main.c | 4 +- 53 files changed, 396 insertions(+), 396 deletions(-) diff --git a/Zend/zend.c b/Zend/zend.c index 354b9c3c5ea16..2e2ff032136bc 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -74,7 +74,7 @@ ZEND_API zend_class_entry *zend_standard_class_def = NULL; ZEND_API size_t (*zend_printf)(const char *format, ...); ZEND_API zend_write_func_t zend_write; ZEND_API FILE *(*zend_fopen)(const char *filename, zend_string **opened_path); -ZEND_API ZEND_RESULT_CODE (*zend_stream_open_function)(const char *filename, zend_file_handle *handle); +ZEND_API zend_result (*zend_stream_open_function)(const char *filename, zend_file_handle *handle); ZEND_API void (*zend_ticks_function)(int ticks); ZEND_API void (*zend_interrupt_function)(zend_execute_data *execute_data); ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message); @@ -82,9 +82,9 @@ void (*zend_printf_to_smart_string)(smart_string *buf, const char *format, va_li void (*zend_printf_to_smart_str)(smart_str *buf, const char *format, va_list ap); ZEND_API char *(*zend_getenv)(const char *name, size_t name_len); ZEND_API zend_string *(*zend_resolve_path)(const char *filename, size_t filename_len); -ZEND_API ZEND_RESULT_CODE (*zend_post_startup_cb)(void) = NULL; +ZEND_API zend_result (*zend_post_startup_cb)(void) = NULL; ZEND_API void (*zend_post_shutdown_cb)(void) = NULL; -ZEND_API ZEND_RESULT_CODE (*zend_preload_autoload)(zend_string *filename) = NULL; +ZEND_API zend_result (*zend_preload_autoload)(zend_string *filename) = NULL; /* This callback must be signal handler safe! */ void (*zend_on_timeout)(int seconds); @@ -1018,7 +1018,7 @@ static void zend_resolve_property_types(void) /* {{{ */ /* Unlink the global (r/o) copies of the class, function and constant tables, * and use a fresh r/w copy for the startup thread */ -ZEND_RESULT_CODE zend_post_startup(void) /* {{{ */ +zend_result zend_post_startup(void) /* {{{ */ { #ifdef ZTS zend_encoding **script_encoding_list; @@ -1030,7 +1030,7 @@ ZEND_RESULT_CODE zend_post_startup(void) /* {{{ */ zend_resolve_property_types(); if (zend_post_startup_cb) { - ZEND_RESULT_CODE (*cb)(void) = zend_post_startup_cb; + zend_result (*cb)(void) = zend_post_startup_cb; zend_post_startup_cb = NULL; if (cb() != SUCCESS) { @@ -1662,13 +1662,13 @@ ZEND_API ZEND_COLD void zend_user_exception_handler(void) /* {{{ */ } } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_execute_scripts(int type, zval *retval, int file_count, ...) /* {{{ */ +ZEND_API zend_result zend_execute_scripts(int type, zval *retval, int file_count, ...) /* {{{ */ { va_list files; int i; zend_file_handle *file_handle; zend_op_array *op_array; - ZEND_RESULT_CODE ret = SUCCESS; + zend_result ret = SUCCESS; va_start(files, file_count); for (i = 0; i < file_count; i++) { diff --git a/Zend/zend.h b/Zend/zend.h index fba45e0270c1d..0a0506f9158a1 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -195,7 +195,7 @@ typedef struct _zend_utility_functions { zval *(*get_configuration_directive)(zend_string *name); void (*ticks_function)(int ticks); void (*on_timeout)(int seconds); - ZEND_RESULT_CODE (*stream_open_function)(const char *filename, zend_file_handle *handle); + zend_result (*stream_open_function)(const char *filename, zend_file_handle *handle); void (*printf_to_smart_string_function)(smart_string *buf, const char *format, va_list ap); void (*printf_to_smart_str_function)(smart_str *buf, const char *format, va_list ap); char *(*getenv_function)(const char *name, size_t name_len); @@ -230,7 +230,7 @@ BEGIN_EXTERN_C() void zend_startup(zend_utility_functions *utility_functions); void zend_shutdown(void); void zend_register_standard_ini_entries(void); -ZEND_RESULT_CODE zend_post_startup(void); +zend_result zend_post_startup(void); void zend_set_utility_values(zend_utility_values *utility_values); ZEND_API ZEND_COLD ZEND_NORETURN void _zend_bailout(const char *filename, uint32_t lineno); @@ -283,18 +283,18 @@ extern ZEND_API void (*zend_ticks_function)(int ticks); extern ZEND_API void (*zend_interrupt_function)(zend_execute_data *execute_data); extern ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message); extern ZEND_API void (*zend_on_timeout)(int seconds); -extern ZEND_API ZEND_RESULT_CODE (*zend_stream_open_function)(const char *filename, zend_file_handle *handle); +extern ZEND_API zend_result (*zend_stream_open_function)(const char *filename, zend_file_handle *handle); extern void (*zend_printf_to_smart_string)(smart_string *buf, const char *format, va_list ap); extern void (*zend_printf_to_smart_str)(smart_str *buf, const char *format, va_list ap); extern ZEND_API char *(*zend_getenv)(const char *name, size_t name_len); extern ZEND_API zend_string *(*zend_resolve_path)(const char *filename, size_t filename_len); /* These two callbacks are especially for opcache */ -extern ZEND_API ZEND_RESULT_CODE (*zend_post_startup_cb)(void); +extern ZEND_API zend_result (*zend_post_startup_cb)(void); extern ZEND_API void (*zend_post_shutdown_cb)(void); /* Callback for loading of not preloaded part of the script */ -extern ZEND_API ZEND_RESULT_CODE (*zend_preload_autoload)(zend_string *filename); +extern ZEND_API zend_result (*zend_preload_autoload)(zend_string *filename); ZEND_API ZEND_COLD void zend_error(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3); ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_noreturn(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3); diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 98905939c142e..1e5dfe57b038d 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -42,7 +42,7 @@ static zend_module_entry **module_post_deactivate_handlers; static zend_class_entry **class_cleanup_handlers; -ZEND_API ZEND_RESULT_CODE _zend_get_parameters_array_ex(uint32_t param_count, zval *argument_array) /* {{{ */ +ZEND_API zend_result _zend_get_parameters_array_ex(uint32_t param_count, zval *argument_array) /* {{{ */ { zval *param_ptr; uint32_t arg_count; @@ -64,7 +64,7 @@ ZEND_API ZEND_RESULT_CODE _zend_get_parameters_array_ex(uint32_t param_count, zv } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_copy_parameters_array(uint32_t param_count, zval *argument_array) /* {{{ */ +ZEND_API zend_result zend_copy_parameters_array(uint32_t param_count, zval *argument_array) /* {{{ */ { zval *param_ptr; uint32_t arg_count; @@ -858,7 +858,7 @@ static const char *zend_parse_arg_impl(zval *arg, va_list *va, const char **spec } /* }}} */ -static ZEND_RESULT_CODE zend_parse_arg(uint32_t arg_num, zval *arg, va_list *va, const char **spec, int flags) /* {{{ */ +static zend_result zend_parse_arg(uint32_t arg_num, zval *arg, va_list *va, const char **spec, int flags) /* {{{ */ { const char *expected_type = NULL; char *error = NULL; @@ -886,10 +886,10 @@ static ZEND_RESULT_CODE zend_parse_arg(uint32_t arg_num, zval *arg, va_list *va, } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_parse_parameter(int flags, uint32_t arg_num, zval *arg, const char *spec, ...) +ZEND_API zend_result zend_parse_parameter(int flags, uint32_t arg_num, zval *arg, const char *spec, ...) { va_list va; - ZEND_RESULT_CODE ret; + zend_result ret; va_start(va, spec); ret = zend_parse_arg(arg_num, arg, &va, &spec, flags); @@ -907,7 +907,7 @@ static ZEND_COLD void zend_parse_parameters_debug_error(const char *msg) { ZSTR_VAL(active_function->common.function_name), msg); } -static ZEND_RESULT_CODE zend_parse_va_args(uint32_t num_args, const char *type_spec, va_list *va, int flags) /* {{{ */ +static zend_result zend_parse_va_args(uint32_t num_args, const char *type_spec, va_list *va, int flags) /* {{{ */ { const char *spec_walk; char c; @@ -1049,10 +1049,10 @@ static ZEND_RESULT_CODE zend_parse_va_args(uint32_t num_args, const char *type_s } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_parse_parameters_ex(int flags, uint32_t num_args, const char *type_spec, ...) /* {{{ */ +ZEND_API zend_result zend_parse_parameters_ex(int flags, uint32_t num_args, const char *type_spec, ...) /* {{{ */ { va_list va; - ZEND_RESULT_CODE retval; + zend_result retval; va_start(va, type_spec); retval = zend_parse_va_args(num_args, type_spec, &va, flags); @@ -1062,10 +1062,10 @@ ZEND_API ZEND_RESULT_CODE zend_parse_parameters_ex(int flags, uint32_t num_args, } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_parse_parameters(uint32_t num_args, const char *type_spec, ...) /* {{{ */ +ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec, ...) /* {{{ */ { va_list va; - ZEND_RESULT_CODE retval; + zend_result retval; int flags = 0; va_start(va, type_spec); @@ -1076,10 +1076,10 @@ ZEND_API ZEND_RESULT_CODE zend_parse_parameters(uint32_t num_args, const char *t } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_parse_method_parameters(uint32_t num_args, zval *this_ptr, const char *type_spec, ...) /* {{{ */ +ZEND_API zend_result zend_parse_method_parameters(uint32_t num_args, zval *this_ptr, const char *type_spec, ...) /* {{{ */ { va_list va; - ZEND_RESULT_CODE retval; + zend_result retval; int flags = 0; const char *p = type_spec; zval **object; @@ -1116,10 +1116,10 @@ ZEND_API ZEND_RESULT_CODE zend_parse_method_parameters(uint32_t num_args, zval * } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_parse_method_parameters_ex(int flags, uint32_t num_args, zval *this_ptr, const char *type_spec, ...) /* {{{ */ +ZEND_API zend_result zend_parse_method_parameters_ex(int flags, uint32_t num_args, zval *this_ptr, const char *type_spec, ...) /* {{{ */ { va_list va; - ZEND_RESULT_CODE retval; + zend_result retval; const char *p = type_spec; zval **object; zend_class_entry *ce; @@ -1172,7 +1172,7 @@ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties) /* {{{ */ } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_update_class_constants(zend_class_entry *class_type) /* {{{ */ +ZEND_API zend_result zend_update_class_constants(zend_class_entry *class_type) /* {{{ */ { if (!(class_type->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) { zend_class_constant *c; @@ -1361,7 +1361,7 @@ ZEND_API void object_properties_load(zend_object *object, HashTable *properties) * class and all props being public. If only a subset is given or the class * has protected members then you need to merge the properties separately by * calling zend_merge_properties(). */ -static zend_always_inline ZEND_RESULT_CODE _object_and_properties_init(zval *arg, zend_class_entry *class_type, HashTable *properties) /* {{{ */ +static zend_always_inline zend_result _object_and_properties_init(zval *arg, zend_class_entry *class_type, HashTable *properties) /* {{{ */ { if (UNEXPECTED(class_type->ce_flags & (ZEND_ACC_INTERFACE|ZEND_ACC_TRAIT|ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS))) { if (class_type->ce_flags & ZEND_ACC_INTERFACE) { @@ -1400,13 +1400,13 @@ static zend_always_inline ZEND_RESULT_CODE _object_and_properties_init(zval *arg } /* }}} */ -ZEND_API ZEND_RESULT_CODE object_and_properties_init(zval *arg, zend_class_entry *class_type, HashTable *properties) /* {{{ */ +ZEND_API zend_result object_and_properties_init(zval *arg, zend_class_entry *class_type, HashTable *properties) /* {{{ */ { return _object_and_properties_init(arg, class_type, properties); } /* }}} */ -ZEND_API ZEND_RESULT_CODE object_init_ex(zval *arg, zend_class_entry *class_type) /* {{{ */ +ZEND_API zend_result object_init_ex(zval *arg, zend_class_entry *class_type) /* {{{ */ { return _object_and_properties_init(arg, class_type, NULL); } @@ -1568,7 +1568,7 @@ ZEND_API void add_index_stringl(zval *arg, zend_ulong index, const char *str, si } /* }}} */ -ZEND_API ZEND_RESULT_CODE add_next_index_long(zval *arg, zend_long n) /* {{{ */ +ZEND_API zend_result add_next_index_long(zval *arg, zend_long n) /* {{{ */ { zval tmp; @@ -1577,7 +1577,7 @@ ZEND_API ZEND_RESULT_CODE add_next_index_long(zval *arg, zend_long n) /* {{{ */ } /* }}} */ -ZEND_API ZEND_RESULT_CODE add_next_index_null(zval *arg) /* {{{ */ +ZEND_API zend_result add_next_index_null(zval *arg) /* {{{ */ { zval tmp; @@ -1586,7 +1586,7 @@ ZEND_API ZEND_RESULT_CODE add_next_index_null(zval *arg) /* {{{ */ } /* }}} */ -ZEND_API ZEND_RESULT_CODE add_next_index_bool(zval *arg, zend_bool b) /* {{{ */ +ZEND_API zend_result add_next_index_bool(zval *arg, zend_bool b) /* {{{ */ { zval tmp; @@ -1595,7 +1595,7 @@ ZEND_API ZEND_RESULT_CODE add_next_index_bool(zval *arg, zend_bool b) /* {{{ */ } /* }}} */ -ZEND_API ZEND_RESULT_CODE add_next_index_resource(zval *arg, zend_resource *r) /* {{{ */ +ZEND_API zend_result add_next_index_resource(zval *arg, zend_resource *r) /* {{{ */ { zval tmp; @@ -1604,7 +1604,7 @@ ZEND_API ZEND_RESULT_CODE add_next_index_resource(zval *arg, zend_resource *r) / } /* }}} */ -ZEND_API ZEND_RESULT_CODE add_next_index_double(zval *arg, double d) /* {{{ */ +ZEND_API zend_result add_next_index_double(zval *arg, double d) /* {{{ */ { zval tmp; @@ -1613,7 +1613,7 @@ ZEND_API ZEND_RESULT_CODE add_next_index_double(zval *arg, double d) /* {{{ */ } /* }}} */ -ZEND_API ZEND_RESULT_CODE add_next_index_str(zval *arg, zend_string *str) /* {{{ */ +ZEND_API zend_result add_next_index_str(zval *arg, zend_string *str) /* {{{ */ { zval tmp; @@ -1622,7 +1622,7 @@ ZEND_API ZEND_RESULT_CODE add_next_index_str(zval *arg, zend_string *str) /* {{{ } /* }}} */ -ZEND_API ZEND_RESULT_CODE add_next_index_string(zval *arg, const char *str) /* {{{ */ +ZEND_API zend_result add_next_index_string(zval *arg, const char *str) /* {{{ */ { zval tmp; @@ -1631,7 +1631,7 @@ ZEND_API ZEND_RESULT_CODE add_next_index_string(zval *arg, const char *str) /* { } /* }}} */ -ZEND_API ZEND_RESULT_CODE add_next_index_stringl(zval *arg, const char *str, size_t length) /* {{{ */ +ZEND_API zend_result add_next_index_stringl(zval *arg, const char *str, size_t length) /* {{{ */ { zval tmp; @@ -1640,7 +1640,7 @@ ZEND_API ZEND_RESULT_CODE add_next_index_stringl(zval *arg, const char *str, siz } /* }}} */ -ZEND_API ZEND_RESULT_CODE array_set_zval_key(HashTable *ht, zval *key, zval *value) /* {{{ */ +ZEND_API zend_result array_set_zval_key(HashTable *ht, zval *key, zval *value) /* {{{ */ { zval *result; @@ -1767,7 +1767,7 @@ ZEND_API void add_property_zval_ex(zval *arg, const char *key, size_t key_len, z } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_startup_module_ex(zend_module_entry *module) /* {{{ */ +ZEND_API zend_result zend_startup_module_ex(zend_module_entry *module) /* {{{ */ { size_t name_len; zend_string *lcname; @@ -2254,7 +2254,7 @@ ZEND_API void zend_add_magic_method(zend_class_entry *ce, zend_function *fptr, z } /* registers all functions in *library_functions in the function hash */ -ZEND_API ZEND_RESULT_CODE zend_register_functions(zend_class_entry *scope, const zend_function_entry *functions, HashTable *function_table, int type) /* {{{ */ +ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend_function_entry *functions, HashTable *function_table, int type) /* {{{ */ { const zend_function_entry *ptr = functions; zend_function function, *reg_function; @@ -2477,7 +2477,7 @@ ZEND_API void zend_unregister_functions(const zend_function_entry *functions, in } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_startup_module(zend_module_entry *module) /* {{{ */ +ZEND_API zend_result zend_startup_module(zend_module_entry *module) /* {{{ */ { if ((module = zend_register_internal_module(module)) != NULL && zend_startup_module_ex(module) == SUCCESS) { return SUCCESS; @@ -2486,7 +2486,7 @@ ZEND_API ZEND_RESULT_CODE zend_startup_module(zend_module_entry *module) /* {{{ } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_get_module_started(const char *module_name) /* {{{ */ +ZEND_API zend_result zend_get_module_started(const char *module_name) /* {{{ */ { zend_module_entry *module; @@ -2730,7 +2730,7 @@ ZEND_API zend_class_entry *zend_register_internal_interface(zend_class_entry *or } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce, bool persistent) /* {{{ */ +ZEND_API zend_result zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce, bool persistent) /* {{{ */ { zend_string *lcname; zval zv, *ret; @@ -2766,7 +2766,7 @@ ZEND_API ZEND_RESULT_CODE zend_register_class_alias_ex(const char *name, size_t /* }}} */ // TODO num_symbol_tables as unsigned int? -ZEND_API ZEND_RESULT_CODE zend_set_hash_symbol(zval *symbol, const char *name, size_t name_length, zend_bool is_ref, int num_symbol_tables, ...) /* {{{ */ +ZEND_API zend_result zend_set_hash_symbol(zval *symbol, const char *name, size_t name_length, zend_bool is_ref, int num_symbol_tables, ...) /* {{{ */ { HashTable *symbol_table; va_list symbol_table_list; @@ -2790,7 +2790,7 @@ ZEND_API ZEND_RESULT_CODE zend_set_hash_symbol(zval *symbol, const char *name, s /* Disabled functions support */ -ZEND_API ZEND_RESULT_CODE zend_disable_function(const char *function_name, size_t function_name_length) /* {{{ */ +ZEND_API zend_result zend_disable_function(const char *function_name, size_t function_name_length) /* {{{ */ { return zend_hash_str_del(CG(function_table), function_name, function_name_length); } @@ -2827,7 +2827,7 @@ static const zend_function_entry disabled_class_new[] = { ZEND_FE_END }; -ZEND_API ZEND_RESULT_CODE zend_disable_class(const char *class_name, size_t class_name_length) /* {{{ */ +ZEND_API zend_result zend_disable_class(const char *class_name, size_t class_name_length) /* {{{ */ { zend_class_entry *disabled_class; zend_string *key; @@ -3391,7 +3391,7 @@ ZEND_API zend_bool zend_make_callable(zval *callable, zend_string **callable_nam } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_fcall_info_init(zval *callable, uint32_t check_flags, zend_fcall_info *fci, zend_fcall_info_cache *fcc, zend_string **callable_name, char **error) /* {{{ */ +ZEND_API zend_result zend_fcall_info_init(zval *callable, uint32_t check_flags, zend_fcall_info *fci, zend_fcall_info_cache *fcc, zend_string **callable_name, char **error) /* {{{ */ { if (!zend_is_callable_ex(callable, NULL, check_flags, callable_name, fcc, error)) { return FAILURE; @@ -3445,7 +3445,7 @@ ZEND_API void zend_fcall_info_args_restore(zend_fcall_info *fci, uint32_t param_ } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_fcall_info_args_ex(zend_fcall_info *fci, zend_function *func, zval *args) /* {{{ */ +ZEND_API zend_result zend_fcall_info_args_ex(zend_fcall_info *fci, zend_function *func, zval *args) /* {{{ */ { zval *arg, *params; uint32_t n = 1; @@ -3478,7 +3478,7 @@ ZEND_API ZEND_RESULT_CODE zend_fcall_info_args_ex(zend_fcall_info *fci, zend_fun } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_fcall_info_args(zend_fcall_info *fci, zval *args) /* {{{ */ +ZEND_API zend_result zend_fcall_info_args(zend_fcall_info *fci, zval *args) /* {{{ */ { return zend_fcall_info_args_ex(fci, NULL, args); } @@ -3526,11 +3526,11 @@ ZEND_API void zend_fcall_info_argn(zend_fcall_info *fci, uint32_t argc, ...) /* } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_fcall_info_call(zend_fcall_info *fci, zend_fcall_info_cache *fcc, zval *retval_ptr, zval *args) /* {{{ */ +ZEND_API zend_result zend_fcall_info_call(zend_fcall_info *fci, zend_fcall_info_cache *fcc, zval *retval_ptr, zval *args) /* {{{ */ { zval retval, *org_params = NULL; uint32_t org_count = 0; - ZEND_RESULT_CODE result; + zend_result result; fci->retval = retval_ptr ? retval_ptr : &retval; if (args) { @@ -3681,7 +3681,7 @@ ZEND_API zend_property_info *zend_declare_typed_property(zend_class_entry *ce, z } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_ex(zend_reference *ref, zval *val, zend_bool strict) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref_ex(zend_reference *ref, zval *val, zend_bool strict) /* {{{ */ { if (UNEXPECTED(!zend_verify_ref_assignable_zval(ref, val, strict))) { zval_ptr_dtor(val); @@ -3694,13 +3694,13 @@ ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_ex(zend_reference *ref, zval } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref(zend_reference *ref, zval *val) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref(zend_reference *ref, zval *val) /* {{{ */ { return zend_try_assign_typed_ref_ex(ref, val, ZEND_ARG_USES_STRICT_TYPES()); } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_null(zend_reference *ref) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref_null(zend_reference *ref) /* {{{ */ { zval tmp; @@ -3709,7 +3709,7 @@ ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_null(zend_reference *ref) /* } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_bool(zend_reference *ref, zend_bool val) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref_bool(zend_reference *ref, zend_bool val) /* {{{ */ { zval tmp; @@ -3718,7 +3718,7 @@ ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_bool(zend_reference *ref, ze } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_long(zend_reference *ref, zend_long lval) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref_long(zend_reference *ref, zend_long lval) /* {{{ */ { zval tmp; @@ -3727,7 +3727,7 @@ ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_long(zend_reference *ref, ze } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_double(zend_reference *ref, double dval) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref_double(zend_reference *ref, double dval) /* {{{ */ { zval tmp; @@ -3736,7 +3736,7 @@ ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_double(zend_reference *ref, } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_empty_string(zend_reference *ref) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref_empty_string(zend_reference *ref) /* {{{ */ { zval tmp; @@ -3745,7 +3745,7 @@ ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_empty_string(zend_reference } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_str(zend_reference *ref, zend_string *str) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref_str(zend_reference *ref, zend_string *str) /* {{{ */ { zval tmp; @@ -3754,7 +3754,7 @@ ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_str(zend_reference *ref, zen } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_string(zend_reference *ref, const char *string) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref_string(zend_reference *ref, const char *string) /* {{{ */ { zval tmp; @@ -3763,7 +3763,7 @@ ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_string(zend_reference *ref, } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_stringl(zend_reference *ref, const char *string, size_t len) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref_stringl(zend_reference *ref, const char *string, size_t len) /* {{{ */ { zval tmp; @@ -3772,7 +3772,7 @@ ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_stringl(zend_reference *ref, } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_arr(zend_reference *ref, zend_array *arr) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref_arr(zend_reference *ref, zend_array *arr) /* {{{ */ { zval tmp; @@ -3781,7 +3781,7 @@ ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_arr(zend_reference *ref, zen } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_res(zend_reference *ref, zend_resource *res) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref_res(zend_reference *ref, zend_resource *res) /* {{{ */ { zval tmp; @@ -3790,7 +3790,7 @@ ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_res(zend_reference *ref, zen } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_zval(zend_reference *ref, zval *zv) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref_zval(zend_reference *ref, zval *zv) /* {{{ */ { zval tmp; @@ -3799,7 +3799,7 @@ ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_zval(zend_reference *ref, zv } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_zval_ex(zend_reference *ref, zval *zv, zend_bool strict) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref_zval_ex(zend_reference *ref, zval *zv, zend_bool strict) /* {{{ */ { zval tmp; @@ -4090,7 +4090,7 @@ ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zend_object } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_update_static_property_ex(zend_class_entry *scope, zend_string *name, zval *value) /* {{{ */ +ZEND_API zend_result zend_update_static_property_ex(zend_class_entry *scope, zend_string *name, zval *value) /* {{{ */ { zval *property, tmp; zend_property_info *prop_info; @@ -4126,7 +4126,7 @@ ZEND_API ZEND_RESULT_CODE zend_update_static_property_ex(zend_class_entry *scope } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value) /* {{{ */ +ZEND_API zend_result zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value) /* {{{ */ { zend_string *key = zend_string_init(name, name_length, 0); bool retval = zend_update_static_property_ex(scope, key, value); @@ -4135,7 +4135,7 @@ ZEND_API ZEND_RESULT_CODE zend_update_static_property(zend_class_entry *scope, c } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_update_static_property_null(zend_class_entry *scope, const char *name, size_t name_length) /* {{{ */ +ZEND_API zend_result zend_update_static_property_null(zend_class_entry *scope, const char *name, size_t name_length) /* {{{ */ { zval tmp; @@ -4144,7 +4144,7 @@ ZEND_API ZEND_RESULT_CODE zend_update_static_property_null(zend_class_entry *sco } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_update_static_property_bool(zend_class_entry *scope, const char *name, size_t name_length, zend_long value) /* {{{ */ +ZEND_API zend_result zend_update_static_property_bool(zend_class_entry *scope, const char *name, size_t name_length, zend_long value) /* {{{ */ { zval tmp; @@ -4153,7 +4153,7 @@ ZEND_API ZEND_RESULT_CODE zend_update_static_property_bool(zend_class_entry *sco } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_update_static_property_long(zend_class_entry *scope, const char *name, size_t name_length, zend_long value) /* {{{ */ +ZEND_API zend_result zend_update_static_property_long(zend_class_entry *scope, const char *name, size_t name_length, zend_long value) /* {{{ */ { zval tmp; @@ -4162,7 +4162,7 @@ ZEND_API ZEND_RESULT_CODE zend_update_static_property_long(zend_class_entry *sco } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_update_static_property_double(zend_class_entry *scope, const char *name, size_t name_length, double value) /* {{{ */ +ZEND_API zend_result zend_update_static_property_double(zend_class_entry *scope, const char *name, size_t name_length, double value) /* {{{ */ { zval tmp; @@ -4171,7 +4171,7 @@ ZEND_API ZEND_RESULT_CODE zend_update_static_property_double(zend_class_entry *s } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value) /* {{{ */ +ZEND_API zend_result zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value) /* {{{ */ { zval tmp; @@ -4181,7 +4181,7 @@ ZEND_API ZEND_RESULT_CODE zend_update_static_property_string(zend_class_entry *s } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_update_static_property_stringl(zend_class_entry *scope, const char *name, size_t name_length, const char *value, size_t value_len) /* {{{ */ +ZEND_API zend_result zend_update_static_property_stringl(zend_class_entry *scope, const char *name, size_t name_length, const char *value, size_t value_len) /* {{{ */ { zval tmp; @@ -4315,7 +4315,7 @@ ZEND_API zend_bool zend_is_countable(zval *countable) /* {{{ */ } /* }}} */ -static ZEND_RESULT_CODE get_default_via_ast(zval *default_value_zval, const char *default_value) { +static zend_result get_default_via_ast(zval *default_value_zval, const char *default_value) { zend_ast *ast; zend_arena *ast_arena; @@ -4363,7 +4363,7 @@ static zend_string *try_parse_string(const char *str, size_t len, char quote) { return zend_string_init(str, len, 0); } -ZEND_API ZEND_RESULT_CODE zend_get_default_from_internal_arg_info( +ZEND_API zend_result zend_get_default_from_internal_arg_info( zval *default_value_zval, zend_internal_arg_info *arg_info) { const char *default_value = arg_info->default_value; diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 5f3d9b8553087..6d588cc90075d 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -182,11 +182,11 @@ typedef struct _zend_fcall_info_cache { #define ZEND_MODULE_GLOBALS_DTOR_N(module) zm_globals_dtor_##module /* Declaration macros */ -#define ZEND_MODULE_STARTUP_D(module) ZEND_RESULT_CODE ZEND_MODULE_STARTUP_N(module)(INIT_FUNC_ARGS) -#define ZEND_MODULE_SHUTDOWN_D(module) ZEND_RESULT_CODE ZEND_MODULE_SHUTDOWN_N(module)(SHUTDOWN_FUNC_ARGS) -#define ZEND_MODULE_ACTIVATE_D(module) ZEND_RESULT_CODE ZEND_MODULE_ACTIVATE_N(module)(INIT_FUNC_ARGS) -#define ZEND_MODULE_DEACTIVATE_D(module) ZEND_RESULT_CODE ZEND_MODULE_DEACTIVATE_N(module)(SHUTDOWN_FUNC_ARGS) -#define ZEND_MODULE_POST_ZEND_DEACTIVATE_D(module) ZEND_RESULT_CODE ZEND_MODULE_POST_ZEND_DEACTIVATE_N(module)(void) +#define ZEND_MODULE_STARTUP_D(module) zend_result ZEND_MODULE_STARTUP_N(module)(INIT_FUNC_ARGS) +#define ZEND_MODULE_SHUTDOWN_D(module) zend_result ZEND_MODULE_SHUTDOWN_N(module)(SHUTDOWN_FUNC_ARGS) +#define ZEND_MODULE_ACTIVATE_D(module) zend_result ZEND_MODULE_ACTIVATE_N(module)(INIT_FUNC_ARGS) +#define ZEND_MODULE_DEACTIVATE_D(module) zend_result ZEND_MODULE_DEACTIVATE_N(module)(SHUTDOWN_FUNC_ARGS) +#define ZEND_MODULE_POST_ZEND_DEACTIVATE_D(module) zend_result ZEND_MODULE_POST_ZEND_DEACTIVATE_N(module)(void) #define ZEND_MODULE_INFO_D(module) ZEND_COLD void ZEND_MODULE_INFO_N(module)(ZEND_MODULE_INFO_FUNC_ARGS) #define ZEND_MODULE_GLOBALS_CTOR_D(module) void ZEND_MODULE_GLOBALS_CTOR_N(module)(zend_##module##_globals *module##_globals) #define ZEND_MODULE_GLOBALS_DTOR_D(module) void ZEND_MODULE_GLOBALS_DTOR_N(module)(zend_##module##_globals *module##_globals) @@ -283,10 +283,10 @@ typedef struct _zend_fcall_info_cache { ZEND_API int zend_next_free_module(void); BEGIN_EXTERN_C() -ZEND_API ZEND_RESULT_CODE _zend_get_parameters_array_ex(uint32_t param_count, zval *argument_array); +ZEND_API zend_result _zend_get_parameters_array_ex(uint32_t param_count, zval *argument_array); /* internal function to efficiently copy parameters when executing __call() */ -ZEND_API ZEND_RESULT_CODE zend_copy_parameters_array(uint32_t param_count, zval *argument_array); +ZEND_API zend_result zend_copy_parameters_array(uint32_t param_count, zval *argument_array); #define zend_get_parameters_array(ht, param_count, argument_array) \ _zend_get_parameters_array_ex(param_count, argument_array) @@ -301,27 +301,27 @@ ZEND_API ZEND_RESULT_CODE zend_copy_parameters_array(uint32_t param_count, zval #define ZEND_PARSE_PARAMS_THROW 0 /* No longer used, zpp always uses exceptions */ #define ZEND_PARSE_PARAMS_QUIET (1<<1) -ZEND_API ZEND_RESULT_CODE zend_parse_parameters(uint32_t num_args, const char *type_spec, ...); -ZEND_API ZEND_RESULT_CODE zend_parse_parameters_ex(int flags, uint32_t num_args, const char *type_spec, ...); +ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec, ...); +ZEND_API zend_result zend_parse_parameters_ex(int flags, uint32_t num_args, const char *type_spec, ...); /* NOTE: This must have at least one value in __VA_ARGS__ for the expression to be valid */ #define zend_parse_parameters_throw(num_args, ...) \ zend_parse_parameters(num_args, __VA_ARGS__) ZEND_API const char *zend_zval_type_name(const zval *arg); ZEND_API zend_string *zend_zval_get_legacy_type(const zval *arg); -ZEND_API ZEND_RESULT_CODE zend_parse_method_parameters(uint32_t num_args, zval *this_ptr, const char *type_spec, ...); -ZEND_API ZEND_RESULT_CODE zend_parse_method_parameters_ex(int flags, uint32_t num_args, zval *this_ptr, const char *type_spec, ...); +ZEND_API zend_result zend_parse_method_parameters(uint32_t num_args, zval *this_ptr, const char *type_spec, ...); +ZEND_API zend_result zend_parse_method_parameters_ex(int flags, uint32_t num_args, zval *this_ptr, const char *type_spec, ...); -ZEND_API ZEND_RESULT_CODE zend_parse_parameter(int flags, uint32_t arg_num, zval *arg, const char *spec, ...); +ZEND_API zend_result zend_parse_parameter(int flags, uint32_t arg_num, zval *arg, const char *spec, ...); /* End of parameter parsing API -- andrei */ -ZEND_API ZEND_RESULT_CODE zend_register_functions(zend_class_entry *scope, const zend_function_entry *functions, HashTable *function_table, int type); +ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend_function_entry *functions, HashTable *function_table, int type); ZEND_API void zend_unregister_functions(const zend_function_entry *functions, int count, HashTable *function_table); -ZEND_API ZEND_RESULT_CODE zend_startup_module(zend_module_entry *module_entry); +ZEND_API zend_result zend_startup_module(zend_module_entry *module_entry); ZEND_API zend_module_entry* zend_register_internal_module(zend_module_entry *module_entry); ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module); -ZEND_API ZEND_RESULT_CODE zend_startup_module_ex(zend_module_entry *module); +ZEND_API zend_result zend_startup_module_ex(zend_module_entry *module); ZEND_API void zend_startup_modules(void); ZEND_API void zend_collect_module_handlers(void); ZEND_API void zend_destroy_modules(void); @@ -334,15 +334,15 @@ ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *cla ZEND_API zend_class_entry *zend_register_internal_interface(zend_class_entry *orig_class_entry); ZEND_API void zend_class_implements(zend_class_entry *class_entry, int num_interfaces, ...); -ZEND_API ZEND_RESULT_CODE zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce, bool persistent); +ZEND_API zend_result zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce, bool persistent); #define zend_register_class_alias(name, ce) \ zend_register_class_alias_ex(name, sizeof(name)-1, ce, 1) #define zend_register_ns_class_alias(ns, name, ce) \ zend_register_class_alias_ex(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, ce, 1) -ZEND_API ZEND_RESULT_CODE zend_disable_function(const char *function_name, size_t function_name_length); -ZEND_API ZEND_RESULT_CODE zend_disable_class(const char *class_name, size_t class_name_length); +ZEND_API zend_result zend_disable_function(const char *function_name, size_t function_name_length); +ZEND_API zend_result zend_disable_class(const char *class_name, size_t class_name_length); ZEND_API ZEND_COLD void zend_wrong_param_count(void); @@ -378,7 +378,7 @@ ZEND_API void zend_declare_class_constant_double(zend_class_entry *ce, const cha ZEND_API void zend_declare_class_constant_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_length); ZEND_API void zend_declare_class_constant_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value); -ZEND_API ZEND_RESULT_CODE zend_update_class_constants(zend_class_entry *class_type); +ZEND_API zend_result zend_update_class_constants(zend_class_entry *class_type); ZEND_API void zend_update_property_ex(zend_class_entry *scope, zend_object *object, zend_string *name, zval *value); ZEND_API void zend_update_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, zval *value); @@ -391,14 +391,14 @@ ZEND_API void zend_update_property_string(zend_class_entry *scope, zend_object * ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, const char *value, size_t value_length); ZEND_API void zend_unset_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length); -ZEND_API ZEND_RESULT_CODE zend_update_static_property_ex(zend_class_entry *scope, zend_string *name, zval *value); -ZEND_API ZEND_RESULT_CODE zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value); -ZEND_API ZEND_RESULT_CODE zend_update_static_property_null(zend_class_entry *scope, const char *name, size_t name_length); -ZEND_API ZEND_RESULT_CODE zend_update_static_property_bool(zend_class_entry *scope, const char *name, size_t name_length, zend_long value); -ZEND_API ZEND_RESULT_CODE zend_update_static_property_long(zend_class_entry *scope, const char *name, size_t name_length, zend_long value); -ZEND_API ZEND_RESULT_CODE zend_update_static_property_double(zend_class_entry *scope, const char *name, size_t name_length, double value); -ZEND_API ZEND_RESULT_CODE zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value); -ZEND_API ZEND_RESULT_CODE zend_update_static_property_stringl(zend_class_entry *scope, const char *name, size_t name_length, const char *value, size_t value_length); +ZEND_API zend_result zend_update_static_property_ex(zend_class_entry *scope, zend_string *name, zval *value); +ZEND_API zend_result zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value); +ZEND_API zend_result zend_update_static_property_null(zend_class_entry *scope, const char *name, size_t name_length); +ZEND_API zend_result zend_update_static_property_bool(zend_class_entry *scope, const char *name, size_t name_length, zend_long value); +ZEND_API zend_result zend_update_static_property_long(zend_class_entry *scope, const char *name, size_t name_length, zend_long value); +ZEND_API zend_result zend_update_static_property_double(zend_class_entry *scope, const char *name, size_t name_length, double value); +ZEND_API zend_result zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value); +ZEND_API zend_result zend_update_static_property_stringl(zend_class_entry *scope, const char *name, size_t name_length, const char *value, size_t value_length); ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zend_object *object, zend_string *name, zend_bool silent, zval *rv); ZEND_API zval *zend_read_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, zend_bool silent, zval *rv); @@ -426,8 +426,8 @@ ZEND_API const char *zend_get_type_by_const(int type); #define array_init(arg) ZVAL_ARR((arg), zend_new_array(0)) #define array_init_size(arg, size) ZVAL_ARR((arg), zend_new_array(size)) ZEND_API void object_init(zval *arg); -ZEND_API ZEND_RESULT_CODE object_init_ex(zval *arg, zend_class_entry *ce); -ZEND_API ZEND_RESULT_CODE object_and_properties_init(zval *arg, zend_class_entry *ce, HashTable *properties); +ZEND_API zend_result object_init_ex(zval *arg, zend_class_entry *ce); +ZEND_API zend_result object_and_properties_init(zval *arg, zend_class_entry *ce, HashTable *properties); ZEND_API void object_properties_init(zend_object *object, zend_class_entry *class_type); ZEND_API void object_properties_init_ex(zend_object *object, HashTable *properties); ZEND_API void object_properties_load(zend_object *object, HashTable *properties); @@ -463,26 +463,26 @@ ZEND_API void add_index_str(zval *arg, zend_ulong index, zend_string *str); ZEND_API void add_index_string(zval *arg, zend_ulong index, const char *str); ZEND_API void add_index_stringl(zval *arg, zend_ulong index, const char *str, size_t length); -static zend_always_inline ZEND_RESULT_CODE add_index_zval(zval *arg, zend_ulong index, zval *value) +static zend_always_inline zend_result add_index_zval(zval *arg, zend_ulong index, zval *value) { return zend_hash_index_update(Z_ARRVAL_P(arg), index, value) ? SUCCESS : FAILURE; } -ZEND_API ZEND_RESULT_CODE add_next_index_long(zval *arg, zend_long n); -ZEND_API ZEND_RESULT_CODE add_next_index_null(zval *arg); -ZEND_API ZEND_RESULT_CODE add_next_index_bool(zval *arg, zend_bool b); -ZEND_API ZEND_RESULT_CODE add_next_index_resource(zval *arg, zend_resource *r); -ZEND_API ZEND_RESULT_CODE add_next_index_double(zval *arg, double d); -ZEND_API ZEND_RESULT_CODE add_next_index_str(zval *arg, zend_string *str); -ZEND_API ZEND_RESULT_CODE add_next_index_string(zval *arg, const char *str); -ZEND_API ZEND_RESULT_CODE add_next_index_stringl(zval *arg, const char *str, size_t length); +ZEND_API zend_result add_next_index_long(zval *arg, zend_long n); +ZEND_API zend_result add_next_index_null(zval *arg); +ZEND_API zend_result add_next_index_bool(zval *arg, zend_bool b); +ZEND_API zend_result add_next_index_resource(zval *arg, zend_resource *r); +ZEND_API zend_result add_next_index_double(zval *arg, double d); +ZEND_API zend_result add_next_index_str(zval *arg, zend_string *str); +ZEND_API zend_result add_next_index_string(zval *arg, const char *str); +ZEND_API zend_result add_next_index_stringl(zval *arg, const char *str, size_t length); -static zend_always_inline ZEND_RESULT_CODE add_next_index_zval(zval *arg, zval *value) +static zend_always_inline zend_result add_next_index_zval(zval *arg, zval *value) { return zend_hash_next_index_insert(Z_ARRVAL_P(arg), value) ? SUCCESS : FAILURE; } -ZEND_API ZEND_RESULT_CODE array_set_zval_key(HashTable *ht, zval *key, zval *value); +ZEND_API zend_result array_set_zval_key(HashTable *ht, zval *key, zval *value); ZEND_API void add_property_long_ex(zval *arg, const char *key, size_t key_len, zend_long l); ZEND_API void add_property_null_ex(zval *arg, const char *key, size_t key_len); @@ -505,7 +505,7 @@ ZEND_API void add_property_zval_ex(zval *arg, const char *key, size_t key_len, z #define add_property_zval(__arg, __key, __value) add_property_zval_ex(__arg, __key, strlen(__key), __value) -ZEND_API ZEND_RESULT_CODE _call_user_function_impl(zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], HashTable *named_params); +ZEND_API zend_result _call_user_function_impl(zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], HashTable *named_params); #define call_user_function(function_table, object, function_name, retval_ptr, param_count, params) \ _call_user_function_impl(object, function_name, retval_ptr, param_count, params, NULL) @@ -524,7 +524,7 @@ ZEND_API extern const zend_fcall_info_cache empty_fcall_info_cache; * fci->params = NULL; * The callable_name argument may be NULL. */ -ZEND_API ZEND_RESULT_CODE zend_fcall_info_init(zval *callable, uint32_t check_flags, zend_fcall_info *fci, zend_fcall_info_cache *fcc, zend_string **callable_name, char **error); +ZEND_API zend_result zend_fcall_info_init(zval *callable, uint32_t check_flags, zend_fcall_info *fci, zend_fcall_info_cache *fcc, zend_string **callable_name, char **error); /** Clear arguments connected with zend_fcall_info *fci * If free_mem is not zero then the params array gets free'd as well @@ -543,8 +543,8 @@ ZEND_API void zend_fcall_info_args_restore(zend_fcall_info *fci, uint32_t param_ /** Set or clear the arguments in the zend_call_info struct taking care of * refcount. If args is NULL and arguments are set then those are cleared. */ -ZEND_API ZEND_RESULT_CODE zend_fcall_info_args(zend_fcall_info *fci, zval *args); -ZEND_API ZEND_RESULT_CODE zend_fcall_info_args_ex(zend_fcall_info *fci, zend_function *func, zval *args); +ZEND_API zend_result zend_fcall_info_args(zend_fcall_info *fci, zval *args); +ZEND_API zend_result zend_fcall_info_args_ex(zend_fcall_info *fci, zend_function *func, zval *args); /** Set arguments in the zend_fcall_info struct taking care of refcount. * If argc is 0 the arguments which are set will be cleared, else pass @@ -567,9 +567,9 @@ ZEND_API void zend_fcall_info_argn(zend_fcall_info *fci, uint32_t argc, ...); /** Call a function using information created by zend_fcall_info_init()/args(). * If args is given then those replace the argument info in fci is temporarily. */ -ZEND_API ZEND_RESULT_CODE zend_fcall_info_call(zend_fcall_info *fci, zend_fcall_info_cache *fcc, zval *retval, zval *args); +ZEND_API zend_result zend_fcall_info_call(zend_fcall_info *fci, zend_fcall_info_cache *fcc, zval *retval, zval *args); -ZEND_API ZEND_RESULT_CODE zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache); +ZEND_API zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache); /* Call the provided zend_function with the given params. * If retval_ptr is NULL, the return value is discarded. @@ -602,17 +602,17 @@ static zend_always_inline void zend_call_known_instance_method_with_1_params( ZEND_API void zend_call_known_instance_method_with_2_params( zend_function *fn, zend_object *object, zval *retval_ptr, zval *param1, zval *param2); -ZEND_API ZEND_RESULT_CODE zend_set_hash_symbol(zval *symbol, const char *name, size_t name_length, zend_bool is_ref, int num_symbol_tables, ...); +ZEND_API zend_result zend_set_hash_symbol(zval *symbol, const char *name, size_t name_length, zend_bool is_ref, int num_symbol_tables, ...); -ZEND_API ZEND_RESULT_CODE zend_delete_global_variable(zend_string *name); +ZEND_API zend_result zend_delete_global_variable(zend_string *name); ZEND_API zend_array *zend_rebuild_symbol_table(void); ZEND_API void zend_attach_symbol_table(zend_execute_data *execute_data); ZEND_API void zend_detach_symbol_table(zend_execute_data *execute_data); -ZEND_API ZEND_RESULT_CODE zend_set_local_var(zend_string *name, zval *value, bool force); -ZEND_API ZEND_RESULT_CODE zend_set_local_var_str(const char *name, size_t len, zval *value, bool force); +ZEND_API zend_result zend_set_local_var(zend_string *name, zval *value, bool force); +ZEND_API zend_result zend_set_local_var_str(const char *name, size_t len, zval *value, bool force); -static zend_always_inline ZEND_RESULT_CODE zend_forbid_dynamic_call(const char *func_name) +static zend_always_inline zend_result zend_forbid_dynamic_call(const char *func_name) { zend_execute_data *ex = EG(current_execute_data); ZEND_ASSERT(ex != NULL && ex->func != NULL); @@ -631,7 +631,7 @@ ZEND_API zend_bool zend_is_iterable(zval *iterable); ZEND_API zend_bool zend_is_countable(zval *countable); -ZEND_API ZEND_RESULT_CODE zend_get_default_from_internal_arg_info( +ZEND_API zend_result zend_get_default_from_internal_arg_info( zval *default_value_zval, zend_internal_arg_info *arg_info); END_EXTERN_C() @@ -779,21 +779,21 @@ END_EXTERN_C() /* May modify arg in-place. Will free arg in failure case (and take ownership in success case). * Prefer using the ZEND_TRY_ASSIGN_* macros over these APIs. */ -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_ex(zend_reference *ref, zval *zv, zend_bool strict); -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref(zend_reference *ref, zval *zv); - -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_null(zend_reference *ref); -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_bool(zend_reference *ref, zend_bool val); -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_long(zend_reference *ref, zend_long lval); -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_double(zend_reference *ref, double dval); -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_empty_string(zend_reference *ref); -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_str(zend_reference *ref, zend_string *str); -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_string(zend_reference *ref, const char *string); -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_stringl(zend_reference *ref, const char *string, size_t len); -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_arr(zend_reference *ref, zend_array *arr); -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_res(zend_reference *ref, zend_resource *res); -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_zval(zend_reference *ref, zval *zv); -ZEND_API ZEND_RESULT_CODE zend_try_assign_typed_ref_zval_ex(zend_reference *ref, zval *zv, zend_bool strict); +ZEND_API zend_result zend_try_assign_typed_ref_ex(zend_reference *ref, zval *zv, zend_bool strict); +ZEND_API zend_result zend_try_assign_typed_ref(zend_reference *ref, zval *zv); + +ZEND_API zend_result zend_try_assign_typed_ref_null(zend_reference *ref); +ZEND_API zend_result zend_try_assign_typed_ref_bool(zend_reference *ref, zend_bool val); +ZEND_API zend_result zend_try_assign_typed_ref_long(zend_reference *ref, zend_long lval); +ZEND_API zend_result zend_try_assign_typed_ref_double(zend_reference *ref, double dval); +ZEND_API zend_result zend_try_assign_typed_ref_empty_string(zend_reference *ref); +ZEND_API zend_result zend_try_assign_typed_ref_str(zend_reference *ref, zend_string *str); +ZEND_API zend_result zend_try_assign_typed_ref_string(zend_reference *ref, const char *string); +ZEND_API zend_result zend_try_assign_typed_ref_stringl(zend_reference *ref, const char *string, size_t len); +ZEND_API zend_result zend_try_assign_typed_ref_arr(zend_reference *ref, zend_array *arr); +ZEND_API zend_result zend_try_assign_typed_ref_res(zend_reference *ref, zend_resource *res); +ZEND_API zend_result zend_try_assign_typed_ref_zval(zend_reference *ref, zval *zv); +ZEND_API zend_result zend_try_assign_typed_ref_zval_ex(zend_reference *ref, zval *zv, zend_bool strict); #define _ZEND_TRY_ASSIGN_NULL(zv, is_ref) do { \ zval *_zv = zv; \ diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index c417189dd30fd..f746b408a1f84 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -438,7 +438,7 @@ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_list_add(zend_ast *ast, zend_ast *op) return (zend_ast *) list; } -static ZEND_RESULT_CODE zend_ast_add_array_element(zval *result, zval *offset, zval *expr) +static zend_result zend_ast_add_array_element(zval *result, zval *offset, zval *expr) { switch (Z_TYPE_P(offset)) { case IS_UNDEF: @@ -478,7 +478,7 @@ static ZEND_RESULT_CODE zend_ast_add_array_element(zval *result, zval *offset, z return SUCCESS; } -static ZEND_RESULT_CODE zend_ast_add_unpacked_element(zval *result, zval *expr) { +static zend_result zend_ast_add_unpacked_element(zval *result, zval *expr) { if (EXPECTED(Z_TYPE_P(expr) == IS_ARRAY)) { HashTable *ht = Z_ARRVAL_P(expr); zval *val; @@ -505,10 +505,10 @@ static ZEND_RESULT_CODE zend_ast_add_unpacked_element(zval *result, zval *expr) return FAILURE; } -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *scope) +ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *scope) { zval op1, op2; - ZEND_RESULT_CODE ret = SUCCESS; + zend_result ret = SUCCESS; switch (ast->kind) { case ZEND_AST_BINARY_OP: diff --git a/Zend/zend_ast.h b/Zend/zend_ast.h index 36f1ab665939f..2d72759c392a4 100644 --- a/Zend/zend_ast.h +++ b/Zend/zend_ast.h @@ -290,7 +290,7 @@ ZEND_API zend_ast *zend_ast_create_decl( zend_string *name, zend_ast *child0, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4 ); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *scope); +ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *scope); ZEND_API zend_string *zend_ast_export(const char *prefix, zend_ast *ast, const char *suffix); ZEND_API zend_ast_ref * ZEND_FASTCALL zend_ast_copy(zend_ast *ast); diff --git a/Zend/zend_attributes.c b/Zend/zend_attributes.c index 6ff35cbe4cd3c..af5baa6ce07d1 100644 --- a/Zend/zend_attributes.c +++ b/Zend/zend_attributes.c @@ -116,7 +116,7 @@ ZEND_API zend_attribute *zend_get_parameter_attribute_str(HashTable *attributes, return get_attribute_str(attributes, str, len, offset + 1); } -ZEND_API ZEND_RESULT_CODE zend_get_attribute_value(zval *ret, zend_attribute *attr, uint32_t i, zend_class_entry *scope) +ZEND_API zend_result zend_get_attribute_value(zval *ret, zend_attribute *attr, uint32_t i, zend_class_entry *scope) { if (i >= attr->argc) { return FAILURE; diff --git a/Zend/zend_attributes.h b/Zend/zend_attributes.h index 02b0311a3465b..6a60b06665a8f 100644 --- a/Zend/zend_attributes.h +++ b/Zend/zend_attributes.h @@ -63,7 +63,7 @@ ZEND_API zend_attribute *zend_get_attribute_str(HashTable *attributes, const cha ZEND_API zend_attribute *zend_get_parameter_attribute(HashTable *attributes, zend_string *lcname, uint32_t offset); ZEND_API zend_attribute *zend_get_parameter_attribute_str(HashTable *attributes, const char *str, size_t len, uint32_t offset); -ZEND_API ZEND_RESULT_CODE zend_get_attribute_value(zval *ret, zend_attribute *attr, uint32_t i, zend_class_entry *scope); +ZEND_API zend_result zend_get_attribute_value(zval *ret, zend_attribute *attr, uint32_t i, zend_class_entry *scope); ZEND_API zend_string *zend_get_attribute_target_names(uint32_t targets); ZEND_API zend_bool zend_is_attribute_repeated(HashTable *attributes, zend_attribute *attr); diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index ba10e62522259..c3a2a1b63f331 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -57,7 +57,7 @@ zend_module_entry zend_builtin_module = { /* {{{ */ }; /* }}} */ -ZEND_RESULT_CODE zend_startup_builtin_functions(void) /* {{{ */ +zend_result zend_startup_builtin_functions(void) /* {{{ */ { zend_builtin_module.module_number = 0; zend_builtin_module.type = MODULE_PERSISTENT; diff --git a/Zend/zend_builtin_functions.h b/Zend/zend_builtin_functions.h index 4fda0e0abfa14..a49dab1b46838 100644 --- a/Zend/zend_builtin_functions.h +++ b/Zend/zend_builtin_functions.h @@ -20,7 +20,7 @@ #ifndef ZEND_BUILTIN_FUNCTIONS_H #define ZEND_BUILTIN_FUNCTIONS_H -ZEND_RESULT_CODE zend_startup_builtin_functions(void); +zend_result zend_startup_builtin_functions(void); BEGIN_EXTERN_C() ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int options, int limit); diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index b2d6456cf7727..630857f26c1df 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -273,7 +273,7 @@ static ZEND_NAMED_FUNCTION(zend_closure_call_magic) /* {{{ */ { } /* }}} */ -static ZEND_RESULT_CODE zend_create_closure_from_callable(zval *return_value, zval *callable, char **error) /* {{{ */ { +static zend_result zend_create_closure_from_callable(zval *return_value, zval *callable, char **error) /* {{{ */ { zend_fcall_info_cache fcc; zend_function *mptr; zval instance; diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 3396c933e6658..b54b435ae9f62 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1076,7 +1076,7 @@ static zend_never_inline ZEND_COLD ZEND_NORETURN void do_bind_function_error(zen } } -ZEND_API ZEND_RESULT_CODE do_bind_function(zval *lcname) /* {{{ */ +ZEND_API zend_result do_bind_function(zval *lcname) /* {{{ */ { zend_function *function; zval *rtd_key, *zv; @@ -1097,7 +1097,7 @@ ZEND_API ZEND_RESULT_CODE do_bind_function(zval *lcname) /* {{{ */ } /* }}} */ -ZEND_API ZEND_RESULT_CODE do_bind_class(zval *lcname, zend_string *lc_parent_name) /* {{{ */ +ZEND_API zend_result do_bind_class(zval *lcname, zend_string *lc_parent_name) /* {{{ */ { zend_class_entry *ce; zval *rtd_key, *zv; @@ -1376,7 +1376,7 @@ static zend_always_inline size_t zend_strnlen(const char* s, size_t maxlen) /* { } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_unmangle_property_name_ex(const zend_string *name, const char **class_name, const char **prop_name, size_t *prop_len) /* {{{ */ +ZEND_API zend_result zend_unmangle_property_name_ex(const zend_string *name, const char **class_name, const char **prop_name, size_t *prop_len) /* {{{ */ { size_t class_name_len; size_t anonclass_src_len; @@ -1749,10 +1749,10 @@ zend_bool zend_is_auto_global(zend_string *name) /* {{{ */ } /* }}} */ -ZEND_RESULT_CODE zend_register_auto_global(zend_string *name, zend_bool jit, zend_auto_global_callback auto_global_callback) /* {{{ */ +zend_result zend_register_auto_global(zend_string *name, zend_bool jit, zend_auto_global_callback auto_global_callback) /* {{{ */ { zend_auto_global auto_global; - ZEND_RESULT_CODE retval; + zend_result retval; auto_global.name = name; auto_global.auto_global_callback = auto_global_callback; @@ -2597,7 +2597,7 @@ static void zend_compile_class_ref(znode *result, zend_ast *name_ast, uint32_t f } /* }}} */ -static ZEND_RESULT_CODE zend_try_compile_cv(znode *result, zend_ast *ast) /* {{{ */ +static zend_result zend_try_compile_cv(znode *result, zend_ast *ast) /* {{{ */ { zend_ast *name_ast = ast->child[0]; if (name_ast->kind == ZEND_AST_ZVAL) { @@ -3637,7 +3637,7 @@ static inline zend_bool zend_args_contain_unpack_or_named(zend_ast_list *args) / } /* }}} */ -ZEND_RESULT_CODE zend_compile_func_strlen(znode *result, zend_ast_list *args) /* {{{ */ +zend_result zend_compile_func_strlen(znode *result, zend_ast_list *args) /* {{{ */ { znode arg_node; @@ -3657,7 +3657,7 @@ ZEND_RESULT_CODE zend_compile_func_strlen(znode *result, zend_ast_list *args) /* } /* }}} */ -ZEND_RESULT_CODE zend_compile_func_typecheck(znode *result, zend_ast_list *args, uint32_t type) /* {{{ */ +zend_result zend_compile_func_typecheck(znode *result, zend_ast_list *args, uint32_t type) /* {{{ */ { znode arg_node; zend_op *opline; @@ -3677,7 +3677,7 @@ ZEND_RESULT_CODE zend_compile_func_typecheck(znode *result, zend_ast_list *args, } /* }}} */ -static ZEND_RESULT_CODE zend_compile_func_is_scalar(znode *result, zend_ast_list *args) /* {{{ */ +static zend_result zend_compile_func_is_scalar(znode *result, zend_ast_list *args) /* {{{ */ { znode arg_node; zend_op *opline; @@ -3692,7 +3692,7 @@ static ZEND_RESULT_CODE zend_compile_func_is_scalar(znode *result, zend_ast_list return SUCCESS; } -ZEND_RESULT_CODE zend_compile_func_cast(znode *result, zend_ast_list *args, uint32_t type) /* {{{ */ +zend_result zend_compile_func_cast(znode *result, zend_ast_list *args, uint32_t type) /* {{{ */ { znode arg_node; zend_op *opline; @@ -3712,7 +3712,7 @@ ZEND_RESULT_CODE zend_compile_func_cast(znode *result, zend_ast_list *args, uint } /* }}} */ -ZEND_RESULT_CODE zend_compile_func_defined(znode *result, zend_ast_list *args) /* {{{ */ +zend_result zend_compile_func_defined(znode *result, zend_ast_list *args) /* {{{ */ { zend_string *name; zend_op *opline; @@ -3744,7 +3744,7 @@ ZEND_RESULT_CODE zend_compile_func_defined(znode *result, zend_ast_list *args) / } /* }}} */ -ZEND_RESULT_CODE zend_compile_func_chr(znode *result, zend_ast_list *args) /* {{{ */ +zend_result zend_compile_func_chr(znode *result, zend_ast_list *args) /* {{{ */ { if (args->children == 1 && @@ -3762,7 +3762,7 @@ ZEND_RESULT_CODE zend_compile_func_chr(znode *result, zend_ast_list *args) /* {{ } /* }}} */ -ZEND_RESULT_CODE zend_compile_func_ord(znode *result, zend_ast_list *args) /* {{{ */ +zend_result zend_compile_func_ord(znode *result, zend_ast_list *args) /* {{{ */ { if (args->children == 1 && args->child[0]->kind == ZEND_AST_ZVAL && @@ -3784,7 +3784,7 @@ static zend_bool fbc_is_finalized(zend_function *fbc) { return !ZEND_USER_CODE(fbc->type) || (fbc->common.fn_flags & ZEND_ACC_DONE_PASS_TWO); } -static ZEND_RESULT_CODE zend_try_compile_ct_bound_init_user_func(zend_ast *name_ast, uint32_t num_args) /* {{{ */ +static zend_result zend_try_compile_ct_bound_init_user_func(zend_ast *name_ast, uint32_t num_args) /* {{{ */ { zend_string *name, *lcname; zend_function *fbc; @@ -3837,7 +3837,7 @@ static void zend_compile_init_user_func(zend_ast *name_ast, uint32_t num_args, z /* }}} */ /* cufa = call_user_func_array */ -ZEND_RESULT_CODE zend_compile_func_cufa(znode *result, zend_ast_list *args, zend_string *lcname) /* {{{ */ +zend_result zend_compile_func_cufa(znode *result, zend_ast_list *args, zend_string *lcname) /* {{{ */ { znode arg_node; @@ -3887,7 +3887,7 @@ ZEND_RESULT_CODE zend_compile_func_cufa(znode *result, zend_ast_list *args, zend /* }}} */ /* cuf = call_user_func */ -ZEND_RESULT_CODE zend_compile_func_cuf(znode *result, zend_ast_list *args, zend_string *lcname) /* {{{ */ +zend_result zend_compile_func_cuf(znode *result, zend_ast_list *args, zend_string *lcname) /* {{{ */ { uint32_t i; @@ -3958,7 +3958,7 @@ static void zend_compile_assert(znode *result, zend_ast_list *args, zend_string } /* }}} */ -static ZEND_RESULT_CODE zend_compile_func_in_array(znode *result, zend_ast_list *args) /* {{{ */ +static zend_result zend_compile_func_in_array(znode *result, zend_ast_list *args) /* {{{ */ { zend_bool strict = 0; znode array, needly; @@ -4043,7 +4043,7 @@ static ZEND_RESULT_CODE zend_compile_func_in_array(znode *result, zend_ast_list } /* }}} */ -ZEND_RESULT_CODE zend_compile_func_count(znode *result, zend_ast_list *args, zend_string *lcname) /* {{{ */ +zend_result zend_compile_func_count(znode *result, zend_ast_list *args, zend_string *lcname) /* {{{ */ { znode arg_node; zend_op *opline; @@ -4060,7 +4060,7 @@ ZEND_RESULT_CODE zend_compile_func_count(znode *result, zend_ast_list *args, zen } /* }}} */ -ZEND_RESULT_CODE zend_compile_func_get_class(znode *result, zend_ast_list *args) /* {{{ */ +zend_result zend_compile_func_get_class(znode *result, zend_ast_list *args) /* {{{ */ { if (args->children == 0) { zend_emit_op_tmp(result, ZEND_GET_CLASS, NULL, NULL); @@ -4078,7 +4078,7 @@ ZEND_RESULT_CODE zend_compile_func_get_class(znode *result, zend_ast_list *args) } /* }}} */ -ZEND_RESULT_CODE zend_compile_func_get_called_class(znode *result, zend_ast_list *args) /* {{{ */ +zend_result zend_compile_func_get_called_class(znode *result, zend_ast_list *args) /* {{{ */ { if (args->children != 0) { return FAILURE; @@ -4089,7 +4089,7 @@ ZEND_RESULT_CODE zend_compile_func_get_called_class(znode *result, zend_ast_list } /* }}} */ -ZEND_RESULT_CODE zend_compile_func_gettype(znode *result, zend_ast_list *args) /* {{{ */ +zend_result zend_compile_func_gettype(znode *result, zend_ast_list *args) /* {{{ */ { znode arg_node; @@ -4103,7 +4103,7 @@ ZEND_RESULT_CODE zend_compile_func_gettype(znode *result, zend_ast_list *args) / } /* }}} */ -ZEND_RESULT_CODE zend_compile_func_num_args(znode *result, zend_ast_list *args) /* {{{ */ +zend_result zend_compile_func_num_args(znode *result, zend_ast_list *args) /* {{{ */ { if (CG(active_op_array)->function_name && args->children == 0) { zend_emit_op_tmp(result, ZEND_FUNC_NUM_ARGS, NULL, NULL); @@ -4114,7 +4114,7 @@ ZEND_RESULT_CODE zend_compile_func_num_args(znode *result, zend_ast_list *args) } /* }}} */ -ZEND_RESULT_CODE zend_compile_func_get_args(znode *result, zend_ast_list *args) /* {{{ */ +zend_result zend_compile_func_get_args(znode *result, zend_ast_list *args) /* {{{ */ { if (CG(active_op_array)->function_name && args->children == 0) { zend_emit_op_tmp(result, ZEND_FUNC_GET_ARGS, NULL, NULL); @@ -4125,7 +4125,7 @@ ZEND_RESULT_CODE zend_compile_func_get_args(znode *result, zend_ast_list *args) } /* }}} */ -ZEND_RESULT_CODE zend_compile_func_array_key_exists(znode *result, zend_ast_list *args) /* {{{ */ +zend_result zend_compile_func_array_key_exists(znode *result, zend_ast_list *args) /* {{{ */ { znode subject, needle; @@ -4141,7 +4141,7 @@ ZEND_RESULT_CODE zend_compile_func_array_key_exists(znode *result, zend_ast_list } /* }}} */ -ZEND_RESULT_CODE zend_compile_func_array_slice(znode *result, zend_ast_list *args) /* {{{ */ +zend_result zend_compile_func_array_slice(znode *result, zend_ast_list *args) /* {{{ */ { if (CG(active_op_array)->function_name && args->children == 2 @@ -4174,7 +4174,7 @@ ZEND_RESULT_CODE zend_compile_func_array_slice(znode *result, zend_ast_list *arg } /* }}} */ -ZEND_RESULT_CODE zend_try_compile_special_func(znode *result, zend_string *lcname, zend_ast_list *args, zend_function *fbc, uint32_t type) /* {{{ */ +zend_result zend_try_compile_special_func(znode *result, zend_string *lcname, zend_ast_list *args, zend_function *fbc, uint32_t type) /* {{{ */ { if (CG(compiler_options) & ZEND_COMPILE_NO_BUILTINS) { return FAILURE; @@ -5859,7 +5859,7 @@ zend_bool zend_handle_encoding_declaration(zend_ast *ast) /* {{{ */ } /* }}} */ -static ZEND_RESULT_CODE zend_declare_is_first_statement(zend_ast *ast) /* {{{ */ +static zend_result zend_declare_is_first_statement(zend_ast *ast) /* {{{ */ { uint32_t i = 0; zend_ast_list *file_ast = zend_ast_get_list(CG(ast)); diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 6dee886022832..e50f620ed4078 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -751,8 +751,8 @@ const char *zend_get_zendtext(void); int zend_get_zendleng(void); #endif -typedef ZEND_RESULT_CODE (ZEND_FASTCALL *unary_op_type)(zval *, zval *); -typedef ZEND_RESULT_CODE (ZEND_FASTCALL *binary_op_type)(zval *, zval *, zval *); +typedef zend_result (ZEND_FASTCALL *unary_op_type)(zval *, zval *); +typedef zend_result (ZEND_FASTCALL *binary_op_type)(zval *, zval *, zval *); ZEND_API unary_op_type get_unary_op(int opcode); ZEND_API binary_op_type get_binary_op(int opcode); @@ -770,8 +770,8 @@ zend_bool zend_handle_encoding_declaration(zend_ast *ast); /* parser-driven code generators */ void zend_do_free(znode *op1); -ZEND_API ZEND_RESULT_CODE do_bind_function(zval *lcname); -ZEND_API ZEND_RESULT_CODE do_bind_class(zval *lcname, zend_string *lc_parent_name); +ZEND_API zend_result do_bind_function(zval *lcname); +ZEND_API zend_result do_bind_class(zval *lcname, zend_string *lc_parent_name); ZEND_API uint32_t zend_build_delayed_early_binding_list(const zend_op_array *op_array); ZEND_API void zend_do_delayed_early_binding(zend_op_array *op_array, uint32_t first_early_binding_opline); @@ -826,7 +826,7 @@ void zend_class_add_ref(zval *zv); ZEND_API zend_string *zend_mangle_property_name(const char *src1, size_t src1_length, const char *src2, size_t src2_length, bool internal); #define zend_unmangle_property_name(mangled_property, class_name, prop_name) \ zend_unmangle_property_name_ex(mangled_property, class_name, prop_name, NULL) -ZEND_API ZEND_RESULT_CODE zend_unmangle_property_name_ex(const zend_string *name, const char **class_name, const char **prop_name, size_t *prop_len); +ZEND_API zend_result zend_unmangle_property_name_ex(const zend_string *name, const char **class_name, const char **prop_name, size_t *prop_len); static zend_always_inline const char *zend_get_unmangled_property_name(const zend_string *mangled_prop) { const char *class_name, *prop_name; @@ -857,7 +857,7 @@ typedef struct _zend_auto_global { zend_bool armed; } zend_auto_global; -ZEND_API ZEND_RESULT_CODE zend_register_auto_global(zend_string *name, zend_bool jit, zend_auto_global_callback auto_global_callback); +ZEND_API zend_result zend_register_auto_global(zend_string *name, zend_bool jit, zend_auto_global_callback auto_global_callback); ZEND_API void zend_activate_auto_globals(void); ZEND_API zend_bool zend_is_auto_global(zend_string *name); ZEND_API zend_bool zend_is_auto_global_str(const char *name, size_t len); diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c index 2858fc15000d0..3ad32446ff56c 100644 --- a/Zend/zend_constants.c +++ b/Zend/zend_constants.c @@ -393,7 +393,7 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope, } if (ret_constant && Z_TYPE_P(ret_constant) == IS_CONSTANT_AST) { - ZEND_RESULT_CODE ret; + zend_result ret; if (IS_CONSTANT_VISITED(ret_constant)) { zend_throw_error(NULL, "Cannot declare self-referencing constant %s::%s", ZSTR_VAL(class_name), ZSTR_VAL(constant_name)); @@ -477,11 +477,11 @@ static void* zend_hash_add_constant(HashTable *ht, zend_string *key, zend_consta return ret; } -ZEND_API ZEND_RESULT_CODE zend_register_constant(zend_constant *c) +ZEND_API zend_result zend_register_constant(zend_constant *c) { zend_string *lowercase_name = NULL; zend_string *name; - ZEND_RESULT_CODE ret = SUCCESS; + zend_result ret = SUCCESS; zend_bool persistent = (ZEND_CONSTANT_FLAGS(c) & CONST_PERSISTENT) != 0; #if 0 diff --git a/Zend/zend_constants.h b/Zend/zend_constants.h index 6090623c07820..0a3c5a737760c 100644 --- a/Zend/zend_constants.h +++ b/Zend/zend_constants.h @@ -82,7 +82,7 @@ ZEND_API void zend_register_long_constant(const char *name, size_t name_len, zen ZEND_API void zend_register_double_constant(const char *name, size_t name_len, double dval, int flags, int module_number); ZEND_API void zend_register_string_constant(const char *name, size_t name_len, const char *strval, int flags, int module_number); ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len, const char *strval, size_t strlen, int flags, int module_number); -ZEND_API ZEND_RESULT_CODE zend_register_constant(zend_constant *c); +ZEND_API zend_result zend_register_constant(zend_constant *c); #ifdef ZTS void zend_copy_constants(HashTable *target, HashTable *sourc); #endif diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index ee3a63a50ddeb..709dfa14c727b 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -908,11 +908,11 @@ static void zend_error_va(int type, const char *file, uint32_t lineno, const cha /* }}} */ /* This function doesn't return if it uses E_ERROR */ -ZEND_API ZEND_COLD ZEND_RESULT_CODE zend_exception_error(zend_object *ex, int severity) /* {{{ */ +ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *ex, int severity) /* {{{ */ { zval exception, rv; zend_class_entry *ce_exception; - ZEND_RESULT_CODE result = FAILURE; + zend_result result = FAILURE; ZVAL_OBJ(&exception, ex); ce_exception = ex->ce; diff --git a/Zend/zend_exceptions.h b/Zend/zend_exceptions.h index 78eff15a40e12..9d0c18a6dada5 100644 --- a/Zend/zend_exceptions.h +++ b/Zend/zend_exceptions.h @@ -67,7 +67,7 @@ ZEND_API zend_object *zend_throw_error_exception(zend_class_entry *exception_ce, extern ZEND_API void (*zend_throw_exception_hook)(zend_object *ex); /* show an exception using zend_error(severity,...), severity should be E_ERROR */ -ZEND_API ZEND_COLD ZEND_RESULT_CODE zend_exception_error(zend_object *exception, int severity); +ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *exception, int severity); ZEND_API ZEND_COLD void zend_throw_unwind_exit(void); ZEND_API zend_bool zend_is_unwind_exit(zend_object *ex); diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 8f69f0a0f08a9..c0e6adf79b840 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1899,7 +1899,7 @@ static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_undefined_index(const zend_error(E_WARNING, "Undefined array key \"%s\"", ZSTR_VAL(offset)); } -ZEND_API ZEND_COLD ZEND_RESULT_CODE ZEND_FASTCALL zend_undefined_offset_write(HashTable *ht, zend_long lval) +ZEND_API ZEND_COLD zend_result ZEND_FASTCALL zend_undefined_offset_write(HashTable *ht, zend_long lval) { /* The array may be destroyed while throwing the notice. * Temporarily increase the refcount to detect this situation. */ @@ -1917,7 +1917,7 @@ ZEND_API ZEND_COLD ZEND_RESULT_CODE ZEND_FASTCALL zend_undefined_offset_write(Ha return SUCCESS; } -ZEND_API ZEND_COLD ZEND_RESULT_CODE ZEND_FASTCALL zend_undefined_index_write(HashTable *ht, zend_string *offset) +ZEND_API ZEND_COLD zend_result ZEND_FASTCALL zend_undefined_index_write(HashTable *ht, zend_string *offset) { /* The array may be destroyed while throwing the notice. * Temporarily increase the refcount to detect this situation. */ @@ -2889,7 +2889,7 @@ static zend_never_inline void zend_assign_to_property_reference_var_var(zval *co OPLINE_CC EXECUTE_DATA_CC); } -static zend_never_inline ZEND_RESULT_CODE zend_fetch_static_property_address_ex(zval **retval, zend_property_info **prop_info, uint32_t cache_slot, int fetch_type OPLINE_DC EXECUTE_DATA_DC) { +static zend_never_inline zend_result zend_fetch_static_property_address_ex(zval **retval, zend_property_info **prop_info, uint32_t cache_slot, int fetch_type OPLINE_DC EXECUTE_DATA_DC) { zend_string *name; zend_class_entry *ce; zend_property_info *property_info; @@ -2967,7 +2967,7 @@ static zend_never_inline ZEND_RESULT_CODE zend_fetch_static_property_address_ex( } -static zend_always_inline ZEND_RESULT_CODE zend_fetch_static_property_address(zval **retval, zend_property_info **prop_info, uint32_t cache_slot, int fetch_type, int flags OPLINE_DC EXECUTE_DATA_DC) { +static zend_always_inline zend_result zend_fetch_static_property_address(zval **retval, zend_property_info **prop_info, uint32_t cache_slot, int fetch_type, int flags OPLINE_DC EXECUTE_DATA_DC) { zend_property_info *property_info; if (opline->op1_type == IS_CONST && (opline->op2_type == IS_CONST || (opline->op2_type == IS_UNUSED && (opline->op2.num == ZEND_FETCH_CLASS_SELF || opline->op2.num == ZEND_FETCH_CLASS_PARENT))) && EXPECTED(CACHED_PTR(cache_slot) != NULL)) { @@ -2983,7 +2983,7 @@ static zend_always_inline ZEND_RESULT_CODE zend_fetch_static_property_address(zv return FAILURE; } } else { - ZEND_RESULT_CODE success; + zend_result success; success = zend_fetch_static_property_address_ex(retval, &property_info, cache_slot, fetch_type OPLINE_CC EXECUTE_DATA_CC); if (UNEXPECTED(success != SUCCESS)) { return FAILURE; @@ -4282,7 +4282,7 @@ static zend_never_inline zend_bool ZEND_FASTCALL zend_fe_reset_iterator(zval *ar } /* }}} */ -static zend_always_inline ZEND_RESULT_CODE _zend_quick_get_constant( +static zend_always_inline zend_result _zend_quick_get_constant( const zval *key, uint32_t flags, bool check_defined_only OPLINE_DC EXECUTE_DATA_DC) /* {{{ */ { zval *zv; @@ -4327,7 +4327,7 @@ static zend_never_inline void ZEND_FASTCALL zend_quick_get_constant( _zend_quick_get_constant(key, flags, 0 OPLINE_CC EXECUTE_DATA_CC); } /* }}} */ -static zend_never_inline ZEND_RESULT_CODE ZEND_FASTCALL zend_quick_check_constant( +static zend_never_inline zend_result ZEND_FASTCALL zend_quick_check_constant( const zval *key OPLINE_DC EXECUTE_DATA_DC) /* {{{ */ { return _zend_quick_get_constant(key, 0, 1 OPLINE_CC EXECUTE_DATA_CC); @@ -4450,7 +4450,7 @@ static void end_fake_frame(zend_execute_data *call) { } } -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_handle_undef_args(zend_execute_data *call) { +ZEND_API zend_result ZEND_FASTCALL zend_handle_undef_args(zend_execute_data *call) { zend_function *fbc = call->func; if (fbc->type == ZEND_USER_FUNCTION) { uint32_t num_args = ZEND_CALL_NUM_ARGS(call); @@ -4478,7 +4478,7 @@ ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_handle_undef_args(zend_execute_data zval tmp; ZVAL_COPY(&tmp, default_value); start_fake_frame(call, opline); - ZEND_RESULT_CODE ret = zval_update_constant_ex(&tmp, fbc->op_array.scope); + zend_result ret = zval_update_constant_ex(&tmp, fbc->op_array.scope); end_fake_frame(call); if (UNEXPECTED(ret == FAILURE)) { zval_ptr_dtor_nogc(&tmp); @@ -4533,7 +4533,7 @@ ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_handle_undef_args(zend_execute_data if (Z_TYPE(default_value) == IS_CONSTANT_AST) { start_fake_frame(call, NULL); - ZEND_RESULT_CODE ret = zval_update_constant_ex(&default_value, fbc->common.scope); + zend_result ret = zval_update_constant_ex(&default_value, fbc->common.scope); end_fake_frame(call); if (ret == FAILURE) { return FAILURE; @@ -4750,7 +4750,7 @@ static zend_always_inline zend_execute_data *_zend_vm_stack_push_call_frame(uint #include "zend_vm_execute.h" -ZEND_API ZEND_RESULT_CODE zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler_t handler) +ZEND_API zend_result zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler_t handler) { if (opcode != ZEND_USER_OPCODE) { if (handler == NULL) { diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index 9d94992586f3a..fb1a39898ca70 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -47,10 +47,10 @@ ZEND_API zend_class_entry *zend_lookup_class(zend_string *name); ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *lcname, uint32_t flags); ZEND_API zend_class_entry *zend_get_called_scope(zend_execute_data *ex); ZEND_API zend_object *zend_get_this_object(zend_execute_data *ex); -ZEND_API ZEND_RESULT_CODE zend_eval_string(const char *str, zval *retval_ptr, const char *string_name); -ZEND_API ZEND_RESULT_CODE zend_eval_stringl(const char *str, size_t str_len, zval *retval_ptr, const char *string_name); -ZEND_API ZEND_RESULT_CODE zend_eval_string_ex(const char *str, zval *retval_ptr, const char *string_name, bool handle_exceptions); -ZEND_API ZEND_RESULT_CODE zend_eval_stringl_ex(const char *str, size_t str_len, zval *retval_ptr, const char *string_name, bool handle_exceptions); +ZEND_API zend_result zend_eval_string(const char *str, zval *retval_ptr, const char *string_name); +ZEND_API zend_result zend_eval_stringl(const char *str, size_t str_len, zval *retval_ptr, const char *string_name); +ZEND_API zend_result zend_eval_string_ex(const char *str, zval *retval_ptr, const char *string_name, bool handle_exceptions); +ZEND_API zend_result zend_eval_stringl_ex(const char *str, size_t str_len, zval *retval_ptr, const char *string_name, bool handle_exceptions); /* export zend_pass_function to allow comparisons against it */ extern ZEND_API const zend_internal_function zend_pass_function; @@ -64,8 +64,8 @@ ZEND_API zend_bool ZEND_FASTCALL zend_verify_prop_assignable_by_ref(zend_propert ZEND_API ZEND_COLD void zend_throw_ref_type_error_zval(zend_property_info *prop, zval *zv); ZEND_API ZEND_COLD void zend_throw_ref_type_error_type(zend_property_info *prop1, zend_property_info *prop2, zval *zv); -ZEND_API ZEND_COLD ZEND_RESULT_CODE ZEND_FASTCALL zend_undefined_offset_write(HashTable *ht, zend_long lval); -ZEND_API ZEND_COLD ZEND_RESULT_CODE ZEND_FASTCALL zend_undefined_index_write(HashTable *ht, zend_string *offset); +ZEND_API ZEND_COLD zend_result ZEND_FASTCALL zend_undefined_offset_write(HashTable *ht, zend_long lval); +ZEND_API ZEND_COLD zend_result ZEND_FASTCALL zend_undefined_index_write(HashTable *ht, zend_string *offset); ZEND_API zend_bool zend_verify_scalar_type_hint(uint32_t type_mask, zval *arg, zend_bool strict, zend_bool is_internal_arg); ZEND_API ZEND_COLD void zend_verify_arg_error( @@ -155,8 +155,8 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval return variable_ptr; } -ZEND_API ZEND_RESULT_CODE zval_update_constant(zval *pp); -ZEND_API ZEND_RESULT_CODE zval_update_constant_ex(zval *pp, zend_class_entry *scope); +ZEND_API zend_result zval_update_constant(zval *pp); +ZEND_API zend_result zval_update_constant_ex(zval *pp, zend_class_entry *scope); /* dedicated Zend executor functions - do not use! */ struct _zend_vm_stack { diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 9059ce61841f2..77964e546b0f0 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -585,7 +585,7 @@ ZEND_API zend_bool zend_is_executing(void) /* {{{ */ } /* }}} */ -ZEND_API ZEND_RESULT_CODE zval_update_constant_ex(zval *p, zend_class_entry *scope) /* {{{ */ +ZEND_API zend_result zval_update_constant_ex(zval *p, zend_class_entry *scope) /* {{{ */ { if (Z_TYPE_P(p) == IS_CONSTANT_AST) { zend_ast *ast = Z_ASTVAL_P(p); @@ -613,13 +613,13 @@ ZEND_API ZEND_RESULT_CODE zval_update_constant_ex(zval *p, zend_class_entry *sco } /* }}} */ -ZEND_API ZEND_RESULT_CODE zval_update_constant(zval *pp) /* {{{ */ +ZEND_API zend_result zval_update_constant(zval *pp) /* {{{ */ { return zval_update_constant_ex(pp, EG(current_execute_data) ? zend_get_executed_scope() : CG(active_class_entry)); } /* }}} */ -ZEND_RESULT_CODE _call_user_function_impl(zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], HashTable *named_params) /* {{{ */ +zend_result _call_user_function_impl(zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], HashTable *named_params) /* {{{ */ { zend_fcall_info fci; @@ -635,7 +635,7 @@ ZEND_RESULT_CODE _call_user_function_impl(zval *object, zval *function_name, zva } /* }}} */ -ZEND_RESULT_CODE zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /* {{{ */ +zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /* {{{ */ { uint32_t i; zend_execute_data *call, dummy_execute_data; @@ -956,7 +956,7 @@ ZEND_API void zend_call_known_function( fcic.object = object; fcic.called_scope = called_scope; - ZEND_RESULT_CODE result = zend_call_function(&fci, &fcic); + zend_result result = zend_call_function(&fci, &fcic); if (UNEXPECTED(result == FAILURE)) { if (!EG(exception)) { zend_error_noreturn(E_CORE_ERROR, "Couldn't execute method %s%s%s", @@ -1134,12 +1134,12 @@ ZEND_API zend_object *zend_get_this_object(zend_execute_data *ex) /* {{{ */ } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_eval_stringl(const char *str, size_t str_len, zval *retval_ptr, const char *string_name) /* {{{ */ +ZEND_API zend_result zend_eval_stringl(const char *str, size_t str_len, zval *retval_ptr, const char *string_name) /* {{{ */ { zval pv; zend_op_array *new_op_array; uint32_t original_compiler_options; - ZEND_RESULT_CODE retval; + zend_result retval; if (retval_ptr) { ZVAL_NEW_STR(&pv, zend_string_alloc(str_len + sizeof("return ;")-1, 0)); @@ -1198,15 +1198,15 @@ ZEND_API ZEND_RESULT_CODE zend_eval_stringl(const char *str, size_t str_len, zva } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_eval_string(const char *str, zval *retval_ptr, const char *string_name) /* {{{ */ +ZEND_API zend_result zend_eval_string(const char *str, zval *retval_ptr, const char *string_name) /* {{{ */ { return zend_eval_stringl(str, strlen(str), retval_ptr, string_name); } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_eval_stringl_ex(const char *str, size_t str_len, zval *retval_ptr, const char *string_name, bool handle_exceptions) /* {{{ */ +ZEND_API zend_result zend_eval_stringl_ex(const char *str, size_t str_len, zval *retval_ptr, const char *string_name, bool handle_exceptions) /* {{{ */ { - ZEND_RESULT_CODE result; + zend_result result; result = zend_eval_stringl(str, str_len, retval_ptr, string_name); if (handle_exceptions && EG(exception)) { @@ -1216,7 +1216,7 @@ ZEND_API ZEND_RESULT_CODE zend_eval_stringl_ex(const char *str, size_t str_len, } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_eval_string_ex(const char *str, zval *retval_ptr, const char *string_name, bool handle_exceptions) /* {{{ */ +ZEND_API zend_result zend_eval_string_ex(const char *str, zval *retval_ptr, const char *string_name, bool handle_exceptions) /* {{{ */ { return zend_eval_stringl_ex(str, strlen(str), retval_ptr, string_name, handle_exceptions); } @@ -1525,7 +1525,7 @@ zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, zend_string } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_delete_global_variable(zend_string *name) /* {{{ */ +ZEND_API zend_result zend_delete_global_variable(zend_string *name) /* {{{ */ { return zend_hash_del_ind(&EG(symbol_table), name); } @@ -1638,7 +1638,7 @@ ZEND_API void zend_detach_symbol_table(zend_execute_data *execute_data) /* {{{ * } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_set_local_var(zend_string *name, zval *value, bool force) /* {{{ */ +ZEND_API zend_result zend_set_local_var(zend_string *name, zval *value, bool force) /* {{{ */ { zend_execute_data *execute_data = EG(current_execute_data); @@ -1681,7 +1681,7 @@ ZEND_API ZEND_RESULT_CODE zend_set_local_var(zend_string *name, zval *value, boo } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_set_local_var_str(const char *name, size_t len, zval *value, bool force) /* {{{ */ +ZEND_API zend_result zend_set_local_var_str(const char *name, size_t len, zval *value, bool force) /* {{{ */ { zend_execute_data *execute_data = EG(current_execute_data); diff --git a/Zend/zend_extensions.c b/Zend/zend_extensions.c index a547ede770071..c44a2f3093752 100644 --- a/Zend/zend_extensions.c +++ b/Zend/zend_extensions.c @@ -24,7 +24,7 @@ ZEND_API uint32_t zend_extension_flags = 0; ZEND_API int zend_op_array_extension_handles = 0; static int last_resource_number; -ZEND_RESULT_CODE zend_load_extension(const char *path) +zend_result zend_load_extension(const char *path) { #if ZEND_EXTENSIONS_SUPPORT DL_HANDLE handle; @@ -51,7 +51,7 @@ ZEND_RESULT_CODE zend_load_extension(const char *path) #endif } -ZEND_RESULT_CODE zend_load_extension_handle(DL_HANDLE handle, const char *path) +zend_result zend_load_extension_handle(DL_HANDLE handle, const char *path) { #if ZEND_EXTENSIONS_SUPPORT zend_extension *new_extension; diff --git a/Zend/zend_extensions.h b/Zend/zend_extensions.h index 02fd3bb6dc51a..a26a6f9fc7e25 100644 --- a/Zend/zend_extensions.h +++ b/Zend/zend_extensions.h @@ -145,8 +145,8 @@ void zend_startup_extensions(void); void zend_shutdown_extensions(void); BEGIN_EXTERN_C() -ZEND_API ZEND_RESULT_CODE zend_load_extension(const char *path); -ZEND_API ZEND_RESULT_CODE zend_load_extension_handle(DL_HANDLE handle, const char *path); +ZEND_API zend_result zend_load_extension(const char *path); +ZEND_API zend_result zend_load_extension_handle(DL_HANDLE handle, const char *path); ZEND_API void zend_register_extension(zend_extension *new_extension, DL_HANDLE handle); ZEND_API zend_extension *zend_get_extension(const char *extension_name); ZEND_API size_t zend_extensions_op_array_persist_calc(zend_op_array *op_array); diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index 590508dd4f474..4f35b727aece3 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -629,7 +629,7 @@ ZEND_API zend_generator *zend_generator_update_current(zend_generator *generator return root; } -static ZEND_RESULT_CODE zend_generator_get_next_delegated_value(zend_generator *generator) /* {{{ */ +static zend_result zend_generator_get_next_delegated_value(zend_generator *generator) /* {{{ */ { zval *value; if (Z_TYPE(generator->values) == IS_ARRAY) { diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index 5779a079232f1..abda03edf631e 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -1360,7 +1360,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_del_bucket(HashTable *ht, Bucket *p) _zend_hash_del_el(ht, HT_IDX_TO_HASH(p - ht->arData), p); } -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key) +ZEND_API zend_result ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key) { zend_ulong h; uint32_t nIndex; @@ -1390,7 +1390,7 @@ ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string return FAILURE; } -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_del_ind(HashTable *ht, zend_string *key) +ZEND_API zend_result ZEND_FASTCALL zend_hash_del_ind(HashTable *ht, zend_string *key) { zend_ulong h; uint32_t nIndex; @@ -1438,7 +1438,7 @@ ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_del_ind(HashTable *ht, zend_st return FAILURE; } -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_str_del_ind(HashTable *ht, const char *str, size_t len) +ZEND_API zend_result ZEND_FASTCALL zend_hash_str_del_ind(HashTable *ht, const char *str, size_t len) { zend_ulong h; uint32_t nIndex; @@ -1482,7 +1482,7 @@ ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_str_del_ind(HashTable *ht, con return FAILURE; } -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_str_del(HashTable *ht, const char *str, size_t len) +ZEND_API zend_result ZEND_FASTCALL zend_hash_str_del(HashTable *ht, const char *str, size_t len) { zend_ulong h; uint32_t nIndex; @@ -1512,7 +1512,7 @@ ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_str_del(HashTable *ht, const c return FAILURE; } -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_index_del(HashTable *ht, zend_ulong h) +ZEND_API zend_result ZEND_FASTCALL zend_hash_index_del(HashTable *ht, zend_ulong h) { uint32_t nIndex; uint32_t idx; @@ -2325,7 +2325,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_end_ex(HashTable *ht, Has } -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_move_forward_ex(HashTable *ht, HashPosition *pos) +ZEND_API zend_result ZEND_FASTCALL zend_hash_move_forward_ex(HashTable *ht, HashPosition *pos) { uint32_t idx; @@ -2350,7 +2350,7 @@ ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_move_forward_ex(HashTable *ht, } } -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos) +ZEND_API zend_result ZEND_FASTCALL zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos) { uint32_t idx = *pos; diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h index bbd5205db3a9d..fb11c4a9e321e 100644 --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@ -162,11 +162,11 @@ ZEND_API void ZEND_FASTCALL zend_hash_reverse_apply(HashTable *ht, apply_func_t /* Deletes */ -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_del_ind(HashTable *ht, zend_string *key); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_str_del(HashTable *ht, const char *key, size_t len); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_str_del_ind(HashTable *ht, const char *key, size_t len); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_index_del(HashTable *ht, zend_ulong h); +ZEND_API zend_result ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key); +ZEND_API zend_result ZEND_FASTCALL zend_hash_del_ind(HashTable *ht, zend_string *key); +ZEND_API zend_result ZEND_FASTCALL zend_hash_str_del(HashTable *ht, const char *key, size_t len); +ZEND_API zend_result ZEND_FASTCALL zend_hash_str_del_ind(HashTable *ht, const char *key, size_t len); +ZEND_API zend_result ZEND_FASTCALL zend_hash_index_del(HashTable *ht, zend_ulong h); ZEND_API void ZEND_FASTCALL zend_hash_del_bucket(HashTable *ht, Bucket *p); /* Data retrieval */ @@ -227,11 +227,11 @@ ZEND_API HashPosition ZEND_FASTCALL zend_hash_get_current_pos(const HashTable *h #define zend_hash_has_more_elements_ex(ht, pos) \ (zend_hash_get_current_key_type_ex(ht, pos) == HASH_KEY_NON_EXISTENT ? FAILURE : SUCCESS) -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_move_forward_ex(HashTable *ht, HashPosition *pos); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, zend_ulong *num_index, HashPosition *pos); +ZEND_API zend_result ZEND_FASTCALL zend_hash_move_forward_ex(HashTable *ht, HashPosition *pos); +ZEND_API zend_result ZEND_FASTCALL zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos); +ZEND_API zend_result ZEND_FASTCALL zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, zend_ulong *num_index, HashPosition *pos); ZEND_API void ZEND_FASTCALL zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, HashPosition *pos); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_hash_get_current_key_type_ex(HashTable *ht, HashPosition *pos); +ZEND_API zend_result ZEND_FASTCALL zend_hash_get_current_key_type_ex(HashTable *ht, HashPosition *pos); ZEND_API zval* ZEND_FASTCALL zend_hash_get_current_data_ex(HashTable *ht, HashPosition *pos); ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_reset_ex(HashTable *ht, HashPosition *pos); ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_end_ex(HashTable *ht, HashPosition *pos); @@ -460,7 +460,7 @@ static zend_always_inline zval *zend_symtable_update_ind(HashTable *ht, zend_str } -static zend_always_inline ZEND_RESULT_CODE zend_symtable_del(HashTable *ht, zend_string *key) +static zend_always_inline zend_result zend_symtable_del(HashTable *ht, zend_string *key) { zend_ulong idx; @@ -472,7 +472,7 @@ static zend_always_inline ZEND_RESULT_CODE zend_symtable_del(HashTable *ht, zend } -static zend_always_inline ZEND_RESULT_CODE zend_symtable_del_ind(HashTable *ht, zend_string *key) +static zend_always_inline zend_result zend_symtable_del_ind(HashTable *ht, zend_string *key) { zend_ulong idx; @@ -556,7 +556,7 @@ static zend_always_inline zval *zend_symtable_str_update_ind(HashTable *ht, cons } -static zend_always_inline ZEND_RESULT_CODE zend_symtable_str_del(HashTable *ht, const char *str, size_t len) +static zend_always_inline zend_result zend_symtable_str_del(HashTable *ht, const char *str, size_t len) { zend_ulong idx; @@ -568,7 +568,7 @@ static zend_always_inline ZEND_RESULT_CODE zend_symtable_str_del(HashTable *ht, } -static zend_always_inline ZEND_RESULT_CODE zend_symtable_str_del_ind(HashTable *ht, const char *str, size_t len) +static zend_always_inline zend_result zend_symtable_str_del_ind(HashTable *ht, const char *str, size_t len) { zend_ulong idx; diff --git a/Zend/zend_highlight.h b/Zend/zend_highlight.h index 6f8e5e51be57e..c4f819d508c1e 100644 --- a/Zend/zend_highlight.h +++ b/Zend/zend_highlight.h @@ -39,7 +39,7 @@ typedef struct _zend_syntax_highlighter_ini { BEGIN_EXTERN_C() ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini); ZEND_API void zend_strip(void); -ZEND_API ZEND_RESULT_CODE highlight_file(const char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini); +ZEND_API zend_result highlight_file(const char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini); ZEND_API void highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, const char *str_name); ZEND_API void zend_html_putc(char c); ZEND_API void zend_html_puts(const char *s, size_t len); diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 3054bd162135f..4d2e2d540074c 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -2390,7 +2390,7 @@ static void check_unrecoverable_load_failure(zend_class_entry *ce) { } } -ZEND_API ZEND_RESULT_CODE zend_do_link_class(zend_class_entry *ce, zend_string *lc_parent_name) /* {{{ */ +ZEND_API zend_result zend_do_link_class(zend_class_entry *ce, zend_string *lc_parent_name) /* {{{ */ { /* Load parent/interface dependencies first, so we can still gracefully abort linking * with an exception and remove the class from the class table. This is only possible diff --git a/Zend/zend_inheritance.h b/Zend/zend_inheritance.h index 067519c5f2347..e49ec49b6f958 100644 --- a/Zend/zend_inheritance.h +++ b/Zend/zend_inheritance.h @@ -30,7 +30,7 @@ ZEND_API void zend_do_inheritance_ex(zend_class_entry *ce, zend_class_entry *par #define zend_do_inheritance(ce, parent_ce) \ zend_do_inheritance_ex(ce, parent_ce, 0) -ZEND_API ZEND_RESULT_CODE zend_do_link_class(zend_class_entry *ce, zend_string *lc_parent_name); +ZEND_API zend_result zend_do_link_class(zend_class_entry *ce, zend_string *lc_parent_name); void zend_verify_abstract_class(zend_class_entry *ce); void zend_build_properties_info_table(zend_class_entry *ce); diff --git a/Zend/zend_ini.c b/Zend/zend_ini.c index 0f4970a28909d..75c7faf4c014e 100644 --- a/Zend/zend_ini.c +++ b/Zend/zend_ini.c @@ -41,9 +41,9 @@ static int zend_remove_ini_entries(zval *el, void *arg) /* {{{ */ } /* }}} */ -static ZEND_RESULT_CODE zend_restore_ini_entry_cb(zend_ini_entry *ini_entry, int stage) /* {{{ */ +static zend_result zend_restore_ini_entry_cb(zend_ini_entry *ini_entry, int stage) /* {{{ */ { - ZEND_RESULT_CODE result = FAILURE; + zend_result result = FAILURE; if (ini_entry->modified) { if (ini_entry->on_modify) { @@ -194,7 +194,7 @@ ZEND_API void zend_ini_sort_entries(void) /* {{{ */ /* * Registration / unregistration */ -ZEND_API ZEND_RESULT_CODE zend_register_ini_entries(const zend_ini_entry_def *ini_entry, int module_number) /* {{{ */ +ZEND_API zend_result zend_register_ini_entries(const zend_ini_entry_def *ini_entry, int module_number) /* {{{ */ { zend_ini_entry *p; zval *default_value; @@ -275,16 +275,16 @@ ZEND_API void zend_ini_refresh_caches(int stage) /* {{{ */ /* }}} */ #endif -ZEND_API ZEND_RESULT_CODE zend_alter_ini_entry(zend_string *name, zend_string *new_value, int modify_type, int stage) /* {{{ */ +ZEND_API zend_result zend_alter_ini_entry(zend_string *name, zend_string *new_value, int modify_type, int stage) /* {{{ */ { return zend_alter_ini_entry_ex(name, new_value, modify_type, stage, 0); } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_alter_ini_entry_chars(zend_string *name, const char *value, size_t value_length, int modify_type, int stage) /* {{{ */ +ZEND_API zend_result zend_alter_ini_entry_chars(zend_string *name, const char *value, size_t value_length, int modify_type, int stage) /* {{{ */ { - ZEND_RESULT_CODE ret; + zend_result ret; zend_string *new_value; new_value = zend_string_init(value, value_length, !(stage & ZEND_INI_STAGE_IN_REQUEST)); @@ -294,9 +294,9 @@ ZEND_API ZEND_RESULT_CODE zend_alter_ini_entry_chars(zend_string *name, const ch } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, int force_change) /* {{{ */ +ZEND_API zend_result zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, int force_change) /* {{{ */ { - ZEND_RESULT_CODE ret; + zend_result ret; zend_string *new_value; new_value = zend_string_init(value, value_length, !(stage & ZEND_INI_STAGE_IN_REQUEST)); @@ -306,7 +306,7 @@ ZEND_API ZEND_RESULT_CODE zend_alter_ini_entry_chars_ex(zend_string *name, const } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, int modify_type, int stage, bool force_change) /* {{{ */ +ZEND_API zend_result zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, int modify_type, int stage, bool force_change) /* {{{ */ { zend_ini_entry *ini_entry; zend_string *duplicate; @@ -358,7 +358,7 @@ ZEND_API ZEND_RESULT_CODE zend_alter_ini_entry_ex(zend_string *name, zend_string } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_restore_ini_entry(zend_string *name, int stage) /* {{{ */ +ZEND_API zend_result zend_restore_ini_entry(zend_string *name, int stage) /* {{{ */ { zend_ini_entry *ini_entry; @@ -379,7 +379,7 @@ ZEND_API ZEND_RESULT_CODE zend_restore_ini_entry(zend_string *name, int stage) / } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_ini_register_displayer(const char *name, uint32_t name_length, void (*displayer)(zend_ini_entry *ini_entry, int type)) /* {{{ */ +ZEND_API zend_result zend_ini_register_displayer(const char *name, uint32_t name_length, void (*displayer)(zend_ini_entry *ini_entry, int type)) /* {{{ */ { zend_ini_entry *ini_entry; diff --git a/Zend/zend_ini.h b/Zend/zend_ini.h index 99378298b2671..d227f3779d990 100644 --- a/Zend/zend_ini.h +++ b/Zend/zend_ini.h @@ -71,14 +71,14 @@ ZEND_API void zend_copy_ini_directives(void); ZEND_API void zend_ini_sort_entries(void); -ZEND_API ZEND_RESULT_CODE zend_register_ini_entries(const zend_ini_entry_def *ini_entry, int module_number); +ZEND_API zend_result zend_register_ini_entries(const zend_ini_entry_def *ini_entry, int module_number); ZEND_API void zend_unregister_ini_entries(int module_number); ZEND_API void zend_ini_refresh_caches(int stage); -ZEND_API ZEND_RESULT_CODE zend_alter_ini_entry(zend_string *name, zend_string *new_value, int modify_type, int stage); -ZEND_API ZEND_RESULT_CODE zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, int modify_type, int stage, bool force_change); -ZEND_API ZEND_RESULT_CODE zend_alter_ini_entry_chars(zend_string *name, const char *value, size_t value_length, int modify_type, int stage); -ZEND_API ZEND_RESULT_CODE zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, int force_change); -ZEND_API ZEND_RESULT_CODE zend_restore_ini_entry(zend_string *name, int stage); +ZEND_API zend_result zend_alter_ini_entry(zend_string *name, zend_string *new_value, int modify_type, int stage); +ZEND_API zend_result zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, int modify_type, int stage, bool force_change); +ZEND_API zend_result zend_alter_ini_entry_chars(zend_string *name, const char *value, size_t value_length, int modify_type, int stage); +ZEND_API zend_result zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, int force_change); +ZEND_API zend_result zend_restore_ini_entry(zend_string *name, int stage); ZEND_API void display_ini_entries(zend_module_entry *module); ZEND_API zend_long zend_ini_long(const char *name, size_t name_length, int orig); @@ -88,7 +88,7 @@ ZEND_API char *zend_ini_string_ex(const char *name, size_t name_length, int orig ZEND_API zend_string *zend_ini_get_value(zend_string *name); ZEND_API zend_bool zend_ini_parse_bool(zend_string *str); -ZEND_API ZEND_RESULT_CODE zend_ini_register_displayer(const char *name, uint32_t name_length, void (*displayer)(zend_ini_entry *ini_entry, int type)); +ZEND_API zend_result zend_ini_register_displayer(const char *name, uint32_t name_length, void (*displayer)(zend_ini_entry *ini_entry, int type)); ZEND_API ZEND_INI_DISP(zend_ini_boolean_displayer_cb); ZEND_API ZEND_INI_DISP(zend_ini_color_displayer_cb); diff --git a/Zend/zend_ini_parser.y b/Zend/zend_ini_parser.y index c65485d6f1933..f9170d9ecc024 100644 --- a/Zend/zend_ini_parser.y +++ b/Zend/zend_ini_parser.y @@ -212,7 +212,7 @@ static ZEND_COLD void ini_error(const char *msg) /* }}} */ /* {{{ zend_parse_ini_file() */ -ZEND_API ZEND_RESULT_CODE zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg) +ZEND_API zend_result zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg) { int retval; zend_ini_parser_param ini_parser_param; @@ -240,7 +240,7 @@ ZEND_API ZEND_RESULT_CODE zend_parse_ini_file(zend_file_handle *fh, zend_bool un /* }}} */ /* {{{ zend_parse_ini_string() */ -ZEND_API ZEND_RESULT_CODE zend_parse_ini_string(char *str, zend_bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg) +ZEND_API zend_result zend_parse_ini_string(char *str, zend_bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg) { int retval; zend_ini_parser_param ini_parser_param; diff --git a/Zend/zend_ini_scanner.h b/Zend/zend_ini_scanner.h index 6d5d2f5062b01..f3d7f1a82b271 100644 --- a/Zend/zend_ini_scanner.h +++ b/Zend/zend_ini_scanner.h @@ -28,8 +28,8 @@ BEGIN_EXTERN_C() ZEND_COLD int zend_ini_scanner_get_lineno(void); ZEND_COLD char *zend_ini_scanner_get_filename(void); -ZEND_RESULT_CODE zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode); -ZEND_RESULT_CODE zend_ini_prepare_string_for_scanning(char *str, int scanner_mode); +zend_result zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode); +zend_result zend_ini_prepare_string_for_scanning(char *str, int scanner_mode); int ini_lex(zval *ini_lval); void shutdown_ini_scanner(void); END_EXTERN_C() diff --git a/Zend/zend_ini_scanner.l b/Zend/zend_ini_scanner.l index 8324526419f12..1d689f3748a5d 100644 --- a/Zend/zend_ini_scanner.l +++ b/Zend/zend_ini_scanner.l @@ -151,7 +151,7 @@ ZEND_API zend_ini_scanner_globals ini_scanner_globals; return type; \ } -static inline ZEND_RESULT_CODE convert_to_number(zval *retval, const char *str, const int str_len) +static inline zend_result convert_to_number(zval *retval, const char *str, const int str_len) { zend_uchar type; int overflow; @@ -218,7 +218,7 @@ static void yy_scan_buffer(char *str, unsigned int len) #define ini_filename SCNG(filename) /* {{{ init_ini_scanner() */ -static ZEND_RESULT_CODE init_ini_scanner(int scanner_mode, zend_file_handle *fh) +static zend_result init_ini_scanner(int scanner_mode, zend_file_handle *fh) { /* Sanity check */ if (scanner_mode != ZEND_INI_SCANNER_NORMAL && scanner_mode != ZEND_INI_SCANNER_RAW && scanner_mode != ZEND_INI_SCANNER_TYPED) { @@ -268,7 +268,7 @@ ZEND_COLD char *zend_ini_scanner_get_filename(void) /* }}} */ /* {{{ zend_ini_open_file_for_scanning() */ -ZEND_RESULT_CODE zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode) +zend_result zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode) { char *buf; size_t size; @@ -289,7 +289,7 @@ ZEND_RESULT_CODE zend_ini_open_file_for_scanning(zend_file_handle *fh, int scann /* }}} */ /* {{{ zend_ini_prepare_string_for_scanning() */ -ZEND_RESULT_CODE zend_ini_prepare_string_for_scanning(char *str, int scanner_mode) +zend_result zend_ini_prepare_string_for_scanning(char *str, int scanner_mode) { int len = (int)strlen(str); diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c index 3d44b4769b29b..1278f08209d67 100644 --- a/Zend/zend_interfaces.c +++ b/Zend/zend_interfaces.c @@ -358,7 +358,7 @@ ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, size_t *b { zend_class_entry * ce = Z_OBJCE_P(object); zval retval; - ZEND_RESULT_CODE result; + zend_result result; zend_call_method_with_0_params( Z_OBJ_P(object), Z_OBJCE_P(object), NULL, "serialize", &retval); @@ -460,7 +460,7 @@ static zend_object *zend_internal_iterator_create(zend_class_entry *ce) { return &intern->std; } -ZEND_API ZEND_RESULT_CODE zend_create_internal_iterator_zval(zval *return_value, zval *obj) { +ZEND_API zend_result zend_create_internal_iterator_zval(zval *return_value, zval *obj) { zend_class_entry *scope = EG(current_execute_data)->func->common.scope; ZEND_ASSERT(scope->get_iterator != zend_user_it_get_new_iterator); zend_object_iterator *iter = scope->get_iterator(Z_OBJCE_P(obj), obj, /* by_ref */ 0); @@ -494,7 +494,7 @@ static zend_internal_iterator *zend_internal_iterator_fetch(zval *This) { } /* Many iterators will not behave correctly if rewind() is not called, make sure it happens. */ -static ZEND_RESULT_CODE zend_internal_iterator_ensure_rewound(zend_internal_iterator *intern) { +static zend_result zend_internal_iterator_ensure_rewound(zend_internal_iterator *intern) { if (!intern->rewind_called) { zend_object_iterator *iter = intern->iter; intern->rewind_called = 1; diff --git a/Zend/zend_interfaces.h b/Zend/zend_interfaces.h index 2f09402c90e5c..ecdc9b0e1b278 100644 --- a/Zend/zend_interfaces.h +++ b/Zend/zend_interfaces.h @@ -61,7 +61,7 @@ ZEND_API zval* zend_call_method(zend_object *object, zend_class_entry *obj_ce, z zend_class_implements(zend_ce_ ## class_name, 1, zend_ce_ ## interface_name) ZEND_API void zend_user_it_rewind(zend_object_iterator *_iter); -ZEND_API ZEND_RESULT_CODE zend_user_it_valid(zend_object_iterator *_iter); +ZEND_API zend_result zend_user_it_valid(zend_object_iterator *_iter); ZEND_API void zend_user_it_get_current_key(zend_object_iterator *_iter, zval *key); ZEND_API zval *zend_user_it_get_current_data(zend_object_iterator *_iter); ZEND_API void zend_user_it_move_forward(zend_object_iterator *_iter); @@ -78,7 +78,7 @@ ZEND_API int zend_user_unserialize(zval *object, zend_class_entry *ce, const uns ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data); ZEND_API int zend_class_unserialize_deny(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data); -ZEND_API ZEND_RESULT_CODE zend_create_internal_iterator_zval(zval *return_value, zval *obj); +ZEND_API zend_result zend_create_internal_iterator_zval(zval *return_value, zval *obj); END_EXTERN_C() diff --git a/Zend/zend_language_scanner.h b/Zend/zend_language_scanner.h index 7af718c5a108b..f08dbb4ea91d8 100644 --- a/Zend/zend_language_scanner.h +++ b/Zend/zend_language_scanner.h @@ -77,8 +77,8 @@ ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state); ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state); ZEND_API void zend_prepare_string_for_scanning(zval *str, const char *filename); ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter, const zend_encoding *old_encoding); -ZEND_API ZEND_RESULT_CODE zend_multibyte_set_filter(const zend_encoding *onetime_encoding); -ZEND_API ZEND_RESULT_CODE zend_lex_tstring(zval *zv, zend_lexer_ident_ref ident_ref); +ZEND_API zend_result zend_multibyte_set_filter(const zend_encoding *onetime_encoding); +ZEND_API zend_result zend_lex_tstring(zval *zv, zend_lexer_ident_ref ident_ref); END_EXTERN_C() diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index 7ebfe30b93ed4..ee88282fd5176 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -306,7 +306,7 @@ ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle) } } -ZEND_API ZEND_RESULT_CODE zend_lex_tstring(zval *zv, zend_lexer_ident_ref ident_ref) +ZEND_API zend_result zend_lex_tstring(zval *zv, zend_lexer_ident_ref ident_ref) { char *ident = (char *) SCNG(yy_start) + ident_ref.offset; size_t length = ident_ref.len; @@ -486,7 +486,7 @@ static const zend_encoding* zend_multibyte_find_script_encoding(void) return CG(script_encoding_list)[0]; } -ZEND_API ZEND_RESULT_CODE zend_multibyte_set_filter(const zend_encoding *onetime_encoding) +ZEND_API zend_result zend_multibyte_set_filter(const zend_encoding *onetime_encoding) { const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding(); const zend_encoding *script_encoding = onetime_encoding ? onetime_encoding: zend_multibyte_find_script_encoding(); @@ -527,7 +527,7 @@ ZEND_API ZEND_RESULT_CODE zend_multibyte_set_filter(const zend_encoding *onetime return SUCCESS; } -ZEND_API ZEND_RESULT_CODE open_file_for_scanning(zend_file_handle *file_handle) +ZEND_API zend_result open_file_for_scanning(zend_file_handle *file_handle) { char *buf; size_t size; @@ -833,7 +833,7 @@ zend_op_array *compile_string(zval *source_string, const char *filename) BEGIN_EXTERN_C() -ZEND_RESULT_CODE highlight_file(const char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini) +zend_result highlight_file(const char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini) { zend_lex_state original_lex_state; zend_file_handle file_handle; @@ -927,7 +927,7 @@ ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter ZVAL_STRINGL(zendlval, yytext, yyleng); \ } -static ZEND_RESULT_CODE zend_scan_escape_string(zval *zendlval, char *str, int len, char quote_type) +static zend_result zend_scan_escape_string(zval *zendlval, char *str, int len, char quote_type) { register char *s, *t; char *end; @@ -1280,7 +1280,7 @@ static void enter_nesting(char opening) zend_stack_push(&SCNG(nest_location_stack), &nest_loc); } -static ZEND_RESULT_CODE exit_nesting(char closing) +static zend_result exit_nesting(char closing) { if (zend_stack_is_empty(&SCNG(nest_location_stack))) { zend_throw_exception_ex(zend_ce_parse_error, 0, "Unmatched '%c'", closing); @@ -1301,7 +1301,7 @@ static ZEND_RESULT_CODE exit_nesting(char closing) return SUCCESS; } -static ZEND_RESULT_CODE check_nesting_at_end() +static zend_result check_nesting_at_end() { if (!zend_stack_is_empty(&SCNG(nest_location_stack))) { zend_nest_location *nest_loc = zend_stack_top(&SCNG(nest_location_stack)); diff --git a/Zend/zend_list.c b/Zend/zend_list.c index ee0e7dcc56b39..45ff950b6bfec 100644 --- a/Zend/zend_list.c +++ b/Zend/zend_list.c @@ -42,7 +42,7 @@ ZEND_API zval* ZEND_FASTCALL zend_list_insert(void *ptr, int type) return zend_hash_index_add_new(&EG(regular_list), index, &zv); } -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL zend_list_delete(zend_resource *res) +ZEND_API zend_result ZEND_FASTCALL zend_list_delete(zend_resource *res) { if (GC_DELREF(res) <= 0) { return zend_hash_index_del(&EG(regular_list), res->handle); diff --git a/Zend/zend_modules.h b/Zend/zend_modules.h index 05f7085190c8f..cb64324d38bc7 100644 --- a/Zend/zend_modules.h +++ b/Zend/zend_modules.h @@ -77,10 +77,10 @@ struct _zend_module_entry { const struct _zend_module_dep *deps; const char *name; const struct _zend_function_entry *functions; - ZEND_RESULT_CODE (*module_startup_func)(INIT_FUNC_ARGS); - ZEND_RESULT_CODE (*module_shutdown_func)(SHUTDOWN_FUNC_ARGS); - ZEND_RESULT_CODE (*request_startup_func)(INIT_FUNC_ARGS); - ZEND_RESULT_CODE (*request_shutdown_func)(SHUTDOWN_FUNC_ARGS); + zend_result (*module_startup_func)(INIT_FUNC_ARGS); + zend_result (*module_shutdown_func)(SHUTDOWN_FUNC_ARGS); + zend_result (*request_startup_func)(INIT_FUNC_ARGS); + zend_result (*request_shutdown_func)(SHUTDOWN_FUNC_ARGS); void (*info_func)(ZEND_MODULE_INFO_FUNC_ARGS); const char *version; size_t globals_size; diff --git a/Zend/zend_multibyte.c b/Zend/zend_multibyte.c index cbf6213b1790c..f8dab668751a1 100644 --- a/Zend/zend_multibyte.c +++ b/Zend/zend_multibyte.c @@ -48,7 +48,7 @@ static size_t dummy_encoding_converter(unsigned char **to, size_t *to_length, co return (size_t)-1; } -static ZEND_RESULT_CODE dummy_encoding_list_parser(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, bool persistent) +static zend_result dummy_encoding_list_parser(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, bool persistent) { *return_list = pemalloc(0, persistent); *return_size = 0; @@ -60,7 +60,7 @@ static const zend_encoding *dummy_internal_encoding_getter(void) return NULL; } -static ZEND_RESULT_CODE dummy_internal_encoding_setter(const zend_encoding *encoding) +static zend_result dummy_internal_encoding_setter(const zend_encoding *encoding) { return FAILURE; } @@ -84,7 +84,7 @@ ZEND_API const zend_encoding *zend_multibyte_encoding_utf16be = (const zend_enco ZEND_API const zend_encoding *zend_multibyte_encoding_utf16le = (const zend_encoding*)"UTF-32LE"; ZEND_API const zend_encoding *zend_multibyte_encoding_utf8 = (const zend_encoding*)"UTF-8"; -ZEND_API ZEND_RESULT_CODE zend_multibyte_set_functions(const zend_multibyte_functions *functions) +ZEND_API zend_result zend_multibyte_set_functions(const zend_multibyte_functions *functions) { zend_multibyte_encoding_utf32be = functions->encoding_fetcher("UTF-32BE"); if (!zend_multibyte_encoding_utf32be) { @@ -155,7 +155,7 @@ ZEND_API size_t zend_multibyte_encoding_converter(unsigned char **to, size_t *to return multibyte_functions.encoding_converter(to, to_length, from, from_length, encoding_to, encoding_from); } -ZEND_API ZEND_RESULT_CODE zend_multibyte_parse_encoding_list(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, bool persistent) +ZEND_API zend_result zend_multibyte_parse_encoding_list(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, bool persistent) { return multibyte_functions.encoding_list_parser(encoding_list, encoding_list_len, return_list, return_size, persistent); } @@ -180,12 +180,12 @@ ZEND_API int zend_multibyte_set_script_encoding(const zend_encoding **encoding_l return SUCCESS; } -ZEND_API ZEND_RESULT_CODE zend_multibyte_set_internal_encoding(const zend_encoding *encoding) +ZEND_API zend_result zend_multibyte_set_internal_encoding(const zend_encoding *encoding) { return multibyte_functions.internal_encoding_setter(encoding); } -ZEND_API ZEND_RESULT_CODE zend_multibyte_set_script_encoding_by_string(const char *new_value, size_t new_value_length) +ZEND_API zend_result zend_multibyte_set_script_encoding_by_string(const char *new_value, size_t new_value_length) { const zend_encoding **list = 0; size_t size = 0; diff --git a/Zend/zend_multibyte.h b/Zend/zend_multibyte.h index 2281fb5abfb28..5466840cd900a 100644 --- a/Zend/zend_multibyte.h +++ b/Zend/zend_multibyte.h @@ -29,9 +29,9 @@ typedef const char* (*zend_encoding_name_getter)(const zend_encoding *encoding); typedef bool (*zend_encoding_lexer_compatibility_checker)(const zend_encoding *encoding); typedef const zend_encoding *(*zend_encoding_detector)(const unsigned char *string, size_t length, const zend_encoding **list, size_t list_size); typedef size_t (*zend_encoding_converter)(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length, const zend_encoding *encoding_to, const zend_encoding *encoding_from); -typedef ZEND_RESULT_CODE (*zend_encoding_list_parser)(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, bool persistent); +typedef zend_result (*zend_encoding_list_parser)(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, bool persistent); typedef const zend_encoding *(*zend_encoding_internal_encoding_getter)(void); -typedef ZEND_RESULT_CODE (*zend_encoding_internal_encoding_setter)(const zend_encoding *encoding); +typedef zend_result (*zend_encoding_internal_encoding_setter)(const zend_encoding *encoding); typedef struct _zend_multibyte_functions { const char *provider_name; @@ -57,7 +57,7 @@ ZEND_API extern const zend_encoding *zend_multibyte_encoding_utf16le; ZEND_API extern const zend_encoding *zend_multibyte_encoding_utf8; /* multibyte utility functions */ -ZEND_API ZEND_RESULT_CODE zend_multibyte_set_functions(const zend_multibyte_functions *functions); +ZEND_API zend_result zend_multibyte_set_functions(const zend_multibyte_functions *functions); ZEND_API void zend_multibyte_restore_functions(void); ZEND_API const zend_multibyte_functions *zend_multibyte_get_functions(void); @@ -72,7 +72,7 @@ ZEND_API const zend_encoding *zend_multibyte_get_internal_encoding(void); ZEND_API const zend_encoding *zend_multibyte_get_script_encoding(void); ZEND_API int zend_multibyte_set_script_encoding(const zend_encoding **encoding_list, size_t encoding_list_size); ZEND_API int zend_multibyte_set_internal_encoding(const zend_encoding *encoding); -ZEND_API ZEND_RESULT_CODE zend_multibyte_set_script_encoding_by_string(const char *new_value, size_t new_value_length); +ZEND_API zend_result zend_multibyte_set_script_encoding_by_string(const char *new_value, size_t new_value_length); END_EXTERN_C() diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index fea8ae3340275..9348ec9a74311 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -232,7 +232,7 @@ static zend_never_inline zval* ZEND_FASTCALL _zendi_convert_scalar_to_number_sil } /* }}} */ -static zend_never_inline ZEND_RESULT_CODE ZEND_FASTCALL _zendi_try_convert_scalar_to_number(zval *op, zval *holder) /* {{{ */ +static zend_never_inline zend_result ZEND_FASTCALL _zendi_try_convert_scalar_to_number(zval *op, zval *holder) /* {{{ */ { switch (Z_TYPE_P(op)) { case IS_NULL: @@ -274,7 +274,7 @@ static zend_never_inline ZEND_RESULT_CODE ZEND_FASTCALL _zendi_try_convert_scala } /* }}} */ -static zend_always_inline ZEND_RESULT_CODE zendi_try_convert_scalar_to_number(zval *op, zval *holder) /* {{{ */ +static zend_always_inline zend_result zendi_try_convert_scalar_to_number(zval *op, zval *holder) /* {{{ */ { if (Z_TYPE_P(op) == IS_LONG || Z_TYPE_P(op) == IS_DOUBLE) { ZVAL_COPY_VALUE(holder, op); @@ -963,7 +963,7 @@ static zend_never_inline void ZEND_FASTCALL add_function_array(zval *result, zva } /* }}} */ -static zend_always_inline ZEND_RESULT_CODE add_function_fast(zval *result, zval *op1, zval *op2) /* {{{ */ +static zend_always_inline zend_result add_function_fast(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_uchar type_pair = TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2)); @@ -987,7 +987,7 @@ static zend_always_inline ZEND_RESULT_CODE add_function_fast(zval *result, zval } } /* }}} */ -static zend_never_inline ZEND_RESULT_CODE ZEND_FASTCALL add_function_slow(zval *result, zval *op1, zval *op2) /* {{{ */ +static zend_never_inline zend_result ZEND_FASTCALL add_function_slow(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_DEREF(op1); ZVAL_DEREF(op2); @@ -1019,7 +1019,7 @@ static zend_never_inline ZEND_RESULT_CODE ZEND_FASTCALL add_function_slow(zval * return FAILURE; } /* }}} */ -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL add_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL add_function(zval *result, zval *op1, zval *op2) /* {{{ */ { if (add_function_fast(result, op1, op2) == SUCCESS) { return SUCCESS; @@ -1029,7 +1029,7 @@ ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL add_function(zval *result, zval *op1, zv } /* }}} */ -static zend_always_inline ZEND_RESULT_CODE sub_function_fast(zval *result, zval *op1, zval *op2) /* {{{ */ +static zend_always_inline zend_result sub_function_fast(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_uchar type_pair = TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2)); @@ -1051,7 +1051,7 @@ static zend_always_inline ZEND_RESULT_CODE sub_function_fast(zval *result, zval } /* }}} */ -static zend_never_inline ZEND_RESULT_CODE ZEND_FASTCALL sub_function_slow(zval *result, zval *op1, zval *op2) /* {{{ */ +static zend_never_inline zend_result ZEND_FASTCALL sub_function_slow(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_DEREF(op1); ZVAL_DEREF(op2); @@ -1084,7 +1084,7 @@ static zend_never_inline ZEND_RESULT_CODE ZEND_FASTCALL sub_function_slow(zval * } /* }}} */ -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL sub_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL sub_function(zval *result, zval *op1, zval *op2) /* {{{ */ { if (sub_function_fast(result, op1, op2) == SUCCESS) { return SUCCESS; @@ -1094,7 +1094,7 @@ ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL sub_function(zval *result, zval *op1, zv } /* }}} */ -static zend_always_inline ZEND_RESULT_CODE mul_function_fast(zval *result, zval *op1, zval *op2) /* {{{ */ +static zend_always_inline zend_result mul_function_fast(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_uchar type_pair = TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2)); @@ -1120,7 +1120,7 @@ static zend_always_inline ZEND_RESULT_CODE mul_function_fast(zval *result, zval } /* }}} */ -static zend_never_inline ZEND_RESULT_CODE ZEND_FASTCALL mul_function_slow(zval *result, zval *op1, zval *op2) /* {{{ */ +static zend_never_inline zend_result ZEND_FASTCALL mul_function_slow(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_DEREF(op1); ZVAL_DEREF(op2); @@ -1153,7 +1153,7 @@ static zend_never_inline ZEND_RESULT_CODE ZEND_FASTCALL mul_function_slow(zval * } /* }}} */ -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL mul_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL mul_function(zval *result, zval *op1, zval *op2) /* {{{ */ { if (mul_function_fast(result, op1, op2) == SUCCESS) { return SUCCESS; @@ -1163,7 +1163,7 @@ ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL mul_function(zval *result, zval *op1, zv } /* }}} */ -static ZEND_RESULT_CODE ZEND_FASTCALL pow_function_base(zval *result, zval *op1, zval *op2) /* {{{ */ +static zend_result ZEND_FASTCALL pow_function_base(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_uchar type_pair = TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2)); @@ -1220,7 +1220,7 @@ static ZEND_RESULT_CODE ZEND_FASTCALL pow_function_base(zval *result, zval *op1, } /* }}} */ -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL pow_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL pow_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_DEREF(op1); ZVAL_DEREF(op2); @@ -1256,7 +1256,7 @@ ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL pow_function(zval *result, zval *op1, zv #ifdef __clang__ __attribute__((no_sanitize("float-divide-by-zero"))) #endif -static ZEND_RESULT_CODE ZEND_FASTCALL div_function_base(zval *result, zval *op1, zval *op2) /* {{{ */ +static zend_result ZEND_FASTCALL div_function_base(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_uchar type_pair = TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2)); @@ -1300,7 +1300,7 @@ static ZEND_RESULT_CODE ZEND_FASTCALL div_function_base(zval *result, zval *op1, } /* }}} */ -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL div_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL div_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_DEREF(op1); ZVAL_DEREF(op2); @@ -1333,7 +1333,7 @@ ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL div_function(zval *result, zval *op1, zv } /* }}} */ -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL mod_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL mod_function(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_long op1_lval, op2_lval; @@ -1367,7 +1367,7 @@ ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL mod_function(zval *result, zval *op1, zv } /* }}} */ -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL boolean_xor_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL boolean_xor_function(zval *result, zval *op1, zval *op2) /* {{{ */ { int op1_val, op2_val; @@ -1417,7 +1417,7 @@ ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL boolean_xor_function(zval *result, zval } /* }}} */ -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL boolean_not_function(zval *result, zval *op1) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL boolean_not_function(zval *result, zval *op1) /* {{{ */ { if (Z_TYPE_P(op1) < IS_TRUE) { ZVAL_TRUE(result); @@ -1442,7 +1442,7 @@ ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL boolean_not_function(zval *result, zval } /* }}} */ -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL bitwise_not_function(zval *result, zval *op1) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL bitwise_not_function(zval *result, zval *op1) /* {{{ */ { try_again: switch (Z_TYPE_P(op1)) { @@ -1482,7 +1482,7 @@ ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL bitwise_not_function(zval *result, zval } /* }}} */ -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL bitwise_or_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL bitwise_or_function(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_long op1_lval, op2_lval; @@ -1564,7 +1564,7 @@ ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL bitwise_or_function(zval *result, zval * } /* }}} */ -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL bitwise_and_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL bitwise_and_function(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_long op1_lval, op2_lval; @@ -1646,7 +1646,7 @@ ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL bitwise_and_function(zval *result, zval } /* }}} */ -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL bitwise_xor_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL bitwise_xor_function(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_long op1_lval, op2_lval; @@ -1728,7 +1728,7 @@ ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL bitwise_xor_function(zval *result, zval } /* }}} */ -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL shift_left_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL shift_left_function(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_long op1_lval, op2_lval; @@ -1765,7 +1765,7 @@ ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL shift_left_function(zval *result, zval * } /* }}} */ -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL shift_right_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL shift_right_function(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_long op1_lval, op2_lval; @@ -1801,7 +1801,7 @@ ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL shift_right_function(zval *result, zval } /* }}} */ -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL concat_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL concat_function(zval *result, zval *op1, zval *op2) /* {{{ */ { zval *orig_op1 = op1; zval op1_copy, op2_copy; @@ -1992,7 +1992,7 @@ ZEND_API int ZEND_FASTCALL numeric_compare_function(zval *op1, zval *op2) /* {{{ } /* }}} */ -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL compare_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL compare_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_LONG(result, zend_compare(op1, op2)); return SUCCESS; @@ -2218,42 +2218,42 @@ ZEND_API zend_bool ZEND_FASTCALL zend_is_identical(zval *op1, zval *op2) /* {{{ } /* }}} */ -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL is_identical_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL is_identical_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_BOOL(result, zend_is_identical(op1, op2)); return SUCCESS; } /* }}} */ -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL is_not_identical_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL is_not_identical_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_BOOL(result, !zend_is_identical(op1, op2)); return SUCCESS; } /* }}} */ -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL is_equal_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL is_equal_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_BOOL(result, zend_compare(op1, op2) == 0); return SUCCESS; } /* }}} */ -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL is_not_equal_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL is_not_equal_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_BOOL(result, (zend_compare(op1, op2) != 0)); return SUCCESS; } /* }}} */ -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL is_smaller_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL is_smaller_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_BOOL(result, (zend_compare(op1, op2) < 0)); return SUCCESS; } /* }}} */ -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL is_smaller_or_equal_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL is_smaller_or_equal_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_BOOL(result, (zend_compare(op1, op2) <= 0)); return SUCCESS; @@ -2396,7 +2396,7 @@ static void ZEND_FASTCALL increment_string(zval *str) /* {{{ */ } /* }}} */ -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL increment_function(zval *op1) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL increment_function(zval *op1) /* {{{ */ { try_again: switch (Z_TYPE_P(op1)) { @@ -2461,7 +2461,7 @@ ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL increment_function(zval *op1) /* {{{ */ } /* }}} */ -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL decrement_function(zval *op1) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL decrement_function(zval *op1) /* {{{ */ { zend_long lval; double dval; diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 4c09ce3761624..efc2990ec0cd7 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -38,30 +38,30 @@ #define LONG_SIGN_MASK ZEND_LONG_MIN BEGIN_EXTERN_C() -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL add_function(zval *result, zval *op1, zval *op2); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL sub_function(zval *result, zval *op1, zval *op2); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL mul_function(zval *result, zval *op1, zval *op2); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL pow_function(zval *result, zval *op1, zval *op2); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL div_function(zval *result, zval *op1, zval *op2); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL mod_function(zval *result, zval *op1, zval *op2); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL boolean_xor_function(zval *result, zval *op1, zval *op2); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL boolean_not_function(zval *result, zval *op1); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL bitwise_not_function(zval *result, zval *op1); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL bitwise_or_function(zval *result, zval *op1, zval *op2); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL bitwise_and_function(zval *result, zval *op1, zval *op2); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL bitwise_xor_function(zval *result, zval *op1, zval *op2); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL shift_left_function(zval *result, zval *op1, zval *op2); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL shift_right_function(zval *result, zval *op1, zval *op2); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL concat_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL add_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL sub_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL mul_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL pow_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL div_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL mod_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL boolean_xor_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL boolean_not_function(zval *result, zval *op1); +ZEND_API zend_result ZEND_FASTCALL bitwise_not_function(zval *result, zval *op1); +ZEND_API zend_result ZEND_FASTCALL bitwise_or_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL bitwise_and_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL bitwise_xor_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL shift_left_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL shift_right_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL concat_function(zval *result, zval *op1, zval *op2); ZEND_API zend_bool ZEND_FASTCALL zend_is_identical(zval *op1, zval *op2); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL is_equal_function(zval *result, zval *op1, zval *op2); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL is_identical_function(zval *result, zval *op1, zval *op2); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL is_not_identical_function(zval *result, zval *op1, zval *op2); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL is_not_equal_function(zval *result, zval *op1, zval *op2); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL is_smaller_function(zval *result, zval *op1, zval *op2); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL is_smaller_or_equal_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL is_equal_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL is_identical_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL is_not_identical_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL is_not_equal_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL is_smaller_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL is_smaller_or_equal_function(zval *result, zval *op1, zval *op2); ZEND_API zend_bool ZEND_FASTCALL zend_class_implements_interface(const zend_class_entry *class_ce, const zend_class_entry *interface_ce); ZEND_API zend_bool ZEND_FASTCALL instanceof_function_slow(const zend_class_entry *instance_ce, const zend_class_entry *ce); @@ -255,8 +255,8 @@ zend_memnrstr(const char *haystack, const char *needle, size_t needle_len, const } } -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL increment_function(zval *op1); -ZEND_API ZEND_RESULT_CODE ZEND_FASTCALL decrement_function(zval *op2); +ZEND_API zend_result ZEND_FASTCALL increment_function(zval *op1); +ZEND_API zend_result ZEND_FASTCALL decrement_function(zval *op2); ZEND_API void ZEND_FASTCALL convert_scalar_to_number(zval *op); ZEND_API void ZEND_FASTCALL _convert_to_string(zval *op); @@ -738,7 +738,7 @@ overflow: ZEND_ATTRIBUTE_COLD_LABEL #endif } -static zend_always_inline ZEND_RESULT_CODE fast_add_function(zval *result, zval *op1, zval *op2) +static zend_always_inline zend_result fast_add_function(zval *result, zval *op1, zval *op2) { if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { @@ -842,7 +842,7 @@ overflow: ZEND_ATTRIBUTE_COLD_LABEL #endif } -static zend_always_inline ZEND_RESULT_CODE fast_div_function(zval *result, zval *op1, zval *op2) +static zend_always_inline zend_result fast_div_function(zval *result, zval *op1, zval *op2) { return div_function(result, op1, op2); } diff --git a/Zend/zend_signal.c b/Zend/zend_signal.c index 79043b199ea60..80feecd98ff3a 100644 --- a/Zend/zend_signal.c +++ b/Zend/zend_signal.c @@ -281,7 +281,7 @@ ZEND_API void zend_signal(int signo, void (*handler)(int)) * Set a handler for a signal we want to defer. * Previously set handler must have been saved before. */ -static ZEND_RESULT_CODE zend_signal_register(int signo, void (*handler)(int, siginfo_t*, void*)) +static zend_result zend_signal_register(int signo, void (*handler)(int, siginfo_t*, void*)) { struct sigaction sa; diff --git a/Zend/zend_stream.c b/Zend/zend_stream.c index 18419457b1376..1dfc5b1bc1e89 100644 --- a/Zend/zend_stream.c +++ b/Zend/zend_stream.c @@ -73,7 +73,7 @@ ZEND_API void zend_stream_init_filename(zend_file_handle *handle, const char *fi handle->filename = filename; } -ZEND_API ZEND_RESULT_CODE zend_stream_open(const char *filename, zend_file_handle *handle) /* {{{ */ +ZEND_API zend_result zend_stream_open(const char *filename, zend_file_handle *handle) /* {{{ */ { zend_string *opened_path; if (zend_stream_open_function) { @@ -113,7 +113,7 @@ static ssize_t zend_stream_read(zend_file_handle *file_handle, char *buf, size_t return file_handle->handle.stream.reader(file_handle->handle.stream.handle, buf, len); } /* }}} */ -ZEND_API ZEND_RESULT_CODE zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t *len) /* {{{ */ +ZEND_API zend_result zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t *len) /* {{{ */ { size_t file_size; diff --git a/Zend/zend_stream.h b/Zend/zend_stream.h index 57ddc3df15f43..023e2d0555a4d 100644 --- a/Zend/zend_stream.h +++ b/Zend/zend_stream.h @@ -66,8 +66,8 @@ typedef struct _zend_file_handle { BEGIN_EXTERN_C() ZEND_API void zend_stream_init_fp(zend_file_handle *handle, FILE *fp, const char *filename); ZEND_API void zend_stream_init_filename(zend_file_handle *handle, const char *filename); -ZEND_API ZEND_RESULT_CODE zend_stream_open(const char *filename, zend_file_handle *handle); -ZEND_API ZEND_RESULT_CODE zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t *len); +ZEND_API zend_result zend_stream_open(const char *filename, zend_file_handle *handle); +ZEND_API zend_result zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t *len); ZEND_API void zend_file_handle_dtor(zend_file_handle *fh); ZEND_API int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2); END_EXTERN_C() diff --git a/Zend/zend_ts_hash.c b/Zend/zend_ts_hash.c index 425ee7d13289e..d4e972d0e3e5d 100644 --- a/Zend/zend_ts_hash.c +++ b/Zend/zend_ts_hash.c @@ -186,9 +186,9 @@ ZEND_API void zend_ts_hash_reverse_apply(TsHashTable *ht, apply_func_t apply_fun end_write(ht); } -ZEND_API ZEND_RESULT_CODE zend_ts_hash_del(TsHashTable *ht, zend_string *key) +ZEND_API zend_result zend_ts_hash_del(TsHashTable *ht, zend_string *key) { - ZEND_RESULT_CODE retval; + zend_result retval; begin_write(ht); retval = zend_hash_del(TS_HASH(ht), key); @@ -197,9 +197,9 @@ ZEND_API ZEND_RESULT_CODE zend_ts_hash_del(TsHashTable *ht, zend_string *key) return retval; } -ZEND_API ZEND_RESULT_CODE zend_ts_hash_index_del(TsHashTable *ht, zend_ulong h) +ZEND_API zend_result zend_ts_hash_index_del(TsHashTable *ht, zend_ulong h) { - ZEND_RESULT_CODE retval; + zend_result retval; begin_write(ht); retval = zend_hash_index_del(TS_HASH(ht), h); diff --git a/Zend/zend_ts_hash.h b/Zend/zend_ts_hash.h index 2f4e5575f19dd..51801e4e05f17 100644 --- a/Zend/zend_ts_hash.h +++ b/Zend/zend_ts_hash.h @@ -56,8 +56,8 @@ ZEND_API void zend_ts_hash_reverse_apply(TsHashTable *ht, apply_func_t apply_fun /* Deletes */ -ZEND_API ZEND_RESULT_CODE zend_ts_hash_del(TsHashTable *ht, zend_string *key); -ZEND_API ZEND_RESULT_CODE zend_ts_hash_index_del(TsHashTable *ht, zend_ulong h); +ZEND_API zend_result zend_ts_hash_del(TsHashTable *ht, zend_string *key); +ZEND_API zend_result zend_ts_hash_index_del(TsHashTable *ht, zend_ulong h); /* Data retrieval */ ZEND_API zval *zend_ts_hash_find(TsHashTable *ht, zend_string *key); diff --git a/Zend/zend_virtual_cwd.c b/Zend/zend_virtual_cwd.c index dab7fdca3b0d0..250d1704dcf19 100644 --- a/Zend/zend_virtual_cwd.c +++ b/Zend/zend_virtual_cwd.c @@ -1178,7 +1178,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func } /* }}} */ -CWD_API ZEND_RESULT_CODE virtual_chdir(const char *path) /* {{{ */ +CWD_API zend_result virtual_chdir(const char *path) /* {{{ */ { return virtual_file_ex(&CWDG(cwd), path, php_is_dir_ok, CWD_REALPATH) ? FAILURE : SUCCESS; } diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index a650f99447f86..e32ed281ee71c 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -296,11 +296,11 @@ static size_t count_commas(const char *p, const char *end) { return count; } -/* {{{ static ZEND_RESULT_CODE php_mb_parse_encoding_list() +/* {{{ static zend_result php_mb_parse_encoding_list() * Return FAILURE if input contains any illegal encoding, otherwise SUCCESS. * Emits a ValueError in function context and a warning in INI context, in INI context arg_num must be 0. */ -static ZEND_RESULT_CODE php_mb_parse_encoding_list(const char *value, size_t value_length, +static zend_result php_mb_parse_encoding_list(const char *value, size_t value_length, const mbfl_encoding ***return_list, size_t *return_size, bool persistent, uint32_t arg_num, zend_bool allow_pass_encoding) { @@ -521,7 +521,7 @@ static size_t php_mb_zend_encoding_converter(unsigned char **to, size_t *to_leng return loc; } -static ZEND_RESULT_CODE php_mb_zend_encoding_list_parser(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, bool persistent) +static zend_result php_mb_zend_encoding_list_parser(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, bool persistent) { return php_mb_parse_encoding_list( encoding_list, encoding_list_len, @@ -534,7 +534,7 @@ static const zend_encoding *php_mb_zend_internal_encoding_getter(void) return (const zend_encoding *)MBSTRG(internal_encoding); } -static ZEND_RESULT_CODE php_mb_zend_internal_encoding_setter(const zend_encoding *encoding) +static zend_result php_mb_zend_internal_encoding_setter(const zend_encoding *encoding) { MBSTRG(internal_encoding) = (const mbfl_encoding *)encoding; return SUCCESS; diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 9bd2ab15e1386..9ee1a5b5d7243 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -119,15 +119,15 @@ zend_bool fallback_process = 0; /* process uses file cache fallback */ #endif static zend_op_array *(*accelerator_orig_compile_file)(zend_file_handle *file_handle, int type); -static ZEND_RESULT_CODE (*accelerator_orig_zend_stream_open_function)(const char *filename, zend_file_handle *handle ); +static zend_result (*accelerator_orig_zend_stream_open_function)(const char *filename, zend_file_handle *handle ); static zend_string *(*accelerator_orig_zend_resolve_path)(const char *filename, size_t filename_len); static void (*accelerator_orig_zend_error_cb)(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message); static zif_handler orig_chdir = NULL; static ZEND_INI_MH((*orig_include_path_on_modify)) = NULL; -static ZEND_RESULT_CODE (*orig_post_startup_cb)(void); +static zend_result (*orig_post_startup_cb)(void); static void accel_gen_system_id(void); -static ZEND_RESULT_CODE accel_post_startup(void); +static zend_result accel_post_startup(void); static int accel_finish_startup(void); static void preload_shutdown(void); @@ -304,7 +304,7 @@ static inline int accel_restart_is_active(void) } /* Creates a read lock for SHM access */ -static inline ZEND_RESULT_CODE accel_activate_add(void) +static inline zend_result accel_activate_add(void) { #ifdef ZEND_WIN32 SHM_UNPROTECT(); @@ -2269,7 +2269,7 @@ static int accel_gen_uname_id(void) #endif /* zend_stream_open_function() replacement for PHP 5.3 and above */ -static ZEND_RESULT_CODE persistent_stream_open_function(const char *filename, zend_file_handle *handle) +static zend_result persistent_stream_open_function(const char *filename, zend_file_handle *handle) { if (ZCG(cache_persistent_script)) { /* check if callback is called from include_once or it's a main request */ @@ -2400,7 +2400,7 @@ static void accel_reset_pcre_cache(void) } ZEND_HASH_FOREACH_END(); } -ZEND_RESULT_CODE accel_activate(INIT_FUNC_ARGS) +zend_result accel_activate(INIT_FUNC_ARGS) { if (!ZCG(enabled) || !accel_startup_ok) { ZCG(accelerator_enabled) = 0; @@ -2963,13 +2963,13 @@ static int accel_startup(zend_extension *extension) return SUCCESS; } -static ZEND_RESULT_CODE accel_post_startup(void) +static zend_result accel_post_startup(void) { zend_function *func; zend_ini_entry *ini_entry; if (orig_post_startup_cb) { - ZEND_RESULT_CODE (*cb)(void) = orig_post_startup_cb; + zend_result (*cb)(void) = orig_post_startup_cb; orig_post_startup_cb = NULL; if (cb() != SUCCESS) { @@ -4368,7 +4368,7 @@ static void preload_load(void) } } -static ZEND_RESULT_CODE preload_autoload(zend_string *filename) +static zend_result preload_autoload(zend_string *filename) { zend_persistent_script *persistent_script; zend_op_array *op_array; diff --git a/ext/opcache/ZendAccelerator.h b/ext/opcache/ZendAccelerator.h index a0749cb22d33a..0d6dda86a1256 100644 --- a/ext/opcache/ZendAccelerator.h +++ b/ext/opcache/ZendAccelerator.h @@ -316,7 +316,7 @@ extern zend_accel_globals accel_globals; extern char *zps_api_failure_reason; void accel_shutdown(void); -ZEND_RESULT_CODE accel_activate(INIT_FUNC_ARGS); +zend_result accel_activate(INIT_FUNC_ARGS); int accel_post_deactivate(void); void zend_accel_schedule_restart(zend_accel_restart_reason reason); void zend_accel_schedule_restart_if_necessary(zend_accel_restart_reason reason); diff --git a/main/main.c b/main/main.c index a02a6698918bb..c9cb9b2d8563b 100644 --- a/main/main.c +++ b/main/main.c @@ -1521,13 +1521,13 @@ static size_t php_zend_stream_fsizer(void *handle) /* {{{ */ } /* }}} */ -static ZEND_RESULT_CODE php_stream_open_for_zend(const char *filename, zend_file_handle *handle) /* {{{ */ +static zend_result php_stream_open_for_zend(const char *filename, zend_file_handle *handle) /* {{{ */ { return php_stream_open_for_zend_ex(filename, handle, USE_PATH|REPORT_ERRORS|STREAM_OPEN_FOR_INCLUDE); } /* }}} */ -PHPAPI ZEND_RESULT_CODE php_stream_open_for_zend_ex(const char *filename, zend_file_handle *handle, int mode) /* {{{ */ +PHPAPI zend_result php_stream_open_for_zend_ex(const char *filename, zend_file_handle *handle, int mode) /* {{{ */ { zend_string *opened_path; php_stream *stream = php_stream_open_wrapper((char *)filename, "rb", mode, &opened_path); From bbc67c49b7bd04da3fba3ae20579c4726caf3de8 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 23 Aug 2020 22:35:01 +0200 Subject: [PATCH 166/170] Attempt to fix some variable types in VM due to JIT failures --- Zend/zend_vm_def.h | 12 +++++++----- Zend/zend_vm_execute.h | 30 +++++++++++++++++------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 9f735c5a4c8ed..00bb179561f0f 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -6962,6 +6962,7 @@ ZEND_VM_HANDLER(114, ZEND_ISSET_ISEMPTY_VAR, CONST|TMPVAR|CV, UNUSED, VAR_FETCH| { USE_OPLINE zval *value; + /* Should be bool result? as below got: result = (opline->extended_value & ZEND_ISEMPTY) */ int result; zval *varname; zend_string *name, *tmp_name; @@ -7007,17 +7008,18 @@ ZEND_VM_HANDLER(180, ZEND_ISSET_ISEMPTY_STATIC_PROP, ANY, CLASS_FETCH, ISSET|CAC { USE_OPLINE zval *value; - int result; + zend_result fetch_result; + bool result; SAVE_OPLINE(); - result = zend_fetch_static_property_address(&value, NULL, opline->extended_value & ~ZEND_ISEMPTY, BP_VAR_IS, 0 OPLINE_CC EXECUTE_DATA_CC); + fetch_result = zend_fetch_static_property_address(&value, NULL, opline->extended_value & ~ZEND_ISEMPTY, BP_VAR_IS, 0 OPLINE_CC EXECUTE_DATA_CC); if (!(opline->extended_value & ZEND_ISEMPTY)) { - result = result == SUCCESS && Z_TYPE_P(value) > IS_NULL && + result = fetch_result == SUCCESS && Z_TYPE_P(value) > IS_NULL && (!Z_ISREF_P(value) || Z_TYPE_P(Z_REFVAL_P(value)) != IS_NULL); } else { - result = result != SUCCESS || !i_zend_is_true(value); + result = fetch_result != SUCCESS || !i_zend_is_true(value); } ZEND_VM_SMART_BRANCH(result, 1); @@ -7027,7 +7029,7 @@ ZEND_VM_COLD_CONSTCONST_HANDLER(115, ZEND_ISSET_ISEMPTY_DIM_OBJ, CONST|TMPVAR|CV { USE_OPLINE zval *container; - int result; + bool result; zend_ulong hval; zval *offset; diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 1e0bfabe381cd..e6712b86afbca 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -2405,17 +2405,18 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_STATIC_PROP_SPEC { USE_OPLINE zval *value; - int result; + zend_result fetch_result; + bool result; SAVE_OPLINE(); - result = zend_fetch_static_property_address(&value, NULL, opline->extended_value & ~ZEND_ISEMPTY, BP_VAR_IS, 0 OPLINE_CC EXECUTE_DATA_CC); + fetch_result = zend_fetch_static_property_address(&value, NULL, opline->extended_value & ~ZEND_ISEMPTY, BP_VAR_IS, 0 OPLINE_CC EXECUTE_DATA_CC); if (!(opline->extended_value & ZEND_ISEMPTY)) { - result = result == SUCCESS && Z_TYPE_P(value) > IS_NULL && + result = fetch_result == SUCCESS && Z_TYPE_P(value) > IS_NULL && (!Z_ISREF_P(value) || Z_TYPE_P(Z_REFVAL_P(value)) != IS_NULL); } else { - result = result != SUCCESS || !i_zend_is_true(value); + result = fetch_result != SUCCESS || !i_zend_is_true(value); } ZEND_VM_SMART_BRANCH(result, 1); @@ -6315,7 +6316,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM { USE_OPLINE zval *container; - int result; + bool result; zend_ulong hval; zval *offset; @@ -8471,7 +8472,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CON { USE_OPLINE zval *container; - int result; + bool result; zend_ulong hval; zval *offset; @@ -9425,6 +9426,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_CONST_U { USE_OPLINE zval *value; + /* Should be bool result? as below got: result = (opline->extended_value & ZEND_ISEMPTY) */ int result; zval *varname; zend_string *name, *tmp_name; @@ -10854,7 +10856,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CON { USE_OPLINE zval *container; - int result; + bool result; zend_ulong hval; zval *offset; @@ -14997,7 +14999,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_TMP { USE_OPLINE zval *container; - int result; + bool result; zend_ulong hval; zval *offset; @@ -16389,7 +16391,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_TMP { USE_OPLINE zval *container; - int result; + bool result; zend_ulong hval; zval *offset; @@ -16787,6 +16789,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_TMPVAR_ { USE_OPLINE zval *value; + /* Should be bool result? as below got: result = (opline->extended_value & ZEND_ISEMPTY) */ int result; zval *varname; zend_string *name, *tmp_name; @@ -17702,7 +17705,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_TMP { USE_OPLINE zval *container; - int result; + bool result; zend_ulong hval; zval *offset; @@ -41169,7 +41172,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CV_ { USE_OPLINE zval *container; - int result; + bool result; zend_ulong hval; zval *offset; @@ -44617,7 +44620,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CV_ { USE_OPLINE zval *container; - int result; + bool result; zend_ulong hval; zval *offset; @@ -46324,6 +46327,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_CV_UNUS { USE_OPLINE zval *value; + /* Should be bool result? as below got: result = (opline->extended_value & ZEND_ISEMPTY) */ int result; zval *varname; zend_string *name, *tmp_name; @@ -49739,7 +49743,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CV_ { USE_OPLINE zval *container; - int result; + bool result; zend_ulong hval; zval *offset; From a953eaadb509c9a3294e5d2f4e181dc861383097 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Mon, 24 Aug 2020 16:29:31 +0200 Subject: [PATCH 167/170] Partial revert of 'Shot in the dark to fix JIT' --- Zend/zend_operators.c | 6 +++--- Zend/zend_operators.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 9348ec9a74311..3488292461630 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -2524,13 +2524,13 @@ ZEND_API zend_result ZEND_FASTCALL decrement_function(zval *op1) /* {{{ */ } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_is_true(zval *op) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_is_true(zval *op) /* {{{ */ { return i_zend_is_true(op); } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_object_is_true(zval *op) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_object_is_true(zval *op) /* {{{ */ { zend_object *zobj = Z_OBJ_P(op); zval tmp; @@ -2538,7 +2538,7 @@ ZEND_API int ZEND_FASTCALL zend_object_is_true(zval *op) /* {{{ */ return Z_TYPE(tmp) == IS_TRUE; } zend_error(E_RECOVERABLE_ERROR, "Object of class %s could not be converted to bool", ZSTR_VAL(zobj->ce->name)); - return 1; + return false; } /* }}} */ diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index efc2990ec0cd7..9f749e4a31e4d 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -341,8 +341,8 @@ static zend_always_inline zend_bool try_convert_to_string(zval *op) { #define convert_to_string(op) if (Z_TYPE_P(op) != IS_STRING) { _convert_to_string((op)); } -ZEND_API int ZEND_FASTCALL zend_is_true(zval *op); -ZEND_API int ZEND_FASTCALL zend_object_is_true(zval *op); +ZEND_API bool ZEND_FASTCALL zend_is_true(zval *op); +ZEND_API bool ZEND_FASTCALL zend_object_is_true(zval *op); #define zval_is_true(op) \ zend_is_true(op) From 3bc1ce8abdbf695b63b342bb1d3b058d73d839ec Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Mon, 24 Aug 2020 17:03:02 +0200 Subject: [PATCH 168/170] Other change to see if this is root cause of JIT failure Might be due to EXT_CALL zend_is_true, r0 in zend_jit_x86.dasc line 7932 --- Zend/zend_operators.c | 4 ++-- Zend/zend_operators.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 3488292461630..7de4cd8ad7ad1 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -2524,9 +2524,9 @@ ZEND_API zend_result ZEND_FASTCALL decrement_function(zval *op1) /* {{{ */ } /* }}} */ -ZEND_API bool ZEND_FASTCALL zend_is_true(zval *op) /* {{{ */ +ZEND_API int ZEND_FASTCALL zend_is_true(zval *op) /* {{{ */ { - return i_zend_is_true(op); + return (int) i_zend_is_true(op); } /* }}} */ diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 9f749e4a31e4d..d543b7b03c2bb 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -341,15 +341,15 @@ static zend_always_inline zend_bool try_convert_to_string(zval *op) { #define convert_to_string(op) if (Z_TYPE_P(op) != IS_STRING) { _convert_to_string((op)); } -ZEND_API bool ZEND_FASTCALL zend_is_true(zval *op); +ZEND_API int ZEND_FASTCALL zend_is_true(zval *op); ZEND_API bool ZEND_FASTCALL zend_object_is_true(zval *op); #define zval_is_true(op) \ zend_is_true(op) -static zend_always_inline int i_zend_is_true(zval *op) +static zend_always_inline bool i_zend_is_true(zval *op) { - int result = 0; + bool result = 0; again: switch (Z_TYPE_P(op)) { From 85dc37f2fc7aaa9f0a4e96612339690aa19c3e50 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Tue, 25 Aug 2020 15:25:47 +0200 Subject: [PATCH 169/170] Fix spurious change --- Zend/zend_exceptions.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index 709dfa14c727b..7184f5bf68c6b 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -1,4 +1,4 @@ - /* +/* +----------------------------------------------------------------------+ | Zend Engine | +----------------------------------------------------------------------+ From 9ffcda208af6075b72eadbc74153724225013667 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Wed, 26 Aug 2020 19:21:32 +0200 Subject: [PATCH 170/170] Update UPGRADING.INTERNALS --- UPGRADING.INTERNALS | 184 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 183 insertions(+), 1 deletion(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 404f5f9c67de8..301faf16cdcff 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -158,6 +158,28 @@ PHP 8.0 INTERNALS UPGRADE NOTES - zend_fcall_info_argp() - zend_fcall_info_argv() - zend_fcall_info_argn() + - zend_startup() + - zend_set_memory_limit() + - pass_two() + - zend_startup_constants() + - zend_shutdown_constants() + - zend_startup_extensions_mechanism() + - zend_startup_extensions() + - zend_register_extension() + - highlight_string() + - zend_ini_startup() + - zend_ini_shutdown() + - zend_ini_global_shutdown() + - zend_ini_deactivate() + - zend_copy_ini_directives() + - zend_prepare_string_for_scanning() + - zend_init_rsrc_list() + - zend_list_close() + - zend_signal() + - zend_sigaction() + - zend_stack_init() + - zend_stack_del_top() + - zend_stack_destroy() 2. Argument int to uint32_t in Zend Engine 4.0: - _zend_get_parameters_array_ex() - zend_copy_parameters_array() @@ -169,8 +191,39 @@ PHP 8.0 INTERNALS UPGRADE NOTES - zend_wrong_parameter*() - zend_wrong_callback_error() - zend_parse_arg_class() - 3. Argument int to zend_bool in Zend Engine 4.0: + 3. Argument int to bool in Zend Engine 4.0: - add_next_index_bool() + - zend_register_class_alias_ex() + - add_assoc_bool_ex() + - add_index_bool() + - zend_fcall_info_args_clear() + - zend_set_local_var() + - zend_set_local_var_str() + - zend_parse_arg_*() + - shutdown_memory_manager() + - zend_memory_usage() + - zend_memory_peak_usage() + - zend_mm_shutdown() + - zend_eval_string*() + - zend_set_timeout() + - _zend_hash_append_ex() + - _zend_hash_append_ptr_ex() + - zend_alter_ini_entry_ex() + - (*zend_encoding_list_parser) typedef + - zend_multibyte_parse_encoding_list() + - zend_safe_address() + - zend_string_tolower_ex() + - zend_string_alloc() + - zend_string_safe_alloc() + - zend_string_init() + - zend_string_dup() + - zend_string_realloc() + - zend_string_extend() + - zend_string_truncate() + - zend_string_safe_realloc() + - zend_string_release_ex() + - zend_ts_hash_merge() + - zend_ts_hash_sort() 4. Argument int to size_t in Zend Engine 4.0: - zend_set_hash_symbol() 5. Argument zval* to zend_object* in Zend Engine 4.0: @@ -185,6 +238,135 @@ PHP 8.0 INTERNALS UPGRADE NOTES - zend_get_exception_base() 6. Argument zval* to zend_long in Zend Engine 4.0: - _php_math_longtobase() + 7. Return type from int to zend_result in Zend Engine 4.0: + - (*stream_open_function) in _zend_utility_functions + - (*zend_post_startup_cb) + - (*zend_preload_autoload) + - zend_execute_scripts() + - zend_post_startup() + - _zend_get_parameters_array_ex() + - zend_copy_parameters_array() + - zend_parse_parameters() + - zend_parse_parameters_ex() + - zend_parse_method_parameters() + - zend_parse_method_parameters_ex() + - zend_parse_method_parameters() + - zend_register_functions() + - zend_startup_module() + - zend_startup_module_ex() + - zend_register_class_alias_ex() + - zend_disable_function() + - zend_disable_class() + - zend_update_class_constants() + - zend_update_static_property*() + - object_init_ex() + - object_and_properties_init() + - add_index_zval() + - add_next_index_long_*() + - array_set_zval_key() + - _call_user_function_impl() + - zend_fcall_info_*() + - zend_call_function() + - zend_set_hash_symbol() + - zend_delete_global_variable() + - zend_set_local_var() + - zend_set_local_var_str() + - zend_forbid_dynamic_call() + - zend_get_default_from_internal_arg_info() + - zend_try_assign_typed_ref*() + - zend_ast_evaluate() + - zend_startup_builtin_functions() + - do_bind_function() + - do_bind_class() + - zend_unmangle_property_name_ex() + - zend_register_auto_global() + - zend_register_constant() + - zend_exception_error() + - zend_eval_string*() + - zend_undefined_offset_write() + - zend_undefined_index_write() + - zval_update_constant(_ex)() + - zend_load_extension() + - zend_load_extension_handle() + - zend_hash_del(_ind)() + - zend_hash_str_del(_ind)() + - zend_hash_index_del() + - zend_hash_move_forward_ex() + - zend_hash_move_backward_ex() + - zend_hash_get_current_key_ex() + - zend_hash_get_current_key_type_ex() + - zend_symtable_del(_ind)() + - zend_symtable_str_del(_ind)() + - highlight_file() + - zend_do_link_class() + - zend_alter_ini_entry*() + - zend_restore_ini_entry() + - zend_ini_register_displayer() + - zend_ini_open_file_for_scanning() + - zend_ini_prepare_string_for_scanning() + - zend_user_it_valid() + - zend_create_internal_iterator_zval() + - zend_multibyte_set_filter() + - zend_lex_tstring() + - _zend_module_entry module_startup_func, module_shutdown_func, + request_startup_func, and request_shutdown_func function pointers + - (*zend_encoding_list_parser) typedef + - (*zend_encoding_internal_encoding_setter) typedef + - zend_multibyte_set_functions() + - zend_multibyte_set_script_encoding_by_string() + - add_function() + - sub_function() + - mul_function() + - pow_function() + - div_function() + - mod_function() + - boolean_xor_function() + - boolean_not_function() + - bitwise_not_function() + - bitwise_or_function() + - bitwise_and_function() + - bitwise_xor_function() + - shift_left_function() + - shift_right_function() + - concat_function() + - is_equal_function( + - is_identical_function() + - is_not_identical_function() + - is_not_equal_function() + - is_smaller_function() + - is_smaller_or_equal_function(zv + - increment_function() + - decrement_function() + - zend_stream_open() + - zend_stream_fixup() + - zend_ts_hash_del() + - zend_ts_hash_index_del() + 8. Return type from int to bool in Zend Engine 4.0: + - zend_make_printable_zval() + - zend_parse_arg_*() + - is_zend_mm() + - is_zend_ptr() + - zend_mm_is_custom_heap() + - (*zend_mm_chunk_truncate_t) + - (*zend_mm_chunk_extend_t) + - zend_bitset_empty() + - zend_is_smart_branch() + - zend_check_arg_send_type() + - zend_verify_const_access() + - zend_gdb_register_code() + - zend_gdb_present() + - _zend_handle_numeric_str(_ex)() + - zend_hash_exists_ind() + - zend_hash_str_exists_ind() + - zend_symtable_exists(_ind)() + - zend_symtable_str_exists() + - (*zend_encoding_lexer_compatibility_checker) + - zend_object_is_true() + - i_zend_is_true() + - zendi_smart_streq() + - zend_stack_is_empty() + - zend_ts_hash_exists() + - zend_ts_hash_index_exists() u. Instead of overwriting zend_error_cb extensions with debugging, monitoring use-cases catching Errors/Exceptions are strongly encouraged to use