Skip to content

Commit 4744dc8

Browse files
committed
Fix edge cases in JIT for ASSIGN_DIM_OP.
(This fixes Zend/tests/bug79947.phpt and Zend/tests/undef_index_to_exception.phpt without PROFITABILITY_CHECKS).
1 parent 88631e3 commit 4744dc8

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

ext/opcache/jit/zend_jit_arm64.dasc

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6104,7 +6104,6 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, uint3
61046104
| LOAD_ADDR CARG3, binary_op
61056105
| SET_EX_OPLINE opline, REG0
61066106
| EXT_CALL zend_jit_assign_op_to_typed_ref, REG0
6107-
zend_jit_check_exception(Dst);
61086107
| b >9
61096108
|.code
61106109
|1:
@@ -6171,18 +6170,34 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, uint3
61716170
| LOAD_ZVAL_ADDR CARG3, op3_addr
61726171
| LOAD_ADDR CARG4, binary_op
61736172
| EXT_CALL zend_jit_assign_dim_op_helper, REG0
6174-
if (!zend_jit_check_exception(Dst)) {
6175-
return 0;
6176-
}
61776173

61786174
if (op1_info & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_ARRAY)) {
61796175
| b >9 // END
61806176
|.code
61816177
}
61826178
}
61836179

6180+
if ((op1_info & (MAY_BE_ANY|MAY_BE_REF|MAY_BE_UNDEF)) == MAY_BE_ARRAY
6181+
&& (op2_info & ((MAY_BE_ANY|MAY_BE_REF|MAY_BE_UNDEF) - (MAY_BE_LONG|MAY_BE_STRING))) == 0
6182+
&& (op1_data_info & ((MAY_BE_ANY|MAY_BE_REF|MAY_BE_UNDEF) - (MAY_BE_LONG|MAY_BE_DOUBLE))) == 0) {
6183+
|.cold_code
6184+
}
6185+
61846186
|9:
6187+
| FREE_OP (opline+1)->op1_type, (opline+1)->op1, op1_data_info, 0, opline, ZREG_TMP1, ZREG_TMP2
61856188
| FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline, ZREG_TMP1, ZREG_TMP2
6189+
if (may_throw) {
6190+
zend_jit_check_exception(Dst);
6191+
}
6192+
6193+
if ((op1_info & (MAY_BE_ANY|MAY_BE_REF|MAY_BE_UNDEF)) == MAY_BE_ARRAY
6194+
&& (op2_info & ((MAY_BE_ANY|MAY_BE_REF|MAY_BE_UNDEF) - (MAY_BE_LONG|MAY_BE_STRING))) == 0
6195+
&& (op1_data_info & ((MAY_BE_ANY|MAY_BE_REF|MAY_BE_UNDEF) - (MAY_BE_LONG|MAY_BE_DOUBLE))) == 0) {
6196+
| b >9
6197+
| FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline, ZREG_TMP1, ZREG_TMP2
6198+
|.code
6199+
|9:
6200+
}
61866201

61876202
return 1;
61886203
}

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6558,7 +6558,6 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, uint3
65586558
|.if not(X64)
65596559
| add r4, 12
65606560
|.endif
6561-
zend_jit_check_exception(Dst);
65626561
| jmp >9
65636562
|.code
65646563
|1:
@@ -6634,18 +6633,34 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, uint3
66346633
|.if not(X64)
66356634
| add r4, 8
66366635
|.endif
6637-
if (!zend_jit_check_exception(Dst)) {
6638-
return 0;
6639-
}
66406636

66416637
if (op1_info & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_ARRAY)) {
66426638
| jmp >9 // END
66436639
|.code
66446640
}
66456641
}
66466642

6643+
if ((op1_info & (MAY_BE_ANY|MAY_BE_REF|MAY_BE_UNDEF)) == MAY_BE_ARRAY
6644+
&& (op2_info & ((MAY_BE_ANY|MAY_BE_REF|MAY_BE_UNDEF) - (MAY_BE_LONG|MAY_BE_STRING))) == 0
6645+
&& (op1_data_info & ((MAY_BE_ANY|MAY_BE_REF|MAY_BE_UNDEF) - (MAY_BE_LONG|MAY_BE_DOUBLE))) == 0) {
6646+
|.cold_code
6647+
}
6648+
66476649
|9:
6650+
| FREE_OP (opline+1)->op1_type, (opline+1)->op1, op1_data_info, 0, opline
66486651
| FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline
6652+
if (may_throw) {
6653+
zend_jit_check_exception(Dst);
6654+
}
6655+
6656+
if ((op1_info & (MAY_BE_ANY|MAY_BE_REF|MAY_BE_UNDEF)) == MAY_BE_ARRAY
6657+
&& (op2_info & ((MAY_BE_ANY|MAY_BE_REF|MAY_BE_UNDEF) - (MAY_BE_LONG|MAY_BE_STRING))) == 0
6658+
&& (op1_data_info & ((MAY_BE_ANY|MAY_BE_REF|MAY_BE_UNDEF) - (MAY_BE_LONG|MAY_BE_DOUBLE))) == 0) {
6659+
| jmp >9
6660+
| FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline
6661+
|.code
6662+
|9:
6663+
}
66496664

66506665
return 1;
66516666
}

0 commit comments

Comments
 (0)