Skip to content

Remove leading underscore for _zend_hash_find_known_hash #7260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ PHP 8.1 INTERNALS UPGRADE NOTES
c. zend_get_opcode_id()
d. Removed support for "p" printf format specifier
e. ZEND_ATOL() changes
f. Non-serializable classes should use ZEND_ACC_NOT_SERIALIZABLE
g. _zend_hash_find_known_hash renamed to zend_hash_find_known_hash

2. Build system changes
a. New compiler flags
Expand Down Expand Up @@ -50,6 +52,7 @@ PHP 8.1 INTERNALS UPGRADE NOTES
f. Non-serializable classes should be indicated using the
ZEND_ACC_NOT_SERIALIZABLE (@not-serializable in stubs) rather than the
zend_class_(un)serialize_deny handlers which are removed.
g. _zend_hash_find_known_hash has been renamed to zend_hash_find_known_hash.

========================
2. Build system changes
Expand Down
2 changes: 1 addition & 1 deletion Zend/Optimizer/zend_func_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ static uint32_t get_internal_func_info(
return 0;
}

zval *zv = zend_hash_find_ex(&func_info, callee_func->common.function_name, 1);
zval *zv = zend_hash_find_known_hash(&func_info, callee_func->common.function_name);
if (!zv) {
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_builtin_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ ZEND_FUNCTION(error_reporting)
zend_ini_entry *p = EG(error_reporting_ini_entry);

if (!p) {
zval *zv = zend_hash_find_ex(EG(ini_directives), ZSTR_KNOWN(ZEND_STR_ERROR_REPORTING), 1);
zval *zv = zend_hash_find_known_hash(EG(ini_directives), ZSTR_KNOWN(ZEND_STR_ERROR_REPORTING));
if (!zv) {
/* Ini setting does not exist -- can this happen? */
RETURN_LONG(old_error_reporting);
Expand Down
8 changes: 4 additions & 4 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ ZEND_API void function_add_ref(zend_function *function) /* {{{ */

static zend_never_inline ZEND_COLD ZEND_NORETURN void do_bind_function_error(zend_string *lcname, zend_op_array *op_array, bool compile_time) /* {{{ */
{
zval *zv = zend_hash_find_ex(compile_time ? CG(function_table) : EG(function_table), lcname, 1);
zval *zv = zend_hash_find_known_hash(compile_time ? CG(function_table) : EG(function_table), lcname);
int error_level = compile_time ? E_COMPILE_ERROR : E_ERROR;
zend_function *old_function;

Expand Down Expand Up @@ -1102,7 +1102,7 @@ ZEND_API zend_result do_bind_class(zval *lcname, zend_string *lc_parent_name) /*

rtd_key = lcname + 1;

zv = zend_hash_find_ex(EG(class_table), Z_STR_P(rtd_key), 1);
zv = zend_hash_find_known_hash(EG(class_table), Z_STR_P(rtd_key));

if (UNEXPECTED(!zv)) {
ce = zend_hash_find_ptr(EG(class_table), Z_STR_P(lcname));
Expand All @@ -1114,7 +1114,7 @@ ZEND_API zend_result do_bind_class(zval *lcname, zend_string *lc_parent_name) /*
ZEND_ASSERT(EG(current_execute_data)->func->op_array.fn_flags & ZEND_ACC_PRELOADED);
if (zend_preload_autoload
&& zend_preload_autoload(EG(current_execute_data)->func->op_array.filename) == SUCCESS) {
zv = zend_hash_find_ex(EG(class_table), Z_STR_P(rtd_key), 1);
zv = zend_hash_find_known_hash(EG(class_table), Z_STR_P(rtd_key));
if (EXPECTED(zv != NULL)) {
break;
}
Expand Down Expand Up @@ -1383,7 +1383,7 @@ ZEND_API void zend_do_delayed_early_binding(zend_op_array *op_array, uint32_t fi
while (opline_num != (uint32_t)-1) {
const zend_op *opline = &op_array->opcodes[opline_num];
zval *lcname = RT_CONSTANT(opline, opline->op1);
zval *zv = zend_hash_find_ex(EG(class_table), Z_STR_P(lcname + 1), 1);
zval *zv = zend_hash_find_known_hash(EG(class_table), Z_STR_P(lcname + 1));

if (zv) {
zend_class_entry *ce = Z_CE_P(zv);
Expand Down
6 changes: 3 additions & 3 deletions Zend/zend_exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,14 +547,14 @@ static void _build_trace_string(smart_str *str, HashTable *ht, uint32_t num) /*
smart_str_append_long(str, num);
smart_str_appendc(str, ' ');

file = zend_hash_find_ex(ht, ZSTR_KNOWN(ZEND_STR_FILE), 1);
file = zend_hash_find_known_hash(ht, ZSTR_KNOWN(ZEND_STR_FILE));
if (file) {
if (Z_TYPE_P(file) != IS_STRING) {
zend_error(E_WARNING, "File name is not a string");
smart_str_appends(str, "[unknown file]: ");
} else{
zend_long line = 0;
tmp = zend_hash_find_ex(ht, ZSTR_KNOWN(ZEND_STR_LINE), 1);
tmp = zend_hash_find_known_hash(ht, ZSTR_KNOWN(ZEND_STR_LINE));
if (tmp) {
if (Z_TYPE_P(tmp) == IS_LONG) {
line = Z_LVAL_P(tmp);
Expand All @@ -574,7 +574,7 @@ static void _build_trace_string(smart_str *str, HashTable *ht, uint32_t num) /*
TRACE_APPEND_KEY(ZSTR_KNOWN(ZEND_STR_TYPE));
TRACE_APPEND_KEY(ZSTR_KNOWN(ZEND_STR_FUNCTION));
smart_str_appendc(str, '(');
tmp = zend_hash_find_ex(ht, ZSTR_KNOWN(ZEND_STR_ARGS), 1);
tmp = zend_hash_find_known_hash(ht, ZSTR_KNOWN(ZEND_STR_ARGS));
if (tmp) {
if (Z_TYPE_P(tmp) == IS_ARRAY) {
size_t last_len = ZSTR_LEN(str->s);
Expand Down
8 changes: 4 additions & 4 deletions Zend/zend_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -2554,7 +2554,7 @@ static zend_never_inline zval* ZEND_FASTCALL zend_find_array_dim_slow(HashTable
return zend_hash_index_find(ht, hval);
} else if (Z_TYPE_P(offset) == IS_NULL) {
str_idx:
return zend_hash_find_ex(ht, ZSTR_EMPTY_ALLOC(), 1);
return zend_hash_find_known_hash(ht, ZSTR_EMPTY_ALLOC());
} else if (Z_TYPE_P(offset) == IS_FALSE) {
hval = 0;
goto num_idx;
Expand Down Expand Up @@ -2866,7 +2866,7 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c
}
zobj->properties = zend_array_dup(zobj->properties);
}
ptr = zend_hash_find_ex(zobj->properties, Z_STR_P(prop_ptr), 1);
ptr = zend_hash_find_known_hash(zobj->properties, Z_STR_P(prop_ptr));
if (EXPECTED(ptr)) {
ZVAL_INDIRECT(result, ptr);
return;
Expand Down Expand Up @@ -4398,12 +4398,12 @@ static zend_always_inline zend_result _zend_quick_get_constant(
zend_constant *c = NULL;

/* null/true/false are resolved during compilation, so don't check for them here. */
zv = zend_hash_find_ex(EG(zend_constants), Z_STR_P(key), 1);
zv = zend_hash_find_known_hash(EG(zend_constants), Z_STR_P(key));
if (zv) {
c = (zend_constant*)Z_PTR_P(zv);
} else if (flags & IS_CONSTANT_UNQUALIFIED_IN_NAMESPACE) {
key++;
zv = zend_hash_find_ex(EG(zend_constants), Z_STR_P(key), 1);
zv = zend_hash_find_known_hash(EG(zend_constants), Z_STR_P(key));
if (zv) {
c = (zend_constant*)Z_PTR_P(zv);
}
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_execute_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,7 @@ ZEND_API void zend_attach_symbol_table(zend_execute_data *execute_data) /* {{{ *
zval *var = EX_VAR_NUM(0);

do {
zval *zv = zend_hash_find_ex(ht, *str, 1);
zval *zv = zend_hash_find_known_hash(ht, *str);

if (zv) {
if (Z_TYPE_P(zv) == IS_INDIRECT) {
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -2270,7 +2270,7 @@ ZEND_API zval* ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *ke
return p ? &p->val : NULL;
}

ZEND_API zval* ZEND_FASTCALL _zend_hash_find_known_hash(const HashTable *ht, zend_string *key)
ZEND_API zval* ZEND_FASTCALL zend_hash_find_known_hash(const HashTable *ht, zend_string *key)
{
Bucket *p;

Expand Down
6 changes: 3 additions & 3 deletions Zend/zend_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ ZEND_API zval* ZEND_FASTCALL zend_hash_str_find(const HashTable *ht, const char
ZEND_API zval* ZEND_FASTCALL zend_hash_index_find(const HashTable *ht, zend_ulong h);
ZEND_API zval* ZEND_FASTCALL _zend_hash_index_find(const HashTable *ht, zend_ulong h);

/* The same as zend_hash_find(), but hash value of the key must be already calculated */
ZEND_API zval* ZEND_FASTCALL _zend_hash_find_known_hash(const HashTable *ht, zend_string *key);
/* The same as zend_hash_find(), but hash value of the key must be already calculated. */
ZEND_API zval* ZEND_FASTCALL zend_hash_find_known_hash(const HashTable *ht, zend_string *key);

static zend_always_inline zval *zend_hash_find_ex(const HashTable *ht, zend_string *key, bool known_hash)
{
if (known_hash) {
return _zend_hash_find_known_hash(ht, key);
return zend_hash_find_known_hash(ht, key);
} else {
return zend_hash_find(ht, key);
}
Expand Down
22 changes: 11 additions & 11 deletions Zend/zend_inheritance.c
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ static zend_never_inline void do_inheritance_check_on_method(

static zend_always_inline void do_inherit_method(zend_string *key, zend_function *parent, zend_class_entry *ce, bool is_interface, bool checked) /* {{{ */
{
zval *child = zend_hash_find_ex(&ce->function_table, key, 1);
zval *child = zend_hash_find_known_hash(&ce->function_table, key);

if (child) {
zend_function *func = (zend_function*)Z_PTR_P(child);
Expand Down Expand Up @@ -1235,7 +1235,7 @@ static void emit_incompatible_property_error(

static void do_inherit_property(zend_property_info *parent_info, zend_string *key, zend_class_entry *ce) /* {{{ */
{
zval *child = zend_hash_find_ex(&ce->properties_info, key, 1);
zval *child = zend_hash_find_known_hash(&ce->properties_info, key);
zend_property_info *child_info;

if (UNEXPECTED(child)) {
Expand Down Expand Up @@ -1340,7 +1340,7 @@ static void zend_do_inherit_interfaces(zend_class_entry *ce, const zend_class_en

static void do_inherit_class_constant(zend_string *name, zend_class_constant *parent_const, zend_class_entry *ce) /* {{{ */
{
zval *zv = zend_hash_find_ex(&ce->constants_table, name, 1);
zval *zv = zend_hash_find_known_hash(&ce->constants_table, name);
zend_class_constant *c;

if (zv != NULL) {
Expand Down Expand Up @@ -1644,7 +1644,7 @@ ZEND_API void zend_do_inheritance_ex(zend_class_entry *ce, zend_class_entry *par
static bool do_inherit_constant_check(
zend_class_entry *ce, zend_class_constant *parent_constant, zend_string *name
) {
zval *zv = zend_hash_find_ex(&ce->constants_table, name, 1);
zval *zv = zend_hash_find_known_hash(&ce->constants_table, name);
if (zv == NULL) {
return true;
}
Expand Down Expand Up @@ -2870,7 +2870,7 @@ ZEND_API zend_class_entry *zend_do_link_class(zend_class_entry *ce, zend_string
if (traits_and_interfaces) {
free_alloca(traits_and_interfaces, use_heap);
}
zv = zend_hash_find_ex(CG(class_table), key, 1);
zv = zend_hash_find_known_hash(CG(class_table), key);
Z_CE_P(zv) = ret;
if (ZSTR_HAS_CE_CACHE(ret->name)) {
ZSTR_SET_CE_CACHE(ret->name, ret);
Expand All @@ -2888,7 +2888,7 @@ ZEND_API zend_class_entry *zend_do_link_class(zend_class_entry *ce, zend_string
}
/* Lazy class loading */
ce = zend_lazy_class_load(ce);
zv = zend_hash_find_ex(CG(class_table), key, 1);
zv = zend_hash_find_known_hash(CG(class_table), key);
Z_CE_P(zv) = ce;
if (CG(unlinked_uses)
&& zend_hash_index_del(CG(unlinked_uses), (zend_long)(zend_uintptr_t)proto) == SUCCESS) {
Expand All @@ -2898,7 +2898,7 @@ ZEND_API zend_class_entry *zend_do_link_class(zend_class_entry *ce, zend_string
/* Lazy class loading */
ce = zend_lazy_class_load(ce);
ce->ce_flags &= ~ZEND_ACC_FILE_CACHED;
zv = zend_hash_find_ex(CG(class_table), key, 1);
zv = zend_hash_find_known_hash(CG(class_table), key);
Z_CE_P(zv) = ce;
if (CG(unlinked_uses)
&& zend_hash_index_del(CG(unlinked_uses), (zend_long)(zend_uintptr_t)proto) == SUCCESS) {
Expand Down Expand Up @@ -2987,7 +2987,7 @@ ZEND_API zend_class_entry *zend_do_link_class(zend_class_entry *ce, zend_string
ce->inheritance_cache = NULL;
new_ce = zend_inheritance_cache_add(ce, proto, parent, traits_and_interfaces, ht);
if (new_ce) {
zv = zend_hash_find_ex(CG(class_table), key, 1);
zv = zend_hash_find_known_hash(CG(class_table), key);
ce = new_ce;
Z_CE_P(zv) = ce;
}
Expand Down Expand Up @@ -3019,7 +3019,7 @@ static inheritance_status zend_can_early_bind(zend_class_entry *ce, zend_class_e
inheritance_status overall_status = INHERITANCE_SUCCESS;

ZEND_HASH_FOREACH_STR_KEY_PTR(&parent_ce->function_table, key, parent_func) {
zval *zv = zend_hash_find_ex(&ce->function_table, key, 1);
zval *zv = zend_hash_find_known_hash(&ce->function_table, key);
if (zv) {
zend_function *child_func = Z_FUNC_P(zv);
inheritance_status status =
Expand All @@ -3041,7 +3041,7 @@ static inheritance_status zend_can_early_bind(zend_class_entry *ce, zend_class_e
continue;
}

zv = zend_hash_find_ex(&ce->properties_info, key, 1);
zv = zend_hash_find_known_hash(&ce->properties_info, key);
if (zv) {
zend_property_info *child_info = Z_PTR_P(zv);
if (ZEND_TYPE_IS_SET(child_info->type)) {
Expand Down Expand Up @@ -3146,7 +3146,7 @@ zend_class_entry *zend_try_early_bind(zend_class_entry *ce, zend_class_entry *pa
ce->inheritance_cache = NULL;
new_ce = zend_inheritance_cache_add(ce, proto, parent_ce, NULL, ht);
if (new_ce) {
zval *zv = zend_hash_find_ex(CG(class_table), lcname, 1);
zval *zv = zend_hash_find_known_hash(CG(class_table), lcname);
ce = new_ce;
Z_CE_P(zv) = ce;
}
Expand Down
4 changes: 2 additions & 2 deletions Zend/zend_object_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1847,10 +1847,10 @@ ZEND_API int zend_std_cast_object_tostring(zend_object *readobj, zval *writeobj,

ZEND_API int zend_std_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, bool check_only) /* {{{ */
{
zval *func;
zend_class_entry *ce = obj->ce;
zval *func = zend_hash_find_known_hash(&ce->function_table, ZSTR_KNOWN(ZEND_STR_MAGIC_INVOKE));

if ((func = zend_hash_find_ex(&ce->function_table, ZSTR_KNOWN(ZEND_STR_MAGIC_INVOKE), 1)) == NULL) {
if (func == NULL) {
return FAILURE;
}
*fptr_ptr = Z_FUNC_P(func);
Expand Down
Loading