Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions ext/opcache/jit/zend_jit.c
Original file line number Diff line number Diff line change
Expand Up @@ -3702,8 +3702,8 @@ void zend_jit_startup(void *buf, size_t size, bool reattached)
*dasm_ptr = (void**)*dasm_ptr + sizeof(zend_jit_stubs) / sizeof(zend_jit_stubs[0]);
#elif defined(IR_TARGET_AARCH64)
zend_jit_stub_handlers = dasm_buf;
*dasm_ptr = (void**)*dasm_ptr + (sizeof(zend_jit_stubs) / sizeof(zend_jit_stubs[0])) * 2;
memset(zend_jit_stub_handlers, 0, (sizeof(zend_jit_stubs) / sizeof(zend_jit_stubs[0])) * 2 * sizeof(void*));
*dasm_ptr = (void**)*dasm_ptr + (sizeof(zend_jit_stubs) / sizeof(zend_jit_stubs[0])) * 3;
memset(zend_jit_stub_handlers, 0, (sizeof(zend_jit_stubs) / sizeof(zend_jit_stubs[0])) * 3 * sizeof(void*));
#endif
*dasm_ptr = (void*)ZEND_MM_ALIGNED_SIZE_EX(((size_t)(*dasm_ptr)), 16);
zend_jit_protect();
Expand Down Expand Up @@ -3889,6 +3889,9 @@ void zend_jit_restart(void)

/* restore JIT buffer pos */
dasm_ptr[0] = dasm_ptr[1];
#if defined(IR_TARGET_AARCH64)
zend_jit_restore_stub_handlers();
#endif

zend_jit_trace_restart();

Expand Down
21 changes: 21 additions & 0 deletions ext/opcache/jit/zend_jit_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,24 @@ static void zend_jit_commit_veneers(void)
}
}
}

/* zend_jit_commit_veneers() replaces the address of a stub by the address of a veneer emitted
* after it. zend_jit_restart() rewinds the buffer below such veneers, so it restores the
* original addresses, kept after the pending veneers. */
static void zend_jit_save_stub_handlers(void)
{
int count = sizeof(zend_jit_stubs) / sizeof(zend_jit_stubs[0]);

memcpy(zend_jit_stub_handlers + count * 2, zend_jit_stub_handlers, count * sizeof(void*));
}

static void zend_jit_restore_stub_handlers(void)
{
int count = sizeof(zend_jit_stubs) / sizeof(zend_jit_stubs[0]);

memcpy(zend_jit_stub_handlers, zend_jit_stub_handlers + count * 2, count * sizeof(void*));
memset(zend_jit_stub_handlers + count, 0, count * sizeof(void*));
}
#endif

static bool zend_jit_prefer_const_addr_load(zend_jit_ctx *jit, uintptr_t addr)
Expand Down Expand Up @@ -2969,6 +2987,9 @@ static void zend_jit_setup_stubs(void)
}
zend_jit_free_ctx(&jit);
}
#if defined(IR_TARGET_AARCH64)
zend_jit_save_stub_handlers();
#endif
}

#define REGISTER_HELPER(n) \
Expand Down
Loading