| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
If an internal class overrides read_property and declared property
types, make sure that the returned value matches the declared
type (in debug builds).
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
When a method is inherited, the static variables will now always
use the initial values, rather than the values at the time of
inheritance. As such, behavior no longer depends on whether
inheritance happens before or after a method has been called.
This is implemented by always keeping static_variables as the
original values, and static_variables_ptr as the modified copy.
Closes GH-6705.
|
| |
|
|
|
|
| |
https://github.com/php/php-src/pull/4981)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The C compiler sees that a dynamic function is being called, so it cannot infer
that iter->funcs has not changed.
This results in more assembly instructions and slightly more time to execute that code
path.
Unpacking traversables to arrays(`ZEND_ADD_ARRAY_UNPACK`),
starting foreach loops (`ZEND_FE_FETCH*`), etc. are affected.
```
<?php
/*
* Before: 1.576 seconds
* After: 1.474 seconds
*/
function example() {
$start = hrtime(true);
$it = new SplFixedArray(1000);
$total = 0;
for ($i = 0; $i < 100000; $i++) {
$total += count([...$it]);
}
$end = hrtime(true);
printf("Elapsed: %.6f\n", ($end - $start) / 1_000_000_000);
}
example();
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This deprecates passing null to non-nullable scale arguments of
internal functions, with the eventual goal of making the behavior
consistent with userland functions, where null is never accepted
for non-nullable arguments.
This change is expected to cause quite a lot of fallout. In most
cases, calling code should be adjusted to avoid passing null. In
some cases, PHP should be adjusted to make some function arguments
nullable. I have already fixed a number of functions before landing
this, but feel free to file a bug if you encounter a function that
doesn't accept null, but probably should. (The rule of thumb for
this to be applicable is that the function must have special behavior
for 0 or "", which is distinct from the natural behavior of the
parameter.)
RFC: https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg
Closes GH-6475.
|
|
|
|
| |
argument/result type checks
|
|
|
|
|
|
|
|
|
|
| |
This is a new transparent technology that eliminates overhead of PHP class inheritance.
PHP classes are compiled and cached (by opcahce) separately, however their "linking" was done at run-time - on each request. The process of "linking" may involve a number of compatibility checks and borrowing methods/properties/constants form parent and traits. This takes significant time, but the result is the same on each request.
Inheritance Cache performs "linking" for unique set of all the depending classes (parent, interfaces, traits, property types, method types involved into compatibility checks) once and stores result in opcache shared memory. As a part of the this patch, I removed limitations for immutable classes (unresolved constants, typed properties and covariant type checks). So now all classes stored in opcache are "immutable". They may be lazily loaded into process memory, if necessary, but this usually occurs just once (on first linking).
The patch shows 8% improvement on Symphony "Hello World" app.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This adds support for:
$array1 = ['a' => 1, 'b' => 2];
$array2 = ['b' => 3, 'c' => 4];
$array = [...$array1, ...$array2];
// => ['a' => 1, 'b' => 3, 'c' => 4]
RFC: https://wiki.php.net/rfc/array_unpacking_string_keys
Closes GH-6584.
|
|\
| |
| |
| |
| | |
* PHP-8.0:
Allow observer handlers disabling optimization in RETURN opcode handler, that may cause loss value of returned local variable.
|
| |
| |
| |
| | |
that may cause loss value of returned local variable.
|
|\ \
| |/
| |
| |
| | |
* PHP-8.0:
Fix VAR return type verification
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
We should also set retval_ref when de-indirecting. Otherwise the
retval_ref != retval_ptr comparison below may incorrect assume
that we're returning a reference.
I don't have a reliable reproducer for this issue, but it sometimes
appears in certain configurations in arrow_functions/007.phpt in
conjunction with other changes.
|
| |
| |
| |
| |
| | |
It was present on other operations, including isset(), but was
missing for unset().
|
| |
| |
| |
| |
| |
| |
| | |
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.
Of course, zend_bool is retained as an alias.
|
| |
| |
| |
| | |
checks by ZEND_ASSERT().
|
| | |
|
|/
|
|
|
|
|
|
|
| |
This restricts allowed usage of $GLOBALS, with the effect that
plain PHP arrays can no longer contain INDIRECT elements.
RFC: https://wiki.php.net/rfc/restrict_globals_usage
Closes GH-6487.
|
|
|
|
|
|
|
| |
Make sure that the return value is available to observers, even if
it is not used by the caller.
Closes GH-6422.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
If we have an undefined variable and null is not accepted by the
return type, we want to throw just the undef var error.
In this case this lead to an infinite loop, because we overwrite
the exception opline in SAVE_OPLINE and it does not get reset
when chaining into a previous exception. Add an assertiong to
catch this case earlier.
|
|\
| |
| |
| |
| | |
* PHP-7.4:
Avoid non-object in FE_FREE
|
| |
| |
| |
| |
| |
| | |
Even if the properties HT is empty, make sure we still leave an
object in the FE_RESET result, so our type inference results
stay correct.
|
|\ \
| |/
| |
| |
| | |
* PHP-7.4:
Fixed bug #80186
|
| |
| |
| |
| |
| | |
Early exit in FE_RESET if get_properties() returns empty array,
as we cannot add HT iterators to zend_empty_array.
|
| |
| |
| |
| | |
ZEND_HANDLE_EXCEPTION might call zend_observer_fcall_end() even if exception is cought by function. The fix moved zend_observer_fcall_end() into a right place and remove OBSERVER sepecialization for ZEND_HANDLE_EXCEPTION handler.
|
| |
| |
| |
| | |
Closes GH-6180
|
| |
| |
| |
| |
| | |
These error conditions throw in the function implementations,
make the opcodes match.
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| | |
We need to initialize the result variable in the exceptional
case as well.
Fixes oss-fuzz #25526.
|
| |
| |
| |
| | |
Closes GH-5999
|
| | |
|
|\ \
| |/
| |
| |
| | |
* PHP-7.4:
Fixed bug #80049
|
| |\
| | |
| | |
| | |
| | | |
* PHP-7.3:
Fixed bug #80049
|
| | |
| | |
| | |
| | |
| | | |
Type checking may convert to refcounted values, so force freeing
of extra args.
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Closes GH-5857.
Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
Co-authored-by: Sammy Powers <sammyk@datadoghq.com>
|
| | |
| | |
| | |
| | |
| | |
| | | |
After a99d08b5d135fffa1d83b08b056e0080d295d863 the type can
include UNDEF. However, UNDEF can only reach FE_FREE, not FE_FETCH.
As such, simply ignore this type.
|
| | | |
|
| | |
| | |
| | |
| | |
| | | |
zend_verify_type_error_common() no longer needs the cache_slot,
so drop it there and from all users.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Voidification of Zend API which always succeeded
Use bool argument types instead of int for boolean arguments
Use bool return type for functions which return true/false (1/0)
Use zend_result return type for functions which return SUCCESS/FAILURE as they don't follow normal boolean semantics
Closes GH-6002
|
| | | |
|
| | | |
|