Skip to content

Commit 22fc522

Browse files
committed
Improve JIT for IS_IDENTICAL
1 parent 2f3538c commit 22fc522

File tree

1 file changed

+36
-18
lines changed

1 file changed

+36
-18
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7942,7 +7942,7 @@ static int zend_jit_identical(dasm_State **Dst,
79427942
if (opline->op1_type != IS_CONST) {
79437943
| LOAD_ZVAL_ADDR FCARG1a, op1_addr
79447944
}
7945-
} else {
7945+
} else if ((op1_info & op2_info & MAY_BE_ANY) != 0) {
79467946
if (opline->op1_type != IS_CONST) {
79477947
if (Z_MODE(op1_addr) == IS_REG) {
79487948
zend_jit_addr real_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->op1.var);
@@ -7964,12 +7964,6 @@ static int zend_jit_identical(dasm_State **Dst,
79647964
| LOAD_ZVAL_ADDR FCARG2a, op2_addr
79657965
}
79667966
}
7967-
if (opline->op1_type & (IS_CV|IS_VAR)) {
7968-
| ZVAL_DEREF FCARG1a, op1_info
7969-
}
7970-
if (opline->op2_type & (IS_CV|IS_VAR)) {
7971-
| ZVAL_DEREF FCARG2a, op2_info
7972-
}
79737967

79747968
if ((op1_info & op2_info & MAY_BE_ANY) == 0) {
79757969
if ((opline->opcode != ZEND_CASE_STRICT &&
@@ -7984,7 +7978,9 @@ static int zend_jit_identical(dasm_State **Dst,
79847978
| FREE_OP opline->op2_type, opline->op2, op2_info, 1, opline
79857979
}
79867980
if (smart_branch_opcode) {
7987-
zend_jit_check_exception_undef_result(Dst, opline);
7981+
if (may_throw) {
7982+
zend_jit_check_exception_undef_result(Dst, opline);
7983+
}
79887984
if (exit_addr) {
79897985
if (smart_branch_opcode == ZEND_JMPZ) {
79907986
| jmp &exit_addr
@@ -7994,12 +7990,24 @@ static int zend_jit_identical(dasm_State **Dst,
79947990
}
79957991
} else {
79967992
| SET_ZVAL_TYPE_INFO res_addr, (opline->opcode != ZEND_IS_NOT_IDENTICAL ? IS_FALSE : IS_TRUE)
7997-
zend_jit_check_exception(Dst);
7993+
if (may_throw) {
7994+
zend_jit_check_exception(Dst);
7995+
}
79987996
}
7999-
} else if (has_concrete_type(op1_info) &&
8000-
has_concrete_type(op2_info) &&
8001-
concrete_type(op1_info) == concrete_type(op2_info) &&
8002-
concrete_type(op1_info) <= IS_TRUE) {
7997+
return 1;
7998+
}
7999+
8000+
if (opline->op1_type & (IS_CV|IS_VAR)) {
8001+
| ZVAL_DEREF FCARG1a, op1_info
8002+
}
8003+
if (opline->op2_type & (IS_CV|IS_VAR)) {
8004+
| ZVAL_DEREF FCARG2a, op2_info
8005+
}
8006+
8007+
if (has_concrete_type(op1_info)
8008+
&& has_concrete_type(op2_info)
8009+
&& concrete_type(op1_info) == concrete_type(op2_info)
8010+
&& concrete_type(op1_info) <= IS_TRUE) {
80038011
if (smart_branch_opcode) {
80048012
if (exit_addr) {
80058013
if (smart_branch_opcode == ZEND_JMPNZ) {
@@ -8046,7 +8054,9 @@ static int zend_jit_identical(dasm_State **Dst,
80468054
| jne >8
80478055
| SET_EX_OPLINE opline, r0
80488056
| FREE_OP opline->op2_type, opline->op2, op2_info, 1, opline
8049-
zend_jit_check_exception_undef_result(Dst, opline);
8057+
if (may_throw) {
8058+
zend_jit_check_exception_undef_result(Dst, opline);
8059+
}
80508060
if (exit_addr && smart_branch_opcode == ZEND_JMPNZ) {
80518061
| jmp &exit_addr
80528062
} else if (identical_label != (uint32_t)-1) {
@@ -8076,7 +8086,9 @@ static int zend_jit_identical(dasm_State **Dst,
80768086
(op2_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF))) {
80778087
| SET_EX_OPLINE opline, r0
80788088
| FREE_OP opline->op2_type, opline->op2, op2_info, 1, opline
8079-
zend_jit_check_exception_undef_result(Dst, opline);
8089+
if (may_throw) {
8090+
zend_jit_check_exception_undef_result(Dst, opline);
8091+
}
80808092
}
80818093
if (exit_addr) {
80828094
if (smart_branch_opcode == ZEND_JMPZ) {
@@ -8095,7 +8107,9 @@ static int zend_jit_identical(dasm_State **Dst,
80958107
| jne >8
80968108
| SET_EX_OPLINE opline, r0
80978109
| FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline
8098-
zend_jit_check_exception_undef_result(Dst, opline);
8110+
if (may_throw) {
8111+
zend_jit_check_exception_undef_result(Dst, opline);
8112+
}
80998113
if (exit_addr && smart_branch_opcode == ZEND_JMPNZ) {
81008114
| jmp &exit_addr
81018115
} else if (identical_label != (uint32_t)-1) {
@@ -8126,7 +8140,9 @@ static int zend_jit_identical(dasm_State **Dst,
81268140
(op1_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF))) {
81278141
| SET_EX_OPLINE opline, r0
81288142
| FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline
8129-
zend_jit_check_exception_undef_result(Dst, opline);
8143+
if (may_throw) {
8144+
zend_jit_check_exception_undef_result(Dst, opline);
8145+
}
81308146
}
81318147
if (smart_branch_opcode) {
81328148
if (exit_addr) {
@@ -8156,7 +8172,9 @@ static int zend_jit_identical(dasm_State **Dst,
81568172
| FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline
81578173
}
81588174
| FREE_OP opline->op2_type, opline->op2, op2_info, 1, opline
8159-
zend_jit_check_exception_undef_result(Dst, opline);
8175+
if (may_throw) {
8176+
zend_jit_check_exception_undef_result(Dst, opline);
8177+
}
81608178
| mov r0, aword T1 // restore
81618179
}
81628180
if (smart_branch_opcode) {

0 commit comments

Comments
 (0)