Skip to content

Commit

Permalink
JIT: Avoid duplicate EX(opline) assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Oct 4, 2021
1 parent ac70bb3 commit 724c4fb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 38 deletions.
32 changes: 13 additions & 19 deletions ext/opcache/jit/zend_jit_arm64.dasc
Expand Up @@ -4447,8 +4447,8 @@ static int zend_jit_math_helper(dasm_State **Dst,
} else {
ZEND_UNREACHABLE();
}
| FREE_OP op1_type, op1, op1_info, 0, opline, ZREG_TMP1, ZREG_TMP2
| FREE_OP op2_type, op2, op2_info, 0, opline, ZREG_TMP1, ZREG_TMP2
| FREE_OP op1_type, op1, op1_info, 0, NULL, ZREG_TMP1, ZREG_TMP2
| FREE_OP op2_type, op2, op2_info, 0, NULL, ZREG_TMP1, ZREG_TMP2
if (may_throw) {
if (Z_MODE(res_addr) == IS_MEM_ZVAL && Z_REG(res_addr) == ZREG_RX) {
zend_jit_check_exception_undef_result(Dst, opline);
Expand Down Expand Up @@ -4792,8 +4792,8 @@ static int zend_jit_long_math_helper(dasm_State **Dst,
} else {
ZEND_UNREACHABLE();
}
| FREE_OP op1_type, op1, op1_info, 0, opline, ZREG_TMP1, ZREG_TMP2
| FREE_OP op2_type, op2, op2_info, 0, opline, ZREG_TMP1, ZREG_TMP2
| FREE_OP op1_type, op1, op1_info, 0, NULL, ZREG_TMP1, ZREG_TMP2
| FREE_OP op2_type, op2, op2_info, 0, NULL, ZREG_TMP1, ZREG_TMP2
if (may_throw) {
if (Z_MODE(res_addr) == IS_MEM_ZVAL && Z_REG(res_addr) == ZREG_RX) {
zend_jit_check_exception_undef_result(Dst, opline);
Expand Down Expand Up @@ -4901,8 +4901,8 @@ static int zend_jit_concat_helper(dasm_State **Dst,
/* concatination with empty string may increase refcount */
op1_info |= MAY_BE_RCN;
op2_info |= MAY_BE_RCN;
| FREE_OP op1_type, op1, op1_info, 0, opline, ZREG_TMP1, ZREG_TMP2
| FREE_OP op2_type, op2, op2_info, 0, opline, ZREG_TMP1, ZREG_TMP2
| FREE_OP op1_type, op1, op1_info, 0, NULL, ZREG_TMP1, ZREG_TMP2
| FREE_OP op2_type, op2, op2_info, 0, NULL, ZREG_TMP1, ZREG_TMP2
if (may_throw) {
if (Z_MODE(res_addr) == IS_MEM_ZVAL && Z_REG(res_addr) == ZREG_RX) {
zend_jit_check_exception_undef_result(Dst, opline);
Expand Down Expand Up @@ -6019,7 +6019,7 @@ static int zend_jit_assign_dim(dasm_State **Dst, const zend_op *opline, uint32_t
}
#endif

| FREE_OP (opline+1)->op1_type, (opline+1)->op1, val_info, 0, opline, ZREG_TMP1, ZREG_TMP2
| FREE_OP (opline+1)->op1_type, (opline+1)->op1, val_info, 0, NULL, ZREG_TMP1, ZREG_TMP2
}

if (op1_info & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_ARRAY)) {
Expand Down Expand Up @@ -6252,8 +6252,8 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, uint3
| EXT_CALL zend_jit_assign_dim_op_helper, REG0

|9:
| FREE_OP (opline+1)->op1_type, (opline+1)->op1, op1_data_info, 0, opline, ZREG_TMP1, ZREG_TMP2
| FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline, ZREG_TMP1, ZREG_TMP2
| FREE_OP (opline+1)->op1_type, (opline+1)->op1, op1_data_info, 0, NULL, ZREG_TMP1, ZREG_TMP2
| FREE_OP opline->op2_type, opline->op2, op2_info, 0, NULL, ZREG_TMP1, ZREG_TMP2
if (may_throw) {
zend_jit_check_exception(Dst);
}
Expand Down Expand Up @@ -7363,9 +7363,9 @@ static int zend_jit_cmp(dasm_State **Dst,
(op2_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)))) {
| str RETVALw, T1 // save
if (opline->opcode != ZEND_CASE) {
| FREE_OP opline->op1_type, opline->op1, op1_info, 0, opline, ZREG_TMP1, ZREG_TMP2
| FREE_OP opline->op1_type, opline->op1, op1_info, 0, NULL, ZREG_TMP1, ZREG_TMP2
}
| FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline, ZREG_TMP1, ZREG_TMP2
| FREE_OP opline->op2_type, opline->op2, op2_info, 0, NULL, ZREG_TMP1, ZREG_TMP2
| ldr RETVALw, T1 // restore
}
if (may_throw) {
Expand Down Expand Up @@ -7548,7 +7548,6 @@ static int zend_jit_identical(dasm_State **Dst,
(op1_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF))) ||
((opline->op2_type & (IS_VAR|IS_TMP_VAR)) &&
(op2_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)))) {
| SET_EX_OPLINE opline, REG0
if (opline->opcode != ZEND_CASE_STRICT) {
| FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline, ZREG_TMP1, ZREG_TMP2
}
Expand Down Expand Up @@ -7630,7 +7629,6 @@ static int zend_jit_identical(dasm_State **Dst,
if (smart_branch_opcode) {
if (opline->op2_type == IS_VAR && (op2_info & MAY_BE_REF)) {
| bne >8
| SET_EX_OPLINE opline, REG0
| FREE_OP opline->op2_type, opline->op2, op2_info, 1, opline, ZREG_TMP1, ZREG_TMP2
if (may_throw) {
zend_jit_check_exception_undef_result(Dst, opline);
Expand Down Expand Up @@ -7661,7 +7659,6 @@ static int zend_jit_identical(dasm_State **Dst,
}
if ((opline->op2_type & (IS_VAR|IS_TMP_VAR)) &&
(op2_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF))) {
| SET_EX_OPLINE opline, REG0
| FREE_OP opline->op2_type, opline->op2, op2_info, 1, opline, ZREG_TMP1, ZREG_TMP2
if (may_throw) {
zend_jit_check_exception_undef_result(Dst, opline);
Expand All @@ -7683,7 +7680,6 @@ static int zend_jit_identical(dasm_State **Dst,
if (opline->opcode != ZEND_CASE_STRICT
&& opline->op1_type == IS_VAR && (op1_info & MAY_BE_REF)) {
| bne >8
| SET_EX_OPLINE opline, REG0
| FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline, ZREG_TMP1, ZREG_TMP2
if (may_throw) {
zend_jit_check_exception_undef_result(Dst, opline);
Expand Down Expand Up @@ -7715,7 +7711,6 @@ static int zend_jit_identical(dasm_State **Dst,
if (opline->opcode != ZEND_CASE_STRICT
&& (opline->op1_type & (IS_VAR|IS_TMP_VAR)) &&
(op1_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF))) {
| SET_EX_OPLINE opline, REG0
| FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline, ZREG_TMP1, ZREG_TMP2
if (may_throw) {
zend_jit_check_exception_undef_result(Dst, opline);
Expand Down Expand Up @@ -7744,7 +7739,6 @@ static int zend_jit_identical(dasm_State **Dst,
((opline->op2_type & (IS_VAR|IS_TMP_VAR)) &&
(op2_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)))) {
| str RETVALw, T1 // save
| SET_EX_OPLINE opline, REG0
if (opline->opcode != ZEND_CASE_STRICT) {
| FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline, ZREG_TMP1, ZREG_TMP2
}
Expand Down Expand Up @@ -13064,7 +13058,7 @@ static int zend_jit_assign_obj_op(dasm_State **Dst,
info |= MAY_BE_RC1|MAY_BE_RCN;
}

| FREE_OP (opline+1)->op1_type, (opline+1)->op1, info, 0, opline, ZREG_TMP1, ZREG_TMP2
| FREE_OP (opline+1)->op1_type, (opline+1)->op1, info, 0, NULL, ZREG_TMP1, ZREG_TMP2
}
}

Expand Down Expand Up @@ -13440,7 +13434,7 @@ static int zend_jit_assign_obj(dasm_State **Dst,
info |= MAY_BE_RC1|MAY_BE_RCN;
}

| FREE_OP (opline+1)->op1_type, (opline+1)->op1, info, 0, opline, ZREG_TMP1, ZREG_TMP2
| FREE_OP (opline+1)->op1_type, (opline+1)->op1, info, 0, NULL, ZREG_TMP1, ZREG_TMP2
}
}

Expand Down
32 changes: 13 additions & 19 deletions ext/opcache/jit/zend_jit_x86.dasc
Expand Up @@ -4869,8 +4869,8 @@ static int zend_jit_math_helper(dasm_State **Dst,
|.if not(X64)
| add r4, 12
|.endif
| FREE_OP op1_type, op1, op1_info, 0, opline
| FREE_OP op2_type, op2, op2_info, 0, opline
| FREE_OP op1_type, op1, op1_info, 0, NULL
| FREE_OP op2_type, op2, op2_info, 0, NULL
if (may_throw) {
if (Z_MODE(res_addr) == IS_MEM_ZVAL && Z_REG(res_addr) == ZREG_RX) {
zend_jit_check_exception_undef_result(Dst, opline);
Expand Down Expand Up @@ -5243,8 +5243,8 @@ static int zend_jit_long_math_helper(dasm_State **Dst,
|.if not(X64)
| add r4, 12
|.endif
| FREE_OP op1_type, op1, op1_info, 0, opline
| FREE_OP op2_type, op2, op2_info, 0, opline
| FREE_OP op1_type, op1, op1_info, 0, NULL
| FREE_OP op2_type, op2, op2_info, 0, NULL
if (may_throw) {
if (Z_MODE(res_addr) == IS_MEM_ZVAL && Z_REG(res_addr) == ZREG_RX) {
zend_jit_check_exception_undef_result(Dst, opline);
Expand Down Expand Up @@ -5370,8 +5370,8 @@ static int zend_jit_concat_helper(dasm_State **Dst,
/* concatination with empty string may increase refcount */
op1_info |= MAY_BE_RCN;
op2_info |= MAY_BE_RCN;
| FREE_OP op1_type, op1, op1_info, 0, opline
| FREE_OP op2_type, op2, op2_info, 0, opline
| FREE_OP op1_type, op1, op1_info, 0, NULL
| FREE_OP op2_type, op2, op2_info, 0, NULL
if (may_throw) {
if (Z_MODE(res_addr) == IS_MEM_ZVAL && Z_REG(res_addr) == ZREG_RX) {
zend_jit_check_exception_undef_result(Dst, opline);
Expand Down Expand Up @@ -6522,7 +6522,7 @@ static int zend_jit_assign_dim(dasm_State **Dst, const zend_op *opline, uint32_t
}
#endif

| FREE_OP (opline+1)->op1_type, (opline+1)->op1, val_info, 0, opline
| FREE_OP (opline+1)->op1_type, (opline+1)->op1, val_info, 0, NULL
}

if (op1_info & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_ARRAY)) {
Expand Down Expand Up @@ -6770,8 +6770,8 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, uint3
|.endif

|9:
| FREE_OP (opline+1)->op1_type, (opline+1)->op1, op1_data_info, 0, opline
| FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline
| FREE_OP (opline+1)->op1_type, (opline+1)->op1, op1_data_info, 0, NULL
| FREE_OP opline->op2_type, opline->op2, op2_info, 0, NULL
if (may_throw) {
zend_jit_check_exception(Dst);
}
Expand Down Expand Up @@ -7898,9 +7898,9 @@ static int zend_jit_cmp(dasm_State **Dst,
(op2_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)))) {
| mov dword T1, eax // save
if (opline->opcode != ZEND_CASE) {
| FREE_OP opline->op1_type, opline->op1, op1_info, 0, opline
| FREE_OP opline->op1_type, opline->op1, op1_info, 0, NULL
}
| FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline
| FREE_OP opline->op2_type, opline->op2, op2_info, 0, NULL
if (may_throw) {
zend_jit_check_exception_undef_result(Dst, opline);
}
Expand Down Expand Up @@ -8099,7 +8099,6 @@ static int zend_jit_identical(dasm_State **Dst,
(op1_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF))) ||
((opline->op2_type & (IS_VAR|IS_TMP_VAR)) &&
(op2_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)))) {
| SET_EX_OPLINE opline, r0
if (opline->opcode != ZEND_CASE_STRICT) {
| FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline
}
Expand Down Expand Up @@ -8180,7 +8179,6 @@ static int zend_jit_identical(dasm_State **Dst,
if (smart_branch_opcode) {
if (opline->op2_type == IS_VAR && (op2_info & MAY_BE_REF)) {
| jne >8
| SET_EX_OPLINE opline, r0
| FREE_OP opline->op2_type, opline->op2, op2_info, 1, opline
if (may_throw) {
zend_jit_check_exception_undef_result(Dst, opline);
Expand Down Expand Up @@ -8212,7 +8210,6 @@ static int zend_jit_identical(dasm_State **Dst,
}
if ((opline->op2_type & (IS_VAR|IS_TMP_VAR)) &&
(op2_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF))) {
| SET_EX_OPLINE opline, r0
| FREE_OP opline->op2_type, opline->op2, op2_info, 1, opline
if (may_throw) {
zend_jit_check_exception_undef_result(Dst, opline);
Expand All @@ -8233,7 +8230,6 @@ static int zend_jit_identical(dasm_State **Dst,
if (opline->opcode != ZEND_CASE_STRICT
&& opline->op1_type == IS_VAR && (op1_info & MAY_BE_REF)) {
| jne >8
| SET_EX_OPLINE opline, r0
| FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline
if (may_throw) {
zend_jit_check_exception_undef_result(Dst, opline);
Expand Down Expand Up @@ -8266,7 +8262,6 @@ static int zend_jit_identical(dasm_State **Dst,
if (opline->opcode != ZEND_CASE_STRICT
&& (opline->op1_type & (IS_VAR|IS_TMP_VAR)) &&
(op1_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF))) {
| SET_EX_OPLINE opline, r0
| FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline
if (may_throw) {
zend_jit_check_exception_undef_result(Dst, opline);
Expand Down Expand Up @@ -8295,7 +8290,6 @@ static int zend_jit_identical(dasm_State **Dst,
((opline->op2_type & (IS_VAR|IS_TMP_VAR)) &&
(op2_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)))) {
| mov aword T1, r0 // save
| SET_EX_OPLINE opline, r0
if (opline->opcode != ZEND_CASE_STRICT) {
| FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline
}
Expand Down Expand Up @@ -13820,7 +13814,7 @@ static int zend_jit_assign_obj_op(dasm_State **Dst,
info |= MAY_BE_RC1|MAY_BE_RCN;
}

| FREE_OP (opline+1)->op1_type, (opline+1)->op1, info, 0, opline
| FREE_OP (opline+1)->op1_type, (opline+1)->op1, info, 0, NULL
}
}

Expand Down Expand Up @@ -14248,7 +14242,7 @@ static int zend_jit_assign_obj(dasm_State **Dst,
info |= MAY_BE_RC1|MAY_BE_RCN;
}

| FREE_OP (opline+1)->op1_type, (opline+1)->op1, info, 0, opline
| FREE_OP (opline+1)->op1_type, (opline+1)->op1, info, 0, NULL
}
}

Expand Down

0 comments on commit 724c4fb

Please sign in to comment.