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

4332 Commits

Author SHA1 Message Date
Nikita Popov 9fe3aab7c5 Remove declares inside functions as well 2021-08-02 10:41:27 +02:00
Nikita Popov 8356da600b Remove dynamic defs from methods as well
We need to remove DECLARE_FUNCTION + dynamic_defs for functions
defined in methods as well, not just for those declared in the
main script.
2021-08-02 10:29:58 +02:00
Nikita Popov 9ee9393784 Skip shebang on preload script 2021-07-30 16:11:47 +02:00
Nikita Popov 67b5d8fcdc Don't reverse class order during preloading
We don't guarantee any particular order, but this reduces test
failures under --preload that are sensitive to class order.

Add some ZEND_HASH_FOREACH_*_FROM macros to allow skipping the
persistent classes while iterating in forward direction.
2021-07-30 15:14:17 +02:00
Nikita Popov d836046ab8 Perform preloading attempt on copied class
It is very hard to determine in advance whether class linking will
fail due to missing dependencies in variance checks (#7314 attempts
this). This patch takes an alternative approach where we try to
perform inheritance on a copy of the class (zend_lazy_class_load)
and then restore the original class if inheritance fails. The fatal
error in that case is recorded and thrown as a warning later.

Closes GH-7319.
2021-07-30 15:09:49 +02:00
Nikita Popov b1b0c81e39 Don't print preload warning for non-top-level classes
Dynamically declared classes categorically do not get linked during
preloading, even if all their dependencies are known. The warning
is misleading in this case, and there isn't anything the user can
do to address it.
2021-07-30 10:27:51 +02:00
Nikita Popov 29aed2a6c8 Clean up dependency resolution during preloading
Combine the code for checking whether all dependencies are
available and reporting an error if they are not. Actually store
the loaded deps and then use those when checking for type
availability, instead of looking up the same classes again and
again.
2021-07-28 16:55:06 +02:00
Mike Pall 58040f257c DynASM/x86: Add missing escape in pattern. 2021-07-28 17:13:08 +03:00
Nikita Popov e011952576 Preload unlinked classes, remove preload autoload (#7311)
Currently, classes that can't be linked get moved back into the original script
and are not preloaded. As such classes may be referenced from functions that
did get preloaded, there is a preload autoload mechanism to load them at
runtime.

Since PHP 8.1, we can safely preload unlinked classes, which will then go
through usual lazy loading. This means that we no longer need the preload
autoload mechanism. However, we need to be careful not to modify any hash
table buckets in-place, and should create new buckets for lazy loaded classes.
2021-07-28 14:27:58 +02:00
Nikita Popov 380e705fc2 Use consistent line numbers for early binding errors
Non-early-bound classes report inheritance errors at the first line
of the class, if no better line information is available (we should
really store line numbers for properties at least...) Early bound
classes report it at the last line of the class instead.

Make the error reporting consistent by always reporting at the
first line.
2021-07-28 12:35:20 +02:00
Nikita Popov 8834cf013b Handle missing class when evaluating CONST_ENUM_INIT
When resolving constants on a dynamically declared class during
preloading, the enum class may not be available. Fail gracefully
in that case.

Possibly we shouldn't be trying to evaluate constants on
non-linked classes at all?
2021-07-27 14:36:38 +02:00
Nikita Popov 8675380b67 Increment refcounts in mutable data copies
For mutable_data on preloaded classes, there may be refcounted
values in the constants/properties table.
2021-07-27 12:29:46 +02:00
Nikita Popov 1bd6fafa2f Fix preloading of trait property attributes 2021-07-27 12:07:22 +02:00
Nikita Popov 5a7e1a7aa8 Don't use IMMUTABLE flag to decide whether mutable_data is used
mutable_data may be used for IMMUTABLE classes, internal classes
and to-be-preloaded classes. Check whether the mutable_data
map_ptr is set rather than only the IMMUTABLE flag.
2021-07-27 11:44:01 +02:00
Nikita Popov b35418402f Allocate map_ptr for mutable_data during preloading
We need to discard objects in the class constants if they happened
to be evaluated during preloading. To allow doing so, we need to
use mutable_data, which will place the evaluated constants into
a separate table.
2021-07-27 11:16:38 +02:00
Nikita Popov c1959e63e5 Fix preloading of enums
We should not store constants that resolve to objects.
2021-07-27 11:01:44 +02:00
Nikita Popov 703e92c121 Don't force constant resolution for include preloading
Same as with property types, we no longer require that all constants
are resolved for preloading to work, it's just an optimization. As
such, drop the forced resolution for include-based preloading and
just keep the optimization.
2021-07-27 10:50:31 +02:00
Nikita Popov 70195c3561 Don't force property type resolution for include preloading
Having all property types resolved is no longer a hard requirement
for preloading, resolving the types is just an optimization. As
such, drop the special logic that forced loading of property
types when include-based preloading is used. Instead only keep
the code that resolves types based on actually preloaded classes.

Also drop the ZEND_ACC_PROPERTY_TYPES_RESOLVED flag, which is now
nearly useless and takes up flag space...
2021-07-27 10:36:21 +02:00
Nikita Popov 3eb97a4566 Always use separate static_members_table
When running without opcache, static_members_table is shared with
default_static_members_table. This is visible in reflection output,
because ReflectionProperty::getDefaultValue() will return the
current value, rather than the default value.

Address this by never sharing the table, which matches the behavior
we already see under opcache.

Fixes bug #80821.

Closes GH-7299.
2021-07-23 09:29:32 +02:00
Dmitry Stogov e1f211f7bb Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed typo
2021-07-22 16:15:44 +03:00
Dmitry Stogov 8fbeebec34 Fixed typo 2021-07-22 16:14:26 +03:00
Dmitry Stogov 9c2b87c3cf JIT: avoid $this check in closures called from methods 2021-07-22 16:05:43 +03:00
Dmitry Stogov 713eec75f2 Merge branch 'PHP-8.0'
* PHP-8.0:
  Added test
2021-07-21 19:43:00 +03:00
Dmitry Stogov 17b5fe13e2 Added test 2021-07-21 19:29:59 +03:00
Dmitry Stogov 053c56f52e Fixed bug #81226 (Integer overflow behavior is different with JIT enabled) 2021-07-21 19:28:43 +03:00
Dmitry Stogov 9108ac678e Fixed test 2021-07-21 14:51:36 +03:00
Dmitry Stogov a3a74b07e5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed Bug #80959 (infinite loop in building cfg during JIT compilation)
2021-07-21 14:34:04 +03:00
Dmitry Stogov a9991fbf28 Fixed Bug #80959 (infinite loop in building cfg during JIT compilation) 2021-07-21 14:32:44 +03:00
Nikita Popov a3f5b11994 Sync JIT overloaded assign/inc/dec overloaded property
We should only release the read_property return value if
retval is used, same as in zend_execute.c. This fixes a test
failure under PROFITABILITY_CHECKS=0.
2021-07-21 10:45:02 +02:00
Nikita Popov a190c7fdb7 Sync JIT zend_check_string_offset()
Return after zend_jit_illegal_string_offset() to avoid a redundant
warning during conversion.

This fixes some tests under PROFITABILITY_CHECKS=0.
2021-07-21 10:32:45 +02:00
Levi Morrison ae8647d9d3 Remove leading underscore for _zend_hash_find_known_hash (#7260)
Convert zend_hash_find_ex(..., 1) to zend_hash_find_known_hash(...)
Convert zend_hash_find_ex(..., 0) to zend_hash_find(...)

Also add serializable changes to UPGRADING.INTERNALS summary
2021-07-20 17:07:17 -06:00
Dmitry Stogov c22a4d76d5 Fixed test 2021-07-20 22:21:10 +03:00
Dmitry Stogov 4cf7a25856 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed Bug #81255 (Memory leak in PHPUnit with functional JIT)
2021-07-20 22:17:41 +03:00
Dmitry Stogov 02acc5ad3b Fixed Bug #81255 (Memory leak in PHPUnit with functional JIT) 2021-07-20 22:14:32 +03:00
Christoph M. Becker 520a8e002a Skip new preload test on Windows 2021-07-20 16:32:24 +02:00
Nikita Popov c14c82e22f Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug #81272: Fix func info for functions returning EMPTY_ARRAY
2021-07-20 14:41:43 +02:00
Nikita Popov 051ff33660 Fix bug #81272: Fix func info for functions returning EMPTY_ARRAY
The empty array has refcount > 1, so we should indicate this in
func info. In most cases this renders the func info redundant,
so drop it entirely.
2021-07-20 14:40:17 +02:00
Dmitry Stogov 1e4095f03d Fixed bug #81256 (Assertion `zv != ((void *)0)' failed for "preload" with JIT) 2021-07-20 15:27:43 +03:00
Joe Watkins 27bb57356c Merge branch 'master' of github.com:php/php-src
* 'master' of github.com:php/php-src:
  Implement readonly properties
2021-07-20 12:32:51 +02:00
Joe Watkins 570d9b63e9 Not serializable flag permeation 2021-07-20 12:28:35 +02:00
Nikita Popov 6780aaa532 Implement readonly properties
Add support for readonly properties, for which only a single
initializing assignment from the declaring scope is allowed.

RFC: https://wiki.php.net/rfc/readonly_properties_v2

Closes GH-7089.
2021-07-20 12:05:46 +02:00
Christoph M. Becker 0ce1cd1370 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #81206: Multiple PHP processes crash with JIT enabled
2021-07-19 23:52:51 +02:00
Christoph M. Becker ef77d3c89f Fix #81206: Multiple PHP processes crash with JIT enabled
We need to avoid resetting the JIT for all SAPIs, but we need to
initialize the JIT handlers even when only reattaching on Windows.

Closes GH-7208.
2021-07-19 23:45:37 +02:00
Kamil Tekiela 052af90b86 Deprecate autovivification on false
Deprecate automatically converting "false" into an empty array
on write operands. Autovivification continues to be supported
for "null" values, as well as undefined/uninitialized values.

RFC: https://wiki.php.net/rfc/autovivification_false

Closes GH-7131.

Co-authored-by: Tyson Andre <tysonandre775@hotmail.com>
Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-07-19 14:49:37 +02:00
Dmitry Stogov 28f6a2ba6e Merge branch 'PHP-8.0'
* PHP-8.0:
  Avoid ASAN integer overflow warnings
2021-07-19 14:55:07 +03:00
Dmitry Stogov 15abbea5e7 Avoid ASAN integer overflow warnings 2021-07-19 14:53:23 +03:00
Dmitry Stogov de1a1d5a36 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed incorrec immediate encoding when using LEA optimization
2021-07-19 14:53:09 +03:00
Hao Sun c5d93aeee9 Fixed incorrec immediate encoding when using LEA optimization 2021-07-19 14:51:08 +03:00
Máté Kocsis 75a678a7e3 Declare tentative return types for Zend (#7251)
Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-07-19 13:44:20 +02:00
Dmitry Stogov 66328742ea Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #81249 (Intermittent property assignment failure with JIT enabled)
2021-07-19 12:14:55 +03:00