Skip to content

Commit e0af92c

Browse files
committed
Eliminate useless exception checks
1 parent a167e04 commit e0af92c

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

ext/opcache/Optimizer/zend_inference.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4312,7 +4312,8 @@ int zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, const ze
43124312
}
43134313
}
43144314
} else if (opline->op1_type & (IS_TMP_VAR|IS_VAR)) {
4315-
if (t1 & (MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_ARRAY_OF_RESOURCE|MAY_BE_ARRAY_OF_ARRAY)) {
4315+
if ((t1 & MAY_BE_RC1)
4316+
&& (t1 & (MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_ARRAY_OF_RESOURCE|MAY_BE_ARRAY_OF_ARRAY))) {
43164317
switch (opline->opcode) {
43174318
case ZEND_CASE:
43184319
case ZEND_CASE_STRICT:
@@ -4350,7 +4351,8 @@ int zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, const ze
43504351
}
43514352
}
43524353
} else if (opline->op2_type & (IS_TMP_VAR|IS_VAR)) {
4353-
if (t2 & (MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_ARRAY_OF_RESOURCE|MAY_BE_ARRAY_OF_ARRAY)) {
4354+
if ((t2 & MAY_BE_RC1)
4355+
&& (t2 & (MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_ARRAY_OF_RESOURCE|MAY_BE_ARRAY_OF_ARRAY))) {
43544356
switch (opline->opcode) {
43554357
case ZEND_ASSIGN:
43564358
break;

ext/opcache/jit/zend_jit_trace.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3765,9 +3765,11 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
37653765
((op1_info & MAY_BE_UNDEF) != 0 &&
37663766
opline->opcode == ZEND_FETCH_DIM_R) ||
37673767
((opline->op1_type & (IS_TMP_VAR|IS_VAR)) != 0 &&
3768+
(op1_info & MAY_BE_RC1) &&
37683769
(op1_info & (MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_ARRAY_OF_RESOURCE|MAY_BE_ARRAY_OF_ARRAY)) != 0) ||
37693770
(op2_info & MAY_BE_UNDEF) != 0 ||
37703771
((opline->op2_type & (IS_TMP_VAR|IS_VAR)) != 0 &&
3772+
(op2_info & MAY_BE_RC1) &&
37713773
(op2_info & (MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_ARRAY_OF_RESOURCE|MAY_BE_ARRAY_OF_ARRAY)) != 0)))) {
37723774
goto jit_failure;
37733775
}

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10595,7 +10595,7 @@ static int zend_jit_isset_isempty_dim(dasm_State **Dst, const zend_op *opline, c
1059510595
if (exit_addr
1059610596
&& !(op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-MAY_BE_ARRAY))
1059710597
&& !may_throw
10598-
&& !(opline->op1_type & (IS_TMP_VAR|IS_VAR))
10598+
&& (!(opline->op1_type & (IS_TMP_VAR|IS_VAR)) || (op1_info & AVOID_REFCOUNTING))
1059910599
&& (!(opline->op2_type & (IS_TMP_VAR|IS_VAR)) || !(op2_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-MAY_BE_LONG)))) {
1060010600
if (smart_branch_opcode == ZEND_JMPNZ) {
1060110601
found_exit_addr = exit_addr;

0 commit comments

Comments
 (0)