Commit graph

61 commits

Author SHA1 Message Date
Dmitry Stogov
cfcee97ad6 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Remove range inference for booleans.
2021-12-10 14:33:36 +03:00
Dmitry Stogov
4ed10f3d47 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix refcount inferemce ($a += $a returns old array with RCN)
2021-12-06 11:31:51 +03:00
Dmitry Stogov
3564001502 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  JIT: Fix incorrect reference counting inference
2021-11-30 13:00:04 +03:00
Dmitry Stogov
2d3ea98624 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed type inference (it's safe to ignore reference counting narrowing)
2021-11-29 23:39:37 +03:00
Dmitry Stogov
23c5a6fd16 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  JIT: Fix exception handling when next array element is already occupied
2021-11-29 21:57:29 +03:00
Dmitry Stogov
c6e895aec2 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Disable type narrowing optimization when we contruct SSA for JIT
2021-11-29 15:53:16 +03:00
Dmitry Stogov
b1a1ed380f Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed incorrect narrowing to double
2021-11-25 15:15:01 +03:00
Dmitry Stogov
ecc4d1326b Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed incorrect refcountion inference for BW_NOT
2021-11-25 13:53:26 +03:00
Dmitry Stogov
fb582f4230 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  JIT: Fixed reference-counting inference
2021-11-15 10:40:35 +03:00
Dmitry Stogov
9bd490dc33 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed incorrect reference counter inference
2021-11-08 20:54:45 +03:00
Dmitry Stogov
22a171a0b5 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed type inference for FETCH_DIM_W without use
2021-11-03 19:45:30 +03:00
Dmitry Stogov
d4a7e4d1ff Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed incorrect assumption about reference counting
2021-11-01 20:28:33 +03:00
Nikita Popov
a89546d8b3 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Handle FETCH_DIM_R after FETCH_DIM_FUNC_ARG in inference
2021-11-01 14:27:14 +01:00
Nikita Popov
3d38960979 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix range inference hang
2021-11-01 12:32:04 +01:00
Dmitry Stogov
1208fe932a Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed type inference for COPY_TMP
2021-10-11 16:56:40 +03:00
Dmitry Stogov
04064187c2 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed type inference (ASSIGN_OP with typed reference may cause type conversion)
2021-10-11 10:50:06 +03:00
Nikita Popov
3661c1932c Fix array cast type inference wrt packed arrays
Use KEY_LONG instead of PACKED if it's possible for the array to
be empty. It won't be packed in that case.

Fixes oss-fuzz #39650.
2021-10-06 10:50:44 +02:00
Nikita Popov
944d653b3d Fix inference for INIT_ARRAY with illegal offset type
Extract assign_dim_array_result_type() helper that can be reused
for INIT_ARRAY and implements all this logic correctly.

Fixes oss-fuzz 5156868775870464.
2021-09-29 11:09:04 +02:00
Nikita Popov
69eb6e04a7 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix ASSIGN_DIM result inference with typed refs
  Remove outdated code in ASSIGN_DIM type inference
2021-09-28 14:14:29 +02:00
Nikita Popov
2b71df71a1 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix type inference and SCCP with typed references
2021-09-28 12:59:24 +02:00
Nikita Popov
2dc8c7b3a7 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix ASSIGN_STATIC_PROP_REF type inference
2021-09-22 15:55:42 +02:00
Dmitry Stogov
cffba945e5 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed type inference
2021-09-22 15:32:16 +03:00
Nikita Popov
37337507ec Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Don't unconditionally add array value type for undef
2021-09-21 14:54:34 +02:00
Nikita Popov
bda1ee9511 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix FETCH_OBJ_IS type inference
2021-09-17 17:05:42 +02:00
Nikita Popov
91aa78f9b4 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix may_throw for ASSIGN_OBJ
2021-09-16 12:47:04 +02:00
Nikita Popov
ce105f655a Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Handle undef assignment to typed ref
2021-09-15 10:58:41 +02:00
Nikita Popov
a2fc14c14f Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix BIND_STATIC may_throw check
2021-09-14 10:10:51 +02:00
Dmitry Stogov
6d1a2b3aed Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Properly check if BIND_STATIC may throw
2021-09-13 21:59:47 +03:00
Nikita Popov
8c601edada Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  BIND_STATIC may throw
2021-09-13 17:25:13 +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
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
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
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
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
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
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
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
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
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
Máté Kocsis
532c60cb92
Add support for tentative return types of internal methods
RFC: https://wiki.php.net/rfc/internal_method_return_types

Closses GH-6971
2021-05-14 15:55:25 +02:00
KsaR
01b3fc03c3
Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
Nikita Popov
b82242a88d Remove unnecessary php.h includes from Zend/
The Zend/ directory really shouldn't be including php headers.
These particular includes are plain unnecessary.
2021-04-20 12:21:45 +02:00
Josh Soref
462da6e09c Fix spelling and grammar mistakes
This PR corrects misspellings identified by the check-spelling action.

The misspellings have been reported at jsoref@b6ba3e2#commitcomment-48946465

The action reports that the changes in this PR would make it happy: jsoref@602417c

Closes GH-6822.
2021-04-13 12:09:37 +02:00