diff --git a/Zend/Optimizer/escape_analysis.c b/Zend/Optimizer/escape_analysis.c index 193479bae4b7..0b25e7f1efb4 100644 --- a/Zend/Optimizer/escape_analysis.c +++ b/Zend/Optimizer/escape_analysis.c @@ -160,7 +160,7 @@ static bool is_allocation_def(zend_op_array *op_array, zend_ssa *ssa, int def, i /* objects with destructors should escape */ zend_class_entry *ce = zend_optimizer_get_class_entry_from_op1( script, op_array, opline); - uint32_t forbidden_flags = + zend_ce_flags forbidden_flags = /* These flags will always cause an exception */ ZEND_ACC_IMPLICIT_ABSTRACT_CLASS | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT; diff --git a/Zend/Optimizer/zend_optimizer.c b/Zend/Optimizer/zend_optimizer.c index 3738e058cd88..74fe3b8a8bf1 100644 --- a/Zend/Optimizer/zend_optimizer.c +++ b/Zend/Optimizer/zend_optimizer.c @@ -1700,7 +1700,7 @@ ZEND_API void zend_optimize_script(zend_script *script, zend_long optimization_l ZEND_ASSERT(orig_op_array != NULL); if (orig_op_array != op_array) { - uint32_t fn_flags = op_array->fn_flags; + zend_fn_flags fn_flags = op_array->fn_flags; zend_function *prototype = op_array->prototype; HashTable *ht = op_array->static_variables; diff --git a/Zend/zend.h b/Zend/zend.h index bc252f4706b0..69ee5025f743 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -98,6 +98,8 @@ typedef struct _zend_trait_precedence { zend_string *exclude_class_names[1]; } zend_trait_precedence; +typedef uint64_t zend_fn_flags; + typedef struct _zend_trait_alias { zend_trait_method_reference trait_method; @@ -109,13 +111,15 @@ typedef struct _zend_trait_alias { /** * modifiers to be set on trait method */ - uint32_t modifiers; + zend_fn_flags modifiers; } zend_trait_alias; +typedef uint64_t zend_ce_flags; + typedef struct _zend_class_mutable_data { zval *default_properties_table; HashTable *constants_table; - uint32_t ce_flags; + zend_ce_flags ce_flags; HashTable *backed_enum_table; } zend_class_mutable_data; @@ -152,8 +156,8 @@ struct _zend_class_entry { zend_class_entry *parent; zend_string *parent_name; }; + zend_ce_flags ce_flags; int refcount; - uint32_t ce_flags; int default_properties_count; int default_static_members_count; diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 2a16f24250eb..d1a6c08ab86f 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -1495,7 +1495,7 @@ ZEND_API zend_result zend_update_class_constants(zend_class_entry *class_type) / zval *static_members_table = NULL; zend_class_constant *c; zval *val; - uint32_t ce_flags; + zend_ce_flags ce_flags; ce_flags = class_type->ce_flags; @@ -4388,7 +4388,7 @@ static zend_always_inline bool is_persistent_class(zend_class_entry *ce) { && ce->info.internal.module->type == MODULE_PERSISTENT; } -ZEND_API zend_property_info *zend_declare_typed_property(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment, zend_type type) /* {{{ */ +ZEND_API zend_property_info *zend_declare_typed_property(zend_class_entry *ce, zend_string *name, zval *property, zend_prop_flags access_type, zend_string *doc_comment, zend_type type) /* {{{ */ { zend_property_info *property_info, *property_info_ptr; @@ -4634,13 +4634,13 @@ ZEND_API zend_result zend_try_assign_typed_ref_zval_ex(zend_reference *ref, zval } /* }}} */ -ZEND_API void zend_declare_property_ex(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment) /* {{{ */ +ZEND_API void zend_declare_property_ex(zend_class_entry *ce, zend_string *name, zval *property, zend_prop_flags access_type, zend_string *doc_comment) /* {{{ */ { zend_declare_typed_property(ce, name, property, access_type, doc_comment, (zend_type) ZEND_TYPE_INIT_NONE(0)); } /* }}} */ -ZEND_API void zend_declare_property(zend_class_entry *ce, const char *name, size_t name_length, zval *property, int access_type) /* {{{ */ +ZEND_API void zend_declare_property(zend_class_entry *ce, const char *name, size_t name_length, zval *property, zend_prop_flags access_type) /* {{{ */ { zend_string *key = zend_string_init(name, name_length, is_persistent_class(ce)); zend_declare_property_ex(ce, key, property, access_type, NULL); @@ -4648,7 +4648,7 @@ ZEND_API void zend_declare_property(zend_class_entry *ce, const char *name, size } /* }}} */ -ZEND_API void zend_declare_property_null(zend_class_entry *ce, const char *name, size_t name_length, int access_type) /* {{{ */ +ZEND_API void zend_declare_property_null(zend_class_entry *ce, const char *name, size_t name_length, zend_prop_flags access_type) /* {{{ */ { zval property; @@ -4657,7 +4657,7 @@ ZEND_API void zend_declare_property_null(zend_class_entry *ce, const char *name, } /* }}} */ -ZEND_API void zend_declare_property_bool(zend_class_entry *ce, const char *name, size_t name_length, zend_long value, int access_type) /* {{{ */ +ZEND_API void zend_declare_property_bool(zend_class_entry *ce, const char *name, size_t name_length, zend_long value, zend_prop_flags access_type) /* {{{ */ { zval property; @@ -4666,7 +4666,7 @@ ZEND_API void zend_declare_property_bool(zend_class_entry *ce, const char *name, } /* }}} */ -ZEND_API void zend_declare_property_long(zend_class_entry *ce, const char *name, size_t name_length, zend_long value, int access_type) /* {{{ */ +ZEND_API void zend_declare_property_long(zend_class_entry *ce, const char *name, size_t name_length, zend_long value, zend_prop_flags access_type) /* {{{ */ { zval property; @@ -4675,7 +4675,7 @@ ZEND_API void zend_declare_property_long(zend_class_entry *ce, const char *name, } /* }}} */ -ZEND_API void zend_declare_property_double(zend_class_entry *ce, const char *name, size_t name_length, double value, int access_type) /* {{{ */ +ZEND_API void zend_declare_property_double(zend_class_entry *ce, const char *name, size_t name_length, double value, zend_prop_flags access_type) /* {{{ */ { zval property; @@ -4684,7 +4684,7 @@ ZEND_API void zend_declare_property_double(zend_class_entry *ce, const char *nam } /* }}} */ -ZEND_API void zend_declare_property_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value, int access_type) /* {{{ */ +ZEND_API void zend_declare_property_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value, zend_prop_flags access_type) /* {{{ */ { zval property; @@ -4693,7 +4693,7 @@ ZEND_API void zend_declare_property_string(zend_class_entry *ce, const char *nam } /* }}} */ -ZEND_API void zend_declare_property_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_len, int access_type) /* {{{ */ +ZEND_API void zend_declare_property_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_len, zend_prop_flags access_type) /* {{{ */ { zval property; @@ -4702,7 +4702,7 @@ ZEND_API void zend_declare_property_stringl(zend_class_entry *ce, const char *na } /* }}} */ -ZEND_API zend_class_constant *zend_declare_typed_class_constant(zend_class_entry *ce, zend_string *name, zval *value, int flags, zend_string *doc_comment, zend_type type) /* {{{ */ +ZEND_API zend_class_constant *zend_declare_typed_class_constant(zend_class_entry *ce, zend_string *name, zval *value, zend_class_const_flags flags, zend_string *doc_comment, zend_type type) /* {{{ */ { zend_class_constant *c; @@ -4752,7 +4752,7 @@ ZEND_API zend_class_constant *zend_declare_typed_class_constant(zend_class_entry return c; } -ZEND_API zend_class_constant *zend_declare_class_constant_ex(zend_class_entry *ce, zend_string *name, zval *value, int flags, zend_string *doc_comment) +ZEND_API zend_class_constant *zend_declare_class_constant_ex(zend_class_entry *ce, zend_string *name, zval *value, zend_class_const_flags flags, zend_string *doc_comment) { return zend_declare_typed_class_constant(ce, name, value, flags, doc_comment, (zend_type) ZEND_TYPE_INIT_NONE(0)); } diff --git a/Zend/zend_API.h b/Zend/zend_API.h index aa085c70d9bb..aa8261e28113 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -37,7 +37,7 @@ typedef struct _zend_function_entry { zif_handler handler; const struct _zend_internal_arg_info *arg_info; uint32_t num_args; - uint32_t flags; + zend_fn_flags flags; const zend_frameless_function_info *frameless_function_infos; const char *doc_comment; } zend_function_entry; @@ -422,19 +422,19 @@ ZEND_API bool zend_make_callable(zval *callable, zend_string **callable_name); ZEND_API const char *zend_get_module_version(const char *module_name); ZEND_API zend_result zend_get_module_started(const char *module_name); -ZEND_API zend_property_info *zend_declare_typed_property(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment, zend_type type); +ZEND_API zend_property_info *zend_declare_typed_property(zend_class_entry *ce, zend_string *name, zval *property, zend_prop_flags access_type, zend_string *doc_comment, zend_type type); -ZEND_API void zend_declare_property_ex(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment); -ZEND_API void zend_declare_property(zend_class_entry *ce, const char *name, size_t name_length, zval *property, int access_type); -ZEND_API void zend_declare_property_null(zend_class_entry *ce, const char *name, size_t name_length, int access_type); -ZEND_API void zend_declare_property_bool(zend_class_entry *ce, const char *name, size_t name_length, zend_long value, int access_type); -ZEND_API void zend_declare_property_long(zend_class_entry *ce, const char *name, size_t name_length, zend_long value, int access_type); -ZEND_API void zend_declare_property_double(zend_class_entry *ce, const char *name, size_t name_length, double value, int access_type); -ZEND_API void zend_declare_property_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value, int access_type); -ZEND_API void zend_declare_property_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_len, int access_type); +ZEND_API void zend_declare_property_ex(zend_class_entry *ce, zend_string *name, zval *property, zend_prop_flags access_type, zend_string *doc_comment); +ZEND_API void zend_declare_property(zend_class_entry *ce, const char *name, size_t name_length, zval *property, zend_prop_flags access_type); +ZEND_API void zend_declare_property_null(zend_class_entry *ce, const char *name, size_t name_length, zend_prop_flags access_type); +ZEND_API void zend_declare_property_bool(zend_class_entry *ce, const char *name, size_t name_length, zend_long value, zend_prop_flags access_type); +ZEND_API void zend_declare_property_long(zend_class_entry *ce, const char *name, size_t name_length, zend_long value, zend_prop_flags access_type); +ZEND_API void zend_declare_property_double(zend_class_entry *ce, const char *name, size_t name_length, double value, zend_prop_flags access_type); +ZEND_API void zend_declare_property_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value, zend_prop_flags access_type); +ZEND_API void zend_declare_property_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_len, zend_prop_flags access_type); -ZEND_API zend_class_constant *zend_declare_typed_class_constant(zend_class_entry *ce, zend_string *name, zval *value, int access_type, zend_string *doc_comment, zend_type type); -ZEND_API zend_class_constant *zend_declare_class_constant_ex(zend_class_entry *ce, zend_string *name, zval *value, int access_type, zend_string *doc_comment); +ZEND_API zend_class_constant *zend_declare_typed_class_constant(zend_class_entry *ce, zend_string *name, zval *value, zend_class_const_flags access_type, zend_string *doc_comment, zend_type type); +ZEND_API zend_class_constant *zend_declare_class_constant_ex(zend_class_entry *ce, zend_string *name, zval *value, zend_class_const_flags access_type, zend_string *doc_comment); ZEND_API void zend_declare_class_constant(zend_class_entry *ce, const char *name, size_t name_length, zval *value); ZEND_API void zend_declare_class_constant_null(zend_class_entry *ce, const char *name, size_t name_length); ZEND_API void zend_declare_class_constant_long(zend_class_entry *ce, const char *name, size_t name_length, zend_long value); diff --git a/Zend/zend_ast.h b/Zend/zend_ast.h index 963b81e53308..693782663583 100644 --- a/Zend/zend_ast.h +++ b/Zend/zend_ast.h @@ -207,7 +207,7 @@ typedef struct _zend_ast_decl { zend_ast_attr attr; /* Unused - for structure compatibility */ uint32_t start_lineno; uint32_t end_lineno; - uint32_t flags; + uint64_t flags; zend_string *doc_comment; zend_string *name; zend_ast *child[5]; diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index c92f507a1b2a..2da20217a615 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1002,7 +1002,7 @@ flf_clean:; Z_FLF_PARAM_FREE_STR(2, property_tmp) } -static inline void _class_exists_impl(zval *return_value, zend_string *name, bool autoload, int flags, int skip_flags) /* {{{ */ +static inline void _class_exists_impl(zval *return_value, zend_string *name, bool autoload, zend_ce_flags flags, zend_ce_flags skip_flags) /* {{{ */ { zend_string *lcname; zend_class_entry *ce; @@ -1037,7 +1037,7 @@ static inline void _class_exists_impl(zval *return_value, zend_string *name, boo } /* {{{ */ -static inline void class_exists_impl(INTERNAL_FUNCTION_PARAMETERS, int flags, int skip_flags) /* {{{ */ +static inline void class_exists_impl(INTERNAL_FUNCTION_PARAMETERS, zend_ce_flags flags, zend_ce_flags skip_flags) /* {{{ */ { zend_string *name; bool autoload = true; diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 4077ef4ef080..c63c891a8331 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -7029,7 +7029,7 @@ static void zend_compile_attributes( } } - uint32_t flags = (CG(active_op_array)->fn_flags & ZEND_ACC_STRICT_TYPES) + zend_fn_flags flags = (CG(active_op_array)->fn_flags & ZEND_ACC_STRICT_TYPES) ? ZEND_ATTRIBUTE_STRICT_TYPES : 0; attr = zend_add_attribute( attributes, name, args ? args->children : 0, flags, offset, el->lineno); @@ -7597,7 +7597,7 @@ static zend_string *zend_begin_method_decl(zend_op_array *op_array, zend_string { zend_class_entry *ce = CG(active_class_entry); bool in_interface = (ce->ce_flags & ZEND_ACC_INTERFACE) != 0; - uint32_t fn_flags = op_array->fn_flags; + zend_fn_flags fn_flags = op_array->fn_flags; zend_string *lcname; @@ -7994,7 +7994,7 @@ static void zend_check_trait_alias_modifiers(uint32_t attr) /* {{{ */ } /* }}} */ -static void zend_compile_class_const_decl(zend_ast *ast, uint32_t flags, zend_ast *attr_ast, zend_ast *type_ast) +static void zend_compile_class_const_decl(zend_ast *ast, zend_class_const_flags flags, zend_ast *attr_ast, zend_ast *type_ast) { zend_ast_list *list = zend_ast_get_list(ast); zend_class_entry *ce = CG(active_class_entry); diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 8efc57163da8..b4f03909429f 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -249,7 +249,7 @@ typedef struct _zend_oparray_context { /* or IS_CONSTANT_VISITED_MARK | | | */ #define ZEND_CLASS_CONST_IS_CASE (1 << 6) /* | | | X */ /* | | | */ -/* Class Flags (unused: 30,31) | | | */ +/* Class Flags (unused: 30-63) | | | */ /* =========== | | | */ /* | | | */ /* Special class types | | | */ @@ -315,7 +315,7 @@ typedef struct _zend_oparray_context { /* Class cannot be serialized or unserialized | | | */ #define ZEND_ACC_NOT_SERIALIZABLE (1 << 29) /* X | | | */ /* | | | */ -/* Function Flags (unused: 29-30) | | | */ +/* Function Flags (unused: 29-30,32-63) | | | */ /* ============== | | | */ /* | | | */ /* deprecation flag | | | */ @@ -394,12 +394,16 @@ typedef struct _zend_oparray_context { // Must not clash with ZEND_SHORT_CIRCUITING_CHAIN_MASK #define ZEND_JMP_NULL_BP_VAR_IS 4 -char *zend_visibility_string(uint32_t fn_flags); +typedef uint64_t zend_fn_flags; + +char *zend_visibility_string(zend_fn_flags fn_flags); + +typedef uint64_t zend_prop_flags; typedef struct _zend_property_info { uint32_t offset; /* property offset for object properties or property index for static properties */ - uint32_t flags; + zend_prop_flags flags; zend_string *name; zend_string *doc_comment; HashTable *attributes; @@ -416,6 +420,8 @@ typedef struct _zend_property_info { #define OBJ_PROP_TO_NUM(offset) \ ((offset - OBJ_PROP_TO_OFFSET(0)) / sizeof(zval)) +typedef uint32_t zend_class_const_flags; + typedef struct _zend_class_constant { zval value; /* flags are stored in u2 */ zend_string *doc_comment; @@ -455,7 +461,7 @@ struct _zend_op_array { /* Common elements */ uint8_t type; uint8_t arg_flags[3]; /* bitset of arg_info.pass_by_reference */ - uint32_t fn_flags; + zend_fn_flags fn_flags; zend_string *function_name; zend_class_entry *scope; zend_function *prototype; @@ -513,7 +519,7 @@ typedef struct _zend_internal_function { /* Common elements */ uint8_t type; uint8_t arg_flags[3]; /* bitset of arg_info.pass_by_reference */ - uint32_t fn_flags; + zend_fn_flags fn_flags; zend_string* function_name; zend_class_entry *scope; zend_function *prototype; @@ -541,7 +547,7 @@ union _zend_function { struct { uint8_t type; /* never used */ uint8_t arg_flags[3]; /* bitset of arg_info.pass_by_reference */ - uint32_t fn_flags; + zend_fn_flags fn_flags; zend_string *function_name; zend_class_entry *scope; zend_function *prototype; diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c index ed649ba29859..c23bbf4de139 100644 --- a/Zend/zend_constants.c +++ b/Zend/zend_constants.c @@ -116,7 +116,7 @@ void zend_register_standard_constants(void) null_const = zend_hash_str_find_ptr(EG(zend_constants), "NULL", sizeof("NULL")-1); } -ZEND_API void zend_register_null_constant(const char *name, size_t name_len, int flags, int module_number) +ZEND_API void zend_register_null_constant(const char *name, size_t name_len, zend_const_flags flags, int module_number) { zend_constant c; @@ -126,7 +126,7 @@ ZEND_API void zend_register_null_constant(const char *name, size_t name_len, int zend_register_constant(&c); } -ZEND_API void zend_register_bool_constant(const char *name, size_t name_len, bool bval, int flags, int module_number) +ZEND_API void zend_register_bool_constant(const char *name, size_t name_len, bool bval, zend_const_flags flags, int module_number) { zend_constant c; @@ -136,7 +136,7 @@ ZEND_API void zend_register_bool_constant(const char *name, size_t name_len, boo zend_register_constant(&c); } -ZEND_API void zend_register_long_constant(const char *name, size_t name_len, zend_long lval, int flags, int module_number) +ZEND_API void zend_register_long_constant(const char *name, size_t name_len, zend_long lval, zend_const_flags flags, int module_number) { zend_constant c; @@ -147,7 +147,7 @@ ZEND_API void zend_register_long_constant(const char *name, size_t name_len, zen } -ZEND_API void zend_register_double_constant(const char *name, size_t name_len, double dval, int flags, int module_number) +ZEND_API void zend_register_double_constant(const char *name, size_t name_len, double dval, zend_const_flags flags, int module_number) { zend_constant c; @@ -158,7 +158,7 @@ ZEND_API void zend_register_double_constant(const char *name, size_t name_len, d } -ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len, const char *strval, size_t strlen, int flags, int module_number) +ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len, const char *strval, size_t strlen, zend_const_flags flags, int module_number) { zend_constant c; @@ -169,7 +169,7 @@ ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len, } -ZEND_API void zend_register_string_constant(const char *name, size_t name_len, const char *strval, int flags, int module_number) +ZEND_API void zend_register_string_constant(const char *name, size_t name_len, const char *strval, zend_const_flags flags, int module_number) { zend_register_stringl_constant(name, name_len, strval, strlen(strval), flags, module_number); } diff --git a/Zend/zend_constants.h b/Zend/zend_constants.h index 33e51858430c..abf3281d46c5 100644 --- a/Zend/zend_constants.h +++ b/Zend/zend_constants.h @@ -30,6 +30,8 @@ #define PHP_USER_CONSTANT 0x7fffff /* a constant defined in user space */ +typedef uint32_t zend_const_flags; + typedef struct _zend_constant { zval value; zend_string *name; @@ -75,14 +77,14 @@ void zend_register_standard_constants(void); ZEND_API bool zend_verify_const_access(zend_class_constant *c, zend_class_entry *ce); ZEND_API zval *zend_get_constant(zend_string *name); ZEND_API zval *zend_get_constant_str(const char *name, size_t name_len); -ZEND_API zval *zend_get_constant_ex(zend_string *name, zend_class_entry *scope, uint32_t flags); -ZEND_API zval *zend_get_class_constant_ex(zend_string *class_name, zend_string *constant_name, zend_class_entry *scope, uint32_t flags); -ZEND_API void zend_register_bool_constant(const char *name, size_t name_len, bool bval, int flags, int module_number); -ZEND_API void zend_register_null_constant(const char *name, size_t name_len, int flags, int module_number); -ZEND_API void zend_register_long_constant(const char *name, size_t name_len, zend_long lval, int flags, int module_number); -ZEND_API void zend_register_double_constant(const char *name, size_t name_len, double dval, int flags, int module_number); -ZEND_API void zend_register_string_constant(const char *name, size_t name_len, const char *strval, int flags, int module_number); -ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len, const char *strval, size_t strlen, int flags, int module_number); +ZEND_API zval *zend_get_constant_ex(zend_string *name, zend_class_entry *scope, zend_const_flags flags); +ZEND_API zval *zend_get_class_constant_ex(zend_string *class_name, zend_string *constant_name, zend_class_entry *scope, zend_const_flags flags); +ZEND_API void zend_register_bool_constant(const char *name, size_t name_len, bool bval, zend_const_flags flags, int module_number); +ZEND_API void zend_register_null_constant(const char *name, size_t name_len, zend_const_flags flags, int module_number); +ZEND_API void zend_register_long_constant(const char *name, size_t name_len, zend_long lval, zend_const_flags flags, int module_number); +ZEND_API void zend_register_double_constant(const char *name, size_t name_len, double dval, zend_const_flags flags, int module_number); +ZEND_API void zend_register_string_constant(const char *name, size_t name_len, const char *strval, zend_const_flags flags, int module_number); +ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len, const char *strval, size_t strlen, zend_const_flags flags, int module_number); ZEND_API zend_result zend_register_constant(zend_constant *c); #ifdef ZTS void zend_copy_constants(HashTable *target, HashTable *source); diff --git a/Zend/zend_enum.c b/Zend/zend_enum.c index 2c0a9611a314..c26c41e38ba6 100644 --- a/Zend/zend_enum.c +++ b/Zend/zend_enum.c @@ -431,7 +431,7 @@ static void zend_enum_register_func(zend_class_entry *ce, zend_known_string_id n void zend_enum_register_funcs(zend_class_entry *ce) { - const uint32_t fn_flags = + const zend_fn_flags fn_flags = ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_HAS_RETURN_TYPE|ZEND_ACC_ARENA_ALLOCATED; zend_internal_function *cases_function = zend_arena_calloc(&CG(arena), sizeof(zend_internal_function), 1); cases_function->handler = zend_enum_cases_func; diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 491d68714b3c..d962c5d4e1f6 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -196,7 +196,7 @@ static void do_inherit_parent_constructor(zend_class_entry *ce) /* {{{ */ } /* }}} */ -char *zend_visibility_string(uint32_t fn_flags) /* {{{ */ +char *zend_visibility_string(zend_fn_flags fn_flags) /* {{{ */ { if (fn_flags & ZEND_ACC_PUBLIC) { return "public"; @@ -1089,8 +1089,8 @@ static zend_always_inline inheritance_status do_inheritance_check_on_method_ex( zend_class_entry *ce, zval *child_zv, bool check_visibility, bool check_only, bool checked, bool force_mutable) /* {{{ */ { - uint32_t child_flags; - uint32_t parent_flags = parent->common.fn_flags; + zend_fn_flags child_flags; + zend_fn_flags parent_flags = parent->common.fn_flags; zend_function *proto; if (UNEXPECTED((parent_flags & ZEND_ACC_PRIVATE) && !(parent_flags & ZEND_ACC_ABSTRACT) && !(parent_flags & ZEND_ACC_CTOR))) { @@ -2032,7 +2032,7 @@ static void zend_fixup_trait_method(zend_function *fn, zend_class_entry *ce) /* } /* }}} */ -static void zend_traits_check_private_final_inheritance(uint32_t original_fn_flags, zend_function *fn_copy, zend_string *name) +static void zend_traits_check_private_final_inheritance(zend_fn_flags original_fn_flags, zend_function *fn_copy, zend_string *name) { /* If the function was originally already private+final, then it will have already been warned about. * If the function became private+final only after applying modifiers, we need to emit the same warning. */ @@ -2483,7 +2483,7 @@ static void zend_do_traits_property_binding(zend_class_entry *ce, zend_class_ent continue; } ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(&traits[i]->properties_info, prop_name, property_info) { - uint32_t flags = property_info->flags; + zend_prop_flags flags = property_info->flags; /* next: check for conflicts with current class */ if ((colliding_prop = zend_hash_find_ptr(&ce->properties_info, prop_name)) != NULL) { @@ -2492,7 +2492,7 @@ static void zend_do_traits_property_binding(zend_class_entry *ce, zend_class_ent flags |= ZEND_ACC_CHANGED; } else { bool is_compatible = false; - uint32_t flags_mask = ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC | ZEND_ACC_READONLY; + zend_prop_flags flags_mask = ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC | ZEND_ACC_READONLY; if ((colliding_prop->flags & flags_mask) == (flags & flags_mask) && property_types_compatible(property_info, colliding_prop) == INHERITANCE_SUCCESS @@ -3011,7 +3011,7 @@ ZEND_API zend_class_entry *zend_do_link_class(zend_class_entry *ce, zend_string zend_class_entry **traits_and_interfaces = NULL; zend_class_entry *proto = NULL; zend_class_entry *orig_linking_class; - uint32_t is_cacheable = ce->ce_flags & ZEND_ACC_IMMUTABLE; + zend_ce_flags is_cacheable = ce->ce_flags & ZEND_ACC_IMMUTABLE; uint32_t i, j; zval *zv; ALLOCA_FLAG(use_heap) @@ -3355,7 +3355,7 @@ ZEND_API zend_class_entry *zend_try_early_bind(zend_class_entry *ce, zend_class_ return ce; } - uint32_t is_cacheable = ce->ce_flags & ZEND_ACC_IMMUTABLE; + zend_ce_flags is_cacheable = ce->ce_flags & ZEND_ACC_IMMUTABLE; UPDATE_IS_CACHEABLE(parent_ce); if (is_cacheable) { if (zend_inheritance_cache_get && zend_inheritance_cache_add) { diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index f72cb76489ab..66636ae10756 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -316,7 +316,7 @@ static zend_always_inline uintptr_t zend_get_property_offset(zend_class_entry *c { zval *zv; zend_property_info *property_info; - uint32_t flags; + zend_prop_flags flags; zend_class_entry *scope; uintptr_t offset; diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 1c2960fd8d81..5092546ff2a1 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -3916,7 +3916,7 @@ static void preload_link(void) * prevent freeing of interface names. */ void *checkpoint = zend_arena_checkpoint(CG(arena)); zend_class_entry *orig_ce = ce; - uint32_t temporary_flags = ZEND_ACC_FILE_CACHED|ZEND_ACC_CACHED; + zend_ce_flags temporary_flags = ZEND_ACC_FILE_CACHED|ZEND_ACC_CACHED; ce->ce_flags |= temporary_flags; if (ce->parent_name) { zend_string_addref(ce->parent_name); @@ -4165,7 +4165,7 @@ static void preload_fix_trait_methods(zend_class_entry *ce) zend_string *function_name = op_array->function_name; zend_class_entry *scope = op_array->scope; - uint32_t fn_flags = op_array->fn_flags; + zend_fn_flags fn_flags = op_array->fn_flags; zend_function *prototype = op_array->prototype; HashTable *ht = op_array->static_variables; *op_array = *orig_op_array; diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c index 7c35481e1a41..0ca58b9793b5 100644 --- a/ext/opcache/jit/zend_jit_ir.c +++ b/ext/opcache/jit/zend_jit_ir.c @@ -8126,9 +8126,9 @@ static int zend_jit_free_trampoline(zend_jit_ctx *jit, int8_t func_reg) { // JIT: if (UNEXPECTED(func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) ir_ref func = ir_RLOAD_A(func_reg); - ir_ref if_trampoline = ir_IF(ir_AND_U32( - ir_LOAD_U32(ir_ADD_OFFSET(func, offsetof(zend_function, common.fn_flags))), - ir_CONST_U32(ZEND_ACC_CALL_VIA_TRAMPOLINE))); + ir_ref if_trampoline = ir_IF(ir_AND_U64( + ir_LOAD_U64(ir_ADD_OFFSET(func, offsetof(zend_function, common.fn_flags))), + ir_CONST_U64(ZEND_ACC_CALL_VIA_TRAMPOLINE))); ir_IF_TRUE(if_trampoline); ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(zend_jit_free_trampoline_helper), func); @@ -8346,7 +8346,8 @@ static int zend_jit_push_call_frame(zend_jit_ctx *jit, const zend_op *opline, co // (closure->func->common.fn_flags & ZEND_ACC_FAKE_CLOSURE); call_info = ir_OR_U32( ir_AND_U32( - ir_LOAD_U32(ir_ADD_OFFSET(func_ref, offsetof(zend_closure, func.common.fn_flags))), + // Truncate high bytes, call_info is stored in type_info, which is only 32-bits. + ir_TRUNC_U32(ir_LOAD_U64(ir_ADD_OFFSET(func_ref, offsetof(zend_closure, func.common.fn_flags)))), ir_CONST_U32(ZEND_ACC_FAKE_CLOSURE)), ir_CONST_U32(ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_DYNAMIC | ZEND_CALL_CLOSURE)); // JIT: if (Z_TYPE(closure->this_ptr) != IS_UNDEF) { @@ -8791,9 +8792,9 @@ static int zend_jit_init_method_call(zend_jit_ctx *jit, if (!func) { // JIT: if (fbc->common.fn_flags & ZEND_ACC_STATIC) { - if_static = ir_IF(ir_AND_U32( - ir_LOAD_U32(ir_ADD_OFFSET(func_ref, offsetof(zend_function, common.fn_flags))), - ir_CONST_U32(ZEND_ACC_STATIC))); + if_static = ir_IF(ir_AND_U64( + ir_LOAD_U64(ir_ADD_OFFSET(func_ref, offsetof(zend_function, common.fn_flags))), + ir_CONST_U64(ZEND_ACC_STATIC))); ir_IF_TRUE_cold(if_static); } @@ -9592,9 +9593,9 @@ static int zend_jit_do_fcall(zend_jit_ctx *jit, const zend_op *opline, const zen func_ref = ir_LOAD_A(jit_CALL(rx, func)); ir_GUARD_NOT( - ir_AND_U32( - ir_LOAD_U32(ir_ADD_OFFSET(func_ref, offsetof(zend_op_array, fn_flags))), - ir_CONST_U32(ZEND_ACC_DEPRECATED)), + ir_AND_U64( + ir_LOAD_U64(ir_ADD_OFFSET(func_ref, offsetof(zend_op_array, fn_flags))), + ir_CONST_U64(ZEND_ACC_DEPRECATED)), ir_CONST_ADDR(exit_addr)); } } @@ -9622,9 +9623,9 @@ static int zend_jit_do_fcall(zend_jit_ctx *jit, const zend_op *opline, const zen if (!trace) { ir_ref if_deprecated, ret; - if_deprecated = ir_IF(ir_AND_U32( - ir_LOAD_U32(ir_ADD_OFFSET(func_ref, offsetof(zend_op_array, fn_flags))), - ir_CONST_U32(ZEND_ACC_DEPRECATED))); + if_deprecated = ir_IF(ir_AND_U64( + ir_LOAD_U64(ir_ADD_OFFSET(func_ref, offsetof(zend_op_array, fn_flags))), + ir_CONST_U64(ZEND_ACC_DEPRECATED))); ir_IF_TRUE_cold(if_deprecated); if (GCC_GLOBAL_REGS) { @@ -9814,9 +9815,9 @@ static int zend_jit_do_fcall(zend_jit_ctx *jit, const zend_op *opline, const zen if (!func || (func->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) == 0) { if (!func) { // JIT: if (EXPECTED((op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS) == 0)) - ir_ref if_has_type_hints = ir_IF(ir_AND_U32( - ir_LOAD_U32(ir_ADD_OFFSET(func_ref, offsetof(zend_op_array, fn_flags))), - ir_CONST_U32(ZEND_ACC_HAS_TYPE_HINTS))); + ir_ref if_has_type_hints = ir_IF(ir_AND_U64( + ir_LOAD_U64(ir_ADD_OFFSET(func_ref, offsetof(zend_op_array, fn_flags))), + ir_CONST_U64(ZEND_ACC_HAS_TYPE_HINTS))); ir_IF_TRUE(if_has_type_hints); ir_END_list(merge_inputs); ir_IF_FALSE(if_has_type_hints); @@ -9974,16 +9975,16 @@ static int zend_jit_do_fcall(zend_jit_ctx *jit, const zend_op *opline, const zen } ZEND_ASSERT(func_ref); ir_GUARD_NOT( - ir_AND_U32( - ir_LOAD_U32(ir_ADD_OFFSET(func_ref, offsetof(zend_op_array, fn_flags))), - ir_CONST_U32(ZEND_ACC_DEPRECATED)), + ir_AND_U64( + ir_LOAD_U64(ir_ADD_OFFSET(func_ref, offsetof(zend_op_array, fn_flags))), + ir_CONST_U64(ZEND_ACC_DEPRECATED)), ir_CONST_ADDR(exit_addr)); } else { ir_ref if_deprecated, ret; - if_deprecated = ir_IF(ir_AND_U32( - ir_LOAD_U32(ir_ADD_OFFSET(func_ref, offsetof(zend_op_array, fn_flags))), - ir_CONST_U32(ZEND_ACC_DEPRECATED))); + if_deprecated = ir_IF(ir_AND_U64( + ir_LOAD_U64(ir_ADD_OFFSET(func_ref, offsetof(zend_op_array, fn_flags))), + ir_CONST_U64(ZEND_ACC_DEPRECATED))); ir_IF_TRUE_cold(if_deprecated); if (GCC_GLOBAL_REGS) { @@ -13769,8 +13770,8 @@ static int zend_jit_fetch_obj(zend_jit_ctx *jit, ir_IF_TRUE_cold(if_has_prop_info); ir_ref if_readonly = ir_IF( - ir_AND_U32(ir_LOAD_U32(ir_ADD_OFFSET(prop_info_ref, offsetof(zend_property_info, flags))), - ir_CONST_U32(ZEND_ACC_READONLY))); + ir_AND_U64(ir_LOAD_U64(ir_ADD_OFFSET(prop_info_ref, offsetof(zend_property_info, flags))), + ir_CONST_U64(ZEND_ACC_READONLY))); ir_IF_TRUE(if_readonly); ir_ref if_prop_obj = jit_if_Z_TYPE(jit, prop_addr, IS_OBJECT); diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 6f201d85ed23..cd011872794f 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -1251,7 +1251,7 @@ static void _zend_extension_string(smart_str *str, zend_extension *extension, ch /* }}} */ /* {{{ _function_check_flag */ -static void _function_check_flag(INTERNAL_FUNCTION_PARAMETERS, int mask) +static void _function_check_flag(INTERNAL_FUNCTION_PARAMETERS, zend_fn_flags mask) { reflection_object *intern; zend_function *mptr; @@ -3697,7 +3697,7 @@ ZEND_METHOD(ReflectionMethod, getModifiers) { reflection_object *intern; zend_function *mptr; - uint32_t keep_flags = ZEND_ACC_PPP_MASK + zend_fn_flags keep_flags = ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC | ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL; if (zend_parse_parameters_none() == FAILURE) { @@ -3894,7 +3894,7 @@ ZEND_METHOD(ReflectionClassConstant, hasType) RETVAL_BOOL(ZEND_TYPE_IS_SET(ref->type)); } -static void _class_constant_check_flag(INTERNAL_FUNCTION_PARAMETERS, int mask) /* {{{ */ +static void _class_constant_check_flag(INTERNAL_FUNCTION_PARAMETERS, zend_class_const_flags mask) /* {{{ */ { reflection_object *intern; zend_class_constant *ref; @@ -3939,7 +3939,7 @@ ZEND_METHOD(ReflectionClassConstant, getModifiers) { reflection_object *intern; zend_class_constant *ref; - uint32_t keep_flags = ZEND_ACC_FINAL | ZEND_ACC_PPP_MASK; + zend_class_const_flags keep_flags = ZEND_ACC_FINAL | ZEND_ACC_PPP_MASK; if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); @@ -4508,7 +4508,7 @@ ZEND_METHOD(ReflectionClass, getMethod) /* }}} */ /* {{{ _addmethod */ -static bool _addmethod(zend_function *mptr, zend_class_entry *ce, HashTable *ht, zend_long filter) +static bool _addmethod(zend_function *mptr, zend_class_entry *ce, HashTable *ht, zend_fn_flags filter) { if ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) && mptr->common.scope != ce) { return 0; @@ -4533,6 +4533,7 @@ ZEND_METHOD(ReflectionClass, getMethods) zend_long filter; bool filter_is_null = 1; + // FIXME: sizeof(zend_long) < sizeof(zend_fn_flags) on 32-bit platforms if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &filter, &filter_is_null) == FAILURE) { RETURN_THROWS(); } @@ -4665,7 +4666,7 @@ ZEND_METHOD(ReflectionClass, getProperty) /* }}} */ /* {{{ _addproperty */ -static void _addproperty(zend_property_info *pptr, zend_string *key, zend_class_entry *ce, HashTable *ht, long filter) +static void _addproperty(zend_property_info *pptr, zend_string *key, zend_class_entry *ce, HashTable *ht, zend_long filter) { if ((pptr->flags & ZEND_ACC_PRIVATE) && pptr->ce != ce) { return; @@ -4711,6 +4712,7 @@ ZEND_METHOD(ReflectionClass, getProperties) zend_long filter; bool filter_is_null = 1; + // FIXME: sizeof(zend_long) < sizeof(zend_prop_flags) on 32-bit platforms if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &filter, &filter_is_null) == FAILURE) { RETURN_THROWS(); }