Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
dc75bb4
calendar: Use `true` / `false` instead of `1` / `0` when assigning to…
TimWolla Sep 23, 2025
b32bc35
com_dotnet: Use `true` / `false` instead of `1` / `0` when assigning …
TimWolla Sep 23, 2025
843cc54
date: Use `true` / `false` instead of `1` / `0` when assigning to `bool`
TimWolla Sep 23, 2025
acb5c7c
dba: Use `true` / `false` instead of `1` / `0` when assigning to `bool`
TimWolla Sep 23, 2025
797e8a4
dom: Use `true` / `false` instead of `1` / `0` when assigning to `bool`
TimWolla Sep 23, 2025
1ed8f2a
ffi: Use `true` / `false` instead of `1` / `0` when assigning to `bool`
TimWolla Sep 23, 2025
62701c0
ftp: Use `true` / `false` instead of `1` / `0` when assigning to `bool`
TimWolla Sep 23, 2025
66e3dcb
gmp: Use `true` / `false` instead of `1` / `0` when assigning to `bool`
TimWolla Sep 23, 2025
bc7961f
hash: Use `true` / `false` instead of `1` / `0` when assigning to `bool`
TimWolla Sep 23, 2025
75eec9a
iconv: Use `true` / `false` instead of `1` / `0` when assigning to `b…
TimWolla Sep 23, 2025
762624c
intl: Use `true` / `false` instead of `1` / `0` when assigning to `bool`
TimWolla Sep 23, 2025
1c077ac
json: Use `true` / `false` instead of `1` / `0` when assigning to `bool`
TimWolla Sep 23, 2025
7121dd0
ldap: Use `true` / `false` instead of `1` / `0` when assigning to `bool`
TimWolla Sep 23, 2025
3b30e3b
mbstring: Use `true` / `false` instead of `1` / `0` when assigning to…
TimWolla Sep 23, 2025
0fe0a32
mysqli: Use `true` / `false` instead of `1` / `0` when assigning to `…
TimWolla Sep 23, 2025
68ea653
mysqlnd: Use `true` / `false` instead of `1` / `0` when assigning to …
TimWolla Sep 23, 2025
99a88d1
odbc: Use `true` / `false` instead of `1` / `0` when assigning to `bool`
TimWolla Sep 23, 2025
5a0e87a
opcache: Use `true` / `false` instead of `1` / `0` when assigning to …
TimWolla Sep 23, 2025
703a047
openssl: Use `true` / `false` instead of `1` / `0` when assigning to …
TimWolla Sep 23, 2025
c5fbc7e
pcre: Use `true` / `false` instead of `1` / `0` when assigning to `bool`
TimWolla Sep 23, 2025
d3bbc02
pdo: Use `true` / `false` instead of `1` / `0` when assigning to `bool`
TimWolla Sep 23, 2025
bf3c6a8
pdo_dblib: Use `true` / `false` instead of `1` / `0` when assigning t…
TimWolla Sep 23, 2025
03c0c8c
pdo_firebird: Use `true` / `false` instead of `1` / `0` when assignin…
TimWolla Sep 23, 2025
c65bb4b
pdo_mysql: Use `true` / `false` instead of `1` / `0` when assigning t…
TimWolla Sep 23, 2025
a56cabc
pdo_pgsql: Use `true` / `false` instead of `1` / `0` when assigning t…
TimWolla Sep 23, 2025
fefb83e
phar: Use `true` / `false` instead of `1` / `0` when assigning to `bool`
TimWolla Sep 23, 2025
f657d6c
reflection: Use `true` / `false` instead of `1` / `0` when assigning …
TimWolla Sep 23, 2025
34bad56
session: Use `true` / `false` instead of `1` / `0` when assigning to …
TimWolla Sep 23, 2025
4bfbe64
simplexml: Use `true` / `false` instead of `1` / `0` when assigning t…
TimWolla Sep 23, 2025
078e7da
soap: Use `true` / `false` instead of `1` / `0` when assigning to `bool`
TimWolla Sep 23, 2025
a89c789
spl: Use `true` / `false` instead of `1` / `0` when assigning to `bool`
TimWolla Sep 23, 2025
fb3c4a7
sqlite3: Use `true` / `false` instead of `1` / `0` when assigning to …
TimWolla Sep 23, 2025
646c833
standard: Use `true` / `false` instead of `1` / `0` when assigning to…
TimWolla Sep 23, 2025
c29b398
sysvmsg: Use `true` / `false` instead of `1` / `0` when assigning to …
TimWolla Sep 23, 2025
e80609b
sysvsem: Use `true` / `false` instead of `1` / `0` when assigning to …
TimWolla Sep 23, 2025
22bf49e
sysvshm: Use `true` / `false` instead of `1` / `0` when assigning to …
TimWolla Sep 23, 2025
66a2fe1
xml: Use `true` / `false` instead of `1` / `0` when assigning to `bool`
TimWolla Sep 23, 2025
a38aac2
xmlwriter: Use `true` / `false` instead of `1` / `0` when assigning t…
TimWolla Sep 23, 2025
e537e1e
zip: Use `true` / `false` instead of `1` / `0` when assigning to `bool`
TimWolla Sep 23, 2025
38c93bb
zlib: Use `true` / `false` instead of `1` / `0` when assigning to `bool`
TimWolla Sep 23, 2025
9eb252a
Optimizer: Use `true` / `false` instead of `1` / `0` when assigning t…
TimWolla Sep 23, 2025
fc8446a
Zend: Use `true` / `false` instead of `1` / `0` when assigning to `bool`
TimWolla Sep 23, 2025
1ae731b
date: Use `return true` / `return false` for functions returning `bool`
TimWolla Sep 23, 2025
ffdf419
exif: Use `return true` / `return false` for functions returning `bool`
TimWolla Sep 23, 2025
564c22d
filter: Use `return true` / `return false` for functions returning `b…
TimWolla Sep 23, 2025
fd25dbc
ftp: Use `return true` / `return false` for functions returning `bool`
TimWolla Sep 23, 2025
3b36e8e
intl: Use `return true` / `return false` for functions returning `bool`
TimWolla Sep 23, 2025
6807bbe
mysqlnd: Use `return true` / `return false` for functions returning `…
TimWolla Sep 23, 2025
cde0c57
opcache: Use `return true` / `return false` for functions returning `…
TimWolla Sep 23, 2025
44c1cfc
openssl: Use `return true` / `return false` for functions returning `…
TimWolla Sep 23, 2025
7b45533
pcre: Use `return true` / `return false` for functions returning `bool`
TimWolla Sep 23, 2025
d881b67
pdo: Use `return true` / `return false` for functions returning `bool`
TimWolla Sep 23, 2025
1aae2f3
phar: Use `return true` / `return false` for functions returning `bool`
TimWolla Sep 23, 2025
b21e08a
session: Use `return true` / `return false` for functions returning `…
TimWolla Sep 23, 2025
ddec4a5
soap: Use `return true` / `return false` for functions returning `bool`
TimWolla Sep 23, 2025
6748025
sockets: Use `return true` / `return false` for functions returning `…
TimWolla Sep 23, 2025
21e88cb
sodium: Use `return true` / `return false` for functions returning `b…
TimWolla Sep 23, 2025
240c4ac
spl: Use `return true` / `return false` for functions returning `bool`
TimWolla Sep 23, 2025
773e83f
standard: Use `return true` / `return false` for functions returning …
TimWolla Sep 23, 2025
b47afc2
tokenizer: Use `return true` / `return false` for functions returning…
TimWolla Sep 23, 2025
5fdf833
zlib: Use `return true` / `return false` for functions returning `bool`
TimWolla Sep 23, 2025
06c393e
Optimizer: Use `return true` / `return false` for functions returning…
TimWolla Sep 23, 2025
170f0f3
Zend: Use `return true` / `return false` for functions returning `bool`
TimWolla Sep 23, 2025
aa0c66f
com_dotnet: Use `true` / `false` instead of `1` / `0` for `bool` para…
TimWolla Sep 23, 2025
d4305c8
date: Use `true` / `false` instead of `1` / `0` for `bool` parameters
TimWolla Sep 23, 2025
ab2d6df
dba: Use `true` / `false` instead of `1` / `0` for `bool` parameters
TimWolla Sep 23, 2025
7fa390e
ffi: Use `true` / `false` instead of `1` / `0` for `bool` parameters
TimWolla Sep 23, 2025
937e807
hash: Use `true` / `false` instead of `1` / `0` for `bool` parameters
TimWolla Sep 23, 2025
c8a02cc
mbstring: Use `true` / `false` instead of `1` / `0` for `bool` parame…
TimWolla Sep 23, 2025
8fde6ea
opcache: Use `true` / `false` instead of `1` / `0` for `bool` parameters
TimWolla Sep 23, 2025
86b8b6e
openssl: Use `true` / `false` instead of `1` / `0` for `bool` parameters
TimWolla Sep 23, 2025
50b6d36
pdo: Use `true` / `false` instead of `1` / `0` for `bool` parameters
TimWolla Sep 23, 2025
81e8d39
pgsql: Use `true` / `false` instead of `1` / `0` for `bool` parameters
TimWolla Sep 23, 2025
b33fd88
phar: Use `true` / `false` instead of `1` / `0` for `bool` parameters
TimWolla Sep 23, 2025
c198044
reflection: Use `true` / `false` instead of `1` / `0` for `bool` para…
TimWolla Sep 23, 2025
c4e7f0d
session: Use `true` / `false` instead of `1` / `0` for `bool` parameters
TimWolla Sep 23, 2025
8a6adce
spl: Use `true` / `false` instead of `1` / `0` for `bool` parameters
TimWolla Sep 23, 2025
4a70271
standard: Use `true` / `false` instead of `1` / `0` for `bool` parame…
TimWolla Sep 23, 2025
ef80d24
Optimizer: Use `true` / `false` instead of `1` / `0` for `bool` param…
TimWolla Sep 23, 2025
e01837f
Zend: Use `true` / `false` instead of `1` / `0` for `bool` parameters
TimWolla Sep 23, 2025
5fd13bb
openssl: Use `true` / `false` instead of `1` / `0` for `bool` paramet…
TimWolla Sep 23, 2025
d69ff81
standard: Use `true` / `false` instead of `1` / `0` for `bool` parame…
TimWolla Sep 23, 2025
c76f355
Optimizer: Use `true` / `false` instead of `1` / `0` for `bool` param…
TimWolla Sep 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Zend/Optimizer/block_pass.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ bool zend_optimizer_get_persistent_constant(zend_string *name, zval *result, int
if (copy) {
Z_TRY_ADDREF_P(result);
}
return 1;
return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huge 👍 for making the codebase cleaner.

What about integrating the simpler patches like:

Changes done with Coccinelle:

    @@
    bool b;
    @@

    - b = 0
    + b = false

    @@
    bool b;
    @@

    - b = 1
    + b = true

into the CI directly?

} else {
return 0;
return false;
}
}

/* Special constants null/true/false can always be substituted. */
c = zend_get_special_const(ZSTR_VAL(name), ZSTR_LEN(name));
if (c) {
ZVAL_COPY_VALUE(result, &c->value);
return 1;
return true;
}
return 0;
return false;
}

/* Data dependencies macros */
Expand Down Expand Up @@ -949,14 +949,14 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array
src = VAR_SOURCE(opline->op1);
if (src && src->opcode == ZEND_QM_ASSIGN) {
zend_op *op = src + 1;
bool optimize = 1;
bool optimize = true;

while (op < opline) {
if ((op->op1_type == opline->op1_type
&& op->op1.var == opline->op1.var)
|| (op->op2_type == opline->op1_type
&& op->op2.var == opline->op1.var)) {
optimize = 0;
optimize = false;
break;
}
op++;
Expand Down Expand Up @@ -1566,14 +1566,14 @@ static void zend_t_usage(zend_cfg *cfg, zend_op_array *op_array, zend_bitset use
}

if (ctx->debug_level & ZEND_DUMP_BLOCK_PASS_VARS) {
bool printed = 0;
bool printed = false;
uint32_t i;

for (i = op_array->last_var; i< op_array->T; i++) {
if (zend_bitset_in(used_ext, i)) {
if (!printed) {
fprintf(stderr, "NON-LOCAL-VARS: %d", i);
printed = 1;
printed = true;
} else {
fprintf(stderr, ", %d", i);
}
Expand Down
82 changes: 41 additions & 41 deletions Zend/Optimizer/dce.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ typedef struct {
static inline bool is_bad_mod(const zend_ssa *ssa, int use, int def) {
if (def < 0) {
/* This modification is not tracked by SSA, assume the worst */
return 1;
return true;
}
if (ssa->var_info[use].type & MAY_BE_REF) {
/* Modification of reference may have side-effect */
return 1;
return true;
}
return 0;
return false;
}

static inline bool may_have_side_effects(
Expand Down Expand Up @@ -125,18 +125,18 @@ static inline bool may_have_side_effects(
case ZEND_FUNC_GET_ARGS:
case ZEND_ARRAY_KEY_EXISTS:
/* No side effects */
return 0;
return false;
case ZEND_FREE:
return opline->extended_value == ZEND_FREE_VOID_CAST;
case ZEND_ADD_ARRAY_ELEMENT:
/* TODO: We can't free two vars. Keep instruction alive. <?php [0, "$a" => "$b"]; */
if ((opline->op1_type & (IS_VAR|IS_TMP_VAR)) && (opline->op2_type & (IS_VAR|IS_TMP_VAR))) {
return 1;
return true;
}
return 0;
return false;
case ZEND_ROPE_END:
/* TODO: Rope dce optimization, see #76446 */
return 1;
return true;
case ZEND_JMP:
case ZEND_JMPZ:
case ZEND_JMPNZ:
Expand All @@ -149,7 +149,7 @@ static inline bool may_have_side_effects(
case ZEND_BIND_INIT_STATIC_OR_JMP:
case ZEND_JMP_FRAMELESS:
/* For our purposes a jumps and branches are side effects. */
return 1;
return true;
case ZEND_BEGIN_SILENCE:
case ZEND_END_SILENCE:
case ZEND_ECHO:
Expand All @@ -164,7 +164,7 @@ static inline bool may_have_side_effects(
case ZEND_YIELD_FROM:
case ZEND_VERIFY_NEVER_TYPE:
/* Intrinsic side effects */
return 1;
return true;
case ZEND_DO_FCALL:
case ZEND_DO_FCALL_BY_NAME:
case ZEND_DO_ICALL:
Expand All @@ -174,31 +174,31 @@ static inline bool may_have_side_effects(
case ZEND_FRAMELESS_ICALL_2:
case ZEND_FRAMELESS_ICALL_3:
/* For now assume all calls have side effects */
return 1;
return true;
case ZEND_RECV:
case ZEND_RECV_INIT:
/* Even though RECV_INIT can be side-effect free, these cannot be simply dropped
* due to the prologue skipping code. */
return 1;
return true;
case ZEND_ASSIGN_REF:
return 1;
return true;
case ZEND_ASSIGN:
{
if (is_bad_mod(ssa, ssa_op->op1_use, ssa_op->op1_def)) {
return 1;
return true;
}
if (!reorder_dtor_effects) {
if (opline->op2_type != IS_CONST
&& (OP2_INFO() & MAY_HAVE_DTOR)
&& ssa->vars[ssa_op->op2_use].escape_state != ESCAPE_STATE_NO_ESCAPE) {
/* DCE might shorten lifetime */
return 1;
return true;
}
}
return 0;
return false;
}
case ZEND_UNSET_VAR:
return 1;
return true;
case ZEND_UNSET_CV:
{
uint32_t t1 = OP1_INFO();
Expand All @@ -207,9 +207,9 @@ static inline bool may_have_side_effects(
* an unset may be considered dead even if there is a later assignment to the
* variable. Removing the unset in this case would not be correct if the variable
* is a reference, because unset breaks references. */
return 1;
return true;
}
return 0;
return false;
}
case ZEND_PRE_INC:
case ZEND_POST_INC:
Expand All @@ -223,41 +223,41 @@ static inline bool may_have_side_effects(
case ZEND_ASSIGN_OBJ:
if (is_bad_mod(ssa, ssa_op->op1_use, ssa_op->op1_def)
|| ssa->vars[ssa_op->op1_def].escape_state != ESCAPE_STATE_NO_ESCAPE) {
return 1;
return true;
}
if (!reorder_dtor_effects) {
opline++;
ssa_op++;
if (opline->op1_type != IS_CONST
&& (OP1_INFO() & MAY_HAVE_DTOR)) {
/* DCE might shorten lifetime */
return 1;
return true;
}
}
return 0;
return false;
case ZEND_PRE_INC_OBJ:
case ZEND_PRE_DEC_OBJ:
case ZEND_POST_INC_OBJ:
case ZEND_POST_DEC_OBJ:
if (is_bad_mod(ssa, ssa_op->op1_use, ssa_op->op1_def)
|| ssa->vars[ssa_op->op1_def].escape_state != ESCAPE_STATE_NO_ESCAPE) {
return 1;
return true;
}
return 0;
return false;
case ZEND_BIND_STATIC:
if (op_array->static_variables) {
/* Implicit and Explicit bind static is effectively prologue of closure so
report it has side effects like RECV, RECV_INIT; This allows us to
reflect on the closure and discover used variable at runtime */
if ((opline->extended_value & (ZEND_BIND_IMPLICIT|ZEND_BIND_EXPLICIT))) {
return 1;
return true;
}
/* Modifies static variables which are observable through reflection */
if ((opline->extended_value & ZEND_BIND_REF) && opline->op2_type != IS_UNUSED) {
return 1;
return true;
}
}
return 0;
return false;
case ZEND_CHECK_VAR:
return (OP1_INFO() & MAY_BE_UNDEF) != 0;
case ZEND_FE_RESET_R:
Expand All @@ -267,7 +267,7 @@ static inline bool may_have_side_effects(
return (OP1_INFO() & MAY_BE_ANY) != MAY_BE_ARRAY;
default:
/* For everything we didn't handle, assume a side-effect */
return 1;
return true;
}
}

Expand Down Expand Up @@ -340,7 +340,7 @@ static inline bool is_var_dead(context *ctx, int var_num) {
// Sometimes we can mark the var as EXT_UNUSED
static bool try_remove_var_def(context *ctx, int free_var, int use_chain, zend_op *opline) {
if (use_chain >= 0) {
return 0;
return false;
}
zend_ssa_var *var = &ctx->ssa->vars[free_var];
int def = var->definition;
Expand Down Expand Up @@ -381,13 +381,13 @@ static bool try_remove_var_def(context *ctx, int free_var, int use_chain, zend_o
def_opline->result.var = 0;
def_op->result_def = -1;
var->definition = -1;
return 1;
return true;
default:
break;
}
}
}
return 0;
return false;
}

static zend_always_inline bool may_be_refcounted(uint32_t type) {
Expand All @@ -400,13 +400,13 @@ static inline bool is_free_of_live_var(context *ctx, zend_op *opline, zend_ssa_o
/* It is always safe to remove FREEs of non-refcounted values, even if they are live. */
if ((ctx->ssa->var_info[ssa_op->op1_use].type & (MAY_BE_REF|MAY_BE_ANY|MAY_BE_UNDEF)) != 0
&& !may_be_refcounted(ctx->ssa->var_info[ssa_op->op1_use].type)) {
return 0;
return false;
}
ZEND_FALLTHROUGH;
case ZEND_FE_FREE:
return !is_var_dead(ctx, ssa_op->op1_use);
default:
return 0;
return false;
}
}

Expand All @@ -417,12 +417,12 @@ static bool dce_instr(context *ctx, zend_op *opline, zend_ssa_op *ssa_op) {
uint8_t free_var_type;

if (opline->opcode == ZEND_NOP) {
return 0;
return false;
}

/* We mark FREEs as dead, but they're only really dead if the destroyed var is dead */
if (is_free_of_live_var(ctx, opline, ssa_op)) {
return 0;
return false;
}

if ((opline->op1_type & (IS_VAR|IS_TMP_VAR))&& !is_var_dead(ctx, ssa_op->op1_use)) {
Expand All @@ -440,7 +440,7 @@ static bool dce_instr(context *ctx, zend_op *opline, zend_ssa_op *ssa_op) {
if (free_var >= 0) {
// TODO: We can't free two vars. Keep instruction alive.
zend_bitset_excl(ctx->instr_dead, opline - ctx->op_array->opcodes);
return 0;
return false;
}
free_var = ssa_op->op2_use;
free_var_type = opline->op2_type;
Expand All @@ -459,9 +459,9 @@ static bool dce_instr(context *ctx, zend_op *opline, zend_ssa_op *ssa_op) {
ssa_op->op1_use = free_var;
ssa_op->op1_use_chain = ssa->vars[free_var].use_chain;
ssa->vars[free_var].use_chain = ssa_op - ssa->ops;
return 0;
return false;
}
return 1;
return true;
}

static inline int get_common_phi_source(zend_ssa *ssa, zend_ssa_phi *phi) {
Expand Down Expand Up @@ -507,17 +507,17 @@ static void try_remove_trivial_phi(context *ctx, zend_ssa_phi *phi) {
static inline bool may_break_varargs(const zend_op_array *op_array, const zend_ssa *ssa, const zend_ssa_op *ssa_op) {
if (ssa_op->op1_def >= 0
&& ssa->vars[ssa_op->op1_def].var < op_array->num_args) {
return 1;
return true;
}
if (ssa_op->op2_def >= 0
&& ssa->vars[ssa_op->op2_def].var < op_array->num_args) {
return 1;
return true;
}
if (ssa_op->result_def >= 0
&& ssa->vars[ssa_op->result_def].var < op_array->num_args) {
return 1;
return true;
}
return 0;
return false;
}

static inline bool may_throw_dce_exception(const zend_op *opline) {
Expand Down
Loading
Loading