Skip to content
Merged
Changes from 1 commit
Commits
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
20 changes: 10 additions & 10 deletions Zend/Optimizer/block_pass.c
Original file line number Diff line number Diff line change
Expand Up @@ -1042,8 +1042,8 @@ static void assemble_code_blocks(const zend_cfg *cfg, zend_op_array *op_array, z
} else {
/* this block will not be used, delete all constants there */
const zend_op *op = op_array->opcodes + b->start;
const zend_op *end = op + b->len;
for (; op < end; op++) {
const zend_op *last_op = op + b->len;
for (; op < last_op; op++) {
if (op->op1_type == IS_CONST) {
literal_dtor(&ZEND_OP1_LITERAL(op));
}
Expand Down Expand Up @@ -1159,15 +1159,15 @@ static void assemble_code_blocks(const zend_cfg *cfg, zend_op_array *op_array, z
}

if (op_array->fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK) {
zend_op *opline = new_opcodes;
const zend_op *end = opline + len;
while (opline < end) {
if (opline->opcode == ZEND_FAST_RET &&
opline->op2.num != (uint32_t)-1 &&
opline->op2.num < j) {
opline->op2.num = map[opline->op2.num];
zend_op *finally_opline = new_opcodes;
const zend_op *last_finally_op = finally_opline + len;
while (finally_opline < last_finally_op) {
Comment on lines +1163 to +1164
Copy link
Member

Choose a reason for hiding this comment

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

Nit: This is not the last finally op, it's the op after it

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, but isn't it a usual convention that "last" means +1? Or am I confused?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I'm not blocking this change. There are some cases of last being used to mean +1, especially in op_array, but I find it confusing. end is slightly better.

Copy link
Member Author

Choose a reason for hiding this comment

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

I do also find it confusing, just couldn't think of a name :) Might keep it like this for the time being tho

if (finally_opline->opcode == ZEND_FAST_RET &&
finally_opline->op2.num != (uint32_t)-1 &&
finally_opline->op2.num < j) {
finally_opline->op2.num = map[finally_opline->op2.num];
}
opline++;
finally_opline++;
}
}
}
Expand Down