Skip to content

Commit 4e7cac8

Browse files
committed
Move exception check to cold path.
1 parent 037bfab commit 4e7cac8

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5291,7 +5291,8 @@ static int zend_jit_assign_to_variable(dasm_State **Dst,
52915291
znode_op val,
52925292
zend_jit_addr val_addr,
52935293
uint32_t val_info,
5294-
zend_jit_addr res_addr)
5294+
zend_jit_addr res_addr,
5295+
zend_bool check_exception)
52955296
/* Labels: 1,2,3,4,5,8 */
52965297
{
52975298
int done = 0;
@@ -5361,14 +5362,24 @@ static int zend_jit_assign_to_variable(dasm_State **Dst,
53615362
| jnz >8
53625363
}
53635364
| ZVAL_DTOR_FUNC var_info, opline
5365+
if (in_cold || (RC_MAY_BE_N(var_info) && (var_info & (MAY_BE_ARRAY|MAY_BE_OBJECT)) != 0)) {
5366+
if (check_exception) {
5367+
| MEM_OP2_1_ZTS cmp, aword, executor_globals, exception, 0, r0
5368+
| je >8
5369+
| jmp ->exception_handler
5370+
} else {
5371+
| jmp >8
5372+
}
5373+
}
53645374
if (RC_MAY_BE_N(var_info) && (var_info & (MAY_BE_ARRAY|MAY_BE_OBJECT)) != 0) {
5365-
| jmp >8
53665375
|4:
53675376
| IF_GC_MAY_NOT_LEAK FCARG1a, >8
53685377
| EXT_CALL gc_possible_root, r0
5378+
if (in_cold) {
5379+
| jmp >8
5380+
}
53695381
}
53705382
if (in_cold) {
5371-
| jmp >8
53725383
|.code
53735384
} else {
53745385
done = 1;
@@ -5508,7 +5519,7 @@ static int zend_jit_assign_dim(dasm_State **Dst, const zend_op *opline, const ze
55085519
var_info |= MAY_BE_REF;
55095520
}
55105521
| // value = zend_assign_to_variable(variable_ptr, value, OP_DATA_TYPE);
5511-
if (!zend_jit_assign_to_variable(Dst, opline, op_array, var_addr, var_info, -1, (opline+1)->op1_type, (opline+1)->op1, op3_addr, val_info, res_addr)) {
5522+
if (!zend_jit_assign_to_variable(Dst, opline, op_array, var_addr, var_info, -1, (opline+1)->op1_type, (opline+1)->op1, op3_addr, val_info, res_addr, 0)) {
55125523
return 0;
55135524
}
55145525
}
@@ -7752,7 +7763,8 @@ static int zend_jit_assign(dasm_State **Dst, const zend_op *opline, const zend_o
77527763
}
77537764
}
77547765

7755-
if (!zend_jit_assign_to_variable(Dst, opline, op_array, op1_addr, op1_info, op1_def_info, opline->op2_type, opline->op2, op2_addr, op2_info, res_addr)) {
7766+
if (!zend_jit_assign_to_variable(Dst, opline, op_array, op1_addr, op1_info, op1_def_info, opline->op2_type, opline->op2, op2_addr, op2_info, res_addr,
7767+
may_throw && !(op1_info & MAY_BE_REF) && (op1_info & (MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_ARRAY_OF_RESOURCE|MAY_BE_ARRAY_OF_ARRAY)))) {
77567768
return 0;
77577769
}
77587770
if (!zend_jit_store_var_if_necessary_ex(Dst, opline->op1.var, op1_addr, op1_def_info, op1_use_addr, op1_info)) {
@@ -7764,7 +7776,7 @@ static int zend_jit_assign(dasm_State **Dst, const zend_op *opline, const zend_o
77647776
}
77657777
}
77667778

7767-
if (may_throw) {
7779+
if (may_throw && (op1_info & MAY_BE_REF)) {
77687780
zend_jit_check_exception(Dst);
77697781
}
77707782

0 commit comments

Comments
 (0)