[GIT-PULLS] [php-src] PR #22743: Defer object destructors to the next VM safepoint

[email protected] (iliaal)
Newsgroups php.git-pulls
Message-ID <[email protected]>
Pull Request: https://github.com/php/php-src/pull/22743
Author: iliaal

Object destructors now run at the next VM safepoint instead of inline at the point an object's last reference is released, so a destructor can no longer reenter the VM mid-opcode. Logical death stays synchronous: a WeakReference reads null and a WeakMap entry is gone at the drop, only the __destruct call and the free move. The flush points include every try-region boundary, so a destructor dropped inside a try stays catchable by that try at the correct nesting level; output is identical across the interpreter, tracing JIT, and function JIT.

Release callgrind shows no change on code without try/catch and under 1.5% on realistic destructor-in-try workloads; the only larger delta is a trivial try/return in a hot JIT trace, where forced opline materialization dominates and collapses once the function does real work.

This builds on the destructor deferral in arnaud-lb/php-src#31; the difference in flush placement and its effect on catchability is in a comment below.

The first commit is php/php-src#22515, the user-error-handler half of the same mechanism, in review; this stacks the destructor half on top and rebases to the single destructor commit once #22515 lands.

Fixes GH-20001
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.