@@ -494,6 +494,14 @@ static void* dasm_labels[zend_lb_MAX];
494
494
| mov aword [zv], val
495
495
|.endmacro
496
496
497
+ |.macro GET_Z_W2, reg, zv
498
+ | mov reg, dword [zv+4]
499
+ |.endmacro
500
+
501
+ |.macro SET_Z_W2, zv, reg
502
+ | mov dword [zv+4], reg
503
+ |.endmacro
504
+
497
505
|.macro GET_ZVAL_PTR, reg, addr
498
506
|| ZEND_ASSERT(Z_MODE(addr) == IS_MEM_ZVAL);
499
507
| mov reg, aword [Ra(Z_REG(addr))+Z_OFFSET(addr)]
@@ -10006,6 +10014,41 @@ static int zend_jit_return(dasm_State **Dst, const zend_op *opline, const zend_o
10006
10014
return 1;
10007
10015
}
10008
10016
10017
+ static int zend_jit_zval_copy_deref(dasm_State **Dst, zend_jit_addr res_addr, zend_jit_addr val_addr, zend_reg type_reg)
10018
+ {
10019
+ ZEND_ASSERT(type_reg == ZREG_R2);
10020
+
10021
+ |.if not(X64)
10022
+ || if (Z_REG(val_addr) == ZREG_R1) {
10023
+ | GET_ZVAL_W2 r0, val_addr
10024
+ || }
10025
+ |.endif
10026
+ | GET_ZVAL_PTR r1, val_addr
10027
+ |.if not(X64)
10028
+ || if (Z_REG(val_addr) != ZREG_R1) {
10029
+ | GET_ZVAL_W2 r0, val_addr
10030
+ || }
10031
+ |.endif
10032
+ | IF_NOT_REFCOUNTED dh, >2
10033
+ | IF_NOT_TYPE dl, IS_REFERENCE, >1
10034
+ | GET_Z_TYPE_INFO edx, r1+offsetof(zend_reference, val)
10035
+ |.if not(X64)
10036
+ | GET_Z_W2 r0, r1+offsetof(zend_reference, val)
10037
+ |.endif
10038
+ | GET_Z_PTR r1, r1+offsetof(zend_reference, val)
10039
+ | IF_NOT_REFCOUNTED dh, >2
10040
+ |1:
10041
+ | GC_ADDREF r1
10042
+ |2:
10043
+ | SET_ZVAL_PTR res_addr, r1
10044
+ |.if not(X64)
10045
+ | SET_ZVAL_W2 res_addr, r0
10046
+ |.endif
10047
+ | SET_ZVAL_TYPE_INFO res_addr, edx
10048
+
10049
+ return 1;
10050
+ }
10051
+
10009
10052
static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, uint32_t op2_info, uint32_t res_info, int may_throw)
10010
10053
{
10011
10054
zend_jit_addr op1_addr, orig_op1_addr, op2_addr, res_addr;
@@ -10174,16 +10217,10 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, cons
10174
10217
|8:
10175
10218
if (op1_info & MAY_BE_ARRAY_OF_REF) {
10176
10219
| // ZVAL_COPY_DEREF
10177
- | GET_Z_PTR r2, r0
10178
- | IF_NOT_ZVAL_REFCOUNTED val_addr, >2
10179
- | IF_NOT_ZVAL_TYPE val_addr, IS_REFERENCE, >1
10180
- | lea r0, [r2 + offsetof(zend_reference, val)]
10181
- | GET_Z_PTR r2, r0
10182
- | IF_NOT_ZVAL_REFCOUNTED val_addr, >2
10183
- |1:
10184
- | GC_ADDREF r2
10185
- |2:
10186
- | ZVAL_COPY_VALUE res_addr, -1, val_addr, MAY_BE_ANY, ZREG_R1, ZREG_R2, 1
10220
+ | GET_ZVAL_TYPE_INFO Rd(ZREG_R2), val_addr
10221
+ if (!zend_jit_zval_copy_deref(Dst, res_addr, val_addr, ZREG_R2)) {
10222
+ return 0;
10223
+ }
10187
10224
} else {
10188
10225
| // ZVAL_COPY
10189
10226
| ZVAL_COPY_VALUE res_addr, -1, val_addr, MAY_BE_ANY, ZREG_R1, ZREG_R2, 0
@@ -10805,20 +10842,9 @@ static int zend_jit_fetch_obj_read(dasm_State **Dst, const zend_op *opline, cons
10805
10842
| IF_UNDEF dl, >5
10806
10843
}
10807
10844
}
10808
- | GET_ZVAL_PTR r0, prop_addr
10809
- | IF_NOT_REFCOUNTED dh, >2
10810
- | IF_TYPE dl, IS_REFERENCE, >6
10811
- |1:
10812
- | GC_ADDREF r0
10813
- |2:
10814
- |.if X64
10815
- | SET_ZVAL_PTR res_addr, r0
10816
- |.else
10817
- | SET_ZVAL_PTR res_addr, r0
10818
- | GET_ZVAL_W2 r0, prop_addr
10819
- | SET_ZVAL_W2 res_addr, r0
10820
- |.endif
10821
- | SET_ZVAL_TYPE_INFO res_addr, edx
10845
+ if (!zend_jit_zval_copy_deref(Dst, res_addr, prop_addr, ZREG_R2)) {
10846
+ return 0;
10847
+ }
10822
10848
10823
10849
|.cold_code
10824
10850
@@ -10845,16 +10871,6 @@ static int zend_jit_fetch_obj_read(dasm_State **Dst, const zend_op *opline, cons
10845
10871
| jmp >9
10846
10872
}
10847
10873
10848
- |6:
10849
- if (offset == ZEND_WRONG_PROPERTY_OFFSET) {
10850
- | mov FCARG2a, FCARG1a
10851
- } else {
10852
- | lea FCARG2a, [FCARG1a + offset]
10853
- }
10854
- | LOAD_ZVAL_ADDR FCARG1a, res_addr
10855
- | EXT_CALL zend_jit_zval_copy_deref_helper, r0
10856
- | jmp >9
10857
-
10858
10874
if ((op1_info & ((MAY_BE_UNDEF|MAY_BE_ANY|MAY_BE_REF)- MAY_BE_OBJECT)) && JIT_G(trigger) != ZEND_JIT_ON_HOT_TRACE) {
10859
10875
|7:
10860
10876
if (opline->opcode != ZEND_FETCH_OBJ_IS) {
0 commit comments