Ilija Tovilo
0b1d750d91
Allow arbitrary expressions in static variable initializer
...
Closes GH-9301
2023-05-24 20:17:31 +02:00
Ilija Tovilo
a00e2233e3
Merge branch 'PHP-8.2'
...
* PHP-8.2:
Fix incorrect match default branch optimization
2023-04-26 15:20:35 +02:00
Ilija Tovilo
368dd81faa
Merge branch 'PHP-8.1' into PHP-8.2
...
* PHP-8.1:
Fix incorrect match default branch optimization
2023-04-26 15:20:27 +02:00
Ilija Tovilo
3a76f795f8
Fix incorrect match default branch optimization
...
Fixes GH-11134
Closes GH-11135
2023-04-26 15:19:20 +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
Dmitry Stogov
ce861373b9
Merge branch 'PHP-8.2'
...
* PHP-8.2:
Fix incorrect optimization of ASSIGN_OP may lead to incorrect result (sub assign -> pre dec conversion for null values)
2023-01-09 13:53:35 +03:00
Dmitry Stogov
9abc2108fa
Merge branch 'PHP-8.1' into PHP-8.2
...
* PHP-8.1:
Fix incorrect optimization of ASSIGN_OP may lead to incorrect result (sub assign -> pre dec conversion for null values)
2023-01-09 13:53:19 +03:00
Dmitry Stogov
4d4a53beee
Fix incorrect optimization of ASSIGN_OP may lead to incorrect result (sub assign -> pre dec conversion for null values)
2023-01-09 13:51:57 +03:00
Ilija Tovilo
6d9d2eb355
Optimize JMP[N]Z_EX to BOOL instead of QM_ASSIGN ( #10108 )
...
&& and || should always evaluate to a boolean instead of the lhs/rhs.
This optimization never gets triggered for any of our tests.
Additionally, even if triggered this instruction gets optimized away
because the else branch of the JMP instruction will overwrite the tmp
value.
2022-12-17 12:47:02 +01:00
Dmitry Stogov
de4b502fef
Merge branch 'PHP-8.1' into PHP-8.2
...
* PHP-8.1:
Fix memory leak
2022-11-07 11:08:54 +03:00
Dmitry Stogov
f31f464cec
Fix memory leak
...
Fixes oss-fuzz #52999
2022-11-07 11:07:58 +03:00
Dmitry Stogov
218da70bcf
Merge branch 'PHP-8.1'
...
* PHP-8.1:
Fix memory leak
2022-08-29 14:54:49 +03:00
Dmitry Stogov
172ac0a48d
Merge branch 'PHP-8.0' into PHP-8.1
...
* PHP-8.0:
Fix memory leak
2022-08-29 14:54:40 +03:00
Dmitry Stogov
21507ef28a
Merge branch 'PHP-8.1'
...
* PHP-8.1:
Fix SSA reconstruction when body of "foreach" loop is removed
2022-08-01 14:01:34 +03:00
Dmitry Stogov
4b19b85eb6
Merge branch 'PHP-8.0' into PHP-8.1
...
* PHP-8.0:
Fix SSA reconstruction when body of "foreach" loop is removed
2022-08-01 14:01:11 +03:00
George Peter Banyard
f905590764
Add support for Disjoint Normal Form (DNF) types ( #8725 )
...
RFC: https://wiki.php.net/rfc/dnf_types
This allows to combine union and intersection types together in the following form (A&B)|(X&Y)|T but not of the form (X|A)&(Y|B) or (X|A)&(Y|B)|T.
* Improve union type parsing
Co-authored-by: Sara Golemon <pollita@php.net>
2022-07-08 11:30:23 +01:00
George Peter Banyard
8685a7f03c
Remove custom alloca() ( #8513 )
...
* Use arena in DCE instead of multiple alloca()
This requires passing the optimizer context
* Use our do_alloca() instead of alloca()
* Use emalloc in DEBUG builds instead of stack allocations for do_alloca()
This helps detecting that we correctly free do_alloca()
2022-05-27 09:05:33 +01:00
Dmitry Stogov
ace00faddd
Merge branch 'PHP-8.1'
...
* PHP-8.1:
Disable ASSIGN optimization for values inferred for fatal errors.
2022-02-18 11:38:16 +03:00
Dmitry Stogov
7e8257fbd2
Disable ASSIGN optimization for values inferred for fatal errors.
2022-02-18 11:35:43 +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
e4cf3f7420
Merge branch 'PHP-8.1'
...
* PHP-8.1:
Fix incorrect optimization of ASSIGN_OP that may lead to memory leak
2021-12-20 15:17:45 +03:00
Dmitry Stogov
ca3f7b0a73
Merge branch 'PHP-8.0' into PHP-8.1
...
* PHP-8.0:
Fix incorrect optimization of ASSIGN_OP that may lead to memory leak
2021-12-20 15:17:30 +03:00
Dmitry Stogov
abcf68387d
Merge branch 'PHP-8.1'
...
* PHP-8.1:
Fix incorrect JMP optimization
2021-12-10 01:45:03 +03:00
Dmitry Stogov
363434bab2
Merge branch 'PHP-8.0' into PHP-8.1
...
* PHP-8.0:
Fix incorrect JMP optimization
2021-12-10 01:44:55 +03:00
Nikita Popov
71b2f46798
Merge branch 'PHP-8.1'
...
* PHP-8.1:
Fix bug #81652
2021-11-24 15:20:38 +01:00
Nikita Popov
51ae5c5397
Merge branch 'PHP-8.0' into PHP-8.1
...
* PHP-8.0:
Fix bug #81652
2021-11-24 15:19:33 +01:00
Nikita Popov
e506564e08
Merge branch 'PHP-8.1'
...
* PHP-8.1:
Drop pi nodes for both old/new pred in replace_predecessor
2021-11-08 14:58:42 +01:00
Nikita Popov
e5c2ad45dd
Merge branch 'PHP-8.0' into PHP-8.1
...
* PHP-8.0:
Drop pi nodes for both old/new pred in replace_predecessor
2021-11-08 14:57:16 +01:00
Dmitry Stogov
564d54192f
Merge branch 'PHP-8.1'
...
* PHP-8.1:
Fixed incorrect optimization that may cause JIT assertion
2021-10-18 23:21:01 +03:00
Dmitry Stogov
bdebefaa61
Merge branch 'PHP-8.0' into PHP-8.1
...
* PHP-8.0:
Fixed incorrect optimization that may cause JIT assertion
2021-10-18 23:20:53 +03:00
Nikita Popov
a00446ca90
Merge branch 'PHP-8.1'
...
* PHP-8.1:
Don't replace tmp with cv in YIELD argument
2021-10-12 14:27:13 +02:00
Nikita Popov
9c1d7b43e9
Merge branch 'PHP-8.0' into PHP-8.1
...
* PHP-8.0:
Don't replace tmp with cv in YIELD argument
2021-10-12 14:27:07 +02:00
Nikita Popov
c19977d054
Fix delayed early binding with optimization
...
It's possible for delayed early binding opcodes to get optimized
away if they are "unreachable". However, we still need to attempt
early binding for them. (In some cases we also corrupt the early
binding list outright during optimization, which is how I got here.)
Fix this by storing information about delayed early binding
independently of DECLARE_CLASS_DELAYED opcodes, so early binding is
performed even after the opcode has been dropped.
2021-09-29 18:00:20 +02:00
Nikita Popov
78bd138232
Merge branch 'PHP-8.1'
...
* PHP-8.1:
Handle pi nodes in replace_predecessor
2021-09-27 10:48:35 +02:00
Nikita Popov
d5e80c1c0c
Merge branch 'PHP-8.0' into PHP-8.1
...
* PHP-8.0:
Handle pi nodes in replace_predecessor
2021-09-27 10:48:23 +02:00
Nikita Popov
7e565daad9
Fix incorrect use chain unlink
...
This issue has been introduced in 87ea3c1f4c
,
where an || has been misinterpreted as an &&.
2021-09-21 14:35:45 +02: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
6c928f3529
Voidify zend_ssa_find_false_dependencies()
...
It always returned SUCCESS
2021-09-21 11:35:53 +01:00
George Peter Banyard
ad3544b08c
Voidify zend_ssa_find_sccs()
...
It always returned SUCCESS
2021-09-21 11:35:53 +01: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
Nikita Popov
f6daf83e75
Merge branch 'PHP-8.0' into PHP-8.1
...
* PHP-8.0:
Check that POST_INC/DEC has use in DFA optimization
2021-09-09 15:50:04 +02:00
Dmitry Stogov
14c103d7c5
Optimize "$x * 2" into "$x + $x"
2021-08-11 11:53:28 +03:00