Skip to content

Commit

Permalink
Non-JIT passes a pointer to a temp zval into zend_observer_fcall_end
Browse files Browse the repository at this point in the history
Add internal variables to test output check
  • Loading branch information
segrax committed Jul 6, 2024
1 parent c8201ed commit 7b3b362
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ext/opcache/jit/zend_jit_arm64.dasc
Original file line number Diff line number Diff line change
Expand Up @@ -10942,6 +10942,7 @@ static int zend_jit_return(dasm_State **Dst, const zend_op *opline, const zend_o
if (Z_REFCOUNTED_P(zv)) {
| ADDREF_CONST zv, REG0, TMP1
}
op1_addr = ret_addr;
} else if (opline->op1_type == IS_TMP_VAR) {
| ZVAL_COPY_VALUE ret_addr, MAY_BE_ANY, op1_addr, op1_info, ZREG_REG0, ZREG_REG2, ZREG_TMP1, ZREG_TMP2, ZREG_FPR0
} else if (opline->op1_type == IS_CV) {
Expand Down Expand Up @@ -11001,7 +11002,6 @@ static int zend_jit_return(dasm_State **Dst, const zend_op *opline, const zend_o
| ZVAL_COPY_VALUE ret_addr, MAY_BE_ANY, op1_addr, op1_info, ZREG_REG0, ZREG_REG2, ZREG_TMP1, ZREG_TMP2, ZREG_FPR0
}
}

|9:
if (ZEND_OBSERVER_ENABLED) {
if (Z_MODE(op1_addr) == IS_REG) {
Expand Down
1 change: 1 addition & 0 deletions ext/opcache/jit/zend_jit_x86.dasc
Original file line number Diff line number Diff line change
Expand Up @@ -11655,6 +11655,7 @@ static int zend_jit_return(dasm_State **Dst, const zend_op *opline, const zend_o
if (Z_REFCOUNTED_P(zv)) {
| ADDREF_CONST zv, r0
}
op1_addr = ret_addr;
} else if (opline->op1_type == IS_TMP_VAR) {
| ZVAL_COPY_VALUE ret_addr, MAY_BE_ANY, op1_addr, op1_info, ZREG_R0, ZREG_R2
} else if (opline->op1_type == IS_CV) {
Expand Down
5 changes: 3 additions & 2 deletions ext/zend_test/tests/observer_retval_alter_01.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function hook(): string {
return 'hook value';
}

$res = foo('some value'); // Retval used
$res = foo('some value');
var_dump($res);
echo 'Done' . PHP_EOL;
?>
Expand All @@ -28,6 +28,7 @@ echo 'Done' . PHP_EOL;
<!-- init foo() -->
<foo>
<!-- init hook() -->
</foo:'original return value'>
</foo:'hook value'>
<!-- init var_dump() -->
string(10) "hook value"
Done

0 comments on commit 7b3b362

Please sign in to comment.