Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1ce0baa

Browse files
zend_compiler, ...: use uint8_t instead of zend_uchar (php#10621)
`zend_uchar` suggests that the value is an ASCII character, but here, it's about very small integers. This is misleading, so let's use a C99 integer instead. On all architectures currently supported by PHP, `zend_uchar` and `uint8_t` are identical. This change is only about code readability.
1 parent 91d31ba commit 1ce0baa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+356
-335
lines changed

‎Zend/Optimizer/block_pass.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array
519519
break;
520520
case ZEND_IS_SMALLER:
521521
if (opline->opcode == ZEND_BOOL_NOT) {
522-
zend_uchar tmp_type;
522+
uint8_t tmp_type;
523523
uint32_t tmp;
524524

525525
src->opcode = ZEND_IS_SMALLER_OR_EQUAL;
@@ -537,7 +537,7 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array
537537
break;
538538
case ZEND_IS_SMALLER_OR_EQUAL:
539539
if (opline->opcode == ZEND_BOOL_NOT) {
540-
zend_uchar tmp_type;
540+
uint8_t tmp_type;
541541
uint32_t tmp;
542542

543543
src->opcode = ZEND_IS_SMALLER;

‎Zend/Optimizer/dce.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ static inline bool is_free_of_live_var(context *ctx, zend_op *opline, zend_ssa_o
413413
static bool dce_instr(context *ctx, zend_op *opline, zend_ssa_op *ssa_op) {
414414
zend_ssa *ssa = ctx->ssa;
415415
int free_var = -1;
416-
zend_uchar free_var_type;
416+
uint8_t free_var_type;
417417

418418
if (opline->opcode == ZEND_NOP) {
419419
return 0;

‎Zend/Optimizer/dfa_pass.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ static int zend_dfa_optimize_jmps(zend_op_array *op_array, zend_ssa *ssa)
932932
case ZEND_MATCH:
933933
if (opline->op1_type == IS_CONST) {
934934
zval *zv = CT_CONSTANT_EX(op_array, opline->op1.constant);
935-
zend_uchar type = Z_TYPE_P(zv);
935+
uint8_t type = Z_TYPE_P(zv);
936936
bool correct_type =
937937
(opline->opcode == ZEND_SWITCH_LONG && type == IS_LONG)
938938
|| (opline->opcode == ZEND_SWITCH_STRING && type == IS_STRING)

‎Zend/Optimizer/sccp.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ typedef struct _sccp_ctx {
8383
zval bot;
8484
} sccp_ctx;
8585

86-
#define TOP ((zend_uchar)-1)
87-
#define BOT ((zend_uchar)-2)
88-
#define PARTIAL_ARRAY ((zend_uchar)-3)
89-
#define PARTIAL_OBJECT ((zend_uchar)-4)
86+
#define TOP ((uint8_t)-1)
87+
#define BOT ((uint8_t)-2)
88+
#define PARTIAL_ARRAY ((uint8_t)-3)
89+
#define PARTIAL_OBJECT ((uint8_t)-4)
9090
#define IS_TOP(zv) (Z_TYPE_P(zv) == TOP)
9191
#define IS_BOT(zv) (Z_TYPE_P(zv) == BOT)
9292
#define IS_PARTIAL_ARRAY(zv) (Z_TYPE_P(zv) == PARTIAL_ARRAY)
@@ -314,7 +314,7 @@ static bool try_replace_op2(
314314
return 0;
315315
}
316316

317-
static inline zend_result ct_eval_binary_op(zval *result, zend_uchar binop, zval *op1, zval *op2) {
317+
static inline zend_result ct_eval_binary_op(zval *result, uint8_t binop, zval *op1, zval *op2) {
318318
/* TODO: We could implement support for evaluation of + on partial arrays. */
319319
if (IS_PARTIAL_ARRAY(op1) || IS_PARTIAL_ARRAY(op2)) {
320320
return FAILURE;
@@ -662,7 +662,7 @@ static inline zend_result ct_eval_assign_obj(zval *result, zval *value, const zv
662662
}
663663
}
664664

665-
static inline zend_result ct_eval_incdec(zval *result, zend_uchar opcode, zval *op1) {
665+
static inline zend_result ct_eval_incdec(zval *result, uint8_t opcode, zval *op1) {
666666
if (Z_TYPE_P(op1) == IS_ARRAY || IS_PARTIAL_ARRAY(op1)) {
667667
return FAILURE;
668668
}
@@ -1843,7 +1843,7 @@ static void sccp_mark_feasible_successors(
18431843
case ZEND_MATCH:
18441844
{
18451845
bool strict_comparison = opline->opcode == ZEND_MATCH;
1846-
zend_uchar type = Z_TYPE_P(op1);
1846+
uint8_t type = Z_TYPE_P(op1);
18471847
bool correct_type =
18481848
(opline->opcode == ZEND_SWITCH_LONG && type == IS_LONG)
18491849
|| (opline->opcode == ZEND_SWITCH_STRING && type == IS_STRING)
@@ -2134,7 +2134,7 @@ static int try_remove_definition(sccp_ctx *ctx, int var_num, zend_ssa_var *var,
21342134
&& opline->opcode != ZEND_ADD_ARRAY_ELEMENT
21352135
&& opline->opcode != ZEND_ADD_ARRAY_UNPACK) {
21362136
/* Replace with QM_ASSIGN */
2137-
zend_uchar old_type = opline->result_type;
2137+
uint8_t old_type = opline->result_type;
21382138
uint32_t old_var = opline->result.var;
21392139

21402140
ssa_op->result_def = -1;

‎Zend/Optimizer/ssa_integrity.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static inline bool is_in_successors(zend_basic_block *block, int check) {
8585
return 0;
8686
}
8787

88-
static inline bool is_var_type(zend_uchar type) {
88+
static inline bool is_var_type(uint8_t type) {
8989
return (type & (IS_CV|IS_VAR|IS_TMP_VAR)) != 0;
9090
}
9191

‎Zend/Optimizer/zend_cfg.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static void zend_mark_reachable(zend_op *opcodes, zend_cfg *cfg, zend_basic_bloc
4141
zend_basic_block *succ = blocks + b->successors[i];
4242

4343
if (b->len != 0) {
44-
zend_uchar opcode = opcodes[b->start + b->len - 1].opcode;
44+
uint8_t opcode = opcodes[b->start + b->len - 1].opcode;
4545
if (opcode == ZEND_MATCH) {
4646
succ->flags |= ZEND_BB_TARGET;
4747
} else if (opcode == ZEND_SWITCH_LONG || opcode == ZEND_SWITCH_STRING) {

‎Zend/Optimizer/zend_dump.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static void zend_dump_unused_op(const zend_op *opline, znode_op op, uint32_t fla
132132
}
133133
}
134134

135-
ZEND_API void zend_dump_var(const zend_op_array *op_array, zend_uchar var_type, int var_num)
135+
ZEND_API void zend_dump_var(const zend_op_array *op_array, uint8_t var_type, int var_num)
136136
{
137137
if (var_type == IS_CV && var_num < op_array->last_var) {
138138
fprintf(stderr, "CV%d($%s)", var_num, op_array->vars[var_num]->val);
@@ -348,7 +348,7 @@ static void zend_dump_ssa_var_info(const zend_ssa *ssa, int ssa_var_num, uint32_
348348
dump_flags);
349349
}
350350

351-
ZEND_API void zend_dump_ssa_var(const zend_op_array *op_array, const zend_ssa *ssa, int ssa_var_num, zend_uchar var_type, int var_num, uint32_t dump_flags)
351+
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, int var_num, uint32_t dump_flags)
352352
{
353353
if (ssa_var_num >= 0) {
354354
fprintf(stderr, "#%d.", ssa_var_num);

‎Zend/Optimizer/zend_dump.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include "zend_ssa.h"
2323
#include "zend_dfg.h"
2424

25+
#include <stdint.h>
26+
2527
#define ZEND_DUMP_HIDE_UNREACHABLE (1<<0)
2628
#define ZEND_DUMP_RC_INFERENCE (1<<1)
2729
#define ZEND_DUMP_CFG (1<<2)
@@ -39,8 +41,8 @@ void zend_dump_dfg(const zend_op_array *op_array, const zend_cfg *cfg, const zen
3941
void zend_dump_phi_placement(const zend_op_array *op_array, const zend_ssa *ssa);
4042
void zend_dump_variables(const zend_op_array *op_array);
4143
void zend_dump_ssa_variables(const zend_op_array *op_array, const zend_ssa *ssa, uint32_t dump_flags);
42-
ZEND_API void zend_dump_ssa_var(const zend_op_array *op_array, const zend_ssa *ssa, int ssa_var_num, zend_uchar var_type, int var_num, uint32_t dump_flags);
43-
ZEND_API void zend_dump_var(const zend_op_array *op_array, zend_uchar var_type, int var_num);
44+
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, int var_num, uint32_t dump_flags);
45+
ZEND_API void zend_dump_var(const zend_op_array *op_array, uint8_t var_type, int var_num);
4446
void zend_dump_op_array_name(const zend_op_array *op_array);
4547
void zend_dump_const(const zval *zv);
4648
void zend_dump_ht(HashTable *ht);

‎Zend/Optimizer/zend_inference.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ static void float_div(zend_long a, zend_long b, zend_long *r1, zend_long *r2) {
562562

563563
static bool zend_inference_calc_binary_op_range(
564564
const zend_op_array *op_array, const zend_ssa *ssa,
565-
const zend_op *opline, const zend_ssa_op *ssa_op, zend_uchar opcode, zend_ssa_range *tmp) {
565+
const zend_op *opline, const zend_ssa_op *ssa_op, uint8_t opcode, zend_ssa_range *tmp) {
566566
zend_long op1_min, op2_min, op1_max, op2_max, t1, t2, t3, t4;
567567

568568
switch (opcode) {
@@ -1881,7 +1881,7 @@ ZEND_API uint32_t ZEND_FASTCALL zend_array_type_info(const zval *zv)
18811881
}
18821882

18831883

1884-
ZEND_API uint32_t zend_array_element_type(uint32_t t1, zend_uchar op_type, int write, int insert)
1884+
ZEND_API uint32_t zend_array_element_type(uint32_t t1, uint8_t op_type, int write, int insert)
18851885
{
18861886
uint32_t tmp = 0;
18871887

@@ -1943,7 +1943,7 @@ ZEND_API uint32_t zend_array_element_type(uint32_t t1, zend_uchar op_type, int w
19431943
}
19441944

19451945
static uint32_t assign_dim_array_result_type(
1946-
uint32_t arr_type, uint32_t dim_type, uint32_t value_type, zend_uchar dim_op_type) {
1946+
uint32_t arr_type, uint32_t dim_type, uint32_t value_type, uint8_t dim_op_type) {
19471947
uint32_t tmp = 0;
19481948
/* Only add key type if we have a value type. We want to maintain the invariant that a
19491949
* key type exists iff a value type exists even in dead code that may use empty types. */
@@ -1987,7 +1987,7 @@ static uint32_t assign_dim_array_result_type(
19871987
}
19881988

19891989
static uint32_t assign_dim_result_type(
1990-
uint32_t arr_type, uint32_t dim_type, uint32_t value_type, zend_uchar dim_op_type) {
1990+
uint32_t arr_type, uint32_t dim_type, uint32_t value_type, uint8_t dim_op_type) {
19911991
uint32_t tmp = arr_type & ~(MAY_BE_RC1|MAY_BE_RCN);
19921992

19931993
if (arr_type & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE)) {
@@ -2008,7 +2008,7 @@ static uint32_t assign_dim_result_type(
20082008

20092009
/* For binary ops that have compound assignment operators */
20102010
static uint32_t binary_op_result_type(
2011-
zend_ssa *ssa, zend_uchar opcode, uint32_t t1, uint32_t t2, int result_var,
2011+
zend_ssa *ssa, uint8_t opcode, uint32_t t1, uint32_t t2, int result_var,
20122012
zend_long optimization_level) {
20132013
uint32_t tmp = 0;
20142014
uint32_t t1_type = (t1 & MAY_BE_ANY) | (t1 & MAY_BE_UNDEF ? MAY_BE_NULL : 0);
@@ -3321,7 +3321,7 @@ static zend_always_inline zend_result _zend_update_type_info(
33213321
tmp |= key_type | MAY_BE_ARRAY | MAY_BE_ARRAY_OF_NULL;
33223322
}
33233323
while (j >= 0) {
3324-
zend_uchar opcode;
3324+
uint8_t opcode;
33253325

33263326
if (!ssa_opcodes) {
33273327
ZEND_ASSERT(j == (opline - op_array->opcodes) + 1 && "Use must be in next opline");
@@ -3964,7 +3964,7 @@ static bool can_convert_to_double(
39643964
return 0;
39653965
}
39663966
} else {
3967-
zend_uchar opcode = opline->opcode;
3967+
uint8_t opcode = opline->opcode;
39683968

39693969
if (opcode == ZEND_ASSIGN_OP) {
39703970
opcode = opline->extended_value;

‎Zend/Optimizer/zend_inference.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
/* Bitmask for type inference (zend_ssa_var_info.type) */
2727
#include "zend_type_info.h"
2828

29+
#include <stdint.h>
30+
2931
#define MAY_BE_PACKED_GUARD (1<<27) /* needs packed array guard */
3032
#define MAY_BE_CLASS_GUARD (1<<27) /* needs class guard */
3133
#define MAY_BE_GUARD (1<<28) /* needs type guard */
@@ -220,7 +222,7 @@ ZEND_API void zend_ssa_find_false_dependencies(const zend_op_array *op_array, ze
220222
ZEND_API void zend_ssa_find_sccs(const zend_op_array *op_array, zend_ssa *ssa);
221223
ZEND_API int zend_ssa_inference(zend_arena **raena, const zend_op_array *op_array, const zend_script *script, zend_ssa *ssa, zend_long optimization_level);
222224

223-
ZEND_API ZEND_ATTRIBUTE_CONST uint32_t zend_array_element_type(uint32_t t1, zend_uchar op_type, int write, int insert);
225+
ZEND_API ZEND_ATTRIBUTE_CONST uint32_t zend_array_element_type(uint32_t t1, uint8_t op_type, int write, int insert);
224226

225227
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);
226228

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /