1
0
mirror of https://github.com/php/php-src.git synced 2026-04-02 21:52:36 +02:00

JIT: Allow keeping result of FETCH_CONSTANT in a CPU register

This commit is contained in:
Dmitry Stogov
2021-08-30 14:56:51 +03:00
parent 8e6e9838b0
commit 8f601be101
4 changed files with 22 additions and 9 deletions

View File

@@ -3861,7 +3861,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
}
goto done;
case ZEND_FETCH_CONSTANT:
if (!zend_jit_fetch_constant(&dasm_state, opline, op_array, ssa, ssa_op)) {
if (!zend_jit_fetch_constant(&dasm_state, opline, op_array, ssa, ssa_op, RES_REG_ADDR())) {
goto jit_failure;
}
goto done;

View File

@@ -13884,10 +13884,10 @@ static int zend_jit_fetch_constant(dasm_State **Dst,
const zend_op *opline,
const zend_op_array *op_array,
zend_ssa *ssa,
const zend_ssa_op *ssa_op)
const zend_ssa_op *ssa_op,
zend_jit_addr res_addr)
{
zval *zv = RT_CONSTANT(opline, opline->op2) + 1;
zend_jit_addr res_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->result.var);
zend_jit_addr const_addr = ZEND_ADDR_MEM_ZVAL(ZREG_REG0, 0);
uint32_t res_info = RES_INFO();
@@ -13929,7 +13929,11 @@ static int zend_jit_fetch_constant(dasm_State **Dst,
}
| ZVAL_COPY_VALUE_V res_addr, -1, const_addr, res_info, ZREG_REG0, ZREG_REG1, ZREG_TMP1, ZREG_FPR0
if (type < IS_STRING) {
| SET_ZVAL_TYPE_INFO res_addr, type, TMP1w, TMP2
if (Z_MODE(res_addr) == IS_MEM_ZVAL) {
| SET_ZVAL_TYPE_INFO res_addr, type, TMP1w, TMP2
} else if (!zend_jit_store_var_if_necessary(Dst, opline->result.var, res_addr, res_info)) {
return 0;
}
} else {
| SET_ZVAL_TYPE_INFO_FROM_REG res_addr, REG2w, TMP1
| TRY_ADDREF res_info, REG2w, REG1, TMP1w
@@ -14266,6 +14270,8 @@ static bool zend_jit_opline_supports_reg(const zend_op_array *op_array, zend_ssa
case ZEND_JMPZ_EX:
case ZEND_JMPNZ_EX:
return 1;
case ZEND_FETCH_CONSTANT:
return 1;
case ZEND_FETCH_DIM_R:
op1_info = OP1_INFO();
op2_info = OP2_INFO();

View File

@@ -2743,7 +2743,8 @@ static zend_lifetime_interval** zend_jit_trace_allocate_registers(zend_jit_trace
|| opline->opcode == ZEND_ADD
|| opline->opcode == ZEND_SUB
|| opline->opcode == ZEND_MUL
|| opline->opcode == ZEND_FETCH_DIM_R) {
|| opline->opcode == ZEND_FETCH_DIM_R
|| opline->opcode == ZEND_FETCH_CONSTANT) {
if (!(ssa->var_info[ssa_op->result_def].type & MAY_BE_DOUBLE)
|| (opline->opcode != ZEND_PRE_INC && opline->opcode != ZEND_PRE_DEC)) {
start[ssa_op->result_def] = idx;
@@ -5730,7 +5731,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
}
goto done;
case ZEND_FETCH_CONSTANT:
if (!zend_jit_fetch_constant(&dasm_state, opline, op_array, ssa, ssa_op)) {
if (!zend_jit_fetch_constant(&dasm_state, opline, op_array, ssa, ssa_op, RES_REG_ADDR())) {
goto jit_failure;
}
goto done;

View File

@@ -14729,10 +14729,10 @@ static int zend_jit_fetch_constant(dasm_State **Dst,
const zend_op *opline,
const zend_op_array *op_array,
zend_ssa *ssa,
const zend_ssa_op *ssa_op)
const zend_ssa_op *ssa_op,
zend_jit_addr res_addr)
{
zval *zv = RT_CONSTANT(opline, opline->op2) + 1;
zend_jit_addr res_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->result.var);
zend_jit_addr const_addr = ZEND_ADDR_MEM_ZVAL(ZREG_R0, 0);
uint32_t res_info = RES_INFO();
@@ -14774,7 +14774,11 @@ static int zend_jit_fetch_constant(dasm_State **Dst,
}
| ZVAL_COPY_VALUE_V res_addr, -1, const_addr, res_info, ZREG_R0, ZREG_R1
if (type < IS_STRING) {
| SET_ZVAL_TYPE_INFO res_addr, type
if (Z_MODE(res_addr) == IS_MEM_ZVAL) {
| SET_ZVAL_TYPE_INFO res_addr, type
} else if (!zend_jit_store_var_if_necessary(Dst, opline->result.var, res_addr, res_info)) {
return 0;
}
} else {
| SET_ZVAL_TYPE_INFO res_addr, edx
| TRY_ADDREF res_info, dh, r1
@@ -15111,6 +15115,8 @@ static bool zend_jit_opline_supports_reg(const zend_op_array *op_array, zend_ssa
case ZEND_JMPZ_EX:
case ZEND_JMPNZ_EX:
return 1;
case ZEND_FETCH_CONSTANT:
return 1;
case ZEND_FETCH_DIM_R:
op1_info = OP1_INFO();
op2_info = OP2_INFO();