@@ -13087,20 +13087,21 @@ static int zend_jit_ffi_symbols_guard(zend_jit_ctx *jit,
1308713087 return 1;
1308813088}
1308913089
13090- static int zend_jit_ffi_fetch_dim_read(zend_jit_ctx *jit,
13091- const zend_op *opline,
13092- zend_ssa *ssa,
13093- const zend_ssa_op *ssa_op,
13094- uint32_t op1_info,
13095- zend_jit_addr op1_addr,
13096- bool op1_avoid_refcounting,
13097- uint32_t op2_info,
13098- zend_jit_addr op2_addr,
13099- zend_ssa_range *op2_range,
13100- uint32_t res_info,
13101- zend_jit_addr res_addr,
13102- zend_ffi_type *op1_ffi_type,
13103- zend_jit_ffi_info *ffi_info)
13090+ static int zend_jit_ffi_fetch_dim(zend_jit_ctx *jit,
13091+ const zend_op *opline,
13092+ zend_ssa *ssa,
13093+ const zend_ssa_op *ssa_op,
13094+ uint32_t op1_info,
13095+ zend_jit_addr op1_addr,
13096+ bool op1_indirect,
13097+ bool op1_avoid_refcounting,
13098+ uint32_t op2_info,
13099+ zend_jit_addr op2_addr,
13100+ zend_ssa_range *op2_range,
13101+ uint32_t res_info,
13102+ zend_jit_addr res_addr,
13103+ zend_ffi_type *op1_ffi_type,
13104+ zend_jit_ffi_info *ffi_info)
1310413105{
1310513106 zend_ffi_type *el_type = ZEND_FFI_TYPE(op1_ffi_type->array.type);
1310613107 ir_ref obj_ref = jit_Z_PTR(jit, op1_addr);
@@ -13122,16 +13123,23 @@ static int zend_jit_ffi_fetch_dim_read(zend_jit_ctx *jit,
1312213123
1312313124 ir_ref ptr = ir_ADD_A(cdata_ref, ir_MUL_L(jit_Z_LVAL(jit, op2_addr), ir_CONST_LONG(el_type->size)));
1312413125
13125- if (!zend_jit_ffi_read(jit, el_type, ptr, res_addr)) {
13126- return 0;
13126+ if (opline->opcode == ZEND_FETCH_DIM_W || opline->opcode == ZEND_FETCH_DIM_RW) {
13127+ jit_set_Z_PTR(jit, res_addr,
13128+ ir_CALL_2(IR_ADDR, ir_CONST_FC_FUNC(zend_ffi_cdata_create),
13129+ ptr, ir_CONST_ADDR(el_type)));
13130+ jit_set_Z_TYPE_INFO(jit, res_addr, IS_OBJECT_EX);
13131+ } else {
13132+ if (!zend_jit_ffi_read(jit, el_type, ptr, res_addr)) {
13133+ return 0;
13134+ }
1312713135 }
1312813136
1312913137 if (res_info & MAY_BE_GUARD) {
1313013138 // TODO: ???
1313113139 ssa->var_info[ssa_op->result_def].type &= ~MAY_BE_GUARD;
1313213140 }
1313313141
13134- if (opline->opcode != ZEND_FETCH_LIST_R && !op1_avoid_refcounting) {
13142+ if (opline->opcode != ZEND_FETCH_LIST_R && !op1_avoid_refcounting && !op1_indirect ) {
1313513143 if (opline->op1_type & (IS_TMP_VAR|IS_VAR)) {
1313613144 jit_FREE_OP(jit, opline->op1_type, opline->op1, op1_info, opline);
1313713145 }
@@ -15005,16 +15013,23 @@ static int zend_jit_ffi_fetch_obj(zend_jit_ctx *jit,
1500515013 ir_ref cdata_ref = ir_LOAD_A(ir_ADD_OFFSET(obj_ref, offsetof(zend_ffi_cdata, ptr)));
1500615014 ir_ref ptr = ir_ADD_A(cdata_ref, ir_CONST_LONG(field->offset));
1500715015
15008- if (!zend_jit_ffi_read(jit, field_type, ptr, res_addr)) {
15009- return 0;
15016+ if (opline->opcode == ZEND_FETCH_OBJ_W) {
15017+ jit_set_Z_PTR(jit, res_addr,
15018+ ir_CALL_2(IR_ADDR, ir_CONST_FC_FUNC(zend_ffi_cdata_create),
15019+ ptr, ir_CONST_ADDR(field_type)));
15020+ jit_set_Z_TYPE_INFO(jit, res_addr, IS_OBJECT_EX);
15021+ } else {
15022+ if (!zend_jit_ffi_read(jit, field_type, ptr, res_addr)) {
15023+ return 0;
15024+ }
1501015025 }
1501115026
1501215027 if (res_info & MAY_BE_GUARD) {
1501315028 // TODO: ???
1501415029 ssa->var_info[ssa_op->result_def].type &= ~MAY_BE_GUARD;
1501515030 }
1501615031
15017- if (!op1_avoid_refcounting) {
15032+ if (!op1_avoid_refcounting && !op1_indirect ) {
1501815033 if (opline->op1_type & (IS_TMP_VAR|IS_VAR)) {
1501915034 jit_FREE_OP(jit, opline->op1_type, opline->op1, op1_info, opline);
1502015035 }
@@ -15045,16 +15060,24 @@ static int zend_jit_ffi_fetch_sym(zend_jit_ctx *jit,
1504515060 }
1504615061
1504715062 ir_ref ptr = ir_CONST_ADDR(sym->addr);
15048- if (!zend_jit_ffi_read(jit, sym_type, ptr, res_addr)) {
15049- return 0;
15063+
15064+ if (opline->opcode == ZEND_FETCH_OBJ_W) {
15065+ jit_set_Z_PTR(jit, res_addr,
15066+ ir_CALL_2(IR_ADDR, ir_CONST_FC_FUNC(zend_ffi_cdata_create),
15067+ ptr, ir_CONST_ADDR(sym_type)));
15068+ jit_set_Z_TYPE_INFO(jit, res_addr, IS_OBJECT_EX);
15069+ } else {
15070+ if (!zend_jit_ffi_read(jit, sym_type, ptr, res_addr)) {
15071+ return 0;
15072+ }
1505015073 }
1505115074
1505215075 if (res_info & MAY_BE_GUARD) {
1505315076 // TODO: ???
1505415077 ssa->var_info[ssa_op->result_def].type &= ~MAY_BE_GUARD;
1505515078 }
1505615079
15057- if (!op1_avoid_refcounting) {
15080+ if (!op1_avoid_refcounting && !op1_indirect ) {
1505815081 if (opline->op1_type & (IS_TMP_VAR|IS_VAR)) {
1505915082 jit_FREE_OP(jit, opline->op1_type, opline->op1, op1_info, opline);
1506015083 }
0 commit comments