Skip to content

Commit 9d52081

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: JIT: Fix missing type stote
2 parents 229b189 + e70d282 commit 9d52081

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4241,6 +4241,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
42414241
bool op1_indirect;
42424242
zend_class_entry *op1_ce = NULL;
42434243
zend_class_entry *op2_ce = NULL;
4244+
bool gen_handler;
42444245

42454246
opline = p->opline;
42464247
if (op1_type & (IS_TRACE_REFERENCE|IS_TRACE_INDIRECT)) {
@@ -4284,6 +4285,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
42844285
}
42854286

42864287
if (JIT_G(opt_level) >= ZEND_JIT_LEVEL_INLINE) {
4288+
gen_handler = 0;
42874289
switch (opline->opcode) {
42884290
case ZEND_PRE_INC:
42894291
case ZEND_PRE_DEC:
@@ -6145,6 +6147,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
61456147
}
61466148

61476149
if (opline->opcode != ZEND_NOP && opline->opcode != ZEND_JMP) {
6150+
gen_handler = 1;
61486151
op1_info = OP1_INFO();
61496152
op2_info = OP2_INFO();
61506153
if (op1_info & MAY_BE_GUARD) {
@@ -6233,7 +6236,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
62336236
}
62346237
} else {
62356238
SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->result.var), type,
6236-
(type == IS_UNKNOWN || !ra || !ra[ssa_op->result_def]));
6239+
(gen_handler || type == IS_UNKNOWN || !ra || !ra[ssa_op->result_def]));
62376240
if (ssa->var_info[ssa_op->result_def].type & MAY_BE_INDIRECT) {
62386241
RESET_STACK_MEM_TYPE(stack, EX_VAR_TO_NUM(opline->result.var));
62396242
}
@@ -6288,7 +6291,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
62886291
type = STACK_TYPE(stack, EX_VAR_TO_NUM(opline->op1.var));
62896292
}
62906293
SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->op1.var), type,
6291-
(type == IS_UNKNOWN || !ra ||
6294+
(gen_handler || type == IS_UNKNOWN || !ra ||
62926295
(!ra[ssa_op->op1_def] &&
62936296
(opline->opcode == ZEND_ASSIGN || !ssa->vars[ssa_op->op1_def].no_val))));
62946297
if (type != IS_UNKNOWN) {
@@ -6335,7 +6338,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
63356338
type = STACK_TYPE(stack, EX_VAR_TO_NUM(opline->op2.var));
63366339
}
63376340
SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->op2.var), type,
6338-
(type == IS_UNKNOWN || !ra ||
6341+
(gen_handler || type == IS_UNKNOWN || !ra ||
63396342
(!ra[ssa_op->op2_def] && !ssa->vars[ssa_op->op2_def].no_val)));
63406343
if (type != IS_UNKNOWN) {
63416344
ssa->var_info[ssa_op->op2_def].type &= ~MAY_BE_GUARD;
@@ -6388,7 +6391,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
63886391
type = STACK_TYPE(stack, EX_VAR_TO_NUM(opline->op1.var));
63896392
}
63906393
SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->op1.var), type,
6391-
(type == IS_UNKNOWN || !ra || !ra[ssa_op->op1_def]));
6394+
(gen_handler || type == IS_UNKNOWN || !ra || !ra[ssa_op->op1_def]));
63926395
if (type != IS_UNKNOWN) {
63936396
ssa->var_info[ssa_op->op1_def].type &= ~MAY_BE_GUARD;
63946397
if (ra && ra[ssa_op->op1_def]) {
@@ -6419,7 +6422,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
64196422
type = concrete_type(ssa->var_info[ssa_op->result_def].type);
64206423
}
64216424
SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->result.var), type,
6422-
(!ra || !ra[ssa_op->result_def]));
6425+
(gen_handler || !ra || !ra[ssa_op->result_def]));
64236426
if (ra && ra[ssa_op->result_def]) {
64246427
SET_STACK_REG_EX(stack, EX_VAR_TO_NUM(opline->result.var), ra[ssa_op->result_def]->reg,
64256428
ra[ssa_op->result_def]->flags & ZREG_STORE);
@@ -6441,7 +6444,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
64416444
type = concrete_type(ssa->var_info[ssa_op->op1_def].type);
64426445
}
64436446
SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->op1.var), type,
6444-
(!ra || !ra[ssa_op->op1_def]));
6447+
(gen_handler || !ra || !ra[ssa_op->op1_def]));
64456448
if (ra && ra[ssa_op->op1_def]) {
64466449
SET_STACK_REG_EX(stack, EX_VAR_TO_NUM(opline->op1.var), ra[ssa_op->op1_def]->reg,
64476450
ra[ssa_op->op1_def]->flags & ZREG_STORE);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
Register Alloction 016: Missing type store
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
--FILE--
9+
<?php
10+
function foo() {
11+
for($cnt = 0; $cnt < 6; $cnt++) {
12+
var_dump($x);
13+
$a - 536 >> 4 - $y - 4 << ++$x == $a ?: $b;
14+
$a .= !$a;
15+
$x = $a ? $b : $b;
16+
}
17+
}
18+
@foo();
19+
?>
20+
DONE
21+
--EXPECTF--
22+
NULL
23+
NULL
24+
NULL
25+
NULL
26+
NULL
27+
NULL
28+
DONE

0 commit comments

Comments
 (0)