Skip to content

Commit

Permalink
Backport JIT fix: set valid EX(opline) before calling gc_possible_roo…
Browse files Browse the repository at this point in the history
…t() (php#16858)
  • Loading branch information
dstogov authored Nov 19, 2024
1 parent fc1db70 commit 6167c64
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ext/opcache/jit/zend_jit_arm64.dasc
Original file line number Diff line number Diff line change
Expand Up @@ -1548,6 +1548,9 @@ static bool logical_immediate_p(uint64_t value, uint32_t reg_size)
|| }
| IF_GC_MAY_NOT_LEAK FCARG1x, >4, Rw(tmp_reg1), Rw(tmp_reg2)
| // gc_possible_root(Z_COUNTED_P(z))
|| if (opline) {
| SET_EX_OPLINE opline, TMP1
|| }
| EXT_CALL gc_possible_root, Rx(tmp_reg1)
|| }
|| if (cold && ((op_info) & ((MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_INDIRECT|MAY_BE_GUARD)-(MAY_BE_OBJECT|MAY_BE_RESOURCE))) != 0) {
Expand Down Expand Up @@ -5944,6 +5947,9 @@ static int zend_jit_assign_to_variable(dasm_State **Dst,
if (RC_MAY_BE_N(var_info) && (var_info & (MAY_BE_ARRAY|MAY_BE_OBJECT)) != 0) {
|4:
| IF_GC_MAY_NOT_LEAK FCARG1x, >8, TMP1w, TMP2w
if (opline) {
| SET_EX_OPLINE opline, REG0
}
| EXT_CALL gc_possible_root, REG0
if (in_cold) {
| b >8
Expand Down Expand Up @@ -5971,6 +5977,9 @@ static int zend_jit_assign_to_variable(dasm_State **Dst,
| GET_ZVAL_PTR FCARG1x, var_use_addr, TMP1
| GC_DELREF FCARG1x, TMP1w
| IF_GC_MAY_NOT_LEAK FCARG1x, >5, TMP1w, TMP2w
if (opline) {
| SET_EX_OPLINE opline, TMP1
}
| EXT_CALL gc_possible_root, TMP1
if (Z_REG(var_use_addr) != ZREG_FP) {
| ldr Rx(Z_REG(var_use_addr)), T1 // restore
Expand Down Expand Up @@ -11831,6 +11840,9 @@ static int zend_jit_bind_global(dasm_State **Dst, const zend_op *opline, uint32_
|3:
| // GC_ZVAL_CHECK_POSSIBLE_ROOT(variable_ptr)
| IF_GC_MAY_NOT_LEAK FCARG1x, >5, TMP1w, TMP2w
if (opline) {
| SET_EX_OPLINE opline, REG0
}
| EXT_CALL gc_possible_root, REG0
| b >5
}
Expand Down
12 changes: 12 additions & 0 deletions ext/opcache/jit/zend_jit_x86.dasc
Original file line number Diff line number Diff line change
Expand Up @@ -1443,6 +1443,9 @@ static size_t tsrm_tls_offset;
|1:
|| }
| IF_GC_MAY_NOT_LEAK FCARG1a, >4
|| if (opline) {
| SET_EX_OPLINE opline, r0
|| }
| // gc_possible_root(Z_COUNTED_P(z))
| EXT_CALL gc_possible_root, r0
|| }
Expand Down Expand Up @@ -6488,6 +6491,9 @@ static int zend_jit_assign_to_variable(dasm_State **Dst,
if (RC_MAY_BE_N(var_info) && (var_info & (MAY_BE_ARRAY|MAY_BE_OBJECT)) != 0) {
|4:
| IF_GC_MAY_NOT_LEAK FCARG1a, >8
if (opline) {
| SET_EX_OPLINE opline, r0
}
| EXT_CALL gc_possible_root, r0
if (in_cold) {
| jmp >8
Expand Down Expand Up @@ -6515,6 +6521,9 @@ static int zend_jit_assign_to_variable(dasm_State **Dst,
| GET_ZVAL_PTR FCARG1a, var_use_addr
| GC_DELREF FCARG1a
| IF_GC_MAY_NOT_LEAK FCARG1a, >5
if (opline) {
| SET_EX_OPLINE opline, r0
}
| EXT_CALL gc_possible_root, r0
if (Z_REG(var_use_addr) != ZREG_FP) {
| mov Ra(Z_REG(var_use_addr)), T1 // restore
Expand Down Expand Up @@ -12583,6 +12592,9 @@ static int zend_jit_bind_global(dasm_State **Dst, const zend_op *opline, uint32_
|3:
| // GC_ZVAL_CHECK_POSSIBLE_ROOT(variable_ptr)
| IF_GC_MAY_NOT_LEAK FCARG1a, >5
if (opline) {
| SET_EX_OPLINE opline, r0
}
| EXT_CALL gc_possible_root, r1
| jmp >5
}
Expand Down

0 comments on commit 6167c64

Please sign in to comment.