Skip to content

Commit b093559

Browse files
committed
Add ce_flags2 & fn_flags2
Alternative to GH-19959.
1 parent f566312 commit b093559

File tree

10 files changed

+27
-0
lines changed

10 files changed

+27
-0
lines changed

Zend/Optimizer/zend_optimizer.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,11 +1727,13 @@ ZEND_API void zend_optimize_script(zend_script *script, zend_long optimization_l
17271727
ZEND_ASSERT(orig_op_array != NULL);
17281728
if (orig_op_array != op_array) {
17291729
uint32_t fn_flags = op_array->fn_flags;
1730+
uint32_t fn_flags2 = op_array->fn_flags2;
17301731
zend_function *prototype = op_array->prototype;
17311732
HashTable *ht = op_array->static_variables;
17321733

17331734
*op_array = *orig_op_array;
17341735
op_array->fn_flags = fn_flags;
1736+
op_array->fn_flags2 = fn_flags2;
17351737
op_array->prototype = prototype;
17361738
op_array->static_variables = ht;
17371739
}

Zend/zend.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ struct _zend_class_entry {
154154
};
155155
int refcount;
156156
uint32_t ce_flags;
157+
uint32_t ce_flags2;
157158

158159
int default_properties_count;
159160
int default_static_members_count;

Zend/zend_compile.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2048,6 +2048,7 @@ ZEND_API void zend_initialize_class_data(zend_class_entry *ce, bool nullify_hand
20482048

20492049
ce->refcount = 1;
20502050
ce->ce_flags = ZEND_ACC_CONSTANTS_UPDATED;
2051+
ce->ce_flags2 = 0;
20512052

20522053
if (CG(compiler_options) & ZEND_COMPILE_GUARDS) {
20532054
ce->ce_flags |= ZEND_ACC_USE_GUARDS;

Zend/zend_compile.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,11 @@ typedef struct _zend_oparray_context {
341341
/* Class cannot be serialized or unserialized | | | */
342342
#define ZEND_ACC_NOT_SERIALIZABLE (1 << 29) /* X | | | */
343343
/* | | | */
344+
/* Class Flags 2 (ce_flags2) (unused: 0-31) | | | */
345+
/* ========================= | | | */
346+
/* | | | */
347+
/* #define ZEND_ACC2_EXAMPLE (1 << 0) X | | | */
348+
/* | | | */
344349
/* Function Flags (unused: 30) | | | */
345350
/* ============== | | | */
346351
/* | | | */
@@ -407,6 +412,11 @@ typedef struct _zend_oparray_context {
407412
/* | | | */
408413
/* op_array uses strict mode types | | | */
409414
#define ZEND_ACC_STRICT_TYPES (1U << 31) /* | X | | */
415+
/* | | | */
416+
/* Function Flags 2 (fn_flags2) (unused: 0-31) | | | */
417+
/* ============================ | | | */
418+
/* | | | */
419+
/* #define ZEND_ACC2_EXAMPLE (1 << 0) | X | | */
410420

411421
#define ZEND_ACC_PPP_MASK (ZEND_ACC_PUBLIC | ZEND_ACC_PROTECTED | ZEND_ACC_PRIVATE)
412422
#define ZEND_ACC_PPP_SET_MASK (ZEND_ACC_PUBLIC_SET | ZEND_ACC_PROTECTED_SET | ZEND_ACC_PRIVATE_SET)
@@ -527,6 +537,7 @@ struct _zend_op_array {
527537
ZEND_MAP_PTR_DEF(void **, run_time_cache);
528538
zend_string *doc_comment;
529539
uint32_t T; /* number of temporary variables */
540+
uint32_t fn_flags2;
530541
const zend_property_info *prop_info; /* The corresponding prop_info if this is a hook. */
531542
/* END of common elements */
532543

@@ -586,6 +597,7 @@ typedef struct _zend_internal_function {
586597
ZEND_MAP_PTR_DEF(void **, run_time_cache);
587598
zend_string *doc_comment;
588599
uint32_t T; /* number of temporary variables */
600+
uint32_t fn_flags2;
589601
const zend_property_info *prop_info; /* The corresponding prop_info if this is a hook. */
590602
/* END of common elements */
591603

@@ -615,6 +627,7 @@ union _zend_function {
615627
ZEND_MAP_PTR_DEF(void **, run_time_cache);
616628
zend_string *doc_comment;
617629
uint32_t T; /* number of temporary variables */
630+
uint32_t fn_flags2;
618631
const zend_property_info *prop_info; /* The corresponding prop_info if this is a hook. */
619632
} common;
620633

Zend/zend_execute.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ ZEND_API const zend_internal_function zend_pass_function = {
153153
NULL, /* run_time_cache */
154154
NULL, /* doc_comment */
155155
0, /* T */
156+
0, /* fn_flags2 */
156157
NULL, /* prop_info */
157158
ZEND_FN(pass), /* handler */
158159
NULL, /* module */

Zend/zend_object_handlers.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,6 +1696,7 @@ ZEND_API zend_function *zend_get_call_trampoline_func(const zend_class_entry *ce
16961696
| ZEND_ACC_PUBLIC
16971697
| ZEND_ACC_VARIADIC
16981698
| (fbc->common.fn_flags & (ZEND_ACC_RETURN_REFERENCE|ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED|ZEND_ACC_NODISCARD));
1699+
func->fn_flags2 = 0;
16991700
/* Attributes outlive the trampoline because they are created by the compiler. */
17001701
func->attributes = fbc->common.attributes;
17011702
if (is_static) {
@@ -1797,6 +1798,7 @@ ZEND_API zend_function *zend_get_property_hook_trampoline(
17971798
func->common.arg_flags[1] = 0;
17981799
func->common.arg_flags[2] = 0;
17991800
func->common.fn_flags = ZEND_ACC_CALL_VIA_TRAMPOLINE;
1801+
func->common.fn_flags2 = 0;
18001802
func->common.function_name = zend_string_concat3(
18011803
"$", 1, ZSTR_VAL(prop_name), ZSTR_LEN(prop_name),
18021804
kind == ZEND_PROPERTY_HOOK_GET ? "::get" : "::set", 5);

Zend/zend_opcode.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ void init_op_array(zend_op_array *op_array, uint8_t type, int initial_ops_size)
8484
op_array->last_try_catch = 0;
8585

8686
op_array->fn_flags = 0;
87+
op_array->fn_flags2 = 0;
8788

8889
op_array->last_literal = 0;
8990
op_array->literals = NULL;

ext/ffi/ffi.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2190,6 +2190,7 @@ static zend_result zend_ffi_cdata_get_closure(zend_object *obj, zend_class_entry
21902190
func->common.arg_flags[1] = 0;
21912191
func->common.arg_flags[2] = 0;
21922192
func->common.fn_flags = ZEND_ACC_CALL_VIA_TRAMPOLINE;
2193+
func->common.fn_flags2 = 0;
21932194
func->common.function_name = ZSTR_KNOWN(ZEND_STR_MAGIC_INVOKE);
21942195
/* set to 0 to avoid arg_info[] allocation, because all values are passed by value anyway */
21952196
func->common.num_args = 0;
@@ -2969,6 +2970,7 @@ static zend_function *zend_ffi_get_func(zend_object **obj, zend_string *name, co
29692970
func->common.arg_flags[1] = 0;
29702971
func->common.arg_flags[2] = 0;
29712972
func->common.fn_flags = ZEND_ACC_CALL_VIA_TRAMPOLINE;
2973+
func->common.fn_flags2 = 0;
29722974
func->common.function_name = zend_string_copy(name);
29732975
/* set to 0 to avoid arg_info[] allocation, because all values are passed by value anyway */
29742976
func->common.num_args = 0;

ext/opcache/ZendAccelerator.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4360,12 +4360,14 @@ static void preload_fix_trait_op_array(zend_op_array *op_array)
43604360
zend_string *function_name = op_array->function_name;
43614361
zend_class_entry *scope = op_array->scope;
43624362
uint32_t fn_flags = op_array->fn_flags;
4363+
uint32_t fn_flags2 = op_array->fn_flags2;
43634364
zend_function *prototype = op_array->prototype;
43644365
HashTable *ht = op_array->static_variables;
43654366
*op_array = *orig_op_array;
43664367
op_array->function_name = function_name;
43674368
op_array->scope = scope;
43684369
op_array->fn_flags = fn_flags;
4370+
op_array->fn_flags2 = fn_flags2;
43694371
op_array->prototype = prototype;
43704372
op_array->static_variables = ht;
43714373
}

ext/zend_test/test.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,7 @@ static zend_function *zend_test_class_method_get(zend_object **object, zend_stri
10531053
fptr->num_args = 0;
10541054
fptr->scope = (*object)->ce;
10551055
fptr->fn_flags = ZEND_ACC_CALL_VIA_HANDLER;
1056+
fptr->fn_flags2 = 0;
10561057
fptr->function_name = zend_string_copy(name);
10571058
fptr->handler = ZEND_FN(zend_test_func);
10581059
fptr->doc_comment = NULL;
@@ -1077,6 +1078,7 @@ static zend_function *zend_test_class_static_method_get(zend_class_entry *ce, ze
10771078
fptr->num_args = 0;
10781079
fptr->scope = ce;
10791080
fptr->fn_flags = ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_STATIC;
1081+
fptr->fn_flags2 = 0;
10801082
fptr->function_name = zend_string_copy(name);
10811083
fptr->handler = ZEND_FN(zend_test_func);
10821084
fptr->doc_comment = NULL;

0 commit comments

Comments
 (0)