@@ -559,6 +559,29 @@ static int zend_jit_trace_subtrace(zend_jit_trace_rec *trace_buffer, int start,
559559 return idx + (end - start );
560560}
561561
562+ #ifdef HAVE_FFI
563+ static zend_ffi_type * zend_jit_trace_ffi_persistent_type (zend_ffi_type * ffi_type )
564+ {
565+ if (!ZEND_FFI_TYPE_IS_OWNED (ffi_type )) {
566+ if (ffi_type -> attr & ZEND_FFI_ATTR_PERSISTENT ) {
567+ return ffi_type ;
568+ }
569+ } else {
570+ ffi_type = ZEND_FFI_TYPE (ffi_type );
571+ if (ffi_type -> kind == ZEND_FFI_TYPE_POINTER ) {
572+ ffi_type = ffi_type -> pointer .type ;
573+ if (!ZEND_FFI_TYPE_IS_OWNED (ffi_type )) {
574+ if (ffi_type -> attr & ZEND_FFI_ATTR_PERSISTENT ) {
575+ /* OWNED flag means POINTER TO */
576+ return ZEND_FFI_TYPE_MAKE_OWNED (ffi_type );
577+ }
578+ }
579+ }
580+ }
581+ return NULL ;
582+ }
583+ #endif
584+
562585/*
563586 * Trace Linking Rules
564587 * ===================
@@ -719,22 +742,11 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex,
719742 if (zend_ffi_api && ce1 == zend_ffi_api -> cdata_ce ) {
720743 zend_ffi_cdata * cdata = (zend_ffi_cdata * )Z_OBJ_P (zv );
721744 zend_ffi_type * ffi_type = cdata -> type ;
722- if (!ZEND_FFI_TYPE_IS_OWNED (ffi_type )) {
723- if (ffi_type -> attr & ZEND_FFI_ATTR_PERSISTENT ) {
724- op1_ffi_type = ffi_type ;
725- }
726- } else {
727- ffi_type = ZEND_FFI_TYPE (ffi_type );
728- if (ffi_type -> kind == ZEND_FFI_TYPE_POINTER ) {
729- ffi_type = ffi_type -> pointer .type ;
730- if (!ZEND_FFI_TYPE_IS_OWNED (ffi_type )) {
731- if (ffi_type -> attr & ZEND_FFI_ATTR_PERSISTENT ) {
732- /* OWNED flag means POINTER TO */
733- op1_ffi_type = ZEND_FFI_TYPE_MAKE_OWNED (ffi_type );
734- }
735- }
736- }
737- }
745+ op1_ffi_type = zend_jit_trace_ffi_persistent_type (ffi_type );
746+ } else if (zend_ffi_api && ce1 == zend_ffi_api -> ctype_ce ) {
747+ zend_ffi_ctype * ctype = (zend_ffi_ctype * )Z_OBJ_P (zv );
748+ zend_ffi_type * ffi_type = ctype -> type ;
749+ op1_ffi_type = zend_jit_trace_ffi_persistent_type (ffi_type );
738750 } else if (zend_ffi_api && ce1 == zend_ffi_api -> scope_ce ) {
739751 zend_ffi * ffi = (zend_ffi * )Z_OBJ_P (zv );
740752 if (ffi -> persistent && ffi -> symbols ) {
@@ -795,22 +807,11 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex,
795807 if (zend_ffi_api && ce2 == zend_ffi_api -> cdata_ce ) {
796808 zend_ffi_cdata * cdata = (zend_ffi_cdata * )Z_OBJ_P (zv );
797809 zend_ffi_type * ffi_type = cdata -> type ;
798- if (!ZEND_FFI_TYPE_IS_OWNED (ffi_type )) {
799- if (ffi_type -> attr & ZEND_FFI_ATTR_PERSISTENT ) {
800- op2_ffi_type = ffi_type ;
801- }
802- } else {
803- ffi_type = ZEND_FFI_TYPE (ffi_type );
804- if (ffi_type -> kind == ZEND_FFI_TYPE_POINTER ) {
805- ffi_type = ffi_type -> pointer .type ;
806- if (!ZEND_FFI_TYPE_IS_OWNED (ffi_type )) {
807- if (ffi_type -> attr & ZEND_FFI_ATTR_PERSISTENT ) {
808- /* OWNED flag means POINTER TO */
809- op2_ffi_type = ZEND_FFI_TYPE_MAKE_OWNED (ffi_type );
810- }
811- }
812- }
813- }
810+ op2_ffi_type = zend_jit_trace_ffi_persistent_type (ffi_type );
811+ } else if (zend_ffi_api && ce2 == zend_ffi_api -> ctype_ce ) {
812+ zend_ffi_ctype * ctype = (zend_ffi_ctype * )Z_OBJ_P (zv );
813+ zend_ffi_type * ffi_type = ctype -> type ;
814+ op2_ffi_type = zend_jit_trace_ffi_persistent_type (ffi_type );
814815 }
815816#endif
816817 }
@@ -845,22 +846,11 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex,
845846 if (zend_ffi_api && ce3 == zend_ffi_api -> cdata_ce ) {
846847 zend_ffi_cdata * cdata = (zend_ffi_cdata * )Z_OBJ_P (zv );
847848 zend_ffi_type * ffi_type = cdata -> type ;
848- if (!ZEND_FFI_TYPE_IS_OWNED (ffi_type )) {
849- if (ffi_type -> attr & ZEND_FFI_ATTR_PERSISTENT ) {
850- op3_ffi_type = ffi_type ;
851- }
852- } else {
853- ffi_type = ZEND_FFI_TYPE (ffi_type );
854- if (ffi_type -> kind == ZEND_FFI_TYPE_POINTER ) {
855- ffi_type = ffi_type -> pointer .type ;
856- if (!ZEND_FFI_TYPE_IS_OWNED (ffi_type )) {
857- if (ffi_type -> attr & ZEND_FFI_ATTR_PERSISTENT ) {
858- /* OWNED flag means POINTER TO */
859- op3_ffi_type = ZEND_FFI_TYPE_MAKE_OWNED (ffi_type );
860- }
861- }
862- }
863- }
849+ op3_ffi_type = zend_jit_trace_ffi_persistent_type (ffi_type );
850+ } else if (zend_ffi_api && ce3 == zend_ffi_api -> ctype_ce ) {
851+ zend_ffi_ctype * ctype = (zend_ffi_ctype * )Z_OBJ_P (zv );
852+ zend_ffi_type * ffi_type = ctype -> type ;
853+ op3_ffi_type = zend_jit_trace_ffi_persistent_type (ffi_type );
864854 }
865855#endif
866856 }
0 commit comments