From edc5f7f3136c97174bb80bf720c9eac3c092bf22 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 25 Oct 2026 16:51:28 +0000 Subject: [PATCH 1/2] Zend: add empty cases for other op types --- Zend/zend_compile.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 0758ed6a5cf8..648c34f8fee5 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -6403,6 +6403,10 @@ static void zend_compile_void_cast(znode *result, const zend_ast *ast) case IS_CONST: zend_do_free(&expr_node); break; + case IS_UNUSED: + case IS_CV: + /* Nothing to free */ + break; } } From 1b26907c1892bf55dff989e92ea012bbe17c9993 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 25 Oct 2026 16:50:10 +0000 Subject: [PATCH 2/2] Zend: convert op_type IS_* to an enum And use the new type to improve clarity rather than just a uint8_t --- Zend/Optimizer/block_pass.c | 4 +-- Zend/Optimizer/dce.c | 2 +- Zend/Optimizer/ssa_integrity.c | 2 +- Zend/Optimizer/zend_dump.c | 4 +-- Zend/Optimizer/zend_dump.h | 4 +-- Zend/Optimizer/zend_inference.c | 6 ++-- Zend/Optimizer/zend_inference.h | 2 +- Zend/Optimizer/zend_optimizer.c | 2 +- Zend/Optimizer/zend_optimizer_internal.h | 2 +- Zend/zend_compile.c | 2 +- Zend/zend_compile.h | 31 +++++++++--------- Zend/zend_execute.c | 40 +++++++++++++----------- Zend/zend_execute.h | 16 +++++----- Zend/zend_vm_def.h | 4 +-- Zend/zend_vm_execute.h | 24 +++++++------- ext/opcache/jit/zend_jit.c | 2 +- ext/opcache/jit/zend_jit_helpers.c | 4 +-- ext/opcache/jit/zend_jit_ir.c | 30 +++++++++--------- 18 files changed, 94 insertions(+), 87 deletions(-) diff --git a/Zend/Optimizer/block_pass.c b/Zend/Optimizer/block_pass.c index 0601994479e6..de61390de3cc 100644 --- a/Zend/Optimizer/block_pass.c +++ b/Zend/Optimizer/block_pass.c @@ -575,7 +575,7 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array break; case ZEND_IS_SMALLER: if (opline->opcode == ZEND_BOOL_NOT) { - uint8_t tmp_type; + zend_operand_type tmp_type; uint32_t tmp; src->opcode = ZEND_IS_SMALLER_OR_EQUAL; @@ -593,7 +593,7 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array break; case ZEND_IS_SMALLER_OR_EQUAL: if (opline->opcode == ZEND_BOOL_NOT) { - uint8_t tmp_type; + zend_operand_type tmp_type; uint32_t tmp; src->opcode = ZEND_IS_SMALLER; diff --git a/Zend/Optimizer/dce.c b/Zend/Optimizer/dce.c index 0780ac190cdd..1508786d6ae1 100644 --- a/Zend/Optimizer/dce.c +++ b/Zend/Optimizer/dce.c @@ -419,7 +419,7 @@ static inline bool is_free_of_live_var(const context *ctx, const zend_op *opline static bool dce_instr(const context *ctx, zend_op *opline, zend_ssa_op *ssa_op) { const zend_ssa *ssa = ctx->ssa; int free_var = -1; - uint8_t free_var_type; + zend_operand_type free_var_type; if (opline->opcode == ZEND_NOP) { return false; diff --git a/Zend/Optimizer/ssa_integrity.c b/Zend/Optimizer/ssa_integrity.c index 34a2b3a9ef64..4b81ea03c971 100644 --- a/Zend/Optimizer/ssa_integrity.c +++ b/Zend/Optimizer/ssa_integrity.c @@ -82,7 +82,7 @@ static inline bool is_in_successors(zend_basic_block *block, int check) { return false; } -static inline bool is_var_type(uint8_t type) { +static inline bool is_var_type(zend_operand_type type) { return (type & (IS_CV|IS_VAR|IS_TMP_VAR)) != 0; } diff --git a/Zend/Optimizer/zend_dump.c b/Zend/Optimizer/zend_dump.c index 83dc8c8bab77..19b5fb9ced34 100644 --- a/Zend/Optimizer/zend_dump.c +++ b/Zend/Optimizer/zend_dump.c @@ -153,7 +153,7 @@ static void zend_dump_unused_op(const zend_op *opline, znode_op op, uint32_t fla } } -ZEND_API void zend_dump_var(const zend_op_array *op_array, uint8_t var_type, uint32_t var_num) +ZEND_API void zend_dump_var(const zend_op_array *op_array, zend_operand_type var_type, uint32_t var_num) { if (var_type == IS_CV && var_num < op_array->last_var) { fprintf(stderr, "CV%d($%s)", var_num, ZSTR_VAL(op_array->vars[var_num])); @@ -382,7 +382,7 @@ static void zend_dump_ssa_var_info(const zend_ssa *ssa, int ssa_var_num, uint32_ dump_flags); } -ZEND_API void zend_dump_ssa_var(const zend_op_array *op_array, const zend_ssa *ssa, int ssa_var_num, uint8_t var_type, uint32_t var_num, uint32_t dump_flags) +ZEND_API void zend_dump_ssa_var(const zend_op_array *op_array, const zend_ssa *ssa, int ssa_var_num, zend_operand_type var_type, uint32_t var_num, uint32_t dump_flags) { if (ssa_var_num >= 0) { fprintf(stderr, "#%d.", ssa_var_num); diff --git a/Zend/Optimizer/zend_dump.h b/Zend/Optimizer/zend_dump.h index 45740d9609cb..de4c2001679e 100644 --- a/Zend/Optimizer/zend_dump.h +++ b/Zend/Optimizer/zend_dump.h @@ -38,8 +38,8 @@ void zend_dump_dominators(const zend_op_array *op_array, const zend_cfg *cfg); void zend_dump_dfg(const zend_op_array *op_array, const zend_cfg *cfg, const zend_dfg *dfg); void zend_dump_phi_placement(const zend_op_array *op_array, const zend_ssa *ssa); void zend_dump_ssa_variables(const zend_op_array *op_array, const zend_ssa *ssa, uint32_t dump_flags); -ZEND_API void zend_dump_ssa_var(const zend_op_array *op_array, const zend_ssa *ssa, int ssa_var_num, uint8_t var_type, uint32_t var_num, uint32_t dump_flags); -ZEND_API void zend_dump_var(const zend_op_array *op_array, uint8_t var_type, uint32_t var_num); +ZEND_API void zend_dump_ssa_var(const zend_op_array *op_array, const zend_ssa *ssa, int ssa_var_num, zend_operand_type var_type, uint32_t var_num, uint32_t dump_flags); +ZEND_API void zend_dump_var(const zend_op_array *op_array, zend_operand_type var_type, uint32_t var_num); void zend_dump_op_array_name(const zend_op_array *op_array); void zend_dump_const(const zval *zv); void zend_dump_ht(const HashTable *ht); diff --git a/Zend/Optimizer/zend_inference.c b/Zend/Optimizer/zend_inference.c index 37bdaf383e8b..5964cf359f83 100644 --- a/Zend/Optimizer/zend_inference.c +++ b/Zend/Optimizer/zend_inference.c @@ -2134,7 +2134,7 @@ ZEND_API uint32_t ZEND_FASTCALL zend_array_type_info(const zval *zv) } -ZEND_API uint32_t zend_array_element_type(uint32_t t1, uint8_t op_type, bool write, bool insert) +ZEND_API uint32_t zend_array_element_type(uint32_t t1, zend_operand_type op_type, bool write, bool insert) { uint32_t tmp = 0; @@ -2196,7 +2196,7 @@ ZEND_API uint32_t zend_array_element_type(uint32_t t1, uint8_t op_type, bool wri } static uint32_t assign_dim_array_result_type( - uint32_t arr_type, uint32_t dim_type, uint32_t value_type, uint8_t dim_op_type) { + uint32_t arr_type, uint32_t dim_type, uint32_t value_type, zend_operand_type dim_op_type) { uint32_t tmp = 0; /* Only add key type if we have a value type. We want to maintain the invariant that a * key type exists iff a value type exists even in dead code that may use empty types. */ @@ -2244,7 +2244,7 @@ static uint32_t assign_dim_array_result_type( } static uint32_t assign_dim_result_type( - uint32_t arr_type, uint32_t dim_type, uint32_t value_type, uint8_t dim_op_type) { + uint32_t arr_type, uint32_t dim_type, uint32_t value_type, zend_operand_type dim_op_type) { uint32_t tmp = arr_type & ~(MAY_BE_RC1|MAY_BE_RCN); if (arr_type & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE)) { diff --git a/Zend/Optimizer/zend_inference.h b/Zend/Optimizer/zend_inference.h index e6b4207c7494..9bd250af1a3e 100644 --- a/Zend/Optimizer/zend_inference.h +++ b/Zend/Optimizer/zend_inference.h @@ -219,7 +219,7 @@ ZEND_API void zend_ssa_find_false_dependencies(const zend_op_array *op_array, co ZEND_API void zend_ssa_find_sccs(const zend_op_array *op_array, zend_ssa *ssa); ZEND_API zend_result zend_ssa_inference(zend_arena **raena, const zend_op_array *op_array, const zend_script *script, zend_ssa *ssa, zend_long optimization_level); -ZEND_API uint32_t zend_array_element_type(uint32_t t1, uint8_t op_type, bool write, bool insert); +ZEND_API uint32_t zend_array_element_type(uint32_t t1, zend_operand_type op_type, bool write, bool insert); ZEND_API bool zend_inference_propagate_range(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op* ssa_op, int var, zend_ssa_range *tmp); diff --git a/Zend/Optimizer/zend_optimizer.c b/Zend/Optimizer/zend_optimizer.c index a0ff18300591..bcb95d9f3d77 100644 --- a/Zend/Optimizer/zend_optimizer.c +++ b/Zend/Optimizer/zend_optimizer.c @@ -602,7 +602,7 @@ bool zend_optimizer_update_op2_const(zend_op_array *op_array, bool zend_optimizer_replace_by_const(zend_op_array *op_array, zend_op *opline, - uint8_t type, + zend_operand_type type, uint32_t var, zval *val) { diff --git a/Zend/Optimizer/zend_optimizer_internal.h b/Zend/Optimizer/zend_optimizer_internal.h index 6add0f76bc02..e0cfc22733e6 100644 --- a/Zend/Optimizer/zend_optimizer_internal.h +++ b/Zend/Optimizer/zend_optimizer_internal.h @@ -95,7 +95,7 @@ bool zend_optimizer_update_op2_const(zend_op_array *op_array, zval *val); bool zend_optimizer_replace_by_const(zend_op_array *op_array, zend_op *opline, - uint8_t type, + zend_operand_type type, uint32_t var, zval *val); zend_op *zend_optimizer_get_loop_var_def(const zend_op_array *op_array, zend_op *free_opline); diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 648c34f8fee5..5b05d5a79068 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -64,7 +64,7 @@ typedef struct _zend_loop_var { uint8_t opcode; - uint8_t var_type; + zend_operand_type var_type; uint32_t var_num; uint32_t try_catch_offset; } zend_loop_var; diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index a5407422b0bf..b3453c1b139d 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -32,6 +32,19 @@ #include "zend_frameless_function.h" #include "zend_property_hooks.h" +/* Assign as specific bits so that one can quickly check types via a bit operation */ +C23_ENUM(zend_operand_type, uint8_t) { + IS_UNUSED = 0, /* Unused operand */ + IS_CONST = (1<<0), + IS_TMP_VAR = (1<<1), + IS_VAR = (1<<2), + IS_CV = (1<<3), /* Compiled variable */ +}; + +/* Used in zend_op.result_type for smart branch instructions */ +#define IS_SMART_BRANCH_JMPZ (1<<4) +#define IS_SMART_BRANCH_JMPNZ (1<<5) + #define SET_UNUSED(op) do { \ op ## _type = IS_UNUSED; \ op.num = (uint32_t) -1; \ @@ -81,7 +94,7 @@ typedef union _znode_op { } znode_op; typedef struct _znode { /* used only during compilation */ - uint8_t op_type; + zend_operand_type op_type; uint8_t flag; union { znode_op op; @@ -142,9 +155,9 @@ struct _zend_op { uint32_t extended_value; uint32_t lineno; uint8_t opcode; /* Opcodes defined in Zend/zend_vm_opcodes.h */ - uint8_t op1_type; /* IS_UNUSED, IS_CONST, IS_TMP_VAR, IS_VAR, IS_CV */ - uint8_t op2_type; /* IS_UNUSED, IS_CONST, IS_TMP_VAR, IS_VAR, IS_CV */ - uint8_t result_type; /* IS_UNUSED, IS_CONST, IS_TMP_VAR, IS_VAR, IS_CV */ + zend_operand_type op1_type; + zend_operand_type op2_type; + uint8_t result_type; /* zend_operand_type value with possible IS_SMART_BRANCH_JMPZ or IS_SMART_BRANCH_JMPNZ flag added */ #ifdef ZEND_VERIFY_TYPE_INFERENCE uint32_t op1_use_type; uint32_t op2_use_type; @@ -852,16 +865,6 @@ static_assert(ZEND_MM_ALIGNED_SIZE(sizeof(zval)) == sizeof(zval), #define ZEND_OP_ARRAY_EXTENSION(op_array, handle) \ ((void**)RUN_TIME_CACHE(op_array))[handle] -#define IS_UNUSED 0 /* Unused operand */ -#define IS_CONST (1<<0) -#define IS_TMP_VAR (1<<1) -#define IS_VAR (1<<2) -#define IS_CV (1<<3) /* Compiled variable */ - -/* Used for result.type of smart branch instructions */ -#define IS_SMART_BRANCH_JMPZ (1<<4) -#define IS_SMART_BRANCH_JMPNZ (1<<5) - #define ZEND_EXTRA_VALUE 1 #include "zend_globals.h" diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 7d270c3e249d..873a379b4776 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -414,7 +414,7 @@ static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_W(uint32_t var EXECUTE_D return ret; } -static zend_always_inline zval *_get_zval_ptr_tmpvarcv(int op_type, znode_op node, int type EXECUTE_DATA_DC) +static zend_always_inline zval *_get_zval_ptr_tmpvarcv(zend_operand_type op_type, znode_op node, int type EXECUTE_DATA_DC) { if (op_type & (IS_TMP_VAR|IS_VAR)) { if (op_type == IS_TMP_VAR) { @@ -429,7 +429,7 @@ static zend_always_inline zval *_get_zval_ptr_tmpvarcv(int op_type, znode_op nod } } -static zend_always_inline zval *_get_zval_ptr(int op_type, znode_op node, int type EXECUTE_DATA_DC OPLINE_DC) +static zend_always_inline zval *_get_zval_ptr(zend_operand_type op_type, znode_op node, int type EXECUTE_DATA_DC OPLINE_DC) { if (op_type & (IS_TMP_VAR|IS_VAR)) { if (!ZEND_DEBUG || op_type == IS_VAR) { @@ -449,7 +449,7 @@ static zend_always_inline zval *_get_zval_ptr(int op_type, znode_op node, int ty } } -static zend_always_inline zval *_get_op_data_zval_ptr_r(int op_type, znode_op node EXECUTE_DATA_DC OPLINE_DC) +static zend_always_inline zval *_get_op_data_zval_ptr_r(zend_operand_type op_type, znode_op node EXECUTE_DATA_DC OPLINE_DC) { if (op_type & (IS_TMP_VAR|IS_VAR)) { if (!ZEND_DEBUG || op_type == IS_VAR) { @@ -469,7 +469,7 @@ static zend_always_inline zval *_get_op_data_zval_ptr_r(int op_type, znode_op no } } -static zend_always_inline ZEND_ATTRIBUTE_UNUSED zval *_get_zval_ptr_deref(int op_type, znode_op node, int type EXECUTE_DATA_DC OPLINE_DC) +static zend_always_inline ZEND_ATTRIBUTE_UNUSED zval *_get_zval_ptr_deref(zend_operand_type op_type, znode_op node, int type EXECUTE_DATA_DC OPLINE_DC) { if (op_type & (IS_TMP_VAR|IS_VAR)) { if (op_type == IS_TMP_VAR) { @@ -489,7 +489,7 @@ static zend_always_inline ZEND_ATTRIBUTE_UNUSED zval *_get_zval_ptr_deref(int op } } -static zend_always_inline ZEND_ATTRIBUTE_UNUSED zval *_get_op_data_zval_ptr_deref_r(int op_type, znode_op node EXECUTE_DATA_DC OPLINE_DC) +static zend_always_inline ZEND_ATTRIBUTE_UNUSED zval *_get_op_data_zval_ptr_deref_r(zend_operand_type op_type, znode_op node EXECUTE_DATA_DC OPLINE_DC) { if (op_type & (IS_TMP_VAR|IS_VAR)) { if (op_type == IS_TMP_VAR) { @@ -509,7 +509,7 @@ static zend_always_inline ZEND_ATTRIBUTE_UNUSED zval *_get_op_data_zval_ptr_dere } } -static zend_always_inline zval *_get_zval_ptr_undef(int op_type, znode_op node, int type EXECUTE_DATA_DC OPLINE_DC) +static zend_always_inline zval *_get_zval_ptr_undef(zend_operand_type op_type, znode_op node, int type EXECUTE_DATA_DC OPLINE_DC) { if (op_type & (IS_TMP_VAR|IS_VAR)) { if (!ZEND_DEBUG || op_type == IS_VAR) { @@ -539,7 +539,7 @@ static zend_always_inline zval *_get_zval_ptr_ptr_var(uint32_t var EXECUTE_DATA_ return ret; } -static inline zval *_get_zval_ptr_ptr(int op_type, znode_op node, int type EXECUTE_DATA_DC) +static inline zval *_get_zval_ptr_ptr(zend_operand_type op_type, znode_op node, int type EXECUTE_DATA_DC) { if (op_type == IS_CV) { return _get_zval_ptr_cv(node.var, type EXECUTE_DATA_CC); @@ -549,7 +549,7 @@ static inline zval *_get_zval_ptr_ptr(int op_type, znode_op node, int type EXECU } } -static inline ZEND_ATTRIBUTE_UNUSED zval *_get_obj_zval_ptr(int op_type, znode_op op, int type EXECUTE_DATA_DC OPLINE_DC) +static inline ZEND_ATTRIBUTE_UNUSED zval *_get_obj_zval_ptr(zend_operand_type op_type, znode_op op, int type EXECUTE_DATA_DC OPLINE_DC) { if (op_type == IS_UNUSED) { return &EX(This); @@ -557,7 +557,7 @@ static inline ZEND_ATTRIBUTE_UNUSED zval *_get_obj_zval_ptr(int op_type, znode_o return get_zval_ptr(op_type, op, type); } -static inline ZEND_ATTRIBUTE_UNUSED zval *_get_obj_zval_ptr_deref(int op_type, znode_op op, int type EXECUTE_DATA_DC OPLINE_DC) +static inline ZEND_ATTRIBUTE_UNUSED zval *_get_obj_zval_ptr_deref(zend_operand_type op_type, znode_op op, int type EXECUTE_DATA_DC OPLINE_DC) { if (op_type == IS_UNUSED) { return &EX(This); @@ -565,7 +565,7 @@ static inline ZEND_ATTRIBUTE_UNUSED zval *_get_obj_zval_ptr_deref(int op_type, z return get_zval_ptr_deref(op_type, op, type); } -static inline ZEND_ATTRIBUTE_UNUSED zval *_get_obj_zval_ptr_undef(int op_type, znode_op op, int type EXECUTE_DATA_DC OPLINE_DC) +static inline ZEND_ATTRIBUTE_UNUSED zval *_get_obj_zval_ptr_undef(zend_operand_type op_type, znode_op op, int type EXECUTE_DATA_DC OPLINE_DC) { if (op_type == IS_UNUSED) { return &EX(This); @@ -573,7 +573,7 @@ static inline ZEND_ATTRIBUTE_UNUSED zval *_get_obj_zval_ptr_undef(int op_type, z return get_zval_ptr_undef(op_type, op, type); } -static inline ZEND_ATTRIBUTE_UNUSED zval *_get_obj_zval_ptr_ptr(int op_type, znode_op node, int type EXECUTE_DATA_DC) +static inline ZEND_ATTRIBUTE_UNUSED zval *_get_obj_zval_ptr_ptr(zend_operand_type op_type, znode_op node, int type EXECUTE_DATA_DC) { if (op_type == IS_UNUSED) { return &EX(This); @@ -3530,9 +3530,9 @@ static zend_never_inline bool zend_handle_fetch_obj_flags( static zend_always_inline void zend_fetch_property_address( zval *result, const zval *container, - uint32_t container_op_type, + zend_operand_type container_op_type, const zval *prop_ptr, - uint32_t prop_op_type, + zend_operand_type prop_op_type, void **cache_slot, int type, uint32_t flags, @@ -3685,9 +3685,9 @@ static zend_always_inline void zend_fetch_property_address( static zend_always_inline void zend_assign_to_property_reference( const zval *container, - uint32_t container_op_type, + zend_operand_type container_op_type, const zval *prop_ptr, - uint32_t prop_op_type, + zend_operand_type prop_op_type, zval *value_ptr OPLINE_DC EXECUTE_DATA_DC ) { @@ -4077,7 +4077,7 @@ static zend_always_inline void i_zval_ptr_dtor_noref(zval *zval_ptr) { } } -ZEND_API zval* zend_assign_to_typed_ref_ex(zval *variable_ptr, zval *orig_value, uint8_t value_type, bool strict, zend_refcounted **garbage_ptr) +ZEND_API zval* zend_assign_to_typed_ref_ex(zval *variable_ptr, zval *orig_value, zend_operand_type value_type, bool strict, zend_refcounted **garbage_ptr) { bool ret; zval value; @@ -4112,7 +4112,7 @@ ZEND_API zval* zend_assign_to_typed_ref_ex(zval *variable_ptr, zval *orig_value, return variable_ptr; } -ZEND_API zval* zend_assign_to_typed_ref(zval *variable_ptr, zval *orig_value, uint8_t value_type, bool strict) +ZEND_API zval* zend_assign_to_typed_ref(zval *variable_ptr, zval *orig_value, zend_operand_type value_type, bool strict) { zend_refcounted *garbage = NULL; zval *result = zend_assign_to_typed_ref_ex(variable_ptr, orig_value, value_type, strict, &garbage); @@ -5947,7 +5947,11 @@ static zend_always_inline zend_execute_data *_zend_vm_stack_push_call_frame(uint /* This callback disables optimization of "vm_stack_data" variable in VM */ ZEND_API void (ZEND_FASTCALL *zend_touch_vm_stack_data)(void *vm_stack_data) = NULL; +/* We ignore tautological compares for the zend_operand_type cases as the VM will generate many IS_* == IS_* + * that will be optimized out by the compiled */ +ZEND_DIAGNOSTIC_IGNORED_START("-Wtautological-compare") #include "zend_vm_execute.h" +ZEND_DIAGNOSTIC_IGNORED_END ZEND_API zend_result zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler_t handler) { @@ -5969,7 +5973,7 @@ ZEND_API user_opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode) return zend_user_opcode_handlers[opcode]; } -ZEND_API zval *zend_get_zval_ptr(const zend_op *opline, int op_type, const znode_op *node, const zend_execute_data *execute_data) +ZEND_API zval *zend_get_zval_ptr(const zend_op *opline, zend_operand_type op_type, const znode_op *node, const zend_execute_data *execute_data) { zval *ret; diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index 82d4af25d914..d889eafa82fc 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -133,10 +133,10 @@ ZEND_API bool zend_verify_internal_return_type(const zend_function *zf, zval *re ZEND_API void ZEND_FASTCALL zend_ref_add_type_source(zend_property_info_source_list *source_list, zend_property_info *prop); ZEND_API void ZEND_FASTCALL zend_ref_del_type_source(zend_property_info_source_list *source_list, const zend_property_info *prop); -ZEND_API zval* zend_assign_to_typed_ref(zval *variable_ptr, zval *value, uint8_t value_type, bool strict); -ZEND_API zval* zend_assign_to_typed_ref_ex(zval *variable_ptr, zval *value, uint8_t value_type, bool strict, zend_refcounted **garbage_ptr); +ZEND_API zval* zend_assign_to_typed_ref(zval *variable_ptr, zval *value, zend_operand_type value_type, bool strict); +ZEND_API zval* zend_assign_to_typed_ref_ex(zval *variable_ptr, zval *value, zend_operand_type value_type, bool strict, zend_refcounted **garbage_ptr); -static zend_always_inline void zend_copy_to_variable(zval *variable_ptr, const zval *value, uint8_t value_type) +static zend_always_inline void zend_copy_to_variable(zval *variable_ptr, const zval *value, zend_operand_type value_type) { zend_refcounted *ref = NULL; @@ -163,7 +163,7 @@ static zend_always_inline void zend_copy_to_variable(zval *variable_ptr, const z } } -static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval *value, uint8_t value_type, bool strict) +static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval *value, zend_operand_type value_type, bool strict) { do { if (UNEXPECTED(Z_REFCOUNTED_P(variable_ptr))) { @@ -190,7 +190,7 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval return variable_ptr; } -static zend_always_inline zval* zend_assign_to_variable_ex(zval *variable_ptr, zval *value, zend_uchar value_type, bool strict, zend_refcounted **garbage_ptr) +static zend_always_inline zval* zend_assign_to_variable_ex(zval *variable_ptr, zval *value, zend_operand_type value_type, bool strict, zend_refcounted **garbage_ptr) { do { if (UNEXPECTED(Z_REFCOUNTED_P(variable_ptr))) { @@ -223,7 +223,7 @@ static zend_always_inline void zend_safe_assign_to_variable_noref(zval *variable } } -static zend_always_inline void zend_cast_zval_to_object(zval *result, zval *expr, uint8_t op1_type) { +static zend_always_inline void zend_cast_zval_to_object(zval *result, zval *expr, zend_operand_type op1_type) { HashTable *ht; ZVAL_OBJ(result, zend_objects_new(zend_standard_class_def)); @@ -248,7 +248,7 @@ static zend_always_inline void zend_cast_zval_to_object(zval *result, zval *expr } } -static zend_always_inline void zend_cast_zval_to_array(zval *result, zval *expr, uint8_t op1_type) { +static zend_always_inline void zend_cast_zval_to_array(zval *result, zval *expr, zend_operand_type op1_type) { extern ZEND_API zend_class_entry *zend_ce_closure; if (op1_type == IS_CONST || Z_TYPE_P(expr) != IS_OBJECT || Z_OBJCE_P(expr) == zend_ce_closure) { if (Z_TYPE_P(expr) != IS_NULL) { @@ -550,7 +550,7 @@ ZEND_API bool zend_gcc_global_regs(void); ZEND_API zend_result zend_set_user_opcode_handler(uint8_t opcode, user_opcode_handler_t handler); ZEND_API user_opcode_handler_t zend_get_user_opcode_handler(uint8_t opcode); -ZEND_API zval *zend_get_zval_ptr(const zend_op *opline, int op_type, const znode_op *node, const zend_execute_data *execute_data); +ZEND_API zval *zend_get_zval_ptr(const zend_op *opline, zend_operand_type op_type, const znode_op *node, const zend_execute_data *execute_data); ZEND_API void zend_clean_and_cache_symbol_table(zend_array *symbol_table); ZEND_API void ZEND_FASTCALL zend_free_compiled_variables(zend_execute_data *execute_data); diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index fedf3c06b4af..43b2618df7b9 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -3138,7 +3138,7 @@ ZEND_VM_HOT_NOCONST_HANDLER(43, ZEND_JMPZ, CONST|TMP|CV, JMP_ADDR) { USE_OPLINE zval *val; - uint8_t op1_type; + zend_operand_type op1_type; val = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); @@ -3172,7 +3172,7 @@ ZEND_VM_HOT_NOCONST_HANDLER(44, ZEND_JMPNZ, CONST|TMP|CV, JMP_ADDR) { USE_OPLINE zval *val; - uint8_t op1_type; + zend_operand_type op1_type; val = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 5a51f057f3d8..8210a29f138d 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -4626,7 +4626,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_ { USE_OPLINE zval *val; - uint8_t op1_type; + zend_operand_type op1_type; val = RT_CONSTANT(opline, opline->op1); @@ -4660,7 +4660,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_ { USE_OPLINE zval *val; - uint8_t op1_type; + zend_operand_type op1_type; val = RT_CONSTANT(opline, opline->op1); @@ -17070,7 +17070,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_J { USE_OPLINE zval *val; - uint8_t op1_type; + zend_operand_type op1_type; val = _get_zval_ptr_tmp(opline->op1.var EXECUTE_DATA_CC); @@ -17104,7 +17104,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_J { USE_OPLINE zval *val; - uint8_t op1_type; + zend_operand_type op1_type; val = _get_zval_ptr_tmp(opline->op1.var EXECUTE_DATA_CC); @@ -39835,7 +39835,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_J { USE_OPLINE zval *val; - uint8_t op1_type; + zend_operand_type op1_type; val = EX_VAR(opline->op1.var); @@ -39869,7 +39869,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_J { USE_OPLINE zval *val; - uint8_t op1_type; + zend_operand_type op1_type; val = EX_VAR(opline->op1.var); @@ -57504,7 +57504,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_JMPZ_ { USE_OPLINE zval *val; - uint8_t op1_type; + zend_operand_type op1_type; val = RT_CONSTANT(opline, opline->op1); @@ -57538,7 +57538,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_JMPNZ { USE_OPLINE zval *val; - uint8_t op1_type; + zend_operand_type op1_type; val = RT_CONSTANT(opline, opline->op1); @@ -69846,7 +69846,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_JMPZ_S { USE_OPLINE zval *val; - uint8_t op1_type; + zend_operand_type op1_type; val = _get_zval_ptr_tmp(opline->op1.var EXECUTE_DATA_CC); @@ -69880,7 +69880,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_JMPNZ_ { USE_OPLINE zval *val; - uint8_t op1_type; + zend_operand_type op1_type; val = _get_zval_ptr_tmp(opline->op1.var EXECUTE_DATA_CC); @@ -92511,7 +92511,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_JMPZ_S { USE_OPLINE zval *val; - uint8_t op1_type; + zend_operand_type op1_type; val = EX_VAR(opline->op1.var); @@ -92545,7 +92545,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_JMPNZ_ { USE_OPLINE zval *val; - uint8_t op1_type; + zend_operand_type op1_type; val = EX_VAR(opline->op1.var); diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index 885ddffd731f..56df7b06f81d 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -566,7 +566,7 @@ static bool zend_jit_is_persistent_constant(zval *key, uint32_t flags) return c && (ZEND_CONSTANT_FLAGS(c) & CONST_PERSISTENT); } -static zend_class_entry* zend_get_known_class(const zend_op_array *op_array, const zend_op *opline, uint8_t op_type, znode_op op) +static zend_class_entry* zend_get_known_class(const zend_op_array *op_array, const zend_op *opline, zend_operand_type op_type, znode_op op) { zend_class_entry *ce = NULL; diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c index d9b91d299f59..7676217b5362 100644 --- a/ext/opcache/jit/zend_jit_helpers.c +++ b/ext/opcache/jit/zend_jit_helpers.c @@ -2381,7 +2381,7 @@ static void ZEND_FASTCALL zend_jit_vm_stack_free_args_helper(zend_execute_data * zend_vm_stack_free_args(call); } -static zend_always_inline zval* zend_jit_assign_to_typed_ref_helper(zend_reference *ref, zval *value, uint8_t value_type) +static zend_always_inline zval* zend_jit_assign_to_typed_ref_helper(zend_reference *ref, zval *value, zend_operand_type value_type) { zval variable; @@ -2421,7 +2421,7 @@ static zval* ZEND_FASTCALL zend_jit_assign_cv_to_typed_ref(zend_reference *ref, return zend_jit_assign_to_typed_ref_helper(ref, value, IS_CV); } -static zend_always_inline zval* zend_jit_assign_to_typed_ref2_helper(zend_reference *ref, zval *value, zval *result, uint8_t value_type) +static zend_always_inline zval* zend_jit_assign_to_typed_ref2_helper(zend_reference *ref, zval *value, zval *result, zend_operand_type value_type) { zval variable, *ret; zend_refcounted *garbage = NULL; diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c index 6ca263ac6e3b..8d6b3e8c8016 100644 --- a/ext/opcache/jit/zend_jit_ir.c +++ b/ext/opcache/jit/zend_jit_ir.c @@ -348,7 +348,7 @@ static int zend_jit_assign_to_variable(zend_jit_ctx *jit, zend_jit_addr var_addr, uint32_t var_info, uint32_t var_def_info, - uint8_t val_type, + zend_operand_type val_type, zend_jit_addr val_addr, uint32_t val_info, zend_jit_addr res_addr, @@ -1877,7 +1877,7 @@ static void jit_ZVAL_PTR_DTOR(zend_jit_ctx *jit, } static void jit_FREE_OP(zend_jit_ctx *jit, - uint8_t op_type, + zend_operand_type op_type, znode_op op, uint32_t op_info, const zend_op *opline) @@ -4585,7 +4585,7 @@ static int zend_jit_load_var(zend_jit_ctx *jit, uint32_t info, int var, int ssa_ return zend_jit_load_reg(jit, src, dst, info); } -static int zend_jit_invalidate_var_if_necessary(zend_jit_ctx *jit, uint8_t op_type, zend_jit_addr addr, znode_op op) +static int zend_jit_invalidate_var_if_necessary(zend_jit_ctx *jit, zend_operand_type op_type, zend_jit_addr addr, znode_op op) { if ((op_type & (IS_TMP_VAR|IS_VAR)) && Z_MODE(addr) == IS_REG && !Z_LOAD(addr) && !Z_STORE(addr)) { /* Invalidate operand type to prevent incorrect destruction by exception_handler_free_op1_op2() */ @@ -5354,11 +5354,11 @@ static int zend_jit_math_double_double(zend_jit_ctx *jit, static int zend_jit_math_helper(zend_jit_ctx *jit, const zend_op *opline, uint8_t opcode, - uint8_t op1_type, + zend_operand_type op1_type, znode_op op1, zend_jit_addr op1_addr, uint32_t op1_info, - uint8_t op2_type, + zend_operand_type op2_type, znode_op op2, zend_jit_addr op2_addr, uint32_t op2_info, @@ -5683,12 +5683,12 @@ static int zend_jit_add_arrays(zend_jit_ctx *jit, const zend_op *opline, uint32_ static int zend_jit_long_math_helper(zend_jit_ctx *jit, const zend_op *opline, uint8_t opcode, - uint8_t op1_type, + zend_operand_type op1_type, znode_op op1, zend_jit_addr op1_addr, uint32_t op1_info, zend_ssa_range *op1_range, - uint8_t op2_type, + zend_operand_type op2_type, znode_op op2, zend_jit_addr op2_addr, uint32_t op2_info, @@ -6059,11 +6059,11 @@ static int zend_jit_long_math(zend_jit_ctx *jit, const zend_op *opline, uint32_t static int zend_jit_concat_helper(zend_jit_ctx *jit, const zend_op *opline, - uint8_t op1_type, + zend_operand_type op1_type, znode_op op1, zend_jit_addr op1_addr, uint32_t op1_info, - uint8_t op2_type, + zend_operand_type op2_type, znode_op op2, zend_jit_addr op2_addr, uint32_t op2_info, @@ -6311,7 +6311,7 @@ static int zend_jit_simple_assign(zend_jit_ctx *jit, zend_jit_addr var_addr, uint32_t var_info, uint32_t var_def_info, - uint8_t val_type, + zend_operand_type val_type, zend_jit_addr val_addr, uint32_t val_info, zend_jit_addr res_addr, @@ -6432,7 +6432,7 @@ static int zend_jit_assign_to_variable_call(zend_jit_ctx *jit, zend_jit_addr var_addr, uint32_t __var_info, uint32_t __var_def_info, - uint8_t val_type, + zend_operand_type val_type, zend_jit_addr val_addr, uint32_t val_info, zend_jit_addr __res_addr, @@ -6512,7 +6512,7 @@ static int zend_jit_assign_to_variable(zend_jit_ctx *jit, zend_jit_addr var_addr, uint32_t var_info, uint32_t var_def_info, - uint8_t val_type, + zend_operand_type val_type, zend_jit_addr val_addr, uint32_t val_info, zend_jit_addr res_addr, @@ -13943,7 +13943,7 @@ static int zend_jit_assign_dim_op(zend_jit_ctx *jit, } if (emit_fast_path) { - uint8_t val_op_type = (opline+1)->op1_type; + zend_operand_type val_op_type = (opline+1)->op1_type; if (val_op_type & (IS_TMP_VAR|IS_VAR)) { /* prevent FREE_OP in the helpers */ @@ -15770,7 +15770,7 @@ static int zend_jit_assign_obj_op(zend_jit_ctx *jit, var_info &= ~MAY_BE_REF; } - uint8_t val_op_type = (opline+1)->op1_type; + zend_operand_type val_op_type = (opline+1)->op1_type; if (val_op_type & (IS_TMP_VAR|IS_VAR)) { /* prevent FREE_OP in the helpers */ val_op_type = IS_CV; @@ -18374,7 +18374,7 @@ static bool jit_frameless_icall3(zend_jit_ctx *jit, const zend_op *opline, uint3 } void *function = ZEND_FLF_HANDLER(opline); - uint8_t op_data_type = (opline + 1)->op1_type; + zend_operand_type op_data_type = (opline + 1)->op1_type; zend_jit_addr res_addr = RES_ADDR(); zend_jit_addr op1_addr = OP1_ADDR(); zend_jit_addr op2_addr = OP2_ADDR();