Skip to content

Commit b6b4f34

Browse files
committed
Better JIT support for FFI function calls
1 parent 86bdff5 commit b6b4f34

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

ext/opcache/jit/zend_jit_ir_ffi.c

+1
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ static int zend_jit_ffi_send_val(zend_jit_ctx *jit,
188188
&& op1_ffi_type->kind == ZEND_FFI_TYPE_POINTER
189189
&& ZEND_FFI_TYPE(type->pointer.type) == ZEND_FFI_TYPE(op1_ffi_type->pointer.type)) {
190190
ref = jit_FFI_CDATA_PTR(jit, jit_Z_PTR(jit, op1_addr));
191+
ref = ir_LOAD_A(ref); // TODO: is this always necessary ???
191192
} else if (op1_ffi_type
192193
&& op1_ffi_type->kind == ZEND_FFI_TYPE_ARRAY
193194
&& ZEND_FFI_TYPE(type->pointer.type) == ZEND_FFI_TYPE(op1_ffi_type->array.type)) {

ext/opcache/jit/zend_jit_trace.c

+13-10
Original file line numberDiff line numberDiff line change
@@ -5533,22 +5533,25 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
55335533
goto done;
55345534
case ZEND_CHECK_FUNC_ARG:
55355535
if (!JIT_G(current_frame)
5536-
|| !JIT_G(current_frame)->call
5537-
|| !JIT_G(current_frame)->call->func) {
5538-
break;
5539-
}
5540-
if (opline->op2_type == IS_CONST
5541-
|| opline->op2.num > MAX_ARG_FLAG_NUM) {
5542-
/* Named parameters not supported in JIT */
5543-
TRACE_FRAME_SET_LAST_SEND_UNKNOWN(JIT_G(current_frame)->call);
5536+
|| !JIT_G(current_frame)->call) {
55445537
break;
55455538
}
55465539
#ifdef HAVE_FFI
55475540
if (TRACE_FRAME_FFI(JIT_G(current_frame)->call)) {
55485541
/* FFI arguments alwyas sent by value ??? */
5542+
TRACE_FRAME_SET_LAST_SEND_BY_VAL(JIT_G(current_frame)->call);
55495543
goto done;
55505544
}
55515545
#endif
5546+
if (!JIT_G(current_frame)->call->func) {
5547+
break;
5548+
}
5549+
if (opline->op2_type == IS_CONST
5550+
|| opline->op2.num > MAX_ARG_FLAG_NUM) {
5551+
/* Named parameters not supported in JIT */
5552+
TRACE_FRAME_SET_LAST_SEND_UNKNOWN(JIT_G(current_frame)->call);
5553+
break;
5554+
}
55525555
if (!zend_jit_check_func_arg(&ctx, opline)) {
55535556
goto jit_failure;
55545557
}
@@ -5986,7 +5989,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
59865989
case ZEND_FETCH_DIM_FUNC_ARG:
59875990
if (!JIT_G(current_frame)
59885991
|| !JIT_G(current_frame)->call
5989-
|| !JIT_G(current_frame)->call->func
5992+
//??? || !JIT_G(current_frame)->call->func
59905993
|| !TRACE_FRAME_IS_LAST_SEND_BY_VAL(JIT_G(current_frame)->call)) {
59915994
break;
59925995
}
@@ -6226,7 +6229,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
62266229
case ZEND_FETCH_OBJ_FUNC_ARG:
62276230
if (!JIT_G(current_frame)
62286231
|| !JIT_G(current_frame)->call
6229-
|| !JIT_G(current_frame)->call->func
6232+
//??? || !JIT_G(current_frame)->call->func
62306233
|| !TRACE_FRAME_IS_LAST_SEND_BY_VAL(JIT_G(current_frame)->call)) {
62316234
break;
62326235
}

0 commit comments

Comments
 (0)