Skip to content

Commit 52f4ed1

Browse files
wxue1devnexen
wxue1
authored andcommitted
Indirect call reduction for Jit code
Changing indirect call to direct call for Jit code benefits the branch prediction, which gets 1% performance gain in our workload. Similarly, we change indirect jump to direct jump. Signed-off-by: Su, Tao <tao.su@intel.com> Signed-off-by: Wang, Xue <xue1.wang@intel.com>
1 parent 3a46f9f commit 52f4ed1

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ PHP NEWS
66
. Fixed bug GH-8805 (finfo returns wrong mime type for woff/woff2 files).
77
(Anatol)
88

9+
- Opcache:
10+
. Added indirect call reduction for jit on x86 architectures. (wxue1)
11+
912
29 Sep 2022, PHP 8.1.11
1013

1114
- Core:

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ static size_t tsrm_tls_offset;
152152

153153
#define IS_SIGNED_32BIT(val) ((((intptr_t)(val)) <= 0x7fffffff) && (((intptr_t)(val)) >= (-2147483647 - 1)))
154154

155+
/* Call range is before or after 2GB */
156+
#define MAY_USE_32BIT_ADDR(addr) \
157+
(IS_SIGNED_32BIT((char*)(addr) - (char*)dasm_buf) && \
158+
IS_SIGNED_32BIT((char*)(addr) - (char*)dasm_end))
159+
155160
#define CAN_USE_AVX() (JIT_G(opt_flags) & allowed_opt_flags & ZEND_JIT_CPU_AVX)
156161

157162
/* Not Implemented Yet */
@@ -353,7 +358,7 @@ static size_t tsrm_tls_offset;
353358

354359
|.macro EXT_CALL, func, tmp_reg
355360
| .if X64
356-
|| if (IS_32BIT(dasm_end) && IS_32BIT(func)) {
361+
|| if (MAY_USE_32BIT_ADDR(func)) {
357362
| call qword &func
358363
|| } else {
359364
| LOAD_ADDR tmp_reg, func
@@ -366,7 +371,7 @@ static size_t tsrm_tls_offset;
366371

367372
|.macro EXT_JMP, func, tmp_reg
368373
| .if X64
369-
|| if (IS_32BIT(dasm_end) && IS_32BIT(func)) {
374+
|| if (MAY_USE_32BIT_ADDR(func)) {
370375
| jmp qword &func
371376
|| } else {
372377
| LOAD_ADDR tmp_reg, func

0 commit comments

Comments
 (0)