mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Fix relative offsets when copying JMPZNZ
This commit is contained in:
commit
0015fc9a8e
2 changed files with 20 additions and 0 deletions
|
@ -94,6 +94,10 @@ void zend_optimizer_pass3(zend_op_array *op_array, zend_optimizer_ctx *ctx)
|
||||||
ZVAL_COPY(&zv, &ZEND_OP1_LITERAL(opline));
|
ZVAL_COPY(&zv, &ZEND_OP1_LITERAL(opline));
|
||||||
opline->op1.constant = zend_optimizer_add_literal(op_array, &zv);
|
opline->op1.constant = zend_optimizer_add_literal(op_array, &zv);
|
||||||
}
|
}
|
||||||
|
/* Jump addresses may be encoded as offsets, recompute them. */
|
||||||
|
ZEND_SET_OP_JMP_ADDR(opline, opline->op2, ZEND_OP2_JMP_ADDR(target));
|
||||||
|
opline->extended_value = ZEND_OPLINE_TO_OFFSET(opline,
|
||||||
|
ZEND_OFFSET_TO_OPLINE(target, target->extended_value));
|
||||||
goto optimize_jmpznz;
|
goto optimize_jmpznz;
|
||||||
} else if ((target->opcode == ZEND_RETURN ||
|
} else if ((target->opcode == ZEND_RETURN ||
|
||||||
target->opcode == ZEND_RETURN_BY_REF ||
|
target->opcode == ZEND_RETURN_BY_REF ||
|
||||||
|
|
16
Zend/tests/jmpznz_relative_offsets.phpt
Normal file
16
Zend/tests/jmpznz_relative_offsets.phpt
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
--TEST--
|
||||||
|
Check for correct treatment of relative JMPZNZ offsets when copying opline
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
function test($c) {
|
||||||
|
L1:
|
||||||
|
if ($c) {
|
||||||
|
goto L1;
|
||||||
|
goto L1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
test(false);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
===DONE===
|
Loading…
Add table
Add a link
Reference in a new issue