1
0
mirror of https://github.com/php/php-src.git synced 2026-04-18 13:31:27 +02:00
Commit Graph

3888 Commits

Author SHA1 Message Date
Dmitry Stogov
3e996622c7 Replace function with macro 2021-03-24 10:36:47 +03:00
Dmitry Stogov
7adaec1ce8 Move system independent code out from x86 specific header 2021-03-23 17:12:15 +03:00
Dmitry Stogov
c290de157c Move x86 dependent code out from platform independed parts. 2021-03-23 16:39:51 +03:00
Dmitry Stogov
617276d807 Use capstone disassembler, if available. 2021-03-23 12:39:42 +03: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
8ed8cf86a9 Use zend_string* instead of char* 2021-03-22 14:56:16 +03:00
Dmitry Stogov
6690547a58 Use zend_hash_lookup() 2021-03-19 23:34:38 +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
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
2f73cbb1b1 Update one more use of NO_AUTOLOAD 2021-03-18 16:25:22 +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
Dmitry Stogov
eb8f5e4347 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80861 (erronous array key overflow in 2D array with JIT)
2021-03-17 23:00:22 +03:00
Dmitry Stogov
7e494d9225 Fixed bug #80861 (erronous array key overflow in 2D array with JIT) 2021-03-17 22:59:59 +03: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
Dmitry Stogov
8f0ca7c16c Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80839 (PHP problem with JIT)
2021-03-17 16:55:42 +03:00
Dmitry Stogov
faf1567212 Fixed bug #80839 (PHP problem with JIT) 2021-03-17 16:55:09 +03:00
Nikita Popov
709e45d89b Avoid unnecessary static_variables persistence
static_variables should be treated the same way as all other
op_array components nowadays (only static_variables_ptr is
special). There's no need to persist/serialize it is separately
per shared op_array.
2021-03-17 12:20:58 +01:00
Nikita Popov
4cff8c10a9 Simplify attribute persistence
For an inherited op_array, directly fetch the xlat entry, as we
do for everything else.
2021-03-17 11:52:45 +01: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
82622d7583 Fix refcount inference for typed properties
We were not adding RC1/RCN if the MAY_BE_OBJECT came from a class
type and there was no other refcounted type in the union.
2021-03-16 11:17:18 +01:00
Nikita Popov
3b9ea4d289 Merge branch 'PHP-8.0'
* PHP-8.0:
  ext/opcache: fix configure output while checking mmap MAP_ANON support
2021-03-15 10:53:08 +01:00
Michael Heimpold
eaf9421df6 ext/opcache: fix configure output while checking mmap MAP_ANON support
It seems that f3efb9e3fb introduced a "typo" which may result
in the following confusing message:

checking for mmap() using MAP_ANON shared memory support... no=yes

Let's fix this.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>

Closes GH-6758.
2021-03-15 10:52:57 +01:00
Dmitry Stogov
65859fe17e Inheritance cache optimization 2021-03-11 13:42:35 +03:00
Dmitry Stogov
d02197853e Fixed assertion (ext/opcache/zend_persist.c:327: zend_accel_get_type_map_ptr: Assertion `ret > 2' failed) 2021-03-10 17:39:26 +03:00
Dmitry Stogov
d336ccaa08 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80814 (threaded mod_php won't load on FreeBSD: No space available for static Thread Local Storage)
2021-03-10 16:04:33 +03:00
Dmitry Stogov
3b377b51a2 Fixed bug #80814 (threaded mod_php won't load on FreeBSD: No space available for static Thread Local Storage) 2021-03-10 16:03:47 +03:00
Nikita Popov
8a134c9a26 Merge branch 'PHP-8.0'
* PHP-8.0:
  Add supports for FreeBSD's PROT_MAX to let mprotect knows X flag can be applied in addition.
2021-03-05 16:44:25 +01:00
David Carlier
ae23852e41 Add supports for FreeBSD's PROT_MAX to let mprotect knows X flag can be applied in addition.
Closes GH-6738.
2021-03-05 16:44:08 +01:00
Christoph M. Becker
9f7c6a824a Merge branch 'PHP-8.0'
* PHP-8.0:
  Print error code if CreateMutex() fails
2021-03-05 15:09:26 +01:00
Christoph M. Becker
1c16749eaa Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Print error code if CreateMutex() fails
2021-03-05 15:08:24 +01:00
Christoph M. Becker
e0e167e581 Print error code if CreateMutex() fails
This issue came up recently in a bug report[1]; without the error code,
users can barely guess why the function failed.

[1] <https://bugs.php.net/80812>

Closes GH-6745.
2021-03-05 15:06:18 +01:00
Nikita Popov
97de8cfc71 Fix dynamic func def persist with preloading
If we find an existing serialization of the op_array, of course
we also need to actually make use of it...
2021-03-04 16:15:05 +01:00
Dmitry Stogov
4b59071844 Switch to new ZPP 2021-03-04 02:11:21 +03:00
Dmitry Stogov
c28751c69c Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80802: (zend_jit_fetch_indirect_var assert failure with tracing JIT)
2021-03-02 00:01:01 +03:00
Dmitry Stogov
957cb13a49 Fixed bug #80802: (zend_jit_fetch_indirect_var assert failure with tracing JIT) 2021-03-01 23:57:20 +03:00
Nikita Popov
e857936518 Fixed bug #80805
Handle missing result_var in binary_op_result_type.

(cherry picked from commit 8446e28275)
2021-03-01 15:13:15 +01: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
Nikita Popov
23afc62080 Allow pointer to end of memory in IS_UNSERIALIZED()
We already use <= for IS_SERIALIZED(), but the same general
problem can also occur for IS_UNSERIALIZED(). We don't seem to
hit this in practice prior to GH-5595 though.
2021-02-24 11:46:35 +01:00
Dmitry Stogov
ae2ea348dd Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80782 (DASM_S_RANGE_VREG on PHP_INT_MIN-1)
2021-02-24 12:20:49 +03:00
Dmitry Stogov
b7fa5268e4 Fixed bug #80782 (DASM_S_RANGE_VREG on PHP_INT_MIN-1) 2021-02-24 12:20:20 +03:00
Nikita Popov
8be711be47 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80786
2021-02-23 10:22:20 +01:00
Nikita Popov
79cf2c56d3 Fixed bug #80786
Don't use r0 as temporary register in math_double_long if it is
already used for a memory result.

This was already done in one branch, but not the other.
2021-02-23 10:22:00 +01:00
Dmitry Stogov
ac7e967b67 Reduce ZPP API overhead 2021-02-20 13:59:29 +03:00
Nikita Popov
5d160e309e Fix static variable behavior with inheritance
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.
2021-02-18 11:18:19 +01:00
Dmitry Stogov
5c78e87399 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80745 (JIT produces Assert failure and UNKNOWN:0 var_dumps in code involving bitshifts)
2021-02-17 11:51:50 +03:00
Dmitry Stogov
7f68a7afe6 Fixed bug #80745 (JIT produces Assert failure and UNKNOWN:0 var_dumps in code involving bitshifts) 2021-02-17 11:51:13 +03:00
Dmitry Stogov
319f73e06b Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80742 (Opcache JIT makes some boolean logic unexpectedly be true)
2021-02-16 20:02:48 +03:00
Dmitry Stogov
fad87a24da Fixed bug #80742 (Opcache JIT makes some boolean logic unexpectedly be true) 2021-02-16 20:02:12 +03:00
Máté Kocsis
bf0f6aaf18 Improve class entry generation
Related to GH-6701
2021-02-16 13:09:56 +01:00
Dmitry Stogov
15f713bd85 Persist class name before methods, because it may be used insted of "self" 2021-02-15 12:33:53 +03:00