Skip to content

Commit 15d1240

Browse files
committed
Add outline versions of zend_string free/release APIs
1 parent 32fe9bc commit 15d1240

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+345
-290
lines changed

Zend/Optimizer/dfa_pass.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ static bool safe_instanceof(zend_class_entry *ce1, zend_class_entry *ce2) {
265265
return instanceof_function(ce1, ce2);
266266
}
267267

268-
static inline bool can_elide_list_type(
268+
static bool can_elide_list_type(
269269
const zend_script *script, const zend_op_array *op_array,
270270
const zend_ssa_var_info *use_info, zend_type type)
271271
{

Zend/Optimizer/zend_optimizer.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ static inline int zend_optimizer_add_literal_string(zend_op_array *op_array, zen
247247
return zend_optimizer_add_literal(op_array, &zv);
248248
}
249249

250-
static inline void drop_leading_backslash(zval *val) {
250+
static void drop_leading_backslash(zval *val) {
251251
if (Z_STRVAL_P(val)[0] == '\\') {
252252
zend_string *str = zend_string_init(Z_STRVAL_P(val) + 1, Z_STRLEN_P(val) - 1, 0);
253253
zval_ptr_dtor_nogc(val);

Zend/zend.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,7 @@ static ZEND_COLD void zend_error_va_list(
15731573
{
15741574
zend_string *message = zend_vstrpprintf(0, format, args);
15751575
zend_error_zstr_at(orig_type, error_filename, error_lineno, message);
1576-
zend_string_release(message);
1576+
zend_string_release_outline(message);
15771577
}
15781578

15791579
static ZEND_COLD void get_filename_lineno(int type, zend_string **filename, uint32_t *lineno) {
@@ -2047,3 +2047,10 @@ ZEND_API void zend_alloc_ce_cache(zend_string *type_name)
20472047
GC_ADD_FLAGS(type_name, IS_STR_CLASS_NAME_MAP_PTR);
20482048
GC_SET_REFCOUNT(type_name, ret);
20492049
}
2050+
2051+
2052+
ZEND_API extern inline uint32_t zend_gc_refcount(const zend_refcounted_h *p);
2053+
ZEND_API extern inline uint32_t zend_gc_delref(zend_refcounted_h *p);
2054+
ZEND_API extern zend_always_inline uint8_t zval_gc_type(uint32_t gc_type_info);
2055+
ZEND_API extern zend_always_inline uint32_t zval_gc_flags(uint32_t gc_type_info);
2056+
ZEND_API extern zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info);

Zend/zend_API.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ ZEND_API ZEND_COLD void zend_wrong_property_read(zval *object, zval *property)
104104
zend_string *tmp_property_name;
105105
zend_string *property_name = zval_get_tmp_string(property, &tmp_property_name);
106106
zend_error(E_WARNING, "Attempt to read property \"%s\" on %s", ZSTR_VAL(property_name), zend_zval_value_name(object));
107-
zend_tmp_string_release(tmp_property_name);
107+
zend_tmp_string_release_outline(tmp_property_name);
108108
}
109109

110110
/* Argument parsing API -- andrei */
@@ -217,7 +217,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_none_error(void) /*
217217

218218
zend_argument_count_error("%s() expects exactly 0 arguments, %d given", ZSTR_VAL(func_name), num_args);
219219

220-
zend_string_release(func_name);
220+
zend_string_release_outline(func_name);
221221
}
222222
/* }}} */
223223

@@ -235,7 +235,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_error(uint32_t
235235
num_args
236236
);
237237

238-
zend_string_release(func_name);
238+
zend_string_release_outline(func_name);
239239
}
240240
/* }}} */
241241

@@ -405,7 +405,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_error_variadic(zend_class_en
405405
arg_name ? " ($" : "", arg_name ? arg_name : "", arg_name ? ")" : "", message
406406
);
407407
efree(message);
408-
zend_string_release(func_name);
408+
zend_string_release_outline(func_name);
409409
}
410410
/* }}} */
411411

@@ -510,9 +510,9 @@ static ZEND_COLD bool zend_null_arg_deprecated(const char *fallback_type, uint32
510510
ZSTR_VAL(func_name), arg_num,
511511
arg_name ? " ($" : "", arg_name ? arg_name : "", arg_name ? ")" : "",
512512
type);
513-
zend_string_release(func_name);
513+
zend_string_release_outline(func_name);
514514
if (type_str) {
515-
zend_string_release(type_str);
515+
zend_string_release_outline(type_str);
516516
}
517517
return !EG(exception);
518518
}
@@ -1225,7 +1225,7 @@ static zend_result zend_parse_va_args(uint32_t num_args, const char *type_spec,
12251225
num_args
12261226
);
12271227

1228-
zend_string_release(func_name);
1228+
zend_string_release_outline(func_name);
12291229
}
12301230
return FAILURE;
12311231
}
@@ -1873,7 +1873,7 @@ ZEND_API zend_result object_init_with_constructor(zval *arg, zend_class_entry *c
18731873
zend_hash_get_current_key(named_params, &arg_name, /* num_index */ NULL);
18741874
ZEND_ASSERT(arg_name != NULL);
18751875
zend_throw_error(NULL, "Unknown named parameter $%s", ZSTR_VAL(arg_name));
1876-
zend_string_release(arg_name);
1876+
zend_string_release_outline(arg_name);
18771877
/* Do not call destructor, free object, and set arg to IS_UNDEF */
18781878
zend_object_store_ctor_failed(obj);
18791879
zval_ptr_dtor(arg);
@@ -2619,7 +2619,7 @@ ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module, i
26192619
lcname = zend_new_interned_string(lcname);
26202620
if ((module_ptr = zend_hash_add_ptr(&module_registry, lcname, module)) == NULL) {
26212621
zend_error(E_CORE_WARNING, "Module \"%s\" is already loaded", module->name);
2622-
zend_string_release(lcname);
2622+
zend_string_release_outline(lcname);
26232623
return NULL;
26242624
}
26252625
module = module_ptr;
@@ -2630,7 +2630,7 @@ ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module, i
26302630

26312631
if (module->functions && zend_register_functions(NULL, module->functions, NULL, module_type)==FAILURE) {
26322632
zend_hash_del(&module_registry, lcname);
2633-
zend_string_release(lcname);
2633+
zend_string_release_outline(lcname);
26342634
EG(current_module) = NULL;
26352635
zend_error(E_CORE_WARNING,"%s: Unable to register functions, unable to load", module->name);
26362636
return NULL;

Zend/zend_API.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ static zend_always_inline zend_result zend_forbid_dynamic_call(void)
900900
zend_string *function_or_method_name = get_active_function_or_method_name();
901901
zend_throw_error(NULL, "Cannot call %.*s() dynamically",
902902
(int) ZSTR_LEN(function_or_method_name), ZSTR_VAL(function_or_method_name));
903-
zend_string_release(function_or_method_name);
903+
zend_string_release_outline(function_or_method_name);
904904
return FAILURE;
905905
}
906906

Zend/zend_ast.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
ZEND_API zend_ast_process_t zend_ast_process = NULL;
3030

31-
static inline void *zend_ast_alloc(size_t size) {
31+
static void *zend_ast_alloc(size_t size) {
3232
return zend_arena_alloc(&CG(ast_arena), size);
3333
}
3434

@@ -1193,10 +1193,10 @@ ZEND_API void ZEND_FASTCALL zend_ast_destroy(zend_ast *ast)
11931193
zend_ast_decl *decl = (zend_ast_decl *) ast;
11941194

11951195
if (decl->name) {
1196-
zend_string_release_ex(decl->name, 0);
1196+
zend_string_release_ex_outline(decl->name, 0);
11971197
}
11981198
if (decl->doc_comment) {
1199-
zend_string_release_ex(decl->doc_comment, 0);
1199+
zend_string_release_ex_outline(decl->doc_comment, 0);
12001200
}
12011201
zend_ast_destroy(decl->child[0]);
12021202
zend_ast_destroy(decl->child[1]);

Zend/zend_compile.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -4111,7 +4111,7 @@ static zend_result zend_compile_func_defined(znode *result, zend_ast_list *args)
41114111

41124112
name = zval_get_string(zend_ast_get_zval(args->child[0]));
41134113
if (zend_memrchr(ZSTR_VAL(name), '\\', ZSTR_LEN(name)) || zend_memrchr(ZSTR_VAL(name), ':', ZSTR_LEN(name))) {
4114-
zend_string_release_ex(name, 0);
4114+
zend_string_release_ex_outline(name, 0);
41154115
return FAILURE;
41164116
}
41174117

@@ -4280,7 +4280,7 @@ static zend_result zend_compile_func_cufa(znode *result, zend_ast_list *args, ze
42804280
opline = zend_emit_op(NULL, ZEND_SEND_ARRAY, &arg_node, &len_node);
42814281
opline->extended_value = Z_LVAL_P(zv);
42824282
zend_emit_op(result, ZEND_DO_FCALL, NULL, NULL);
4283-
zend_string_release_ex(name, 0);
4283+
zend_string_release_ex_outline(name, 0);
42844284
return SUCCESS;
42854285
}
42864286
}
@@ -7534,7 +7534,7 @@ static void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32
75347534
&& (op_array->fn_flags & ZEND_ACC_RETURN_REFERENCE)) {
75357535
zend_string *func_name = get_function_or_method_name((zend_function *) op_array);
75367536
zend_error(E_DEPRECATED, "%s(): Returning by reference from a void function is deprecated", ZSTR_VAL(func_name));
7537-
zend_string_release(func_name);
7537+
zend_string_release_outline(func_name);
75387538
}
75397539
} else {
75407540
if (list->children == 0) {
@@ -7670,7 +7670,7 @@ static void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32
76707670
"%s(): Optional parameter $%s declared before required parameter $%s "
76717671
"is implicitly treated as a required parameter",
76727672
ZSTR_VAL(func_name), ZSTR_VAL(name), ZSTR_VAL(zend_ast_get_str(required_param_ast->child[1])));
7673-
zend_string_release(func_name);
7673+
zend_string_release_outline(func_name);
76747674
}
76757675

76767676
/* Regardless of whether we issue a deprecation, convert this parameter into
@@ -10759,7 +10759,7 @@ static void zend_compile_class_const(znode *result, zend_ast *ast) /* {{{ */
1075910759
zend_string *resolved_name = zend_resolve_class_name_ast(class_ast);
1076010760
if (zend_try_ct_eval_class_const(&result->u.constant, resolved_name, const_str)) {
1076110761
result->op_type = IS_CONST;
10762-
zend_string_release_ex(resolved_name, 0);
10762+
zend_string_release_ex_outline(resolved_name, 0);
1076310763
return;
1076410764
}
1076510765
zend_string_release_ex(resolved_name, 0);

Zend/zend_constants.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ ZEND_API zend_result zend_register_constant(zend_constant *c)
573573
|| zend_hash_add_constant(EG(zend_constants), name, c) == NULL
574574
) {
575575
zend_error(E_WARNING, "Constant %s already defined", ZSTR_VAL(name));
576-
zend_string_release(c->name);
576+
zend_string_release_outline(c->name);
577577
if (!persistent) {
578578
zval_ptr_dtor_nogc(&c->value);
579579
}

Zend/zend_exceptions.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ ZEND_API ZEND_COLD zend_object *zend_throw_exception(zend_class_entry *exception
844844
zend_string *msg_str = message ? zend_string_init(message, strlen(message), 0) : NULL;
845845
zend_object *ex = zend_throw_exception_zstr(exception_ce, msg_str, code);
846846
if (msg_str) {
847-
zend_string_release(msg_str);
847+
zend_string_release_outline(msg_str);
848848
}
849849
return ex;
850850
}
@@ -884,7 +884,7 @@ static void zend_error_va(int type, zend_string *file, uint32_t lineno, const ch
884884
zend_string *message = zend_vstrpprintf(0, format, args);
885885
zend_observer_error_notify(type, file, lineno, message);
886886
zend_error_cb(type, file, lineno, message);
887-
zend_string_release(message);
887+
zend_string_release_outline(message);
888888
va_end(args);
889889
}
890890
/* }}} */
@@ -908,8 +908,8 @@ ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *ex, int severit
908908
zend_observer_error_notify(type, file, line, message);
909909
zend_error_cb(type, file, line, message);
910910

911-
zend_string_release_ex(file, 0);
912-
zend_string_release_ex(message, 0);
911+
zend_string_release_ex_outline(file, 0);
912+
zend_string_release_ex_outline(message, 0);
913913
} else if (instanceof_function(ce_exception, zend_ce_throwable)) {
914914
zval tmp;
915915
zend_string *str, *file = NULL;
@@ -940,7 +940,7 @@ ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *ex, int severit
940940
ZSTR_VAL(Z_OBJCE(zv)->name), ZSTR_VAL(ce_exception->name));
941941

942942
if (file) {
943-
zend_string_release_ex(file, 0);
943+
zend_string_release_ex_outline(file, 0);
944944
}
945945
}
946946

@@ -952,8 +952,8 @@ ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *ex, int severit
952952
(file && ZSTR_LEN(file) > 0) ? file : NULL, line,
953953
"Uncaught %S\n thrown", str);
954954

955-
zend_string_release_ex(str, 0);
956-
zend_string_release_ex(file, 0);
955+
zend_string_release_ex_outline(str, 0);
956+
zend_string_release_ex_outline(file, 0);
957957
} else if (ce_exception == &zend_ce_unwind_exit || ce_exception == &zend_ce_graceful_exit) {
958958
/* We successfully unwound, nothing more to do.
959959
* We still return FAILURE in this case, as further execution should still be aborted. */

0 commit comments

Comments
 (0)