From 8c06a6472c52e83e8d57c61d3c1c9207a5127583 Mon Sep 17 00:00:00 2001 From: Levi Morrison Date: Mon, 22 Jul 2024 19:17:52 -0600 Subject: [PATCH 01/12] Add outline versions of zend_string free/release APIs --- Zend/Optimizer/dfa_pass.c | 2 +- Zend/Optimizer/zend_optimizer.c | 2 +- Zend/zend.c | 9 ++++- Zend/zend_API.c | 20 +++++----- Zend/zend_API.h | 2 +- Zend/zend_ast.c | 6 +-- Zend/zend_compile.c | 10 ++--- Zend/zend_constants.c | 2 +- Zend/zend_exceptions.c | 14 +++---- Zend/zend_execute.c | 62 +++++++++++++++--------------- Zend/zend_execute_API.c | 4 +- Zend/zend_inheritance.c | 8 ++-- Zend/zend_ini.c | 4 +- Zend/zend_language_scanner.l | 2 +- Zend/zend_operators.c | 9 ++++- Zend/zend_operators.h | 1 + Zend/zend_smart_str.c | 5 +++ Zend/zend_smart_str.h | 1 + Zend/zend_string.c | 20 ++++++++++ Zend/zend_string.h | 5 +++ Zend/zend_types.h | 16 +++++--- Zend/zend_vm_def.h | 12 +++--- Zend/zend_vm_execute.h | 52 ++++++++++++------------- ext/date/php_date.c | 6 +-- ext/dom/document.c | 2 +- ext/fileinfo/libmagic/apprentice.c | 2 +- ext/fileinfo/libmagic/softmagic.c | 6 +-- ext/iconv/iconv.c | 2 +- ext/json/json.c | 2 +- ext/mbstring/mbstring.c | 18 ++++----- ext/opcache/ZendAccelerator.c | 6 +-- ext/opcache/jit/zend_jit_helpers.c | 14 +++---- ext/openssl/openssl.c | 24 ++++++------ ext/openssl/xp_ssl.c | 14 +++---- ext/pcre/php_pcre.c | 14 +++---- ext/pdo/pdo_stmt.c | 18 ++++----- ext/pdo_sqlite/pdo_sqlite.c | 4 +- ext/phar/phar_object.c | 18 ++++----- ext/phar/util.c | 4 +- ext/reflection/php_reflection.c | 22 +++++------ ext/session/mod_files.c | 4 +- ext/session/session.c | 10 ++--- ext/simplexml/simplexml.c | 2 +- ext/spl/spl_directory.c | 4 +- ext/standard/array.c | 6 +-- ext/standard/basic_functions.c | 4 +- ext/standard/exec.c | 8 ++-- ext/standard/file.c | 2 +- ext/standard/http.c | 4 +- ext/standard/http_fopen_wrapper.c | 2 +- ext/standard/incomplete_class.c | 4 +- ext/standard/info.c | 10 ++--- ext/standard/password.c | 6 +-- ext/standard/proc_open.c | 6 +-- ext/standard/streamsfuncs.c | 6 +-- ext/standard/string.c | 23 ++++++----- ext/standard/var.c | 2 +- ext/standard/var_unserializer.re | 34 ++++++++-------- ext/xml/xml.c | 2 +- ext/zip/php_zip.c | 6 +-- ext/zlib/zlib.c | 12 +++--- main/SAPI.c | 4 +- main/main.c | 12 +++--- main/network.c | 4 +- main/output.c | 4 +- main/streams/streams.c | 2 +- main/streams/transports.c | 2 +- sapi/cli/php_cli.c | 2 +- 68 files changed, 343 insertions(+), 288 deletions(-) diff --git a/Zend/Optimizer/dfa_pass.c b/Zend/Optimizer/dfa_pass.c index ce2a19f2e8fe9..d010bf2db2f7c 100644 --- a/Zend/Optimizer/dfa_pass.c +++ b/Zend/Optimizer/dfa_pass.c @@ -265,7 +265,7 @@ static bool safe_instanceof(zend_class_entry *ce1, zend_class_entry *ce2) { return instanceof_function(ce1, ce2); } -static inline bool can_elide_list_type( +static bool can_elide_list_type( const zend_script *script, const zend_op_array *op_array, const zend_ssa_var_info *use_info, zend_type type) { diff --git a/Zend/Optimizer/zend_optimizer.c b/Zend/Optimizer/zend_optimizer.c index 3f54db9f09f91..464c6f96f86bf 100644 --- a/Zend/Optimizer/zend_optimizer.c +++ b/Zend/Optimizer/zend_optimizer.c @@ -247,7 +247,7 @@ static inline int zend_optimizer_add_literal_string(zend_op_array *op_array, zen return zend_optimizer_add_literal(op_array, &zv); } -static inline void drop_leading_backslash(zval *val) { +static void drop_leading_backslash(zval *val) { if (Z_STRVAL_P(val)[0] == '\\') { zend_string *str = zend_string_init(Z_STRVAL_P(val) + 1, Z_STRLEN_P(val) - 1, 0); zval_ptr_dtor_nogc(val); diff --git a/Zend/zend.c b/Zend/zend.c index ef5ea8cebc78b..98ea35ed2b6d9 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -1573,7 +1573,7 @@ static ZEND_COLD void zend_error_va_list( { zend_string *message = zend_vstrpprintf(0, format, args); zend_error_zstr_at(orig_type, error_filename, error_lineno, message); - zend_string_release(message); + zend_string_release_outline(message); } static ZEND_COLD void get_filename_lineno(int type, zend_string **filename, uint32_t *lineno) { @@ -2047,3 +2047,10 @@ ZEND_API void zend_alloc_ce_cache(zend_string *type_name) GC_ADD_FLAGS(type_name, IS_STR_CLASS_NAME_MAP_PTR); GC_SET_REFCOUNT(type_name, ret); } + + +ZEND_API extern inline uint32_t zend_gc_refcount(const zend_refcounted_h *p); +ZEND_API extern inline uint32_t zend_gc_delref(zend_refcounted_h *p); +ZEND_API extern zend_always_inline uint8_t zval_gc_type(uint32_t gc_type_info); +ZEND_API extern zend_always_inline uint32_t zval_gc_flags(uint32_t gc_type_info); +ZEND_API extern zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info); diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 00a4df3de3fef..49234ffa30187 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -104,7 +104,7 @@ ZEND_API ZEND_COLD void zend_wrong_property_read(zval *object, zval *property) zend_string *tmp_property_name; zend_string *property_name = zval_get_tmp_string(property, &tmp_property_name); zend_error(E_WARNING, "Attempt to read property \"%s\" on %s", ZSTR_VAL(property_name), zend_zval_value_name(object)); - zend_tmp_string_release(tmp_property_name); + zend_tmp_string_release_outline(tmp_property_name); } /* Argument parsing API -- andrei */ @@ -217,7 +217,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_none_error(void) /* zend_argument_count_error("%s() expects exactly 0 arguments, %d given", ZSTR_VAL(func_name), num_args); - zend_string_release(func_name); + zend_string_release_outline(func_name); } /* }}} */ @@ -235,7 +235,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_error(uint32_t num_args ); - zend_string_release(func_name); + zend_string_release_outline(func_name); } /* }}} */ @@ -405,7 +405,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_error_variadic(zend_class_en arg_name ? " ($" : "", arg_name ? arg_name : "", arg_name ? ")" : "", message ); efree(message); - zend_string_release(func_name); + zend_string_release_outline(func_name); } /* }}} */ @@ -510,9 +510,9 @@ static ZEND_COLD bool zend_null_arg_deprecated(const char *fallback_type, uint32 ZSTR_VAL(func_name), arg_num, arg_name ? " ($" : "", arg_name ? arg_name : "", arg_name ? ")" : "", type); - zend_string_release(func_name); + zend_string_release_outline(func_name); if (type_str) { - zend_string_release(type_str); + zend_string_release_outline(type_str); } return !EG(exception); } @@ -1225,7 +1225,7 @@ static zend_result zend_parse_va_args(uint32_t num_args, const char *type_spec, num_args ); - zend_string_release(func_name); + zend_string_release_outline(func_name); } return FAILURE; } @@ -1873,7 +1873,7 @@ ZEND_API zend_result object_init_with_constructor(zval *arg, zend_class_entry *c zend_hash_get_current_key(named_params, &arg_name, /* num_index */ NULL); ZEND_ASSERT(arg_name != NULL); zend_throw_error(NULL, "Unknown named parameter $%s", ZSTR_VAL(arg_name)); - zend_string_release(arg_name); + zend_string_release_outline(arg_name); /* Do not call destructor, free object, and set arg to IS_UNDEF */ zend_object_store_ctor_failed(obj); zval_ptr_dtor(arg); @@ -2619,7 +2619,7 @@ ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module, i lcname = zend_new_interned_string(lcname); if ((module_ptr = zend_hash_add_ptr(&module_registry, lcname, module)) == NULL) { zend_error(E_CORE_WARNING, "Module \"%s\" is already loaded", module->name); - zend_string_release(lcname); + zend_string_release_outline(lcname); return NULL; } module = module_ptr; @@ -2630,7 +2630,7 @@ ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module, i if (module->functions && zend_register_functions(NULL, module->functions, NULL, module_type)==FAILURE) { zend_hash_del(&module_registry, lcname); - zend_string_release(lcname); + zend_string_release_outline(lcname); EG(current_module) = NULL; zend_error(E_CORE_WARNING,"%s: Unable to register functions, unable to load", module->name); return NULL; diff --git a/Zend/zend_API.h b/Zend/zend_API.h index ab67dd5717e69..49b488c94e9ea 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -900,7 +900,7 @@ static zend_always_inline zend_result zend_forbid_dynamic_call(void) zend_string *function_or_method_name = get_active_function_or_method_name(); zend_throw_error(NULL, "Cannot call %.*s() dynamically", (int) ZSTR_LEN(function_or_method_name), ZSTR_VAL(function_or_method_name)); - zend_string_release(function_or_method_name); + zend_string_release_outline(function_or_method_name); return FAILURE; } diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index 81562411e6b0c..2acba4114bb68 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -28,7 +28,7 @@ ZEND_API zend_ast_process_t zend_ast_process = NULL; -static inline void *zend_ast_alloc(size_t size) { +static void *zend_ast_alloc(size_t size) { return zend_arena_alloc(&CG(ast_arena), size); } @@ -1193,10 +1193,10 @@ ZEND_API void ZEND_FASTCALL zend_ast_destroy(zend_ast *ast) zend_ast_decl *decl = (zend_ast_decl *) ast; if (decl->name) { - zend_string_release_ex(decl->name, 0); + zend_string_release_ex_outline(decl->name, 0); } if (decl->doc_comment) { - zend_string_release_ex(decl->doc_comment, 0); + zend_string_release_ex_outline(decl->doc_comment, 0); } zend_ast_destroy(decl->child[0]); zend_ast_destroy(decl->child[1]); diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 9253cb9708ce5..b348af1b64512 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -4111,7 +4111,7 @@ static zend_result zend_compile_func_defined(znode *result, zend_ast_list *args) name = zval_get_string(zend_ast_get_zval(args->child[0])); if (zend_memrchr(ZSTR_VAL(name), '\\', ZSTR_LEN(name)) || zend_memrchr(ZSTR_VAL(name), ':', ZSTR_LEN(name))) { - zend_string_release_ex(name, 0); + zend_string_release_ex_outline(name, 0); return FAILURE; } @@ -4280,7 +4280,7 @@ static zend_result zend_compile_func_cufa(znode *result, zend_ast_list *args, ze opline = zend_emit_op(NULL, ZEND_SEND_ARRAY, &arg_node, &len_node); opline->extended_value = Z_LVAL_P(zv); zend_emit_op(result, ZEND_DO_FCALL, NULL, NULL); - zend_string_release_ex(name, 0); + zend_string_release_ex_outline(name, 0); return SUCCESS; } } @@ -7534,7 +7534,7 @@ static void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32 && (op_array->fn_flags & ZEND_ACC_RETURN_REFERENCE)) { zend_string *func_name = get_function_or_method_name((zend_function *) op_array); zend_error(E_DEPRECATED, "%s(): Returning by reference from a void function is deprecated", ZSTR_VAL(func_name)); - zend_string_release(func_name); + zend_string_release_outline(func_name); } } else { if (list->children == 0) { @@ -7670,7 +7670,7 @@ static void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32 "%s(): Optional parameter $%s declared before required parameter $%s " "is implicitly treated as a required parameter", ZSTR_VAL(func_name), ZSTR_VAL(name), ZSTR_VAL(zend_ast_get_str(required_param_ast->child[1]))); - zend_string_release(func_name); + zend_string_release_outline(func_name); } /* Regardless of whether we issue a deprecation, convert this parameter into @@ -10759,7 +10759,7 @@ static void zend_compile_class_const(znode *result, zend_ast *ast) /* {{{ */ zend_string *resolved_name = zend_resolve_class_name_ast(class_ast); if (zend_try_ct_eval_class_const(&result->u.constant, resolved_name, const_str)) { result->op_type = IS_CONST; - zend_string_release_ex(resolved_name, 0); + zend_string_release_ex_outline(resolved_name, 0); return; } zend_string_release_ex(resolved_name, 0); diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c index 9fa98e74e8ccb..1fc49bb03e90a 100644 --- a/Zend/zend_constants.c +++ b/Zend/zend_constants.c @@ -573,7 +573,7 @@ ZEND_API zend_result zend_register_constant(zend_constant *c) || zend_hash_add_constant(EG(zend_constants), name, c) == NULL ) { zend_error(E_WARNING, "Constant %s already defined", ZSTR_VAL(name)); - zend_string_release(c->name); + zend_string_release_outline(c->name); if (!persistent) { zval_ptr_dtor_nogc(&c->value); } diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index 4af4ec2cfc059..b03e95cc5de35 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -844,7 +844,7 @@ ZEND_API ZEND_COLD zend_object *zend_throw_exception(zend_class_entry *exception zend_string *msg_str = message ? zend_string_init(message, strlen(message), 0) : NULL; zend_object *ex = zend_throw_exception_zstr(exception_ce, msg_str, code); if (msg_str) { - zend_string_release(msg_str); + zend_string_release_outline(msg_str); } return ex; } @@ -884,7 +884,7 @@ static void zend_error_va(int type, zend_string *file, uint32_t lineno, const ch zend_string *message = zend_vstrpprintf(0, format, args); zend_observer_error_notify(type, file, lineno, message); zend_error_cb(type, file, lineno, message); - zend_string_release(message); + zend_string_release_outline(message); va_end(args); } /* }}} */ @@ -908,8 +908,8 @@ ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *ex, int severit zend_observer_error_notify(type, file, line, message); zend_error_cb(type, file, line, message); - zend_string_release_ex(file, 0); - zend_string_release_ex(message, 0); + zend_string_release_ex_outline(file, 0); + zend_string_release_ex_outline(message, 0); } else if (instanceof_function(ce_exception, zend_ce_throwable)) { zval tmp; zend_string *str, *file = NULL; @@ -940,7 +940,7 @@ ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *ex, int severit ZSTR_VAL(Z_OBJCE(zv)->name), ZSTR_VAL(ce_exception->name)); if (file) { - zend_string_release_ex(file, 0); + zend_string_release_ex_outline(file, 0); } } @@ -952,8 +952,8 @@ ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *ex, int severit (file && ZSTR_LEN(file) > 0) ? file : NULL, line, "Uncaught %S\n thrown", str); - zend_string_release_ex(str, 0); - zend_string_release_ex(file, 0); + zend_string_release_ex_outline(str, 0); + zend_string_release_ex_outline(file, 0); } else if (ce_exception == &zend_ce_unwind_exit || ce_exception == &zend_ce_graceful_exit) { /* We successfully unwound, nothing more to do. * We still return FAILURE in this case, as further execution should still be aborted. */ diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 89904af06d2ad..d3df18172f1cf 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -606,7 +606,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_cannot_pass_by_reference(uint32_t arg ZSTR_VAL(func_name), arg_num, param_name ? " ($" : "", param_name ? param_name : "", param_name ? ")" : "" ); - zend_string_release(func_name); + zend_string_release_outline(func_name); } static zend_never_inline ZEND_COLD void zend_throw_auto_init_in_prop_error(zend_property_info *prop) { @@ -616,7 +616,7 @@ static zend_never_inline ZEND_COLD void zend_throw_auto_init_in_prop_error(zend_ ZSTR_VAL(prop->ce->name), zend_get_unmangled_property_name(prop->name), ZSTR_VAL(type_str) ); - zend_string_release(type_str); + zend_string_release_outline(type_str); } static zend_never_inline ZEND_COLD void zend_throw_auto_init_in_ref_error(zend_property_info *prop) { @@ -626,7 +626,7 @@ static zend_never_inline ZEND_COLD void zend_throw_auto_init_in_ref_error(zend_p ZSTR_VAL(prop->ce->name), zend_get_unmangled_property_name(prop->name), ZSTR_VAL(type_str) ); - zend_string_release(type_str); + zend_string_release_outline(type_str); } static zend_never_inline ZEND_COLD void zend_throw_access_uninit_prop_by_ref_error( @@ -665,7 +665,7 @@ static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_throw_non_object_erro ZSTR_VAL(property_name), zend_zval_value_name(object) ); } - zend_tmp_string_release(tmp_property_name); + zend_tmp_string_release_outline(tmp_property_name); if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_NULL(EX_VAR(opline->result.var)); @@ -718,7 +718,7 @@ ZEND_API ZEND_COLD void zend_verify_arg_error( "must be of type %s, %s given", ZSTR_VAL(need_msg), given_msg); } - zend_string_release(need_msg); + zend_string_release_outline(need_msg); } static bool zend_verify_weak_scalar_type_hint(uint32_t type_mask, zval *arg) @@ -834,7 +834,7 @@ ZEND_COLD zend_never_inline void zend_verify_class_constant_type_error(const zen zend_type_error("Cannot assign %s to class constant %s::%s of type %s", zend_zval_type_name(constant), ZSTR_VAL(c->ce->name), ZSTR_VAL(name), ZSTR_VAL(type_str)); - zend_string_release(type_str); + zend_string_release_outline(type_str); } ZEND_COLD zend_never_inline void zend_verify_property_type_error(const zend_property_info *info, const zval *property) @@ -852,7 +852,7 @@ ZEND_COLD zend_never_inline void zend_verify_property_type_error(const zend_prop ZSTR_VAL(info->ce->name), zend_get_unmangled_property_name(info->name), ZSTR_VAL(type_str)); - zend_string_release(type_str); + zend_string_release_outline(type_str); } ZEND_COLD zend_never_inline void zend_magic_get_property_type_inconsistency_error(const zend_property_info *info, const zval *property) @@ -869,7 +869,7 @@ ZEND_COLD zend_never_inline void zend_magic_get_property_type_inconsistency_erro ZSTR_VAL(info->ce->name), zend_get_unmangled_property_name(info->name), ZSTR_VAL(type_str)); - zend_string_release(type_str); + zend_string_release_outline(type_str); } ZEND_COLD void zend_match_unhandled_error(const zval *value) @@ -884,7 +884,7 @@ ZEND_COLD void zend_match_unhandled_error(const zval *value) zend_throw_exception_ex( zend_ce_unhandled_match_error, 0, "Unhandled match case %s", ZSTR_VAL(msg.s)); - smart_str_free(&msg); + smart_str_free_outline(&msg); } ZEND_API ZEND_COLD void ZEND_FASTCALL zend_readonly_property_modification_error( @@ -1409,7 +1409,7 @@ ZEND_API ZEND_COLD void zend_verify_return_error(const zend_function *zf, zval * zend_type_error("%s%s%s(): Return value must be of type %s, %s returned", fclass, fsep, fname, ZSTR_VAL(need_msg), given_msg); - zend_string_release(need_msg); + zend_string_release_outline(need_msg); } ZEND_API ZEND_COLD void zend_verify_never_error(const zend_function *zf) @@ -1419,7 +1419,7 @@ ZEND_API ZEND_COLD void zend_verify_never_error(const zend_function *zf) zend_type_error("%s(): never-returning %s must not implicitly return", ZSTR_VAL(func_name), zf->common.scope ? "method" : "function"); - zend_string_release(func_name); + zend_string_release_outline(func_name); } #if ZEND_DEBUG @@ -1833,8 +1833,8 @@ ZEND_COLD static zend_result ZEND_FASTCALL get_deprecation_suffix_from_attribute out: - zend_string_release(since); - zend_string_release(message); + zend_string_release_outline(since); + zend_string_release_outline(message); zval_ptr_dtor(&obj); return result; @@ -1863,7 +1863,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_deprecated_function(const zend_functi ); } - zend_string_release(message_suffix); + zend_string_release_outline(message_suffix); } ZEND_API ZEND_COLD void ZEND_FASTCALL zend_deprecated_class_constant(const zend_class_constant *c, const zend_string *constant_name) @@ -1884,7 +1884,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_deprecated_class_constant(const zend_ message_suffix ); - zend_string_release(message_suffix); + zend_string_release_outline(message_suffix); } ZEND_API ZEND_COLD void ZEND_FASTCALL zend_false_to_array_deprecated(void) @@ -1998,7 +1998,7 @@ static zend_never_inline void zend_assign_to_string_offset(zval *str, zval *dim, GC_ADDREF(s); zend_error(E_WARNING, "Only the first byte will be assigned to the string offset"); if (UNEXPECTED(GC_DELREF(s) == 0)) { - zend_string_efree(s); + zend_string_efree_outline(s); if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_NULL(EX_VAR(opline->result.var)); } @@ -2052,7 +2052,7 @@ static ZEND_COLD zend_long zend_throw_incdec_ref_error( ZSTR_VAL(error_prop->ce->name), zend_get_unmangled_property_name(error_prop->name), ZSTR_VAL(type_str)); - zend_string_release(type_str); + zend_string_release_outline(type_str); return ZEND_LONG_MAX; } else { zend_type_error( @@ -2060,7 +2060,7 @@ static ZEND_COLD zend_long zend_throw_incdec_ref_error( ZSTR_VAL(error_prop->ce->name), zend_get_unmangled_property_name(error_prop->name), ZSTR_VAL(type_str)); - zend_string_release(type_str); + zend_string_release_outline(type_str); return ZEND_LONG_MIN; } } @@ -2072,14 +2072,14 @@ static ZEND_COLD zend_long zend_throw_incdec_prop_error(zend_property_info *prop ZSTR_VAL(prop->ce->name), zend_get_unmangled_property_name(prop->name), ZSTR_VAL(type_str)); - zend_string_release(type_str); + zend_string_release_outline(type_str); return ZEND_LONG_MAX; } else { zend_type_error("Cannot decrement property %s::$%s of type %s past its minimal value", ZSTR_VAL(prop->ce->name), zend_get_unmangled_property_name(prop->name), ZSTR_VAL(type_str)); - zend_string_release(type_str); + zend_string_release_outline(type_str); return ZEND_LONG_MIN; } } @@ -2403,7 +2403,7 @@ ZEND_API ZEND_COLD zval* ZEND_FASTCALL zend_undefined_index_write(HashTable *ht, } else { retval = zend_hash_add_new(ht, offset, &EG(uninitialized_zval)); } - zend_string_release(offset); + zend_string_release_outline(offset); return retval; } @@ -2937,7 +2937,7 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z } ZVAL_UNDEFINED_OP2(); if (!(GC_FLAGS(str) & IS_STR_INTERNED) && UNEXPECTED(GC_DELREF(str) == 0)) { - zend_string_efree(str); + zend_string_efree_outline(str); ZVAL_NULL(result); return; } @@ -2954,7 +2954,7 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z } zend_error(E_WARNING, "String offset cast occurred"); if (!(GC_FLAGS(str) & IS_STR_INTERNED) && UNEXPECTED(GC_DELREF(str) == 0)) { - zend_string_efree(str); + zend_string_efree_outline(str); ZVAL_NULL(result); return; } @@ -3645,8 +3645,8 @@ ZEND_API ZEND_COLD void zend_throw_ref_type_error_type(const zend_property_info zend_get_unmangled_property_name(prop2->name), ZSTR_VAL(type2_str) ); - zend_string_release(type1_str); - zend_string_release(type2_str); + zend_string_release_outline(type1_str); + zend_string_release_outline(type2_str); } ZEND_API ZEND_COLD void zend_throw_ref_type_error_zval(const zend_property_info *prop, const zval *zv) { @@ -3657,7 +3657,7 @@ ZEND_API ZEND_COLD void zend_throw_ref_type_error_zval(const zend_property_info zend_get_unmangled_property_name(prop->name), ZSTR_VAL(type_str) ); - zend_string_release(type_str); + zend_string_release_outline(type_str); } ZEND_API ZEND_COLD void zend_throw_conflicting_coercion_error(const zend_property_info *prop1, const zend_property_info *prop2, const zval *zv) { @@ -3672,8 +3672,8 @@ ZEND_API ZEND_COLD void zend_throw_conflicting_coercion_error(const zend_propert zend_get_unmangled_property_name(prop2->name), ZSTR_VAL(type2_str) ); - zend_string_release(type1_str); - zend_string_release(type2_str); + zend_string_release_outline(type1_str); + zend_string_release_outline(type2_str); } /* 1: valid, 0: invalid, -1: may be valid after type coercion */ @@ -4872,7 +4872,7 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_string(zend_s if (UNEXPECTED(!(fbc->common.fn_flags & ZEND_ACC_STATIC))) { zend_non_static_method_call(fbc); if (fbc->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) { - zend_string_release_ex(fbc->common.function_name, 0); + zend_string_release_ex_outline(fbc->common.function_name, 0); zend_free_trampoline(fbc); } return NULL; @@ -4889,7 +4889,7 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_string(zend_s } if (UNEXPECTED((func = zend_hash_find(EG(function_table), lcname)) == NULL)) { zend_throw_error(NULL, "Call to undefined function %s()", ZSTR_VAL(function)); - zend_string_release_ex(lcname, 0); + zend_string_release_ex_outline(lcname, 0); return NULL; } zend_string_release_ex(lcname, 0); @@ -5000,7 +5000,7 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_array(zend_ar if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) { zend_non_static_method_call(fbc); if (fbc->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) { - zend_string_release_ex(fbc->common.function_name, 0); + zend_string_release_ex_outline(fbc->common.function_name, 0); zend_free_trampoline(fbc); } return NULL; diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index f1f5bfc84516f..de6f4669f7625 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -829,7 +829,7 @@ zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_ = zend_get_callable_name_ex(&fci->function_name, fci->object); zend_throw_error(NULL, "Invalid callback %s, %s", ZSTR_VAL(callable_name), error); efree(error); - zend_string_release_ex(callable_name, 0); + zend_string_release_ex_outline(callable_name, 0); return SUCCESS; } @@ -1228,7 +1228,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string * /* Verify class name before passing it to the autoloader. */ if (!key && !ZSTR_HAS_CE_CACHE(name) && !zend_is_valid_class_name(name)) { - zend_string_release_ex(lc_name, 0); + zend_string_release_ex_outline(lc_name, 0); return NULL; } diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index d33ad2500fb5b..6a5fe4d50909f 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -867,7 +867,7 @@ static ZEND_COLD void zend_append_type_hint( if (ZEND_TYPE_IS_SET(arg_info->type)) { zend_string *type_str = zend_type_to_string_resolved(arg_info->type, scope); smart_str_append(str, type_str); - zend_string_release(type_str); + zend_string_release_outline(type_str); if (!return_hint) { smart_str_appendc(str, ' '); } @@ -987,7 +987,7 @@ static ZEND_COLD zend_string *zend_get_function_declaration( zend_string *tmp_zv_str; zend_string *zv_str = zval_get_tmp_string(zv, &tmp_zv_str); smart_str_append(&str, zv_str); - zend_tmp_string_release(tmp_zv_str); + zend_tmp_string_release_outline(tmp_zv_str); } } } @@ -1060,8 +1060,8 @@ static void ZEND_COLD emit_incompatible_method_error( "Declaration of %s must be compatible with %s", ZSTR_VAL(child_prototype), ZSTR_VAL(parent_prototype)); } - zend_string_efree(child_prototype); - zend_string_efree(parent_prototype); + zend_string_efree_outline(child_prototype); + zend_string_efree_outline(parent_prototype); } static void perform_delayable_implementation_check( diff --git a/Zend/zend_ini.c b/Zend/zend_ini.c index b4c0722e3e946..d95f6f87f7179 100644 --- a/Zend/zend_ini.c +++ b/Zend/zend_ini.c @@ -879,7 +879,7 @@ ZEND_API zend_long zend_ini_parse_quantity_warn(zend_string *value, zend_string if (errstr) { zend_error(E_WARNING, "Invalid \"%s\" setting. %s", ZSTR_VAL(setting), ZSTR_VAL(errstr)); - zend_string_release(errstr); + zend_string_release_outline(errstr); } return retval; @@ -893,7 +893,7 @@ ZEND_API zend_ulong zend_ini_parse_uquantity_warn(zend_string *value, zend_strin if (errstr) { zend_error(E_WARNING, "Invalid \"%s\" setting. %s", ZSTR_VAL(setting), ZSTR_VAL(errstr)); - zend_string_release(errstr); + zend_string_release_outline(errstr); } return retval; diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index 4551d26a17e79..e65f2cb0b7a5b 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -2999,7 +2999,7 @@ heredoc_scan_done: } if (UNEXPECTED(zend_scan_escape_string(zendlval, ZSTR_VAL(copy), ZSTR_LEN(copy), 0) != SUCCESS)) { - zend_string_efree(copy); + zend_string_efree_outline(copy); RETURN_TOKEN(T_ERROR); } diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 5331244731cac..5bb8155b8a1ef 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -2545,7 +2545,7 @@ static bool ZEND_FASTCALL increment_string(zval *str) /* {{{ */ zend_string_addref(zstr); zend_error(E_DEPRECATED, "Increment on non-alphanumeric string is deprecated"); if (EG(exception)) { - zend_string_release(zstr); + zend_string_release_outline(zstr); return false; } zval_ptr_dtor(str); @@ -2754,7 +2754,7 @@ ZEND_API zend_result ZEND_FASTCALL decrement_function(zval *op1) /* {{{ */ zend_string_addref(zstr); zend_error(E_DEPRECATED, "Decrement on non-numeric string has no effect and is deprecated"); if (EG(exception)) { - zend_string_release(zstr); + zend_string_release_outline(zstr); return FAILURE; } zval_ptr_dtor(op1); @@ -3783,3 +3783,8 @@ ZEND_API zend_long ZEND_FASTCALL zend_dval_to_lval_slow(double d) } /* }}} */ #endif + +ZEND_API void zend_tmp_string_release_outline(zend_string *tmp) +{ + zend_tmp_string_release(tmp); +} diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 45f9820c41b16..83625d3529f6d 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -300,6 +300,7 @@ ZEND_API zend_long ZEND_FASTCALL zval_try_get_long(const zval *op, bool *fail ZEND_API double ZEND_FASTCALL zval_get_double_func(const zval *op); ZEND_API zend_string* ZEND_FASTCALL zval_get_string_func(zval *op); ZEND_API zend_string* ZEND_FASTCALL zval_try_get_string_func(zval *op); +ZEND_API void zend_tmp_string_release_outline(zend_string *tmp); static zend_always_inline zend_long zval_get_long(const zval *op) { return EXPECTED(Z_TYPE_P(op) == IS_LONG) ? Z_LVAL_P(op) : zval_get_long_func(op, false); diff --git a/Zend/zend_smart_str.c b/Zend/zend_smart_str.c index ade137a4bb6c3..12ca158d19cfe 100644 --- a/Zend/zend_smart_str.c +++ b/Zend/zend_smart_str.c @@ -236,3 +236,8 @@ ZEND_API zend_result ZEND_FASTCALL smart_str_append_zval(smart_str *dest, const } return SUCCESS; } + +ZEND_API void smart_str_free_outline(smart_str *str) +{ + smart_str_free(str); +} diff --git a/Zend/zend_smart_str.h b/Zend/zend_smart_str.h index affbb5c50ac2e..4cb36e1e2311e 100644 --- a/Zend/zend_smart_str.h +++ b/Zend/zend_smart_str.h @@ -35,6 +35,7 @@ ZEND_API void smart_str_append_printf(smart_str *dest, const char *format, ...) ZEND_API void ZEND_FASTCALL smart_str_append_escaped_truncated(smart_str *str, const zend_string *value, size_t length); ZEND_API void ZEND_FASTCALL smart_str_append_scalar(smart_str *str, const zval *value, size_t truncate); ZEND_API zend_result ZEND_FASTCALL smart_str_append_zval(smart_str *dest, const zval *value, size_t truncate); +ZEND_API void smart_str_free_outline(smart_str *str); END_EXTERN_C() static zend_always_inline size_t smart_str_alloc(smart_str *str, size_t len, bool persistent) { diff --git a/Zend/zend_string.c b/Zend/zend_string.c index 7a00171d2c84d..ba39b4f39c1f8 100644 --- a/Zend/zend_string.c +++ b/Zend/zend_string.c @@ -528,3 +528,23 @@ size_t strlcat (char *__restrict dest, const char *restrict src, size_t n) return result; } #endif + +ZEND_API void zend_string_free_outline(zend_string *s) +{ + zend_string_free(s); +} + +ZEND_API void zend_string_efree_outline(zend_string *s) +{ + zend_string_efree(s); +} + +ZEND_API void zend_string_release_outline(zend_string *s) +{ + zend_string_release(s); +} + +ZEND_API void zend_string_release_ex_outline(zend_string *s, bool persistent) +{ + zend_string_release_ex(s, persistent); +} diff --git a/Zend/zend_string.h b/Zend/zend_string.h index b62875a6ec1ce..c8d16f1ec5eea 100644 --- a/Zend/zend_string.h +++ b/Zend/zend_string.h @@ -57,6 +57,11 @@ ZEND_API void zend_interned_strings_set_request_storage_handlers( zend_string_init_existing_interned_func_t init_existing_handler); ZEND_API void zend_interned_strings_switch_storage(bool request); +ZEND_API void zend_string_free_outline(zend_string *s); +ZEND_API void zend_string_efree_outline(zend_string *s); +ZEND_API void zend_string_release_outline(zend_string *s); +ZEND_API void zend_string_release_ex_outline(zend_string *s, bool persistent); + ZEND_API extern zend_string *zend_empty_string; ZEND_API extern zend_string *zend_one_char_string[256]; ZEND_API extern zend_string **zend_known_strings; diff --git a/Zend/zend_types.h b/Zend/zend_types.h index d1db25a8f2bda..dbf74b2ac6def 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -738,17 +738,19 @@ static zend_always_inline uint8_t zval_get_type(const zval* pz) { #define GC_FLAGS_SHIFT 0 #define GC_INFO_SHIFT 10 -static zend_always_inline uint8_t zval_gc_type(uint32_t gc_type_info) { +BEGIN_EXTERN_C() +ZEND_API zend_always_inline uint8_t zval_gc_type(uint32_t gc_type_info) { return (gc_type_info & GC_TYPE_MASK); } -static zend_always_inline uint32_t zval_gc_flags(uint32_t gc_type_info) { +ZEND_API zend_always_inline uint32_t zval_gc_flags(uint32_t gc_type_info) { return (gc_type_info >> GC_FLAGS_SHIFT) & (GC_FLAGS_MASK >> GC_FLAGS_SHIFT); } -static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) { +ZEND_API zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) { return (gc_type_info >> GC_INFO_SHIFT); } +END_EXTERN_C() #define GC_TYPE_INFO(p) (p)->gc.u.type_info #define GC_TYPE(p) zval_gc_type(GC_TYPE_INFO(p)) @@ -1311,9 +1313,11 @@ extern ZEND_API bool zend_rc_debug; do { } while (0) #endif -static zend_always_inline uint32_t zend_gc_refcount(const zend_refcounted_h *p) { +BEGIN_EXTERN_C() +ZEND_API zend_always_inline uint32_t zend_gc_refcount(const zend_refcounted_h *p) { return p->refcount; } +END_EXTERN_C() static zend_always_inline uint32_t zend_gc_set_refcount(zend_refcounted_h *p, uint32_t rc) { p->refcount = rc; @@ -1339,11 +1343,13 @@ static zend_always_inline void zend_gc_try_delref(zend_refcounted_h *p) { } } -static zend_always_inline uint32_t zend_gc_delref(zend_refcounted_h *p) { +BEGIN_EXTERN_C() +ZEND_API zend_always_inline uint32_t zend_gc_delref(zend_refcounted_h *p) { ZEND_ASSERT(p->refcount > 0); ZEND_RC_MOD_CHECK(p); return --(p->refcount); } +END_EXTERN_C() static zend_always_inline uint32_t zend_gc_addref_ex(zend_refcounted_h *p, uint32_t rc) { ZEND_RC_MOD_CHECK(p); diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 77c1487b65c62..fbe7f17795303 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -3319,7 +3319,7 @@ ZEND_VM_COLD_CONSTCONST_HANDLER(53, ZEND_FAST_CONCAT, CONST|TMPVAR|CV, CONST|TMP } } ZVAL_STR(EX_VAR(opline->result.var), op2_str); - zend_string_release_ex(op1_str, 0); + zend_string_release_ex_outline(op1_str, 0); break; } } @@ -3331,7 +3331,7 @@ ZEND_VM_COLD_CONSTCONST_HANDLER(53, ZEND_FAST_CONCAT, CONST|TMPVAR|CV, CONST|TMP } } ZVAL_STR(EX_VAR(opline->result.var), op1_str); - zend_string_release_ex(op2_str, 0); + zend_string_release_ex_outline(op2_str, 0); break; } } @@ -3454,7 +3454,7 @@ ZEND_VM_HANDLER(56, ZEND_ROPE_END, TMP, CONST|TMPVAR|CV, NUM) FREE_OP2(); if (UNEXPECTED(EG(exception))) { for (i = 0; i <= opline->extended_value; i++) { - zend_string_release_ex(rope[i], 0); + zend_string_release_ex_outline(rope[i], 0); } ZVAL_UNDEF(EX_VAR(opline->result.var)); HANDLE_EXCEPTION(); @@ -3878,7 +3878,7 @@ ZEND_VM_C_LABEL(try_function_name): if (UNEXPECTED(EG(exception))) { if (call) { if (call->func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) { - zend_string_release_ex(call->func->common.function_name, 0); + zend_string_release_ex_outline(call->func->common.function_name, 0); zend_free_trampoline(call->func); } zend_vm_stack_free_call_frame(call); @@ -5326,7 +5326,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); + zend_string_release_outline(name); break; } @@ -5346,7 +5346,7 @@ ZEND_VM_C_LABEL(send_again): ZVAL_COPY_VALUE(top, arg); } - zend_string_release(name); + zend_string_release_outline(name); } else { if (have_named_params) { zend_throw_error(NULL, diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index b32ef2a6cc132..c0b31b1435de1 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -2415,7 +2415,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); + zend_string_release_outline(name); break; } @@ -2435,7 +2435,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_UNPACK_SPEC_HANDLER(ZEND_ ZVAL_COPY_VALUE(top, arg); } - zend_string_release(name); + zend_string_release_outline(name); } else { if (have_named_params) { zend_throw_error(NULL, @@ -3978,7 +3978,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_DYNAMIC_CALL_SPEC_CONST_H if (UNEXPECTED(EG(exception))) { if (call) { if (call->func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) { - zend_string_release_ex(call->func->common.function_name, 0); + zend_string_release_ex_outline(call->func->common.function_name, 0); zend_free_trampoline(call->func); } zend_vm_stack_free_call_frame(call); @@ -4161,7 +4161,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_DYNAMIC_CALL_SPEC_TMPVAR_ if (UNEXPECTED(EG(exception))) { if (call) { if (call->func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) { - zend_string_release_ex(call->func->common.function_name, 0); + zend_string_release_ex_outline(call->func->common.function_name, 0); zend_free_trampoline(call->func); } zend_vm_stack_free_call_frame(call); @@ -4357,7 +4357,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_DYNAMIC_CALL_SPEC_CV_HAND if (UNEXPECTED(EG(exception))) { if (call) { if (call->func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) { - zend_string_release_ex(call->func->common.function_name, 0); + zend_string_release_ex_outline(call->func->common.function_name, 0); zend_free_trampoline(call->func); } zend_vm_stack_free_call_frame(call); @@ -7083,7 +7083,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_ } } ZVAL_STR(EX_VAR(opline->result.var), op2_str); - zend_string_release_ex(op1_str, 0); + zend_string_release_ex_outline(op1_str, 0); break; } } @@ -7095,7 +7095,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_ } } ZVAL_STR(EX_VAR(opline->result.var), op1_str); - zend_string_release_ex(op2_str, 0); + zend_string_release_ex_outline(op2_str, 0); break; } } @@ -9652,7 +9652,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CONST_TMPVAR_ } } ZVAL_STR(EX_VAR(opline->result.var), op2_str); - zend_string_release_ex(op1_str, 0); + zend_string_release_ex_outline(op1_str, 0); break; } } @@ -9664,7 +9664,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CONST_TMPVAR_ } } ZVAL_STR(EX_VAR(opline->result.var), op1_str); - zend_string_release_ex(op2_str, 0); + zend_string_release_ex_outline(op2_str, 0); break; } } @@ -12143,7 +12143,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CONST_CV_HAND } } ZVAL_STR(EX_VAR(opline->result.var), op2_str); - zend_string_release_ex(op1_str, 0); + zend_string_release_ex_outline(op1_str, 0); break; } } @@ -12155,7 +12155,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CONST_CV_HAND } } ZVAL_STR(EX_VAR(opline->result.var), op1_str); - zend_string_release_ex(op2_str, 0); + zend_string_release_ex_outline(op2_str, 0); break; } } @@ -16545,7 +16545,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_CONST_ } } ZVAL_STR(EX_VAR(opline->result.var), op2_str); - zend_string_release_ex(op1_str, 0); + zend_string_release_ex_outline(op1_str, 0); break; } } @@ -16557,7 +16557,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_CONST_ } } ZVAL_STR(EX_VAR(opline->result.var), op1_str); - zend_string_release_ex(op2_str, 0); + zend_string_release_ex_outline(op2_str, 0); break; } } @@ -18039,7 +18039,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_TMPVAR } } ZVAL_STR(EX_VAR(opline->result.var), op2_str); - zend_string_release_ex(op1_str, 0); + zend_string_release_ex_outline(op1_str, 0); break; } } @@ -18051,7 +18051,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_TMPVAR } } ZVAL_STR(EX_VAR(opline->result.var), op1_str); - zend_string_release_ex(op2_str, 0); + zend_string_release_ex_outline(op2_str, 0); break; } } @@ -19447,7 +19447,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_CV_HAN } } ZVAL_STR(EX_VAR(opline->result.var), op2_str); - zend_string_release_ex(op1_str, 0); + zend_string_release_ex_outline(op1_str, 0); break; } } @@ -19459,7 +19459,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_CV_HAN } } ZVAL_STR(EX_VAR(opline->result.var), op1_str); - zend_string_release_ex(op2_str, 0); + zend_string_release_ex_outline(op2_str, 0); break; } } @@ -20634,7 +20634,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ROPE_END_SPEC_TMP_CONST_HANDLE if (UNEXPECTED(EG(exception))) { for (i = 0; i <= opline->extended_value; i++) { - zend_string_release_ex(rope[i], 0); + zend_string_release_ex_outline(rope[i], 0); } ZVAL_UNDEF(EX_VAR(opline->result.var)); HANDLE_EXCEPTION(); @@ -21115,7 +21115,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ROPE_END_SPEC_TMP_TMPVAR_HANDL zval_ptr_dtor_nogc(EX_VAR(opline->op2.var)); if (UNEXPECTED(EG(exception))) { for (i = 0; i <= opline->extended_value; i++) { - zend_string_release_ex(rope[i], 0); + zend_string_release_ex_outline(rope[i], 0); } ZVAL_UNDEF(EX_VAR(opline->result.var)); HANDLE_EXCEPTION(); @@ -21980,7 +21980,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ROPE_END_SPEC_TMP_CV_HANDLER(Z if (UNEXPECTED(EG(exception))) { for (i = 0; i <= opline->extended_value; i++) { - zend_string_release_ex(rope[i], 0); + zend_string_release_ex_outline(rope[i], 0); } ZVAL_UNDEF(EX_VAR(opline->result.var)); HANDLE_EXCEPTION(); @@ -44568,7 +44568,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_CONST_HAND } } ZVAL_STR(EX_VAR(opline->result.var), op2_str); - zend_string_release_ex(op1_str, 0); + zend_string_release_ex_outline(op1_str, 0); break; } } @@ -44580,7 +44580,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_CONST_HAND } } ZVAL_STR(EX_VAR(opline->result.var), op1_str); - zend_string_release_ex(op2_str, 0); + zend_string_release_ex_outline(op2_str, 0); break; } } @@ -48438,7 +48438,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_TMPVAR_HAN } } ZVAL_STR(EX_VAR(opline->result.var), op2_str); - zend_string_release_ex(op1_str, 0); + zend_string_release_ex_outline(op1_str, 0); break; } } @@ -48450,7 +48450,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_TMPVAR_HAN } } ZVAL_STR(EX_VAR(opline->result.var), op1_str); - zend_string_release_ex(op2_str, 0); + zend_string_release_ex_outline(op2_str, 0); break; } } @@ -54013,7 +54013,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_CV_HANDLER } } ZVAL_STR(EX_VAR(opline->result.var), op2_str); - zend_string_release_ex(op1_str, 0); + zend_string_release_ex_outline(op1_str, 0); break; } } @@ -54025,7 +54025,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_CV_HANDLER } } ZVAL_STR(EX_VAR(opline->result.var), op1_str); - zend_string_release_ex(op2_str, 0); + zend_string_release_ex_outline(op2_str, 0); break; } } diff --git a/ext/date/php_date.c b/ext/date/php_date.c index bfff54c2b6d23..adb6ffd42326d 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -5068,19 +5068,19 @@ static bool date_period_init_iso8601_string(php_period_obj *dpobj, zend_class_en if (dpobj->start == NULL) { zend_string *func = get_active_function_or_method_name(); zend_throw_exception_ex(date_ce_date_malformed_period_string_exception, 0, "%s(): ISO interval must contain a start date, \"%s\" given", ZSTR_VAL(func), isostr); - zend_string_release(func); + zend_string_release_outline(func); return false; } if (dpobj->interval == NULL) { zend_string *func = get_active_function_or_method_name(); zend_throw_exception_ex(date_ce_date_malformed_period_string_exception, 0, "%s(): ISO interval must contain an interval, \"%s\" given", ZSTR_VAL(func), isostr); - zend_string_release(func); + zend_string_release_outline(func); return false; } if (dpobj->end == NULL && recurrences == 0) { zend_string *func = get_active_function_or_method_name(); zend_throw_exception_ex(date_ce_date_malformed_period_string_exception, 0, "%s(): ISO interval must contain an end date or a recurrence count, \"%s\" given", ZSTR_VAL(func), isostr); - zend_string_release(func); + zend_string_release_outline(func); return false; } diff --git a/ext/dom/document.c b/ext/dom/document.c index 56bbc07d41e1d..3dd6f1b67c2ad 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -193,7 +193,7 @@ zend_result dom_document_version_write(dom_object *obj, zval *newval) if (php_dom_follow_spec_intern(obj)) { if (!zend_string_equals_literal(str, "1.0") && !zend_string_equals_literal(str, "1.1")) { zend_value_error("Invalid XML version"); - zend_string_release_ex(str, 0); + zend_string_release_ex_outline(str, 0); return FAILURE; } } diff --git a/ext/fileinfo/libmagic/apprentice.c b/ext/fileinfo/libmagic/apprentice.c index a4ead7fbce6e6..a8e72b617e796 100644 --- a/ext/fileinfo/libmagic/apprentice.c +++ b/ext/fileinfo/libmagic/apprentice.c @@ -2815,7 +2815,7 @@ getvalue(struct magic_set *ms, struct magic *m, const char **p, int action) pattern = convert_libmagic_pattern(m->value.s, strlen(m->value.s), options); if ((pce = pcre_get_compiled_regex_cache(pattern)) == NULL) { - zend_string_release(pattern); + zend_string_release_outline(pattern); return -1; } zend_string_release(pattern); diff --git a/ext/fileinfo/libmagic/softmagic.c b/ext/fileinfo/libmagic/softmagic.c index 3d4bf1d4ba5ef..9f7c6953bed73 100644 --- a/ext/fileinfo/libmagic/softmagic.c +++ b/ext/fileinfo/libmagic/softmagic.c @@ -2286,7 +2286,7 @@ magiccheck(struct magic_set *ms, struct magic *m) l = v = 0; if ((pce = pcre_get_compiled_regex_cache(pattern)) == NULL) { - zend_string_release(pattern); + zend_string_release_outline(pattern); return -1; } else { /* pce now contains the compiled regex */ @@ -2307,7 +2307,7 @@ magiccheck(struct magic_set *ms, struct magic *m) if (Z_LVAL(retval) < 0) { zval_ptr_dtor(&subpats); - zend_string_release(pattern); + zend_string_release_outline(pattern); return -1; } else if ((Z_LVAL(retval) > 0) && (Z_TYPE(subpats) == IS_ARRAY)) { /* Need to fetch global match which equals pmatch[0] */ @@ -2334,7 +2334,7 @@ magiccheck(struct magic_set *ms, struct magic *m) } else { error_out: zval_ptr_dtor(&subpats); - zend_string_release(pattern); + zend_string_release_outline(pattern); return -1; } } else { diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index 4241b7c2887fb..81253eef4c06e 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -792,7 +792,7 @@ static php_iconv_err_t _php_iconv_strpos(size_t *pretval, if (cd == (iconv_t)(-1)) { if (ndl_buf != NULL) { - zend_string_efree(ndl_buf); + zend_string_efree_outline(ndl_buf); } if (errno == EINVAL) { return PHP_ICONV_ERR_WRONG_CHARSET; diff --git a/ext/json/json.c b/ext/json/json.c index 9f91d39594ec7..01ed37f7dc24a 100644 --- a/ext/json/json.c +++ b/ext/json/json.c @@ -244,7 +244,7 @@ PHP_FUNCTION(json_encode) } } else { if (encoder.error_code != PHP_JSON_ERROR_NONE) { - smart_str_free(&buf); + smart_str_free_outline(&buf); zend_throw_exception(php_json_exception_ce, php_json_get_error_msg(encoder.error_code), encoder.error_code); RETURN_THROWS(); } diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index a9670684cbda0..bc3bfc57b8b7e 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -410,12 +410,12 @@ static zend_result php_mb_parse_encoding_array(HashTable *target_hash, const mbf } } else { const mbfl_encoding *encoding = mbfl_name2encoding(ZSTR_VAL(encoding_str)); - if (encoding) { + if (EXPECTED(encoding)) { *entry++ = encoding; n++; } else { zend_argument_value_error(arg_num, "contains invalid encoding \"%s\"", ZSTR_VAL(encoding_str)); - zend_string_release(encoding_str); + zend_string_release_outline(encoding_str); efree(ZEND_VOIDP(list)); return FAILURE; } @@ -917,7 +917,7 @@ static PHP_INI_MH(OnUpdate_mbstring_http_output_conv_mimetypes) if (ZSTR_LEN(tmp) > 0) { if (!(re = _php_mb_compile_regex(ZSTR_VAL(tmp)))) { - zend_string_release_ex(tmp, 0); + zend_string_release_ex_outline(tmp, 0); return FAILURE; } } @@ -1221,7 +1221,7 @@ PHP_FUNCTION(mb_language) zend_string *ini_name = ZSTR_INIT_LITERAL("mbstring.language", 0); if (FAILURE == zend_alter_ini_entry(ini_name, name, PHP_INI_USER, PHP_INI_STAGE_RUNTIME)) { zend_argument_value_error(1, "must be a valid language, \"%s\" given", ZSTR_VAL(name)); - zend_string_release_ex(ini_name, 0); + zend_string_release_ex_outline(ini_name, 0); RETURN_THROWS(); } // TODO Make return void @@ -2275,9 +2275,9 @@ PHP_FUNCTION(mb_substr_count) needle_u8 = mb_fast_convert((unsigned char*)ZSTR_VAL(needle), ZSTR_LEN(needle), enc, &mbfl_encoding_utf8, 0, MBFL_OUTPUTFILTER_ILLEGAL_MODE_BADUTF8, &num_errors); /* A string with >0 bytes may convert to 0 codepoints; for example, the contents * may be only escape sequences */ - if (ZSTR_LEN(needle_u8) == 0) { - zend_string_free(haystack_u8); - zend_string_free(needle_u8); + if (UNEXPECTED(ZSTR_LEN(needle_u8) == 0)) { + zend_string_free_outline(haystack_u8); + zend_string_free_outline(needle_u8); zend_argument_value_error(2, "must not be empty"); RETURN_THROWS(); } @@ -2665,7 +2665,7 @@ PHP_FUNCTION(mb_strimwidth) } } - if (width < 0) { + if (UNEXPECTED(width < 0)) { php_error_docref(NULL, E_DEPRECATED, "passing a negative integer to argument #3 ($width) is deprecated"); width += mb_get_strwidth(str, enc); @@ -2673,7 +2673,7 @@ PHP_FUNCTION(mb_strimwidth) if (from > 0) { zend_string *trimmed = mb_get_substr(str, 0, from, enc); width -= mb_get_strwidth(trimmed, enc); - zend_string_free(trimmed); + zend_string_free_outline(trimmed); } if (width < 0) { diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 96a400ee29c3a..26cb30ee27fd1 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -1235,7 +1235,7 @@ zend_string *accel_make_persistent_key(zend_string *str) zend_shared_alloc_lock(); str = accel_new_interned_string(zend_string_copy(cwd_str)); if (str == cwd_str) { - zend_string_release_ex(str, 0); + zend_string_release_ex_outline(str, 0); str = NULL; } zend_shared_alloc_unlock(); @@ -1279,7 +1279,7 @@ zend_string *accel_make_persistent_key(zend_string *str) zend_shared_alloc_lock(); str = accel_new_interned_string(zend_string_copy(ZCG(include_path))); if (str == ZCG(include_path)) { - zend_string_release(str); + zend_string_release_outline(str); str = NULL; } zend_shared_alloc_unlock(); @@ -4018,7 +4018,7 @@ static void preload_link(void) "Can't preload unlinked class %s: %s", ZSTR_VAL(ce->name), ZSTR_VAL(error->message)); } - zend_string_release(lcname); + zend_string_release_outline(lcname); } } ZEND_HASH_FOREACH_END(); diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c index 8ed378d7552b0..b0a7e5a96cfe8 100644 --- a/ext/opcache/jit/zend_jit_helpers.c +++ b/ext/opcache/jit/zend_jit_helpers.c @@ -1328,7 +1328,7 @@ static zend_never_inline void zend_assign_to_string_offset(zval *str, zval *dim, GC_ADDREF(s); zend_error(E_WARNING, "Only the first byte will be assigned to the string offset"); if (UNEXPECTED(GC_DELREF(s) == 0)) { - zend_string_efree(s); + zend_string_efree_outline(s); if (result) { ZVAL_NULL(result); } @@ -2089,7 +2089,7 @@ static zend_never_inline ZEND_COLD void zend_throw_auto_init_in_prop_error(zend_ ZSTR_VAL(prop->ce->name), zend_get_unmangled_property_name(prop->name), ZSTR_VAL(type_str) ); - zend_string_release(type_str); + zend_string_release_outline(type_str); } static zend_never_inline ZEND_COLD void zend_throw_access_uninit_prop_by_ref_error( @@ -2215,7 +2215,7 @@ static void ZEND_FASTCALL zend_jit_check_array_promotion(zval *val, zend_propert ZSTR_VAL(prop->ce->name), zend_get_unmangled_property_name(prop->name), ZSTR_VAL(type_str) ); - zend_string_release(type_str); + zend_string_release_outline(type_str); ZVAL_ERROR(result); } else { ZVAL_INDIRECT(result, val); @@ -2354,7 +2354,7 @@ static ZEND_COLD void zend_jit_throw_inc_ref_error(zend_reference *ref, zend_pro ZSTR_VAL(error_prop->ce->name), zend_get_unmangled_property_name(error_prop->name), ZSTR_VAL(type_str)); - zend_string_release(type_str); + zend_string_release_outline(type_str); } static ZEND_COLD void zend_jit_throw_dec_ref_error(zend_reference *ref, zend_property_info *error_prop) @@ -2366,7 +2366,7 @@ static ZEND_COLD void zend_jit_throw_dec_ref_error(zend_reference *ref, zend_pro ZSTR_VAL(error_prop->ce->name), zend_get_unmangled_property_name(error_prop->name), ZSTR_VAL(type_str)); - zend_string_release(type_str); + zend_string_release_outline(type_str); } static void ZEND_FASTCALL zend_jit_pre_inc_typed_ref(zend_reference *ref, zval *ret) @@ -2799,7 +2799,7 @@ static ZEND_COLD zend_long _zend_jit_throw_inc_prop_error(zend_property_info *pr ZSTR_VAL(prop->ce->name), zend_get_unmangled_property_name(prop->name), ZSTR_VAL(type_str)); - zend_string_release(type_str); + zend_string_release_outline(type_str); return ZEND_LONG_MAX; } @@ -2810,7 +2810,7 @@ static ZEND_COLD zend_long _zend_jit_throw_dec_prop_error(zend_property_info *pr ZSTR_VAL(prop->ce->name), zend_get_unmangled_property_name(prop->name), ZSTR_VAL(type_str)); - zend_string_release(type_str); + zend_string_release_outline(type_str); return ZEND_LONG_MIN; } diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 4c16279d81856..4d70b44f1839b 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -2874,8 +2874,8 @@ static zend_result php_openssl_csr_add_subj_entry(zval *item, X509_NAME *subj, i if (UNEXPECTED(!str_item)) { return FAILURE; } - if (!X509_NAME_add_entry_by_NID(subj, nid, MBSTRING_UTF8, - (unsigned char*)ZSTR_VAL(str_item), -1, -1, 0)) + if (UNEXPECTED(!X509_NAME_add_entry_by_NID(subj, nid, MBSTRING_UTF8, + (unsigned char*)ZSTR_VAL(str_item), -1, -1, 0))) { php_openssl_store_errors(); php_error_docref(NULL, E_WARNING, @@ -2883,7 +2883,7 @@ static zend_result php_openssl_csr_add_subj_entry(zval *item, X509_NAME *subj, i " queue and value of string_mask OpenSSL option " "if illegal characters are reported)", nid, ZSTR_VAL(str_item)); - zend_string_release(str_item); + zend_string_release_outline(str_item); return FAILURE; } zend_string_release(str_item); @@ -3009,10 +3009,10 @@ static zend_result php_openssl_csr_make(struct php_x509_request * req, X509_REQ if (UNEXPECTED(!str_item)) { return FAILURE; } - if (!X509_REQ_add1_attr_by_NID(csr, nid, MBSTRING_UTF8, (unsigned char*)ZSTR_VAL(str_item), (int)ZSTR_LEN(str_item))) { + if (UNEXPECTED(!X509_REQ_add1_attr_by_NID(csr, nid, MBSTRING_UTF8, (unsigned char*)ZSTR_VAL(str_item), (int)ZSTR_LEN(str_item)))) { php_openssl_store_errors(); php_error_docref(NULL, E_WARNING, "attributes: add_attr_by_NID %d -> %s (failed)", nid, ZSTR_VAL(str_item)); - zend_string_release(str_item); + zend_string_release_outline(str_item); return FAILURE; } zend_string_release(str_item); @@ -7874,15 +7874,15 @@ PHP_OPENSSL_API zend_string* php_openssl_encrypt( ZEND_TRY_ASSIGN_REF_NEW_STR(tag, tag_str); } else { php_error_docref(NULL, E_WARNING, "Retrieving verification tag failed"); - zend_string_release_ex(tag_str, 0); - zend_string_release_ex(outbuf, 0); + zend_string_release_ex_outline(tag_str, 0); + zend_string_release_ex_outline(outbuf, 0); outbuf = NULL; } } else if (tag) { ZEND_TRY_ASSIGN_REF_NULL(tag); } else if (mode.is_aead) { php_error_docref(NULL, E_WARNING, "A tag should be provided when using AEAD mode"); - zend_string_release_ex(outbuf, 0); + zend_string_release_ex_outline(outbuf, 0); outbuf = NULL; } } else { @@ -8115,14 +8115,14 @@ PHP_OPENSSL_API zend_string* php_openssl_random_pseudo_bytes(zend_long buffer_le PHP_OPENSSL_CHECK_LONG_TO_INT_NULL_RETURN(buffer_length, length); PHP_OPENSSL_RAND_ADD_TIME(); - if (RAND_bytes((unsigned char*)ZSTR_VAL(buffer), (int)buffer_length) <= 0) { - zend_string_release_ex(buffer, 0); + if (UNEXPECTED(RAND_bytes((unsigned char*)ZSTR_VAL(buffer), (int)buffer_length) <= 0)) { + zend_string_release_ex_outline(buffer, 0); zend_throw_exception(zend_ce_exception, "Error reading from source device", 0); return NULL; - } else { - php_openssl_store_errors(); } + php_openssl_store_errors(); + return buffer; } diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c index eb7ab93815a9c..155de483a9fbb 100644 --- a/ext/openssl/xp_ssl.c +++ b/ext/openssl/xp_ssl.c @@ -308,7 +308,7 @@ static int php_openssl_handle_ssl_error(php_stream *stream, int nr_bytes, bool i ebuf.s ? "OpenSSL Error messages:\n" : "", ebuf.s ? ZSTR_VAL(ebuf.s) : ""); if (ebuf.s) { - smart_str_free(&ebuf); + smart_str_free_outline(&ebuf); } } @@ -1506,14 +1506,14 @@ static zend_result php_openssl_enable_server_sni(php_stream *stream, php_openssl if (UNEXPECTED(!local_cert_str)) { return FAILURE; } - if (!php_openssl_check_path_str_ex( + if (UNEXPECTED(!php_openssl_check_path_str_ex( local_cert_str, resolved_cert_path_buff, 0, false, false, - "SNI_server_certs local_cert in ssl stream context")) { + "SNI_server_certs local_cert in ssl stream context"))) { php_error_docref(NULL, E_WARNING, "Failed setting local cert chain file `%s'; could not open file", ZSTR_VAL(local_cert_str) ); - zend_string_release(local_cert_str); + zend_string_release_outline(local_cert_str); return FAILURE; } zend_string_release(local_cert_str); @@ -1530,14 +1530,14 @@ static zend_result php_openssl_enable_server_sni(php_stream *stream, php_openssl if (UNEXPECTED(!local_pk_str)) { return FAILURE; } - if (!php_openssl_check_path_str_ex( + if (UNEXPECTED(!php_openssl_check_path_str_ex( local_pk_str, resolved_pk_path_buff, 0, false, false, - "SNI_server_certs local_pk in ssl stream context")) { + "SNI_server_certs local_pk in ssl stream context"))) { php_error_docref(NULL, E_WARNING, "Failed setting local private key file `%s'; could not open file", ZSTR_VAL(local_pk_str) ); - zend_string_release(local_pk_str); + zend_string_release_outline(local_pk_str); return FAILURE; } zend_string_release(local_pk_str); diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index ac0ad2c378be2..7a3c62174b738 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -648,7 +648,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, bo while (isspace((int)*(unsigned char *)p)) p++; if (p >= end_p) { if (key != regex) { - zend_string_release_ex(key, 0); + zend_string_release_ex_outline(key, 0); } php_error_docref(NULL, E_WARNING, "Empty regular expression"); pcre_handle_exec_error(PCRE2_ERROR_INTERNAL); @@ -660,7 +660,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, bo delimiter = *p++; if (isalnum((int)*(unsigned char *)&delimiter) || delimiter == '\\' || delimiter == '\0') { if (key != regex) { - zend_string_release_ex(key, 0); + zend_string_release_ex_outline(key, 0); } php_error_docref(NULL, E_WARNING, "Delimiter must not be alphanumeric, backslash, or NUL byte"); pcre_handle_exec_error(PCRE2_ERROR_INTERNAL); @@ -766,7 +766,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, bo pcre_handle_exec_error(PCRE2_ERROR_INTERNAL); efree(pattern); if (key != regex) { - zend_string_release_ex(key, 0); + zend_string_release_ex_outline(key, 0); } return NULL; } @@ -780,7 +780,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, bo if (UNEXPECTED(!tables)) { php_error_docref(NULL,E_WARNING, "Failed to generate locale character tables"); pcre_handle_exec_error(PCRE2_ERROR_NOMEMORY); - zend_string_release_ex(key, 0); + zend_string_release_ex_outline(key, 0); efree(pattern); return NULL; } @@ -799,7 +799,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, bo if (re == NULL) { if (key != regex) { - zend_string_release_ex(key, 0); + zend_string_release_ex_outline(key, 0); } pcre2_get_error_message(errnumber, error, sizeof(error)); php_error_docref(NULL,E_WARNING, "Compilation failed: %s at offset %zu", error, erroffset); @@ -851,7 +851,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, bo rc = pcre2_pattern_info(re, PCRE2_INFO_CAPTURECOUNT, &new_entry.capture_count); if (rc < 0) { if (key != regex) { - zend_string_release_ex(key, 0); + zend_string_release_ex_outline(key, 0); } php_error_docref(NULL, E_WARNING, "Internal pcre2_pattern_info() error %d", rc); pcre_handle_exec_error(PCRE2_ERROR_INTERNAL); @@ -862,7 +862,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, bo rc = pcre2_pattern_info(re, PCRE2_INFO_NAMECOUNT, &name_count); if (rc < 0) { if (key != regex) { - zend_string_release_ex(key, 0); + zend_string_release_ex_outline(key, 0); } php_error_docref(NULL, E_WARNING, "Internal pcre_pattern_info() error %d", rc); pcre_handle_exec_error(PCRE2_ERROR_INTERNAL); diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 4674e901da5a5..7f78369b10173 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -1301,7 +1301,7 @@ PHP_METHOD(PDOStatement, fetchAll) zend_string *func = get_active_function_or_method_name(); zend_argument_count_error("%s() expects exactly 2 argument for PDO::FETCH_FUNC, %d given", ZSTR_VAL(func), ZEND_NUM_ARGS()); - zend_string_release(func); + zend_string_release_outline(func); RETURN_THROWS(); } if (arg2 == NULL) { @@ -1321,7 +1321,7 @@ PHP_METHOD(PDOStatement, fetchAll) zend_string *func = get_active_function_or_method_name(); zend_argument_count_error("%s() expects at most 2 argument for the fetch mode provided, %d given", ZSTR_VAL(func), ZEND_NUM_ARGS()); - zend_string_release(func); + zend_string_release_outline(func); RETURN_THROWS(); } /* Is column index passed? */ @@ -1347,7 +1347,7 @@ PHP_METHOD(PDOStatement, fetchAll) zend_string *func = get_active_function_or_method_name(); zend_argument_count_error("%s() expects exactly 1 argument for the fetch mode provided, %d given", ZSTR_VAL(func), ZEND_NUM_ARGS()); - zend_string_release(func); + zend_string_release_outline(func); RETURN_THROWS(); } } @@ -1733,7 +1733,7 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a zend_string *func = get_active_function_or_method_name(); zend_argument_count_error("%s() expects exactly %d arguments for the fetch mode provided, %d given", ZSTR_VAL(func), mode_arg_num, total_num_args); - zend_string_release(func); + zend_string_release_outline(func); return false; } break; @@ -1743,7 +1743,7 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a zend_string *func = get_active_function_or_method_name(); zend_argument_count_error("%s() expects exactly %d arguments for the fetch mode provided, %d given", ZSTR_VAL(func), arg1_arg_num, total_num_args); - zend_string_release(func); + zend_string_release_outline(func); return false; } if (Z_TYPE(args[0]) != IS_LONG) { @@ -1767,7 +1767,7 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a zend_string *func = get_active_function_or_method_name(); zend_argument_count_error("%s() expects exactly %d arguments for the fetch mode provided, %d given", ZSTR_VAL(func), mode_arg_num, total_num_args); - zend_string_release(func); + zend_string_release_outline(func); return false; } stmt->fetch.cls.ce = NULL; @@ -1777,7 +1777,7 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a zend_string *func = get_active_function_or_method_name(); zend_argument_count_error("%s() expects at least %d arguments for the fetch mode provided, %d given", ZSTR_VAL(func), arg1_arg_num, total_num_args); - zend_string_release(func); + zend_string_release_outline(func); return false; } /* constructor_arguments can be null/not passed */ @@ -1785,7 +1785,7 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a zend_string *func = get_active_function_or_method_name(); zend_argument_count_error("%s() expects at most %d arguments for the fetch mode provided, %d given", ZSTR_VAL(func), constructor_arg_num, total_num_args); - zend_string_release(func); + zend_string_release_outline(func); return false; } if (Z_TYPE(args[0]) != IS_STRING) { @@ -1825,7 +1825,7 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a zend_string *func = get_active_function_or_method_name(); zend_argument_count_error("%s() expects exactly %d arguments for the fetch mode provided, %d given", ZSTR_VAL(func), arg1_arg_num, total_num_args); - zend_string_release(func); + zend_string_release_outline(func); return false; } if (Z_TYPE(args[0]) != IS_OBJECT) { diff --git a/ext/pdo_sqlite/pdo_sqlite.c b/ext/pdo_sqlite/pdo_sqlite.c index e2c686ed691ff..949c79c19014a 100644 --- a/ext/pdo_sqlite/pdo_sqlite.c +++ b/ext/pdo_sqlite/pdo_sqlite.c @@ -347,11 +347,11 @@ static int php_sqlite_collation_callback(void *context, int string1_len, const v zend_call_known_fcc(&collation->callback, &retval, /* argc */ 2, zargs, /* named_params */ NULL); if (!Z_ISUNDEF(retval)) { - if (Z_TYPE(retval) != IS_LONG) { + if (UNEXPECTED(Z_TYPE(retval) != IS_LONG)) { zend_string *func_name = get_active_function_or_method_name(); zend_type_error("%s(): Return value of the callback must be of type int, %s returned", ZSTR_VAL(func_name), zend_zval_value_name(&retval)); - zend_string_release(func_name); + zend_string_release_outline(func_name); return FAILURE; } if (Z_LVAL(retval) > 0) { diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 9d16512ec5d13..87dcd093b92f4 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -1636,7 +1636,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ } if (opened) { - zend_string_release_ex(opened, 0); + zend_string_release_ex_outline(opened, 0); } if (temp) { @@ -2874,7 +2874,7 @@ PHP_METHOD(Phar, setStub) if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "r|l", &zstub, &len) == SUCCESS) { zend_string *method_name = get_active_function_or_method_name(); zend_error(E_DEPRECATED, "Calling %s(resource $stub, int $length) is deprecated", ZSTR_VAL(method_name)); - zend_string_release(method_name); + zend_string_release_outline(method_name); if (UNEXPECTED(EG(exception))) { RETURN_THROWS(); } @@ -2969,11 +2969,11 @@ PHP_METHOD(Phar, setDefaultStub) if (!phar_obj->archive->is_tar && !phar_obj->archive->is_zip) { stub = phar_create_default_stub(index, webindex, &error); - if (error) { + if (UNEXPECTED(error)) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "%s", error); efree(error); if (stub) { - zend_string_free(stub); + zend_string_free_outline(stub); } RETURN_THROWS(); } @@ -3951,7 +3951,7 @@ PHP_METHOD(Phar, getStub) } zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Unable to read stub"); - zend_string_release_ex(buf, 0); + zend_string_release_ex_outline(buf, 0); RETURN_THROWS(); } @@ -4018,15 +4018,15 @@ static int serialize_metadata_or_throw(phar_metadata_tracker *tracker, int persi } phar_metadata_tracker_free(tracker, persistent); - if (EG(exception)) { + if (UNEXPECTED(EG(exception))) { /* Destructor can throw. */ - zend_string_release(main_metadata_str.s); + zend_string_release_outline(main_metadata_str.s); return FAILURE; } - if (tracker->str) { + if (UNEXPECTED(tracker->str)) { zend_throw_exception_ex(phar_ce_PharException, 0, "Metadata unexpectedly changed during setMetadata()"); - zend_string_release(main_metadata_str.s); + zend_string_release_outline(main_metadata_str.s); return FAILURE; } ZVAL_COPY(&tracker->val, metadata); diff --git a/ext/phar/util.c b/ext/phar/util.c index aed95e635dd8c..37137c3722779 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -1541,7 +1541,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t sig_type, tempsig = sig_len; if (FAILURE == phar_call_openssl_signverify(0, fp, end_of_phar, ZSTR_VAL(pubkey), ZSTR_LEN(pubkey), &sig, &tempsig, sig_type)) { - zend_string_release_ex(pubkey, 0); + zend_string_release_ex_outline(pubkey, 0); if (error) { spprintf(error, 0, "openssl signature could not be verified"); @@ -1557,7 +1557,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t sig_type, in = BIO_new_mem_buf(ZSTR_VAL(pubkey), ZSTR_LEN(pubkey)); if (NULL == in) { - zend_string_release_ex(pubkey, 0); + zend_string_release_ex_outline(pubkey, 0); if (error) { spprintf(error, 0, "openssl signature could not be processed"); } diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 0956bbc1acf70..973ee0d3127da 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -2471,10 +2471,10 @@ ZEND_METHOD(ReflectionParameter, __construct) if (UNEXPECTED(!name)) { return; } - if ((ce = zend_lookup_class(name)) == NULL) { + if (UNEXPECTED((ce = zend_lookup_class(name)) == NULL)) { zend_throw_exception_ex(reflection_exception_ptr, 0, "Class \"%s\" does not exist", ZSTR_VAL(name)); - zend_string_release(name); + zend_string_release_outline(name); RETURN_THROWS(); } zend_string_release(name); @@ -2494,8 +2494,8 @@ ZEND_METHOD(ReflectionParameter, __construct) } else if ((fptr = zend_hash_find_ptr(&ce->function_table, lcname)) == NULL) { zend_throw_exception_ex(reflection_exception_ptr, 0, "Method %s::%s() does not exist", ZSTR_VAL(ce->name), ZSTR_VAL(name)); - zend_string_release(name); - zend_string_release(lcname); + zend_string_release_outline(name); + zend_string_release_outline(lcname); RETURN_THROWS(); } zend_string_release(name); @@ -2589,8 +2589,8 @@ ZEND_METHOD(ReflectionParameter, __construct) return; failure: - if (fptr->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) { - zend_string_release_ex(fptr->common.function_name, 0); + if (UNEXPECTED(fptr->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) { + zend_string_release_ex_outline(fptr->common.function_name, 0); zend_free_trampoline(fptr); } if (is_closure) { @@ -5804,7 +5804,7 @@ ZEND_METHOD(ReflectionProperty, setValue) if (Z_TYPE_P(tmp) != IS_NULL && Z_TYPE_P(tmp) != IS_OBJECT) { zend_string *method_name = get_active_function_or_method_name(); zend_error(E_DEPRECATED, "Calling %s() with a 1st argument which is not null or an object is deprecated", ZSTR_VAL(method_name)); - zend_string_release(method_name); + zend_string_release_outline(method_name); if (UNEXPECTED(EG(exception))) { RETURN_THROWS(); } @@ -5812,7 +5812,7 @@ ZEND_METHOD(ReflectionProperty, setValue) } else { zend_string *method_name = get_active_function_or_method_name(); zend_error(E_DEPRECATED, "Calling %s() with a single argument is deprecated", ZSTR_VAL(method_name)); - zend_string_release(method_name); + zend_string_release_outline(method_name); if (UNEXPECTED(EG(exception))) { RETURN_THROWS(); } @@ -6929,7 +6929,7 @@ ZEND_METHOD(ReflectionAttribute, newInstance) RETURN_THROWS(); } - if (!(attr->target & flags)) { + if (UNEXPECTED(!(attr->target & flags))) { zend_string *location = zend_get_attribute_target_names(attr->target); zend_string *allowed = zend_get_attribute_target_names(flags); @@ -6937,8 +6937,8 @@ ZEND_METHOD(ReflectionAttribute, newInstance) ZSTR_VAL(attr->data->name), ZSTR_VAL(location), ZSTR_VAL(allowed) ); - zend_string_release(location); - zend_string_release(allowed); + zend_string_release_outline(location); + zend_string_release_outline(allowed); RETURN_THROWS(); } diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c index 74e77973405b2..322002e758589 100644 --- a/ext/session/mod_files.c +++ b/ext/session/mod_files.c @@ -513,13 +513,13 @@ PS_READ_FUNC(files) #endif #endif - if (n != (zend_long)sbuf.st_size) { + if (UNEXPECTED(n != (zend_long)sbuf.st_size)) { if (n == -1) { php_error_docref(NULL, E_WARNING, "Read failed: %s (%d)", strerror(errno), errno); } else { php_error_docref(NULL, E_WARNING, "Read returned less bytes than requested"); } - zend_string_release_ex(*val, 0); + zend_string_release_ex_outline (*val, 0); *val = ZSTR_EMPTY_ALLOC(); return FAILURE; } diff --git a/ext/session/session.c b/ext/session/session.c index 01cffb997dafe..3a97b10bf5701 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -1599,7 +1599,7 @@ PHPAPI zend_result php_session_start(void) /* {{{ */ Z_STRLEN_P(data) != 0 && strstr(Z_STRVAL_P(data), PS(extern_referer_chk)) == NULL ) { - zend_string_release_ex(PS(id), 0); + zend_string_release_ex_outline(PS(id), 0); PS(id) = NULL; } } @@ -2152,7 +2152,7 @@ PHP_FUNCTION(session_set_save_handler) /* If a custom session handler is already set, release relevant info */ if (PS(mod_user_class_name)) { - zend_string_release(PS(mod_user_class_name)); + zend_string_release_outline(PS(mod_user_class_name)); PS(mod_user_class_name) = NULL; } @@ -2410,7 +2410,7 @@ PHP_FUNCTION(session_create_id) smart_str_append(&id, new_id); zend_string_release_ex(new_id, 0); } else { - smart_str_free(&id); + smart_str_free_outline(&id); php_error_docref(NULL, E_WARNING, "Failed to create new ID"); RETURN_FALSE; } @@ -2975,7 +2975,7 @@ static PHP_MINFO_FUNCTION(session) /* {{{ */ if (save_handlers.s) { smart_str_0(&save_handlers); php_info_print_table_row(2, "Registered save handlers", ZSTR_VAL(save_handlers.s)); - smart_str_free(&save_handlers); + smart_str_free_outline(&save_handlers); } else { php_info_print_table_row(2, "Registered save handlers", "none"); } @@ -2983,7 +2983,7 @@ static PHP_MINFO_FUNCTION(session) /* {{{ */ if (ser_handlers.s) { smart_str_0(&ser_handlers); php_info_print_table_row(2, "Registered serializer handlers", ZSTR_VAL(ser_handlers.s)); - smart_str_free(&ser_handlers); + smart_str_free_outline(&ser_handlers); } else { php_info_print_table_row(2, "Registered serializer handlers", "none"); } diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index d3fee2952c651..6196f598455ae 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -507,7 +507,7 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value, if (node->type == XML_ATTRIBUTE_NODE) { zend_throw_error(NULL, "Cannot create duplicate attribute"); if (value_str) { - zend_string_release(value_str); + zend_string_release_outline(value_str); } return &EG(error_zval); } diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 0521087da303d..ebf97b52dcc82 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -317,8 +317,8 @@ static zend_result spl_filesystem_file_open(spl_filesystem_object *intern, bool intern->type = SPL_FS_FILE; php_stat(intern->file_name, FS_IS_DIR, &tmp); - if (Z_TYPE(tmp) == IS_TRUE) { - zend_string_release(intern->u.file.open_mode); + if (UNEXPECTED(Z_TYPE(tmp) == IS_TRUE)) { + zend_string_release_outline(intern->u.file.open_mode); intern->u.file.open_mode = NULL; intern->file_name = NULL; zend_throw_exception_ex(spl_ce_LogicException, 0, "Cannot use SplFileObject with directories"); diff --git a/ext/standard/array.c b/ext/standard/array.c index 068057e70a9ec..dd50b6185ba19 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -807,7 +807,7 @@ PHP_FUNCTION(rsort) } /* }}} */ -static inline int php_array_user_compare_unstable(Bucket *f, Bucket *s) /* {{{ */ +static int php_array_user_compare_unstable(Bucket *f, Bucket *s) /* {{{ */ { zval args[2]; zval retval; @@ -925,7 +925,7 @@ PHP_FUNCTION(uasort) } /* }}} */ -static inline int php_array_user_key_compare_unstable(Bucket *f, Bucket *s) /* {{{ */ +static int php_array_user_key_compare_unstable(Bucket *f, Bucket *s) /* {{{ */ { zval args[2]; zval retval; @@ -1631,7 +1631,7 @@ PHP_FUNCTION(array_walk_recursive) * 0 = return boolean * 1 = return key */ -static inline void _php_search_array(zval *return_value, zval *value, zval *array, bool strict, int behavior) /* {{{ */ +static void _php_search_array(zval *return_value, zval *value, zval *array, bool strict, int behavior) /* {{{ */ { zval *entry; /* pointer to array entry */ zend_ulong num_idx; diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 7b3494303ca41..475402aebb4e6 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -1887,9 +1887,9 @@ PHP_FUNCTION(ini_parse_quantity) RETVAL_LONG(zend_ini_parse_quantity(shorthand, &errstr)); - if (errstr) { + if (UNEXPECTED(errstr)) { zend_error(E_WARNING, "%s", ZSTR_VAL(errstr)); - zend_string_release(errstr); + zend_string_release_outline(errstr); } } /* }}} */ diff --git a/ext/standard/exec.c b/ext/standard/exec.c index 5b3ba60e5fdea..85cc410a75a77 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -368,9 +368,9 @@ PHPAPI zend_string *php_escape_shell_cmd(const zend_string *unescaped_cmd) } ZSTR_VAL(cmd)[y] = '\0'; - if (y > cmd_max_len + 1) { + if (UNEXPECTED(y > cmd_max_len + 1)) { zend_value_error("Escaped command exceeds the allowed length of %zu bytes", cmd_max_len); - zend_string_release_ex(cmd, 0); + zend_string_release_ex_outline(cmd, 0); return ZSTR_EMPTY_ALLOC(); } @@ -458,9 +458,9 @@ PHPAPI zend_string *php_escape_shell_arg(const zend_string *unescaped_arg) #endif ZSTR_VAL(cmd)[y] = '\0'; - if (y > cmd_max_len + 1) { + if (UNEXPECTED(y > cmd_max_len + 1)) { zend_value_error("Escaped argument exceeds the allowed length of %zu bytes", cmd_max_len); - zend_string_release_ex(cmd, 0); + zend_string_release_ex_outline(cmd, 0); return ZSTR_EMPTY_ALLOC(); } diff --git a/ext/standard/file.c b/ext/standard/file.c index 8a3decd5125fd..18a521ad1fd2f 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -541,7 +541,7 @@ PHP_FUNCTION(file_put_contents) bytes_written = php_stream_write(stream, ZSTR_VAL(str), ZSTR_LEN(str)); if (bytes_written != ZSTR_LEN(str)) { php_error_docref(NULL, E_WARNING, "Failed to write %zd bytes to %s", ZSTR_LEN(str), filename); - zend_tmp_string_release(t); + zend_tmp_string_release_outline(t); numbytes = -1; break; } diff --git a/ext/standard/http.c b/ext/standard/http.c index 7a4a58755d894..86ba48fec0a7b 100644 --- a/ext/standard/http.c +++ b/ext/standard/http.c @@ -248,9 +248,9 @@ static zend_result cache_request_parse_body_option(HashTable *options, zval *opt if (Z_TYPE_P(option) == IS_STRING) { zend_string *errstr; result = zend_ini_parse_quantity(Z_STR_P(option), &errstr); - if (errstr) { + if (UNEXPECTED(errstr)) { zend_error(E_WARNING, "%s", ZSTR_VAL(errstr)); - zend_string_release(errstr); + zend_string_release_outline(errstr); } } else if (Z_TYPE_P(option) == IS_LONG) { result = Z_LVAL_P(option); diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index edc3327aa1150..1bd0a38b22abd 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -870,7 +870,7 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, if (!s) { s = ZSTR_VAL(resource->path); if (!ZSTR_LEN(resource->path)) { - zend_string_release_ex(resource->path, 0); + zend_string_release_ex_outline(resource->path, 0); resource->path = ZSTR_INIT_LITERAL("/", 0); s = ZSTR_VAL(resource->path); } else { diff --git a/ext/standard/incomplete_class.c b/ext/standard/incomplete_class.c index 228e03fbe863e..370392808909d 100644 --- a/ext/standard/incomplete_class.c +++ b/ext/standard/incomplete_class.c @@ -34,7 +34,7 @@ static void incomplete_class_message(zend_object *object) php_error_docref(NULL, E_WARNING, INCOMPLETE_CLASS_MSG, "access a property", class_name ? ZSTR_VAL(class_name) : "unknown"); if (class_name) { - zend_string_release_ex(class_name, 0); + zend_string_release_ex_outline(class_name, 0); } } @@ -44,7 +44,7 @@ static void throw_incomplete_class_error(zend_object *object, const char *what) zend_throw_error(NULL, INCOMPLETE_CLASS_MSG, what, class_name ? ZSTR_VAL(class_name) : "unknown"); if (class_name) { - zend_string_release_ex(class_name, 0); + zend_string_release_ex_outline(class_name, 0); } } diff --git a/ext/standard/info.c b/ext/standard/info.c index 70cd5bda7b2e9..36666afd85e31 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -58,7 +58,7 @@ static ZEND_COLD int php_info_print_html_esc(const char *str, size_t len) /* {{{ new_str = php_escape_html_entities((const unsigned char *) str, len, 0, ENT_QUOTES, "utf-8"); written = php_output_write(ZSTR_VAL(new_str), ZSTR_LEN(new_str)); - zend_string_free(new_str); + zend_string_free_outline(new_str); return written; } /* }}} */ @@ -207,7 +207,7 @@ static ZEND_COLD void php_print_gpcse_array(char *name, uint32_t name_length) php_info_print("
");
 					php_info_print_html_esc(ZSTR_VAL(str), ZSTR_LEN(str));
 					php_info_print("
"); - zend_string_release_ex(str, 0); + zend_string_release_ex_outline(str, 0); } else { zend_print_zval_r(tmp, 0); } @@ -225,7 +225,7 @@ static ZEND_COLD void php_print_gpcse_array(char *name, uint32_t name_length) php_info_print(ZSTR_VAL(str)); } - zend_tmp_string_release(tmp2); + zend_tmp_string_release_outline(tmp2); } if (!sapi_module.phpinfo_as_text) { php_info_print("\n"); @@ -234,7 +234,7 @@ static ZEND_COLD void php_print_gpcse_array(char *name, uint32_t name_length) } } ZEND_HASH_FOREACH_END(); } - zend_string_efree(key); + zend_string_efree_outline(key); } /* }}} */ @@ -939,7 +939,7 @@ PHPAPI ZEND_COLD void php_print_info(int flag) zend_html_puts(zend_version, strlen(zend_version)); } php_info_print_box_end(); - zend_string_free(php_uname); + zend_string_free_outline(php_uname); } zend_ini_sort_entries(); diff --git a/ext/standard/password.c b/ext/standard/password.c index 1e647bb301c3b..91a5c98f0a903 100644 --- a/ext/standard/password.c +++ b/ext/standard/password.c @@ -86,15 +86,15 @@ static zend_string* php_password_make_salt(size_t length) /* {{{ */ buffer = zend_string_alloc(length * 3 / 4 + 1, 0); if (FAILURE == php_random_bytes_throw(ZSTR_VAL(buffer), ZSTR_LEN(buffer))) { zend_value_error("Unable to generate salt"); - zend_string_release_ex(buffer, 0); + zend_string_release_ex_outline(buffer, 0); return NULL; } ret = zend_string_alloc(length, 0); if (php_password_salt_to64(ZSTR_VAL(buffer), ZSTR_LEN(buffer), length, ZSTR_VAL(ret)) == FAILURE) { zend_value_error("Generated salt too short"); - zend_string_release_ex(buffer, 0); - zend_string_release_ex(ret, 0); + zend_string_release_ex_outline(buffer, 0); + zend_string_release_ex_outline(ret, 0); return NULL; } zend_string_release_ex(buffer, 0); diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index f55fbfef5685d..7790d29d56ab6 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -511,13 +511,13 @@ static zend_string *get_valid_arg_string(zval *zv, int elem_num) { if (elem_num == 1 && ZSTR_LEN(str) == 0) { zend_value_error("First element must contain a non-empty program name"); - zend_string_release(str); + zend_string_release_outline(str); return NULL; } if (strlen(ZSTR_VAL(str)) != ZSTR_LEN(str)) { zend_value_error("Command array element %d contains a null byte", elem_num); - zend_string_release(str); + zend_string_release_outline(str); return NULL; } @@ -868,7 +868,7 @@ static zend_result set_proc_descriptor_to_socket(descriptorspec_item *desc) if (create_socketpair(sock)) { zend_string *err = php_socket_error_str(php_socket_errno()); php_error_docref(NULL, E_WARNING, "Unable to create socket pair: %s", ZSTR_VAL(err)); - zend_string_release(err); + zend_string_release_outline(err); return FAILURE; } diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index 1929075b60b71..cb6a79a8f2f86 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -167,7 +167,7 @@ PHP_FUNCTION(stream_socket_client) zend_string *quoted_host = php_addslashes(host); php_error_docref(NULL, E_WARNING, "Unable to connect to %s (%s)", ZSTR_VAL(quoted_host), errstr == NULL ? "Unknown error" : ZSTR_VAL(errstr)); - zend_string_release_ex(quoted_host, 0); + zend_string_release_ex_outline(quoted_host, 0); } if (hashkey) { @@ -242,7 +242,7 @@ PHP_FUNCTION(stream_socket_server) if (zerrstr && errstr) { ZEND_TRY_ASSIGN_REF_STR(zerrstr, errstr); } else if (errstr) { - zend_string_release_ex(errstr, 0); + zend_string_release_ex_outline(errstr, 0); } RETURN_FALSE; } @@ -312,7 +312,7 @@ PHP_FUNCTION(stream_socket_accept) php_stream_to_zval(clistream, return_value); } else { if (peername) { - zend_string_release(peername); + zend_string_release_outline(peername); } php_error_docref(NULL, E_WARNING, "Accept failed: %s", errstr ? ZSTR_VAL(errstr) : "Unknown error"); RETVAL_FALSE; diff --git a/ext/standard/string.c b/ext/standard/string.c index a5d8827edf5aa..135176574add1 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -1367,7 +1367,7 @@ PHP_FUNCTION(str_decrement) if (UNEXPECTED(carry || (ZSTR_VAL(decremented)[0] == '0' && ZSTR_LEN(decremented) > 1))) { if (ZSTR_LEN(decremented) == 1) { - zend_string_release_ex(decremented, /* persistent */ false); + zend_string_release_ex_outline(decremented, /* persistent */ false); zend_argument_value_error(1, "\"%s\" is out of decrement range", ZSTR_VAL(str)); RETURN_THROWS(); } @@ -1539,7 +1539,7 @@ PHPAPI size_t php_dirname(char *path, size_t len) } /* }}} */ -static inline void _zend_dirname(zval *return_value, zend_string *str, zend_long levels) +static void _zend_dirname(zval *return_value, zend_string *str, zend_long levels) { zend_string *ret; @@ -1554,7 +1554,7 @@ static inline void _zend_dirname(zval *return_value, zend_string *str, zend_long #endif } else if (levels < 1) { zend_argument_value_error(2, "must be greater than or equal to 1"); - zend_string_efree(ret); + zend_string_efree_outline(ret); RETURN_THROWS(); } else { /* Some levels up */ @@ -1784,7 +1784,7 @@ PHP_FUNCTION(stristr) } /* }}} */ -static inline void _zend_strstr(zval *return_value, zend_string *haystack, zend_string *needle, bool part) +static void _zend_strstr(zval *return_value, zend_string *haystack, zend_string *needle, bool part) { const char *found = NULL; zend_long found_offset; @@ -1928,7 +1928,7 @@ PHP_FUNCTION(str_ends_with) } /* }}} */ -static inline void _zend_strpos(zval *return_value, zend_string *haystack, zend_string *needle, zend_long offset) +static zend_always_inline void _zend_strpos_inline(zval *return_value, zend_string *haystack, zend_string *needle, zend_long offset) { const char *found = NULL; @@ -1950,6 +1950,11 @@ static inline void _zend_strpos(zval *return_value, zend_string *haystack, zend_ RETURN_LONG(found - ZSTR_VAL(haystack)); } +static zend_never_inline void _zend_strpos(zval *return_value, zend_string *haystack, zend_string *needle, zend_long offset) +{ + _zend_strpos_inline(return_value, haystack, needle, offset); +} + /* {{{ Finds position of first occurrence of a string within another */ PHP_FUNCTION(strpos) { @@ -1975,7 +1980,7 @@ ZEND_FRAMELESS_FUNCTION(strpos, 2) Z_FLF_PARAM_STR(1, haystack, haystack_tmp); Z_FLF_PARAM_STR(2, needle, needle_tmp); - _zend_strpos(return_value, haystack, needle, 0); + _zend_strpos_inline(return_value, haystack, needle, 0); flf_clean: Z_FLF_PARAM_FREE_STR(1, haystack_tmp); @@ -2124,7 +2129,7 @@ PHP_FUNCTION(strripos) haystack_dup = zend_string_tolower(haystack); if (offset >= 0) { if ((size_t)offset > ZSTR_LEN(haystack)) { - zend_string_release_ex(haystack_dup, 0); + zend_string_release_ex_outline(haystack_dup, 0); zend_argument_value_error(3, "must be contained in argument #1 ($haystack)"); RETURN_THROWS(); } @@ -2132,7 +2137,7 @@ PHP_FUNCTION(strripos) e = ZSTR_VAL(haystack_dup) + ZSTR_LEN(haystack); } else { if (offset < -ZEND_LONG_MAX || (size_t)(-offset) > ZSTR_LEN(haystack)) { - zend_string_release_ex(haystack_dup, 0); + zend_string_release_ex_outline(haystack_dup, 0); zend_argument_value_error(3, "must be contained in argument #1 ($haystack)"); RETURN_THROWS(); } @@ -2262,7 +2267,7 @@ PHP_FUNCTION(chunk_split) } /* }}} */ -static inline void _zend_substr(zval *return_value, zend_string *str, zend_long f, bool len_is_null, zend_long l) +static void _zend_substr(zval *return_value, zend_string *str, zend_long f, bool len_is_null, zend_long l) { if (f < 0) { /* if "from" position is negative, count start position from the end diff --git a/ext/standard/var.c b/ext/standard/var.c index dd2bd86d91ee8..cff2069cd364d 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -944,7 +944,7 @@ static int php_var_serialize_get_sleep_props( php_error_docref(NULL, E_WARNING, "\"%s\" returned as member variable from __sleep() but does not exist", ZSTR_VAL(name)); - zend_tmp_string_release(tmp_name); + zend_tmp_string_release_outline(tmp_name); } ZEND_HASH_FOREACH_END(); zend_release_properties(props); diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re index 69dd3f84d3a7e..f928b21f5d69e 100644 --- a/ext/standard/var_unserializer.re +++ b/ext/standard/var_unserializer.re @@ -391,7 +391,7 @@ object = [OC]; -static inline zend_long parse_iv2(const unsigned char *p, const unsigned char **q) +static zend_long parse_iv2(const unsigned char *p, const unsigned char **q) { zend_ulong result = 0; zend_ulong neg = 0; @@ -1074,7 +1074,7 @@ use_double: } if (*(YYCURSOR) != '"') { - zend_string_efree(str); + zend_string_efree_outline(str); *p = YYCURSOR; return 0; } @@ -1193,9 +1193,9 @@ object ":" uiv ":" ["] { lc_name = zend_string_tolower(class_name); if(!unserialize_allowed_class(lc_name, var_hash)) { - zend_string_release_ex(lc_name, 0); + zend_string_release_ex_outline(lc_name, 0); if (!zend_is_valid_class_name(class_name)) { - zend_string_release_ex(class_name, 0); + zend_string_release_ex_outline(class_name, 0); return 0; } incomplete_class = 1; @@ -1206,7 +1206,7 @@ object ":" uiv ":" ["] { if ((*var_hash)->allowed_classes && ZSTR_HAS_CE_CACHE(class_name)) { ce = ZSTR_GET_CE_CACHE(class_name); if (ce) { - zend_string_release_ex(lc_name, 0); + zend_string_release_ex_outline(lc_name, 0); break; } } @@ -1215,13 +1215,13 @@ object ":" uiv ":" ["] { if (ce && (ce->ce_flags & ZEND_ACC_LINKED) && !(ce->ce_flags & ZEND_ACC_ANON_CLASS)) { - zend_string_release_ex(lc_name, 0); + zend_string_release_ex_outline(lc_name, 0); break; } if (!ZSTR_HAS_CE_CACHE(class_name) && !zend_is_valid_class_name(class_name)) { - zend_string_release_ex(lc_name, 0); - zend_string_release_ex(class_name, 0); + zend_string_release_ex_outline(lc_name, 0); + zend_string_release_ex_outline(class_name, 0); return 0; } @@ -1231,7 +1231,7 @@ object ":" uiv ":" ["] { BG(serialize_lock)--; zend_string_release_ex(lc_name, 0); if (EG(exception)) { - zend_string_release_ex(class_name, 0); + zend_string_release_ex_outline(class_name, 0); return 0; } @@ -1256,7 +1256,7 @@ object ":" uiv ":" ["] { zval_ptr_dtor(&retval); if (EG(exception)) { - zend_string_release_ex(class_name, 0); + zend_string_release_ex_outline(class_name, 0); zval_ptr_dtor(&user_func); return 0; } @@ -1278,7 +1278,7 @@ object ":" uiv ":" ["] { if (ce->ce_flags & ZEND_ACC_NOT_SERIALIZABLE) { zend_throw_exception_ex(NULL, 0, "Unserialization of '%s' is not allowed", ZSTR_VAL(ce->name)); - zend_string_release_ex(class_name, 0); + zend_string_release_ex_outline(class_name, 0); return 0; } @@ -1296,13 +1296,13 @@ object ":" uiv ":" ["] { if (*p >= max - 2) { zend_error(E_WARNING, "Bad unserialize data"); - zend_string_release_ex(class_name, 0); + zend_string_release_ex_outline(class_name, 0); return 0; } elements = parse_iv2(*p + 2, p); if (elements < 0 || IS_FAKE_ELEM_COUNT(elements, max - YYCURSOR)) { - zend_string_release_ex(class_name, 0); + zend_string_release_ex_outline(class_name, 0); return 0; } @@ -1326,12 +1326,12 @@ object ":" uiv ":" ["] { * depending on the serialization format. */ if (ce->serialize != NULL && !has_unserialize) { zend_error(E_WARNING, "Erroneous data format for unserializing '%s'", ZSTR_VAL(ce->name)); - zend_string_release_ex(class_name, 0); + zend_string_release_ex_outline(class_name, 0); return 0; } if (object_init_ex(rval, ce) == FAILURE) { - zend_string_release_ex(class_name, 0); + zend_string_release_ex_outline(class_name, 0); return 0; } @@ -1418,8 +1418,8 @@ object ":" uiv ":" ["] { return 1; fail: - zend_string_release_ex(enum_name, 0); - zend_string_release_ex(case_name, 0); + zend_string_release_ex_outline(enum_name, 0); + zend_string_release_ex_outline(case_name, 0); return 0; } diff --git a/ext/xml/xml.c b/ext/xml/xml.c index 1ae8d32c1f3fa..50d3f39c54ae6 100644 --- a/ext/xml/xml.c +++ b/ext/xml/xml.c @@ -1118,7 +1118,7 @@ static bool php_xml_check_string_method_arg( if (status == false) { \ zend_argument_value_error(2, "cannot safely swap to object of class %s as method \"%s\" does not exist, which was set via " handler_set_method, \ ZSTR_VAL(new_this_obj->ce->name), ZSTR_VAL(method_name)); \ - zend_string_release(method_name); \ + zend_string_release_outline(method_name); \ RETURN_THROWS(); \ } \ zend_string_release(method_name); \ diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 5d331c2fa4b82..83d7e4928216b 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -218,7 +218,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, const char *file, s } else if (len > MAXPATHLEN) { php_error_docref(NULL, E_WARNING, "Full extraction path exceed MAXPATHLEN (%i)", MAXPATHLEN); efree(file_dirname_fullpath); - zend_string_release_ex(file_basename, 0); + zend_string_release_ex_outline(file_basename, 0); CWD_STATE_FREE(new_state.cwd); return 0; } @@ -781,7 +781,7 @@ int php_zip_pcre(zend_string *regexp, char *path, int path_len, zval *return_val if ((path_len + namelist_len + 1) >= MAXPATHLEN) { php_error_docref(NULL, E_WARNING, "add_path string too long (max: %u, %zu given)", MAXPATHLEN - 1, (path_len + namelist_len + 1)); - zend_string_release_ex(namelist[i], 0); + zend_string_release_ex_outline(namelist[i], 0); break; } @@ -803,7 +803,7 @@ int php_zip_pcre(zend_string *regexp, char *path, int path_len, zval *return_val if (0 != VCWD_STAT(fullpath, &s)) { php_error_docref(NULL, E_WARNING, "Cannot read <%s>", fullpath); - zend_string_release_ex(namelist[i], 0); + zend_string_release_ex_outline(namelist[i], 0); continue; } diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 3c9f72e82bc2f..7ea65c6be701e 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -401,14 +401,14 @@ static zend_string *php_zlib_encode(const char *in_buf, size_t in_len, int encod status = deflate(&Z, Z_FINISH); deflateEnd(&Z); - if (Z_STREAM_END == status) { + if (EXPECTED(Z_STREAM_END == status)) { /* size buffer down to actual length */ out = zend_string_truncate(out, Z.total_out, 0); ZSTR_VAL(out)[ZSTR_LEN(out)] = '\0'; return out; - } else { - zend_string_efree(out); } + + zend_string_efree_outline(out); } php_error_docref(NULL, E_WARNING, "%s", zError(status)); @@ -1022,7 +1022,7 @@ PHP_FUNCTION(inflate_add) case Z_DATA_ERROR: efree(ctx->inflateDict); ctx->inflateDict = NULL; - zend_string_release_ex(out, 0); + zend_string_release_ex_outline(out, 0); php_error_docref(NULL, E_WARNING, "Dictionary does not match expected dictionary (incorrect adler32 hash)"); RETURN_FALSE; EMPTY_SWITCH_DEFAULT_CASE() @@ -1033,7 +1033,7 @@ PHP_FUNCTION(inflate_add) RETURN_FALSE; } default: - zend_string_release_ex(out, 0); + zend_string_release_ex_outline(out, 0); php_error_docref(NULL, E_WARNING, "%s", zError(status)); RETURN_FALSE; } @@ -1246,7 +1246,7 @@ PHP_FUNCTION(deflate_add) RETURN_STR(out); break; default: - zend_string_release_ex(out, 0); + zend_string_release_ex_outline(out, 0); php_error_docref(NULL, E_WARNING, "zlib error (%s)", zError(status)); RETURN_FALSE; } diff --git a/main/SAPI.c b/main/SAPI.c index ba34f7ef63860..2d5ed4cff078b 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -296,7 +296,7 @@ SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data) } -static inline char *get_default_content_type(uint32_t prefix_len, uint32_t *len) +static char *get_default_content_type(uint32_t prefix_len, uint32_t *len) { char *mimetype, *charset, *content_type; uint32_t mimetype_len, charset_len; @@ -850,7 +850,7 @@ SAPI_API int sapi_send_headers(void) * in case of an error situation. */ if (SG(sapi_headers).send_default_content_type && sapi_module.send_headers) { - uint32_t len = 0; + uint32_t len = 0; char *default_mimetype = get_default_content_type(0, &len); if (default_mimetype && len) { diff --git a/main/main.c b/main/main.c index f93ae526c8a29..ff005aec5b238 100644 --- a/main/main.c +++ b/main/main.c @@ -870,7 +870,7 @@ PHPAPI ZEND_COLD void php_log_err_with_severity(const char *log_message, int sys php_ignore_value(write(fd, tmp, len)); #endif efree(tmp); - zend_string_free(error_time_str); + zend_string_free_outline(error_time_str); close(fd); PG(in_error_log) = 0; return; @@ -968,7 +968,7 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ if (PG(html_errors)) { zend_string *replace_buffer = escape_html(ZSTR_VAL(buffer), ZSTR_LEN(buffer)); - zend_string_free(buffer); + zend_string_free_outline(buffer); if (replace_buffer) { buffer = replace_buffer; @@ -1106,7 +1106,7 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ message = zend_strpprintf_unchecked(0, "%s: %S", origin, buffer); } if (replace_origin) { - zend_string_free(replace_origin); + zend_string_free_outline(replace_origin); } else { efree(origin); } @@ -1114,10 +1114,10 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ efree(docref_buf); } - zend_string_free(buffer); + zend_string_free_outline(buffer); zend_error_zstr(type, message); - zend_string_release(message); + zend_string_release_outline(message); } /* }}} */ @@ -1367,7 +1367,7 @@ static ZEND_COLD void php_error_cb(int orig_type, zend_string *error_filename, c if (type == E_ERROR || type == E_PARSE) { zend_string *buf = escape_html(ZSTR_VAL(message), ZSTR_LEN(message)); php_printf("%s
\n%s: %s in %s on line %" PRIu32 "
\n%s", STR_PRINT(prepend_string), error_type_str, ZSTR_VAL(buf), ZSTR_VAL(error_filename), error_lineno, STR_PRINT(append_string)); - zend_string_free(buf); + zend_string_free_outline(buf); } else { php_printf_unchecked("%s
\n%s: %S in %s on line %" PRIu32 "
\n%s", STR_PRINT(prepend_string), error_type_str, message, ZSTR_VAL(error_filename), error_lineno, STR_PRINT(append_string)); } diff --git a/main/network.c b/main/network.c index f582218d1a1a7..8d8cb889850bc 100644 --- a/main/network.c +++ b/main/network.c @@ -206,7 +206,7 @@ PHPAPI int php_network_getaddresses(const char *host, int socktype, struct socka if (error_string) { /* free error string received during previous iteration (if any) */ if (*error_string) { - zend_string_release_ex(*error_string, 0); + zend_string_release_ex_outline(*error_string, 0); } *error_string = strpprintf(0, "php_network_getaddresses: getaddrinfo for %s failed (null result pointer) errno=%d", host, errno); php_error_docref(NULL, E_WARNING, "%s", ZSTR_VAL(*error_string)); @@ -559,7 +559,7 @@ PHPAPI int php_network_parse_network_address_with_port(const char *addr, zend_lo if (n == 0) { if (errstr) { php_error_docref(NULL, E_WARNING, "Failed to resolve `%s': %s", tmp, ZSTR_VAL(errstr)); - zend_string_release_ex(errstr, 0); + zend_string_release_ex_outline(errstr, 0); } goto out; } diff --git a/main/output.c b/main/output.c index c6ac741cab1fc..9c5d8a6dfa445 100644 --- a/main/output.c +++ b/main/output.c @@ -52,7 +52,7 @@ static inline bool php_output_lock_error(int op); static inline void php_output_op(int op, const char *str, size_t len); static inline php_output_handler *php_output_handler_init(zend_string *name, size_t chunk_size, int flags); -static inline php_output_handler_status_t php_output_handler_op(php_output_handler *handler, php_output_context *context); +static php_output_handler_status_t php_output_handler_op(php_output_handler *handler, php_output_context *context); static inline bool php_output_handler_append(php_output_handler *handler, const php_output_buffer *buf); static inline zval *php_output_handler_status(php_output_handler *handler, zval *entry); @@ -898,7 +898,7 @@ static inline bool php_output_handler_append(php_output_handler *handler, const /* {{{ static php_output_handler_status_t php_output_handler_op(php_output_handler *handler, php_output_context *context) * Output handler operation dispatcher, applying context op to the php_output_handler handler */ -static inline php_output_handler_status_t php_output_handler_op(php_output_handler *handler, php_output_context *context) +static php_output_handler_status_t php_output_handler_op(php_output_handler *handler, php_output_context *context) { php_output_handler_status_t status; int original_op = context->op; diff --git a/main/streams/streams.c b/main/streams/streams.c index 0b3e5cc06cb9e..7d06c35fa4405 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -2222,7 +2222,7 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mod if ((options & STREAM_USE_URL) && (!wrapper || !wrapper->is_url)) { php_error_docref(NULL, E_WARNING, "This function may only be used against URLs"); if (resolved_path) { - zend_string_release_ex(resolved_path, 0); + zend_string_release_ex_outline(resolved_path, 0); } return NULL; } diff --git a/main/streams/transports.c b/main/streams/transports.c index 38850a3b541a4..3fc28a044c5e7 100644 --- a/main/streams/transports.c +++ b/main/streams/transports.c @@ -46,7 +46,7 @@ PHPAPI int php_stream_xport_unregister(const char *protocol) #define ERR_RETURN(out_err, local_err, fmt) \ if (out_err) { *out_err = local_err; } \ else { php_error_docref(NULL, E_WARNING, fmt, local_err ? ZSTR_VAL(local_err) : "Unspecified error"); \ - if (local_err) { zend_string_release_ex(local_err, 0); local_err = NULL; } \ + if (local_err) { zend_string_release_ex_outline(local_err, 0); local_err = NULL; } \ } PHPAPI php_stream *_php_stream_xport_create(const char *name, size_t namelen, int options, diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index ae7dbfb51fecc..08261ba032505 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -993,7 +993,7 @@ static int do_cli(int argc, char **argv) /* {{{ */ zval argn, argi; if (!exec_run && script_file) { - zend_string_release_ex(file_handle.filename, 0); + zend_string_release_ex_outline(file_handle.filename, 0); file_handle.filename = NULL; } From 63820dc8f8cc4858540dc61714a78d9936f705ab Mon Sep 17 00:00:00 2001 From: Levi Morrison Date: Mon, 22 Jul 2024 22:33:27 -0600 Subject: [PATCH 02/12] Make more string API functions ZEND_API --- Zend/zend.c | 9 +++--- Zend/zend_builtin_functions.c | 4 +-- Zend/zend_exceptions.c | 23 +++++++++------ Zend/zend_string.c | 17 +++++++++++ Zend/zend_string.h | 54 ++++++++++++++++++---------------- Zend/zend_types.h | 6 ++-- ext/opcache/ZendAccelerator.c | 6 ++-- ext/pdo/pdo_stmt.c | 2 +- ext/simplexml/simplexml.c | 4 +-- ext/spl/spl_directory.c | 2 +- ext/standard/url_scanner_ex.re | 8 ++--- ext/standard/var.c | 2 +- sapi/phpdbg/phpdbg.c | 2 +- sapi/phpdbg/phpdbg_bp.c | 6 ++-- sapi/phpdbg/phpdbg_frame.c | 2 +- sapi/phpdbg/phpdbg_prompt.c | 2 +- 16 files changed, 88 insertions(+), 61 deletions(-) diff --git a/Zend/zend.c b/Zend/zend.c index 98ea35ed2b6d9..886dc06b80f43 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -2049,8 +2049,9 @@ ZEND_API void zend_alloc_ce_cache(zend_string *type_name) } -ZEND_API extern inline uint32_t zend_gc_refcount(const zend_refcounted_h *p); ZEND_API extern inline uint32_t zend_gc_delref(zend_refcounted_h *p); -ZEND_API extern zend_always_inline uint8_t zval_gc_type(uint32_t gc_type_info); -ZEND_API extern zend_always_inline uint32_t zval_gc_flags(uint32_t gc_type_info); -ZEND_API extern zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info); +ZEND_API extern inline uint32_t zval_gc_flags(uint32_t gc_type_info); +ZEND_API extern inline uint32_t zval_gc_info(uint32_t gc_type_info); +ZEND_API extern inline uint32_t zend_gc_refcount(const zend_refcounted_h *p); +ZEND_API extern inline uint32_t zend_gc_set_refcount(zend_refcounted_h *p, uint32_t rc); +ZEND_API extern inline uint8_t zval_gc_type(uint32_t gc_type_info); diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 9d2751a4a5856..ca1f1d7317742 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1026,7 +1026,7 @@ flf_clean:; Z_FLF_PARAM_FREE_STR(2, property_tmp) } -static inline void _class_exists_impl(zval *return_value, zend_string *name, bool autoload, int flags, int skip_flags) /* {{{ */ +static void _class_exists_impl(zval *return_value, zend_string *name, bool autoload, int flags, int skip_flags) /* {{{ */ { zend_string *lcname; zend_class_entry *ce; @@ -1336,7 +1336,7 @@ ZEND_FUNCTION(restore_exception_handler) } /* }}} */ -static inline void get_declared_class_impl(INTERNAL_FUNCTION_PARAMETERS, int flags) /* {{{ */ +static void get_declared_class_impl(INTERNAL_FUNCTION_PARAMETERS, int flags) /* {{{ */ { zend_string *key; zval *zv; diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index b03e95cc5de35..c259a71ae25fd 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -87,7 +87,7 @@ static inline zend_class_entry *i_get_exception_base(zend_object *object) /* {{{ } /* }}} */ -ZEND_API zend_class_entry *zend_get_exception_base(zend_object *object) /* {{{ */ +ZEND_API zend_never_inline zend_class_entry *zend_get_exception_base(zend_object *object) /* {{{ */ { return i_get_exception_base(object); } @@ -403,6 +403,11 @@ ZEND_METHOD(ErrorException, __construct) #define GET_PROPERTY_SILENT(object, id) \ zend_read_property_ex(i_get_exception_base(Z_OBJ_P(object)), Z_OBJ_P(object), ZSTR_KNOWN(id), 1, &rv) +#define GET_PROPERTY_OUTLINE(object, id) \ + zend_read_property_ex(zend_get_exception_base(Z_OBJ_P(object)), Z_OBJ_P(object), ZSTR_KNOWN(id), 0, &rv) +#define GET_PROPERTY_SILENT_OUTLINE(object, id) \ + zend_read_property_ex(zend_get_exception_base(Z_OBJ_P(object)), Z_OBJ_P(object), ZSTR_KNOWN(id), 1, &rv) + /* {{{ Get the file in which the exception occurred */ ZEND_METHOD(Exception, getFile) { @@ -900,9 +905,9 @@ ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *ex, int severit ce_exception = ex->ce; EG(exception) = NULL; if (ce_exception == zend_ce_parse_error || ce_exception == zend_ce_compile_error) { - zend_string *message = zval_get_string(GET_PROPERTY(&exception, ZEND_STR_MESSAGE)); - zend_string *file = zval_get_string(GET_PROPERTY_SILENT(&exception, ZEND_STR_FILE)); - zend_long line = zval_get_long(GET_PROPERTY_SILENT(&exception, ZEND_STR_LINE)); + zend_string *message = zval_get_string(GET_PROPERTY_OUTLINE(&exception, ZEND_STR_MESSAGE)); + zend_string *file = zval_get_string(GET_PROPERTY_SILENT_OUTLINE(&exception, ZEND_STR_FILE)); + zend_long line = zval_get_long(GET_PROPERTY_SILENT_OUTLINE(&exception, ZEND_STR_LINE)); int type = (ce_exception == zend_ce_parse_error ? E_PARSE : E_COMPILE_ERROR) | E_DONT_BAIL; zend_observer_error_notify(type, file, line, message); @@ -931,8 +936,8 @@ ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *ex, int severit ZVAL_OBJ(&zv, EG(exception)); /* do the best we can to inform about the inner exception */ if (instanceof_function(ce_exception, zend_ce_exception) || instanceof_function(ce_exception, zend_ce_error)) { - file = zval_get_string(GET_PROPERTY_SILENT(&zv, ZEND_STR_FILE)); - line = zval_get_long(GET_PROPERTY_SILENT(&zv, ZEND_STR_LINE)); + file = zval_get_string(GET_PROPERTY_SILENT_OUTLINE(&zv, ZEND_STR_FILE)); + line = zval_get_long(GET_PROPERTY_SILENT_OUTLINE(&zv, ZEND_STR_LINE)); } zend_error_va(E_WARNING, (file && ZSTR_LEN(file) > 0) ? file : NULL, line, @@ -944,9 +949,9 @@ ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *ex, int severit } } - str = zval_get_string(GET_PROPERTY_SILENT(&exception, ZEND_STR_STRING)); - file = zval_get_string(GET_PROPERTY_SILENT(&exception, ZEND_STR_FILE)); - line = zval_get_long(GET_PROPERTY_SILENT(&exception, ZEND_STR_LINE)); + str = zval_get_string(GET_PROPERTY_SILENT_OUTLINE(&exception, ZEND_STR_STRING)); + file = zval_get_string(GET_PROPERTY_SILENT_OUTLINE(&exception, ZEND_STR_FILE)); + line = zval_get_long(GET_PROPERTY_SILENT_OUTLINE(&exception, ZEND_STR_LINE)); zend_error_va(severity | E_DONT_BAIL, (file && ZSTR_LEN(file) > 0) ? file : NULL, line, diff --git a/Zend/zend_string.c b/Zend/zend_string.c index ba39b4f39c1f8..0c9f96c51967e 100644 --- a/Zend/zend_string.c +++ b/Zend/zend_string.c @@ -396,6 +396,8 @@ ZEND_API bool ZEND_FASTCALL I_REPLACE_SONAME_FNNAME_ZU(NONE,zend_string_equal_va { return !memcmp(ZSTR_VAL(s1), ZSTR_VAL(s2), ZSTR_LEN(s1)); } +#else +ZEND_API extern inline bool zend_string_equal_val(const zend_string *s1, const zend_string *s2); #endif #if defined(__GNUC__) && defined(__i386__) @@ -548,3 +550,18 @@ ZEND_API void zend_string_release_ex_outline(zend_string *s, bool persistent) { zend_string_release_ex(s, persistent); } + +ZEND_API extern inline uint32_t zend_string_addref(zend_string *s); +ZEND_API extern inline zend_string *zend_string_alloc(size_t len, bool persistent); +ZEND_API extern inline zend_string *zend_string_copy(zend_string *s); +ZEND_API extern inline uint32_t zend_string_delref(zend_string *s); +ZEND_API extern inline zend_string *zend_string_dup(zend_string *s, bool persistent); +ZEND_API extern inline bool zend_string_equals(const zend_string *s1, const zend_string *s2); +ZEND_API extern inline bool zend_string_equal_content(const zend_string *s1, const zend_string *s2); +ZEND_API extern inline bool zend_string_equals_cstr(const zend_string *s1, const char *s2, size_t s2_length); +ZEND_API extern inline void zend_string_forget_hash_val(zend_string *s); +ZEND_API extern inline zend_ulong zend_string_hash_val(zend_string *s); +ZEND_API extern inline zend_string *zend_string_init(const char *str, size_t len, bool persistent); +ZEND_API extern inline zend_string *zend_string_realloc(zend_string *s, size_t len, bool persistent); +ZEND_API extern inline uint32_t zend_string_refcount(const zend_string *s); +ZEND_API extern inline zend_string *zend_string_separate(zend_string *s, bool persistent); diff --git a/Zend/zend_string.h b/Zend/zend_string.h index c8d16f1ec5eea..984c306ce41e5 100644 --- a/Zend/zend_string.h +++ b/Zend/zend_string.h @@ -141,18 +141,19 @@ END_EXTERN_C() /*---*/ -static zend_always_inline zend_ulong zend_string_hash_val(zend_string *s) +BEGIN_EXTERN_C() +ZEND_API zend_always_inline zend_ulong zend_string_hash_val(zend_string *s) { return ZSTR_H(s) ? ZSTR_H(s) : zend_string_hash_func(s); } -static zend_always_inline void zend_string_forget_hash_val(zend_string *s) +ZEND_API zend_always_inline void zend_string_forget_hash_val(zend_string *s) { ZSTR_H(s) = 0; GC_DEL_FLAGS(s, IS_STR_VALID_UTF8); } -static zend_always_inline uint32_t zend_string_refcount(const zend_string *s) +ZEND_API zend_always_inline uint32_t zend_string_refcount(const zend_string *s) { if (!ZSTR_IS_INTERNED(s)) { return GC_REFCOUNT(s); @@ -160,7 +161,7 @@ static zend_always_inline uint32_t zend_string_refcount(const zend_string *s) return 1; } -static zend_always_inline uint32_t zend_string_addref(zend_string *s) +ZEND_API zend_always_inline uint32_t zend_string_addref(zend_string *s) { if (!ZSTR_IS_INTERNED(s)) { return GC_ADDREF(s); @@ -168,7 +169,7 @@ static zend_always_inline uint32_t zend_string_addref(zend_string *s) return 1; } -static zend_always_inline uint32_t zend_string_delref(zend_string *s) +ZEND_API zend_always_inline uint32_t zend_string_delref(zend_string *s) { if (!ZSTR_IS_INTERNED(s)) { return GC_DELREF(s); @@ -176,7 +177,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, bool persistent) +ZEND_API 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); @@ -187,6 +188,16 @@ static zend_always_inline zend_string *zend_string_alloc(size_t len, bool persis return ret; } +ZEND_API zend_always_inline zend_string *zend_string_init(const char *str, size_t len, bool persistent) +{ + zend_string *ret = zend_string_alloc(len, persistent); + + memcpy(ZSTR_VAL(ret), str, len); + ZSTR_VAL(ret)[len] = '\0'; + return ret; +} +END_EXTERN_C() + 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); @@ -198,15 +209,6 @@ 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, bool persistent) -{ - zend_string *ret = zend_string_alloc(len, persistent); - - memcpy(ZSTR_VAL(ret), str, len); - ZSTR_VAL(ret)[len] = '\0'; - return ret; -} - static zend_always_inline zend_string *zend_string_init_fast(const char *str, size_t len) { if (len > 1) { @@ -218,7 +220,8 @@ static zend_always_inline zend_string *zend_string_init_fast(const char *str, si } } -static zend_always_inline zend_string *zend_string_copy(zend_string *s) +BEGIN_EXTERN_C() +ZEND_API inline zend_string *zend_string_copy(zend_string *s) { if (!ZSTR_IS_INTERNED(s)) { GC_ADDREF(s); @@ -226,7 +229,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, bool persistent) +ZEND_API zend_always_inline zend_string *zend_string_dup(zend_string *s, bool persistent) { if (ZSTR_IS_INTERNED(s)) { return s; @@ -235,7 +238,7 @@ static zend_always_inline zend_string *zend_string_dup(zend_string *s, bool pers } } -static zend_always_inline zend_string *zend_string_separate(zend_string *s, bool persistent) +ZEND_API zend_always_inline zend_string *zend_string_separate(zend_string *s, bool persistent) { if (ZSTR_IS_INTERNED(s) || GC_REFCOUNT(s) > 1) { if (!ZSTR_IS_INTERNED(s)) { @@ -248,7 +251,7 @@ static zend_always_inline zend_string *zend_string_separate(zend_string *s, bool return s; } -static zend_always_inline zend_string *zend_string_realloc(zend_string *s, size_t len, bool persistent) +ZEND_API zend_always_inline zend_string *zend_string_realloc(zend_string *s, size_t len, bool persistent) { zend_string *ret; @@ -267,6 +270,7 @@ static zend_always_inline zend_string *zend_string_realloc(zend_string *s, size_ } return ret; } +END_EXTERN_C() static zend_always_inline zend_string *zend_string_extend(zend_string *s, size_t len, bool persistent) { @@ -370,31 +374,31 @@ static zend_always_inline void zend_string_release_ex(zend_string *s, bool persi } } -static zend_always_inline bool zend_string_equals_cstr(const zend_string *s1, const char *s2, size_t s2_length) +BEGIN_EXTERN_C() +ZEND_API zend_always_inline bool zend_string_equals_cstr(const zend_string *s1, const char *s2, size_t s2_length) { return ZSTR_LEN(s1) == s2_length && !memcmp(ZSTR_VAL(s1), s2, s2_length); } #if defined(__GNUC__) && (defined(__i386__) || (defined(__x86_64__) && !defined(__ILP32__))) -BEGIN_EXTERN_C() ZEND_API bool ZEND_FASTCALL zend_string_equal_val(const zend_string *s1, const zend_string *s2); -END_EXTERN_C() #else -static zend_always_inline bool zend_string_equal_val(const zend_string *s1, const zend_string *s2) +ZEND_API zend_always_inline bool zend_string_equal_val(const zend_string *s1, const zend_string *s2) { return !memcmp(ZSTR_VAL(s1), ZSTR_VAL(s2), ZSTR_LEN(s1)); } #endif -static zend_always_inline bool zend_string_equal_content(const zend_string *s1, const zend_string *s2) +ZEND_API zend_always_inline bool zend_string_equal_content(const zend_string *s1, const zend_string *s2) { return ZSTR_LEN(s1) == ZSTR_LEN(s2) && zend_string_equal_val(s1, s2); } -static zend_always_inline bool zend_string_equals(const zend_string *s1, const zend_string *s2) +ZEND_API zend_always_inline bool zend_string_equals(const zend_string *s1, const zend_string *s2) { return s1 == s2 || zend_string_equal_content(s1, s2); } +END_EXTERN_C() #define zend_string_equals_ci(s1, s2) \ (ZSTR_LEN(s1) == ZSTR_LEN(s2) && !zend_binary_strcasecmp(ZSTR_VAL(s1), ZSTR_LEN(s1), ZSTR_VAL(s2), ZSTR_LEN(s2))) diff --git a/Zend/zend_types.h b/Zend/zend_types.h index dbf74b2ac6def..69df452025e14 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -1317,17 +1317,17 @@ BEGIN_EXTERN_C() ZEND_API zend_always_inline uint32_t zend_gc_refcount(const zend_refcounted_h *p) { return p->refcount; } -END_EXTERN_C() -static zend_always_inline uint32_t zend_gc_set_refcount(zend_refcounted_h *p, uint32_t rc) { +ZEND_API zend_always_inline uint32_t zend_gc_set_refcount(zend_refcounted_h *p, uint32_t rc) { p->refcount = rc; return p->refcount; } -static zend_always_inline uint32_t zend_gc_addref(zend_refcounted_h *p) { +ZEND_API zend_always_inline uint32_t zend_gc_addref(zend_refcounted_h *p) { ZEND_RC_MOD_CHECK(p); return ++(p->refcount); } +END_EXTERN_C() static zend_always_inline void zend_gc_try_addref(zend_refcounted_h *p) { if (!(p->u.type_info & GC_IMMUTABLE)) { diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 26cb30ee27fd1..add72c5ea0302 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -220,7 +220,7 @@ static ZEND_FUNCTION(accel_chdir) ZCG(cwd_check) = true; } -static inline zend_string* accel_getcwd(void) +static zend_string* accel_getcwd(void) { if (ZCG(cwd)) { return ZCG(cwd); @@ -598,7 +598,7 @@ static zend_always_inline zend_string *accel_find_interned_string_ex(zend_ulong 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); + zend_ulong h = zend_inline_hash_func(str, size); zend_string *ret = accel_find_interned_string_ex(h, str, size); if (!ret) { @@ -1102,7 +1102,7 @@ accel_time_t zend_get_file_handle_timestamp(zend_file_handle *file_handle, size_ return statbuf.st_mtime; } -static inline int do_validate_timestamps(zend_persistent_script *persistent_script, zend_file_handle *file_handle) +static int do_validate_timestamps(zend_persistent_script *persistent_script, zend_file_handle *file_handle) { zend_file_handle ps_handle; zend_string *full_path_ptr = NULL; diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 7f78369b10173..c3df612325da5 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -484,7 +484,7 @@ PHP_METHOD(PDOStatement, execute) } /* }}} */ -static inline void fetch_value(pdo_stmt_t *stmt, zval *dest, int colno, enum pdo_param_type *type_override) /* {{{ */ +static void fetch_value(pdo_stmt_t *stmt, zval *dest, int colno, enum pdo_param_type *type_override) /* {{{ */ { if (colno < 0) { zend_value_error("Column index must be greater than or equal to 0"); diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 6196f598455ae..d2e29525a5f4a 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -894,7 +894,7 @@ static void sxe_dimension_delete(zend_object *object, zval *offset) } /* }}} */ -static inline zend_string *sxe_xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int inLine) /* {{{ */ +static zend_string *sxe_xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int inLine) /* {{{ */ { xmlChar *tmp = xmlNodeListGetString(doc, list, inLine); zend_string *res; @@ -1389,7 +1389,7 @@ PHP_METHOD(SimpleXMLElement, asXML) #define SXE_NS_PREFIX(ns) (ns->prefix ? (char*)ns->prefix : "") -static inline void sxe_add_namespace_name_raw(zval *return_value, const char *prefix, const char *href) +static void sxe_add_namespace_name_raw(zval *return_value, const char *prefix, const char *href) { zend_string *key = zend_string_init(prefix, strlen(prefix), 0); zval zv; diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index ebf97b52dcc82..c2d29f3aa743d 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -317,7 +317,7 @@ static zend_result spl_filesystem_file_open(spl_filesystem_object *intern, bool intern->type = SPL_FS_FILE; php_stat(intern->file_name, FS_IS_DIR, &tmp); - if (UNEXPECTED(Z_TYPE(tmp) == IS_TRUE)) { + if (Z_TYPE(tmp) == IS_TRUE) { zend_string_release_outline(intern->u.file.open_mode); intern->u.file.open_mode = NULL; intern->file_name = NULL; diff --git a/ext/standard/url_scanner_ex.re b/ext/standard/url_scanner_ex.re index 1b8f36c384a0a..fe7082e84858a 100644 --- a/ext/standard/url_scanner_ex.re +++ b/ext/standard/url_scanner_ex.re @@ -182,7 +182,7 @@ alphadash = ([a-zA-Z] | "-"); #define YYLIMIT q #define YYMARKER r -static inline void append_modified_url(smart_str *url, smart_str *dest, smart_str *url_app, const char *separator, int type) +static void append_modified_url(smart_str *url, smart_str *dest, smart_str *url_app, const char *separator, int type) { php_url *url_parts; @@ -485,7 +485,7 @@ static inline void handle_arg(STD_PARA) } } -static inline void handle_val(STD_PARA, char quotes, char type) +static void handle_val(STD_PARA, char quotes, char type) { smart_str_setl(&ctx->val, start + quotes, YYCURSOR - start - quotes * 2); if (ctx->tag_type == TAG_FORM && ctx->attr_type == ATTR_ACTION) { @@ -728,7 +728,7 @@ static void php_url_scanner_output_handler(char *output, size_t output_len, char php_url_scanner_session_handler_impl(output, output_len, handled_output, handled_output_len, mode, 0); } -static inline int php_url_scanner_add_var_impl(const char *name, size_t name_len, const char *value, size_t value_len, int encode, int type) +static int php_url_scanner_add_var_impl(const char *name, size_t name_len, const char *value, size_t value_len, int encode, int type) { smart_str sname = {0}; smart_str svalue = {0}; @@ -836,7 +836,7 @@ PHPAPI int php_url_scanner_reset_vars(void) } -static inline int php_url_scanner_reset_var_impl(zend_string *name, int encode, int type) +static int php_url_scanner_reset_var_impl(zend_string *name, int encode, int type) { char *start, *end, *limit; size_t separator_len; diff --git a/ext/standard/var.c b/ext/standard/var.c index cff2069cd364d..21a590757a0ac 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -783,7 +783,7 @@ static inline void php_var_serialize_string(smart_str *buf, char *str, size_t le } /* }}} */ -static inline bool php_var_serialize_class_name(smart_str *buf, zval *struc) /* {{{ */ +static bool php_var_serialize_class_name(smart_str *buf, zval *struc) /* {{{ */ { char b[32]; PHP_CLASS_ATTRIBUTES; diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 6528c6f2c2fd3..bc6791040808d 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -1017,7 +1017,7 @@ static void phpdbg_welcome(bool cleaning) /* {{{ */ } } /* }}} */ -static inline void phpdbg_sigint_handler(int signo) /* {{{ */ +static void phpdbg_sigint_handler(int signo) /* {{{ */ { if (!(PHPDBG_G(flags) & PHPDBG_IS_INTERACTIVE)) { /* set signalled only when not interactive */ diff --git a/sapi/phpdbg/phpdbg_bp.c b/sapi/phpdbg/phpdbg_bp.c index 90f8ed7bb1295..07cae0b096bb7 100644 --- a/sapi/phpdbg/phpdbg_bp.c +++ b/sapi/phpdbg/phpdbg_bp.c @@ -32,7 +32,7 @@ static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_symbol(zend_function*); static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_method(zend_op_array*); static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_opline(phpdbg_opline_ptr_t); static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_opcode(uint8_t); -static inline phpdbg_breakbase_t *phpdbg_find_conditional_breakpoint(zend_execute_data *execute_data); /* }}} */ +static phpdbg_breakbase_t *phpdbg_find_conditional_breakpoint(zend_execute_data *execute_data); /* }}} */ /* * Note: @@ -823,7 +823,7 @@ PHPDBG_API void phpdbg_set_breakpoint_opline_ex(phpdbg_opline_ptr_t opline) /* { } } /* }}} */ -static inline void phpdbg_create_conditional_break(phpdbg_breakcond_t *brake, const phpdbg_param_t *param, const char *expr, size_t expr_len, zend_ulong hash) /* {{{ */ +static void phpdbg_create_conditional_break(phpdbg_breakcond_t *brake, const phpdbg_param_t *param, const char *expr, size_t expr_len, zend_ulong hash) /* {{{ */ { phpdbg_breakcond_t new_break; uint32_t cops = CG(compiler_options); @@ -1092,7 +1092,7 @@ static inline bool phpdbg_find_breakpoint_param(phpdbg_param_t *param, zend_exec return 0; } /* }}} */ -static inline phpdbg_breakbase_t *phpdbg_find_conditional_breakpoint(zend_execute_data *execute_data) /* {{{ */ +static phpdbg_breakbase_t *phpdbg_find_conditional_breakpoint(zend_execute_data *execute_data) /* {{{ */ { phpdbg_breakcond_t *bp; int breakpoint = FAILURE; diff --git a/sapi/phpdbg/phpdbg_frame.c b/sapi/phpdbg/phpdbg_frame.c index efb35e5cdf503..60b2a79adcbfc 100644 --- a/sapi/phpdbg/phpdbg_frame.c +++ b/sapi/phpdbg/phpdbg_frame.c @@ -25,7 +25,7 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg) -static inline void phpdbg_append_individual_arg(smart_str *s, uint32_t i, zend_function *func, zval *arg) { +static void phpdbg_append_individual_arg(smart_str *s, uint32_t i, zend_function *func, zval *arg) { const zend_arg_info *arginfo = func->common.arg_info; char *arg_name = NULL; diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index b242e5345a180..9d82bd6b28189 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -91,7 +91,7 @@ const phpdbg_command_t phpdbg_prompt_commands[] = { PHPDBG_END_COMMAND }; /* }}} */ -static inline int phpdbg_call_register(phpdbg_param_t *stack) /* {{{ */ +static int phpdbg_call_register(phpdbg_param_t *stack) /* {{{ */ { phpdbg_param_t *name = NULL; From 323eb91a150d39aab0a857aaa139ea9116d174e2 Mon Sep 17 00:00:00 2001 From: Levi Morrison Date: Tue, 23 Jul 2024 17:36:15 -0600 Subject: [PATCH 03/12] remove more inlines from functions which don't inline --- ext/hash/hash_gost.c | 2 +- ext/hash/hash_snefru.c | 2 +- ext/hash/hash_tiger.c | 2 +- ext/json/json_encoder.c | 2 +- ext/random/engine_mt19937.c | 2 +- ext/standard/formatted_print.c | 14 +++++++------- ext/standard/html.c | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ext/hash/hash_gost.c b/ext/hash/hash_gost.c index 2ad6948a9a676..51d5bebca7160 100644 --- a/ext/hash/hash_gost.c +++ b/ext/hash/hash_gost.c @@ -203,7 +203,7 @@ AA(v, l, r); \ } -static inline void Gost(PHP_GOST_CTX *context, uint32_t data[8]) +static void Gost(PHP_GOST_CTX *context, uint32_t data[8]) { int i; uint32_t l, r, t, key[8], u[8], v[8], w[8], s[8], *h = context->state, *m = data; diff --git a/ext/hash/hash_snefru.c b/ext/hash/hash_snefru.c index c1dbc3ae57a6c..a50b2919acc93 100644 --- a/ext/hash/hash_snefru.c +++ b/ext/hash/hash_snefru.c @@ -37,7 +37,7 @@ void ph(uint32_t h[16]) } #endif -static inline void Snefru(uint32_t input[16]) +static void Snefru(uint32_t input[16]) { static const int shifts[4] = {16, 8, 16, 24}; int b, index, rshift, lshift; diff --git a/ext/hash/hash_tiger.c b/ext/hash/hash_tiger.c index 841693a67dd14..b4a9b381ed532 100644 --- a/ext/hash/hash_tiger.c +++ b/ext/hash/hash_tiger.c @@ -132,7 +132,7 @@ } /* }}} */ -static inline void TigerFinalize(PHP_TIGER_CTX *context) +static void TigerFinalize(PHP_TIGER_CTX *context) { context->passed += (uint64_t) context->length << 3; diff --git a/ext/json/json_encoder.c b/ext/json/json_encoder.c index 1e344cde436ff..29042bb4c8135 100644 --- a/ext/json/json_encoder.c +++ b/ext/json/json_encoder.c @@ -80,7 +80,7 @@ bool php_json_is_valid_double(double d) /* {{{ */ } /* }}} */ -static inline void php_json_encode_double(smart_str *buf, double d, int options) /* {{{ */ +static void php_json_encode_double(smart_str *buf, double d, int options) /* {{{ */ { size_t len; char num[ZEND_DOUBLE_MAX_LENGTH]; diff --git a/ext/random/engine_mt19937.c b/ext/random/engine_mt19937.c index 7c9d1741d81f1..81dd17f88baba 100644 --- a/ext/random/engine_mt19937.c +++ b/ext/random/engine_mt19937.c @@ -100,7 +100,7 @@ ZEND_STATIC_ASSERT( #define twist(m,u,v) (m ^ (mixBits(u,v) >> 1) ^ ((uint32_t)(-(int32_t)(loBit(v))) & 0x9908b0dfU)) #define twist_php(m,u,v) (m ^ (mixBits(u,v) >> 1) ^ ((uint32_t)(-(int32_t)(loBit(u))) & 0x9908b0dfU)) -static inline void mt19937_reload(php_random_status_state_mt19937 *state) +static void mt19937_reload(php_random_status_state_mt19937 *state) { uint32_t *p = state->state; diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c index ba0f73d9a9c22..5d2e3d2512042 100644 --- a/ext/standard/formatted_print.c +++ b/ext/standard/formatted_print.c @@ -45,7 +45,7 @@ static const char hexchars[] = "0123456789abcdef"; static const char HEXCHARS[] = "0123456789ABCDEF"; /* php_spintf_appendchar() {{{ */ -inline static void +static void php_sprintf_appendchar(zend_string **buffer, size_t *pos, char add) { if ((*pos + 1) >= ZSTR_LEN(*buffer)) { @@ -58,7 +58,7 @@ php_sprintf_appendchar(zend_string **buffer, size_t *pos, char add) /* }}} */ /* php_spintf_appendchar() {{{ */ -inline static void +static void php_sprintf_appendchars(zend_string **buffer, size_t *pos, char *add, size_t len) { if ((*pos + len) >= ZSTR_LEN(*buffer)) { @@ -77,7 +77,7 @@ php_sprintf_appendchars(zend_string **buffer, size_t *pos, char *add, size_t len /* }}} */ /* php_spintf_appendstring() {{{ */ -inline static void +static void php_sprintf_appendstring(zend_string **buffer, size_t *pos, char *add, size_t min_width, size_t max_width, char padding, size_t alignment, size_t len, bool neg, int expprec, int always_sign) @@ -134,7 +134,7 @@ php_sprintf_appendstring(zend_string **buffer, size_t *pos, char *add, /* }}} */ /* php_spintf_appendint() {{{ */ -inline static void +static void php_sprintf_appendint(zend_string **buffer, size_t *pos, zend_long number, size_t width, char padding, size_t alignment, int always_sign) @@ -178,7 +178,7 @@ php_sprintf_appendint(zend_string **buffer, size_t *pos, zend_long number, /* }}} */ /* php_spintf_appenduint() {{{ */ -inline static void +static void php_sprintf_appenduint(zend_string **buffer, size_t *pos, zend_ulong number, size_t width, char padding, size_t alignment) @@ -210,7 +210,7 @@ php_sprintf_appenduint(zend_string **buffer, size_t *pos, /* }}} */ /* php_spintf_appenddouble() {{{ */ -inline static void +static void php_sprintf_appenddouble(zend_string **buffer, size_t *pos, double number, size_t width, char padding, @@ -317,7 +317,7 @@ php_sprintf_appenddouble(zend_string **buffer, size_t *pos, /* }}} */ /* php_spintf_appendd2n() {{{ */ -inline static void +static void php_sprintf_append2n(zend_string **buffer, size_t *pos, zend_long number, size_t width, char padding, size_t alignment, int n, const char *chartable, int expprec) diff --git a/ext/standard/html.c b/ext/standard/html.c index 92cee224e068b..4d599ccc6d1b5 100644 --- a/ext/standard/html.c +++ b/ext/standard/html.c @@ -86,7 +86,7 @@ static char *get_default_charset(void) { /* }}} */ /* {{{ get_next_char */ -static inline unsigned int get_next_char( +static unsigned int get_next_char( enum entity_charset charset, const unsigned char *str, size_t str_len, @@ -451,7 +451,7 @@ static inline unsigned char unimap_bsearch(const uni_to_enc *table, unsigned cod /* }}} */ /* {{{ map_from_unicode */ -static inline int map_from_unicode(unsigned code, enum entity_charset charset, unsigned *res) +static int map_from_unicode(unsigned code, enum entity_charset charset, unsigned *res) { unsigned char found; const uni_to_enc *table; From 097274b4baf11c55f086d12111378a7707c54ac9 Mon Sep 17 00:00:00 2001 From: Levi Morrison Date: Mon, 29 Jul 2024 10:39:10 -0600 Subject: [PATCH 04/12] Add more ZEND_API string functions --- Zend/zend_string.c | 3 +++ Zend/zend_string.h | 42 +++++++++++++++++++++--------------------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/Zend/zend_string.c b/Zend/zend_string.c index 0c9f96c51967e..c7839147f6bb7 100644 --- a/Zend/zend_string.c +++ b/Zend/zend_string.c @@ -562,6 +562,9 @@ ZEND_API extern inline bool zend_string_equals_cstr(const zend_string *s1, const ZEND_API extern inline void zend_string_forget_hash_val(zend_string *s); ZEND_API extern inline zend_ulong zend_string_hash_val(zend_string *s); ZEND_API extern inline zend_string *zend_string_init(const char *str, size_t len, bool persistent); +ZEND_API extern inline zend_string *zend_string_init_fast(const char *str, size_t len); ZEND_API extern inline zend_string *zend_string_realloc(zend_string *s, size_t len, bool persistent); ZEND_API extern inline uint32_t zend_string_refcount(const zend_string *s); +ZEND_API extern inline zend_string *zend_string_safe_alloc(size_t n, size_t m, size_t l, bool persistent); +ZEND_API extern inline zend_string *zend_string_safe_realloc(zend_string *s, size_t n, size_t m, size_t l, bool persistent); ZEND_API extern inline zend_string *zend_string_separate(zend_string *s, bool persistent); diff --git a/Zend/zend_string.h b/Zend/zend_string.h index 984c306ce41e5..4f803bf256229 100644 --- a/Zend/zend_string.h +++ b/Zend/zend_string.h @@ -196,9 +196,8 @@ ZEND_API zend_always_inline zend_string *zend_string_init(const char *str, size_ ZSTR_VAL(ret)[len] = '\0'; return ret; } -END_EXTERN_C() -static zend_always_inline zend_string *zend_string_safe_alloc(size_t n, size_t m, size_t l, bool persistent) +ZEND_API 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); @@ -209,7 +208,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_fast(const char *str, size_t len) +ZEND_API zend_always_inline zend_string *zend_string_init_fast(const char *str, size_t len) { if (len > 1) { return zend_string_init(str, len, 0); @@ -220,7 +219,6 @@ static zend_always_inline zend_string *zend_string_init_fast(const char *str, si } } -BEGIN_EXTERN_C() ZEND_API inline zend_string *zend_string_copy(zend_string *s) { if (!ZSTR_IS_INTERNED(s)) { @@ -270,34 +268,33 @@ ZEND_API zend_always_inline zend_string *zend_string_realloc(zend_string *s, siz } return ret; } -END_EXTERN_C() -static zend_always_inline zend_string *zend_string_extend(zend_string *s, size_t len, bool persistent) +ZEND_API 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; - ZEND_ASSERT(len >= ZSTR_LEN(s)); if (!ZSTR_IS_INTERNED(s)) { - if (EXPECTED(GC_REFCOUNT(s) == 1)) { - ret = (zend_string *)perealloc(s, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(len)), persistent); - ZSTR_LEN(ret) = len; + if (GC_REFCOUNT(s) == 1) { + ret = (zend_string *)safe_perealloc(s, n, m, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(l)), persistent); + ZSTR_LEN(ret) = (n * m) + l; zend_string_forget_hash_val(ret); return ret; } } - ret = zend_string_alloc(len, persistent); - memcpy(ZSTR_VAL(ret), ZSTR_VAL(s), ZSTR_LEN(s) + 1); + ret = zend_string_safe_alloc(n, m, l, persistent); + memcpy(ZSTR_VAL(ret), ZSTR_VAL(s), MIN((n * m) + l, ZSTR_LEN(s)) + 1); if (!ZSTR_IS_INTERNED(s)) { GC_DELREF(s); } return ret; } +END_EXTERN_C() -static zend_always_inline zend_string *zend_string_truncate(zend_string *s, size_t len, bool persistent) +static zend_always_inline zend_string *zend_string_extend(zend_string *s, size_t len, bool persistent) { zend_string *ret; - ZEND_ASSERT(len <= ZSTR_LEN(s)); + ZEND_ASSERT(len >= ZSTR_LEN(s)); if (!ZSTR_IS_INTERNED(s)) { if (EXPECTED(GC_REFCOUNT(s) == 1)) { ret = (zend_string *)perealloc(s, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(len)), persistent); @@ -307,33 +304,35 @@ static zend_always_inline zend_string *zend_string_truncate(zend_string *s, size } } ret = zend_string_alloc(len, persistent); - memcpy(ZSTR_VAL(ret), ZSTR_VAL(s), len + 1); + memcpy(ZSTR_VAL(ret), ZSTR_VAL(s), ZSTR_LEN(s) + 1); if (!ZSTR_IS_INTERNED(s)) { GC_DELREF(s); } return ret; } -static zend_always_inline zend_string *zend_string_safe_realloc(zend_string *s, size_t n, size_t m, size_t l, bool persistent) +static zend_always_inline zend_string *zend_string_truncate(zend_string *s, size_t len, bool persistent) { zend_string *ret; + ZEND_ASSERT(len <= ZSTR_LEN(s)); if (!ZSTR_IS_INTERNED(s)) { - if (GC_REFCOUNT(s) == 1) { - ret = (zend_string *)safe_perealloc(s, n, m, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(l)), persistent); - ZSTR_LEN(ret) = (n * m) + l; + if (EXPECTED(GC_REFCOUNT(s) == 1)) { + ret = (zend_string *)perealloc(s, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(len)), persistent); + ZSTR_LEN(ret) = len; zend_string_forget_hash_val(ret); return ret; } } - ret = zend_string_safe_alloc(n, m, l, persistent); - memcpy(ZSTR_VAL(ret), ZSTR_VAL(s), MIN((n * m) + l, ZSTR_LEN(s)) + 1); + ret = zend_string_alloc(len, persistent); + memcpy(ZSTR_VAL(ret), ZSTR_VAL(s), len + 1); if (!ZSTR_IS_INTERNED(s)) { GC_DELREF(s); } return ret; } +/* These functions have noinline variants */ static zend_always_inline void zend_string_free(zend_string *s) { if (!ZSTR_IS_INTERNED(s)) { @@ -373,6 +372,7 @@ static zend_always_inline void zend_string_release_ex(zend_string *s, bool persi } } } +/* }}} */ BEGIN_EXTERN_C() ZEND_API zend_always_inline bool zend_string_equals_cstr(const zend_string *s1, const char *s2, size_t s2_length) From fa7f28a4c11aecded2ae95aef12319a6329870d7 Mon Sep 17 00:00:00 2001 From: Levi Morrison Date: Mon, 29 Jul 2024 10:54:58 -0600 Subject: [PATCH 05/12] Rename _outline funcs to _noinline --- Zend/zend.c | 2 +- Zend/zend_API.c | 20 +++++----- Zend/zend_API.h | 2 +- Zend/zend_ast.c | 4 +- Zend/zend_compile.c | 10 ++--- Zend/zend_constants.c | 2 +- Zend/zend_exceptions.c | 14 +++---- Zend/zend_execute.c | 62 +++++++++++++++--------------- Zend/zend_execute_API.c | 4 +- Zend/zend_inheritance.c | 8 ++-- Zend/zend_ini.c | 4 +- Zend/zend_language_scanner.l | 2 +- Zend/zend_operators.c | 6 +-- Zend/zend_operators.h | 2 +- Zend/zend_smart_str.c | 2 +- Zend/zend_smart_str.h | 2 +- Zend/zend_string.c | 8 ++-- Zend/zend_string.h | 8 ++-- Zend/zend_vm_def.h | 12 +++--- Zend/zend_vm_execute.h | 52 ++++++++++++------------- ext/date/php_date.c | 6 +-- ext/dom/document.c | 2 +- ext/fileinfo/libmagic/apprentice.c | 2 +- ext/fileinfo/libmagic/softmagic.c | 6 +-- ext/iconv/iconv.c | 2 +- ext/json/json.c | 2 +- ext/mbstring/mbstring.c | 12 +++--- ext/opcache/ZendAccelerator.c | 6 +-- ext/opcache/jit/zend_jit_helpers.c | 14 +++---- ext/openssl/openssl.c | 12 +++--- ext/openssl/xp_ssl.c | 6 +-- ext/pcre/php_pcre.c | 14 +++---- ext/pdo/pdo_stmt.c | 18 ++++----- ext/pdo_sqlite/pdo_sqlite.c | 2 +- ext/phar/phar_object.c | 12 +++--- ext/phar/util.c | 4 +- ext/reflection/php_reflection.c | 16 ++++---- ext/session/mod_files.c | 2 +- ext/session/session.c | 10 ++--- ext/simplexml/simplexml.c | 2 +- ext/spl/spl_directory.c | 2 +- ext/standard/basic_functions.c | 2 +- ext/standard/exec.c | 4 +- ext/standard/file.c | 2 +- ext/standard/http.c | 2 +- ext/standard/http_fopen_wrapper.c | 2 +- ext/standard/incomplete_class.c | 4 +- ext/standard/info.c | 10 ++--- ext/standard/password.c | 6 +-- ext/standard/proc_open.c | 6 +-- ext/standard/streamsfuncs.c | 6 +-- ext/standard/string.c | 8 ++-- ext/standard/var.c | 2 +- ext/standard/var_unserializer.re | 32 +++++++-------- ext/xml/xml.c | 2 +- ext/zip/php_zip.c | 6 +-- ext/zlib/zlib.c | 8 ++-- main/main.c | 12 +++--- main/network.c | 4 +- main/streams/streams.c | 2 +- main/streams/transports.c | 2 +- sapi/cli/php_cli.c | 2 +- 62 files changed, 251 insertions(+), 251 deletions(-) diff --git a/Zend/zend.c b/Zend/zend.c index 886dc06b80f43..9f8dff5fed8ce 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -1573,7 +1573,7 @@ static ZEND_COLD void zend_error_va_list( { zend_string *message = zend_vstrpprintf(0, format, args); zend_error_zstr_at(orig_type, error_filename, error_lineno, message); - zend_string_release_outline(message); + zend_string_release_noinline(message); } static ZEND_COLD void get_filename_lineno(int type, zend_string **filename, uint32_t *lineno) { diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 49234ffa30187..e5b0ee2c9b333 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -104,7 +104,7 @@ ZEND_API ZEND_COLD void zend_wrong_property_read(zval *object, zval *property) zend_string *tmp_property_name; zend_string *property_name = zval_get_tmp_string(property, &tmp_property_name); zend_error(E_WARNING, "Attempt to read property \"%s\" on %s", ZSTR_VAL(property_name), zend_zval_value_name(object)); - zend_tmp_string_release_outline(tmp_property_name); + zend_tmp_string_release_noinline(tmp_property_name); } /* Argument parsing API -- andrei */ @@ -217,7 +217,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_none_error(void) /* zend_argument_count_error("%s() expects exactly 0 arguments, %d given", ZSTR_VAL(func_name), num_args); - zend_string_release_outline(func_name); + zend_string_release_noinline(func_name); } /* }}} */ @@ -235,7 +235,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_error(uint32_t num_args ); - zend_string_release_outline(func_name); + zend_string_release_noinline(func_name); } /* }}} */ @@ -405,7 +405,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_error_variadic(zend_class_en arg_name ? " ($" : "", arg_name ? arg_name : "", arg_name ? ")" : "", message ); efree(message); - zend_string_release_outline(func_name); + zend_string_release_noinline(func_name); } /* }}} */ @@ -510,9 +510,9 @@ static ZEND_COLD bool zend_null_arg_deprecated(const char *fallback_type, uint32 ZSTR_VAL(func_name), arg_num, arg_name ? " ($" : "", arg_name ? arg_name : "", arg_name ? ")" : "", type); - zend_string_release_outline(func_name); + zend_string_release_noinline(func_name); if (type_str) { - zend_string_release_outline(type_str); + zend_string_release_noinline(type_str); } return !EG(exception); } @@ -1225,7 +1225,7 @@ static zend_result zend_parse_va_args(uint32_t num_args, const char *type_spec, num_args ); - zend_string_release_outline(func_name); + zend_string_release_noinline(func_name); } return FAILURE; } @@ -1873,7 +1873,7 @@ ZEND_API zend_result object_init_with_constructor(zval *arg, zend_class_entry *c zend_hash_get_current_key(named_params, &arg_name, /* num_index */ NULL); ZEND_ASSERT(arg_name != NULL); zend_throw_error(NULL, "Unknown named parameter $%s", ZSTR_VAL(arg_name)); - zend_string_release_outline(arg_name); + zend_string_release_noinline(arg_name); /* Do not call destructor, free object, and set arg to IS_UNDEF */ zend_object_store_ctor_failed(obj); zval_ptr_dtor(arg); @@ -2619,7 +2619,7 @@ ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module, i lcname = zend_new_interned_string(lcname); if ((module_ptr = zend_hash_add_ptr(&module_registry, lcname, module)) == NULL) { zend_error(E_CORE_WARNING, "Module \"%s\" is already loaded", module->name); - zend_string_release_outline(lcname); + zend_string_release_noinline(lcname); return NULL; } module = module_ptr; @@ -2630,7 +2630,7 @@ ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module, i if (module->functions && zend_register_functions(NULL, module->functions, NULL, module_type)==FAILURE) { zend_hash_del(&module_registry, lcname); - zend_string_release_outline(lcname); + zend_string_release_noinline(lcname); EG(current_module) = NULL; zend_error(E_CORE_WARNING,"%s: Unable to register functions, unable to load", module->name); return NULL; diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 49b488c94e9ea..0531e472a8f05 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -900,7 +900,7 @@ static zend_always_inline zend_result zend_forbid_dynamic_call(void) zend_string *function_or_method_name = get_active_function_or_method_name(); zend_throw_error(NULL, "Cannot call %.*s() dynamically", (int) ZSTR_LEN(function_or_method_name), ZSTR_VAL(function_or_method_name)); - zend_string_release_outline(function_or_method_name); + zend_string_release_noinline(function_or_method_name); return FAILURE; } diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index 2acba4114bb68..db97edd96fc7d 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -1193,10 +1193,10 @@ ZEND_API void ZEND_FASTCALL zend_ast_destroy(zend_ast *ast) zend_ast_decl *decl = (zend_ast_decl *) ast; if (decl->name) { - zend_string_release_ex_outline(decl->name, 0); + zend_string_release_ex_noinline(decl->name, 0); } if (decl->doc_comment) { - zend_string_release_ex_outline(decl->doc_comment, 0); + zend_string_release_ex_noinline(decl->doc_comment, 0); } zend_ast_destroy(decl->child[0]); zend_ast_destroy(decl->child[1]); diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index b348af1b64512..6de5f624a84d8 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -4111,7 +4111,7 @@ static zend_result zend_compile_func_defined(znode *result, zend_ast_list *args) name = zval_get_string(zend_ast_get_zval(args->child[0])); if (zend_memrchr(ZSTR_VAL(name), '\\', ZSTR_LEN(name)) || zend_memrchr(ZSTR_VAL(name), ':', ZSTR_LEN(name))) { - zend_string_release_ex_outline(name, 0); + zend_string_release_ex_noinline(name, 0); return FAILURE; } @@ -4280,7 +4280,7 @@ static zend_result zend_compile_func_cufa(znode *result, zend_ast_list *args, ze opline = zend_emit_op(NULL, ZEND_SEND_ARRAY, &arg_node, &len_node); opline->extended_value = Z_LVAL_P(zv); zend_emit_op(result, ZEND_DO_FCALL, NULL, NULL); - zend_string_release_ex_outline(name, 0); + zend_string_release_ex_noinline(name, 0); return SUCCESS; } } @@ -7534,7 +7534,7 @@ static void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32 && (op_array->fn_flags & ZEND_ACC_RETURN_REFERENCE)) { zend_string *func_name = get_function_or_method_name((zend_function *) op_array); zend_error(E_DEPRECATED, "%s(): Returning by reference from a void function is deprecated", ZSTR_VAL(func_name)); - zend_string_release_outline(func_name); + zend_string_release_noinline(func_name); } } else { if (list->children == 0) { @@ -7670,7 +7670,7 @@ static void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32 "%s(): Optional parameter $%s declared before required parameter $%s " "is implicitly treated as a required parameter", ZSTR_VAL(func_name), ZSTR_VAL(name), ZSTR_VAL(zend_ast_get_str(required_param_ast->child[1]))); - zend_string_release_outline(func_name); + zend_string_release_noinline(func_name); } /* Regardless of whether we issue a deprecation, convert this parameter into @@ -10759,7 +10759,7 @@ static void zend_compile_class_const(znode *result, zend_ast *ast) /* {{{ */ zend_string *resolved_name = zend_resolve_class_name_ast(class_ast); if (zend_try_ct_eval_class_const(&result->u.constant, resolved_name, const_str)) { result->op_type = IS_CONST; - zend_string_release_ex_outline(resolved_name, 0); + zend_string_release_ex_noinline(resolved_name, 0); return; } zend_string_release_ex(resolved_name, 0); diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c index 1fc49bb03e90a..220f50a7eaa9b 100644 --- a/Zend/zend_constants.c +++ b/Zend/zend_constants.c @@ -573,7 +573,7 @@ ZEND_API zend_result zend_register_constant(zend_constant *c) || zend_hash_add_constant(EG(zend_constants), name, c) == NULL ) { zend_error(E_WARNING, "Constant %s already defined", ZSTR_VAL(name)); - zend_string_release_outline(c->name); + zend_string_release_noinline(c->name); if (!persistent) { zval_ptr_dtor_nogc(&c->value); } diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index c259a71ae25fd..8390a4939e002 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -849,7 +849,7 @@ ZEND_API ZEND_COLD zend_object *zend_throw_exception(zend_class_entry *exception zend_string *msg_str = message ? zend_string_init(message, strlen(message), 0) : NULL; zend_object *ex = zend_throw_exception_zstr(exception_ce, msg_str, code); if (msg_str) { - zend_string_release_outline(msg_str); + zend_string_release_noinline(msg_str); } return ex; } @@ -889,7 +889,7 @@ static void zend_error_va(int type, zend_string *file, uint32_t lineno, const ch zend_string *message = zend_vstrpprintf(0, format, args); zend_observer_error_notify(type, file, lineno, message); zend_error_cb(type, file, lineno, message); - zend_string_release_outline(message); + zend_string_release_noinline(message); va_end(args); } /* }}} */ @@ -913,8 +913,8 @@ ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *ex, int severit zend_observer_error_notify(type, file, line, message); zend_error_cb(type, file, line, message); - zend_string_release_ex_outline(file, 0); - zend_string_release_ex_outline(message, 0); + zend_string_release_ex_noinline(file, 0); + zend_string_release_ex_noinline(message, 0); } else if (instanceof_function(ce_exception, zend_ce_throwable)) { zval tmp; zend_string *str, *file = NULL; @@ -945,7 +945,7 @@ ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *ex, int severit ZSTR_VAL(Z_OBJCE(zv)->name), ZSTR_VAL(ce_exception->name)); if (file) { - zend_string_release_ex_outline(file, 0); + zend_string_release_ex_noinline(file, 0); } } @@ -957,8 +957,8 @@ ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *ex, int severit (file && ZSTR_LEN(file) > 0) ? file : NULL, line, "Uncaught %S\n thrown", str); - zend_string_release_ex_outline(str, 0); - zend_string_release_ex_outline(file, 0); + zend_string_release_ex_noinline(str, 0); + zend_string_release_ex_noinline(file, 0); } else if (ce_exception == &zend_ce_unwind_exit || ce_exception == &zend_ce_graceful_exit) { /* We successfully unwound, nothing more to do. * We still return FAILURE in this case, as further execution should still be aborted. */ diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index d3df18172f1cf..f8e50b9301eaa 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -606,7 +606,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_cannot_pass_by_reference(uint32_t arg ZSTR_VAL(func_name), arg_num, param_name ? " ($" : "", param_name ? param_name : "", param_name ? ")" : "" ); - zend_string_release_outline(func_name); + zend_string_release_noinline(func_name); } static zend_never_inline ZEND_COLD void zend_throw_auto_init_in_prop_error(zend_property_info *prop) { @@ -616,7 +616,7 @@ static zend_never_inline ZEND_COLD void zend_throw_auto_init_in_prop_error(zend_ ZSTR_VAL(prop->ce->name), zend_get_unmangled_property_name(prop->name), ZSTR_VAL(type_str) ); - zend_string_release_outline(type_str); + zend_string_release_noinline(type_str); } static zend_never_inline ZEND_COLD void zend_throw_auto_init_in_ref_error(zend_property_info *prop) { @@ -626,7 +626,7 @@ static zend_never_inline ZEND_COLD void zend_throw_auto_init_in_ref_error(zend_p ZSTR_VAL(prop->ce->name), zend_get_unmangled_property_name(prop->name), ZSTR_VAL(type_str) ); - zend_string_release_outline(type_str); + zend_string_release_noinline(type_str); } static zend_never_inline ZEND_COLD void zend_throw_access_uninit_prop_by_ref_error( @@ -665,7 +665,7 @@ static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_throw_non_object_erro ZSTR_VAL(property_name), zend_zval_value_name(object) ); } - zend_tmp_string_release_outline(tmp_property_name); + zend_tmp_string_release_noinline(tmp_property_name); if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_NULL(EX_VAR(opline->result.var)); @@ -718,7 +718,7 @@ ZEND_API ZEND_COLD void zend_verify_arg_error( "must be of type %s, %s given", ZSTR_VAL(need_msg), given_msg); } - zend_string_release_outline(need_msg); + zend_string_release_noinline(need_msg); } static bool zend_verify_weak_scalar_type_hint(uint32_t type_mask, zval *arg) @@ -834,7 +834,7 @@ ZEND_COLD zend_never_inline void zend_verify_class_constant_type_error(const zen zend_type_error("Cannot assign %s to class constant %s::%s of type %s", zend_zval_type_name(constant), ZSTR_VAL(c->ce->name), ZSTR_VAL(name), ZSTR_VAL(type_str)); - zend_string_release_outline(type_str); + zend_string_release_noinline(type_str); } ZEND_COLD zend_never_inline void zend_verify_property_type_error(const zend_property_info *info, const zval *property) @@ -852,7 +852,7 @@ ZEND_COLD zend_never_inline void zend_verify_property_type_error(const zend_prop ZSTR_VAL(info->ce->name), zend_get_unmangled_property_name(info->name), ZSTR_VAL(type_str)); - zend_string_release_outline(type_str); + zend_string_release_noinline(type_str); } ZEND_COLD zend_never_inline void zend_magic_get_property_type_inconsistency_error(const zend_property_info *info, const zval *property) @@ -869,7 +869,7 @@ ZEND_COLD zend_never_inline void zend_magic_get_property_type_inconsistency_erro ZSTR_VAL(info->ce->name), zend_get_unmangled_property_name(info->name), ZSTR_VAL(type_str)); - zend_string_release_outline(type_str); + zend_string_release_noinline(type_str); } ZEND_COLD void zend_match_unhandled_error(const zval *value) @@ -884,7 +884,7 @@ ZEND_COLD void zend_match_unhandled_error(const zval *value) zend_throw_exception_ex( zend_ce_unhandled_match_error, 0, "Unhandled match case %s", ZSTR_VAL(msg.s)); - smart_str_free_outline(&msg); + smart_str_free_noinline(&msg); } ZEND_API ZEND_COLD void ZEND_FASTCALL zend_readonly_property_modification_error( @@ -1409,7 +1409,7 @@ ZEND_API ZEND_COLD void zend_verify_return_error(const zend_function *zf, zval * zend_type_error("%s%s%s(): Return value must be of type %s, %s returned", fclass, fsep, fname, ZSTR_VAL(need_msg), given_msg); - zend_string_release_outline(need_msg); + zend_string_release_noinline(need_msg); } ZEND_API ZEND_COLD void zend_verify_never_error(const zend_function *zf) @@ -1419,7 +1419,7 @@ ZEND_API ZEND_COLD void zend_verify_never_error(const zend_function *zf) zend_type_error("%s(): never-returning %s must not implicitly return", ZSTR_VAL(func_name), zf->common.scope ? "method" : "function"); - zend_string_release_outline(func_name); + zend_string_release_noinline(func_name); } #if ZEND_DEBUG @@ -1833,8 +1833,8 @@ ZEND_COLD static zend_result ZEND_FASTCALL get_deprecation_suffix_from_attribute out: - zend_string_release_outline(since); - zend_string_release_outline(message); + zend_string_release_noinline(since); + zend_string_release_noinline(message); zval_ptr_dtor(&obj); return result; @@ -1863,7 +1863,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_deprecated_function(const zend_functi ); } - zend_string_release_outline(message_suffix); + zend_string_release_noinline(message_suffix); } ZEND_API ZEND_COLD void ZEND_FASTCALL zend_deprecated_class_constant(const zend_class_constant *c, const zend_string *constant_name) @@ -1884,7 +1884,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_deprecated_class_constant(const zend_ message_suffix ); - zend_string_release_outline(message_suffix); + zend_string_release_noinline(message_suffix); } ZEND_API ZEND_COLD void ZEND_FASTCALL zend_false_to_array_deprecated(void) @@ -1998,7 +1998,7 @@ static zend_never_inline void zend_assign_to_string_offset(zval *str, zval *dim, GC_ADDREF(s); zend_error(E_WARNING, "Only the first byte will be assigned to the string offset"); if (UNEXPECTED(GC_DELREF(s) == 0)) { - zend_string_efree_outline(s); + zend_string_efree_noinline(s); if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_NULL(EX_VAR(opline->result.var)); } @@ -2052,7 +2052,7 @@ static ZEND_COLD zend_long zend_throw_incdec_ref_error( ZSTR_VAL(error_prop->ce->name), zend_get_unmangled_property_name(error_prop->name), ZSTR_VAL(type_str)); - zend_string_release_outline(type_str); + zend_string_release_noinline(type_str); return ZEND_LONG_MAX; } else { zend_type_error( @@ -2060,7 +2060,7 @@ static ZEND_COLD zend_long zend_throw_incdec_ref_error( ZSTR_VAL(error_prop->ce->name), zend_get_unmangled_property_name(error_prop->name), ZSTR_VAL(type_str)); - zend_string_release_outline(type_str); + zend_string_release_noinline(type_str); return ZEND_LONG_MIN; } } @@ -2072,14 +2072,14 @@ static ZEND_COLD zend_long zend_throw_incdec_prop_error(zend_property_info *prop ZSTR_VAL(prop->ce->name), zend_get_unmangled_property_name(prop->name), ZSTR_VAL(type_str)); - zend_string_release_outline(type_str); + zend_string_release_noinline(type_str); return ZEND_LONG_MAX; } else { zend_type_error("Cannot decrement property %s::$%s of type %s past its minimal value", ZSTR_VAL(prop->ce->name), zend_get_unmangled_property_name(prop->name), ZSTR_VAL(type_str)); - zend_string_release_outline(type_str); + zend_string_release_noinline(type_str); return ZEND_LONG_MIN; } } @@ -2403,7 +2403,7 @@ ZEND_API ZEND_COLD zval* ZEND_FASTCALL zend_undefined_index_write(HashTable *ht, } else { retval = zend_hash_add_new(ht, offset, &EG(uninitialized_zval)); } - zend_string_release_outline(offset); + zend_string_release_noinline(offset); return retval; } @@ -2937,7 +2937,7 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z } ZVAL_UNDEFINED_OP2(); if (!(GC_FLAGS(str) & IS_STR_INTERNED) && UNEXPECTED(GC_DELREF(str) == 0)) { - zend_string_efree_outline(str); + zend_string_efree_noinline(str); ZVAL_NULL(result); return; } @@ -2954,7 +2954,7 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z } zend_error(E_WARNING, "String offset cast occurred"); if (!(GC_FLAGS(str) & IS_STR_INTERNED) && UNEXPECTED(GC_DELREF(str) == 0)) { - zend_string_efree_outline(str); + zend_string_efree_noinline(str); ZVAL_NULL(result); return; } @@ -3645,8 +3645,8 @@ ZEND_API ZEND_COLD void zend_throw_ref_type_error_type(const zend_property_info zend_get_unmangled_property_name(prop2->name), ZSTR_VAL(type2_str) ); - zend_string_release_outline(type1_str); - zend_string_release_outline(type2_str); + zend_string_release_noinline(type1_str); + zend_string_release_noinline(type2_str); } ZEND_API ZEND_COLD void zend_throw_ref_type_error_zval(const zend_property_info *prop, const zval *zv) { @@ -3657,7 +3657,7 @@ ZEND_API ZEND_COLD void zend_throw_ref_type_error_zval(const zend_property_info zend_get_unmangled_property_name(prop->name), ZSTR_VAL(type_str) ); - zend_string_release_outline(type_str); + zend_string_release_noinline(type_str); } ZEND_API ZEND_COLD void zend_throw_conflicting_coercion_error(const zend_property_info *prop1, const zend_property_info *prop2, const zval *zv) { @@ -3672,8 +3672,8 @@ ZEND_API ZEND_COLD void zend_throw_conflicting_coercion_error(const zend_propert zend_get_unmangled_property_name(prop2->name), ZSTR_VAL(type2_str) ); - zend_string_release_outline(type1_str); - zend_string_release_outline(type2_str); + zend_string_release_noinline(type1_str); + zend_string_release_noinline(type2_str); } /* 1: valid, 0: invalid, -1: may be valid after type coercion */ @@ -4872,7 +4872,7 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_string(zend_s if (UNEXPECTED(!(fbc->common.fn_flags & ZEND_ACC_STATIC))) { zend_non_static_method_call(fbc); if (fbc->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) { - zend_string_release_ex_outline(fbc->common.function_name, 0); + zend_string_release_ex_noinline(fbc->common.function_name, 0); zend_free_trampoline(fbc); } return NULL; @@ -4889,7 +4889,7 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_string(zend_s } if (UNEXPECTED((func = zend_hash_find(EG(function_table), lcname)) == NULL)) { zend_throw_error(NULL, "Call to undefined function %s()", ZSTR_VAL(function)); - zend_string_release_ex_outline(lcname, 0); + zend_string_release_ex_noinline(lcname, 0); return NULL; } zend_string_release_ex(lcname, 0); @@ -5000,7 +5000,7 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_array(zend_ar if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) { zend_non_static_method_call(fbc); if (fbc->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) { - zend_string_release_ex_outline(fbc->common.function_name, 0); + zend_string_release_ex_noinline(fbc->common.function_name, 0); zend_free_trampoline(fbc); } return NULL; diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index de6f4669f7625..e61805c6ac055 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -829,7 +829,7 @@ zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_ = zend_get_callable_name_ex(&fci->function_name, fci->object); zend_throw_error(NULL, "Invalid callback %s, %s", ZSTR_VAL(callable_name), error); efree(error); - zend_string_release_ex_outline(callable_name, 0); + zend_string_release_ex_noinline(callable_name, 0); return SUCCESS; } @@ -1228,7 +1228,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string * /* Verify class name before passing it to the autoloader. */ if (!key && !ZSTR_HAS_CE_CACHE(name) && !zend_is_valid_class_name(name)) { - zend_string_release_ex_outline(lc_name, 0); + zend_string_release_ex_noinline(lc_name, 0); return NULL; } diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 6a5fe4d50909f..3473ebe686a29 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -867,7 +867,7 @@ static ZEND_COLD void zend_append_type_hint( if (ZEND_TYPE_IS_SET(arg_info->type)) { zend_string *type_str = zend_type_to_string_resolved(arg_info->type, scope); smart_str_append(str, type_str); - zend_string_release_outline(type_str); + zend_string_release_noinline(type_str); if (!return_hint) { smart_str_appendc(str, ' '); } @@ -987,7 +987,7 @@ static ZEND_COLD zend_string *zend_get_function_declaration( zend_string *tmp_zv_str; zend_string *zv_str = zval_get_tmp_string(zv, &tmp_zv_str); smart_str_append(&str, zv_str); - zend_tmp_string_release_outline(tmp_zv_str); + zend_tmp_string_release_noinline(tmp_zv_str); } } } @@ -1060,8 +1060,8 @@ static void ZEND_COLD emit_incompatible_method_error( "Declaration of %s must be compatible with %s", ZSTR_VAL(child_prototype), ZSTR_VAL(parent_prototype)); } - zend_string_efree_outline(child_prototype); - zend_string_efree_outline(parent_prototype); + zend_string_efree_noinline(child_prototype); + zend_string_efree_noinline(parent_prototype); } static void perform_delayable_implementation_check( diff --git a/Zend/zend_ini.c b/Zend/zend_ini.c index d95f6f87f7179..c4cbb4340d33a 100644 --- a/Zend/zend_ini.c +++ b/Zend/zend_ini.c @@ -879,7 +879,7 @@ ZEND_API zend_long zend_ini_parse_quantity_warn(zend_string *value, zend_string if (errstr) { zend_error(E_WARNING, "Invalid \"%s\" setting. %s", ZSTR_VAL(setting), ZSTR_VAL(errstr)); - zend_string_release_outline(errstr); + zend_string_release_noinline(errstr); } return retval; @@ -893,7 +893,7 @@ ZEND_API zend_ulong zend_ini_parse_uquantity_warn(zend_string *value, zend_strin if (errstr) { zend_error(E_WARNING, "Invalid \"%s\" setting. %s", ZSTR_VAL(setting), ZSTR_VAL(errstr)); - zend_string_release_outline(errstr); + zend_string_release_noinline(errstr); } return retval; diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index e65f2cb0b7a5b..608e23ce42b4d 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -2999,7 +2999,7 @@ heredoc_scan_done: } if (UNEXPECTED(zend_scan_escape_string(zendlval, ZSTR_VAL(copy), ZSTR_LEN(copy), 0) != SUCCESS)) { - zend_string_efree_outline(copy); + zend_string_efree_noinline(copy); RETURN_TOKEN(T_ERROR); } diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 5bb8155b8a1ef..47e6d72a51ff4 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -2545,7 +2545,7 @@ static bool ZEND_FASTCALL increment_string(zval *str) /* {{{ */ zend_string_addref(zstr); zend_error(E_DEPRECATED, "Increment on non-alphanumeric string is deprecated"); if (EG(exception)) { - zend_string_release_outline(zstr); + zend_string_release_noinline(zstr); return false; } zval_ptr_dtor(str); @@ -2754,7 +2754,7 @@ ZEND_API zend_result ZEND_FASTCALL decrement_function(zval *op1) /* {{{ */ zend_string_addref(zstr); zend_error(E_DEPRECATED, "Decrement on non-numeric string has no effect and is deprecated"); if (EG(exception)) { - zend_string_release_outline(zstr); + zend_string_release_noinline(zstr); return FAILURE; } zval_ptr_dtor(op1); @@ -3784,7 +3784,7 @@ ZEND_API zend_long ZEND_FASTCALL zend_dval_to_lval_slow(double d) /* }}} */ #endif -ZEND_API void zend_tmp_string_release_outline(zend_string *tmp) +ZEND_API void zend_tmp_string_release_noinline(zend_string *tmp) { zend_tmp_string_release(tmp); } diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 83625d3529f6d..b817f68dc7006 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -300,7 +300,7 @@ ZEND_API zend_long ZEND_FASTCALL zval_try_get_long(const zval *op, bool *fail ZEND_API double ZEND_FASTCALL zval_get_double_func(const zval *op); ZEND_API zend_string* ZEND_FASTCALL zval_get_string_func(zval *op); ZEND_API zend_string* ZEND_FASTCALL zval_try_get_string_func(zval *op); -ZEND_API void zend_tmp_string_release_outline(zend_string *tmp); +ZEND_API void zend_tmp_string_release_noinline(zend_string *tmp); static zend_always_inline zend_long zval_get_long(const zval *op) { return EXPECTED(Z_TYPE_P(op) == IS_LONG) ? Z_LVAL_P(op) : zval_get_long_func(op, false); diff --git a/Zend/zend_smart_str.c b/Zend/zend_smart_str.c index 12ca158d19cfe..81dbafc0b8878 100644 --- a/Zend/zend_smart_str.c +++ b/Zend/zend_smart_str.c @@ -237,7 +237,7 @@ ZEND_API zend_result ZEND_FASTCALL smart_str_append_zval(smart_str *dest, const return SUCCESS; } -ZEND_API void smart_str_free_outline(smart_str *str) +ZEND_API void smart_str_free_noinline(smart_str *str) { smart_str_free(str); } diff --git a/Zend/zend_smart_str.h b/Zend/zend_smart_str.h index 4cb36e1e2311e..08dae6e0d6caf 100644 --- a/Zend/zend_smart_str.h +++ b/Zend/zend_smart_str.h @@ -35,7 +35,7 @@ ZEND_API void smart_str_append_printf(smart_str *dest, const char *format, ...) ZEND_API void ZEND_FASTCALL smart_str_append_escaped_truncated(smart_str *str, const zend_string *value, size_t length); ZEND_API void ZEND_FASTCALL smart_str_append_scalar(smart_str *str, const zval *value, size_t truncate); ZEND_API zend_result ZEND_FASTCALL smart_str_append_zval(smart_str *dest, const zval *value, size_t truncate); -ZEND_API void smart_str_free_outline(smart_str *str); +ZEND_API void smart_str_free_noinline(smart_str *str); END_EXTERN_C() static zend_always_inline size_t smart_str_alloc(smart_str *str, size_t len, bool persistent) { diff --git a/Zend/zend_string.c b/Zend/zend_string.c index c7839147f6bb7..a94bb022ec006 100644 --- a/Zend/zend_string.c +++ b/Zend/zend_string.c @@ -531,22 +531,22 @@ size_t strlcat (char *__restrict dest, const char *restrict src, size_t n) } #endif -ZEND_API void zend_string_free_outline(zend_string *s) +ZEND_API void zend_string_free_noinline(zend_string *s) { zend_string_free(s); } -ZEND_API void zend_string_efree_outline(zend_string *s) +ZEND_API void zend_string_efree_noinline(zend_string *s) { zend_string_efree(s); } -ZEND_API void zend_string_release_outline(zend_string *s) +ZEND_API void zend_string_release_noinline(zend_string *s) { zend_string_release(s); } -ZEND_API void zend_string_release_ex_outline(zend_string *s, bool persistent) +ZEND_API void zend_string_release_ex_noinline(zend_string *s, bool persistent) { zend_string_release_ex(s, persistent); } diff --git a/Zend/zend_string.h b/Zend/zend_string.h index 4f803bf256229..0bb294c50d404 100644 --- a/Zend/zend_string.h +++ b/Zend/zend_string.h @@ -57,10 +57,10 @@ ZEND_API void zend_interned_strings_set_request_storage_handlers( zend_string_init_existing_interned_func_t init_existing_handler); ZEND_API void zend_interned_strings_switch_storage(bool request); -ZEND_API void zend_string_free_outline(zend_string *s); -ZEND_API void zend_string_efree_outline(zend_string *s); -ZEND_API void zend_string_release_outline(zend_string *s); -ZEND_API void zend_string_release_ex_outline(zend_string *s, bool persistent); +ZEND_API void zend_string_free_noinline(zend_string *s); +ZEND_API void zend_string_efree_noinline(zend_string *s); +ZEND_API void zend_string_release_noinline(zend_string *s); +ZEND_API void zend_string_release_ex_noinline(zend_string *s, bool persistent); ZEND_API extern zend_string *zend_empty_string; ZEND_API extern zend_string *zend_one_char_string[256]; diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index fbe7f17795303..29b4365484a3d 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -3319,7 +3319,7 @@ ZEND_VM_COLD_CONSTCONST_HANDLER(53, ZEND_FAST_CONCAT, CONST|TMPVAR|CV, CONST|TMP } } ZVAL_STR(EX_VAR(opline->result.var), op2_str); - zend_string_release_ex_outline(op1_str, 0); + zend_string_release_ex_noinline(op1_str, 0); break; } } @@ -3331,7 +3331,7 @@ ZEND_VM_COLD_CONSTCONST_HANDLER(53, ZEND_FAST_CONCAT, CONST|TMPVAR|CV, CONST|TMP } } ZVAL_STR(EX_VAR(opline->result.var), op1_str); - zend_string_release_ex_outline(op2_str, 0); + zend_string_release_ex_noinline(op2_str, 0); break; } } @@ -3454,7 +3454,7 @@ ZEND_VM_HANDLER(56, ZEND_ROPE_END, TMP, CONST|TMPVAR|CV, NUM) FREE_OP2(); if (UNEXPECTED(EG(exception))) { for (i = 0; i <= opline->extended_value; i++) { - zend_string_release_ex_outline(rope[i], 0); + zend_string_release_ex_noinline(rope[i], 0); } ZVAL_UNDEF(EX_VAR(opline->result.var)); HANDLE_EXCEPTION(); @@ -3878,7 +3878,7 @@ ZEND_VM_C_LABEL(try_function_name): if (UNEXPECTED(EG(exception))) { if (call) { if (call->func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) { - zend_string_release_ex_outline(call->func->common.function_name, 0); + zend_string_release_ex_noinline(call->func->common.function_name, 0); zend_free_trampoline(call->func); } zend_vm_stack_free_call_frame(call); @@ -5326,7 +5326,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_outline(name); + zend_string_release_noinline(name); break; } @@ -5346,7 +5346,7 @@ ZEND_VM_C_LABEL(send_again): ZVAL_COPY_VALUE(top, arg); } - zend_string_release_outline(name); + zend_string_release_noinline(name); } else { if (have_named_params) { zend_throw_error(NULL, diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index c0b31b1435de1..297efc6527f42 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -2415,7 +2415,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_outline(name); + zend_string_release_noinline(name); break; } @@ -2435,7 +2435,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_UNPACK_SPEC_HANDLER(ZEND_ ZVAL_COPY_VALUE(top, arg); } - zend_string_release_outline(name); + zend_string_release_noinline(name); } else { if (have_named_params) { zend_throw_error(NULL, @@ -3978,7 +3978,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_DYNAMIC_CALL_SPEC_CONST_H if (UNEXPECTED(EG(exception))) { if (call) { if (call->func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) { - zend_string_release_ex_outline(call->func->common.function_name, 0); + zend_string_release_ex_noinline(call->func->common.function_name, 0); zend_free_trampoline(call->func); } zend_vm_stack_free_call_frame(call); @@ -4161,7 +4161,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_DYNAMIC_CALL_SPEC_TMPVAR_ if (UNEXPECTED(EG(exception))) { if (call) { if (call->func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) { - zend_string_release_ex_outline(call->func->common.function_name, 0); + zend_string_release_ex_noinline(call->func->common.function_name, 0); zend_free_trampoline(call->func); } zend_vm_stack_free_call_frame(call); @@ -4357,7 +4357,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_DYNAMIC_CALL_SPEC_CV_HAND if (UNEXPECTED(EG(exception))) { if (call) { if (call->func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) { - zend_string_release_ex_outline(call->func->common.function_name, 0); + zend_string_release_ex_noinline(call->func->common.function_name, 0); zend_free_trampoline(call->func); } zend_vm_stack_free_call_frame(call); @@ -7083,7 +7083,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_ } } ZVAL_STR(EX_VAR(opline->result.var), op2_str); - zend_string_release_ex_outline(op1_str, 0); + zend_string_release_ex_noinline(op1_str, 0); break; } } @@ -7095,7 +7095,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_ } } ZVAL_STR(EX_VAR(opline->result.var), op1_str); - zend_string_release_ex_outline(op2_str, 0); + zend_string_release_ex_noinline(op2_str, 0); break; } } @@ -9652,7 +9652,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CONST_TMPVAR_ } } ZVAL_STR(EX_VAR(opline->result.var), op2_str); - zend_string_release_ex_outline(op1_str, 0); + zend_string_release_ex_noinline(op1_str, 0); break; } } @@ -9664,7 +9664,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CONST_TMPVAR_ } } ZVAL_STR(EX_VAR(opline->result.var), op1_str); - zend_string_release_ex_outline(op2_str, 0); + zend_string_release_ex_noinline(op2_str, 0); break; } } @@ -12143,7 +12143,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CONST_CV_HAND } } ZVAL_STR(EX_VAR(opline->result.var), op2_str); - zend_string_release_ex_outline(op1_str, 0); + zend_string_release_ex_noinline(op1_str, 0); break; } } @@ -12155,7 +12155,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CONST_CV_HAND } } ZVAL_STR(EX_VAR(opline->result.var), op1_str); - zend_string_release_ex_outline(op2_str, 0); + zend_string_release_ex_noinline(op2_str, 0); break; } } @@ -16545,7 +16545,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_CONST_ } } ZVAL_STR(EX_VAR(opline->result.var), op2_str); - zend_string_release_ex_outline(op1_str, 0); + zend_string_release_ex_noinline(op1_str, 0); break; } } @@ -16557,7 +16557,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_CONST_ } } ZVAL_STR(EX_VAR(opline->result.var), op1_str); - zend_string_release_ex_outline(op2_str, 0); + zend_string_release_ex_noinline(op2_str, 0); break; } } @@ -18039,7 +18039,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_TMPVAR } } ZVAL_STR(EX_VAR(opline->result.var), op2_str); - zend_string_release_ex_outline(op1_str, 0); + zend_string_release_ex_noinline(op1_str, 0); break; } } @@ -18051,7 +18051,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_TMPVAR } } ZVAL_STR(EX_VAR(opline->result.var), op1_str); - zend_string_release_ex_outline(op2_str, 0); + zend_string_release_ex_noinline(op2_str, 0); break; } } @@ -19447,7 +19447,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_CV_HAN } } ZVAL_STR(EX_VAR(opline->result.var), op2_str); - zend_string_release_ex_outline(op1_str, 0); + zend_string_release_ex_noinline(op1_str, 0); break; } } @@ -19459,7 +19459,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_CV_HAN } } ZVAL_STR(EX_VAR(opline->result.var), op1_str); - zend_string_release_ex_outline(op2_str, 0); + zend_string_release_ex_noinline(op2_str, 0); break; } } @@ -20634,7 +20634,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ROPE_END_SPEC_TMP_CONST_HANDLE if (UNEXPECTED(EG(exception))) { for (i = 0; i <= opline->extended_value; i++) { - zend_string_release_ex_outline(rope[i], 0); + zend_string_release_ex_noinline(rope[i], 0); } ZVAL_UNDEF(EX_VAR(opline->result.var)); HANDLE_EXCEPTION(); @@ -21115,7 +21115,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ROPE_END_SPEC_TMP_TMPVAR_HANDL zval_ptr_dtor_nogc(EX_VAR(opline->op2.var)); if (UNEXPECTED(EG(exception))) { for (i = 0; i <= opline->extended_value; i++) { - zend_string_release_ex_outline(rope[i], 0); + zend_string_release_ex_noinline(rope[i], 0); } ZVAL_UNDEF(EX_VAR(opline->result.var)); HANDLE_EXCEPTION(); @@ -21980,7 +21980,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ROPE_END_SPEC_TMP_CV_HANDLER(Z if (UNEXPECTED(EG(exception))) { for (i = 0; i <= opline->extended_value; i++) { - zend_string_release_ex_outline(rope[i], 0); + zend_string_release_ex_noinline(rope[i], 0); } ZVAL_UNDEF(EX_VAR(opline->result.var)); HANDLE_EXCEPTION(); @@ -44568,7 +44568,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_CONST_HAND } } ZVAL_STR(EX_VAR(opline->result.var), op2_str); - zend_string_release_ex_outline(op1_str, 0); + zend_string_release_ex_noinline(op1_str, 0); break; } } @@ -44580,7 +44580,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_CONST_HAND } } ZVAL_STR(EX_VAR(opline->result.var), op1_str); - zend_string_release_ex_outline(op2_str, 0); + zend_string_release_ex_noinline(op2_str, 0); break; } } @@ -48438,7 +48438,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_TMPVAR_HAN } } ZVAL_STR(EX_VAR(opline->result.var), op2_str); - zend_string_release_ex_outline(op1_str, 0); + zend_string_release_ex_noinline(op1_str, 0); break; } } @@ -48450,7 +48450,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_TMPVAR_HAN } } ZVAL_STR(EX_VAR(opline->result.var), op1_str); - zend_string_release_ex_outline(op2_str, 0); + zend_string_release_ex_noinline(op2_str, 0); break; } } @@ -54013,7 +54013,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_CV_HANDLER } } ZVAL_STR(EX_VAR(opline->result.var), op2_str); - zend_string_release_ex_outline(op1_str, 0); + zend_string_release_ex_noinline(op1_str, 0); break; } } @@ -54025,7 +54025,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_CV_HANDLER } } ZVAL_STR(EX_VAR(opline->result.var), op1_str); - zend_string_release_ex_outline(op2_str, 0); + zend_string_release_ex_noinline(op2_str, 0); break; } } diff --git a/ext/date/php_date.c b/ext/date/php_date.c index adb6ffd42326d..94f6f221142dd 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -5068,19 +5068,19 @@ static bool date_period_init_iso8601_string(php_period_obj *dpobj, zend_class_en if (dpobj->start == NULL) { zend_string *func = get_active_function_or_method_name(); zend_throw_exception_ex(date_ce_date_malformed_period_string_exception, 0, "%s(): ISO interval must contain a start date, \"%s\" given", ZSTR_VAL(func), isostr); - zend_string_release_outline(func); + zend_string_release_noinline(func); return false; } if (dpobj->interval == NULL) { zend_string *func = get_active_function_or_method_name(); zend_throw_exception_ex(date_ce_date_malformed_period_string_exception, 0, "%s(): ISO interval must contain an interval, \"%s\" given", ZSTR_VAL(func), isostr); - zend_string_release_outline(func); + zend_string_release_noinline(func); return false; } if (dpobj->end == NULL && recurrences == 0) { zend_string *func = get_active_function_or_method_name(); zend_throw_exception_ex(date_ce_date_malformed_period_string_exception, 0, "%s(): ISO interval must contain an end date or a recurrence count, \"%s\" given", ZSTR_VAL(func), isostr); - zend_string_release_outline(func); + zend_string_release_noinline(func); return false; } diff --git a/ext/dom/document.c b/ext/dom/document.c index 3dd6f1b67c2ad..d85c14132bebe 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -193,7 +193,7 @@ zend_result dom_document_version_write(dom_object *obj, zval *newval) if (php_dom_follow_spec_intern(obj)) { if (!zend_string_equals_literal(str, "1.0") && !zend_string_equals_literal(str, "1.1")) { zend_value_error("Invalid XML version"); - zend_string_release_ex_outline(str, 0); + zend_string_release_ex_noinline(str, 0); return FAILURE; } } diff --git a/ext/fileinfo/libmagic/apprentice.c b/ext/fileinfo/libmagic/apprentice.c index a8e72b617e796..2150e6120da6b 100644 --- a/ext/fileinfo/libmagic/apprentice.c +++ b/ext/fileinfo/libmagic/apprentice.c @@ -2815,7 +2815,7 @@ getvalue(struct magic_set *ms, struct magic *m, const char **p, int action) pattern = convert_libmagic_pattern(m->value.s, strlen(m->value.s), options); if ((pce = pcre_get_compiled_regex_cache(pattern)) == NULL) { - zend_string_release_outline(pattern); + zend_string_release_noinline(pattern); return -1; } zend_string_release(pattern); diff --git a/ext/fileinfo/libmagic/softmagic.c b/ext/fileinfo/libmagic/softmagic.c index 9f7c6953bed73..2c202851b133b 100644 --- a/ext/fileinfo/libmagic/softmagic.c +++ b/ext/fileinfo/libmagic/softmagic.c @@ -2286,7 +2286,7 @@ magiccheck(struct magic_set *ms, struct magic *m) l = v = 0; if ((pce = pcre_get_compiled_regex_cache(pattern)) == NULL) { - zend_string_release_outline(pattern); + zend_string_release_noinline(pattern); return -1; } else { /* pce now contains the compiled regex */ @@ -2307,7 +2307,7 @@ magiccheck(struct magic_set *ms, struct magic *m) if (Z_LVAL(retval) < 0) { zval_ptr_dtor(&subpats); - zend_string_release_outline(pattern); + zend_string_release_noinline(pattern); return -1; } else if ((Z_LVAL(retval) > 0) && (Z_TYPE(subpats) == IS_ARRAY)) { /* Need to fetch global match which equals pmatch[0] */ @@ -2334,7 +2334,7 @@ magiccheck(struct magic_set *ms, struct magic *m) } else { error_out: zval_ptr_dtor(&subpats); - zend_string_release_outline(pattern); + zend_string_release_noinline(pattern); return -1; } } else { diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index 81253eef4c06e..934835922b8e2 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -792,7 +792,7 @@ static php_iconv_err_t _php_iconv_strpos(size_t *pretval, if (cd == (iconv_t)(-1)) { if (ndl_buf != NULL) { - zend_string_efree_outline(ndl_buf); + zend_string_efree_noinline(ndl_buf); } if (errno == EINVAL) { return PHP_ICONV_ERR_WRONG_CHARSET; diff --git a/ext/json/json.c b/ext/json/json.c index 01ed37f7dc24a..5f72828f05008 100644 --- a/ext/json/json.c +++ b/ext/json/json.c @@ -244,7 +244,7 @@ PHP_FUNCTION(json_encode) } } else { if (encoder.error_code != PHP_JSON_ERROR_NONE) { - smart_str_free_outline(&buf); + smart_str_free_noinline(&buf); zend_throw_exception(php_json_exception_ce, php_json_get_error_msg(encoder.error_code), encoder.error_code); RETURN_THROWS(); } diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index bc3bfc57b8b7e..8558d212f85d3 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -415,7 +415,7 @@ static zend_result php_mb_parse_encoding_array(HashTable *target_hash, const mbf n++; } else { zend_argument_value_error(arg_num, "contains invalid encoding \"%s\"", ZSTR_VAL(encoding_str)); - zend_string_release_outline(encoding_str); + zend_string_release_noinline(encoding_str); efree(ZEND_VOIDP(list)); return FAILURE; } @@ -917,7 +917,7 @@ static PHP_INI_MH(OnUpdate_mbstring_http_output_conv_mimetypes) if (ZSTR_LEN(tmp) > 0) { if (!(re = _php_mb_compile_regex(ZSTR_VAL(tmp)))) { - zend_string_release_ex_outline(tmp, 0); + zend_string_release_ex_noinline(tmp, 0); return FAILURE; } } @@ -1221,7 +1221,7 @@ PHP_FUNCTION(mb_language) zend_string *ini_name = ZSTR_INIT_LITERAL("mbstring.language", 0); if (FAILURE == zend_alter_ini_entry(ini_name, name, PHP_INI_USER, PHP_INI_STAGE_RUNTIME)) { zend_argument_value_error(1, "must be a valid language, \"%s\" given", ZSTR_VAL(name)); - zend_string_release_ex_outline(ini_name, 0); + zend_string_release_ex_noinline(ini_name, 0); RETURN_THROWS(); } // TODO Make return void @@ -2276,8 +2276,8 @@ PHP_FUNCTION(mb_substr_count) /* A string with >0 bytes may convert to 0 codepoints; for example, the contents * may be only escape sequences */ if (UNEXPECTED(ZSTR_LEN(needle_u8) == 0)) { - zend_string_free_outline(haystack_u8); - zend_string_free_outline(needle_u8); + zend_string_free_noinline(haystack_u8); + zend_string_free_noinline(needle_u8); zend_argument_value_error(2, "must not be empty"); RETURN_THROWS(); } @@ -2673,7 +2673,7 @@ PHP_FUNCTION(mb_strimwidth) if (from > 0) { zend_string *trimmed = mb_get_substr(str, 0, from, enc); width -= mb_get_strwidth(trimmed, enc); - zend_string_free_outline(trimmed); + zend_string_free_noinline(trimmed); } if (width < 0) { diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index add72c5ea0302..1bc07fd202df1 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -1235,7 +1235,7 @@ zend_string *accel_make_persistent_key(zend_string *str) zend_shared_alloc_lock(); str = accel_new_interned_string(zend_string_copy(cwd_str)); if (str == cwd_str) { - zend_string_release_ex_outline(str, 0); + zend_string_release_ex_noinline(str, 0); str = NULL; } zend_shared_alloc_unlock(); @@ -1279,7 +1279,7 @@ zend_string *accel_make_persistent_key(zend_string *str) zend_shared_alloc_lock(); str = accel_new_interned_string(zend_string_copy(ZCG(include_path))); if (str == ZCG(include_path)) { - zend_string_release_outline(str); + zend_string_release_noinline(str); str = NULL; } zend_shared_alloc_unlock(); @@ -4018,7 +4018,7 @@ static void preload_link(void) "Can't preload unlinked class %s: %s", ZSTR_VAL(ce->name), ZSTR_VAL(error->message)); } - zend_string_release_outline(lcname); + zend_string_release_noinline(lcname); } } ZEND_HASH_FOREACH_END(); diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c index b0a7e5a96cfe8..529aa8eb41a8a 100644 --- a/ext/opcache/jit/zend_jit_helpers.c +++ b/ext/opcache/jit/zend_jit_helpers.c @@ -1328,7 +1328,7 @@ static zend_never_inline void zend_assign_to_string_offset(zval *str, zval *dim, GC_ADDREF(s); zend_error(E_WARNING, "Only the first byte will be assigned to the string offset"); if (UNEXPECTED(GC_DELREF(s) == 0)) { - zend_string_efree_outline(s); + zend_string_efree_noinline(s); if (result) { ZVAL_NULL(result); } @@ -2089,7 +2089,7 @@ static zend_never_inline ZEND_COLD void zend_throw_auto_init_in_prop_error(zend_ ZSTR_VAL(prop->ce->name), zend_get_unmangled_property_name(prop->name), ZSTR_VAL(type_str) ); - zend_string_release_outline(type_str); + zend_string_release_noinline(type_str); } static zend_never_inline ZEND_COLD void zend_throw_access_uninit_prop_by_ref_error( @@ -2215,7 +2215,7 @@ static void ZEND_FASTCALL zend_jit_check_array_promotion(zval *val, zend_propert ZSTR_VAL(prop->ce->name), zend_get_unmangled_property_name(prop->name), ZSTR_VAL(type_str) ); - zend_string_release_outline(type_str); + zend_string_release_noinline(type_str); ZVAL_ERROR(result); } else { ZVAL_INDIRECT(result, val); @@ -2354,7 +2354,7 @@ static ZEND_COLD void zend_jit_throw_inc_ref_error(zend_reference *ref, zend_pro ZSTR_VAL(error_prop->ce->name), zend_get_unmangled_property_name(error_prop->name), ZSTR_VAL(type_str)); - zend_string_release_outline(type_str); + zend_string_release_noinline(type_str); } static ZEND_COLD void zend_jit_throw_dec_ref_error(zend_reference *ref, zend_property_info *error_prop) @@ -2366,7 +2366,7 @@ static ZEND_COLD void zend_jit_throw_dec_ref_error(zend_reference *ref, zend_pro ZSTR_VAL(error_prop->ce->name), zend_get_unmangled_property_name(error_prop->name), ZSTR_VAL(type_str)); - zend_string_release_outline(type_str); + zend_string_release_noinline(type_str); } static void ZEND_FASTCALL zend_jit_pre_inc_typed_ref(zend_reference *ref, zval *ret) @@ -2799,7 +2799,7 @@ static ZEND_COLD zend_long _zend_jit_throw_inc_prop_error(zend_property_info *pr ZSTR_VAL(prop->ce->name), zend_get_unmangled_property_name(prop->name), ZSTR_VAL(type_str)); - zend_string_release_outline(type_str); + zend_string_release_noinline(type_str); return ZEND_LONG_MAX; } @@ -2810,7 +2810,7 @@ static ZEND_COLD zend_long _zend_jit_throw_dec_prop_error(zend_property_info *pr ZSTR_VAL(prop->ce->name), zend_get_unmangled_property_name(prop->name), ZSTR_VAL(type_str)); - zend_string_release_outline(type_str); + zend_string_release_noinline(type_str); return ZEND_LONG_MIN; } diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 4d70b44f1839b..4bf8102bd65ea 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -2883,7 +2883,7 @@ static zend_result php_openssl_csr_add_subj_entry(zval *item, X509_NAME *subj, i " queue and value of string_mask OpenSSL option " "if illegal characters are reported)", nid, ZSTR_VAL(str_item)); - zend_string_release_outline(str_item); + zend_string_release_noinline(str_item); return FAILURE; } zend_string_release(str_item); @@ -3012,7 +3012,7 @@ static zend_result php_openssl_csr_make(struct php_x509_request * req, X509_REQ if (UNEXPECTED(!X509_REQ_add1_attr_by_NID(csr, nid, MBSTRING_UTF8, (unsigned char*)ZSTR_VAL(str_item), (int)ZSTR_LEN(str_item)))) { php_openssl_store_errors(); php_error_docref(NULL, E_WARNING, "attributes: add_attr_by_NID %d -> %s (failed)", nid, ZSTR_VAL(str_item)); - zend_string_release_outline(str_item); + zend_string_release_noinline(str_item); return FAILURE; } zend_string_release(str_item); @@ -7874,15 +7874,15 @@ PHP_OPENSSL_API zend_string* php_openssl_encrypt( ZEND_TRY_ASSIGN_REF_NEW_STR(tag, tag_str); } else { php_error_docref(NULL, E_WARNING, "Retrieving verification tag failed"); - zend_string_release_ex_outline(tag_str, 0); - zend_string_release_ex_outline(outbuf, 0); + zend_string_release_ex_noinline(tag_str, 0); + zend_string_release_ex_noinline(outbuf, 0); outbuf = NULL; } } else if (tag) { ZEND_TRY_ASSIGN_REF_NULL(tag); } else if (mode.is_aead) { php_error_docref(NULL, E_WARNING, "A tag should be provided when using AEAD mode"); - zend_string_release_ex_outline(outbuf, 0); + zend_string_release_ex_noinline(outbuf, 0); outbuf = NULL; } } else { @@ -8116,7 +8116,7 @@ PHP_OPENSSL_API zend_string* php_openssl_random_pseudo_bytes(zend_long buffer_le PHP_OPENSSL_CHECK_LONG_TO_INT_NULL_RETURN(buffer_length, length); PHP_OPENSSL_RAND_ADD_TIME(); if (UNEXPECTED(RAND_bytes((unsigned char*)ZSTR_VAL(buffer), (int)buffer_length) <= 0)) { - zend_string_release_ex_outline(buffer, 0); + zend_string_release_ex_noinline(buffer, 0); zend_throw_exception(zend_ce_exception, "Error reading from source device", 0); return NULL; } diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c index 155de483a9fbb..5eb61d1dd51f9 100644 --- a/ext/openssl/xp_ssl.c +++ b/ext/openssl/xp_ssl.c @@ -308,7 +308,7 @@ static int php_openssl_handle_ssl_error(php_stream *stream, int nr_bytes, bool i ebuf.s ? "OpenSSL Error messages:\n" : "", ebuf.s ? ZSTR_VAL(ebuf.s) : ""); if (ebuf.s) { - smart_str_free_outline(&ebuf); + smart_str_free_noinline(&ebuf); } } @@ -1513,7 +1513,7 @@ static zend_result php_openssl_enable_server_sni(php_stream *stream, php_openssl "Failed setting local cert chain file `%s'; could not open file", ZSTR_VAL(local_cert_str) ); - zend_string_release_outline(local_cert_str); + zend_string_release_noinline(local_cert_str); return FAILURE; } zend_string_release(local_cert_str); @@ -1537,7 +1537,7 @@ static zend_result php_openssl_enable_server_sni(php_stream *stream, php_openssl "Failed setting local private key file `%s'; could not open file", ZSTR_VAL(local_pk_str) ); - zend_string_release_outline(local_pk_str); + zend_string_release_noinline(local_pk_str); return FAILURE; } zend_string_release(local_pk_str); diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 7a3c62174b738..9a88f4eea7982 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -648,7 +648,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, bo while (isspace((int)*(unsigned char *)p)) p++; if (p >= end_p) { if (key != regex) { - zend_string_release_ex_outline(key, 0); + zend_string_release_ex_noinline(key, 0); } php_error_docref(NULL, E_WARNING, "Empty regular expression"); pcre_handle_exec_error(PCRE2_ERROR_INTERNAL); @@ -660,7 +660,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, bo delimiter = *p++; if (isalnum((int)*(unsigned char *)&delimiter) || delimiter == '\\' || delimiter == '\0') { if (key != regex) { - zend_string_release_ex_outline(key, 0); + zend_string_release_ex_noinline(key, 0); } php_error_docref(NULL, E_WARNING, "Delimiter must not be alphanumeric, backslash, or NUL byte"); pcre_handle_exec_error(PCRE2_ERROR_INTERNAL); @@ -766,7 +766,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, bo pcre_handle_exec_error(PCRE2_ERROR_INTERNAL); efree(pattern); if (key != regex) { - zend_string_release_ex_outline(key, 0); + zend_string_release_ex_noinline(key, 0); } return NULL; } @@ -780,7 +780,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, bo if (UNEXPECTED(!tables)) { php_error_docref(NULL,E_WARNING, "Failed to generate locale character tables"); pcre_handle_exec_error(PCRE2_ERROR_NOMEMORY); - zend_string_release_ex_outline(key, 0); + zend_string_release_ex_noinline(key, 0); efree(pattern); return NULL; } @@ -799,7 +799,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, bo if (re == NULL) { if (key != regex) { - zend_string_release_ex_outline(key, 0); + zend_string_release_ex_noinline(key, 0); } pcre2_get_error_message(errnumber, error, sizeof(error)); php_error_docref(NULL,E_WARNING, "Compilation failed: %s at offset %zu", error, erroffset); @@ -851,7 +851,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, bo rc = pcre2_pattern_info(re, PCRE2_INFO_CAPTURECOUNT, &new_entry.capture_count); if (rc < 0) { if (key != regex) { - zend_string_release_ex_outline(key, 0); + zend_string_release_ex_noinline(key, 0); } php_error_docref(NULL, E_WARNING, "Internal pcre2_pattern_info() error %d", rc); pcre_handle_exec_error(PCRE2_ERROR_INTERNAL); @@ -862,7 +862,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, bo rc = pcre2_pattern_info(re, PCRE2_INFO_NAMECOUNT, &name_count); if (rc < 0) { if (key != regex) { - zend_string_release_ex_outline(key, 0); + zend_string_release_ex_noinline(key, 0); } php_error_docref(NULL, E_WARNING, "Internal pcre_pattern_info() error %d", rc); pcre_handle_exec_error(PCRE2_ERROR_INTERNAL); diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index c3df612325da5..59c41143cbb99 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -1301,7 +1301,7 @@ PHP_METHOD(PDOStatement, fetchAll) zend_string *func = get_active_function_or_method_name(); zend_argument_count_error("%s() expects exactly 2 argument for PDO::FETCH_FUNC, %d given", ZSTR_VAL(func), ZEND_NUM_ARGS()); - zend_string_release_outline(func); + zend_string_release_noinline(func); RETURN_THROWS(); } if (arg2 == NULL) { @@ -1321,7 +1321,7 @@ PHP_METHOD(PDOStatement, fetchAll) zend_string *func = get_active_function_or_method_name(); zend_argument_count_error("%s() expects at most 2 argument for the fetch mode provided, %d given", ZSTR_VAL(func), ZEND_NUM_ARGS()); - zend_string_release_outline(func); + zend_string_release_noinline(func); RETURN_THROWS(); } /* Is column index passed? */ @@ -1347,7 +1347,7 @@ PHP_METHOD(PDOStatement, fetchAll) zend_string *func = get_active_function_or_method_name(); zend_argument_count_error("%s() expects exactly 1 argument for the fetch mode provided, %d given", ZSTR_VAL(func), ZEND_NUM_ARGS()); - zend_string_release_outline(func); + zend_string_release_noinline(func); RETURN_THROWS(); } } @@ -1733,7 +1733,7 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a zend_string *func = get_active_function_or_method_name(); zend_argument_count_error("%s() expects exactly %d arguments for the fetch mode provided, %d given", ZSTR_VAL(func), mode_arg_num, total_num_args); - zend_string_release_outline(func); + zend_string_release_noinline(func); return false; } break; @@ -1743,7 +1743,7 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a zend_string *func = get_active_function_or_method_name(); zend_argument_count_error("%s() expects exactly %d arguments for the fetch mode provided, %d given", ZSTR_VAL(func), arg1_arg_num, total_num_args); - zend_string_release_outline(func); + zend_string_release_noinline(func); return false; } if (Z_TYPE(args[0]) != IS_LONG) { @@ -1767,7 +1767,7 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a zend_string *func = get_active_function_or_method_name(); zend_argument_count_error("%s() expects exactly %d arguments for the fetch mode provided, %d given", ZSTR_VAL(func), mode_arg_num, total_num_args); - zend_string_release_outline(func); + zend_string_release_noinline(func); return false; } stmt->fetch.cls.ce = NULL; @@ -1777,7 +1777,7 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a zend_string *func = get_active_function_or_method_name(); zend_argument_count_error("%s() expects at least %d arguments for the fetch mode provided, %d given", ZSTR_VAL(func), arg1_arg_num, total_num_args); - zend_string_release_outline(func); + zend_string_release_noinline(func); return false; } /* constructor_arguments can be null/not passed */ @@ -1785,7 +1785,7 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a zend_string *func = get_active_function_or_method_name(); zend_argument_count_error("%s() expects at most %d arguments for the fetch mode provided, %d given", ZSTR_VAL(func), constructor_arg_num, total_num_args); - zend_string_release_outline(func); + zend_string_release_noinline(func); return false; } if (Z_TYPE(args[0]) != IS_STRING) { @@ -1825,7 +1825,7 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a zend_string *func = get_active_function_or_method_name(); zend_argument_count_error("%s() expects exactly %d arguments for the fetch mode provided, %d given", ZSTR_VAL(func), arg1_arg_num, total_num_args); - zend_string_release_outline(func); + zend_string_release_noinline(func); return false; } if (Z_TYPE(args[0]) != IS_OBJECT) { diff --git a/ext/pdo_sqlite/pdo_sqlite.c b/ext/pdo_sqlite/pdo_sqlite.c index 949c79c19014a..5a0773d842651 100644 --- a/ext/pdo_sqlite/pdo_sqlite.c +++ b/ext/pdo_sqlite/pdo_sqlite.c @@ -351,7 +351,7 @@ static int php_sqlite_collation_callback(void *context, int string1_len, const v zend_string *func_name = get_active_function_or_method_name(); zend_type_error("%s(): Return value of the callback must be of type int, %s returned", ZSTR_VAL(func_name), zend_zval_value_name(&retval)); - zend_string_release_outline(func_name); + zend_string_release_noinline(func_name); return FAILURE; } if (Z_LVAL(retval) > 0) { diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 87dcd093b92f4..e1a2878843224 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -1636,7 +1636,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ } if (opened) { - zend_string_release_ex_outline(opened, 0); + zend_string_release_ex_noinline(opened, 0); } if (temp) { @@ -2874,7 +2874,7 @@ PHP_METHOD(Phar, setStub) if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "r|l", &zstub, &len) == SUCCESS) { zend_string *method_name = get_active_function_or_method_name(); zend_error(E_DEPRECATED, "Calling %s(resource $stub, int $length) is deprecated", ZSTR_VAL(method_name)); - zend_string_release_outline(method_name); + zend_string_release_noinline(method_name); if (UNEXPECTED(EG(exception))) { RETURN_THROWS(); } @@ -2973,7 +2973,7 @@ PHP_METHOD(Phar, setDefaultStub) zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "%s", error); efree(error); if (stub) { - zend_string_free_outline(stub); + zend_string_free_noinline(stub); } RETURN_THROWS(); } @@ -3951,7 +3951,7 @@ PHP_METHOD(Phar, getStub) } zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Unable to read stub"); - zend_string_release_ex_outline(buf, 0); + zend_string_release_ex_noinline(buf, 0); RETURN_THROWS(); } @@ -4020,13 +4020,13 @@ static int serialize_metadata_or_throw(phar_metadata_tracker *tracker, int persi phar_metadata_tracker_free(tracker, persistent); if (UNEXPECTED(EG(exception))) { /* Destructor can throw. */ - zend_string_release_outline(main_metadata_str.s); + zend_string_release_noinline(main_metadata_str.s); return FAILURE; } if (UNEXPECTED(tracker->str)) { zend_throw_exception_ex(phar_ce_PharException, 0, "Metadata unexpectedly changed during setMetadata()"); - zend_string_release_outline(main_metadata_str.s); + zend_string_release_noinline(main_metadata_str.s); return FAILURE; } ZVAL_COPY(&tracker->val, metadata); diff --git a/ext/phar/util.c b/ext/phar/util.c index 37137c3722779..e52090d75dd25 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -1541,7 +1541,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t sig_type, tempsig = sig_len; if (FAILURE == phar_call_openssl_signverify(0, fp, end_of_phar, ZSTR_VAL(pubkey), ZSTR_LEN(pubkey), &sig, &tempsig, sig_type)) { - zend_string_release_ex_outline(pubkey, 0); + zend_string_release_ex_noinline(pubkey, 0); if (error) { spprintf(error, 0, "openssl signature could not be verified"); @@ -1557,7 +1557,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t sig_type, in = BIO_new_mem_buf(ZSTR_VAL(pubkey), ZSTR_LEN(pubkey)); if (NULL == in) { - zend_string_release_ex_outline(pubkey, 0); + zend_string_release_ex_noinline(pubkey, 0); if (error) { spprintf(error, 0, "openssl signature could not be processed"); } diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 973ee0d3127da..96a3bcd632f05 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -2474,7 +2474,7 @@ ZEND_METHOD(ReflectionParameter, __construct) if (UNEXPECTED((ce = zend_lookup_class(name)) == NULL)) { zend_throw_exception_ex(reflection_exception_ptr, 0, "Class \"%s\" does not exist", ZSTR_VAL(name)); - zend_string_release_outline(name); + zend_string_release_noinline(name); RETURN_THROWS(); } zend_string_release(name); @@ -2494,8 +2494,8 @@ ZEND_METHOD(ReflectionParameter, __construct) } else if ((fptr = zend_hash_find_ptr(&ce->function_table, lcname)) == NULL) { zend_throw_exception_ex(reflection_exception_ptr, 0, "Method %s::%s() does not exist", ZSTR_VAL(ce->name), ZSTR_VAL(name)); - zend_string_release_outline(name); - zend_string_release_outline(lcname); + zend_string_release_noinline(name); + zend_string_release_noinline(lcname); RETURN_THROWS(); } zend_string_release(name); @@ -2590,7 +2590,7 @@ ZEND_METHOD(ReflectionParameter, __construct) failure: if (UNEXPECTED(fptr->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) { - zend_string_release_ex_outline(fptr->common.function_name, 0); + zend_string_release_ex_noinline(fptr->common.function_name, 0); zend_free_trampoline(fptr); } if (is_closure) { @@ -5804,7 +5804,7 @@ ZEND_METHOD(ReflectionProperty, setValue) if (Z_TYPE_P(tmp) != IS_NULL && Z_TYPE_P(tmp) != IS_OBJECT) { zend_string *method_name = get_active_function_or_method_name(); zend_error(E_DEPRECATED, "Calling %s() with a 1st argument which is not null or an object is deprecated", ZSTR_VAL(method_name)); - zend_string_release_outline(method_name); + zend_string_release_noinline(method_name); if (UNEXPECTED(EG(exception))) { RETURN_THROWS(); } @@ -5812,7 +5812,7 @@ ZEND_METHOD(ReflectionProperty, setValue) } else { zend_string *method_name = get_active_function_or_method_name(); zend_error(E_DEPRECATED, "Calling %s() with a single argument is deprecated", ZSTR_VAL(method_name)); - zend_string_release_outline(method_name); + zend_string_release_noinline(method_name); if (UNEXPECTED(EG(exception))) { RETURN_THROWS(); } @@ -6937,8 +6937,8 @@ ZEND_METHOD(ReflectionAttribute, newInstance) ZSTR_VAL(attr->data->name), ZSTR_VAL(location), ZSTR_VAL(allowed) ); - zend_string_release_outline(location); - zend_string_release_outline(allowed); + zend_string_release_noinline(location); + zend_string_release_noinline(allowed); RETURN_THROWS(); } diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c index 322002e758589..9e6f5cd0708c1 100644 --- a/ext/session/mod_files.c +++ b/ext/session/mod_files.c @@ -519,7 +519,7 @@ PS_READ_FUNC(files) } else { php_error_docref(NULL, E_WARNING, "Read returned less bytes than requested"); } - zend_string_release_ex_outline (*val, 0); + zend_string_release_ex_noinline(*val, 0); *val = ZSTR_EMPTY_ALLOC(); return FAILURE; } diff --git a/ext/session/session.c b/ext/session/session.c index 3a97b10bf5701..2f414fc163d01 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -1599,7 +1599,7 @@ PHPAPI zend_result php_session_start(void) /* {{{ */ Z_STRLEN_P(data) != 0 && strstr(Z_STRVAL_P(data), PS(extern_referer_chk)) == NULL ) { - zend_string_release_ex_outline(PS(id), 0); + zend_string_release_ex_noinline(PS(id), 0); PS(id) = NULL; } } @@ -2152,7 +2152,7 @@ PHP_FUNCTION(session_set_save_handler) /* If a custom session handler is already set, release relevant info */ if (PS(mod_user_class_name)) { - zend_string_release_outline(PS(mod_user_class_name)); + zend_string_release_noinline(PS(mod_user_class_name)); PS(mod_user_class_name) = NULL; } @@ -2410,7 +2410,7 @@ PHP_FUNCTION(session_create_id) smart_str_append(&id, new_id); zend_string_release_ex(new_id, 0); } else { - smart_str_free_outline(&id); + smart_str_free_noinline(&id); php_error_docref(NULL, E_WARNING, "Failed to create new ID"); RETURN_FALSE; } @@ -2975,7 +2975,7 @@ static PHP_MINFO_FUNCTION(session) /* {{{ */ if (save_handlers.s) { smart_str_0(&save_handlers); php_info_print_table_row(2, "Registered save handlers", ZSTR_VAL(save_handlers.s)); - smart_str_free_outline(&save_handlers); + smart_str_free_noinline(&save_handlers); } else { php_info_print_table_row(2, "Registered save handlers", "none"); } @@ -2983,7 +2983,7 @@ static PHP_MINFO_FUNCTION(session) /* {{{ */ if (ser_handlers.s) { smart_str_0(&ser_handlers); php_info_print_table_row(2, "Registered serializer handlers", ZSTR_VAL(ser_handlers.s)); - smart_str_free_outline(&ser_handlers); + smart_str_free_noinline(&ser_handlers); } else { php_info_print_table_row(2, "Registered serializer handlers", "none"); } diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index d2e29525a5f4a..8d91c7446988e 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -507,7 +507,7 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value, if (node->type == XML_ATTRIBUTE_NODE) { zend_throw_error(NULL, "Cannot create duplicate attribute"); if (value_str) { - zend_string_release_outline(value_str); + zend_string_release_noinline(value_str); } return &EG(error_zval); } diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index c2d29f3aa743d..c371a93fca95a 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -318,7 +318,7 @@ static zend_result spl_filesystem_file_open(spl_filesystem_object *intern, bool intern->type = SPL_FS_FILE; php_stat(intern->file_name, FS_IS_DIR, &tmp); if (Z_TYPE(tmp) == IS_TRUE) { - zend_string_release_outline(intern->u.file.open_mode); + zend_string_release_noinline(intern->u.file.open_mode); intern->u.file.open_mode = NULL; intern->file_name = NULL; zend_throw_exception_ex(spl_ce_LogicException, 0, "Cannot use SplFileObject with directories"); diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 475402aebb4e6..53403ba286ffb 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -1889,7 +1889,7 @@ PHP_FUNCTION(ini_parse_quantity) if (UNEXPECTED(errstr)) { zend_error(E_WARNING, "%s", ZSTR_VAL(errstr)); - zend_string_release_outline(errstr); + zend_string_release_noinline(errstr); } } /* }}} */ diff --git a/ext/standard/exec.c b/ext/standard/exec.c index 85cc410a75a77..c4efdca943d86 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -370,7 +370,7 @@ PHPAPI zend_string *php_escape_shell_cmd(const zend_string *unescaped_cmd) if (UNEXPECTED(y > cmd_max_len + 1)) { zend_value_error("Escaped command exceeds the allowed length of %zu bytes", cmd_max_len); - zend_string_release_ex_outline(cmd, 0); + zend_string_release_ex_noinline(cmd, 0); return ZSTR_EMPTY_ALLOC(); } @@ -460,7 +460,7 @@ PHPAPI zend_string *php_escape_shell_arg(const zend_string *unescaped_arg) if (UNEXPECTED(y > cmd_max_len + 1)) { zend_value_error("Escaped argument exceeds the allowed length of %zu bytes", cmd_max_len); - zend_string_release_ex_outline(cmd, 0); + zend_string_release_ex_noinline(cmd, 0); return ZSTR_EMPTY_ALLOC(); } diff --git a/ext/standard/file.c b/ext/standard/file.c index 18a521ad1fd2f..3ff16b7226faf 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -541,7 +541,7 @@ PHP_FUNCTION(file_put_contents) bytes_written = php_stream_write(stream, ZSTR_VAL(str), ZSTR_LEN(str)); if (bytes_written != ZSTR_LEN(str)) { php_error_docref(NULL, E_WARNING, "Failed to write %zd bytes to %s", ZSTR_LEN(str), filename); - zend_tmp_string_release_outline(t); + zend_tmp_string_release_noinline(t); numbytes = -1; break; } diff --git a/ext/standard/http.c b/ext/standard/http.c index 86ba48fec0a7b..e0078cdac63c9 100644 --- a/ext/standard/http.c +++ b/ext/standard/http.c @@ -250,7 +250,7 @@ static zend_result cache_request_parse_body_option(HashTable *options, zval *opt result = zend_ini_parse_quantity(Z_STR_P(option), &errstr); if (UNEXPECTED(errstr)) { zend_error(E_WARNING, "%s", ZSTR_VAL(errstr)); - zend_string_release_outline(errstr); + zend_string_release_noinline(errstr); } } else if (Z_TYPE_P(option) == IS_LONG) { result = Z_LVAL_P(option); diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index 1bd0a38b22abd..14a14b490b2e8 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -870,7 +870,7 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, if (!s) { s = ZSTR_VAL(resource->path); if (!ZSTR_LEN(resource->path)) { - zend_string_release_ex_outline(resource->path, 0); + zend_string_release_ex_noinline(resource->path, 0); resource->path = ZSTR_INIT_LITERAL("/", 0); s = ZSTR_VAL(resource->path); } else { diff --git a/ext/standard/incomplete_class.c b/ext/standard/incomplete_class.c index 370392808909d..f8fe938a87fdd 100644 --- a/ext/standard/incomplete_class.c +++ b/ext/standard/incomplete_class.c @@ -34,7 +34,7 @@ static void incomplete_class_message(zend_object *object) php_error_docref(NULL, E_WARNING, INCOMPLETE_CLASS_MSG, "access a property", class_name ? ZSTR_VAL(class_name) : "unknown"); if (class_name) { - zend_string_release_ex_outline(class_name, 0); + zend_string_release_ex_noinline(class_name, 0); } } @@ -44,7 +44,7 @@ static void throw_incomplete_class_error(zend_object *object, const char *what) zend_throw_error(NULL, INCOMPLETE_CLASS_MSG, what, class_name ? ZSTR_VAL(class_name) : "unknown"); if (class_name) { - zend_string_release_ex_outline(class_name, 0); + zend_string_release_ex_noinline(class_name, 0); } } diff --git a/ext/standard/info.c b/ext/standard/info.c index 36666afd85e31..29bb6ceded9de 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -58,7 +58,7 @@ static ZEND_COLD int php_info_print_html_esc(const char *str, size_t len) /* {{{ new_str = php_escape_html_entities((const unsigned char *) str, len, 0, ENT_QUOTES, "utf-8"); written = php_output_write(ZSTR_VAL(new_str), ZSTR_LEN(new_str)); - zend_string_free_outline(new_str); + zend_string_free_noinline(new_str); return written; } /* }}} */ @@ -207,7 +207,7 @@ static ZEND_COLD void php_print_gpcse_array(char *name, uint32_t name_length) php_info_print("
");
 					php_info_print_html_esc(ZSTR_VAL(str), ZSTR_LEN(str));
 					php_info_print("
"); - zend_string_release_ex_outline(str, 0); + zend_string_release_ex_noinline(str, 0); } else { zend_print_zval_r(tmp, 0); } @@ -225,7 +225,7 @@ static ZEND_COLD void php_print_gpcse_array(char *name, uint32_t name_length) php_info_print(ZSTR_VAL(str)); } - zend_tmp_string_release_outline(tmp2); + zend_tmp_string_release_noinline(tmp2); } if (!sapi_module.phpinfo_as_text) { php_info_print("\n"); @@ -234,7 +234,7 @@ static ZEND_COLD void php_print_gpcse_array(char *name, uint32_t name_length) } } ZEND_HASH_FOREACH_END(); } - zend_string_efree_outline(key); + zend_string_efree_noinline(key); } /* }}} */ @@ -939,7 +939,7 @@ PHPAPI ZEND_COLD void php_print_info(int flag) zend_html_puts(zend_version, strlen(zend_version)); } php_info_print_box_end(); - zend_string_free_outline(php_uname); + zend_string_free_noinline(php_uname); } zend_ini_sort_entries(); diff --git a/ext/standard/password.c b/ext/standard/password.c index 91a5c98f0a903..77fca9abb157c 100644 --- a/ext/standard/password.c +++ b/ext/standard/password.c @@ -86,15 +86,15 @@ static zend_string* php_password_make_salt(size_t length) /* {{{ */ buffer = zend_string_alloc(length * 3 / 4 + 1, 0); if (FAILURE == php_random_bytes_throw(ZSTR_VAL(buffer), ZSTR_LEN(buffer))) { zend_value_error("Unable to generate salt"); - zend_string_release_ex_outline(buffer, 0); + zend_string_release_ex_noinline(buffer, 0); return NULL; } ret = zend_string_alloc(length, 0); if (php_password_salt_to64(ZSTR_VAL(buffer), ZSTR_LEN(buffer), length, ZSTR_VAL(ret)) == FAILURE) { zend_value_error("Generated salt too short"); - zend_string_release_ex_outline(buffer, 0); - zend_string_release_ex_outline(ret, 0); + zend_string_release_ex_noinline(buffer, 0); + zend_string_release_ex_noinline(ret, 0); return NULL; } zend_string_release_ex(buffer, 0); diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index 7790d29d56ab6..e01397ef605d0 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -511,13 +511,13 @@ static zend_string *get_valid_arg_string(zval *zv, int elem_num) { if (elem_num == 1 && ZSTR_LEN(str) == 0) { zend_value_error("First element must contain a non-empty program name"); - zend_string_release_outline(str); + zend_string_release_noinline(str); return NULL; } if (strlen(ZSTR_VAL(str)) != ZSTR_LEN(str)) { zend_value_error("Command array element %d contains a null byte", elem_num); - zend_string_release_outline(str); + zend_string_release_noinline(str); return NULL; } @@ -868,7 +868,7 @@ static zend_result set_proc_descriptor_to_socket(descriptorspec_item *desc) if (create_socketpair(sock)) { zend_string *err = php_socket_error_str(php_socket_errno()); php_error_docref(NULL, E_WARNING, "Unable to create socket pair: %s", ZSTR_VAL(err)); - zend_string_release_outline(err); + zend_string_release_noinline(err); return FAILURE; } diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index cb6a79a8f2f86..7eef5cde5f408 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -167,7 +167,7 @@ PHP_FUNCTION(stream_socket_client) zend_string *quoted_host = php_addslashes(host); php_error_docref(NULL, E_WARNING, "Unable to connect to %s (%s)", ZSTR_VAL(quoted_host), errstr == NULL ? "Unknown error" : ZSTR_VAL(errstr)); - zend_string_release_ex_outline(quoted_host, 0); + zend_string_release_ex_noinline(quoted_host, 0); } if (hashkey) { @@ -242,7 +242,7 @@ PHP_FUNCTION(stream_socket_server) if (zerrstr && errstr) { ZEND_TRY_ASSIGN_REF_STR(zerrstr, errstr); } else if (errstr) { - zend_string_release_ex_outline(errstr, 0); + zend_string_release_ex_noinline(errstr, 0); } RETURN_FALSE; } @@ -312,7 +312,7 @@ PHP_FUNCTION(stream_socket_accept) php_stream_to_zval(clistream, return_value); } else { if (peername) { - zend_string_release_outline(peername); + zend_string_release_noinline(peername); } php_error_docref(NULL, E_WARNING, "Accept failed: %s", errstr ? ZSTR_VAL(errstr) : "Unknown error"); RETVAL_FALSE; diff --git a/ext/standard/string.c b/ext/standard/string.c index 135176574add1..e3c6a112fd749 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -1367,7 +1367,7 @@ PHP_FUNCTION(str_decrement) if (UNEXPECTED(carry || (ZSTR_VAL(decremented)[0] == '0' && ZSTR_LEN(decremented) > 1))) { if (ZSTR_LEN(decremented) == 1) { - zend_string_release_ex_outline(decremented, /* persistent */ false); + zend_string_release_ex_noinline(decremented, /* persistent */ false); zend_argument_value_error(1, "\"%s\" is out of decrement range", ZSTR_VAL(str)); RETURN_THROWS(); } @@ -1554,7 +1554,7 @@ static void _zend_dirname(zval *return_value, zend_string *str, zend_long levels #endif } else if (levels < 1) { zend_argument_value_error(2, "must be greater than or equal to 1"); - zend_string_efree_outline(ret); + zend_string_efree_noinline(ret); RETURN_THROWS(); } else { /* Some levels up */ @@ -2129,7 +2129,7 @@ PHP_FUNCTION(strripos) haystack_dup = zend_string_tolower(haystack); if (offset >= 0) { if ((size_t)offset > ZSTR_LEN(haystack)) { - zend_string_release_ex_outline(haystack_dup, 0); + zend_string_release_ex_noinline(haystack_dup, 0); zend_argument_value_error(3, "must be contained in argument #1 ($haystack)"); RETURN_THROWS(); } @@ -2137,7 +2137,7 @@ PHP_FUNCTION(strripos) e = ZSTR_VAL(haystack_dup) + ZSTR_LEN(haystack); } else { if (offset < -ZEND_LONG_MAX || (size_t)(-offset) > ZSTR_LEN(haystack)) { - zend_string_release_ex_outline(haystack_dup, 0); + zend_string_release_ex_noinline(haystack_dup, 0); zend_argument_value_error(3, "must be contained in argument #1 ($haystack)"); RETURN_THROWS(); } diff --git a/ext/standard/var.c b/ext/standard/var.c index 21a590757a0ac..1f1cec508f6e9 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -944,7 +944,7 @@ static int php_var_serialize_get_sleep_props( php_error_docref(NULL, E_WARNING, "\"%s\" returned as member variable from __sleep() but does not exist", ZSTR_VAL(name)); - zend_tmp_string_release_outline(tmp_name); + zend_tmp_string_release_noinline(tmp_name); } ZEND_HASH_FOREACH_END(); zend_release_properties(props); diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re index f928b21f5d69e..e8445615ca433 100644 --- a/ext/standard/var_unserializer.re +++ b/ext/standard/var_unserializer.re @@ -1074,7 +1074,7 @@ use_double: } if (*(YYCURSOR) != '"') { - zend_string_efree_outline(str); + zend_string_efree_noinline(str); *p = YYCURSOR; return 0; } @@ -1193,9 +1193,9 @@ object ":" uiv ":" ["] { lc_name = zend_string_tolower(class_name); if(!unserialize_allowed_class(lc_name, var_hash)) { - zend_string_release_ex_outline(lc_name, 0); + zend_string_release_ex_noinline(lc_name, 0); if (!zend_is_valid_class_name(class_name)) { - zend_string_release_ex_outline(class_name, 0); + zend_string_release_ex_noinline(class_name, 0); return 0; } incomplete_class = 1; @@ -1206,7 +1206,7 @@ object ":" uiv ":" ["] { if ((*var_hash)->allowed_classes && ZSTR_HAS_CE_CACHE(class_name)) { ce = ZSTR_GET_CE_CACHE(class_name); if (ce) { - zend_string_release_ex_outline(lc_name, 0); + zend_string_release_ex_noinline(lc_name, 0); break; } } @@ -1215,13 +1215,13 @@ object ":" uiv ":" ["] { if (ce && (ce->ce_flags & ZEND_ACC_LINKED) && !(ce->ce_flags & ZEND_ACC_ANON_CLASS)) { - zend_string_release_ex_outline(lc_name, 0); + zend_string_release_ex_noinline(lc_name, 0); break; } if (!ZSTR_HAS_CE_CACHE(class_name) && !zend_is_valid_class_name(class_name)) { - zend_string_release_ex_outline(lc_name, 0); - zend_string_release_ex_outline(class_name, 0); + zend_string_release_ex_noinline(lc_name, 0); + zend_string_release_ex_noinline(class_name, 0); return 0; } @@ -1231,7 +1231,7 @@ object ":" uiv ":" ["] { BG(serialize_lock)--; zend_string_release_ex(lc_name, 0); if (EG(exception)) { - zend_string_release_ex_outline(class_name, 0); + zend_string_release_ex_noinline(class_name, 0); return 0; } @@ -1256,7 +1256,7 @@ object ":" uiv ":" ["] { zval_ptr_dtor(&retval); if (EG(exception)) { - zend_string_release_ex_outline(class_name, 0); + zend_string_release_ex_noinline(class_name, 0); zval_ptr_dtor(&user_func); return 0; } @@ -1278,7 +1278,7 @@ object ":" uiv ":" ["] { if (ce->ce_flags & ZEND_ACC_NOT_SERIALIZABLE) { zend_throw_exception_ex(NULL, 0, "Unserialization of '%s' is not allowed", ZSTR_VAL(ce->name)); - zend_string_release_ex_outline(class_name, 0); + zend_string_release_ex_noinline(class_name, 0); return 0; } @@ -1296,13 +1296,13 @@ object ":" uiv ":" ["] { if (*p >= max - 2) { zend_error(E_WARNING, "Bad unserialize data"); - zend_string_release_ex_outline(class_name, 0); + zend_string_release_ex_noinline(class_name, 0); return 0; } elements = parse_iv2(*p + 2, p); if (elements < 0 || IS_FAKE_ELEM_COUNT(elements, max - YYCURSOR)) { - zend_string_release_ex_outline(class_name, 0); + zend_string_release_ex_noinline(class_name, 0); return 0; } @@ -1326,12 +1326,12 @@ object ":" uiv ":" ["] { * depending on the serialization format. */ if (ce->serialize != NULL && !has_unserialize) { zend_error(E_WARNING, "Erroneous data format for unserializing '%s'", ZSTR_VAL(ce->name)); - zend_string_release_ex_outline(class_name, 0); + zend_string_release_ex_noinline(class_name, 0); return 0; } if (object_init_ex(rval, ce) == FAILURE) { - zend_string_release_ex_outline(class_name, 0); + zend_string_release_ex_noinline(class_name, 0); return 0; } @@ -1418,8 +1418,8 @@ object ":" uiv ":" ["] { return 1; fail: - zend_string_release_ex_outline(enum_name, 0); - zend_string_release_ex_outline(case_name, 0); + zend_string_release_ex_noinline(enum_name, 0); + zend_string_release_ex_noinline(case_name, 0); return 0; } diff --git a/ext/xml/xml.c b/ext/xml/xml.c index 50d3f39c54ae6..e4e2fe0d9e9c6 100644 --- a/ext/xml/xml.c +++ b/ext/xml/xml.c @@ -1118,7 +1118,7 @@ static bool php_xml_check_string_method_arg( if (status == false) { \ zend_argument_value_error(2, "cannot safely swap to object of class %s as method \"%s\" does not exist, which was set via " handler_set_method, \ ZSTR_VAL(new_this_obj->ce->name), ZSTR_VAL(method_name)); \ - zend_string_release_outline(method_name); \ + zend_string_release_noinline(method_name); \ RETURN_THROWS(); \ } \ zend_string_release(method_name); \ diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 83d7e4928216b..2902b76d8f64b 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -218,7 +218,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, const char *file, s } else if (len > MAXPATHLEN) { php_error_docref(NULL, E_WARNING, "Full extraction path exceed MAXPATHLEN (%i)", MAXPATHLEN); efree(file_dirname_fullpath); - zend_string_release_ex_outline(file_basename, 0); + zend_string_release_ex_noinline(file_basename, 0); CWD_STATE_FREE(new_state.cwd); return 0; } @@ -781,7 +781,7 @@ int php_zip_pcre(zend_string *regexp, char *path, int path_len, zval *return_val if ((path_len + namelist_len + 1) >= MAXPATHLEN) { php_error_docref(NULL, E_WARNING, "add_path string too long (max: %u, %zu given)", MAXPATHLEN - 1, (path_len + namelist_len + 1)); - zend_string_release_ex_outline(namelist[i], 0); + zend_string_release_ex_noinline(namelist[i], 0); break; } @@ -803,7 +803,7 @@ int php_zip_pcre(zend_string *regexp, char *path, int path_len, zval *return_val if (0 != VCWD_STAT(fullpath, &s)) { php_error_docref(NULL, E_WARNING, "Cannot read <%s>", fullpath); - zend_string_release_ex_outline(namelist[i], 0); + zend_string_release_ex_noinline(namelist[i], 0); continue; } diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 7ea65c6be701e..05be251b0c269 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -408,7 +408,7 @@ static zend_string *php_zlib_encode(const char *in_buf, size_t in_len, int encod return out; } - zend_string_efree_outline(out); + zend_string_efree_noinline(out); } php_error_docref(NULL, E_WARNING, "%s", zError(status)); @@ -1022,7 +1022,7 @@ PHP_FUNCTION(inflate_add) case Z_DATA_ERROR: efree(ctx->inflateDict); ctx->inflateDict = NULL; - zend_string_release_ex_outline(out, 0); + zend_string_release_ex_noinline(out, 0); php_error_docref(NULL, E_WARNING, "Dictionary does not match expected dictionary (incorrect adler32 hash)"); RETURN_FALSE; EMPTY_SWITCH_DEFAULT_CASE() @@ -1033,7 +1033,7 @@ PHP_FUNCTION(inflate_add) RETURN_FALSE; } default: - zend_string_release_ex_outline(out, 0); + zend_string_release_ex_noinline(out, 0); php_error_docref(NULL, E_WARNING, "%s", zError(status)); RETURN_FALSE; } @@ -1246,7 +1246,7 @@ PHP_FUNCTION(deflate_add) RETURN_STR(out); break; default: - zend_string_release_ex_outline(out, 0); + zend_string_release_ex_noinline(out, 0); php_error_docref(NULL, E_WARNING, "zlib error (%s)", zError(status)); RETURN_FALSE; } diff --git a/main/main.c b/main/main.c index ff005aec5b238..7bdf979d83ca3 100644 --- a/main/main.c +++ b/main/main.c @@ -870,7 +870,7 @@ PHPAPI ZEND_COLD void php_log_err_with_severity(const char *log_message, int sys php_ignore_value(write(fd, tmp, len)); #endif efree(tmp); - zend_string_free_outline(error_time_str); + zend_string_free_noinline(error_time_str); close(fd); PG(in_error_log) = 0; return; @@ -968,7 +968,7 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ if (PG(html_errors)) { zend_string *replace_buffer = escape_html(ZSTR_VAL(buffer), ZSTR_LEN(buffer)); - zend_string_free_outline(buffer); + zend_string_free_noinline(buffer); if (replace_buffer) { buffer = replace_buffer; @@ -1106,7 +1106,7 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ message = zend_strpprintf_unchecked(0, "%s: %S", origin, buffer); } if (replace_origin) { - zend_string_free_outline(replace_origin); + zend_string_free_noinline(replace_origin); } else { efree(origin); } @@ -1114,10 +1114,10 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ efree(docref_buf); } - zend_string_free_outline(buffer); + zend_string_free_noinline(buffer); zend_error_zstr(type, message); - zend_string_release_outline(message); + zend_string_release_noinline(message); } /* }}} */ @@ -1367,7 +1367,7 @@ static ZEND_COLD void php_error_cb(int orig_type, zend_string *error_filename, c if (type == E_ERROR || type == E_PARSE) { zend_string *buf = escape_html(ZSTR_VAL(message), ZSTR_LEN(message)); php_printf("%s
\n%s: %s in %s on line %" PRIu32 "
\n%s", STR_PRINT(prepend_string), error_type_str, ZSTR_VAL(buf), ZSTR_VAL(error_filename), error_lineno, STR_PRINT(append_string)); - zend_string_free_outline(buf); + zend_string_free_noinline(buf); } else { php_printf_unchecked("%s
\n%s: %S in %s on line %" PRIu32 "
\n%s", STR_PRINT(prepend_string), error_type_str, message, ZSTR_VAL(error_filename), error_lineno, STR_PRINT(append_string)); } diff --git a/main/network.c b/main/network.c index 8d8cb889850bc..41abeb6829342 100644 --- a/main/network.c +++ b/main/network.c @@ -206,7 +206,7 @@ PHPAPI int php_network_getaddresses(const char *host, int socktype, struct socka if (error_string) { /* free error string received during previous iteration (if any) */ if (*error_string) { - zend_string_release_ex_outline(*error_string, 0); + zend_string_release_ex_noinline(*error_string, 0); } *error_string = strpprintf(0, "php_network_getaddresses: getaddrinfo for %s failed (null result pointer) errno=%d", host, errno); php_error_docref(NULL, E_WARNING, "%s", ZSTR_VAL(*error_string)); @@ -559,7 +559,7 @@ PHPAPI int php_network_parse_network_address_with_port(const char *addr, zend_lo if (n == 0) { if (errstr) { php_error_docref(NULL, E_WARNING, "Failed to resolve `%s': %s", tmp, ZSTR_VAL(errstr)); - zend_string_release_ex_outline(errstr, 0); + zend_string_release_ex_noinline(errstr, 0); } goto out; } diff --git a/main/streams/streams.c b/main/streams/streams.c index 7d06c35fa4405..62bd898ff95f3 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -2222,7 +2222,7 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mod if ((options & STREAM_USE_URL) && (!wrapper || !wrapper->is_url)) { php_error_docref(NULL, E_WARNING, "This function may only be used against URLs"); if (resolved_path) { - zend_string_release_ex_outline(resolved_path, 0); + zend_string_release_ex_noinline(resolved_path, 0); } return NULL; } diff --git a/main/streams/transports.c b/main/streams/transports.c index 3fc28a044c5e7..501435eee4305 100644 --- a/main/streams/transports.c +++ b/main/streams/transports.c @@ -46,7 +46,7 @@ PHPAPI int php_stream_xport_unregister(const char *protocol) #define ERR_RETURN(out_err, local_err, fmt) \ if (out_err) { *out_err = local_err; } \ else { php_error_docref(NULL, E_WARNING, fmt, local_err ? ZSTR_VAL(local_err) : "Unspecified error"); \ - if (local_err) { zend_string_release_ex_outline(local_err, 0); local_err = NULL; } \ + if (local_err) { zend_string_release_ex_noinline(local_err, 0); local_err = NULL; } \ } PHPAPI php_stream *_php_stream_xport_create(const char *name, size_t namelen, int options, diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 08261ba032505..b7545ec18cfd1 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -993,7 +993,7 @@ static int do_cli(int argc, char **argv) /* {{{ */ zval argn, argi; if (!exec_run && script_file) { - zend_string_release_ex_outline(file_handle.filename, 0); + zend_string_release_ex_noinline(file_handle.filename, 0); file_handle.filename = NULL; } From 07073cc9b7492a4e89b1eaac4fe7848676111083 Mon Sep 17 00:00:00 2001 From: Levi Morrison Date: Mon, 29 Jul 2024 13:54:40 -0600 Subject: [PATCH 06/12] Rename _OUTLINE macros too --- Zend/zend_exceptions.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index 8390a4939e002..0bf203c9064a0 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -403,9 +403,9 @@ ZEND_METHOD(ErrorException, __construct) #define GET_PROPERTY_SILENT(object, id) \ zend_read_property_ex(i_get_exception_base(Z_OBJ_P(object)), Z_OBJ_P(object), ZSTR_KNOWN(id), 1, &rv) -#define GET_PROPERTY_OUTLINE(object, id) \ +#define GET_PROPERTY_NOINLINE(object, id) \ zend_read_property_ex(zend_get_exception_base(Z_OBJ_P(object)), Z_OBJ_P(object), ZSTR_KNOWN(id), 0, &rv) -#define GET_PROPERTY_SILENT_OUTLINE(object, id) \ +#define GET_PROPERTY_SILENT_NOINLINE(object, id) \ zend_read_property_ex(zend_get_exception_base(Z_OBJ_P(object)), Z_OBJ_P(object), ZSTR_KNOWN(id), 1, &rv) /* {{{ Get the file in which the exception occurred */ @@ -905,9 +905,9 @@ ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *ex, int severit ce_exception = ex->ce; EG(exception) = NULL; if (ce_exception == zend_ce_parse_error || ce_exception == zend_ce_compile_error) { - zend_string *message = zval_get_string(GET_PROPERTY_OUTLINE(&exception, ZEND_STR_MESSAGE)); - zend_string *file = zval_get_string(GET_PROPERTY_SILENT_OUTLINE(&exception, ZEND_STR_FILE)); - zend_long line = zval_get_long(GET_PROPERTY_SILENT_OUTLINE(&exception, ZEND_STR_LINE)); + zend_string *message = zval_get_string(GET_PROPERTY_NOINLINE(&exception, ZEND_STR_MESSAGE)); + zend_string *file = zval_get_string(GET_PROPERTY_SILENT_NOINLINE(&exception, ZEND_STR_FILE)); + zend_long line = zval_get_long(GET_PROPERTY_SILENT_NOINLINE(&exception, ZEND_STR_LINE)); int type = (ce_exception == zend_ce_parse_error ? E_PARSE : E_COMPILE_ERROR) | E_DONT_BAIL; zend_observer_error_notify(type, file, line, message); @@ -936,8 +936,8 @@ ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *ex, int severit ZVAL_OBJ(&zv, EG(exception)); /* do the best we can to inform about the inner exception */ if (instanceof_function(ce_exception, zend_ce_exception) || instanceof_function(ce_exception, zend_ce_error)) { - file = zval_get_string(GET_PROPERTY_SILENT_OUTLINE(&zv, ZEND_STR_FILE)); - line = zval_get_long(GET_PROPERTY_SILENT_OUTLINE(&zv, ZEND_STR_LINE)); + file = zval_get_string(GET_PROPERTY_SILENT_NOINLINE(&zv, ZEND_STR_FILE)); + line = zval_get_long(GET_PROPERTY_SILENT_NOINLINE(&zv, ZEND_STR_LINE)); } zend_error_va(E_WARNING, (file && ZSTR_LEN(file) > 0) ? file : NULL, line, @@ -949,9 +949,9 @@ ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *ex, int severit } } - str = zval_get_string(GET_PROPERTY_SILENT_OUTLINE(&exception, ZEND_STR_STRING)); - file = zval_get_string(GET_PROPERTY_SILENT_OUTLINE(&exception, ZEND_STR_FILE)); - line = zval_get_long(GET_PROPERTY_SILENT_OUTLINE(&exception, ZEND_STR_LINE)); + str = zval_get_string(GET_PROPERTY_SILENT_NOINLINE(&exception, ZEND_STR_STRING)); + file = zval_get_string(GET_PROPERTY_SILENT_NOINLINE(&exception, ZEND_STR_FILE)); + line = zval_get_long(GET_PROPERTY_SILENT_NOINLINE(&exception, ZEND_STR_LINE)); zend_error_va(severity | E_DONT_BAIL, (file && ZSTR_LEN(file) > 0) ? file : NULL, line, From 9d5dc4b86e22d3dc21eb07978f280bf93bb2a09c Mon Sep 17 00:00:00 2001 From: Levi Morrison Date: Fri, 9 Aug 2024 10:23:02 -0600 Subject: [PATCH 07/12] fix zend_string_copy --- Zend/zend_string.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_string.h b/Zend/zend_string.h index 0bb294c50d404..e2c393bf278be 100644 --- a/Zend/zend_string.h +++ b/Zend/zend_string.h @@ -219,7 +219,7 @@ ZEND_API zend_always_inline zend_string *zend_string_init_fast(const char *str, } } -ZEND_API inline zend_string *zend_string_copy(zend_string *s) +ZEND_API zend_always_inline zend_string *zend_string_copy(zend_string *s) { if (!ZSTR_IS_INTERNED(s)) { GC_ADDREF(s); From 5d3e48ff1ab00b844f4b930c999a60b130359cdf Mon Sep 17 00:00:00 2001 From: Levi Morrison Date: Fri, 9 Aug 2024 10:44:54 -0600 Subject: [PATCH 08/12] remove 2 more inlines from funcs that don't inline --- Zend/Optimizer/zend_inference.c | 2 +- Zend/zend_generators.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Zend/Optimizer/zend_inference.c b/Zend/Optimizer/zend_inference.c index b7fa1e837d096..0e443f46c2b29 100644 --- a/Zend/Optimizer/zend_inference.c +++ b/Zend/Optimizer/zend_inference.c @@ -761,7 +761,7 @@ static inline zend_long safe_shift_left(zend_long n, zend_long s) { return (zend_long) ((zend_ulong) n << (zend_ulong) s); } -static inline bool shift_left_overflows(zend_long n, zend_long s) { +static bool shift_left_overflows(zend_long n, zend_long s) { /* This considers shifts that shift in the sign bit to be overflowing as well */ if (n >= 0) { return s >= SIZEOF_ZEND_LONG * 8 - 1 || safe_shift_left(n, s) < n; diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index bce1fbe01dd68..f9e07b31a2867 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -214,7 +214,7 @@ static zend_always_inline void clear_link_to_root(zend_generator *generator) { /* In the context of zend_generator_dtor_storage during shutdown, check if * the intermediate node 'generator' is running in a fiber */ -static inline bool check_node_running_in_fiber(zend_generator *generator) { +static bool check_node_running_in_fiber(zend_generator *generator) { ZEND_ASSERT(EG(flags) & EG_FLAGS_IN_SHUTDOWN); ZEND_ASSERT(generator->execute_data); From 4e9b4fa2b498efad75b5563b94ab6728f38c3583 Mon Sep 17 00:00:00 2001 From: Levi Morrison Date: Fri, 9 Aug 2024 11:01:41 -0600 Subject: [PATCH 09/12] fix comment --- Zend/zend_string.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_string.h b/Zend/zend_string.h index e2c393bf278be..65a47aa5b1f7f 100644 --- a/Zend/zend_string.h +++ b/Zend/zend_string.h @@ -332,7 +332,7 @@ static zend_always_inline zend_string *zend_string_truncate(zend_string *s, size return ret; } -/* These functions have noinline variants */ +/* These functions have noinline variants {{{ */ static zend_always_inline void zend_string_free(zend_string *s) { if (!ZSTR_IS_INTERNED(s)) { From 1910740f6544bcf65656656405533c2d3c5c1752 Mon Sep 17 00:00:00 2001 From: Levi Morrison Date: Fri, 9 Aug 2024 11:22:04 -0600 Subject: [PATCH 10/12] use noinline in another place --- ext/hash/hash_xxhash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/hash/hash_xxhash.c b/ext/hash/hash_xxhash.c index 07ac801d99e95..2dd220d67a448 100644 --- a/ext/hash/hash_xxhash.c +++ b/ext/hash/hash_xxhash.c @@ -192,7 +192,7 @@ zend_always_inline static void _PHP_XXH3_Init(PHP_XXH3_64_CTX *ctx, HashTable *a } size_t len = ZSTR_LEN(secret_string); if (len < PHP_XXH3_SECRET_SIZE_MIN) { - zend_string_release(secret_string); + zend_string_release_noinline(secret_string); zend_throw_error(NULL, "%s: Secret length must be >= %u bytes, %zu bytes passed", algo_name, XXH3_SECRET_SIZE_MIN, len); return; } From 027c4519be1ea1c4b863a48ce083d6138ff71bd8 Mon Sep 17 00:00:00 2001 From: Levi Morrison Date: Wed, 14 Aug 2024 12:28:52 -0600 Subject: [PATCH 11/12] See if zend_string_addref exists in the dll --- .github/workflows/push.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 086c5cc0347bd..83ae0e2c47161 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -259,6 +259,8 @@ jobs: run: .github/scripts/windows/build.bat - name: Test run: .github/scripts/windows/test.bat + - name: Check ZEND_API zend_always_inline symbol + run: dumpbin /exports x64\Release_TS\php8ts.dll | grep zend_string_addref BENCHMARKING: name: BENCHMARKING if: github.repository == 'php/php-src' || github.event_name == 'pull_request' From 161cf3d94083f6441f8764dc39865c6f661d27d8 Mon Sep 17 00:00:00 2001 From: Levi Morrison Date: Wed, 14 Aug 2024 13:31:48 -0600 Subject: [PATCH 12/12] Revert "See if zend_string_addref exists in the dll" This reverts commit 027c4519be1ea1c4b863a48ce083d6138ff71bd8. --- .github/workflows/push.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 83ae0e2c47161..086c5cc0347bd 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -259,8 +259,6 @@ jobs: run: .github/scripts/windows/build.bat - name: Test run: .github/scripts/windows/test.bat - - name: Check ZEND_API zend_always_inline symbol - run: dumpbin /exports x64\Release_TS\php8ts.dll | grep zend_string_addref BENCHMARKING: name: BENCHMARKING if: github.repository == 'php/php-src' || github.event_name == 'pull_request'