Skip to content

Commit 8095a0e

Browse files
committed
Better register usage for ASSIGN_DIM_OP
1 parent 35a3e45 commit 8095a0e

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3936,8 +3936,11 @@ static int zend_jit_math_long_long(dasm_State **Dst,
39363936
result_reg = Z_REG(res_addr);
39373937
} else if (Z_MODE(op1_addr) == IS_REG && Z_LAST_USE(op1_addr)) {
39383938
result_reg = Z_REG(op1_addr);
3939-
} else {
3939+
} else if (Z_REG(res_addr) != ZREG_R0) {
39403940
result_reg = ZREG_R0;
3941+
} else {
3942+
/* ASSIGN_DIM_OP */
3943+
result_reg = ZREG_FCARG1a;
39413944
}
39423945

39433946
if (opcode == ZEND_MUL &&
@@ -4392,7 +4395,6 @@ static int zend_jit_math_helper(dasm_State **Dst,
43924395
|.cold_code
43934396
}
43944397
|6:
4395-
| SAVE_VALID_OPLINE opline, r0
43964398
if (Z_MODE(res_addr) == IS_REG) {
43974399
zend_jit_addr real_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, res_var);
43984400
| LOAD_ZVAL_ADDR FCARG1a, real_addr
@@ -4420,6 +4422,7 @@ static int zend_jit_math_helper(dasm_State **Dst,
44204422
| sub r4, 12
44214423
| PUSH_ZVAL_ADDR op2_addr, r0
44224424
|.endif
4425+
| SAVE_VALID_OPLINE opline, r0
44234426
if (opcode == ZEND_ADD) {
44244427
| EXT_CALL add_function, r0
44254428
} else if (opcode == ZEND_SUB) {
@@ -4545,8 +4548,17 @@ static int zend_jit_long_math_helper(dasm_State **Dst,
45454548
result_reg = Z_REG(res_addr);
45464549
} else if (Z_MODE(op1_addr) == IS_REG && Z_LAST_USE(op1_addr)) {
45474550
result_reg = Z_REG(op1_addr);
4548-
} else {
4551+
} else if (Z_REG(res_addr) != ZREG_R0) {
45494552
result_reg = ZREG_R0;
4553+
} else {
4554+
/* ASSIGN_DIM_OP */
4555+
if (sizeof(void*) == 4
4556+
&& (opcode == ZEND_SL || opcode == ZEND_SR)
4557+
&& Z_MODE(op2_addr) != IS_CONST_ZVAL) {
4558+
result_reg = ZREG_R2;
4559+
} else {
4560+
result_reg = ZREG_FCARG1a;
4561+
}
45504562
}
45514563

45524564
if (opcode == ZEND_SL) {
@@ -4716,7 +4728,6 @@ static int zend_jit_long_math_helper(dasm_State **Dst,
47164728
|.cold_code
47174729
}
47184730
|6:
4719-
| SAVE_VALID_OPLINE opline, r0
47204731
if (Z_MODE(res_addr) == IS_REG) {
47214732
zend_jit_addr real_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, res_var);
47224733
| LOAD_ZVAL_ADDR FCARG1a, real_addr
@@ -4744,6 +4755,7 @@ static int zend_jit_long_math_helper(dasm_State **Dst,
47444755
| sub r4, 12
47454756
| PUSH_ZVAL_ADDR op2_addr, r0
47464757
|.endif
4758+
| SAVE_VALID_OPLINE opline, r0
47474759
if (opcode == ZEND_BW_OR) {
47484760
| EXT_CALL bitwise_or_function, r0
47494761
} else if (opcode == ZEND_BW_AND) {
@@ -4864,7 +4876,6 @@ static int zend_jit_concat_helper(dasm_State **Dst,
48644876
|6:
48654877
}
48664878
#endif
4867-
| SAVE_VALID_OPLINE opline, r0
48684879
if (Z_REG(res_addr) != ZREG_FCARG1a || Z_OFFSET(res_addr) != 0) {
48694880
| LOAD_ZVAL_ADDR FCARG1a, res_addr
48704881
}
@@ -4875,6 +4886,7 @@ static int zend_jit_concat_helper(dasm_State **Dst,
48754886
| sub r4, 12
48764887
| PUSH_ZVAL_ADDR op2_addr, r0
48774888
|.endif
4889+
| SAVE_VALID_OPLINE opline, r0
48784890
| EXT_CALL concat_function, r0
48794891
|.if not(X64)
48804892
| add r4, 12
@@ -5993,7 +6005,6 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, uint3
59936005
| //ZEND_VM_C_GOTO(assign_dim_op_ret_null);
59946006
| jmp >9
59956007
|.code
5996-
| mov FCARG1a, r0
59976008
} else {
59986009
var_info = zend_array_element_type(op1_info, opline->op1_type, 0, 0);
59996010
if (op1_info & (MAY_BE_ARRAY_OF_REF|MAY_BE_OBJECT)) {
@@ -6008,14 +6019,13 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, uint3
60086019
}
60096020

60106021
|8:
6011-
| mov FCARG1a, r0
60126022
if (op1_info & (MAY_BE_ARRAY_OF_REF)) {
60136023
binary_op_type binary_op = get_binary_op(opline->extended_value);
6014-
| IF_NOT_Z_TYPE, FCARG1a, IS_REFERENCE, >1
6015-
| GET_Z_PTR FCARG1a, FCARG1a
6024+
| IF_NOT_Z_TYPE, r0, IS_REFERENCE, >1
6025+
| GET_Z_PTR FCARG1a, r0
60166026
| cmp aword [FCARG1a + offsetof(zend_reference, sources.ptr)], 0
60176027
| jnz >2
6018-
| add FCARG1a, offsetof(zend_reference, val)
6028+
| lea r0, aword [FCARG1a + offsetof(zend_reference, val)]
60196029
|.cold_code
60206030
|2:
60216031
| LOAD_ZVAL_ADDR FCARG2a, op3_addr
@@ -6037,7 +6047,7 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, uint3
60376047
}
60386048
}
60396049

6040-
var_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, 0);
6050+
var_addr = ZEND_ADDR_MEM_ZVAL(ZREG_R0, 0);
60416051
switch (opline->extended_value) {
60426052
case ZEND_ADD:
60436053
case ZEND_SUB:

0 commit comments

Comments
 (0)