Skip to content

Commit f910edd

Browse files
committed
Try to fix the build for jit
1 parent 44e0350 commit f910edd

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

ext/opcache/jit/zend_jit_arm64.dasc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8765,9 +8765,12 @@ static int zend_jit_init_fcall(dasm_State **Dst, const zend_op *opline, uint32_t
87658765
| ADD_SUB_64_WITH_CONST_32 add, FCARG2x, REG2, opline->result.num, TMP1
87668766
| EXT_CALL zend_jit_find_func_helper, REG0
87678767
} else if (opline->opcode == ZEND_INIT_FCALL_BY_NAME) {
8768+
/* TODO: Actually use the precomputed stack size in the JIT For ZEND_INIT_FCALL_BY_NAME */
8769+
| MEM_ACCESS_64_WITH_UOFFSET str, FCARG1x, REG2, opline->result.num + sizeof(void*), TMP1
87688770
| LOAD_ADDR FCARG1x, Z_STR_P(zv + 1);
87698771
| ADD_SUB_64_WITH_CONST_32 add, FCARG2x, REG2, opline->result.num, TMP1
8770-
| EXT_CALL zend_jit_find_func_helper, REG0
8772+
| LOAD_ADDR CARG3, opline
8773+
| EXT_CALL zend_jit_find_func_by_namehelper, REG0
87718774
} else if (opline->opcode == ZEND_INIT_NS_FCALL_BY_NAME) {
87728775
| LOAD_ADDR FCARG1x, zv;
87738776
| ADD_SUB_64_WITH_CONST_32 add, FCARG2x, REG2, opline->result.num, TMP1

ext/opcache/jit/zend_jit_helpers.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,24 @@ static zend_function* ZEND_FASTCALL zend_jit_find_func_helper(zend_string *name,
7777
return fbc;
7878
}
7979

80+
static zend_function* ZEND_FASTCALL zend_jit_find_func_by_name_helper(zend_string *name, void **cache_slot, zend_op *opline)
81+
{
82+
zval *func = zend_hash_find_known_hash(EG(function_table), name);
83+
zend_function *fbc;
84+
85+
if (UNEXPECTED(func == NULL)) {
86+
/* When opcache.preload is used, func can be null when compiling - ext/opcache/tests/jit/bug81256.phpt */
87+
return NULL;
88+
}
89+
fbc = Z_FUNC_P(func);
90+
if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) {
91+
fbc = _zend_jit_init_func_run_time_cache(&fbc->op_array);
92+
}
93+
cache_slot[0] = fbc;
94+
cache_slot[1] = (void*)(uintptr_t)zend_vm_calc_used_stack(opline->extended_value, fbc);
95+
return fbc;
96+
}
97+
8098
static zend_function* ZEND_FASTCALL zend_jit_find_ns_func_helper(zval *func_name, void **cache_slot)
8199
{
82100
zval *func = zend_hash_find_known_hash(EG(function_table), Z_STR_P(func_name + 1));

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9350,7 +9350,17 @@ static int zend_jit_init_fcall(dasm_State **Dst, const zend_op *opline, uint32_t
93509350
} else if (opline->opcode == ZEND_INIT_FCALL_BY_NAME) {
93519351
| LOAD_ADDR FCARG1a, Z_STR_P(zv + 1);
93529352
| lea FCARG2a, aword [r2 + opline->result.num]
9353-
| EXT_CALL zend_jit_find_func_helper, r0
9353+
|.if X64
9354+
| LOAD_ADDR CARG3, opline
9355+
|.else
9356+
| lea r0, opline
9357+
| sub r4, 12
9358+
| push r0
9359+
|.endif
9360+
| EXT_CALL zend_jit_find_func_by_name_helper, r0
9361+
|.if not(X64)
9362+
| add r4, 12
9363+
|.endif
93549364
} else if (opline->opcode == ZEND_INIT_NS_FCALL_BY_NAME) {
93559365
| LOAD_ADDR FCARG1a, zv;
93569366
| lea FCARG2a, aword [r2 + opline->result.num]

0 commit comments

Comments
 (0)