@@ -31,18 +31,20 @@ static int zend_jit_ffi_symbols_guard(zend_jit_ctx *jit,
31
31
zend_ssa * ssa ,
32
32
int use ,
33
33
int def ,
34
+ uint32_t info ,
34
35
zend_jit_addr addr ,
35
36
HashTable * ffi_symbols ,
36
37
zend_jit_ffi_info * ffi_info );
37
38
38
- static int zend_jit_ffi_guard (zend_jit_ctx * jit ,
39
- const zend_op * opline ,
40
- zend_ssa * ssa ,
41
- int use ,
42
- int def ,
43
- ir_ref ref ,
44
- zend_ffi_type * ffi_type ,
45
- zend_jit_ffi_info * ffi_info );
39
+ static ir_ref zend_jit_ffi_guard (zend_jit_ctx * jit ,
40
+ const zend_op * opline ,
41
+ zend_ssa * ssa ,
42
+ int use ,
43
+ int def ,
44
+ uint32_t info ,
45
+ zend_jit_addr addr ,
46
+ zend_ffi_type * ffi_type ,
47
+ zend_jit_ffi_info * ffi_info );
46
48
47
49
static int zend_jit_ffi_init_call_sym (zend_jit_ctx * jit ,
48
50
const zend_op * opline ,
@@ -62,7 +64,7 @@ static int zend_jit_ffi_init_call_sym(zend_jit_ctx *jit,
62
64
type = ZEND_FFI_TYPE (sym -> type );
63
65
ZEND_ASSERT (type -> kind == ZEND_FFI_TYPE_FUNC );
64
66
65
- if (!zend_jit_ffi_symbols_guard (jit , opline , ssa , ssa_op -> op1_use , -1 , op1_addr , op1_ffi_symbols , ffi_info )) {
67
+ if (!zend_jit_ffi_symbols_guard (jit , opline , ssa , ssa_op -> op1_use , -1 , op1_info , op1_addr , op1_ffi_symbols , ffi_info )) {
66
68
return 0 ;
67
69
}
68
70
@@ -92,14 +94,15 @@ static int zend_jit_ffi_init_call_obj(zend_jit_ctx *jit,
92
94
zend_jit_ffi_info * ffi_info ,
93
95
ir_ref * ffi_func_ref )
94
96
{
95
- ir_ref obj_ref = jit_Z_PTR ( jit , op2_addr ) ;
97
+ ir_ref obj_ref ;
96
98
zend_ffi_type * type ;
97
99
98
100
ZEND_ASSERT (op2_ffi_type -> kind == ZEND_FFI_TYPE_POINTER );
99
101
type = ZEND_FFI_TYPE (op2_ffi_type -> pointer .type );
100
102
ZEND_ASSERT (type -> kind == ZEND_FFI_TYPE_FUNC );
101
103
102
- if (!zend_jit_ffi_guard (jit , opline , ssa , ssa_op -> op2_use , -1 , obj_ref , op2_ffi_type , ffi_info )) {
104
+ obj_ref = zend_jit_ffi_guard (jit , opline , ssa , ssa_op -> op2_use , -1 , op2_info , op2_addr , op2_ffi_type , ffi_info );
105
+ if (!obj_ref ) {
103
106
return 0 ;
104
107
}
105
108
@@ -890,15 +893,22 @@ static int zend_jit_ffi_read(zend_jit_ctx *jit,
890
893
return 1 ;
891
894
}
892
895
893
- static int zend_jit_ffi_guard (zend_jit_ctx * jit ,
894
- const zend_op * opline ,
895
- zend_ssa * ssa ,
896
- int use ,
897
- int def ,
898
- ir_ref ref ,
899
- zend_ffi_type * ffi_type ,
900
- zend_jit_ffi_info * ffi_info )
896
+ static ir_ref zend_jit_ffi_guard (zend_jit_ctx * jit ,
897
+ const zend_op * opline ,
898
+ zend_ssa * ssa ,
899
+ int use ,
900
+ int def ,
901
+ uint32_t info ,
902
+ zend_jit_addr addr ,
903
+ zend_ffi_type * ffi_type ,
904
+ zend_jit_ffi_info * ffi_info )
901
905
{
906
+ ir_ref ref ;
907
+
908
+ /* MAY_BE_GUARD may be added by zend_jit_fetch_reference() */
909
+ ZEND_ASSERT ((info & (/*MAY_BE_GUARD|*/ MAY_BE_REF |MAY_BE_ANY |MAY_BE_UNDEF )) == MAY_BE_OBJECT );
910
+
911
+ ref = jit_Z_PTR (jit , addr );
902
912
if (ssa -> var_info
903
913
&& use >= 0
904
914
&& ssa -> var_info [use ].ce != zend_ffi_api -> cdata_ce ) {
@@ -930,20 +940,23 @@ static int zend_jit_ffi_guard(zend_jit_ctx *jit,
930
940
}
931
941
}
932
942
933
- return 1 ;
943
+ return ref ;
934
944
}
935
945
936
946
static int zend_jit_ffi_symbols_guard (zend_jit_ctx * jit ,
937
947
const zend_op * opline ,
938
948
zend_ssa * ssa ,
939
949
int use ,
940
950
int def ,
951
+ uint32_t info ,
941
952
zend_jit_addr addr ,
942
953
HashTable * ffi_symbols ,
943
954
zend_jit_ffi_info * ffi_info )
944
955
{
945
956
ir_ref ref = IR_UNUSED ;
946
957
958
+ ZEND_ASSERT ((info & (MAY_BE_GUARD |MAY_BE_REF |MAY_BE_ANY |MAY_BE_UNDEF )) == MAY_BE_OBJECT );
959
+
947
960
if (ssa -> var_info
948
961
&& use >= 0
949
962
&& ssa -> var_info [use ].ce != zend_ffi_api -> scope_ce ) {
@@ -1007,9 +1020,10 @@ static int zend_jit_ffi_fetch_dim(zend_jit_ctx *jit,
1007
1020
zend_jit_ffi_info * ffi_info )
1008
1021
{
1009
1022
zend_ffi_type * el_type = ZEND_FFI_TYPE (op1_ffi_type -> array .type );
1010
- ir_ref obj_ref = jit_Z_PTR ( jit , op1_addr ) ;
1023
+ ir_ref obj_ref ;
1011
1024
1012
- if (!zend_jit_ffi_guard (jit , opline , ssa , ssa_op -> op1_use , -1 , obj_ref , op1_ffi_type , ffi_info )) {
1025
+ obj_ref = zend_jit_ffi_guard (jit , opline , ssa , ssa_op -> op1_use , -1 , op1_info , op1_addr , op1_ffi_type , ffi_info );
1026
+ if (!obj_ref ) {
1013
1027
return 0 ;
1014
1028
}
1015
1029
@@ -1349,9 +1363,10 @@ static int zend_jit_ffi_assign_dim(zend_jit_ctx *jit,
1349
1363
zend_jit_ffi_info * ffi_info )
1350
1364
{
1351
1365
zend_ffi_type * el_type = ZEND_FFI_TYPE (op1_ffi_type -> array .type );
1352
- ir_ref obj_ref = jit_Z_PTR ( jit , op1_addr ) ;
1366
+ ir_ref obj_ref ;
1353
1367
1354
- if (!zend_jit_ffi_guard (jit , opline , ssa , ssa_op -> op1_use , ssa_op -> op1_def , obj_ref , op1_ffi_type , ffi_info )) {
1368
+ obj_ref = zend_jit_ffi_guard (jit , opline , ssa , ssa_op -> op1_use , ssa_op -> op1_def , op1_info , op1_addr , op1_ffi_type , ffi_info );
1369
+ if (!obj_ref ) {
1355
1370
return 0 ;
1356
1371
}
1357
1372
@@ -1596,9 +1611,10 @@ static int zend_jit_ffi_assign_dim_op(zend_jit_ctx *jit,
1596
1611
zend_jit_ffi_info * ffi_info )
1597
1612
{
1598
1613
zend_ffi_type * el_type = ZEND_FFI_TYPE (op1_ffi_type -> array .type );
1599
- ir_ref obj_ref = jit_Z_PTR ( jit , op1_addr ) ;
1614
+ ir_ref obj_ref ;
1600
1615
1601
- if (!zend_jit_ffi_guard (jit , opline , ssa , ssa_op -> op1_use , ssa_op -> op1_def , obj_ref , op1_ffi_type , ffi_info )) {
1616
+ obj_ref = zend_jit_ffi_guard (jit , opline , ssa , ssa_op -> op1_use , ssa_op -> op1_def , op1_info , op1_addr , op1_ffi_type , ffi_info );
1617
+ if (!obj_ref ) {
1602
1618
return 0 ;
1603
1619
}
1604
1620
@@ -1644,9 +1660,10 @@ static int zend_jit_ffi_fetch_obj(zend_jit_ctx *jit,
1644
1660
{
1645
1661
uint32_t res_info = RES_INFO ();
1646
1662
zend_ffi_type * field_type = ZEND_FFI_TYPE (field -> type );
1647
- ir_ref obj_ref = jit_Z_PTR ( jit , op1_addr ) ;
1663
+ ir_ref obj_ref ;
1648
1664
1649
- if (!zend_jit_ffi_guard (jit , opline , ssa , ssa_op -> op1_use , -1 , obj_ref , op1_ffi_type , ffi_info )) {
1665
+ obj_ref = zend_jit_ffi_guard (jit , opline , ssa , ssa_op -> op1_use , -1 , op1_info , op1_addr , op1_ffi_type , ffi_info );
1666
+ if (!obj_ref ) {
1650
1667
return 0 ;
1651
1668
}
1652
1669
@@ -1692,9 +1709,10 @@ static int zend_jit_ffi_fetch_val(zend_jit_ctx *jit,
1692
1709
zend_jit_ffi_info * ffi_info )
1693
1710
{
1694
1711
uint32_t res_info = RES_INFO ();
1695
- ir_ref obj_ref = jit_Z_PTR ( jit , op1_addr ) ;
1712
+ ir_ref obj_ref ;
1696
1713
1697
- if (!zend_jit_ffi_guard (jit , opline , ssa , ssa_op -> op1_use , -1 , obj_ref , op1_ffi_type , ffi_info )) {
1714
+ obj_ref = zend_jit_ffi_guard (jit , opline , ssa , ssa_op -> op1_use , -1 , op1_info , op1_addr , op1_ffi_type , ffi_info );
1715
+ if (!obj_ref ) {
1698
1716
return 0 ;
1699
1717
}
1700
1718
@@ -1742,7 +1760,7 @@ static int zend_jit_ffi_fetch_sym(zend_jit_ctx *jit,
1742
1760
uint32_t res_info = RES_INFO ();
1743
1761
zend_ffi_type * sym_type = ZEND_FFI_TYPE (sym -> type );
1744
1762
1745
- if (!zend_jit_ffi_symbols_guard (jit , opline , ssa , ssa_op -> op1_use , -1 , op1_addr , op1_ffi_symbols , ffi_info )) {
1763
+ if (!zend_jit_ffi_symbols_guard (jit , opline , ssa , ssa_op -> op1_use , -1 , op1_info , op1_addr , op1_ffi_symbols , ffi_info )) {
1746
1764
return 0 ;
1747
1765
}
1748
1766
@@ -1791,9 +1809,10 @@ static int zend_jit_ffi_assign_obj(zend_jit_ctx *jit,
1791
1809
zend_jit_ffi_info * ffi_info )
1792
1810
{
1793
1811
zend_ffi_type * field_type = ZEND_FFI_TYPE (field -> type );
1794
- ir_ref obj_ref = jit_Z_PTR ( jit , op1_addr ) ;
1812
+ ir_ref obj_ref ;
1795
1813
1796
- if (!zend_jit_ffi_guard (jit , opline , ssa , ssa_op -> op1_use , ssa_op -> op1_def , obj_ref , op1_ffi_type , ffi_info )) {
1814
+ obj_ref = zend_jit_ffi_guard (jit , opline , ssa , ssa_op -> op1_use , ssa_op -> op1_def , op1_info , op1_addr , op1_ffi_type , ffi_info );
1815
+ if (!obj_ref ) {
1797
1816
return 0 ;
1798
1817
}
1799
1818
@@ -1840,9 +1859,10 @@ static int zend_jit_ffi_assign_val(zend_jit_ctx *jit,
1840
1859
zend_ffi_type * val_ffi_type ,
1841
1860
zend_jit_ffi_info * ffi_info )
1842
1861
{
1843
- ir_ref obj_ref = jit_Z_PTR ( jit , op1_addr ) ;
1862
+ ir_ref obj_ref ;
1844
1863
1845
- if (!zend_jit_ffi_guard (jit , opline , ssa , ssa_op -> op1_use , ssa_op -> op1_def , obj_ref , op1_ffi_type , ffi_info )) {
1864
+ obj_ref = zend_jit_ffi_guard (jit , opline , ssa , ssa_op -> op1_use , ssa_op -> op1_def , op1_info , op1_addr , op1_ffi_type , ffi_info );
1865
+ if (!obj_ref ) {
1846
1866
return 0 ;
1847
1867
}
1848
1868
@@ -1891,7 +1911,7 @@ static int zend_jit_ffi_assign_sym(zend_jit_ctx *jit,
1891
1911
{
1892
1912
zend_ffi_type * sym_type = ZEND_FFI_TYPE (sym -> type );
1893
1913
1894
- if (!zend_jit_ffi_symbols_guard (jit , opline , ssa , ssa_op -> op1_use , ssa_op -> op1_def , op1_addr , op1_ffi_symbols , ffi_info )) {
1914
+ if (!zend_jit_ffi_symbols_guard (jit , opline , ssa , ssa_op -> op1_use , ssa_op -> op1_def , op1_info , op1_addr , op1_ffi_symbols , ffi_info )) {
1895
1915
return 0 ;
1896
1916
}
1897
1917
@@ -1935,9 +1955,10 @@ static int zend_jit_ffi_assign_obj_op(zend_jit_ctx *jit,
1935
1955
zend_jit_ffi_info * ffi_info )
1936
1956
{
1937
1957
zend_ffi_type * field_type = ZEND_FFI_TYPE (field -> type );
1938
- ir_ref obj_ref = jit_Z_PTR ( jit , op1_addr ) ;
1958
+ ir_ref obj_ref ;
1939
1959
1940
- if (!zend_jit_ffi_guard (jit , opline , ssa , ssa_op -> op1_use , ssa_op -> op1_def , obj_ref , op1_ffi_type , ffi_info )) {
1960
+ obj_ref = zend_jit_ffi_guard (jit , opline , ssa , ssa_op -> op1_use , ssa_op -> op1_def , op1_info , op1_addr , op1_ffi_type , ffi_info );
1961
+ if (!obj_ref ) {
1941
1962
return 0 ;
1942
1963
}
1943
1964
@@ -1971,9 +1992,10 @@ static int zend_jit_ffi_assign_val_op(zend_jit_ctx *jit,
1971
1992
zend_ffi_type * op1_ffi_type ,
1972
1993
zend_jit_ffi_info * ffi_info )
1973
1994
{
1974
- ir_ref obj_ref = jit_Z_PTR ( jit , op1_addr ) ;
1995
+ ir_ref obj_ref ;
1975
1996
1976
- if (!zend_jit_ffi_guard (jit , opline , ssa , ssa_op -> op1_use , ssa_op -> op1_def , obj_ref , op1_ffi_type , ffi_info )) {
1997
+ obj_ref = zend_jit_ffi_guard (jit , opline , ssa , ssa_op -> op1_use , ssa_op -> op1_def , op1_info , op1_addr , op1_ffi_type , ffi_info );
1998
+ if (!obj_ref ) {
1977
1999
return 0 ;
1978
2000
}
1979
2001
@@ -2009,7 +2031,7 @@ static int zend_jit_ffi_assign_sym_op(zend_jit_ctx *jit,
2009
2031
{
2010
2032
zend_ffi_type * sym_type = ZEND_FFI_TYPE (sym -> type );
2011
2033
2012
- if (!zend_jit_ffi_symbols_guard (jit , opline , ssa , ssa_op -> op1_use , ssa_op -> op1_def , op1_addr , op1_ffi_symbols , ffi_info )) {
2034
+ if (!zend_jit_ffi_symbols_guard (jit , opline , ssa , ssa_op -> op1_use , ssa_op -> op1_def , op1_info , op1_addr , op1_ffi_symbols , ffi_info )) {
2013
2035
return 0 ;
2014
2036
}
2015
2037
@@ -2249,9 +2271,10 @@ static int zend_jit_ffi_incdec_obj(zend_jit_ctx *jit,
2249
2271
zend_jit_ffi_info * ffi_info )
2250
2272
{
2251
2273
zend_ffi_type * field_type = ZEND_FFI_TYPE (field -> type );
2252
- ir_ref obj_ref = jit_Z_PTR ( jit , op1_addr ) ;
2274
+ ir_ref obj_ref ;
2253
2275
2254
- if (!zend_jit_ffi_guard (jit , opline , ssa , ssa_op -> op1_use , ssa_op -> op1_def , obj_ref , op1_ffi_type , ffi_info )) {
2276
+ obj_ref = zend_jit_ffi_guard (jit , opline , ssa , ssa_op -> op1_use , ssa_op -> op1_def , op1_info , op1_addr , op1_ffi_type , ffi_info );
2277
+ if (!obj_ref ) {
2255
2278
return 0 ;
2256
2279
}
2257
2280
@@ -2281,9 +2304,10 @@ static int zend_jit_ffi_incdec_val(zend_jit_ctx *jit,
2281
2304
zend_ffi_type * op1_ffi_type ,
2282
2305
zend_jit_ffi_info * ffi_info )
2283
2306
{
2284
- ir_ref obj_ref = jit_Z_PTR ( jit , op1_addr ) ;
2307
+ ir_ref obj_ref ;
2285
2308
2286
- if (!zend_jit_ffi_guard (jit , opline , ssa , ssa_op -> op1_use , ssa_op -> op1_def , obj_ref , op1_ffi_type , ffi_info )) {
2309
+ obj_ref = zend_jit_ffi_guard (jit , opline , ssa , ssa_op -> op1_use , ssa_op -> op1_def , op1_info , op1_addr , op1_ffi_type , ffi_info );
2310
+ if (!obj_ref ) {
2287
2311
return 0 ;
2288
2312
}
2289
2313
@@ -2315,7 +2339,7 @@ static int zend_jit_ffi_incdec_sym(zend_jit_ctx *jit,
2315
2339
{
2316
2340
zend_ffi_type * sym_type = ZEND_FFI_TYPE (sym -> type );
2317
2341
2318
- if (!zend_jit_ffi_symbols_guard (jit , opline , ssa , ssa_op -> op1_use , ssa_op -> op1_def , op1_addr , op1_ffi_symbols , ffi_info )) {
2342
+ if (!zend_jit_ffi_symbols_guard (jit , opline , ssa , ssa_op -> op1_use , ssa_op -> op1_def , op1_info , op1_addr , op1_ffi_symbols , ffi_info )) {
2319
2343
return 0 ;
2320
2344
}
2321
2345
0 commit comments