@@ -6943,26 +6943,57 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
6943
6943
}
6944
6944
#ifdef HAVE_FFI
6945
6945
if (op1_ffi_symbols ) {
6946
- zend_ffi_symbol * sym = zend_hash_find_ptr (op1_ffi_symbols ,
6947
- Z_STR_P (RT_CONSTANT (opline , opline -> op2 )));
6948
- if (sym
6949
- && sym -> kind == ZEND_FFI_SYM_FUNC
6950
- && zend_jit_ffi_supported_func (ZEND_FFI_TYPE (sym -> type ))) {
6951
- ir_ref ffi_func_ref ;
6952
-
6953
- if (!ffi_info ) {
6954
- ffi_info = zend_arena_calloc (& CG (arena ), ssa -> vars_count , sizeof (zend_jit_ffi_info ));
6946
+ zend_string * name = Z_STR_P (RT_CONSTANT (opline , opline -> op2 ));
6947
+
6948
+ if (zend_string_equals_literal_ci (name , "type" )) {
6949
+ if (opline -> extended_value == 1
6950
+ && (p + 1 )-> op == ZEND_JIT_TRACE_INIT_CALL
6951
+ && (p + 2 )-> op == ZEND_JIT_TRACE_VM
6952
+ && ((p + 2 )-> opline -> opcode == ZEND_SEND_VAL
6953
+ || (p + 2 )-> opline -> opcode == ZEND_SEND_VAL_EX )
6954
+ && (p + 2 )-> opline -> op1_type == IS_CONST ) {
6955
+ zval * zv = RT_CONSTANT ((p + 2 )-> opline , (p + 2 )-> opline -> op1 );
6956
+
6957
+ if (Z_TYPE_P (zv ) == IS_STRING ) {
6958
+ zend_ffi_dcl * dcl = zend_ffi_api -> cache_type_get (Z_STR_P (zv ), op1_ffi_symbols );
6959
+
6960
+ if (dcl ) {
6961
+ if (!ffi_info ) {
6962
+ ffi_info = zend_arena_calloc (& CG (arena ), ssa -> vars_count , sizeof (zend_jit_ffi_info ));
6963
+ }
6964
+ if (!zend_jit_ffi_symbols_guard (& ctx , opline , ssa ,
6965
+ ssa_op -> op1_use , -1 , op1_info , op1_addr , op1_ffi_symbols , ffi_info )) {
6966
+ goto jit_failure ;
6967
+ }
6968
+ frame_flags = TRACE_FRAME_MASK_FFI | TRACE_FRAME_FFI_FUNC_TYPE ;
6969
+ frame_ffi_func_type = dcl -> type ;
6970
+ frame_ffi_func_ref = IR_UNUSED ;
6971
+ goto done ;
6972
+ }
6973
+ }
6955
6974
}
6956
- if (!zend_jit_ffi_init_call_sym (& ctx , opline , op_array , ssa , ssa_op ,
6957
- op1_info , op1_addr ,
6958
- sym ,
6959
- op1_ffi_symbols , ffi_info , & ffi_func_ref )) {
6960
- goto jit_failure ;
6975
+ } else {
6976
+ zend_ffi_symbol * sym = zend_hash_find_ptr (op1_ffi_symbols , name );
6977
+
6978
+ if (sym
6979
+ && sym -> kind == ZEND_FFI_SYM_FUNC
6980
+ && zend_jit_ffi_supported_func (ZEND_FFI_TYPE (sym -> type ))) {
6981
+ ir_ref ffi_func_ref ;
6982
+
6983
+ if (!ffi_info ) {
6984
+ ffi_info = zend_arena_calloc (& CG (arena ), ssa -> vars_count , sizeof (zend_jit_ffi_info ));
6985
+ }
6986
+ if (!zend_jit_ffi_init_call_sym (& ctx , opline , op_array , ssa , ssa_op ,
6987
+ op1_info , op1_addr ,
6988
+ sym ,
6989
+ op1_ffi_symbols , ffi_info , & ffi_func_ref )) {
6990
+ goto jit_failure ;
6991
+ }
6992
+ frame_flags = TRACE_FRAME_MASK_FFI ;
6993
+ frame_ffi_func_type = ZEND_FFI_TYPE (sym -> type );
6994
+ frame_ffi_func_ref = ffi_func_ref ;
6995
+ goto done ;
6961
6996
}
6962
- frame_flags = TRACE_FRAME_MASK_FFI ;
6963
- frame_ffi_func_type = ZEND_FFI_TYPE (sym -> type );
6964
- frame_ffi_func_ref = ffi_func_ref ;
6965
- goto done ;
6966
6997
}
6967
6998
}
6968
6999
#endif
0 commit comments