Skip to content

Commit b2bc2c6

Browse files
committed
Remove unnecessary cache_slot arguments
zend_verify_type_error_common() no longer needs the cache_slot, so drop it there and from all users.
1 parent f0dfdca commit b2bc2c6

File tree

4 files changed

+26
-34
lines changed

4 files changed

+26
-34
lines changed

Zend/zend_execute.c

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,7 @@ static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_throw_non_object_erro
648648
}
649649

650650
static ZEND_COLD void zend_verify_type_error_common(
651-
const zend_function *zf, const zend_arg_info *arg_info,
652-
void **cache_slot, zval *value,
651+
const zend_function *zf, const zend_arg_info *arg_info, zval *value,
653652
const char **fname, const char **fsep, const char **fclass,
654653
zend_string **need_msg, const char **given_kind)
655654
{
@@ -672,8 +671,7 @@ static ZEND_COLD void zend_verify_type_error_common(
672671
}
673672

674673
ZEND_API ZEND_COLD void zend_verify_arg_error(
675-
const zend_function *zf, const zend_arg_info *arg_info,
676-
int arg_num, void **cache_slot, zval *value)
674+
const zend_function *zf, const zend_arg_info *arg_info, int arg_num, zval *value)
677675
{
678676
zend_execute_data *ptr = EG(current_execute_data)->prev_execute_data;
679677
const char *fname, *fsep, *fclass;
@@ -688,8 +686,7 @@ ZEND_API ZEND_COLD void zend_verify_arg_error(
688686

689687
if (value) {
690688
zend_verify_type_error_common(
691-
zf, arg_info, cache_slot, value,
692-
&fname, &fsep, &fclass, &need_msg, &given_msg);
689+
zf, arg_info, value, &fname, &fsep, &fclass, &need_msg, &given_msg);
693690

694691
if (zf->common.type == ZEND_USER_FUNCTION) {
695692
if (ptr && ptr->func && ZEND_USER_CODE(ptr->func->common.type)) {
@@ -1044,7 +1041,7 @@ static zend_always_inline bool zend_verify_recv_arg_type(zend_function *zf, uint
10441041

10451042
if (ZEND_TYPE_IS_SET(cur_arg_info->type)
10461043
&& UNEXPECTED(!zend_check_type(cur_arg_info->type, arg, cache_slot, zf->common.scope, 0, 0))) {
1047-
zend_verify_arg_error(zf, cur_arg_info, arg_num, cache_slot, arg);
1044+
zend_verify_arg_error(zf, cur_arg_info, arg_num, arg);
10481045
return 0;
10491046
}
10501047

@@ -1056,7 +1053,7 @@ static zend_always_inline bool zend_verify_variadic_arg_type(
10561053
{
10571054
ZEND_ASSERT(ZEND_TYPE_IS_SET(arg_info->type));
10581055
if (UNEXPECTED(!zend_check_type(arg_info->type, arg, cache_slot, zf->common.scope, 0, 0))) {
1059-
zend_verify_arg_error(zf, arg_info, arg_num, cache_slot, arg);
1056+
zend_verify_arg_error(zf, arg_info, arg_num, arg);
10601057
return 0;
10611058
}
10621059

@@ -1150,17 +1147,15 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_missing_arg_error(zend_execute_data *
11501147
}
11511148
}
11521149

1153-
ZEND_API ZEND_COLD void zend_verify_return_error(
1154-
const zend_function *zf, void **cache_slot, zval *value)
1150+
ZEND_API ZEND_COLD void zend_verify_return_error(const zend_function *zf, zval *value)
11551151
{
11561152
const zend_arg_info *arg_info = &zf->common.arg_info[-1];
11571153
const char *fname, *fsep, *fclass;
11581154
zend_string *need_msg;
11591155
const char *given_msg;
11601156

11611157
zend_verify_type_error_common(
1162-
zf, arg_info, cache_slot, value,
1163-
&fname, &fsep, &fclass, &need_msg, &given_msg);
1158+
zf, arg_info, value, &fname, &fsep, &fclass, &need_msg, &given_msg);
11641159

11651160
zend_type_error("%s%s%s(): Return value must be of type %s, %s returned",
11661161
fclass, fsep, fname, ZSTR_VAL(need_msg), given_msg);
@@ -1169,17 +1164,15 @@ ZEND_API ZEND_COLD void zend_verify_return_error(
11691164
}
11701165

11711166
#if ZEND_DEBUG
1172-
static ZEND_COLD void zend_verify_internal_return_error(
1173-
const zend_function *zf, void **cache_slot, zval *value)
1167+
static ZEND_COLD void zend_verify_internal_return_error(const zend_function *zf, zval *value)
11741168
{
11751169
const zend_arg_info *arg_info = &zf->common.arg_info[-1];
11761170
const char *fname, *fsep, *fclass;
11771171
zend_string *need_msg;
11781172
const char *given_msg;
11791173

11801174
zend_verify_type_error_common(
1181-
zf, arg_info, cache_slot, value,
1182-
&fname, &fsep, &fclass, &need_msg, &given_msg);
1175+
zf, arg_info, value, &fname, &fsep, &fclass, &need_msg, &given_msg);
11831176

11841177
zend_error_noreturn(E_CORE_ERROR, "%s%s%s(): Return value must be of type %s, %s returned",
11851178
fclass, fsep, fname, ZSTR_VAL(need_msg), given_msg);
@@ -1217,18 +1210,18 @@ static bool zend_verify_internal_return_type(zend_function *zf, zval *ret)
12171210
}
12181211

12191212
if (UNEXPECTED(!zend_check_type(ret_info->type, ret, &dummy_cache_slot, NULL, 1, /* is_internal */ 1))) {
1220-
zend_verify_internal_return_error(zf, &dummy_cache_slot, ret);
1213+
zend_verify_internal_return_error(zf, ret);
12211214
return 0;
12221215
}
12231216

12241217
return 1;
12251218
}
12261219
#endif
12271220

1228-
static ZEND_COLD void zend_verify_missing_return_type(const zend_function *zf, void **cache_slot)
1221+
static ZEND_COLD void zend_verify_missing_return_type(const zend_function *zf)
12291222
{
12301223
/* VERIFY_RETURN_TYPE is not emitted for "void" functions, so this is always an error. */
1231-
zend_verify_return_error(zf, cache_slot, NULL);
1224+
zend_verify_return_error(zf, NULL);
12321225
}
12331226

12341227
static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_use_object_as_array(void)

Zend/zend_execute.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,9 @@ ZEND_API ZEND_COLD zend_result ZEND_FASTCALL zend_undefined_index_write(HashTabl
7070

7171
ZEND_API zend_bool zend_verify_scalar_type_hint(uint32_t type_mask, zval *arg, zend_bool strict, zend_bool is_internal_arg);
7272
ZEND_API ZEND_COLD void zend_verify_arg_error(
73-
const zend_function *zf, const zend_arg_info *arg_info,
74-
int arg_num, void **cache_slot, zval *value);
73+
const zend_function *zf, const zend_arg_info *arg_info, int arg_num, zval *value);
7574
ZEND_API ZEND_COLD void zend_verify_return_error(
76-
const zend_function *zf, void **cache_slot, zval *value);
75+
const zend_function *zf, zval *value);
7776
ZEND_API zend_bool zend_verify_ref_array_assignable(zend_reference *ref);
7877
ZEND_API zend_bool zend_value_instanceof_static(zval *zv);
7978

Zend/zend_vm_def.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4161,7 +4161,7 @@ ZEND_VM_COLD_CONST_HANDLER(124, ZEND_VERIFY_RETURN_TYPE, CONST|TMP|VAR|UNUSED|CV
41614161

41624162
if (OP1_TYPE == IS_UNUSED) {
41634163
SAVE_OPLINE();
4164-
zend_verify_missing_return_type(EX(func), CACHE_ADDR(opline->op2.num));
4164+
zend_verify_missing_return_type(EX(func));
41654165
HANDLE_EXCEPTION();
41664166
} else {
41674167
/* prevents "undefined variable opline" errors */
@@ -4213,7 +4213,7 @@ ZEND_VM_COLD_CONST_HANDLER(124, ZEND_VERIFY_RETURN_TYPE, CONST|TMP|VAR|UNUSED|CV
42134213

42144214
SAVE_OPLINE();
42154215
if (UNEXPECTED(!zend_check_type_slow(ret_info->type, retval_ptr, ref, cache_slot, NULL, 1, 0))) {
4216-
zend_verify_return_error(EX(func), cache_slot, retval_ptr);
4216+
zend_verify_return_error(EX(func), retval_ptr);
42174217
HANDLE_EXCEPTION();
42184218
}
42194219
ZEND_VM_NEXT_OPCODE();

Zend/zend_vm_execute.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9036,7 +9036,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYP
90369036

90379037
if (IS_CONST == IS_UNUSED) {
90389038
SAVE_OPLINE();
9039-
zend_verify_missing_return_type(EX(func), CACHE_ADDR(opline->op2.num));
9039+
zend_verify_missing_return_type(EX(func));
90409040
HANDLE_EXCEPTION();
90419041
} else {
90429042
/* prevents "undefined variable opline" errors */
@@ -9088,7 +9088,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYP
90889088

90899089
SAVE_OPLINE();
90909090
if (UNEXPECTED(!zend_check_type_slow(ret_info->type, retval_ptr, ref, cache_slot, NULL, 1, 0))) {
9091-
zend_verify_return_error(EX(func), cache_slot, retval_ptr);
9091+
zend_verify_return_error(EX(func), retval_ptr);
90929092
HANDLE_EXCEPTION();
90939093
}
90949094
ZEND_VM_NEXT_OPCODE();
@@ -19370,7 +19370,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_TMP_UN
1937019370

1937119371
if (IS_TMP_VAR == IS_UNUSED) {
1937219372
SAVE_OPLINE();
19373-
zend_verify_missing_return_type(EX(func), CACHE_ADDR(opline->op2.num));
19373+
zend_verify_missing_return_type(EX(func));
1937419374
HANDLE_EXCEPTION();
1937519375
} else {
1937619376
/* prevents "undefined variable opline" errors */
@@ -19422,7 +19422,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_TMP_UN
1942219422

1942319423
SAVE_OPLINE();
1942419424
if (UNEXPECTED(!zend_check_type_slow(ret_info->type, retval_ptr, ref, cache_slot, NULL, 1, 0))) {
19425-
zend_verify_return_error(EX(func), cache_slot, retval_ptr);
19425+
zend_verify_return_error(EX(func), retval_ptr);
1942619426
HANDLE_EXCEPTION();
1942719427
}
1942819428
ZEND_VM_NEXT_OPCODE();
@@ -26964,7 +26964,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_VAR_UN
2696426964

2696526965
if (IS_VAR == IS_UNUSED) {
2696626966
SAVE_OPLINE();
26967-
zend_verify_missing_return_type(EX(func), CACHE_ADDR(opline->op2.num));
26967+
zend_verify_missing_return_type(EX(func));
2696826968
HANDLE_EXCEPTION();
2696926969
} else {
2697026970
/* prevents "undefined variable opline" errors */
@@ -27016,7 +27016,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_VAR_UN
2701627016

2701727017
SAVE_OPLINE();
2701827018
if (UNEXPECTED(!zend_check_type_slow(ret_info->type, retval_ptr, ref, cache_slot, NULL, 1, 0))) {
27019-
zend_verify_return_error(EX(func), cache_slot, retval_ptr);
27019+
zend_verify_return_error(EX(func), retval_ptr);
2702027020
HANDLE_EXCEPTION();
2702127021
}
2702227022
ZEND_VM_NEXT_OPCODE();
@@ -34162,7 +34162,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_UNUSED
3416234162

3416334163
if (IS_UNUSED == IS_UNUSED) {
3416434164
SAVE_OPLINE();
34165-
zend_verify_missing_return_type(EX(func), CACHE_ADDR(opline->op2.num));
34165+
zend_verify_missing_return_type(EX(func));
3416634166
HANDLE_EXCEPTION();
3416734167
} else {
3416834168
/* prevents "undefined variable opline" errors */
@@ -34214,7 +34214,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_UNUSED
3421434214

3421534215
SAVE_OPLINE();
3421634216
if (UNEXPECTED(!zend_check_type_slow(ret_info->type, retval_ptr, ref, cache_slot, NULL, 1, 0))) {
34217-
zend_verify_return_error(EX(func), cache_slot, retval_ptr);
34217+
zend_verify_return_error(EX(func), retval_ptr);
3421834218
HANDLE_EXCEPTION();
3421934219
}
3422034220
ZEND_VM_NEXT_OPCODE();
@@ -45836,7 +45836,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_CV_UNU
4583645836

4583745837
if (IS_CV == IS_UNUSED) {
4583845838
SAVE_OPLINE();
45839-
zend_verify_missing_return_type(EX(func), CACHE_ADDR(opline->op2.num));
45839+
zend_verify_missing_return_type(EX(func));
4584045840
HANDLE_EXCEPTION();
4584145841
} else {
4584245842
/* prevents "undefined variable opline" errors */
@@ -45888,7 +45888,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_CV_UNU
4588845888

4588945889
SAVE_OPLINE();
4589045890
if (UNEXPECTED(!zend_check_type_slow(ret_info->type, retval_ptr, ref, cache_slot, NULL, 1, 0))) {
45891-
zend_verify_return_error(EX(func), cache_slot, retval_ptr);
45891+
zend_verify_return_error(EX(func), retval_ptr);
4589245892
HANDLE_EXCEPTION();
4589345893
}
4589445894
ZEND_VM_NEXT_OPCODE();

0 commit comments

Comments
 (0)