Dmitry Stogov
eb43f8a4f8
Eliminate more VERIFY_RETURN_TYPE instructions
2021-12-27 23:40:21 +03:00
Christoph M. Becker
1d4482908b
Merge branch 'PHP-8.1'
...
* PHP-8.1:
Revert "Fix zend_observer_fcall_end_all() accessing dangling pointers"
2021-12-27 21:11:24 +01:00
Christoph M. Becker
d58c48d45d
Merge branch 'PHP-8.0' into PHP-8.1
...
* PHP-8.0:
Revert "Fix zend_observer_fcall_end_all() accessing dangling pointers"
2021-12-27 21:10:40 +01:00
Christoph M. Becker
ee610947ce
Revert "Fix zend_observer_fcall_end_all() accessing dangling pointers"
...
This reverts commit 76e2a8380e . Cf.
<76e2a8380e (r62560239) >.
2021-12-27 21:08:51 +01:00
Christoph M. Becker
a72a011054
Merge branch 'PHP-8.1'
...
* PHP-8.1:
Fix zend_observer_fcall_end_all() accessing dangling pointers
2021-12-27 18:21:37 +01:00
Christoph M. Becker
d4c07df4df
Merge branch 'PHP-8.0' into PHP-8.1
...
* PHP-8.0:
Fix zend_observer_fcall_end_all() accessing dangling pointers
2021-12-27 18:20:48 +01:00
Florian Sowade
76e2a8380e
Fix zend_observer_fcall_end_all() accessing dangling pointers
...
This may happen, when the execute_data was allocated on the stack. We
ensure that the runtime cache pointer is not NULL before dereferencing
it.
This is a partial fix for bug 81430.
Closes GH-7665.
2021-12-27 18:19:13 +01:00
Dmitry Stogov
a066b809de
Skip abstract methods
2021-12-27 15:28:46 +03:00
Dmitry Stogov
2759e6bc69
Fixed assertion when check "instanceof" on unlinked class
2021-12-27 12:02:13 +03:00
Nikita Popov
e45653c089
Make sure SCCP can evaluate all functions pass1 can
...
Move evaluation of ini_get() into eval_special_func_call() and
use this helper both in pass1 and sccp.
2021-12-26 15:40:35 +01:00
Nikita Popov
1050edaef8
Extract special function evaluation from pass1
...
Pass1 handles a number of special functions that can be evaluated
under some circumstances. Move the core logic into a separate
helper, as I believe that SCCP should reuse this.
2021-12-26 15:40:35 +01:00
Nikita Popov
c4334fc616
Remove special chr/count handling in sccp function evaluation
...
These can be handled by the generic code. Worth noting that count
will usually go through ZEND_COUNT, and chr on constants is
evaluated in the compiler, so these are not particularly compile-time
sensitive either.
2021-12-26 09:55:18 +01:00
Nikita Popov
924e875651
Minor code cleanup in pass1
...
Move literal destruction into helper and use a common result
variable to make code more compact.
2021-12-26 09:48:06 +01:00
Nikita Popov
206d80e11a
Reuse get_class_entry_from_op1() helper
...
Export and reuse this helper in places that fetch a class entry
from op1.
2021-12-25 22:18:50 +01: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
Nikita Popov
046096f265
Remove outdated FETCH_CLASS handling in FETCH_CLASS_CONSTANT optimization
...
Nowadays self::X is represented using an UNUSED operand with
FETCH_CLASS_SELF flag rather than a separate FETCH_CLASS instruction.
The code already handles the new pattern.
2021-12-25 21:00:07 +01:00
Nikita Popov
f6dce4a8ca
Extract common replacement login in pass1
...
The replace const or replace with QM_ASSIGN pattern is common to
all constant folding, extract it into a function.
2021-12-25 20:56:25 +01:00
Nikita Popov
52676f2b7e
Remove unnecessary wrapper function
...
This seems to date back to a time where zval_ptr_dtor was a macro
implicitly passing additional parameters.
2021-12-25 17:39:05 +01:00
Nikita Popov
0884048401
Don't exclude arrays from constant collection
...
These are supported as constants nowadays, so we can drop the
string check.
Also fix a potential leak, though I believe this doesn't matter in
current usage, as it will effectively be suppressed during persist.
2021-12-25 17:32:18 +01:00
Nikita Popov
7eae7e5e54
Remove FETCH_CLASS+INSTANCEOF special case
...
Instead propagate the FETCH_CLASS return value, so it can be
directly replaced if possible, which will also eliminate the
FETCH_CLASS subsequently.
2021-12-25 16:45:38 +01:00
Nikita Popov
92e7cf5962
Move FETCH_CLASS+INSTANCEOF special case out of update_op1_const()
...
The generic code was rejecting this to go into a special code path
in SCCP. We should directly do that in SCCP instead, to still allow
the generic (and valid) replacement.
2021-12-25 16:32:02 +01:00
Nikita Popov
98dfde2c14
Remove unnecessary INSTANCEOF special case in sccp
...
While we can't replace the instanceof operand, we will evaluate
the instanceof to false and replace its result anyway. Even in
cases where the instanceof user cannot be replaced, we already
have generic code to convert the opcode to QM_ASSIGN in that
case.
2021-12-25 13:02:10 +01:00
Nikita Popov
36dafade51
Remove unnecessary try_replace_op1() special cases
...
update_op1_const() can handle these nowadays.
2021-12-25 12:39:52 +01:00
Nikita Popov
4ad9dbbac9
Don't replace SEND opcodes with different by-ref behavior
...
update_op1_const() implements the right logic here -- these cannot
be replaced by different opcodes, as the by-ref passing behavior
is not the same.
2021-12-25 12:34:02 +01:00
Nikita Popov
46d1e503dd
Remove redundant code in zend_optimizer_replace_by_const()
...
zend_optimizer_update_op1_const() already handles these cases.
2021-12-25 12:18:12 +01:00
Dmitry Stogov
eee3b1d917
Bucket->key must be removed before destructor call, because destructor may update the same HashTable.
...
Fixes oss-fuzz #42894
2021-12-24 15:36:52 +03:00
Dmitry Stogov
8b23538034
Merge branch 'PHP-8.1'
...
* PHP-8.1:
Fix memory leak in SCCP
2021-12-24 13:11:09 +03:00
Dmitry Stogov
b2939b636d
Merge branch 'PHP-8.0' into PHP-8.1
...
* PHP-8.0:
Fix memory leak in SCCP
2021-12-24 13:10:58 +03:00
Dmitry Stogov
aab52968a3
micro-optimization
2021-12-23 18:31:45 +03:00
Christoph M. Becker
3c3257b0d3
Merge branch 'PHP-8.1'
...
* PHP-8.1:
Avoid void* arithmetic in sockets/multicast.c on NetBSD
2021-12-23 16:22:11 +01:00
Christoph M. Becker
9d2dc1e9a9
Merge branch 'PHP-8.0' into PHP-8.1
...
* PHP-8.0:
Avoid void* arithmetic in sockets/multicast.c on NetBSD
2021-12-23 16:21:28 +01:00
David Carlier
3f0bb67361
Avoid void* arithmetic in sockets/multicast.c on NetBSD
...
On NetBSD, ifconf.ifc_buf member, unlike most of platforms, is a void
pointer.
We also fix the cpuinfo declarations with empty parameter lists.
Closes GH-7819.
2021-12-23 16:17:30 +01:00
Dmitry Stogov
5d6bc25063
Reset Bucket->key of deleted HastTable elemets to NULL.
...
This allows elimination of some Z_ISUNDEF(Bucket->val) checks.
2021-12-22 12:54:32 +03:00
Joe Watkins
898da7bee1
Merge branch 'PHP-8.1'
...
* PHP-8.1:
zend gdb detection fix on FreeBSD.
2021-12-21 07:21:59 +01:00
Joe Watkins
3ee2422cbb
Merge branch 'PHP-8.0' into PHP-8.1
...
* PHP-8.0:
zend gdb detection fix on FreeBSD.
2021-12-21 07:19:58 +01:00
David CARLIER
62bcb31706
zend gdb detection fix on FreeBSD.
2021-12-21 07:19:33 +01:00
David CARLIER
1a4d2dd962
zend alloc USE_ZEND_ALLOC_HUGE_PAGES option support on solaris based systems ( #7789 )
2021-12-21 07:18:11 +01:00
George Peter Banyard
d4920f4284
Move ctype test out from Zend and into ctype extension
2021-12-20 18:12:35 +00:00
Tyson Andre
32e2d97a26
Allow internal functions to declare if they support compile-time evaluation, add functions. ( #7780 )
...
https://wiki.php.net/rfc/strtolower-ascii means that these functions no longer
depend on the current locale in php 8.2. Before that, this was unsafe to
evaluate at compile time.
Followup to GH-7506
Add strcmp/strcasecmp/strtolower/strtoupper functions
Add bin2hex/hex2bin and related functions
Update test of garbage collection using strtolower to use something else to create a refcounted string
2021-12-20 09:27:06 -05:00
Christoph M. Becker
04b9049973
Merge branch 'PHP-8.1'
...
* PHP-8.1:
Fix zend_fibers.c build with ZEND_FIBER_UCONTEXT
2021-12-20 14:22:08 +01:00
Petr Sumbera
069bbf3e80
Fix zend_fibers.c build with ZEND_FIBER_UCONTEXT
...
Avoids (Solaris SPARC) issue:
zend_fibers.c:77:9: error: unknown type name 'ucontext_t'
Closes GH-7773.
2021-12-20 14:21:50 +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
6b60dc29de
Merge branch 'PHP-8.1'
...
* PHP-8.1:
Fix type inference for INIT_ARRAY with invalid index
2021-12-20 11:46:45 +03:00
Dmitry Stogov
c8d10a8243
Merge branch 'PHP-8.0' into PHP-8.1
...
* PHP-8.0:
Fix type inference for INIT_ARRAY with invalid index
2021-12-20 11:46:36 +03:00
Dmitry Stogov
192ea91deb
Avoid useless symbol table reattaching on retutn from an included op_array
2021-12-16 21:44:43 +03:00
Dmitry Stogov
67bb79259b
Don't execute INCLUDE for empty op_arrays.
2021-12-16 19:42:29 +03:00
Dmitry Stogov
79fac32d6b
Don't call zend_attach/detach_symbol_table() for op_arrays without local variables
2021-12-16 17:37:01 +03:00
Tim Starling
8eee0d6130
Make strtolower() and strtoupper() do ASCII case conversion ( #7506 )
...
Implement RFC https://wiki.php.net/rfc/strtolower-ascii
2021-12-15 08:38:35 -05:00
Dmitry Stogov
faa143ca1b
Merge branch 'PHP-8.1'
...
* PHP-8.1:
Fix array clobbering by user error handler
2021-12-15 12:21:36 +03:00