Skip to content

Commit 3f50922

Browse files
committed
Fixed incorrect JIT compilation
1 parent 4273865 commit 3f50922

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3505,7 +3505,8 @@ static int zend_jit_math(dasm_State **Dst, const zend_op *opline, int *opnum, ze
35053505
if (opline->result_type == IS_TMP_VAR &&
35063506
(opline+1)->opcode == ZEND_SEND_VAL &&
35073507
(opline+1)->op1_type == IS_TMP_VAR &&
3508-
(opline+1)->op1.var == opline->result.var) {
3508+
(opline+1)->op1.var == opline->result.var &&
3509+
ssa->cfg.map[(opline+1) - op_array->opcodes] == ssa->cfg.map[opline - op_array->opcodes]) {
35093510
/* Eliminate the following SEND_VAL */
35103511
(*opnum)++;
35113512
if (!reuse_ip) {
@@ -3839,7 +3840,8 @@ static int zend_jit_long_math(dasm_State **Dst, const zend_op *opline, int *opnu
38393840
if (opline->result_type == IS_TMP_VAR &&
38403841
(opline+1)->opcode == ZEND_SEND_VAL &&
38413842
(opline+1)->op1_type == IS_TMP_VAR &&
3842-
(opline+1)->op1.var == opline->result.var) {
3843+
(opline+1)->op1.var == opline->result.var &&
3844+
ssa->cfg.map[(opline+1) - op_array->opcodes] == ssa->cfg.map[opline - op_array->opcodes]) {
38433845
/* Eliminate the following SEND_VAL */
38443846
(*opnum)++;
38453847
if (!reuse_ip) {
@@ -3980,7 +3982,8 @@ static int zend_jit_concat(dasm_State **Dst, const zend_op *opline, int *opnum,
39803982
if (opline->result_type == IS_TMP_VAR &&
39813983
(opline+1)->opcode == ZEND_SEND_VAL &&
39823984
(opline+1)->op1_type == IS_TMP_VAR &&
3983-
(opline+1)->op1.var == opline->result.var) {
3985+
(opline+1)->op1.var == opline->result.var &&
3986+
ssa->cfg.map[(opline+1) - op_array->opcodes] == ssa->cfg.map[opline - op_array->opcodes]) {
39843987
/* Eliminate the following SEND_VAL */
39853988
(*opnum)++;
39863989
if (!reuse_ip) {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
JIT SEND_VAL: 001
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
--SKIPIF--
9+
<?php require_once('skipif.inc'); ?>
10+
--FILE--
11+
<?php
12+
function foo($type) {
13+
$key = md5(
14+
is_array($type) ? \implode('_', $type) : $type .
15+
"ops"
16+
);
17+
return $key;
18+
}
19+
var_dump(foo("int"));
20+
var_dump(foo(["int"]));
21+
--EXPECT--
22+
string(32) "253a948ecc9192cb47e492f692aa63a8"
23+
string(32) "fa7153f7ed1cb6c0fcf2ffb2fac21748"

0 commit comments

Comments
 (0)