@@ -7761,26 +7761,24 @@ fallback:
7761
7761
return zend_jit_handler(Dst, opline, zend_may_throw(opline, op_array, ssa));
7762
7762
}
7763
7763
7764
- static int zend_jit_smart_true(dasm_State **Dst, const zend_op *opline, int b, const zend_op_array *op_array, zend_ssa *ssa, int jmp)
7764
+ static int zend_jit_smart_true(dasm_State **Dst, const zend_op *opline, int b, const zend_op_array *op_array, zend_ssa *ssa, int jmp, zend_bool smart_branch )
7765
7765
{
7766
7766
uint32_t target_label;
7767
7767
7768
- if ((opline+1)->opcode == ZEND_JMPZ &&
7769
- (opline+1)->op1_type == IS_TMP_VAR &&
7770
- (opline+1)->op1.var == opline->result.var) {
7771
- if (jmp) {
7772
- | jmp >7
7768
+ if (smart_branch) {
7769
+ if ((opline+1)->opcode == ZEND_JMPZ) {
7770
+ if (jmp) {
7771
+ | jmp >7
7772
+ }
7773
+ } else if ((opline+1)->opcode == ZEND_JMPNZ) {
7774
+ target_label = ssa->cfg.blocks[b].successors[0];
7775
+ | jmp =>target_label
7776
+ } else if ((opline+1)->opcode == ZEND_JMPZNZ) {
7777
+ target_label = ssa->cfg.blocks[b].successors[1];
7778
+ | jmp =>target_label
7779
+ } else {
7780
+ ZEND_ASSERT(0);
7773
7781
}
7774
- } else if ((opline+1)->opcode == ZEND_JMPNZ &&
7775
- (opline+1)->op1_type == IS_TMP_VAR &&
7776
- (opline+1)->op1.var == opline->result.var) {
7777
- target_label = ssa->cfg.blocks[b].successors[0];
7778
- | jmp =>target_label
7779
- } else if ((opline+1)->opcode == ZEND_JMPZNZ &&
7780
- (opline+1)->op1_type == IS_TMP_VAR &&
7781
- (opline+1)->op1.var == opline->result.var) {
7782
- target_label = ssa->cfg.blocks[b].successors[1];
7783
- | jmp =>target_label
7784
7782
} else {
7785
7783
zend_jit_addr res_addr = zend_jit_decode_op(op_array, opline->result_type, opline->result, opline, NULL, -1);
7786
7784
@@ -7793,26 +7791,24 @@ static int zend_jit_smart_true(dasm_State **Dst, const zend_op *opline, int b, c
7793
7791
return 1;
7794
7792
}
7795
7793
7796
- static int zend_jit_smart_false(dasm_State **Dst, const zend_op *opline, int b, const zend_op_array *op_array, zend_ssa *ssa, int jmp)
7794
+ static int zend_jit_smart_false(dasm_State **Dst, const zend_op *opline, int b, const zend_op_array *op_array, zend_ssa *ssa, int jmp, zend_bool smart_branch )
7797
7795
{
7798
7796
uint32_t target_label;
7799
7797
7800
- if ((opline+1)->opcode == ZEND_JMPZ &&
7801
- (opline+1)->op1_type == IS_TMP_VAR &&
7802
- (opline+1)->op1.var == opline->result.var) {
7803
- target_label = ssa->cfg.blocks[b].successors[0];
7804
- | jmp =>target_label
7805
- } else if ((opline+1)->opcode == ZEND_JMPNZ &&
7806
- (opline+1)->op1_type == IS_TMP_VAR &&
7807
- (opline+1)->op1.var == opline->result.var) {
7808
- if (jmp) {
7809
- | jmp >7
7798
+ if (smart_branch) {
7799
+ if ((opline+1)->opcode == ZEND_JMPZ) {
7800
+ target_label = ssa->cfg.blocks[b].successors[0];
7801
+ | jmp =>target_label
7802
+ } else if ((opline+1)->opcode == ZEND_JMPNZ) {
7803
+ if (jmp) {
7804
+ | jmp >7
7805
+ }
7806
+ } else if ((opline+1)->opcode == ZEND_JMPZNZ) {
7807
+ target_label = ssa->cfg.blocks[b].successors[0];
7808
+ | jmp =>target_label
7809
+ } else {
7810
+ ZEND_ASSERT(0);
7810
7811
}
7811
- } else if ((opline+1)->opcode == ZEND_JMPZNZ &&
7812
- (opline+1)->op1_type == IS_TMP_VAR &&
7813
- (opline+1)->op1.var == opline->result.var) {
7814
- target_label = ssa->cfg.blocks[b].successors[0];
7815
- | jmp =>target_label
7816
7812
} else {
7817
7813
zend_jit_addr res_addr = zend_jit_decode_op(op_array, opline->result_type, opline->result, opline, NULL, -1);
7818
7814
@@ -7948,11 +7944,11 @@ static int zend_jit_type_check(dasm_State **Dst, const zend_op *opline, int b, i
7948
7944
| mov FCARG1d, opline->op1.var
7949
7945
| EXT_CALL zend_jit_undefined_op_helper, r0
7950
7946
if (opline->extended_value & MAY_BE_NULL) {
7951
- if (!zend_jit_smart_true(Dst, opline, b, op_array, ssa, (op1_info & (MAY_BE_ANY|MAY_BE_REF)) != 0)) {
7947
+ if (!zend_jit_smart_true(Dst, opline, b, op_array, ssa, (op1_info & (MAY_BE_ANY|MAY_BE_REF)) != 0, smart_branch )) {
7952
7948
return 0;
7953
7949
}
7954
7950
} else {
7955
- if (!zend_jit_smart_false(Dst, opline, b, op_array, ssa, (op1_info & (MAY_BE_ANY|MAY_BE_REF)) != 0)) {
7951
+ if (!zend_jit_smart_false(Dst, opline, b, op_array, ssa, (op1_info & (MAY_BE_ANY|MAY_BE_REF)) != 0, smart_branch )) {
7956
7952
return 0;
7957
7953
}
7958
7954
}
@@ -7978,12 +7974,12 @@ static int zend_jit_type_check(dasm_State **Dst, const zend_op *opline, int b, i
7978
7974
7979
7975
if (!(op1_info & (MAY_BE_ANY - mask))) {
7980
7976
| FREE_OP opline->op1_type, opline->op1, op1_info, 1, op_array, opline
7981
- if (!zend_jit_smart_true(Dst, opline, b, op_array, ssa, 0)) {
7977
+ if (!zend_jit_smart_true(Dst, opline, b, op_array, ssa, 0, smart_branch )) {
7982
7978
return 0;
7983
7979
}
7984
7980
} else if (!(op1_info & mask)) {
7985
7981
| FREE_OP opline->op1_type, opline->op1, op1_info, 1, op_array, opline
7986
- if (!zend_jit_smart_false(Dst, opline, b, op_array, ssa, 0)) {
7982
+ if (!zend_jit_smart_false(Dst, opline, b, op_array, ssa, 0, smart_branch )) {
7987
7983
return 0;
7988
7984
}
7989
7985
} else {
@@ -8042,23 +8038,21 @@ static int zend_jit_type_check(dasm_State **Dst, const zend_op *opline, int b, i
8042
8038
| mov eax, 1
8043
8039
| shl eax, cl
8044
8040
| test eax, mask
8045
- if ((opline+1)->opcode == ZEND_JMPZ &&
8046
- (opline+1)->op1_type == IS_TMP_VAR &&
8047
- (opline+1)->op1.var == opline->result.var) {
8048
- target_label = ssa->cfg.blocks[b].successors[0];
8049
- | je =>target_label
8050
- } else if ((opline+1)->opcode == ZEND_JMPNZ &&
8051
- (opline+1)->op1_type == IS_TMP_VAR &&
8052
- (opline+1)->op1.var == opline->result.var) {
8053
- target_label = ssa->cfg.blocks[b].successors[0];
8054
- | jne =>target_label
8055
- } else if ((opline+1)->opcode == ZEND_JMPZNZ &&
8056
- (opline+1)->op1_type == IS_TMP_VAR &&
8057
- (opline+1)->op1.var == opline->result.var) {
8058
- target_label = ssa->cfg.blocks[b].successors[0];
8059
- | je =>target_label
8060
- target_label = ssa->cfg.blocks[b].successors[1];
8061
- | jmp =>target_label
8041
+ if (smart_branch) {
8042
+ if ((opline+1)->opcode == ZEND_JMPZ) {
8043
+ target_label = ssa->cfg.blocks[b].successors[0];
8044
+ | je =>target_label
8045
+ } else if ((opline+1)->opcode == ZEND_JMPNZ) {
8046
+ target_label = ssa->cfg.blocks[b].successors[0];
8047
+ | jne =>target_label
8048
+ } else if ((opline+1)->opcode == ZEND_JMPZNZ) {
8049
+ target_label = ssa->cfg.blocks[b].successors[0];
8050
+ | je =>target_label
8051
+ target_label = ssa->cfg.blocks[b].successors[1];
8052
+ | jmp =>target_label
8053
+ } else {
8054
+ ZEND_ASSERT(0);
8055
+ }
8062
8056
} else {
8063
8057
zend_jit_addr res_addr = zend_jit_decode_op(op_array, opline->result_type, opline->result, opline, NULL, -1);
8064
8058
@@ -8117,23 +8111,21 @@ static int zend_jit_type_check(dasm_State **Dst, const zend_op *opline, int b, i
8117
8111
| cmp byte [FP + opline->op1.var + 8], type
8118
8112
}
8119
8113
}
8120
- if ((opline+1)->opcode == ZEND_JMPZ &&
8121
- (opline+1)->op1_type == IS_TMP_VAR &&
8122
- (opline+1)->op1.var == opline->result.var) {
8123
- target_label = ssa->cfg.blocks[b].successors[0];
8124
- | jne =>target_label
8125
- } else if ((opline+1)->opcode == ZEND_JMPNZ &&
8126
- (opline+1)->op1_type == IS_TMP_VAR &&
8127
- (opline+1)->op1.var == opline->result.var) {
8128
- target_label = ssa->cfg.blocks[b].successors[0];
8129
- | je =>target_label
8130
- } else if ((opline+1)->opcode == ZEND_JMPZNZ &&
8131
- (opline+1)->op1_type == IS_TMP_VAR &&
8132
- (opline+1)->op1.var == opline->result.var) {
8133
- target_label = ssa->cfg.blocks[b].successors[0];
8134
- | jne =>target_label
8135
- target_label = ssa->cfg.blocks[b].successors[1];
8136
- | jmp =>target_label
8114
+ if (smart_branch) {
8115
+ if ((opline+1)->opcode == ZEND_JMPZ) {
8116
+ target_label = ssa->cfg.blocks[b].successors[0];
8117
+ | jne =>target_label
8118
+ } else if ((opline+1)->opcode == ZEND_JMPNZ) {
8119
+ target_label = ssa->cfg.blocks[b].successors[0];
8120
+ | je =>target_label
8121
+ } else if ((opline+1)->opcode == ZEND_JMPZNZ) {
8122
+ target_label = ssa->cfg.blocks[b].successors[0];
8123
+ | jne =>target_label
8124
+ target_label = ssa->cfg.blocks[b].successors[1];
8125
+ | jmp =>target_label
8126
+ } else {
8127
+ ZEND_ASSERT(0);
8128
+ }
8137
8129
} else {
8138
8130
zend_jit_addr res_addr = zend_jit_decode_op(op_array, opline->result_type, opline->result, opline, NULL, -1);
8139
8131
0 commit comments