Commit graph

33 commits

Author SHA1 Message Date
Niels Dossche
8b5231388c
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-19065: Long match statement can segfault compiler during recursive SSA renaming
2025-08-11 23:05:50 +02:00
Niels Dossche
9b86533ce4
Fix GH-19065: Long match statement can segfault compiler during recursive SSA renaming
On some systems, like Alpine, the thread stack size is small by default.
The last step of SSA construction involves variable renaming that is
recursive, and also makes copies of their version of the renamed
variables on the stack. This combination causes a stack overflow during
compilation on Alpine. Triggerable for example with very long match
statements.

A stop-gap solution would be to use heap allocated arrays for the
renamed variable list, but that would only delay the error as increasing
the number of match arms increases the depth of the dominator tree, and
will eventually run into the same issue.

This patch transforms the algorithm into an iterative one.
There are two states stored in a worklist stack: positive numbers
indicate that the block still needs to undergo variable renaming.
Negative numbers indicate that the block and its dominated children are
already renamed. Because 0 is also a valid block number, we bias the
block numbers by adding 1.
To restore to the right variant when backtracking the "recursive" step,
we index into an array pointing to the different variable renaming
variants.

Closes GH-19083.
2025-08-11 23:05:21 +02:00
Ilija Tovilo
631bc81607
Implement stackless internal function calls
Co-authored-by: Dmitry Stogov <dmitry@zend.com>

Closes GH-12461
2024-02-06 17:42:28 +01:00
Ilija Tovilo
6f6289caca
Avoid new SSA var for ASSIGN_OBJ_REF without RC inference
Previously, this variable was necessary because of auto-vivification on
UNDEF/null/false. It's now only used for RC inference, as auto-vivification has
been removed.

This implicitly solves an inference problem for $obj->bar &= $obj; where we get
a new variable for both literal references to $obj, with the first one getting
the RCn flag, and the second one getting the MAY_BE_REFERENCE flag. Thus, the
first variable will be missing the reference type, causing a false-positive type
inference warning.

If we want to verify RC inference at some point we'll need a better solution.

Closes GH-13233
2024-01-24 11:30:49 +01:00
Ilija Tovilo
0b0cec5b8a
Fix clang warning
has_range_constraint should can be a bool, remove unused visited field.

Closes GH-11729
2023-07-18 00:49:13 +02:00
Ilija Tovilo
0b1d750d91
Allow arbitrary expressions in static variable initializer
Closes GH-9301
2023-05-24 20:17:31 +02:00
Christoph M. Becker
2f4973fd88
Revert GH-10279
Cf. <https://github.com/php/php-src/pull/10220#issuecomment-1383739816>.

This reverts commit 45a128c9de.
This reverts commit 1eb71c3f15.
This reverts commit 492523a779.
This reverts commit c7a4633891.
This reverts commit 308adb915c.
This reverts commit cd27d5e07f.
This reverts commit c5933409b4.
This reverts commit 46371f4eb3.
This reverts commit 623e2e9fc6.
This reverts commit e7434c1247.
This reverts commit d28d323ca2.
This reverts commit 1a067b84ee.
This reverts commit a55c0c5fc3.
This reverts commit b5aeb3a4d4.
This reverts commit f061a035e4.
This reverts commit b088575119.
This reverts commit b1d48774a7.
This reverts commit 94f9a20ce6.
This reverts commit 4831e48708.
This reverts commit cd985de190.
This reverts commit 9521d21681.
This reverts commit d6136151e9.
2023-01-16 12:25:59 +01:00
Max Kellermann
d28d323ca2 Zend/Optimizer/zend_ssa: include cleanup 2023-01-12 15:12:45 +00:00
Max Kellermann
5ea9a7e219 Zend/Optimizer/zend_ssa: make pointer const 2023-01-04 12:59:16 +00:00
Dmitry Stogov
7496a400aa Fix SSA construction and type inference
Fixes oss-fuzz #51476
2022-09-19 15:45:34 +03:00
Nikita Popov
4543cd32ae Remove JMPZNZ opcode
While JMPZNZ can avoid execution of a separate JMP opcode in some
cases, it also prevents smart branch optimization, so creating
JMPZNZ may actually have a negative effect. It also adds additional
complexity for optimizations.

Drop JMPZNZ in favor of JMPZ+JMP or JMPNZ+JMP.

Closes GH-7857.
2022-01-10 22:07:10 +01:00
Dmitry Stogov
eb43f8a4f8 Eliminate more VERIFY_RETURN_TYPE instructions 2021-12-27 23:40:21 +03:00
Nikita Popov
2cf93032ee Sink op_array scope case into get_class_entry()
This handles references to the current class through its name
rather than self (and for cases where is is not linked yet and
thus not covered by the context lookup). Rather than handling this
only for FETCH_CLASS_CONSTANT optimization, integrate this into
the generic get_class_entry() utility.
2021-12-25 21:51:29 +01:00
Dmitry Stogov
bdcef24f4b Merge branch 'PHP-8.1'
* PHP-8.1:
  Remove range inference for booleans.
2021-12-10 14:44:21 +03:00
Dmitry Stogov
cfcee97ad6 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Remove range inference for booleans.
2021-12-10 14:33:36 +03:00
Dmitry Stogov
923bd51599 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix SCDF cleanup of unused basic block, kept only because of FREE of a loop var
2021-12-01 18:04:47 +03:00
Dmitry Stogov
c3766c08f4 Fix SCDF cleanup of unused basic block, kept only because of FREE of a loop var
Fixes oss-fuzz #41516
2021-12-01 18:03:08 +03:00
Dmitry Stogov
b7f19f2674 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fixed incorrect reference counter inference
2021-11-08 20:55:09 +03:00
Dmitry Stogov
9bd490dc33 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed incorrect reference counter inference
2021-11-08 20:54:45 +03:00
Dmitry Stogov
2f5cc67eba Merge branch 'PHP-8.1'
* PHP-8.1:
  Fixed SSA construction
2021-10-05 16:16:38 +03:00
Dmitry Stogov
41dc14792e Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed SSA construction
2021-10-05 16:14:58 +03:00
George Peter Banyard
44bc955619 Check against FAILURE instead of different then SUCCESS 2021-09-21 11:35:53 +01:00
George Peter Banyard
87ea3c1f4c Voidify zend_ssa_unlink_use_chain()
It always returned 1 or threw an assertion failure

Also drop else branch by moving it to the main scope
2021-09-21 11:35:53 +01:00
George Peter Banyard
35dfdd9b1b Voidify zend_ssa_compute_use_def_chains()
It always returned SUCCESS
2021-09-21 11:35:53 +01:00
George Peter Banyard
57e4bd2be3 Voidify zend_build_dfg()
It always returned SUCCESS
2021-09-21 11:35:53 +01:00
George Peter Banyard
53d5420d49 Use more appropriate types in Optimizer
Mainly using zend_result and bool instead of int
2021-09-21 11:35:53 +01:00
Nikita Popov
e0e5b59d2e Try harder to clean up unreachable loop free block
While we can't drop the loop free, we can drop other instructions
in the same block. We should also indicate that it no longer has
predecessors.
2021-09-17 16:32:29 +02:00
Nikita Popov
0d9269de75 Extract helper for fetching class entry in optimizer
This code is repeated a few time. Two occurrences additionally
contained checks for user classes in CG(class_table) with the
same file name, but as far as I know these should always be in
the script class_table, so I'm omitting the check here.
2021-06-18 10:48:48 +02:00
KsaR
01b3fc03c3
Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
Nikita Popov
13467bdcc0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #81015
2021-05-06 10:47:22 +02:00
Nikita Popov
b82242a88d Remove unnecessary php.h includes from Zend/
The Zend/ directory really shouldn't be including php headers.
These particular includes are plain unnecessary.
2021-04-20 12:21:45 +02:00
George Peter Banyard
5caaf40b43
Introduce pseudo-keyword ZEND_FALLTHROUGH
And use it instead of comments
2021-04-07 00:46:29 +01:00
Nikita Popov
83be073abe Move optimizer into core
This only moves the files, adjusts the build system, exports APIs
and does minor fixups to make sure the code builds.

This does not yet try to make the optimizer usable independently
of opcache.

Closes GH-6642.
2021-01-28 10:38:25 +01:00
Renamed from ext/opcache/Optimizer/zend_ssa.c (Browse further)