Skip to content

Commit f2b7d15

Browse files
committed
Zend: convert op_type IS_* to an enum
And use the new type to improve clarity rather than just a uint8_t
1 parent edaa439 commit f2b7d15

18 files changed

Lines changed: 89 additions & 86 deletions

‎Zend/Optimizer/block_pass.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array
563563
break;
564564
case ZEND_IS_SMALLER:
565565
if (opline->opcode == ZEND_BOOL_NOT) {
566-
uint8_t tmp_type;
566+
zend_operand_type tmp_type;
567567
uint32_t tmp;
568568

569569
src->opcode = ZEND_IS_SMALLER_OR_EQUAL;
@@ -581,7 +581,7 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array
581581
break;
582582
case ZEND_IS_SMALLER_OR_EQUAL:
583583
if (opline->opcode == ZEND_BOOL_NOT) {
584-
uint8_t tmp_type;
584+
zend_operand_type tmp_type;
585585
uint32_t tmp;
586586

587587
src->opcode = ZEND_IS_SMALLER;

‎Zend/Optimizer/dce.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ static inline bool is_free_of_live_var(const context *ctx, const zend_op *opline
419419
static bool dce_instr(const context *ctx, zend_op *opline, zend_ssa_op *ssa_op) {
420420
const zend_ssa *ssa = ctx->ssa;
421421
int free_var = -1;
422-
uint8_t free_var_type;
422+
zend_operand_type free_var_type;
423423

424424
if (opline->opcode == ZEND_NOP) {
425425
return false;

‎Zend/Optimizer/ssa_integrity.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static inline bool is_in_successors(zend_basic_block *block, int check) {
8282
return false;
8383
}
8484

85-
static inline bool is_var_type(uint8_t type) {
85+
static inline bool is_var_type(zend_operand_type type) {
8686
return (type & (IS_CV|IS_VAR|IS_TMP_VAR)) != 0;
8787
}
8888

‎Zend/Optimizer/zend_dump.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static void zend_dump_unused_op(const zend_op *opline, znode_op op, uint32_t fla
153153
}
154154
}
155155

156-
ZEND_API void zend_dump_var(const zend_op_array *op_array, uint8_t var_type, uint32_t var_num)
156+
ZEND_API void zend_dump_var(const zend_op_array *op_array, zend_operand_type var_type, uint32_t var_num)
157157
{
158158
if (var_type == IS_CV && var_num < op_array->last_var) {
159159
fprintf(stderr, "CV%d($%s)", var_num, op_array->vars[var_num]->val);
@@ -382,7 +382,7 @@ static void zend_dump_ssa_var_info(const zend_ssa *ssa, int ssa_var_num, uint32_
382382
dump_flags);
383383
}
384384

385-
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)
385+
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)
386386
{
387387
if (ssa_var_num >= 0) {
388388
fprintf(stderr, "#%d.", ssa_var_num);

‎Zend/Optimizer/zend_dump.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ void zend_dump_dominators(const zend_op_array *op_array, const zend_cfg *cfg);
3838
void zend_dump_dfg(const zend_op_array *op_array, const zend_cfg *cfg, const zend_dfg *dfg);
3939
void zend_dump_phi_placement(const zend_op_array *op_array, const zend_ssa *ssa);
4040
void zend_dump_ssa_variables(const zend_op_array *op_array, const zend_ssa *ssa, uint32_t dump_flags);
41-
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);
42-
ZEND_API void zend_dump_var(const zend_op_array *op_array, uint8_t var_type, uint32_t var_num);
41+
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);
42+
ZEND_API void zend_dump_var(const zend_op_array *op_array, zend_operand_type var_type, uint32_t var_num);
4343
void zend_dump_op_array_name(const zend_op_array *op_array);
4444
void zend_dump_const(const zval *zv);
4545
void zend_dump_ht(const HashTable *ht);

‎Zend/Optimizer/zend_inference.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,7 +2132,7 @@ ZEND_API uint32_t ZEND_FASTCALL zend_array_type_info(const zval *zv)
21322132
}
21332133

21342134

2135-
ZEND_API uint32_t zend_array_element_type(uint32_t t1, uint8_t op_type, bool write, bool insert)
2135+
ZEND_API uint32_t zend_array_element_type(uint32_t t1, zend_operand_type op_type, bool write, bool insert)
21362136
{
21372137
uint32_t tmp = 0;
21382138

@@ -2194,7 +2194,7 @@ ZEND_API uint32_t zend_array_element_type(uint32_t t1, uint8_t op_type, bool wri
21942194
}
21952195

21962196
static uint32_t assign_dim_array_result_type(
2197-
uint32_t arr_type, uint32_t dim_type, uint32_t value_type, uint8_t dim_op_type) {
2197+
uint32_t arr_type, uint32_t dim_type, uint32_t value_type, zend_operand_type dim_op_type) {
21982198
uint32_t tmp = 0;
21992199
/* Only add key type if we have a value type. We want to maintain the invariant that a
22002200
* key type exists iff a value type exists even in dead code that may use empty types. */
@@ -2239,7 +2239,7 @@ static uint32_t assign_dim_array_result_type(
22392239
}
22402240

22412241
static uint32_t assign_dim_result_type(
2242-
uint32_t arr_type, uint32_t dim_type, uint32_t value_type, uint8_t dim_op_type) {
2242+
uint32_t arr_type, uint32_t dim_type, uint32_t value_type, zend_operand_type dim_op_type) {
22432243
uint32_t tmp = arr_type & ~(MAY_BE_RC1|MAY_BE_RCN);
22442244

22452245
if (arr_type & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE)) {

‎Zend/Optimizer/zend_inference.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ ZEND_API void zend_ssa_find_false_dependencies(const zend_op_array *op_array, co
219219
ZEND_API void zend_ssa_find_sccs(const zend_op_array *op_array, zend_ssa *ssa);
220220
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);
221221

222-
ZEND_API uint32_t zend_array_element_type(uint32_t t1, uint8_t op_type, bool write, bool insert);
222+
ZEND_API uint32_t zend_array_element_type(uint32_t t1, zend_operand_type op_type, bool write, bool insert);
223223

224224
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);
225225

‎Zend/Optimizer/zend_optimizer.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ bool zend_optimizer_update_op2_const(zend_op_array *op_array,
602602

603603
bool zend_optimizer_replace_by_const(zend_op_array *op_array,
604604
zend_op *opline,
605-
uint8_t type,
605+
zend_operand_type type,
606606
uint32_t var,
607607
zval *val)
608608
{

‎Zend/Optimizer/zend_optimizer_internal.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ bool zend_optimizer_update_op2_const(zend_op_array *op_array,
9595
zval *val);
9696
bool zend_optimizer_replace_by_const(zend_op_array *op_array,
9797
zend_op *opline,
98-
uint8_t type,
98+
zend_operand_type type,
9999
uint32_t var,
100100
zval *val);
101101
zend_op *zend_optimizer_get_loop_var_def(const zend_op_array *op_array, zend_op *free_opline);

‎Zend/zend_compile.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464

6565
typedef struct _zend_loop_var {
6666
uint8_t opcode;
67-
uint8_t var_type;
67+
zend_operand_type var_type;
6868
uint32_t var_num;
6969
uint32_t try_catch_offset;
7070
} zend_loop_var;

0 commit comments

Comments
 (0)