Skip to content

Commit 93c57af

Browse files
committedOct 30, 2023
Fixed GH-12560: Assertion `0 && "too long jmp distance"' failed with new JIT on AArch64
1 parent 2efe366 commit 93c57af

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed
 

‎ext/opcache/jit/zend_jit_ir.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ typedef struct _zend_jit_registers_buf {
310310
#define ZEND_JIT_EXIT_POINTS_SPACING 4 // push byte + short jmp = bytes
311311
#define ZEND_JIT_EXIT_POINTS_PER_GROUP 32 // number of continuous exit points
312312

313-
static uint32_t zend_jit_exit_point_by_addr(void *addr);
313+
static uint32_t zend_jit_exit_point_by_addr(const void *addr);
314314
int ZEND_FASTCALL zend_jit_trace_exit(uint32_t exit_num, zend_jit_registers_buf *regs);
315315

316316
static int zend_jit_assign_to_variable(zend_jit_ctx *jit,
@@ -358,7 +358,7 @@ static const void *zend_jit_get_veneer(ir_ctx *ctx, const void *addr)
358358

359359
if (((zend_jit_ctx*)ctx)->trace
360360
&& (void*)addr >= dasm_buf && (void*)addr < dasm_end) {
361-
uint32_t exit_point = zend_jit_exit_point_by_addr((void*)addr);
361+
uint32_t exit_point = zend_jit_exit_point_by_addr(addr);
362362

363363
if (exit_point != (uint32_t)-1) {
364364
zend_jit_trace_info *t = ((zend_jit_ctx*)ctx)->trace;
@@ -375,7 +375,11 @@ static bool zend_jit_set_veneer(ir_ctx *ctx, const void *addr, const void *venee
375375
{
376376
int i, count = sizeof(zend_jit_stubs) / sizeof(zend_jit_stubs[0]);
377377
int64_t offset;
378+
uint32_t exit_point = zend_jit_exit_point_by_addr(addr);
378379

380+
if (exit_point != (uint32_t)-1) {
381+
return 1;
382+
}
379383
for (i = 0; i < count; i++) {
380384
if (zend_jit_stub_handlers[i] == addr) {
381385
const void **ptr = (const void**)&zend_jit_stub_handlers[count + i];

‎ext/opcache/jit/zend_jit_trace.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static const void *zend_jit_trace_get_exit_addr(uint32_t n)
117117
((n % ZEND_JIT_EXIT_POINTS_PER_GROUP) * ZEND_JIT_EXIT_POINTS_SPACING));
118118
}
119119

120-
static uint32_t zend_jit_exit_point_by_addr(void *addr)
120+
static uint32_t zend_jit_exit_point_by_addr(const void *addr)
121121
{
122122
uint32_t n = (ZEND_JIT_EXIT_NUM + (ZEND_JIT_EXIT_POINTS_PER_GROUP - 1)) / ZEND_JIT_EXIT_POINTS_PER_GROUP;
123123
uint32_t i;

0 commit comments

Comments
 (0)
Please sign in to comment.