1
0
mirror of https://github.com/php/php-src.git synced 2026-04-05 07:02:33 +02:00
Commit Graph

1490 Commits

Author SHA1 Message Date
Máté Kocsis
b3718430de Annotate internal functions with the mixed type
Closes GH-5618
2020-05-25 17:30:57 +02:00
Nikita Popov
33b5c026aa Extract zend_foreach_op_array()
Move this functionality from zend_call_graph into zend_optimizer,
because we use this pattern in a number of places.
2020-05-19 11:15:54 +02:00
Dmitry Stogov
2224f63bb5 Prevent usage of uninitialized class entry 2020-05-12 23:34:07 +03:00
Tyson Andre
9f8f84adbc Evaluate str_starts_with and str_ends_with on constants
When both arguments are strings,
this is guaranteed not to emit notices.

Closes GH-5539
2020-05-07 16:24:03 +02:00
Nikita Popov
5bc1e224db Make numeric operations on resources, arrays and objects type errors
RFC: https://wiki.php.net/rfc/arithmetic_operator_type_checks

Closes GH-5331.
2020-05-05 16:11:13 +02:00
Nikita Popov
f55b413d60 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79535
2020-05-04 14:52:42 +02:00
Nikita Popov
733d84dbdf Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #79535
2020-05-04 14:52:18 +02:00
Nikita Popov
7c1316ec6a Fixed bug #79535
We did not allocate a cache slot for FETCH_CLASS. This is already
fixed on newer PHP versions.
2020-05-04 14:51:18 +02:00
Tyson Andre
d63eca285a Fix miscellaneous typos in code comments/var names
Closes GH-5501
2020-05-01 15:49:05 +02:00
Tyson Andre
54febdbc7d Fix other typos in param name/code comments
Closes GH-5502
2020-05-01 12:23:16 +02:00
Nikita Popov
53eee290b6 Completely remove disabled functions from function table
Currently, disabling a function only replaces the internal
function handler with one that throws a warning, and a few
places in the engine special-case such functions, such as
function_exists. This leaves us with a Schrödinger's function,
which both does not exist (function_exists returns false) and
does exist (you cannot define a function with the same name).
In particular, this prevents the implementation of robust
polyfills, as reported in https://bugs.php.net/bug.php?id=79382:

    if (!function_exists('getallheaders')) {
        function getallheaders(...) { ... }
    }

If getallheaders() is a disabled function, this code will break.

This patch changes disable_functions to remove the functions from
the function table completely. For all intents and purposes, it
will look like the function does not exist.

This also renders two bits of PHP functionality obsolete and thus
deprecated:

 * ReflectionFunction::isDisabled(), as it will no longer be
   possible to construct the ReflectionFunction of a disabled
   function in the first place.
 * get_defined_functions() with $exclude_disabled=false, as
   get_defined_functions() now never returns disabled functions.

Fixed bug #79382.

Closes GH-5473.
2020-04-30 09:53:57 +02:00
Nikita Popov
f38d6cea42 Check func_info consistency
Make sure explicitly specified func_info is a subset of
automatically computed info. This will at least prevent
cases where a type is removed from stubs, but not removed
from func_info.

Closes GH-5471.
2020-04-27 16:25:59 +02:00
Nikita Popov
c5f87eee5d Mark passthru() as RC0
This function only returns null/false, RC1 does not make sense.
2020-04-27 15:39:31 +02:00
Nikita Popov
58eafbe734 Make array_rand() type info more accurate 2020-04-27 15:36:32 +02:00
Nikita Popov
cc8a8613b6 Remove MAY_BE_FALSE from range() type info 2020-04-27 15:36:32 +02:00
Máté Kocsis
a6960cfb05 Fix inaccurate func infos
Closes GH-5472
2020-04-27 15:35:44 +02:00
Nikita Popov
19e886d9d8 Avoid throw expression leaks
Mark "throw" used in expression context with a flag, and don't
treat it as a BB terminator in that case. This prevents us from
optimizing away the following opcodes as unreachable, which may
result in live ranges being dropped incorrectly.

Close GH-5450.
2020-04-27 15:22:05 +02:00
Nikita Popov
a447897db0 Use information about classes returned by internal functions 2020-04-27 12:50:24 +02:00
Tyson Andre
4e1219ac88 [skip ci] Fix typos in jit code comments
And in Opcache's zend_cfg.h

Closes GH-5414
2020-04-19 10:03:49 -04:00
Christoph M. Becker
a1eaaa692e Fix #79475: [JIT] func_get_args() assertion violation
`func_get_args()` may return `zend_empty_array`, which has refcount 2
to enforce separation.   We have to cater to that during type inference
so that the optimization in the JIT macro `SEPARATE_ARRAY` doesn't
prevent the separation.
2020-04-17 09:53:23 +02:00
Nikita Popov
00013401ff Allow using prototypes when optimizing arg passing
Closes GH-5193.
2020-04-16 12:15:19 +02:00
Nikita Popov
bac5137e4e Add zend_create_member_string() API
This is a recurring pattern.
2020-04-14 16:52:13 +02:00
Nikita Popov
d030ddb2cd Export the zend_string_concat3() API 2020-04-09 15:06:53 +02:00
Nikita Popov
1ed132e2e5 Unify checks for binary operator errors for ct eval
Move everything into one function and share it with opcache.
This fixes some discrepancies.
2020-04-01 14:42:58 +02:00
Nikita Popov
56b18d478e Don't convert binop operand types in opcache
This may produce different behavior if operator overloading is
involved, and may change the error message.

If there's strong interest, this could be done in the DFA pass
with available type information. It does not look particularly
practically useful to me though.
2020-04-01 14:39:41 +02:00
Nikita Popov
2d8f9f34dd Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix literal compaction collision between string and double
2020-04-01 14:23:07 +02:00
Nikita Popov
59c8d6a863 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix literal compaction collision between string and double
2020-04-01 14:22:27 +02:00
Nikita Popov
14b770d407 Fix literal compaction collision between string and double
For the sake of simplicity I'm using a separate hashtable, rather
than trying to do hash perturabation on the double strings.
2020-04-01 14:20:59 +02:00
Tyson Andre
47ddd95836 Do constant evaluation for str_contains in opcache
Both arguments must be strings.
str_contains deliberately does not emit a warning for an empty needle.

Closes GH-5324
2020-03-30 09:54:38 -04:00
Nikita Popov
a34480ec82 SCCP: Optimize strpos with empty needle
This is no longer special cases in PHP 8.
2020-03-30 10:37:22 +02:00
Dmitry Stogov
099ffc2169 BIND_GLOBAL and BIND_STATIC don't use value of the first operand 2020-03-27 15:20:21 +03:00
Nikita Popov
97cb81ead5 Remove HAVE_REALPATH checks
We do not actually use realpath(), but a custom implementation.
Make sure the realpath() function is always available.

Closes GH-5290.
2020-03-26 11:46:00 +01:00
Dmitry Stogov
5a05fef2af Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79412 (Opcache chokes and uses 100% CPU on specific script).
2020-03-25 17:38:08 +03:00
Dmitry Stogov
91ee85c20c Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #79412 (Opcache chokes and uses 100% CPU on specific script).
2020-03-25 17:31:33 +03:00
Dmitry Stogov
65120cfc09 Fixed bug #79412 (Opcache chokes and uses 100% CPU on specific script). 2020-03-25 17:31:06 +03:00
Dmitry Stogov
b7c6244dfc Add new line before basic-block labels (except for the first BB0) 2020-03-25 14:26:42 +03:00
Dmitry Stogov
0684b9fcdc Always print numeric opline numbers 2020-03-25 14:26:42 +03:00
Dmitry Stogov
af3142daaf Make SSA dump format controlled by opcache.jit_debug more readable (always print opcode number).
This doesn't affect dumps controlled by opcache.opt_debug_level.
2020-03-24 22:44:11 +03:00
Nikita Popov
dcbdcf87c8 Merge branch 'PHP-7.4'
* PHP-7.4:
  Handle NULL caller_call_opline
2020-03-23 17:12:55 +01:00
Nikita Popov
dd9b5c8680 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Handle NULL caller_call_opline
2020-03-23 17:12:12 +01:00
Nikita Popov
34f1266a9c Handle NULL caller_call_opline
This can happen if there is an EXIT in the call arguments, in which
case the DO_CALL opcode may be eliminated as unreachable.
2020-03-23 17:12:01 +01:00
Dmitry Stogov
7283dbba27 ZEND_MAKE_REF can't throw 2020-03-20 01:37:27 +03:00
Dmitry Stogov
8e879b9f44 JIT for ZEND_CHECK_FUNC_ARG 2020-03-18 23:56:03 +03:00
Nikita Popov
1ba6e66c46 Improve type inference
After thinking about this a bit more, the code here was too
conservative. We know that everything but an object is going to
throw, so it's sufficient to restrict the type to MAY_BE_OBJECT.

The change in the test is weird but not incorrect, because it
operates on empty inferred types, in which case the code must be
dead (which it is). We should probably add a more explicit removal
of code working on empty types.
2020-03-17 15:41:47 +01:00
Nikita Popov
41a86a72c4 Clean up a few more places 2020-03-17 15:23:52 +01:00
Nikita Popov
023039fbfc Remove object auto-vivification leftovers in type-inference
undef/null/false no longer get promoted to object in PHP 8.

In fact, we may drop the SSA var defs outside RC inference mode now.
2020-03-17 14:54:11 +01:00
Nikita Popov
3723985058 Merge EX variants of INFO macros 2020-03-16 13:02:16 +01:00
Nikita Popov
d35ce5d661 Merge EX variants of RANGE macros
Only need to create the ssa_op variable in range inference...
2020-03-16 12:36:03 +01:00
Nikita Popov
44b3971b85 Merge zend_may_throw(_ex)
Explicitly pass ssa_op in the places that don't do so yet.
2020-03-16 12:24:40 +01:00
Dmitry Stogov
9a8f735c57 Emit warning about type narrowing for tracing JIT as well 2020-03-14 01:29:46 +03:00