Skip to content

Commit efde51e

Browse files
committed
Improved tracing JIT for FETCH_OBJ_R/IS
1 parent 4984bd1 commit efde51e

File tree

1 file changed

+41
-21
lines changed

1 file changed

+41
-21
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10773,7 +10773,17 @@ static int zend_jit_fetch_obj_read(dasm_State **Dst, const zend_op *opline, cons
1077310773
} else {
1077410774
prop_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, offset);
1077510775
| mov edx, dword [FCARG1a + offset + 8]
10776-
| IF_TYPE dl, IS_UNDEF, >5
10776+
if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) {
10777+
int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM);
10778+
const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point);
10779+
10780+
if (!exit_addr) {
10781+
return 0;
10782+
}
10783+
| IF_TYPE dl, IS_UNDEF, &exit_addr
10784+
} else {
10785+
| IF_TYPE dl, IS_UNDEF, >5
10786+
}
1077710787
}
1077810788
| GET_ZVAL_PTR r0, prop_addr
1077910789
| IF_NOT_REFCOUNTED dh, >2
@@ -10791,26 +10801,29 @@ static int zend_jit_fetch_obj_read(dasm_State **Dst, const zend_op *opline, cons
1079110801
| SET_ZVAL_TYPE_INFO res_addr, edx
1079210802

1079310803
|.cold_code
10794-
|5:
10795-
| LOAD_ADDR FCARG2a, member
10796-
|.if X64
10797-
| LOAD_ZVAL_ADDR CARG3, res_addr
10798-
| mov CARG4, (opline->extended_value & ~ZEND_FETCH_OBJ_FLAGS)
10799-
|.else
10800-
| sub r4, 8
10801-
| push (opline->extended_value & ~ZEND_FETCH_OBJ_FLAGS)
10802-
| PUSH_ZVAL_ADDR res_addr, r0
10803-
|.endif
10804-
| SAVE_VALID_OPLINE opline, r0
10805-
if (opline->opcode != ZEND_FETCH_OBJ_IS) {
10806-
| EXT_CALL zend_jit_fetch_obj_r_slow, r0
10807-
} else {
10808-
| EXT_CALL zend_jit_fetch_obj_is_slow, r0
10804+
10805+
if (JIT_G(trigger) != ZEND_JIT_ON_HOT_TRACE || offset == ZEND_WRONG_PROPERTY_OFFSET) {
10806+
|5:
10807+
| LOAD_ADDR FCARG2a, member
10808+
|.if X64
10809+
| LOAD_ZVAL_ADDR CARG3, res_addr
10810+
| mov CARG4, (opline->extended_value & ~ZEND_FETCH_OBJ_FLAGS)
10811+
|.else
10812+
| sub r4, 8
10813+
| push (opline->extended_value & ~ZEND_FETCH_OBJ_FLAGS)
10814+
| PUSH_ZVAL_ADDR res_addr, r0
10815+
|.endif
10816+
| SAVE_VALID_OPLINE opline, r0
10817+
if (opline->opcode != ZEND_FETCH_OBJ_IS) {
10818+
| EXT_CALL zend_jit_fetch_obj_r_slow, r0
10819+
} else {
10820+
| EXT_CALL zend_jit_fetch_obj_is_slow, r0
10821+
}
10822+
|.if not(X64)
10823+
| add r4, 8
10824+
|.endif
10825+
| jmp >9
1080910826
}
10810-
|.if not(X64)
10811-
| add r4, 8
10812-
|.endif
10813-
| jmp >9
1081410827

1081510828
|6:
1081610829
if (offset == ZEND_WRONG_PROPERTY_OFFSET) {
@@ -10822,7 +10835,7 @@ static int zend_jit_fetch_obj_read(dasm_State **Dst, const zend_op *opline, cons
1082210835
| EXT_CALL zend_jit_zval_copy_deref_helper, r0
1082310836
| jmp >9
1082410837

10825-
if ((op1_info & ((MAY_BE_UNDEF|MAY_BE_ANY|MAY_BE_REF)- MAY_BE_OBJECT)) && JIT_G(trigger) != ZEND_JIT_ON_HOT_TRACE) {
10838+
if ((op1_info & ((MAY_BE_UNDEF|MAY_BE_ANY|MAY_BE_REF)- MAY_BE_OBJECT)) && JIT_G(trigger) != ZEND_JIT_ON_HOT_TRACE) {
1082610839
|7:
1082710840
if (opline->opcode != ZEND_FETCH_OBJ_IS) {
1082810841
| SAVE_VALID_OPLINE opline, r1
@@ -10875,6 +10888,13 @@ static int zend_jit_fetch_obj_read(dasm_State **Dst, const zend_op *opline, cons
1087510888
|9: // END
1087610889
| FREE_OP opline->op1_type, opline->op1, op1_info, 1, op_array, opline
1087710890

10891+
if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE
10892+
&& offset != ZEND_WRONG_PROPERTY_OFFSET
10893+
&& opline->op1_type != IS_VAR
10894+
&& opline->op1_type != IS_TMP_VAR) {
10895+
may_throw = 0;
10896+
}
10897+
1087810898
if (may_throw) {
1087910899
if (!zend_jit_check_exception(Dst)) {
1088010900
return 0;

0 commit comments

Comments
 (0)