Skip to content

Commit

Permalink
JIT: Avoid useless EX(func) load
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Aug 30, 2021
1 parent 608d568 commit 96c3465
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
13 changes: 11 additions & 2 deletions ext/opcache/jit/zend_jit_arm64.dasc
Original file line number Diff line number Diff line change
Expand Up @@ -9028,11 +9028,11 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend
| str REG2, EX:RX->run_time_cache
}
} else {
// Always defined as ZEND_MAP_PTR_KIND_PTR_OR_OFFSET. See Zend/zend_map_ptr.h.
#if ZEND_MAP_PTR_KIND == ZEND_MAP_PTR_KIND_PTR
if (func) {
| ldr REG0, EX:RX->func
}
// Always defined as ZEND_MAP_PTR_KIND_PTR_OR_OFFSET. See Zend/zend_map_ptr.h.
#if ZEND_MAP_PTR_KIND == ZEND_MAP_PTR_KIND_PTR
| ldr REG2, [REG0, #offsetof(zend_op_array, run_time_cache__ptr)]
| ldr REG2, [REG2]
#elif ZEND_MAP_PTR_KIND == ZEND_MAP_PTR_KIND_PTR_OR_OFFSET
Expand All @@ -9043,11 +9043,17 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend
| ldr REG2, [REG2]
} else if ((func->op_array.fn_flags & ZEND_ACC_IMMUTABLE)
&& (!func->op_array.scope || (func->op_array.scope->ce_flags & ZEND_ACC_LINKED))) {
if (func) {
| ldr REG0, EX:RX->func
}
| ldr REG2, [REG0, #offsetof(zend_op_array, run_time_cache__ptr)]
| MEM_LOAD_OP_ZTS add, ldr, REG2, compiler_globals, map_ptr_base, REG1, TMP1
| ldr REG2, [REG2]
} else {
/* the called op_array may be not persisted yet */
if (func) {
| ldr REG0, EX:RX->func
}
| ldr REG2, [REG0, #offsetof(zend_op_array, run_time_cache__ptr)]
| TST_64_WITH_ONE REG2
| beq >1
Expand All @@ -9056,6 +9062,9 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend
| ldr REG2, [REG2]
}
} else {
if (func) {
| ldr REG0, EX:RX->func
}
| ldr REG2, [REG0, #offsetof(zend_op_array, run_time_cache__ptr)]
| TST_64_WITH_ONE REG2
| beq >1
Expand Down
11 changes: 10 additions & 1 deletion ext/opcache/jit/zend_jit_x86.dasc
Original file line number Diff line number Diff line change
Expand Up @@ -9652,10 +9652,10 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend
| mov EX:RX->run_time_cache, r2
}
} else {
#if ZEND_MAP_PTR_KIND == ZEND_MAP_PTR_KIND_PTR
if (func) {
| mov r0, EX:RX->func
}
#if ZEND_MAP_PTR_KIND == ZEND_MAP_PTR_KIND_PTR
| mov r2, aword [r0 + offsetof(zend_op_array, run_time_cache__ptr)]
| mov r2, aword [r2]
#elif ZEND_MAP_PTR_KIND == ZEND_MAP_PTR_KIND_PTR_OR_OFFSET
Expand All @@ -9665,11 +9665,17 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend
| mov r2, aword [r2 + (uintptr_t)ZEND_MAP_PTR(func->op_array.run_time_cache)]
} else if ((func->op_array.fn_flags & ZEND_ACC_IMMUTABLE)
&& (!func->op_array.scope || (func->op_array.scope->ce_flags & ZEND_ACC_LINKED))) {
if (func) {
| mov r0, EX:RX->func
}
| mov r2, aword [r0 + offsetof(zend_op_array, run_time_cache__ptr)]
| MEM_LOAD_OP_ZTS add, r2, aword, compiler_globals, map_ptr_base, r1
| mov r2, aword [r2]
} else {
/* the called op_array may be not persisted yet */
if (func) {
| mov r0, EX:RX->func
}
| mov r2, aword [r0 + offsetof(zend_op_array, run_time_cache__ptr)]
| test r2, 1
| jz >1
Expand All @@ -9678,6 +9684,9 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend
| mov r2, aword [r2]
}
} else {
if (func) {
| mov r0, EX:RX->func
}
| mov r2, aword [r0 + offsetof(zend_op_array, run_time_cache__ptr)]
| test r2, 1
| jz >1
Expand Down

0 comments on commit 96c3465

Please sign in to comment.