@@ -12505,7 +12505,8 @@ static int zend_jit_ffi_fetch_dim_read(zend_jit_ctx *jit,
12505
12505
zend_ssa_range *op2_range,
12506
12506
uint32_t res_info,
12507
12507
zend_jit_addr res_addr,
12508
- zend_ffi_type *op1_ffi_type)
12508
+ zend_ffi_type *op1_ffi_type,
12509
+ zend_jit_ffi_info *ffi_info)
12509
12510
{
12510
12511
uint32_t res_type;
12511
12512
zend_ffi_type *el_type = ZEND_FFI_TYPE(op1_ffi_type->array.type);
@@ -12524,9 +12525,15 @@ static int zend_jit_ffi_fetch_dim_read(zend_jit_ctx *jit,
12524
12525
}
12525
12526
}
12526
12527
12527
- // TODO: ffi type guard ???
12528
- if (!zend_jit_ffi_type_guard(jit, opline, obj_ref, op1_ffi_type)) {
12529
- return 0;
12528
+ if (ffi_info
12529
+ && ssa_op->op1_use >= 0
12530
+ && (ffi_info[ssa_op->op1_use].type != op1_ffi_type
12531
+ || (ffi_info[ssa_op->op1_use].info & FFI_TYPE_GUARD))) {
12532
+ if (!zend_jit_ffi_type_guard(jit, opline, obj_ref, op1_ffi_type)) {
12533
+ return 0;
12534
+ }
12535
+ ffi_info[ssa_op->op1_use].info &= ~FFI_TYPE_GUARD;
12536
+ ffi_info[ssa_op->op1_use].type = op1_ffi_type;
12530
12537
}
12531
12538
12532
12539
if (!zend_jit_ffi_abc(jit, opline, op1_ffi_type, op2_info, op2_addr, op2_range)) {
@@ -13283,7 +13290,8 @@ static int zend_jit_ffi_assign_dim(zend_jit_ctx *jit,
13283
13290
zend_jit_addr op3_addr,
13284
13291
zend_jit_addr op3_def_addr,
13285
13292
zend_jit_addr res_addr,
13286
- zend_ffi_type *op1_ffi_type)
13293
+ zend_ffi_type *op1_ffi_type,
13294
+ zend_jit_ffi_info *ffi_info)
13287
13295
{
13288
13296
zend_ffi_type *el_type = ZEND_FFI_TYPE(op1_ffi_type->array.type);
13289
13297
ir_ref obj_ref = jit_Z_PTR(jit, op1_addr);
@@ -13306,9 +13314,19 @@ static int zend_jit_ffi_assign_dim(zend_jit_ctx *jit,
13306
13314
}
13307
13315
}
13308
13316
13309
- // TODO: ffi type guard ???
13310
- if (!zend_jit_ffi_type_guard(jit, opline, obj_ref, op1_ffi_type)) {
13311
- return 0;
13317
+ if (ffi_info
13318
+ && ssa_op->op1_use >= 0
13319
+ && (ffi_info[ssa_op->op1_use].type != op1_ffi_type
13320
+ || (ffi_info[ssa_op->op1_use].info & FFI_TYPE_GUARD))) {
13321
+ if (!zend_jit_ffi_type_guard(jit, opline, obj_ref, op1_ffi_type)) {
13322
+ return 0;
13323
+ }
13324
+ ffi_info[ssa_op->op1_use].info &= ~FFI_TYPE_GUARD;
13325
+ ffi_info[ssa_op->op1_use].type = op1_ffi_type;
13326
+ if (ssa_op->op1_def >= 0) {
13327
+ ffi_info[ssa_op->op1_def].info &= ~FFI_TYPE_GUARD;
13328
+ ffi_info[ssa_op->op1_def].type = op1_ffi_type;
13329
+ }
13312
13330
}
13313
13331
13314
13332
if (!zend_jit_ffi_abc(jit, opline, op1_ffi_type, op2_info, op2_addr, op2_range)) {
@@ -13797,7 +13815,8 @@ static int zend_jit_ffi_assign_dim_op(zend_jit_ctx *jit,
13797
13815
uint32_t op1_data_info,
13798
13816
zend_jit_addr op3_addr,
13799
13817
zend_ssa_range *op1_data_range,
13800
- zend_ffi_type *op1_ffi_type)
13818
+ zend_ffi_type *op1_ffi_type,
13819
+ zend_jit_ffi_info *ffi_info)
13801
13820
{
13802
13821
zend_ffi_type *el_type = ZEND_FFI_TYPE(op1_ffi_type->array.type);
13803
13822
ir_ref obj_ref = jit_Z_PTR(jit, op1_addr);
@@ -13820,9 +13839,19 @@ static int zend_jit_ffi_assign_dim_op(zend_jit_ctx *jit,
13820
13839
}
13821
13840
}
13822
13841
13823
- // TODO: ffi type guard ???
13824
- if (!zend_jit_ffi_type_guard(jit, opline, obj_ref, op1_ffi_type)) {
13825
- return 0;
13842
+ if (ffi_info
13843
+ && ssa_op->op1_use >= 0
13844
+ && (ffi_info[ssa_op->op1_use].type != op1_ffi_type
13845
+ || (ffi_info[ssa_op->op1_use].info & FFI_TYPE_GUARD))) {
13846
+ if (!zend_jit_ffi_type_guard(jit, opline, obj_ref, op1_ffi_type)) {
13847
+ return 0;
13848
+ }
13849
+ ffi_info[ssa_op->op1_use].info &= ~FFI_TYPE_GUARD;
13850
+ ffi_info[ssa_op->op1_use].type = op1_ffi_type;
13851
+ if (ssa_op->op1_def >= 0) {
13852
+ ffi_info[ssa_op->op1_def].info &= ~FFI_TYPE_GUARD;
13853
+ ffi_info[ssa_op->op1_def].type = op1_ffi_type;
13854
+ }
13826
13855
}
13827
13856
13828
13857
if (!zend_jit_ffi_abc(jit, opline, op1_ffi_type, op2_info, op2_addr, op2_range)) {
0 commit comments