@@ -10908,7 +10908,6 @@ static int zend_jit_defined(dasm_State **Dst, const zend_op *opline, zend_uchar
10908
10908
static int zend_jit_type_check(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_uchar smart_branch_opcode, uint32_t target_label, uint32_t target_label2, const void *exit_addr)
10909
10909
{
10910
10910
uint32_t mask;
10911
- zend_uchar type;
10912
10911
zend_jit_addr op1_addr = OP1_ADDR();
10913
10912
10914
10913
// TODO: support for is_resource() ???
@@ -10952,19 +10951,6 @@ static int zend_jit_type_check(dasm_State **Dst, const zend_op *opline, uint32_t
10952
10951
10953
10952
if (op1_info & (MAY_BE_ANY|MAY_BE_REF)) {
10954
10953
mask = opline->extended_value;
10955
- switch (mask) {
10956
- case MAY_BE_NULL: type = IS_NULL; break;
10957
- case MAY_BE_FALSE: type = IS_FALSE; break;
10958
- case MAY_BE_TRUE: type = IS_TRUE; break;
10959
- case MAY_BE_LONG: type = IS_LONG; break;
10960
- case MAY_BE_DOUBLE: type = IS_DOUBLE; break;
10961
- case MAY_BE_STRING: type = IS_STRING; break;
10962
- case MAY_BE_ARRAY: type = IS_ARRAY; break;
10963
- case MAY_BE_OBJECT: type = IS_OBJECT; break;
10964
- default:
10965
- type = 0;
10966
- }
10967
-
10968
10954
if (!(op1_info & MAY_BE_GUARD) && !(op1_info & (MAY_BE_ANY - mask))) {
10969
10955
| FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline
10970
10956
if (exit_addr) {
@@ -10984,6 +10970,31 @@ static int zend_jit_type_check(dasm_State **Dst, const zend_op *opline, uint32_t
10984
10970
return 0;
10985
10971
}
10986
10972
} else {
10973
+ bool invert = 0;
10974
+ zend_uchar type;
10975
+
10976
+ switch (mask) {
10977
+ case MAY_BE_NULL: type = IS_NULL; break;
10978
+ case MAY_BE_FALSE: type = IS_FALSE; break;
10979
+ case MAY_BE_TRUE: type = IS_TRUE; break;
10980
+ case MAY_BE_LONG: type = IS_LONG; break;
10981
+ case MAY_BE_DOUBLE: type = IS_DOUBLE; break;
10982
+ case MAY_BE_STRING: type = IS_STRING; break;
10983
+ case MAY_BE_ARRAY: type = IS_ARRAY; break;
10984
+ case MAY_BE_OBJECT: type = IS_OBJECT; break;
10985
+ case MAY_BE_ANY - MAY_BE_NULL: type = IS_NULL; invert = 1; break;
10986
+ case MAY_BE_ANY - MAY_BE_FALSE: type = IS_FALSE; invert = 1; break;
10987
+ case MAY_BE_ANY - MAY_BE_TRUE: type = IS_TRUE; invert = 1; break;
10988
+ case MAY_BE_ANY - MAY_BE_LONG: type = IS_LONG; invert = 1; break;
10989
+ case MAY_BE_ANY - MAY_BE_DOUBLE: type = IS_DOUBLE; invert = 1; break;
10990
+ case MAY_BE_ANY - MAY_BE_STRING: type = IS_STRING; invert = 1; break;
10991
+ case MAY_BE_ANY - MAY_BE_ARRAY: type = IS_ARRAY; invert = 1; break;
10992
+ case MAY_BE_ANY - MAY_BE_OBJECT: type = IS_OBJECT; invert = 1; break;
10993
+ case MAY_BE_ANY - MAY_BE_RESOURCE: type = IS_OBJECT; invert = 1; break;
10994
+ default:
10995
+ type = 0;
10996
+ }
10997
+
10987
10998
if (op1_info & MAY_BE_REF) {
10988
10999
| LOAD_ZVAL_ADDR r0, op1_addr
10989
11000
| ZVAL_DEREF r0, op1_info
@@ -11115,26 +11126,51 @@ static int zend_jit_type_check(dasm_State **Dst, const zend_op *opline, uint32_t
11115
11126
}
11116
11127
}
11117
11128
if (exit_addr) {
11118
- if (smart_branch_opcode == ZEND_JMPNZ) {
11119
- | je &exit_addr
11129
+ if (invert) {
11130
+ if (smart_branch_opcode == ZEND_JMPNZ) {
11131
+ | jne &exit_addr
11132
+ } else {
11133
+ | je &exit_addr
11134
+ }
11120
11135
} else {
11121
- | jne &exit_addr
11136
+ if (smart_branch_opcode == ZEND_JMPNZ) {
11137
+ | je &exit_addr
11138
+ } else {
11139
+ | jne &exit_addr
11140
+ }
11122
11141
}
11123
11142
} else if (smart_branch_opcode) {
11124
- if (smart_branch_opcode == ZEND_JMPZ) {
11125
- | jne =>target_label
11126
- } else if (smart_branch_opcode == ZEND_JMPNZ) {
11127
- | je =>target_label
11128
- } else if (smart_branch_opcode == ZEND_JMPZNZ) {
11129
- | jne =>target_label
11130
- | jmp =>target_label2
11143
+ if (invert) {
11144
+ if (smart_branch_opcode == ZEND_JMPZ) {
11145
+ | je =>target_label
11146
+ } else if (smart_branch_opcode == ZEND_JMPNZ) {
11147
+ | jne =>target_label
11148
+ } else if (smart_branch_opcode == ZEND_JMPZNZ) {
11149
+ | je =>target_label
11150
+ | jmp =>target_label2
11151
+ } else {
11152
+ ZEND_UNREACHABLE();
11153
+ }
11131
11154
} else {
11132
- ZEND_UNREACHABLE();
11155
+ if (smart_branch_opcode == ZEND_JMPZ) {
11156
+ | jne =>target_label
11157
+ } else if (smart_branch_opcode == ZEND_JMPNZ) {
11158
+ | je =>target_label
11159
+ } else if (smart_branch_opcode == ZEND_JMPZNZ) {
11160
+ | jne =>target_label
11161
+ | jmp =>target_label2
11162
+ } else {
11163
+ ZEND_UNREACHABLE();
11164
+ }
11133
11165
}
11134
11166
} else {
11135
11167
zend_jit_addr res_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->result.var);
11136
11168
11137
- | sete al
11169
+ if (invert) {
11170
+ | setne al
11171
+ } else {
11172
+ | sete al
11173
+ }
11138
11174
| movzx eax, al
11139
11175
| add eax, 2
11140
11176
| SET_ZVAL_TYPE_INFO res_addr, eax
0 commit comments