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_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/Optimizer/zend_optimizer.c b/Zend/Optimizer/zend_optimizer.c index 823277694b4ff..fb4a7bedd6a6a 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..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(message); + zend_string_release_noinline(message); } static ZEND_COLD void get_filename_lineno(int type, zend_string **filename, uint32_t *lineno) { @@ -2047,3 +2047,11 @@ 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_delref(zend_refcounted_h *p); +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_API.c b/Zend/zend_API.c index 229af38c2a8c4..6062b9ca26145 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_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(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(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(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(func_name); + zend_string_release_noinline(func_name); if (type_str) { - zend_string_release(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(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(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(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(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 ab67dd5717e69..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(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 5ecda76870452..c778f7dd5dbe7 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_noinline(decl->name, 0); } if (decl->doc_comment) { - zend_string_release_ex(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_builtin_functions.c b/Zend/zend_builtin_functions.c index 0335d2498acca..9251c1698681e 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1053,7 +1053,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; @@ -1368,7 +1368,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_compile.c b/Zend/zend_compile.c index 9e736ea1b37ad..f8324117974d5 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -4116,7 +4116,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_noinline(name, 0); return FAILURE; } @@ -4285,7 +4285,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_noinline(name, 0); return SUCCESS; } } @@ -7538,7 +7538,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_noinline(func_name); } } else { if (list->children == 0) { @@ -7674,7 +7674,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_noinline(func_name); } /* Regardless of whether we issue a deprecation, convert this parameter into @@ -10742,7 +10742,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_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 9fa98e74e8ccb..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(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 4af4ec2cfc059..0bf203c9064a0 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_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_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 */ ZEND_METHOD(Exception, getFile) { @@ -844,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(msg_str); + zend_string_release_noinline(msg_str); } return ex; } @@ -884,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(message); + zend_string_release_noinline(message); va_end(args); } /* }}} */ @@ -900,16 +905,16 @@ 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_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); zend_error_cb(type, file, line, message); - zend_string_release_ex(file, 0); - zend_string_release_ex(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; @@ -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_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, @@ -940,20 +945,20 @@ 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_noinline(file, 0); } } - 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_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, "Uncaught %S\n thrown", str); - zend_string_release_ex(str, 0); - zend_string_release_ex(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 602bb3b0e79f5..967a5e9e1346f 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_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(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(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(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(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(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(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(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(&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(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(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(since); - zend_string_release(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(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(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(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(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(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(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(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(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(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(str); + zend_string_efree_noinline(str); ZVAL_NULL(result); return; } @@ -3643,8 +3643,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_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) { @@ -3655,7 +3655,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_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) { @@ -3670,8 +3670,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_noinline(type1_str); + zend_string_release_noinline(type2_str); } /* 1: valid, 0: invalid, -1: may be valid after type coercion */ @@ -4857,7 +4857,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_noinline(fbc->common.function_name, 0); zend_free_trampoline(fbc); } return NULL; @@ -4874,7 +4874,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_noinline(lcname, 0); return NULL; } zend_string_release_ex(lcname, 0); @@ -4985,7 +4985,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_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 f1f5bfc84516f..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(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(lc_name, 0); + zend_string_release_ex_noinline(lc_name, 0); return NULL; } diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index 3ec308246c7c1..4a4b376f2b00d 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); diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index b43544766b848..09e34c859d632 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_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(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(child_prototype); - zend_string_efree(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 b4c0722e3e946..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(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(errstr); + zend_string_release_noinline(errstr); } return retval; diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index 4551d26a17e79..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(copy); + zend_string_efree_noinline(copy); RETURN_TOKEN(T_ERROR); } diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 5331244731cac..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(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(zstr); + zend_string_release_noinline(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_noinline(zend_string *tmp) +{ + zend_tmp_string_release(tmp); +} diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 45f9820c41b16..b817f68dc7006 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_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 ade137a4bb6c3..81dbafc0b8878 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_noinline(smart_str *str) +{ + smart_str_free(str); +} diff --git a/Zend/zend_smart_str.h b/Zend/zend_smart_str.h index affbb5c50ac2e..08dae6e0d6caf 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_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 7a00171d2c84d..a94bb022ec006 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__) @@ -528,3 +530,41 @@ size_t strlcat (char *__restrict dest, const char *restrict src, size_t n) return result; } #endif + +ZEND_API void zend_string_free_noinline(zend_string *s) +{ + zend_string_free(s); +} + +ZEND_API void zend_string_efree_noinline(zend_string *s) +{ + zend_string_efree(s); +} + +ZEND_API void zend_string_release_noinline(zend_string *s) +{ + zend_string_release(s); +} + +ZEND_API void zend_string_release_ex_noinline(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_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 ad6c5e1ee38bf..b515e6c195fc5 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_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]; ZEND_API extern zend_string **zend_known_strings; @@ -136,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); @@ -155,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); @@ -163,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); @@ -171,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); @@ -182,27 +188,27 @@ static zend_always_inline zend_string *zend_string_alloc(size_t len, bool persis return ret; } -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_init(const char *str, size_t len, bool persistent) { - zend_string *ret = (zend_string *)safe_pemalloc(n, m, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(l)), persistent); + zend_string *ret = zend_string_alloc(len, persistent); - GC_SET_REFCOUNT(ret, 1); - GC_TYPE_INFO(ret) = GC_STRING | ((persistent ? IS_STR_PERSISTENT : 0) << GC_FLAGS_SHIFT); - ZSTR_H(ret) = 0; - ZSTR_LEN(ret) = (n * m) + l; + memcpy(ZSTR_VAL(ret), str, len); + ZSTR_VAL(ret)[len] = '\0'; return ret; } -static zend_always_inline zend_string *zend_string_init(const char *str, size_t len, 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_alloc(len, persistent); + zend_string *ret = (zend_string *)safe_pemalloc(n, m, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(l)), persistent); - memcpy(ZSTR_VAL(ret), str, len); - ZSTR_VAL(ret)[len] = '\0'; + GC_SET_REFCOUNT(ret, 1); + GC_TYPE_INFO(ret) = GC_STRING | ((persistent ? IS_STR_PERSISTENT : 0) << GC_FLAGS_SHIFT); + ZSTR_H(ret) = 0; + ZSTR_LEN(ret) = (n * m) + l; 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); @@ -213,7 +219,7 @@ 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) +ZEND_API zend_always_inline zend_string *zend_string_copy(zend_string *s) { if (!ZSTR_IS_INTERNED(s)) { GC_ADDREF(s); @@ -221,7 +227,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; @@ -230,7 +236,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)) { @@ -243,7 +249,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; @@ -263,32 +269,32 @@ static zend_always_inline zend_string *zend_string_realloc(zend_string *s, size_ return ret; } -static zend_always_inline zend_string *zend_string_extend(zend_string *s, size_t len, 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); @@ -298,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)) { @@ -364,32 +372,33 @@ 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 d33f8a33bcbe6..f992d06a5f883 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)) @@ -1306,19 +1308,21 @@ 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; } -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)) { @@ -1334,11 +1338,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 55fdb7d46582b..edd6401d6625d 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_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(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(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(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(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(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 16455b6e0cd58..a117db6e78b75 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_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(name); + zend_string_release_noinline(name); } else { if (have_named_params) { zend_throw_error(NULL, @@ -3947,7 +3947,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_noinline(call->func->common.function_name, 0); zend_free_trampoline(call->func); } zend_vm_stack_free_call_frame(call); @@ -4130,7 +4130,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_noinline(call->func->common.function_name, 0); zend_free_trampoline(call->func); } zend_vm_stack_free_call_frame(call); @@ -4326,7 +4326,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_noinline(call->func->common.function_name, 0); zend_free_trampoline(call->func); } zend_vm_stack_free_call_frame(call); @@ -7048,7 +7048,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_noinline(op1_str, 0); break; } } @@ -7060,7 +7060,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_noinline(op2_str, 0); break; } } @@ -9612,7 +9612,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_noinline(op1_str, 0); break; } } @@ -9624,7 +9624,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_noinline(op2_str, 0); break; } } @@ -12094,7 +12094,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_noinline(op1_str, 0); break; } } @@ -12106,7 +12106,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_noinline(op2_str, 0); break; } } @@ -16487,7 +16487,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_noinline(op1_str, 0); break; } } @@ -16499,7 +16499,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_noinline(op2_str, 0); break; } } @@ -17980,7 +17980,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_noinline(op1_str, 0); break; } } @@ -17992,7 +17992,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_noinline(op2_str, 0); break; } } @@ -19387,7 +19387,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_noinline(op1_str, 0); break; } } @@ -19399,7 +19399,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_noinline(op2_str, 0); break; } } @@ -20573,7 +20573,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_noinline(rope[i], 0); } ZVAL_UNDEF(EX_VAR(opline->result.var)); HANDLE_EXCEPTION(); @@ -21050,7 +21050,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_noinline(rope[i], 0); } ZVAL_UNDEF(EX_VAR(opline->result.var)); HANDLE_EXCEPTION(); @@ -21907,7 +21907,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_noinline(rope[i], 0); } ZVAL_UNDEF(EX_VAR(opline->result.var)); HANDLE_EXCEPTION(); @@ -44455,7 +44455,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_noinline(op1_str, 0); break; } } @@ -44467,7 +44467,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_noinline(op2_str, 0); break; } } @@ -48320,7 +48320,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_noinline(op1_str, 0); break; } } @@ -48332,7 +48332,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_noinline(op2_str, 0); break; } } @@ -53886,7 +53886,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_noinline(op1_str, 0); break; } } @@ -53898,7 +53898,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_noinline(op2_str, 0); break; } } diff --git a/ext/date/php_date.c b/ext/date/php_date.c index bfff54c2b6d23..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(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(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(func); + zend_string_release_noinline(func); return false; } diff --git a/ext/dom/document.c b/ext/dom/document.c index 6e64fe497b025..a53ce5d712480 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -203,7 +203,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_noinline(str, 0); return FAILURE; } } diff --git a/ext/fileinfo/libmagic/apprentice.c b/ext/fileinfo/libmagic/apprentice.c index a4ead7fbce6e6..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(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 3d4bf1d4ba5ef..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(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(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(pattern); + zend_string_release_noinline(pattern); return -1; } } else { 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/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; } diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index 4241b7c2887fb..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(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 9f91d39594ec7..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(&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/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/mbstring/mbstring.c b/ext/mbstring/mbstring.c index a9670684cbda0..8558d212f85d3 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_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(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(ini_name, 0); + zend_string_release_ex_noinline(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_noinline(haystack_u8); + zend_string_free_noinline(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_noinline(trimmed); } if (width < 0) { diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 0bd55d319e31e..f324f4ad0865d 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; @@ -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_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(str); + zend_string_release_noinline(str); str = NULL; } zend_shared_alloc_unlock(); @@ -4025,7 +4025,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_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 8ed378d7552b0..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(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(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(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(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(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(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(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 4c16279d81856..4bf8102bd65ea 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_noinline(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_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(tag_str, 0); - zend_string_release_ex(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(outbuf, 0); + zend_string_release_ex_noinline(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_noinline(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..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(&ebuf); + smart_str_free_noinline(&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_noinline(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_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 ac0ad2c378be2..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(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(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(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(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(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(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(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 4674e901da5a5..59c41143cbb99 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"); @@ -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_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(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(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(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(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(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(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(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(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 e2c686ed691ff..5a0773d842651 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_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 9d16512ec5d13..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(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(method_name); + zend_string_release_noinline(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_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(buf, 0); + zend_string_release_ex_noinline(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_noinline(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_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 aed95e635dd8c..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(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(pubkey, 0); + zend_string_release_ex_noinline(pubkey, 0); if (error) { spprintf(error, 0, "openssl signature could not be processed"); } 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/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 0956bbc1acf70..96a3bcd632f05 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_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(name); - zend_string_release(lcname); + zend_string_release_noinline(name); + zend_string_release_noinline(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_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(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(method_name); + zend_string_release_noinline(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_noinline(location); + zend_string_release_noinline(allowed); RETURN_THROWS(); } diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c index 74e77973405b2..9e6f5cd0708c1 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_noinline(*val, 0); *val = ZSTR_EMPTY_ALLOC(); return FAILURE; } diff --git a/ext/session/session.c b/ext/session/session.c index aa9883ab1df33..56a2841eb78cf 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -1605,7 +1605,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_noinline(PS(id), 0); PS(id) = NULL; } } @@ -2158,7 +2158,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_noinline(PS(mod_user_class_name)); PS(mod_user_class_name) = NULL; } @@ -2416,7 +2416,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_noinline(&id); php_error_docref(NULL, E_WARNING, "Failed to create new ID"); RETURN_FALSE; } @@ -2981,7 +2981,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_noinline(&save_handlers); } else { php_info_print_table_row(2, "Registered save handlers", "none"); } @@ -2989,7 +2989,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_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 8a12d430d476f..ec98c80f4a377 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -519,7 +519,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_noinline(value_str); } return &EG(error_zval); } @@ -905,7 +905,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; @@ -1400,7 +1400,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 989f84f1fdd1c..d301771c2a66a 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(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/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..53403ba286ffb 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_noinline(errstr); } } /* }}} */ diff --git a/ext/standard/exec.c b/ext/standard/exec.c index 5b3ba60e5fdea..c4efdca943d86 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_noinline(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_noinline(cmd, 0); return ZSTR_EMPTY_ALLOC(); } diff --git a/ext/standard/file.c b/ext/standard/file.c index 677fd74d225cf..6d6695ee758a5 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_noinline(t); numbytes = -1; break; } 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; diff --git a/ext/standard/http.c b/ext/standard/http.c index 7a4a58755d894..e0078cdac63c9 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_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 edc3327aa1150..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(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 228e03fbe863e..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(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(class_name, 0); + zend_string_release_ex_noinline(class_name, 0); } } diff --git a/ext/standard/info.c b/ext/standard/info.c index 2da58f3cccef6..170825a7b61ba 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -58,7 +58,7 @@ static ZEND_COLD size_t 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_noinline(new_str); return written; } /* }}} */ @@ -207,7 +207,7 @@ static ZEND_COLD void php_print_gpcse_array(char *name, size_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_noinline(str, 0); } else { zend_print_zval_r(tmp, 0); } @@ -225,7 +225,7 @@ static ZEND_COLD void php_print_gpcse_array(char *name, size_t name_length) php_info_print(ZSTR_VAL(str)); } - zend_tmp_string_release(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, size_t name_length) } } ZEND_HASH_FOREACH_END(); } - zend_string_efree(key); + zend_string_efree_noinline(key); } /* }}} */ @@ -930,7 +930,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_noinline(php_uname); } zend_ini_sort_entries(); diff --git a/ext/standard/password.c b/ext/standard/password.c index 1e647bb301c3b..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(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(buffer, 0); - zend_string_release_ex(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 2f7b85124f53b..d23244fc7102c 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -514,13 +514,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_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(str); + zend_string_release_noinline(str); return NULL; } @@ -871,7 +871,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_noinline(err); return FAILURE; } diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index 1929075b60b71..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(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(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(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 23c34df958b51..438654c10422a 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_noinline(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_noinline(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_noinline(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_noinline(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/url_scanner_ex.re b/ext/standard/url_scanner_ex.re index 305be39d8780f..4953115485abd 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) { @@ -724,7 +724,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, /* is_session */ false); } -static inline void php_url_scanner_add_var_impl(const char *name, size_t name_len, const char *value, size_t value_len, bool encode, bool is_session) +static void php_url_scanner_add_var_impl(const char *name, size_t name_len, const char *value, size_t value_len, bool encode, bool is_session) { smart_str sname = {0}; smart_str svalue = {0}; @@ -837,7 +837,7 @@ PHPAPI zend_result php_url_scanner_reset_vars(void) } -static inline zend_result php_url_scanner_reset_var_impl(zend_string *name, int encode, bool is_session) +static zend_result php_url_scanner_reset_var_impl(zend_string *name, int encode, bool is_session) { char *start, *end, *limit; size_t separator_len; diff --git a/ext/standard/var.c b/ext/standard/var.c index dd2bd86d91ee8..1f1cec508f6e9 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; @@ -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_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 78d102eefda6c..25db5b124a587 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_noinline(str); *p = YYCURSOR; return 0; } @@ -1196,9 +1196,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_noinline(lc_name, 0); if (!zend_is_valid_class_name(class_name)) { - zend_string_release_ex(class_name, 0); + zend_string_release_ex_noinline(class_name, 0); return 0; } incomplete_class = 1; @@ -1209,7 +1209,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_noinline(lc_name, 0); break; } } @@ -1218,13 +1218,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_noinline(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_noinline(lc_name, 0); + zend_string_release_ex_noinline(class_name, 0); return 0; } @@ -1234,7 +1234,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_noinline(class_name, 0); return 0; } @@ -1259,7 +1259,7 @@ object ":" uiv ":" ["] { zval_ptr_dtor(&retval); if (EG(exception)) { - zend_string_release_ex(class_name, 0); + zend_string_release_ex_noinline(class_name, 0); zval_ptr_dtor(&user_func); return 0; } @@ -1281,7 +1281,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_noinline(class_name, 0); return 0; } @@ -1299,13 +1299,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_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(class_name, 0); + zend_string_release_ex_noinline(class_name, 0); return 0; } @@ -1329,12 +1329,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_noinline(class_name, 0); return 0; } if (object_init_ex(rval, ce) == FAILURE) { - zend_string_release_ex(class_name, 0); + zend_string_release_ex_noinline(class_name, 0); return 0; } @@ -1421,8 +1421,8 @@ object ":" uiv ":" ["] { return 1; fail: - zend_string_release_ex(enum_name, 0); - zend_string_release_ex(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 d1965b7bb53dc..aeec59a20a564 100644 --- a/ext/xml/xml.c +++ b/ext/xml/xml.c @@ -1119,7 +1119,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_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 342d6aabe7240..1096512c17b16 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_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(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(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 3c9f72e82bc2f..05be251b0c269 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_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(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(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(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/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 15a9f9a59b2be..5e1411214ac80 100644 --- a/main/main.c +++ b/main/main.c @@ -911,7 +911,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_noinline(error_time_str); close(fd); PG(in_error_log) = 0; return; @@ -1009,7 +1009,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_noinline(buffer); if (replace_buffer) { buffer = replace_buffer; @@ -1147,7 +1147,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_noinline(replace_origin); } else { efree(origin); } @@ -1155,10 +1155,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_noinline(buffer); zend_error_zstr(type, message); - zend_string_release(message); + zend_string_release_noinline(message); } /* }}} */ @@ -1408,7 +1408,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