Skip to content

Bump flag size #13886

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

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion Zend/Optimizer/escape_analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Zend/Optimizer/zend_optimizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
10 changes: 7 additions & 3 deletions Zend/zend.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
24 changes: 12 additions & 12 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -4634,21 +4634,21 @@ 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);
zend_string_release(key);
}
/* }}} */

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;

Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -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));
}
Expand Down
24 changes: 12 additions & 12 deletions Zend/zend_API.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions Zend/zend_builtin_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
20 changes: 13 additions & 7 deletions Zend/zend_compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 | | | */
Expand Down Expand Up @@ -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 | | | */
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions Zend/zend_constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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);
}
Expand Down
Loading