com php-src: Fixed optimization (the bug caused endless-loop on micro_bench.php in master branch): ext/opcache/ Optimizer/dfa_pass.c

From: Date: Mon, 18 Sep 2017 11:10:18 +0000
Subject: com php-src: Fixed optimization (the bug caused endless-loop on micro_bench.php in master branch): ext/opcache/ Optimizer/dfa_pass.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-99449@lists.php.net to get a copy of this message
Commit: 084e34098a44669b64a9e43fb598456136268cde Author: Dmitry Stogov <dmitry@zend.com> Mon, 18 Sep 2017 14:10:18 +0300 Parents: d8f1afb45ea90cd655e62b4f514276099a033521 Branches: PHP-7.2 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=084e34098a44669b64a9e43fb598456136268cde Log: Fixed optimization (the bug caused endless-loop on micro_bench.php in master branch) Changed paths: M ext/opcache/Optimizer/dfa_pass.c Diff: diff --git a/ext/opcache/Optimizer/dfa_pass.c b/ext/opcache/Optimizer/dfa_pass.c index 9dbd4d1..15245cf 100644 --- a/ext/opcache/Optimizer/dfa_pass.c +++ b/ext/opcache/Optimizer/dfa_pass.c @@ -129,7 +129,7 @@ static void zend_ssa_remove_nops(zend_op_array *op_array, zend_ssa *ssa) zend_basic_block *b; zend_func_info *func_info; int j; - uint32_t i; + uint32_t i = 0; uint32_t target = 0; uint32_t *shiftlist; ALLOCA_FLAG(use_heap); @@ -139,46 +139,53 @@ static void zend_ssa_remove_nops(zend_op_array *op_array, zend_ssa *ssa) for (b = blocks; b < end; b++) { if (b->flags & (ZEND_BB_REACHABLE|ZEND_BB_UNREACHABLE_FREE)) { uint32_t end; - if (b->flags & ZEND_BB_UNREACHABLE_FREE) { - /* Only keep the FREE for the loop var */ - ZEND_ASSERT(op_array->opcodes[b->start].opcode == ZEND_FREE - || op_array->opcodes[b->start].opcode == ZEND_FE_FREE); - b->len = 1; - } - end = b->start + b->len; - i = b->start; - b->start = target; - while (i < end) { - shiftlist[i] = i - target; - if (EXPECTED(op_array->opcodes[i].opcode != ZEND_NOP) || - /*keep NOP to support ZEND_VM_SMART_BRANCH */ - (i > 0 && - i + 1 < op_array->last && - (op_array->opcodes[i+1].opcode == ZEND_JMPZ || - op_array->opcodes[i+1].opcode == ZEND_JMPNZ) && - zend_is_smart_branch(op_array->opcodes + i - 1))) { - if (i != target) { - op_array->opcodes[target] = op_array->opcodes[i]; - ssa->ops[target] = ssa->ops[i]; - ssa->cfg.map[target] = b - blocks; - } - target++; + if (b->len) { + while (i < b->start) { + shiftlist[i] = i - target; + i++; } - i++; - } - if (target != end && b->len != 0) { - zend_op *opline; - zend_op *new_opline; - - b->len = target - b->start; - opline = op_array->opcodes + end - 1; - if (opline->opcode == ZEND_NOP) { - continue; + + if (b->flags & ZEND_BB_UNREACHABLE_FREE) { + /* Only keep the FREE for the loop var */ + ZEND_ASSERT(op_array->opcodes[b->start].opcode == ZEND_FREE + || op_array->opcodes[b->start].opcode == ZEND_FE_FREE); + b->len = 1; + } + + end = b->start + b->len; + b->start = target; + while (i < end) { + shiftlist[i] = i - target; + if (EXPECTED(op_array->opcodes[i].opcode != ZEND_NOP) || + /*keep NOP to support ZEND_VM_SMART_BRANCH */ + (i > 0 && + i + 1 < op_array->last && + (op_array->opcodes[i+1].opcode == ZEND_JMPZ || + op_array->opcodes[i+1].opcode == ZEND_JMPNZ) && + zend_is_smart_branch(op_array->opcodes + i - 1))) { + if (i != target) { + op_array->opcodes[target] = op_array->opcodes[i]; + ssa->ops[target] = ssa->ops[i]; + ssa->cfg.map[target] = b - blocks; + } + target++; + } + i++; } + if (target != end) { + zend_op *opline; + zend_op *new_opline; + + b->len = target - b->start; + opline = op_array->opcodes + end - 1; + if (opline->opcode == ZEND_NOP) { + continue; + } - new_opline = op_array->opcodes + target - 1; - zend_optimizer_migrate_jump(op_array, new_opline, opline); + new_opline = op_array->opcodes + target - 1; + zend_optimizer_migrate_jump(op_array, new_opline, opline); + } } } else { b->start = target;

« previous php.cvs (#99449) next »