1
0
mirror of https://github.com/php/php-src.git synced 2026-04-26 01:18:19 +02:00
Commit Graph

93 Commits

Author SHA1 Message Date
Máté Kocsis 5e424d2884 Fix a few ext/date return types 2021-08-26 15:26:13 +02:00
Máté Kocsis 9cd6c57ad1 Merge branch 'PHP-8.0'
* PHP-8.0:
  Sync ext/mysqli optimizer func info entries with the stubs
2021-08-26 12:14:21 +02:00
Máté Kocsis 765aec8623 Generate optimizer func info from stubs for ext/sodium (#7404) 2021-08-26 10:44:38 +02:00
Máté Kocsis 2d248c80b9 Generate optimizer func info from stubs for ext/date (#7403) 2021-08-25 21:29:46 +02:00
Máté Kocsis 50f31829b1 Generate optimizer func info from stubs for a few extensions - part 2 (#7401)
ext/bcmath, ext/fileinfo, ext/filter, ext/gettext, ext/session
2021-08-25 15:29:46 +02:00
Máté Kocsis d379044066 Generate a few missing optimizer function entries from stubs 2021-08-25 10:37:43 +02:00
Máté Kocsis 4a7a414735 Fix callable and iterable handling 2021-08-25 10:37:43 +02:00
Máté Kocsis bdfe0ab505 Generate Zend, ext/spl and ext/json optimizer func info from stubs
Closes GH-7397
2021-08-25 10:37:27 +02:00
Máté Kocsis b1822899fc Add support for generating optimizer function info from stubs (#7367) 2021-08-24 16:35:33 +02:00
Máté Kocsis 58fcded8ec Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix a few optimizer func info
2021-08-24 15:21:27 +02:00
Nikita Popov 8c67abb67f Drop gz aliases from func info
Func info does not need to include function aliases, we'll look
up based on the primary function name.
2021-08-23 10:41:41 +02:00
Nikita Popov 6e20f0f3a2 Returned interned string from fgetc()
Make use of single-character interned strings.
2021-08-16 11:15:23 +02:00
Nikita Popov a4c2fb1462 Fix func info for constant()/get_defined_constants()
As pointed out on GH-7367, these have not been adjusted for
object constant support.

Now the only thing the type info specifies is that array of ref
is not possible.
2021-08-16 10:57:46 +02:00
Dmitry Stogov 1ffbb7372a Better specialization for packed/hash arrays
- improved packed/hash inference.
- added hash guards for ASSIGN_DIM, ASSIGN_DIM_OP, FETCH_DIM_W* instructions
- more accurate invariant type guards motion
- invariant packed/hash guards motion
- rename MAY_BE_ARRAY_HASH into MAY_BE_ARRAY_NUMERIC_HASH and add MAY_BE_ARRAY_STRING_HASH
- cleanup
2021-08-13 14:30:41 +03:00
Dmitry Stogov aaa14501f8 Make private functions "static" and remove unused zend_inference_check_recursive_dependencies(). 2021-08-11 16:07:21 +03:00
Dmitry Stogov 14c103d7c5 Optimize "$x * 2" into "$x + $x" 2021-08-11 11:53:28 +03:00
Nikita Popov 315f40942b Always use CE_CACHE, remove TYPE_HAS_CE (#7336)
Currently, CE_CACHE on strings is only used with opcache interned strings. This
patch extends usage to non-opcache interned strings as well. This means that
most type strings can now make use of CE_CACHE even if opcache is not loaded,
which allows us to remove TYPE_HAS_CE kind, and fix some discrepancies
depending on whether a type stores a resolved or non-resolved name.

There are two cases where CE_CACHE will not be used:

 * When opcache is not used and a permanent interned string (that is not an
   internal class name) is used as a type name during the request. In this case
   we can't allocate a map_ptr index for the permanent string, as it would be
   not be in the permanent map_ptr index space.
 * When opcache is used but the script is not cached (e.g. eval'd code or
   opcache full). If opcache is used, we can't allocate additional map_ptr
   indexes at runtime, because they may conflict with indexes allocated by
   opcache.

In these two cases we would end up not using CE caching for property types
(argument/return types still have the separate cache slot).
2021-08-11 10:28:52 +02:00
Nikita Popov a4e206808c Use zend_string_equals_literal_ci() 2021-08-10 15:52:28 +02:00
Dmitry Stogov df6ffa806c Improve Range Inference
Support for simple negative range constraints on induction variables
2021-08-09 19:26:00 +03:00
Nikita Popov e2194c18df FETCH_STATIC_PROP_IS may return undef
We don't go out of our way to convert IS_UNDEF to IS_NULL for
this opcode. Reflect this in type info.
2021-07-21 17:19:43 +02:00
Nikita Popov d1456d1e3c Print MAY_BE_INDIRECT in dump 2021-07-21 17:19:43 +02:00
Nikita Popov e3d90fa7de Transfer MAY_BE_INDIRECT for VERIFY_RETURN
If the input is indirect, the output will be indirect too.
2021-07-21 17:19:43 +02: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
Nikita Popov 7b85d3bbdd Add support for verifying optimizer func info
This is guarded by -DZEND_VERIFY_FUNC_INFO=1. Enable this on the
variation job.

Closes GH-6924.
2021-07-21 12:24:30 +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
Nikita Popov b420d09f4d Fix type info for pg_socket()
This was mistakenly changed to MAY_BE_OBJECT when pgsql was
migrated to use objects. However, this particular function
still returns a (stream) resource.
2021-07-20 14:44:57 +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 273720dcf2 Add str_replace/array_unique to ct eval list
Taken from GH-5870.
2021-07-19 15:31:26 +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
Joe Watkins d0b09a7be4 Add first-class callables
Support acquiring a Closure to a callable using the syntax
func(...), $obj->method(...), etc. This is essentially a
shortcut for Closure::fromCallable().

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

Closes GH-7019.

Co-Authored-By: Nikita Popov <nikita.ppv@gmail.com>
2021-07-14 14:37:25 +02:00
Joe Watkins 60fbd6df95 replace phpdbg custom opcode dumper with O+ dump (#7227) 2021-07-13 15:32:14 +02:00
Kamil Tekiela 7bbc85f16a Sccp new functions for ct (#7220)
* strstr

* explode
2021-07-08 10:00:26 +01:00
George Peter Banyard 069a9fa5e4 Pure Intersection types (#6799)
Implement pure intersection types RFC

RFC: https://wiki.php.net/rfc/pure-intersection-types

Co-authored-by: Nikita Popov <nikic@php.net>
Co-authored-by: Ilija Tovilo <ilutov@php.net>
2021-07-05 14:11:03 +02:00
Patrick Allaert aff365871a Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +02:00
Patrick Allaert ceb6fa6dc0 Convert some recently introduced zend_bool to bool
As well as `scripts/dev/check_parameters.php` utility.

Cfr. 3e01f5afb1
2021-06-18 15:21:39 +01:00
Nikita Popov be369dec70 Deduplicate code for handling zend_type in inference
This should be doing the same for the argument and the property
type case.
2021-06-18 11:37:15 +02:00
Nikita Popov a30fab57eb Make can_elide_return_type_check() more robust
Rather than using def_info, check against the actual arg_info type.
As it is stored as a type mask nowadays, this is not much harder,
but more general and more robust as we don't need to deal with
inaccurate cases.
2021-06-18 11:17:32 +02:00
Nikita Popov 0d9269de75 Extract helper for fetching class entry in optimizer
This code is repeated a few time. Two occurrences additionally
contained checks for user classes in CG(class_table) with the
same file name, but as far as I know these should always be in
the script class_table, so I'm omitting the check here.
2021-06-18 10:48:48 +02:00
Dmitry Stogov cc0aac3f73 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed incorrect type inference for "(array)$null".
2021-06-17 13:05:45 +03:00
Dmitry Stogov c8ff5a1082 Fix assertions 2021-06-11 11:39:39 +03:00
Ben Morss 81f6d36c90 Add avif support to ext/gd
This backports avif support from upstream libgd into bundled libgd
and exposes the functionality through new imagecreatefromavif()
and imageavif() functions.

Closes GH-7026.

Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>
2021-06-10 12:32:30 +02:00
Dmitry Stogov 7368d0c418 Fixed bug #81096: Inconsistent range inferece for variables passed by reference
Detect references before range inference and exclude them from range
inference.
2021-06-10 11:43:15 +03:00
Nikita Popov cbe485db05 Make PRE_INC/PRE_DEC type inference more accurate
The return value can never be a reference, even if the variable
is a reference.

While here, also exclude the resource and array types which throw
a TypeError since PHP 8.0.
2021-06-09 15:15:23 +02:00
Nikita Popov ff2fbd0ecb Remove zend_make_printable_zval() use in debug code
This is an awkward API left from the PHP 5 times. Replacing it
with zval_get_string().
2021-06-09 10:19:42 +02:00
codinghuang 2f710f5bb2 Support custom passes in Optimizer 2021-06-06 08:10:11 +02:00
George Peter Banyard b6958bb847 Implement "Deprecate implicit non-integer-compatible float to int conversions" RFC. (#6661)
RFC: https://wiki.php.net/rfc/implicit-float-int-deprecate

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-05-31 15:48:45 +01:00
Nikita Popov ba9c0b38cb Export zend_unary_op_produces_error() and use in optimizer
Don't repeat this logic, as it's going to become more complex.
2021-05-27 16:33:30 +02:00
Máté Kocsis 6af5b369d7 Merge branch 'PHP-8.0'
* mysqli_get_client_info() cannot return null
2021-05-26 17:49:39 +02:00
Nikita Popov b55793e45b Merge branch 'PHP-8.0'
* PHP-8.0:
  Update func info for mysqli_connect
2021-05-26 14:36:52 +02:00
Joe Watkins b227a72285 ReflectionFunctionAbstract::getClosureUsedVariables
Make a distinction at compile time between bind types for static
  variables

  getStaticVariables remains unchanged

  Fixes #80071
2021-05-21 15:25:35 +02:00