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

16498 Commits

Author SHA1 Message Date
Dmitry Stogov 2f3538c215 Improved type inference for FE_FETCH_R 2021-03-25 16:00:36 +03:00
George Peter Banyard 56c18c4038 Drop unneessary if branch and adjust arg_num type
This if branch seems to be a remain of when certain type errors where E_WARNINGs, something which isn't the case since PHP 8.0.
2021-03-25 02:12:06 +00:00
Nikita Popov f42f539324 Revert "Use better function"
This reverts commit 9162116a85.

This causes many "__HALT_COMPILER(); must be declared in a phar"
errors in phar tests on windows.
2021-03-22 17:53:37 +01:00
Nikita Popov 79a9f809ee Fix const warning 2021-03-22 15:19:06 +01:00
Nikita Popov 6a5d60085d Support VERIFY_RETURN_TYPE elision with unused operand
This handles the degenerate case where SCCP replaced the value in
the RETURN opcode with a constant, but the VERIFY_RETURN is still
there. We can still apply the same optimization, just don't need
to adjust the use list in this case.

The result is still sub-optimal in that a dead QM_ASSIGN is left
behind.
2021-03-22 14:54:29 +01:00
Dmitry Stogov 9162116a85 Use better function 2021-03-22 14:55:54 +03:00
Dmitry Stogov 340013ad01 Add zend_hash_lookup() and zend_hash_index_lookup() functions.
Thet search for an element with given key/index and add an empty one (NULL), if no found.
2021-03-19 22:36:24 +03:00
Nikita Popov 5fd2a5b13b Fix handling of unknown class in trait precedence list
Fixes oss-fuzz #31983.
2021-03-19 16:04:47 +01:00
Dmitry Stogov 89c61186ff micro-optimization 2021-03-19 16:57:42 +03:00
Nikita Popov 2d0e2733c8 Support prototypes in call graph
Even if we don't know the exact method being called, include it
in the call graph with the is_prototype flag. In particular, we
can still make use of return types from prototype methods, as
PHP 8 makes LSP violations a hard error.

Most other places are adjusted to skip calls with !is_prototype.
Maybe some of them would be fine, but ignoring them is conservative.
2021-03-19 10:49:15 +01:00
Nikita Popov e67156e967 Add missing rc1/rcn to return type initialization 2021-03-19 10:04:56 +01:00
Nikita Popov dcac654fd5 Allow inferring narrowed return type
Even if an explicit return type is given, we might still infer
a more narrow one based on return statements. We shouldn't
pessimize this just because a type has been declared.
2021-03-18 17:11:56 +01:00
Nikita Popov 8690efd1f8 Update opt test
And fix a type in the fetch class flags dumping while here.
2021-03-18 15:25:40 +01:00
Nikita Popov 4df39f4bd0 Don't imply SILENT from NO_AUTOLOAD
We have separate flags for non-autoloading class fetches and
silent class fetches. There's no reason why NO_AUTOLOAD should
be special-cased to be implicitly silent.
2021-03-18 15:15:21 +01:00
Nikita Popov 234af00bcb Destroy constant values before object store
Now that constants can contain objects (currently only enums),
we should destroy them before we free the object store, otherwise
there will be false positive leak reports.

This doesn't affect the fast_shutdown sequence.
2021-03-18 10:31:28 +01:00
Ilija Tovilo 269c8dac1d Implement enums
RFC: https://wiki.php.net/rfc/enumerations

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>

Closes GH-6489.
2021-03-17 19:08:03 +01:00
George Peter Banyard a6fc427b8c Use zend_string_equals() API instead of strcmp() in various places
Closes GH-6784
2021-03-17 16:36:23 +00:00
Dmitry Stogov c732ab400a Change Zend Stream API to use zend_string* instead of char*.
This allows to eliminate re-calculation of string lenght and hash value.
See the detailed list of changes in UPGRADING.INTERNALS.
2021-03-16 20:31:36 +03:00
Nikita Popov e35f9dfecc Don't check executability
As $(PHP) is not an absolute path, test -x doesn't do anything
meaningful. Rely on the autoconf check.
2021-03-16 14:36:10 +01:00
Nikita Popov 59e610092a Check for WRONG_PROPERTY_INFO 2021-03-16 14:24:48 +01:00
Nikita Popov 4f750f7171 Revert "Remove some unnecessary explicit header dependencies"
This reverts commit c386b1fb17.

It looks like at least some of these might be needed for ordering
in a clean build?
2021-03-16 14:22:25 +01:00
Nikita Popov 9b816d83f6 Automatically run zend_vm_gen.php if zend_vm_def.h changes 2021-03-16 13:08:37 +01:00
Nikita Popov c386b1fb17 Remove some unnecessary explicit header dependencies
These are now automatically tracked by the build system.
2021-03-16 13:02:23 +01:00
Nikita Popov 77ebf81492 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix refcount inference for typed properties
2021-03-16 11:18:12 +01:00
Nikita Popov 53e9c36cd9 Add sanity check for type of read_property return value
If an internal class overrides read_property and declared property
types, make sure that the returned value matches the declared
type (in debug builds).
2021-03-16 10:42:47 +01:00
Dmitry Stogov d5a15d2c91 Remove deprecated code 2021-03-13 01:04:43 +03:00
Dmitry Stogov fe3dbe5294 Fixed compilation warning 2021-03-12 21:50:26 +03:00
Dmitry Stogov 3d11743372 Inline "array" part of FE_FETCH_R handler into HYBRID VM 2021-03-11 22:33:01 +03:00
Dmitry Stogov 278d452a6a zend_verify_recv_arg_type_helper is not "cold". 2021-03-11 15:57:02 +03:00
Dmitry Stogov d0e043b294 Avoid repeatable work when error_reporting() is called with the same argument few times. 2021-03-11 14:27:53 +03:00
Dmitry Stogov 65859fe17e Inheritance cache optimization 2021-03-11 13:42:35 +03:00
Máté Kocsis 495bf5cdd0 Merge branch 'PHP-8.0' 2021-03-06 00:56:47 +01:00
Máté Kocsis 0f8312342f Fix the error message of attribute flag validation 2021-03-06 00:56:25 +01:00
Levi Morrison 2317b81c62 Add const to zend_extension_version_info.build_id
This is a follow-up to:
https://github.com/php/php-src/commit/3c6ab4b3ea5854fd44a2945bb65bf027a6c94890

Closes GH-6744.
2021-03-02 18:42:58 -07:00
Dmitry Stogov 9da66e6ad0 Optimized object conversion to array without rebulding properties HashTable 2021-03-01 22:37:37 +03:00
Nikita Popov 056eac6b03 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80811
2021-03-01 16:30:19 +01:00
Nikita Popov 75a4f484f0 Fixed bug #80811
When filling in defaults for skipped params, make sure that
reference parameters get the expected reference wrapper.
2021-03-01 16:30:01 +01:00
Nikita Popov 26c3fa2759 Merge branch 'PHP-8.0'
* PHP-8.0:
  Always remove HT iterators, even for uninit HT
2021-03-01 16:22:51 +01:00
Nikita Popov 5875bf754e Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Always remove HT iterators, even for uninit HT
2021-03-01 16:22:29 +01:00
Nikita Popov 2c508c4d40 Always remove HT iterators, even for uninit HT
Fixes oss-fuzz #31423.
2021-03-01 16:22:11 +01:00
Dmitry Stogov b0c7ea4919 Change the order of properties used in foreach(), var_dump(), serialize(), comparison, etc. Now properties are ordered according to their layout in zend_object structure. 2021-03-01 13:43:22 +03:00
Nikita Popov 47a2e5c785 Reference dynamic functions through dynamic_defs
Currently, dynamically declared functions and closures are inserted
into the function table under a runtime definition key, and then later
possibly renamed. When opcache is not used and a file containing a
closure is repeatedly included, this leads to a very large memory leak,
as the no longer needed closure declarations will never be freed
(https://bugs.php.net/bug.php?id=76982).

With this patch, dynamic functions are instead stored in a
dynamic_func_defs member on the op_array, which opcodes reference
by index. When the parent op_array is destroyed, the dynamic_func_defs
it contains are also destroyed (unless they are stilled used elsewhere,
e.g. because they have been bound, or are used by a live closure). This
resolves the fundamental part of the leak, though doesn't completely
fix it yet due to some arena allocations.

The main non-obvious change here is to static variable handling:
We can't destroy static_variables_ptr in destroy_op_array, as e.g.
that would clear the static variables in a dynamic function when
the op_array containing it is destroyed. Static variable destruction
is separated out for this reason (we already do static variable
destruction separately for normal functions, so we only need to
handle main scripts).

Closes GH-5595.
2021-03-01 11:35:54 +01:00
Dmitry Stogov 72c3ededed Change the order of properties used for var_dump(), serialize(), comparison, etc.
Now properties are ordered according to their layout in zend_object structure.
2021-03-01 13:29:49 +03:00
Max Semenik b86dfb0e74 Fix E_DEPRECATED in zend_vm_gen.php
explode(): Passing null to parameter #2 ($string) of type string is
deprecated

Closes GH-6698.
2021-03-01 11:22:18 +01:00
Dmitry Stogov 0f6c00200b Speed up __sleep() and __wakeup() calls 2021-02-25 12:16:22 +03:00
Dmitry Stogov 5caf29a01e Switch few functions useful in Symphony apps to new ZPP API. 2021-02-24 19:13:11 +03:00
Dmitry Stogov 99d0f502dc Fixed error message 2021-02-24 19:12:32 +03:00
Dylan T e5551d50e7 zend_compile.c: fix typo
Don't mind me, I just happened to be browsing this code. 🙃

Closes GH-6721.

[ci skip]
2021-02-24 10:10:19 +01:00
Máté Kocsis 4c6533c257 Generate class entries from stubs for com, standard, xmlreader, xmlwriter, xsl, zip, Zend
Closes GH-6706
2021-02-22 15:24:03 +01:00
Nikita Popov 8e8e0017b9 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix trampoline leak on dynamic static call of non-static method
2021-02-22 10:33:16 +01:00