@@ -13801,119 +13801,212 @@ static int zend_jit_ffi_write(zend_jit_ctx *jit,
13801
13801
ir_ref ptr,
13802
13802
uint32_t val_info,
13803
13803
zend_jit_addr val_addr,
13804
- zend_ffi_type *val_ffi_type)
13804
+ zend_ffi_type *val_ffi_type,
13805
+ zend_jit_addr res_addr)
13805
13806
{
13807
+ ir_ref ref = IR_UNUSED;
13808
+
13806
13809
switch (ffi_type->kind) {
13807
13810
case ZEND_FFI_TYPE_FLOAT:
13808
13811
if (val_info == MAY_BE_LONG) {
13809
- ir_STORE(ptr, ir_INT2F(jit_Z_LVAL(jit, val_addr) ));
13812
+ ref = ir_INT2F(jit_Z_LVAL(jit, val_addr));
13810
13813
} else if (val_info == MAY_BE_DOUBLE) {
13811
- ir_STORE(ptr, ir_D2F(jit_Z_DVAL(jit, val_addr) ));
13814
+ ref = ir_D2F(jit_Z_DVAL(jit, val_addr));
13812
13815
} else if (val_ffi_type && val_ffi_type->kind == ffi_type->kind) {
13813
- ir_STORE(ptr, ir_LOAD_F(jit_FFI_CDATA_PTR(jit, jit_Z_PTR(jit, val_addr) )));
13816
+ ref = ir_LOAD_F(jit_FFI_CDATA_PTR(jit, jit_Z_PTR(jit, val_addr)));
13814
13817
} else {
13815
13818
ZEND_UNREACHABLE();
13816
13819
}
13820
+ ir_STORE(ptr, ref);
13821
+ if (res_addr) {
13822
+ ref = ir_F2D(ref);
13823
+ jit_set_Z_DVAL(jit, res_addr, ref);
13824
+ if (Z_MODE(res_addr) != IS_REG) {
13825
+ jit_set_Z_TYPE_INFO(jit, res_addr, IS_DOUBLE);
13826
+ }
13827
+ }
13817
13828
break;
13818
13829
case ZEND_FFI_TYPE_DOUBLE:
13819
13830
if (val_info == MAY_BE_LONG) {
13820
- ir_STORE(ptr, ir_INT2D(jit_Z_LVAL(jit, val_addr) ));
13831
+ ref = ir_INT2D(jit_Z_LVAL(jit, val_addr));
13821
13832
} else if (val_info == MAY_BE_DOUBLE) {
13822
- ir_STORE(ptr, jit_Z_DVAL(jit, val_addr) );
13833
+ ref = jit_Z_DVAL(jit, val_addr);
13823
13834
} else if (val_ffi_type && val_ffi_type->kind == ffi_type->kind) {
13824
- ir_STORE(ptr, ir_LOAD_D(jit_FFI_CDATA_PTR(jit, jit_Z_PTR(jit, val_addr) )));
13835
+ ref = ir_LOAD_D(jit_FFI_CDATA_PTR(jit, jit_Z_PTR(jit, val_addr)));
13825
13836
} else {
13826
13837
ZEND_UNREACHABLE();
13827
13838
}
13839
+ ir_STORE(ptr, ref);
13840
+ if (res_addr) {
13841
+ jit_set_Z_DVAL(jit, res_addr, ref);
13842
+ if (Z_MODE(res_addr) != IS_REG) {
13843
+ jit_set_Z_TYPE_INFO(jit, res_addr, IS_DOUBLE);
13844
+ }
13845
+ }
13828
13846
break;
13829
13847
case ZEND_FFI_TYPE_BOOL:
13830
13848
if (val_info == MAY_BE_FALSE) {
13831
13849
ir_STORE(ptr, IR_FALSE);
13850
+ if (res_addr) {
13851
+ jit_set_Z_TYPE_INFO(jit, res_addr, IS_FALSE);
13852
+ }
13832
13853
return 1;
13833
13854
} else if (val_info == MAY_BE_TRUE) {
13834
13855
ir_STORE(ptr, IR_TRUE);
13856
+ if (res_addr) {
13857
+ jit_set_Z_TYPE_INFO(jit, res_addr, IS_TRUE);
13858
+ }
13835
13859
return 1;
13836
13860
} else if (val_info == (MAY_BE_FALSE|MAY_BE_TRUE)) {
13837
- ir_STORE(ptr, ir_SUB_U8(jit_Z_TYPE(jit, val_addr), ir_CONST_U8(IS_FALSE)));
13861
+ if (res_addr) {
13862
+ ref = jit_Z_TYPE_INFO(jit, val_addr);
13863
+ jit_set_Z_TYPE_INFO_ex(jit, res_addr, ref);
13864
+ ref = ir_TRUNC_U8(ref);
13865
+ } else {
13866
+ ref = jit_Z_TYPE(jit, val_addr);
13867
+ }
13868
+ ir_STORE(ptr, ir_SUB_U8(ref, ir_CONST_U8(IS_FALSE)));
13838
13869
return 1;
13839
13870
}
13840
13871
ZEND_FALLTHROUGH;
13841
13872
case ZEND_FFI_TYPE_UINT8:
13842
13873
if (val_info == MAY_BE_LONG) {
13843
- ir_STORE(ptr, ir_TRUNC_U8(jit_Z_LVAL(jit, val_addr) ));
13874
+ ref = ir_TRUNC_U8(jit_Z_LVAL(jit, val_addr));
13844
13875
} else if (val_ffi_type && val_ffi_type->kind == ffi_type->kind) {
13845
- ir_STORE(ptr, ir_LOAD_U8(jit_FFI_CDATA_PTR(jit, jit_Z_PTR(jit, val_addr) )));
13876
+ ref = ir_LOAD_U8(jit_FFI_CDATA_PTR(jit, jit_Z_PTR(jit, val_addr)));
13846
13877
} else {
13847
13878
ZEND_UNREACHABLE();
13848
13879
}
13880
+ ir_STORE(ptr, ref);
13881
+ if (res_addr) {
13882
+ ref = ir_ZEXT_L(ref);
13883
+ jit_set_Z_LVAL(jit, res_addr, ref);
13884
+ if (Z_MODE(res_addr) != IS_REG) {
13885
+ jit_set_Z_TYPE_INFO(jit, res_addr, IS_LONG);
13886
+ }
13887
+ }
13849
13888
break;
13850
13889
case ZEND_FFI_TYPE_SINT8:
13851
13890
case ZEND_FFI_TYPE_CHAR:
13852
13891
if (val_info == MAY_BE_LONG) {
13853
- ir_STORE(ptr, ir_TRUNC_I8(jit_Z_LVAL(jit, val_addr) ));
13892
+ ref = ir_TRUNC_I8(jit_Z_LVAL(jit, val_addr));
13854
13893
} else if (val_ffi_type && val_ffi_type->kind == ffi_type->kind) {
13855
- ir_STORE(ptr, ir_LOAD_I8(jit_FFI_CDATA_PTR(jit, jit_Z_PTR(jit, val_addr) )));
13894
+ ref = ir_LOAD_I8(jit_FFI_CDATA_PTR(jit, jit_Z_PTR(jit, val_addr)));
13856
13895
} else {
13857
13896
ZEND_UNREACHABLE();
13858
13897
}
13898
+ ir_STORE(ptr, ref);
13899
+ if (res_addr) {
13900
+ ref = ir_SEXT_L(ref);
13901
+ jit_set_Z_LVAL(jit, res_addr, ref);
13902
+ if (Z_MODE(res_addr) != IS_REG) {
13903
+ jit_set_Z_TYPE_INFO(jit, res_addr, IS_LONG);
13904
+ }
13905
+ }
13859
13906
break;
13860
13907
case ZEND_FFI_TYPE_UINT16:
13861
13908
if (val_info == MAY_BE_LONG) {
13862
- ir_STORE(ptr, ir_TRUNC_U16(jit_Z_LVAL(jit, val_addr) ));
13909
+ ref = ir_TRUNC_U16(jit_Z_LVAL(jit, val_addr));
13863
13910
} else if (val_ffi_type && val_ffi_type->kind == ffi_type->kind) {
13864
- ir_STORE(ptr, ir_LOAD_U16(jit_FFI_CDATA_PTR(jit, jit_Z_PTR(jit, val_addr) )));
13911
+ ref = ir_LOAD_U16(jit_FFI_CDATA_PTR(jit, jit_Z_PTR(jit, val_addr)));
13865
13912
} else {
13866
13913
ZEND_UNREACHABLE();
13867
13914
}
13915
+ ir_STORE(ptr, ref);
13916
+ if (res_addr) {
13917
+ ref = ir_ZEXT_L(ref);
13918
+ jit_set_Z_LVAL(jit, res_addr, ref);
13919
+ if (Z_MODE(res_addr) != IS_REG) {
13920
+ jit_set_Z_TYPE_INFO(jit, res_addr, IS_LONG);
13921
+ }
13922
+ }
13868
13923
break;
13869
13924
case ZEND_FFI_TYPE_SINT16:
13870
13925
if (val_info == MAY_BE_LONG) {
13871
- ir_STORE(ptr, ir_TRUNC_I16(jit_Z_LVAL(jit, val_addr) ));
13926
+ ref = ir_TRUNC_I16(jit_Z_LVAL(jit, val_addr));
13872
13927
} else if (val_ffi_type && val_ffi_type->kind == ffi_type->kind) {
13873
- ir_STORE(ptr, ir_LOAD_I16(jit_FFI_CDATA_PTR(jit, jit_Z_PTR(jit, val_addr) )));
13928
+ ref = ir_LOAD_I16(jit_FFI_CDATA_PTR(jit, jit_Z_PTR(jit, val_addr)));
13874
13929
} else {
13875
13930
ZEND_UNREACHABLE();
13876
13931
}
13932
+ ir_STORE(ptr, ref);
13933
+ if (res_addr) {
13934
+ ref = ir_SEXT_L(ref);
13935
+ jit_set_Z_LVAL(jit, res_addr, ref);
13936
+ if (Z_MODE(res_addr) != IS_REG) {
13937
+ jit_set_Z_TYPE_INFO(jit, res_addr, IS_LONG);
13938
+ }
13939
+ }
13877
13940
break;
13878
13941
#ifdef ZEND_ENABLE_ZVAL_LONG64
13879
13942
case ZEND_FFI_TYPE_UINT32:
13880
13943
if (val_info == MAY_BE_LONG) {
13881
- ir_STORE(ptr, ir_TRUNC_U32(jit_Z_LVAL(jit, val_addr) ));
13944
+ ref = ir_TRUNC_U32(jit_Z_LVAL(jit, val_addr));
13882
13945
} else if (val_ffi_type && val_ffi_type->kind == ffi_type->kind) {
13883
- ir_STORE(ptr, ir_LOAD_U32(jit_FFI_CDATA_PTR(jit, jit_Z_PTR(jit, val_addr) )));
13946
+ ref = ir_LOAD_U32(jit_FFI_CDATA_PTR(jit, jit_Z_PTR(jit, val_addr)));
13884
13947
} else {
13885
13948
ZEND_UNREACHABLE();
13886
13949
}
13950
+ ir_STORE(ptr, ref);
13951
+ if (res_addr) {
13952
+ ref = ir_ZEXT_L(ref);
13953
+ jit_set_Z_LVAL(jit, res_addr, ref);
13954
+ if (Z_MODE(res_addr) != IS_REG) {
13955
+ jit_set_Z_TYPE_INFO(jit, res_addr, IS_LONG);
13956
+ }
13957
+ }
13887
13958
break;
13888
13959
case ZEND_FFI_TYPE_SINT32:
13889
13960
if (val_info == MAY_BE_LONG) {
13890
- ir_STORE(ptr, ir_TRUNC_I32(jit_Z_LVAL(jit, val_addr) ));
13961
+ ref = ir_TRUNC_I32(jit_Z_LVAL(jit, val_addr));
13891
13962
} else if (val_ffi_type && val_ffi_type->kind == ffi_type->kind) {
13892
- ir_STORE(ptr, ir_LOAD_I32(jit_FFI_CDATA_PTR(jit, jit_Z_PTR(jit, val_addr) )));
13963
+ ref = ir_LOAD_I32(jit_FFI_CDATA_PTR(jit, jit_Z_PTR(jit, val_addr)));
13893
13964
} else {
13894
13965
ZEND_UNREACHABLE();
13895
13966
}
13967
+ ir_STORE(ptr, ref);
13968
+ if (res_addr) {
13969
+ ref = ir_SEXT_L(ref);
13970
+ jit_set_Z_LVAL(jit, res_addr, ref);
13971
+ if (Z_MODE(res_addr) != IS_REG) {
13972
+ jit_set_Z_TYPE_INFO(jit, res_addr, IS_LONG);
13973
+ }
13974
+ }
13896
13975
break;
13897
13976
case ZEND_FFI_TYPE_UINT64:
13898
13977
case ZEND_FFI_TYPE_SINT64:
13899
13978
if (val_info == MAY_BE_LONG) {
13900
- ir_STORE(ptr, jit_Z_LVAL(jit, val_addr) );
13979
+ ref = jit_Z_LVAL(jit, val_addr);
13901
13980
} else if (val_ffi_type && val_ffi_type->kind == ffi_type->kind) {
13902
- ir_STORE(ptr, ir_LOAD_I64(jit_FFI_CDATA_PTR(jit, jit_Z_PTR(jit, val_addr) )));
13981
+ ref = ir_LOAD_I64(jit_FFI_CDATA_PTR(jit, jit_Z_PTR(jit, val_addr)));
13903
13982
} else {
13904
13983
ZEND_UNREACHABLE();
13905
13984
}
13985
+ ir_STORE(ptr, ref);
13986
+ if (res_addr) {
13987
+ jit_set_Z_LVAL(jit, res_addr, ref);
13988
+ if (Z_MODE(res_addr) != IS_REG) {
13989
+ jit_set_Z_TYPE_INFO(jit, res_addr, IS_LONG);
13990
+ }
13991
+ }
13906
13992
break;
13907
13993
#else
13908
13994
case ZEND_FFI_TYPE_UINT32:
13909
13995
case ZEND_FFI_TYPE_SINT32:
13910
13996
if (val_info == MAY_BE_LONG) {
13911
- ir_STORE(ptr, jit_Z_LVAL(jit, val_addr) );
13997
+ ref = jit_Z_LVAL(jit, val_addr);
13912
13998
} else if (val_ffi_type && val_ffi_type->kind == ffi_type->kind) {
13913
- ir_STORE(ptr, ir_LOAD_I32(jit_FFI_CDATA_PTR(jit, jit_Z_PTR(jit, val_addr) )));
13999
+ ref = ir_LOAD_I32(jit_FFI_CDATA_PTR(jit, jit_Z_PTR(jit, val_addr)));
13914
14000
} else {
13915
14001
ZEND_UNREACHABLE();
13916
14002
}
14003
+ ir_STORE(ptr, ref);
14004
+ if (res_addr) {
14005
+ jit_set_Z_LVAL(jit, res_addr, ref);
14006
+ if (Z_MODE(res_addr) != IS_REG) {
14007
+ jit_set_Z_TYPE_INFO(jit, res_addr, IS_LONG);
14008
+ }
14009
+ }
13917
14010
break;
13918
14011
#endif
13919
14012
default:
@@ -13968,12 +14061,12 @@ static int zend_jit_ffi_assign_dim(zend_jit_ctx *jit,
13968
14061
13969
14062
ir_ref ptr = ir_ADD_A(cdata_ref, ir_MUL_L(jit_Z_LVAL(jit, op2_addr), ir_CONST_LONG(el_type->size)));
13970
14063
13971
- if (!zend_jit_ffi_write(jit, el_type, ptr, val_info, val_addr, val_ffi_type)) {
14064
+ ZEND_ASSERT(!res_addr || RETURN_VALUE_USED(opline));
14065
+
14066
+ if (!zend_jit_ffi_write(jit, el_type, ptr, val_info, val_addr, val_ffi_type, res_addr)) {
13972
14067
return 0;
13973
14068
}
13974
14069
13975
- ZEND_ASSERT(!res_addr);
13976
-
13977
14070
return 1;
13978
14071
}
13979
14072
#endif
@@ -15479,12 +15572,12 @@ static int zend_jit_ffi_assign_obj(zend_jit_ctx *jit,
15479
15572
ir_ref cdata_ref = ir_LOAD_A(ir_ADD_OFFSET(obj_ref, offsetof(zend_ffi_cdata, ptr)));
15480
15573
ir_ref ptr = ir_ADD_A(cdata_ref, ir_CONST_LONG(field->offset));
15481
15574
15482
- if (!zend_jit_ffi_write(jit, field_type, ptr, val_info, val_addr, val_ffi_type)) {
15575
+ ZEND_ASSERT(!res_addr || RETURN_VALUE_USED(opline));
15576
+
15577
+ if (!zend_jit_ffi_write(jit, field_type, ptr, val_info, val_addr, val_ffi_type, res_addr)) {
15483
15578
return 0;
15484
15579
}
15485
15580
15486
- ZEND_ASSERT(!res_addr);
15487
-
15488
15581
if (!op1_indirect) {
15489
15582
jit_FREE_OP(jit, opline->op1_type, opline->op1, op1_info, opline);
15490
15583
}
@@ -15524,13 +15617,13 @@ static int zend_jit_ffi_assign_sym(zend_jit_ctx *jit,
15524
15617
}
15525
15618
}
15526
15619
15620
+ ZEND_ASSERT(!res_addr || RETURN_VALUE_USED(opline));
15621
+
15527
15622
ir_ref ptr = ir_CONST_ADDR(sym->addr);
15528
- if (!zend_jit_ffi_write(jit, sym_type, ptr, val_info, val_addr, val_ffi_type)) {
15623
+ if (!zend_jit_ffi_write(jit, sym_type, ptr, val_info, val_addr, val_ffi_type, res_addr )) {
15529
15624
return 0;
15530
15625
}
15531
15626
15532
- ZEND_ASSERT(!res_addr);
15533
-
15534
15627
if (!op1_indirect) {
15535
15628
jit_FREE_OP(jit, opline->op1_type, opline->op1, op1_info, opline);
15536
15629
}
0 commit comments