@@ -559,6 +559,29 @@ static int zend_jit_trace_subtrace(zend_jit_trace_rec *trace_buffer, int start,
559
559
return idx + (end - start );
560
560
}
561
561
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
+
562
585
/*
563
586
* Trace Linking Rules
564
587
* ===================
@@ -719,22 +742,11 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex,
719
742
if (zend_ffi_api && ce1 == zend_ffi_api -> cdata_ce ) {
720
743
zend_ffi_cdata * cdata = (zend_ffi_cdata * )Z_OBJ_P (zv );
721
744
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 );
738
750
} else if (zend_ffi_api && ce1 == zend_ffi_api -> scope_ce ) {
739
751
zend_ffi * ffi = (zend_ffi * )Z_OBJ_P (zv );
740
752
if (ffi -> persistent && ffi -> symbols ) {
@@ -795,22 +807,11 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex,
795
807
if (zend_ffi_api && ce2 == zend_ffi_api -> cdata_ce ) {
796
808
zend_ffi_cdata * cdata = (zend_ffi_cdata * )Z_OBJ_P (zv );
797
809
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 );
814
815
}
815
816
#endif
816
817
}
@@ -845,22 +846,11 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex,
845
846
if (zend_ffi_api && ce3 == zend_ffi_api -> cdata_ce ) {
846
847
zend_ffi_cdata * cdata = (zend_ffi_cdata * )Z_OBJ_P (zv );
847
848
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 );
864
854
}
865
855
#endif
866
856
}
0 commit comments