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 0f17ea4

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 04c76a3 commit 0f17ea4

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

+357
-336
lines changed

‎Zend/Optimizer/block_pass.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array
533533
break;
534534
case ZEND_IS_SMALLER:
535535
if (opline->opcode == ZEND_BOOL_NOT) {
536-
zend_uchar tmp_type;
536+
uint8_t tmp_type;
537537
uint32_t tmp;
538538

539539
src->opcode = ZEND_IS_SMALLER_OR_EQUAL;
@@ -551,7 +551,7 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array
551551
break;
552552
case ZEND_IS_SMALLER_OR_EQUAL:
553553
if (opline->opcode == ZEND_BOOL_NOT) {
554-
zend_uchar tmp_type;
554+
uint8_t tmp_type;
555555
uint32_t tmp;
556556

557557
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
}
@@ -1844,7 +1844,7 @@ static void sccp_mark_feasible_successors(
18441844
case ZEND_MATCH:
18451845
{
18461846
bool strict_comparison = opline->opcode == ZEND_MATCH;
1847-
zend_uchar type = Z_TYPE_P(op1);
1847+
uint8_t type = Z_TYPE_P(op1);
18481848
bool correct_type =
18491849
(opline->opcode == ZEND_SWITCH_LONG && type == IS_LONG)
18501850
|| (opline->opcode == ZEND_SWITCH_STRING && type == IS_STRING)
@@ -2135,7 +2135,7 @@ static int try_remove_definition(sccp_ctx *ctx, int var_num, zend_ssa_var *var,
21352135
&& opline->opcode != ZEND_ADD_ARRAY_ELEMENT
21362136
&& opline->opcode != ZEND_ADD_ARRAY_UNPACK) {
21372137
/* Replace with QM_ASSIGN */
2138-
zend_uchar old_type = opline->result_type;
2138+
uint8_t old_type = opline->result_type;
21392139
uint32_t old_var = opline->result.var;
21402140

21412141
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);
@@ -361,7 +361,7 @@ static void zend_dump_ssa_var_info(const zend_ssa *ssa, int ssa_var_num, uint32_
361361
dump_flags);
362362
}
363363

364-
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)
364+
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)
365365
{
366366
if (ssa_var_num >= 0) {
367367
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
@@ -795,7 +795,7 @@ static void float_div(zend_long a, zend_long b, zend_long *r1, zend_long *r2) {
795795

796796
static bool zend_inference_calc_binary_op_range(
797797
const zend_op_array *op_array, const zend_ssa *ssa,
798-
const zend_op *opline, const zend_ssa_op *ssa_op, zend_uchar opcode, zend_ssa_range *tmp) {
798+
const zend_op *opline, const zend_ssa_op *ssa_op, uint8_t opcode, zend_ssa_range *tmp) {
799799
zend_long op1_min, op2_min, op1_max, op2_max, t1, t2, t3, t4;
800800

801801
switch (opcode) {
@@ -2126,7 +2126,7 @@ ZEND_API uint32_t ZEND_FASTCALL zend_array_type_info(const zval *zv)
21262126
}
21272127

21282128

2129-
ZEND_API uint32_t zend_array_element_type(uint32_t t1, zend_uchar op_type, int write, int insert)
2129+
ZEND_API uint32_t zend_array_element_type(uint32_t t1, uint8_t op_type, int write, int insert)
21302130
{
21312131
uint32_t tmp = 0;
21322132

@@ -2188,7 +2188,7 @@ ZEND_API uint32_t zend_array_element_type(uint32_t t1, zend_uchar op_type, int w
21882188
}
21892189

21902190
static uint32_t assign_dim_array_result_type(
2191-
uint32_t arr_type, uint32_t dim_type, uint32_t value_type, zend_uchar dim_op_type) {
2191+
uint32_t arr_type, uint32_t dim_type, uint32_t value_type, uint8_t dim_op_type) {
21922192
uint32_t tmp = 0;
21932193
/* Only add key type if we have a value type. We want to maintain the invariant that a
21942194
* key type exists iff a value type exists even in dead code that may use empty types. */
@@ -2233,7 +2233,7 @@ static uint32_t assign_dim_array_result_type(
22332233
}
22342234

22352235
static uint32_t assign_dim_result_type(
2236-
uint32_t arr_type, uint32_t dim_type, uint32_t value_type, zend_uchar dim_op_type) {
2236+
uint32_t arr_type, uint32_t dim_type, uint32_t value_type, uint8_t dim_op_type) {
22372237
uint32_t tmp = arr_type & ~(MAY_BE_RC1|MAY_BE_RCN);
22382238

22392239
if (arr_type & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE)) {
@@ -2254,7 +2254,7 @@ static uint32_t assign_dim_result_type(
22542254

22552255
/* For binary ops that have compound assignment operators */
22562256
static uint32_t binary_op_result_type(
2257-
zend_ssa *ssa, zend_uchar opcode, uint32_t t1, uint32_t t2, int result_var,
2257+
zend_ssa *ssa, uint8_t opcode, uint32_t t1, uint32_t t2, int result_var,
22582258
zend_long optimization_level) {
22592259
uint32_t tmp = 0;
22602260
uint32_t t1_type = (t1 & MAY_BE_ANY) | (t1 & MAY_BE_UNDEF ? MAY_BE_NULL : 0);
@@ -3602,7 +3602,7 @@ static zend_always_inline zend_result _zend_update_type_info(
36023602
tmp |= key_type | MAY_BE_ARRAY | MAY_BE_ARRAY_OF_NULL;
36033603
}
36043604
while (j >= 0) {
3605-
zend_uchar opcode;
3605+
uint8_t opcode;
36063606

36073607
if (!ssa_opcodes) {
36083608
if (j != (opline - op_array->opcodes) + 1) {
@@ -4262,7 +4262,7 @@ static bool can_convert_to_double(
42624262
return 0;
42634263
}
42644264
} else {
4265-
zend_uchar opcode = opline->opcode;
4265+
uint8_t opcode = opline->opcode;
42664266

42674267
if (opcode == ZEND_ASSIGN_OP) {
42684268
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 */
@@ -219,7 +221,7 @@ ZEND_API void zend_ssa_find_false_dependencies(const zend_op_array *op_array, ze
219221
ZEND_API void zend_ssa_find_sccs(const zend_op_array *op_array, zend_ssa *ssa);
220222
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);
221223

222-
ZEND_API ZEND_ATTRIBUTE_CONST uint32_t zend_array_element_type(uint32_t t1, zend_uchar op_type, int write, int insert);
224+
ZEND_API ZEND_ATTRIBUTE_CONST uint32_t zend_array_element_type(uint32_t t1, uint8_t op_type, int write, int insert);
223225

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

0 commit comments

Comments
(0)

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