]> granicus.if.org Git - php/commitdiff
Fix JMPZ, JMPZNZ_EX chain optimization
authorNikita Popov <nikic@php.net>
Wed, 4 May 2016 21:52:42 +0000 (23:52 +0200)
committerNikita Popov <nikic@php.net>
Wed, 4 May 2016 22:00:56 +0000 (00:00 +0200)
The result_type was not copied, resulting in a corrupted JMPZ_EX.
Fix can be verified by inspecting the opcodes of the following
function (it should not contain any _EX opcodes):

function test() {
    if ($a && $b) {
        echo "a";
    }

    if ($b || $c || $d) {
        echo "b";
    }
}

Conflicts:
ext/opcache/Optimizer/block_pass.c

ext/opcache/Optimizer/block_pass.c

index e168457661b8a2c5edf71505443d3eebd48a9006..5e9b20d191e49f13c2cc4ed1abb5e6069b01d77f 100644 (file)
@@ -1471,9 +1471,9 @@ next_target:
                                                same_var == VAR_NUM_EX(target->op1) &&
                                                        target_block->follow_to &&
                                                        !target_block->protected) {
-                                       /* JMPZ(X, L), L: X = JMPNZ_EX(X, L2) -> JMPZ(X, L+1) */
+                                       /* JMPZ(X, L), L: T = JMPNZ_EX(X, L2) -> T = JMPZ_EX(X, L+1) */
                                        last_op->opcode += 3;
-                                       last_op->result = target->result;
+                                       COPY_NODE(last_op->result, target->result);
                                        del_source(block, block->op2_to);
                                        block->op2_to = target_block->follow_to;
                                        ADD_SOURCE(block, block->op2_to);