Commit graph

29 commits

Author SHA1 Message Date
Niels Dossche
2ec8d37eb4
Fix GH-18107: Opcache CFG jmp optimization with try-finally breaks the exception table
If there's a try-finally where the try_op starts on a basic block with a
single JMP, and the JMP optimization causes that basic block to become
unreachable, then we update try_op.
In this case, there is no catch_op, so try_op is erroneously set to 0,
we should instead set it to `b->start`.

Closes GH-18110.
2025-03-21 13:56:31 +01:00
Ilija Tovilo
0b1d750d91
Allow arbitrary expressions in static variable initializer
Closes GH-9301
2023-05-24 20:17:31 +02:00
Max Kellermann
d5c649b36b
zend_compiler, ...: use uint8_t instead of zend_uchar (#10621)
`zend_uchar` suggests that the value is an ASCII character, but here,
it's about very small integers.  This is misleading, so let's use a
C99 integer instead.

On all architectures currently supported by PHP, `zend_uchar` and
`uint8_t` are identical.  This change is only about code readability.
2023-02-23 14:56:54 +00: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
a55c0c5fc3 Zend/Optimizer/zend_cfg: include cleanup 2023-01-12 15:12:45 +00:00
Dmitry Stogov
eecbb60db6 Fix memory leak
Fixes oss-fuzz #52479
2022-10-17 15:08:21 +03:00
Dmitry Stogov
ca0afc3c8e Improve speed of dominators and loop identification algorithms 2022-02-07 12:48:44 +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
Nikita Popov
43b3cf110f Merge branch 'PHP-8.1'
* PHP-8.1:
  Don't start new block after loop free
2021-10-06 10:13:24 +02:00
Nikita Popov
f455894bb6 Don't start new block after loop free
This reverts the change from 493c91c742.
Starting a new block means that in the common case where the loop var
free is not unreachable, we'll always merge back the block.

Instead fix the original problem by explicitly removing instructions
apart from the loop var free in block pass.
2021-10-06 10:13:15 +02:00
Nikita Popov
d1aff29a04 Merge branch 'PHP-8.1'
* PHP-8.1:
  Start new block after loop free
2021-10-04 17:02:40 +02:00
Nikita Popov
493c91c742 Start new block after loop free
In the attached test case we ended up not updating a leftover
MATCH jump in the unreachable_free block. There's different ways
this can be addressed, but in this case we can just make sure that
a new block is started after the loop free, which will allow it
to be dropped as unreachable. We only need to retain the free
itself for live-range reconstruction.

Fixes oss-fuzz #39516.
2021-10-04 16:59:46 +02:00
Nikita Popov
223370e506 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix block marking for two arm math
2021-09-28 10:38:34 +02:00
Nikita Popov
1e4a9a4999 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix block marking for two arm math
2021-09-28 10:38:22 +02:00
Nikita Popov
3981f43058 Merge branch 'PHP-8.1'
* PHP-8.1:
  Start block at loop var free
2021-09-27 11:59:03 +02:00
Nikita Popov
b86fdf84f0 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Start block at loop var free
2021-09-27 11:58:53 +02:00
Nikita Popov
2157d11ddc Merge branch 'PHP-8.1'
* PHP-8.1:
  Don't treat expression exit as terminator
2021-09-23 10:26:34 +02:00
Nikita Popov
c9762be566 Don't treat expression exit as terminator
Same as with throw expressions, this may remove later temporary
consuming instructions and thus eliminate live ranges, resulting
in a memory leak. We make use of the same hack and don't consider
exit a terminator if used in an expression context.
2021-09-23 10:26:07 +02:00
George Peter Banyard
a06d6c36d4 Voidify zend_cfg_identify_loops()
It always returned SUCCESS
2021-09-21 11:35:53 +01:00
George Peter Banyard
53c72bd6e0 Voidify zend_cfg_compute_dominators_tree()
It always returned SUCCESS
2021-09-21 11:35:53 +01:00
George Peter Banyard
6a45664484 Voidify zend_cfg_build_predecessors()
It always returned SUCCESS
2021-09-21 11:35:53 +01:00
George Peter Banyard
50378666fe Voidify zend_build_cfg()
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
Dmitry Stogov
a3a74b07e5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed Bug #80959 (infinite loop in building cfg during JIT compilation)
2021-07-21 14:34:04 +03: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
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
Matt Brown
6cd0b48cac Implement never return type
The never type can be used to indicate that a function never
returns, for example because it always unwinds.

RFC: https://wiki.php.net/rfc/noreturn_type

Closes GH-6761.
2021-04-19 11:27:29 +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_cfg.c (Browse further)