Remove unnecessary cache_slot arguments

zend_verify_type_error_common() no longer needs the cache_slot,
so drop it there and from all users.
This commit is contained in:
Nikita Popov 2020-08-28 17:15:09 +02:00
parent f0dfdca0ae
commit b2bc2c62fa
4 changed files with 26 additions and 34 deletions

View file

@ -648,8 +648,7 @@ static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_throw_non_object_erro
} }
static ZEND_COLD void zend_verify_type_error_common( static ZEND_COLD void zend_verify_type_error_common(
const zend_function *zf, const zend_arg_info *arg_info, const zend_function *zf, const zend_arg_info *arg_info, zval *value,
void **cache_slot, zval *value,
const char **fname, const char **fsep, const char **fclass, const char **fname, const char **fsep, const char **fclass,
zend_string **need_msg, const char **given_kind) zend_string **need_msg, const char **given_kind)
{ {
@ -672,8 +671,7 @@ static ZEND_COLD void zend_verify_type_error_common(
} }
ZEND_API ZEND_COLD void zend_verify_arg_error( ZEND_API ZEND_COLD void zend_verify_arg_error(
const zend_function *zf, const zend_arg_info *arg_info, const zend_function *zf, const zend_arg_info *arg_info, int arg_num, zval *value)
int arg_num, void **cache_slot, zval *value)
{ {
zend_execute_data *ptr = EG(current_execute_data)->prev_execute_data; zend_execute_data *ptr = EG(current_execute_data)->prev_execute_data;
const char *fname, *fsep, *fclass; const char *fname, *fsep, *fclass;
@ -688,8 +686,7 @@ ZEND_API ZEND_COLD void zend_verify_arg_error(
if (value) { if (value) {
zend_verify_type_error_common( zend_verify_type_error_common(
zf, arg_info, cache_slot, value, zf, arg_info, value, &fname, &fsep, &fclass, &need_msg, &given_msg);
&fname, &fsep, &fclass, &need_msg, &given_msg);
if (zf->common.type == ZEND_USER_FUNCTION) { if (zf->common.type == ZEND_USER_FUNCTION) {
if (ptr && ptr->func && ZEND_USER_CODE(ptr->func->common.type)) { 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
if (ZEND_TYPE_IS_SET(cur_arg_info->type) if (ZEND_TYPE_IS_SET(cur_arg_info->type)
&& UNEXPECTED(!zend_check_type(cur_arg_info->type, arg, cache_slot, zf->common.scope, 0, 0))) { && UNEXPECTED(!zend_check_type(cur_arg_info->type, arg, cache_slot, zf->common.scope, 0, 0))) {
zend_verify_arg_error(zf, cur_arg_info, arg_num, cache_slot, arg); zend_verify_arg_error(zf, cur_arg_info, arg_num, arg);
return 0; return 0;
} }
@ -1056,7 +1053,7 @@ static zend_always_inline bool zend_verify_variadic_arg_type(
{ {
ZEND_ASSERT(ZEND_TYPE_IS_SET(arg_info->type)); ZEND_ASSERT(ZEND_TYPE_IS_SET(arg_info->type));
if (UNEXPECTED(!zend_check_type(arg_info->type, arg, cache_slot, zf->common.scope, 0, 0))) { if (UNEXPECTED(!zend_check_type(arg_info->type, arg, cache_slot, zf->common.scope, 0, 0))) {
zend_verify_arg_error(zf, arg_info, arg_num, cache_slot, arg); zend_verify_arg_error(zf, arg_info, arg_num, arg);
return 0; return 0;
} }
@ -1150,8 +1147,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_missing_arg_error(zend_execute_data *
} }
} }
ZEND_API ZEND_COLD void zend_verify_return_error( ZEND_API ZEND_COLD void zend_verify_return_error(const zend_function *zf, zval *value)
const zend_function *zf, void **cache_slot, zval *value)
{ {
const zend_arg_info *arg_info = &zf->common.arg_info[-1]; const zend_arg_info *arg_info = &zf->common.arg_info[-1];
const char *fname, *fsep, *fclass; const char *fname, *fsep, *fclass;
@ -1159,8 +1155,7 @@ ZEND_API ZEND_COLD void zend_verify_return_error(
const char *given_msg; const char *given_msg;
zend_verify_type_error_common( zend_verify_type_error_common(
zf, arg_info, cache_slot, value, zf, arg_info, value, &fname, &fsep, &fclass, &need_msg, &given_msg);
&fname, &fsep, &fclass, &need_msg, &given_msg);
zend_type_error("%s%s%s(): Return value must be of type %s, %s returned", zend_type_error("%s%s%s(): Return value must be of type %s, %s returned",
fclass, fsep, fname, ZSTR_VAL(need_msg), given_msg); fclass, fsep, fname, ZSTR_VAL(need_msg), given_msg);
@ -1169,8 +1164,7 @@ ZEND_API ZEND_COLD void zend_verify_return_error(
} }
#if ZEND_DEBUG #if ZEND_DEBUG
static ZEND_COLD void zend_verify_internal_return_error( static ZEND_COLD void zend_verify_internal_return_error(const zend_function *zf, zval *value)
const zend_function *zf, void **cache_slot, zval *value)
{ {
const zend_arg_info *arg_info = &zf->common.arg_info[-1]; const zend_arg_info *arg_info = &zf->common.arg_info[-1];
const char *fname, *fsep, *fclass; const char *fname, *fsep, *fclass;
@ -1178,8 +1172,7 @@ static ZEND_COLD void zend_verify_internal_return_error(
const char *given_msg; const char *given_msg;
zend_verify_type_error_common( zend_verify_type_error_common(
zf, arg_info, cache_slot, value, zf, arg_info, value, &fname, &fsep, &fclass, &need_msg, &given_msg);
&fname, &fsep, &fclass, &need_msg, &given_msg);
zend_error_noreturn(E_CORE_ERROR, "%s%s%s(): Return value must be of type %s, %s returned", zend_error_noreturn(E_CORE_ERROR, "%s%s%s(): Return value must be of type %s, %s returned",
fclass, fsep, fname, ZSTR_VAL(need_msg), given_msg); fclass, fsep, fname, ZSTR_VAL(need_msg), given_msg);
@ -1217,7 +1210,7 @@ static bool zend_verify_internal_return_type(zend_function *zf, zval *ret)
} }
if (UNEXPECTED(!zend_check_type(ret_info->type, ret, &dummy_cache_slot, NULL, 1, /* is_internal */ 1))) { if (UNEXPECTED(!zend_check_type(ret_info->type, ret, &dummy_cache_slot, NULL, 1, /* is_internal */ 1))) {
zend_verify_internal_return_error(zf, &dummy_cache_slot, ret); zend_verify_internal_return_error(zf, ret);
return 0; return 0;
} }
@ -1225,10 +1218,10 @@ static bool zend_verify_internal_return_type(zend_function *zf, zval *ret)
} }
#endif #endif
static ZEND_COLD void zend_verify_missing_return_type(const zend_function *zf, void **cache_slot) static ZEND_COLD void zend_verify_missing_return_type(const zend_function *zf)
{ {
/* VERIFY_RETURN_TYPE is not emitted for "void" functions, so this is always an error. */ /* VERIFY_RETURN_TYPE is not emitted for "void" functions, so this is always an error. */
zend_verify_return_error(zf, cache_slot, NULL); zend_verify_return_error(zf, NULL);
} }
static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_use_object_as_array(void) static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_use_object_as_array(void)

View file

@ -70,10 +70,9 @@ ZEND_API ZEND_COLD zend_result ZEND_FASTCALL zend_undefined_index_write(HashTabl
ZEND_API zend_bool zend_verify_scalar_type_hint(uint32_t type_mask, zval *arg, zend_bool strict, zend_bool is_internal_arg); ZEND_API zend_bool zend_verify_scalar_type_hint(uint32_t type_mask, zval *arg, zend_bool strict, zend_bool is_internal_arg);
ZEND_API ZEND_COLD void zend_verify_arg_error( ZEND_API ZEND_COLD void zend_verify_arg_error(
const zend_function *zf, const zend_arg_info *arg_info, const zend_function *zf, const zend_arg_info *arg_info, int arg_num, zval *value);
int arg_num, void **cache_slot, zval *value);
ZEND_API ZEND_COLD void zend_verify_return_error( ZEND_API ZEND_COLD void zend_verify_return_error(
const zend_function *zf, void **cache_slot, zval *value); const zend_function *zf, zval *value);
ZEND_API zend_bool zend_verify_ref_array_assignable(zend_reference *ref); ZEND_API zend_bool zend_verify_ref_array_assignable(zend_reference *ref);
ZEND_API zend_bool zend_value_instanceof_static(zval *zv); ZEND_API zend_bool zend_value_instanceof_static(zval *zv);

View file

@ -4161,7 +4161,7 @@ ZEND_VM_COLD_CONST_HANDLER(124, ZEND_VERIFY_RETURN_TYPE, CONST|TMP|VAR|UNUSED|CV
if (OP1_TYPE == IS_UNUSED) { if (OP1_TYPE == IS_UNUSED) {
SAVE_OPLINE(); SAVE_OPLINE();
zend_verify_missing_return_type(EX(func), CACHE_ADDR(opline->op2.num)); zend_verify_missing_return_type(EX(func));
HANDLE_EXCEPTION(); HANDLE_EXCEPTION();
} else { } else {
/* prevents "undefined variable opline" errors */ /* prevents "undefined variable opline" errors */
@ -4213,7 +4213,7 @@ ZEND_VM_COLD_CONST_HANDLER(124, ZEND_VERIFY_RETURN_TYPE, CONST|TMP|VAR|UNUSED|CV
SAVE_OPLINE(); SAVE_OPLINE();
if (UNEXPECTED(!zend_check_type_slow(ret_info->type, retval_ptr, ref, cache_slot, NULL, 1, 0))) { if (UNEXPECTED(!zend_check_type_slow(ret_info->type, retval_ptr, ref, cache_slot, NULL, 1, 0))) {
zend_verify_return_error(EX(func), cache_slot, retval_ptr); zend_verify_return_error(EX(func), retval_ptr);
HANDLE_EXCEPTION(); HANDLE_EXCEPTION();
} }
ZEND_VM_NEXT_OPCODE(); ZEND_VM_NEXT_OPCODE();

View file

@ -9036,7 +9036,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYP
if (IS_CONST == IS_UNUSED) { if (IS_CONST == IS_UNUSED) {
SAVE_OPLINE(); SAVE_OPLINE();
zend_verify_missing_return_type(EX(func), CACHE_ADDR(opline->op2.num)); zend_verify_missing_return_type(EX(func));
HANDLE_EXCEPTION(); HANDLE_EXCEPTION();
} else { } else {
/* prevents "undefined variable opline" errors */ /* prevents "undefined variable opline" errors */
@ -9088,7 +9088,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYP
SAVE_OPLINE(); SAVE_OPLINE();
if (UNEXPECTED(!zend_check_type_slow(ret_info->type, retval_ptr, ref, cache_slot, NULL, 1, 0))) { if (UNEXPECTED(!zend_check_type_slow(ret_info->type, retval_ptr, ref, cache_slot, NULL, 1, 0))) {
zend_verify_return_error(EX(func), cache_slot, retval_ptr); zend_verify_return_error(EX(func), retval_ptr);
HANDLE_EXCEPTION(); HANDLE_EXCEPTION();
} }
ZEND_VM_NEXT_OPCODE(); ZEND_VM_NEXT_OPCODE();
@ -19370,7 +19370,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_TMP_UN
if (IS_TMP_VAR == IS_UNUSED) { if (IS_TMP_VAR == IS_UNUSED) {
SAVE_OPLINE(); SAVE_OPLINE();
zend_verify_missing_return_type(EX(func), CACHE_ADDR(opline->op2.num)); zend_verify_missing_return_type(EX(func));
HANDLE_EXCEPTION(); HANDLE_EXCEPTION();
} else { } else {
/* prevents "undefined variable opline" errors */ /* prevents "undefined variable opline" errors */
@ -19422,7 +19422,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_TMP_UN
SAVE_OPLINE(); SAVE_OPLINE();
if (UNEXPECTED(!zend_check_type_slow(ret_info->type, retval_ptr, ref, cache_slot, NULL, 1, 0))) { if (UNEXPECTED(!zend_check_type_slow(ret_info->type, retval_ptr, ref, cache_slot, NULL, 1, 0))) {
zend_verify_return_error(EX(func), cache_slot, retval_ptr); zend_verify_return_error(EX(func), retval_ptr);
HANDLE_EXCEPTION(); HANDLE_EXCEPTION();
} }
ZEND_VM_NEXT_OPCODE(); ZEND_VM_NEXT_OPCODE();
@ -26964,7 +26964,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_VAR_UN
if (IS_VAR == IS_UNUSED) { if (IS_VAR == IS_UNUSED) {
SAVE_OPLINE(); SAVE_OPLINE();
zend_verify_missing_return_type(EX(func), CACHE_ADDR(opline->op2.num)); zend_verify_missing_return_type(EX(func));
HANDLE_EXCEPTION(); HANDLE_EXCEPTION();
} else { } else {
/* prevents "undefined variable opline" errors */ /* prevents "undefined variable opline" errors */
@ -27016,7 +27016,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_VAR_UN
SAVE_OPLINE(); SAVE_OPLINE();
if (UNEXPECTED(!zend_check_type_slow(ret_info->type, retval_ptr, ref, cache_slot, NULL, 1, 0))) { if (UNEXPECTED(!zend_check_type_slow(ret_info->type, retval_ptr, ref, cache_slot, NULL, 1, 0))) {
zend_verify_return_error(EX(func), cache_slot, retval_ptr); zend_verify_return_error(EX(func), retval_ptr);
HANDLE_EXCEPTION(); HANDLE_EXCEPTION();
} }
ZEND_VM_NEXT_OPCODE(); ZEND_VM_NEXT_OPCODE();
@ -34162,7 +34162,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_UNUSED
if (IS_UNUSED == IS_UNUSED) { if (IS_UNUSED == IS_UNUSED) {
SAVE_OPLINE(); SAVE_OPLINE();
zend_verify_missing_return_type(EX(func), CACHE_ADDR(opline->op2.num)); zend_verify_missing_return_type(EX(func));
HANDLE_EXCEPTION(); HANDLE_EXCEPTION();
} else { } else {
/* prevents "undefined variable opline" errors */ /* prevents "undefined variable opline" errors */
@ -34214,7 +34214,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_UNUSED
SAVE_OPLINE(); SAVE_OPLINE();
if (UNEXPECTED(!zend_check_type_slow(ret_info->type, retval_ptr, ref, cache_slot, NULL, 1, 0))) { if (UNEXPECTED(!zend_check_type_slow(ret_info->type, retval_ptr, ref, cache_slot, NULL, 1, 0))) {
zend_verify_return_error(EX(func), cache_slot, retval_ptr); zend_verify_return_error(EX(func), retval_ptr);
HANDLE_EXCEPTION(); HANDLE_EXCEPTION();
} }
ZEND_VM_NEXT_OPCODE(); ZEND_VM_NEXT_OPCODE();
@ -45836,7 +45836,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_CV_UNU
if (IS_CV == IS_UNUSED) { if (IS_CV == IS_UNUSED) {
SAVE_OPLINE(); SAVE_OPLINE();
zend_verify_missing_return_type(EX(func), CACHE_ADDR(opline->op2.num)); zend_verify_missing_return_type(EX(func));
HANDLE_EXCEPTION(); HANDLE_EXCEPTION();
} else { } else {
/* prevents "undefined variable opline" errors */ /* prevents "undefined variable opline" errors */
@ -45888,7 +45888,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_CV_UNU
SAVE_OPLINE(); SAVE_OPLINE();
if (UNEXPECTED(!zend_check_type_slow(ret_info->type, retval_ptr, ref, cache_slot, NULL, 1, 0))) { if (UNEXPECTED(!zend_check_type_slow(ret_info->type, retval_ptr, ref, cache_slot, NULL, 1, 0))) {
zend_verify_return_error(EX(func), cache_slot, retval_ptr); zend_verify_return_error(EX(func), retval_ptr);
HANDLE_EXCEPTION(); HANDLE_EXCEPTION();
} }
ZEND_VM_NEXT_OPCODE(); ZEND_VM_NEXT_OPCODE();