@@ -1044,8 +1044,7 @@ ZEND_API zend_string *zend_type_to_string(zend_type type);
10441044
10451045#define ZEND_SEND_BY_VAL 0u
10461046#define ZEND_SEND_BY_REF 1u
1047- #define ZEND_SEND_PREFER_VAL 2u
1048- #define ZEND_SEND_PREFER_REF 3u
1047+ #define ZEND_SEND_PREFER_REF 2u
10491048
10501049#define ZEND_THROW_IS_EXPR 1u
10511050
@@ -1078,7 +1077,7 @@ ZEND_API zend_string *zend_type_to_string(zend_type type);
10781077#define IS_CONSTANT_CLASS 0x400 /* __CLASS__ in trait */
10791078#define IS_CONSTANT_UNQUALIFIED_IN_NAMESPACE 0x800
10801079
1081- static zend_always_inline bool zend_check_arg_must_be_sent_by_ref (const zend_function * zf , uint32_t arg_num )
1080+ static zend_always_inline bool zend_check_arg_send_type (const zend_function * zf , uint32_t arg_num , uint32_t mask )
10821081{
10831082 arg_num -- ;
10841083 if (UNEXPECTED (arg_num >= zf -> common .num_args )) {
@@ -1087,44 +1086,17 @@ static zend_always_inline bool zend_check_arg_must_be_sent_by_ref(const zend_fun
10871086 }
10881087 arg_num = zf -> common .num_args ;
10891088 }
1090- return ZEND_ARG_SEND_MODE (& zf -> common .arg_info [arg_num ]) == ZEND_SEND_BY_REF ;
1091- }
1092-
1093- static zend_always_inline int zend_check_arg_should_be_sent_by_ref (const zend_function * zf , uint32_t arg_num )
1094- {
1095- arg_num -- ;
1096- if (UNEXPECTED (arg_num >= zf -> common .num_args )) {
1097- if (EXPECTED ((zf -> common .fn_flags & ZEND_ACC_VARIADIC ) == 0 )) {
1098- return 0 ;
1099- }
1100- arg_num = zf -> common .num_args ;
1101- }
1102-
1103- /* The SEND_BY_REF bit is set for PREFER_REF as well. */
1104- return (ZEND_ARG_SEND_MODE (& zf -> common .arg_info [arg_num ]) & ZEND_SEND_BY_REF ) != 0 ;
1105- }
1106-
1107- static zend_always_inline int zend_check_arg_may_be_sent_by_ref (const zend_function * zf , uint32_t arg_num )
1108- {
1109- arg_num -- ;
1110- if (UNEXPECTED (arg_num >= zf -> common .num_args )) {
1111- if (EXPECTED ((zf -> common .fn_flags & ZEND_ACC_VARIADIC ) == 0 )) {
1112- return 0 ;
1113- }
1114- arg_num = zf -> common .num_args ;
1115- }
1116-
1117- return ZEND_ARG_SEND_MODE (& zf -> common .arg_info [arg_num ]) != ZEND_SEND_BY_VAL ;
1089+ return UNEXPECTED ((ZEND_ARG_SEND_MODE (& zf -> common .arg_info [arg_num ]) & mask ) != 0 );
11181090}
11191091
11201092#define ARG_MUST_BE_SENT_BY_REF (zf , arg_num ) \
1121- zend_check_arg_must_be_sent_by_ref (zf, arg_num)
1093+ zend_check_arg_send_type (zf, arg_num, ZEND_SEND_BY_REF )
11221094
11231095#define ARG_SHOULD_BE_SENT_BY_REF (zf , arg_num ) \
1124- zend_check_arg_should_be_sent_by_ref (zf, arg_num)
1096+ zend_check_arg_send_type (zf, arg_num, ZEND_SEND_BY_REF|ZEND_SEND_PREFER_REF )
11251097
11261098#define ARG_MAY_BE_SENT_BY_REF (zf , arg_num ) \
1127- zend_check_arg_may_be_sent_by_ref (zf, arg_num)
1099+ zend_check_arg_send_type (zf, arg_num, ZEND_SEND_PREFER_REF )
11281100
11291101/* Quick API to check first 12 arguments */
11301102#define MAX_ARG_FLAG_NUM 12
@@ -1133,24 +1105,24 @@ static zend_always_inline int zend_check_arg_may_be_sent_by_ref(const zend_funct
11331105# define ZEND_SET_ARG_FLAG (zf , arg_num , mask ) do { \
11341106 (zf)->quick_arg_flags |= ((mask) << ((arg_num) - 1) * 2); \
11351107 } while (0)
1136- # define ZEND_GET_ARG_FLAG (zf , arg_num ) \
1137- (((zf)->quick_arg_flags >> (((arg_num) - 1) * 2)) & 0x3u )
1108+ # define ZEND_CHECK_ARG_FLAG (zf , arg_num , mask ) \
1109+ (((zf)->quick_arg_flags >> (((arg_num) - 1) * 2)) & (mask) )
11381110#else
11391111# define ZEND_SET_ARG_FLAG (zf , arg_num , mask ) do { \
11401112 (zf)->quick_arg_flags |= (((mask) << 6) << (arg_num) * 2); \
11411113 } while (0)
1142- # define ZEND_GET_ARG_FLAG (zf , arg_num ) \
1143- (((zf)->quick_arg_flags >> (((arg_num) + 3) * 2)) & 0x3u )
1114+ # define ZEND_CHECK_ARG_FLAG (zf , arg_num , mask ) \
1115+ (((zf)->quick_arg_flags >> (((arg_num) + 3) * 2)) & (mask) )
11441116#endif
11451117
11461118#define QUICK_ARG_MUST_BE_SENT_BY_REF (zf , arg_num ) \
1147- (ZEND_GET_ARG_FLAG( zf, arg_num) == ZEND_SEND_BY_REF)
1119+ ZEND_CHECK_ARG_FLAG( zf, arg_num, ZEND_SEND_BY_REF)
11481120
11491121#define QUICK_ARG_SHOULD_BE_SENT_BY_REF (zf , arg_num ) \
1150- ((ZEND_GET_ARG_FLAG( zf, arg_num) & ZEND_SEND_BY_REF) != 0 )
1122+ ZEND_CHECK_ARG_FLAG( zf, arg_num, ZEND_SEND_BY_REF|ZEND_SEND_PREFER_REF )
11511123
11521124#define QUICK_ARG_MAY_BE_SENT_BY_REF (zf , arg_num ) \
1153- (ZEND_GET_ARG_FLAG( zf, arg_num) != ZEND_SEND_BY_VAL )
1125+ ZEND_CHECK_ARG_FLAG( zf, arg_num, ZEND_SEND_PREFER_REF )
11541126
11551127#define ZEND_RETURN_VAL 0
11561128#define ZEND_RETURN_REF 1
0 commit comments