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

2721 Commits

Author SHA1 Message Date
Nikita Popov 999e32b65a Implement union types
According to RFC: https://wiki.php.net/rfc/union_types_v2

The type representation now makes use of both the pointer payload
and the type mask at the same time. Additionall, zend_type_list is
introduced as a new kind of pointer payload, which is used to store
multiple class types. Each of the class types is a tagged pointer,
which may be either a class name or class entry. The latter is only
used for typed properties, while arguments/returns will instead use
cache slots. A type list can contain a mix of both names and CEs at
the same time, as not all classes may be resolvable.

One thing this is missing is support for union types in arginfo
and stubs, which I want to handle separately.

I've also dropped the special object code from the JIT implementation
for now -- I plan to add this back in a different form at a later time.
For now I did not want to include non-trivial JIT changes together
with large functional changes.

Another possible piece of follow-up work is to implement "iterable"
as an internal alias for "array|Traversable". I believe this will
eliminate quite a few special-cases that had to be implemented.

Closes GH-4838.
2019-11-08 15:15:48 +01:00
Nikita Popov ac4e0f0852 Make zend_type a 2-field struct
We now store the pointer payload and the type mask separately. This
is in preparation for union types, where we will be using both at
the same time.

To avoid increasing the size of arginfo structures, the
pass_by_reference and is_variadic fields are now stored as part of
the type_mask (8-bit are reserved for custom use).

Different types of pointer payloads are distinguished based on bits
in the type_mask.
2019-11-08 15:15:48 +01:00
Fabien Villepinte a555cc0b3d Clean DONE tags from tests
Remove most of the `===DONE===` tags and its variations.
Keep `===DONE===` if the test output otherwise becomes empty.

Closes GH-4872.
2019-11-07 21:31:47 +01:00
Máté Kocsis 14bdb0cfc7 Fix consistency issues with array accesses warnings/exceptions
* Change a number of "resource used as offset" notices to warnings,
   which were previously missed.
 * Throw the "resource used as offset" warning for isset() as well.
 * Make array_key_exists() behavior with regard to different key
   types consistent with isset() and normal array accesses. All key
   types now use the usual coercions and array/object keys throw
   TypeError.

Closes GH-4887.
2019-11-06 12:56:47 +01:00
Dmitry Stogov 61ebce1f06 Don't skip RECV instuctions when function uses type hints 2019-11-01 09:33:46 +03:00
Máté Kocsis 9493893412 Cleanup return values when parameter parsing is unsuccessful 2019-10-30 16:05:20 +01:00
Nikita Popov aef8836110 Don't check $this existence in object opcodes
We are now guaranteed that $this always exists inside methods, as
well as insides closures (if they use $this at all).

This removes checks for $this existence from the individual object
opcodes. Instead ZEND_FETCH_THIS is used in the cases where $this
is not guaranteed to exist, which is mainly the pseudo-main scope.

Closes GH-3822.
2019-10-30 09:30:13 +01:00
Nikita Popov 39897eb80b Try to fix asan warning in scalar_constant_defaults.phpt
Doing the SAVE_VALID_OPLINE right before the call, because we
still need r0 before that.
2019-10-29 10:01:35 +01:00
Nikita Popov e63a44dd03 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix bug #78226: Don't call __set() on uninitialized typed properties
2019-10-25 16:32:14 +02:00
Nikita Popov f1848a4b3f Fix bug #78226: Don't call __set() on uninitialized typed properties
Assigning to an uninitialized typed property will no longer trigger
a call to __set(). However, calls to __set() are still triggered if
the property is explicitly unset().

This gives us both the behavior people generally expect, and still
allows ORMs to do lazy initialization by unsetting properties.

For PHP 8, we should fine a way to forbid unsetting of declared
properties entirely, and provide a different way to achieve lazy
initialization.
2019-10-25 16:31:45 +02:00
Nikita Popov 7d056fc6c0 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #78747
2019-10-25 12:53:24 +02:00
Nikita Popov 4d8541debb Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #78747
2019-10-25 12:50:26 +02:00
Nikita Popov 74699533e5 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fixed bug #78747
2019-10-25 12:50:12 +02:00
Nikita Popov 5249993814 Fixed bug #78747 2019-10-25 12:47:18 +02:00
Nikita Popov 225a02f3d6 Merge branch 'PHP-7.4'
* PHP-7.4:
  Optimize VERIFY_RETURN_TYPE for TMP operands as well
2019-10-25 11:41:41 +02:00
Nikita Popov 6aece7be0a Optimize VERIFY_RETURN_TYPE for TMP operands as well
Only exclude CONST operands, which use a different instruction
format (they have a return operand).
2019-10-25 11:37:19 +02:00
Nikita Popov 711e2a1216 Merge branch 'PHP-7.4'
* PHP-7.4:
  Check class linking in VERIFY_RETURN_TYPE optimization
  Simplify travis setup scripts
2019-10-25 11:25:49 +02:00
Nikita Popov f07565b0eb Check class linking in VERIFY_RETURN_TYPE optimization
instanceof_function() requires linked classes. I'm not reusing
unlinked_instanceof() here, because it performs class loading,
which wouldn't be right here, I think.
2019-10-25 11:24:32 +02:00
Nikita Popov c858d17f06 Optimize instanceof_function
Split out the simple equality check into an inline function --
this is one of the common cases.

Replace instanceof_function_ex with zend_class_implements_interface.
There are a few more places where it may be used.
2019-10-25 10:51:17 +02:00
Nikita Popov ae46df0cb9 JIT: Add option to disable SSA checks 2019-10-23 11:25:13 +02:00
Nikita Popov fe6c420b02 JIT: Handle typed refs in assign dim 2019-10-23 11:25:10 +02:00
Nikita Popov ecc309bfb9 JIT: Fix handling of typed ref in assign dim op 2019-10-23 10:08:25 +02:00
Nikita Popov 2f80fbe3ae JIT: Fix handling of typed ref in assign op 2019-10-23 10:08:09 +02:00
Nikita Popov 8cdbcd7d91 JIT: Check exception after jit_assign_dim_op_helper 2019-10-23 10:07:59 +02:00
Nikita Popov 097184cae7 JIT: UNDEF result on "Illegal offset type" exception 2019-10-23 10:07:48 +02:00
Dmitry Stogov 626a5837c0 Merge branch 'PHP-7.4'
* PHP-7.4:
  Allow loading FFI bindings through ffi.preload directive
2019-10-22 17:53:24 +03:00
Dmitry Stogov 1417352dda Allow loading FFI bindings through ffi.preload directive 2019-10-22 17:52:56 +03:00
Dmitry Stogov 42f4bdba2a Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #78512 (Cannot make preload work)
2019-10-21 14:53:03 +03:00
Dmitry Stogov 05c5e5dfde Fixed bug #78512 (Cannot make preload work) 2019-10-21 14:52:26 +03:00
Dmitry Stogov 605e0de357 Clenup "smart branch" handling 2019-10-18 00:11:30 +03:00
Dmitry Stogov 65c4cc231d Fixed wrong shift 2019-10-17 23:31:47 +03:00
Nikita Popov e80934d747 Pass cache slot when printing type errors
Instead of using a separate ce.
2019-10-17 17:06:48 +02:00
Dmitry Stogov 3df64af965 Relay on DO_ICALL/DO_UCALL opcode to avoid generation of useless code 2019-10-17 12:55:36 +03:00
Dmitry Stogov 3a88c5b87a Fixed exception handling 2019-10-16 22:38:01 +03:00
Dmitry Stogov 5431837a6c Clenup "smart branch" handling 2019-10-16 12:28:30 +03:00
Dmitry Stogov 51da02375a Fixed exception handling 2019-10-16 02:36:06 +03:00
Dmitry Stogov 902b00e68e Fixed exception source 2019-10-16 01:26:35 +03:00
Dmitry Stogov 0d55456d73 Use "const" qualifier 2019-10-15 11:06:11 +03:00
Dmitry Stogov cef1960ce7 Use "const" qualifier 2019-10-14 21:49:08 +03:00
Dmitry Stogov 5213612359 Fixed compilation warning 2019-10-14 21:47:46 +03:00
Dmitry Stogov 2958fecb8b Fixed incorrect JIT compilation 2019-10-14 21:32:10 +03:00
Joe Watkins f8e3970ff0 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix checksum calculation for opcache
2019-10-14 16:50:56 +02:00
Joe Watkins 042e3b227e Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix checksum calculation for opcache
2019-10-14 16:50:23 +02:00
Joe Watkins 22ac57b064 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix checksum calculation for opcache
2019-10-14 16:49:48 +02:00
Mitch Hagstrand e2a6bf482f Fix checksum calculation for opcache 2019-10-14 16:46:42 +02:00
Dmitry Stogov 3f50922aee Fixed incorrect JIT compilation 2019-10-14 16:45:58 +03:00
Dmitry Stogov 4273865bba Drop checkpoint that leaded to use after free 2019-10-14 13:37:22 +03:00
Dmitry Stogov 5197d0cd5e Reduced number of CFG pass iterations 2019-10-14 11:37:10 +03:00
Dmitry Stogov daac578b51 Fixed JIT of preloaded script 2019-10-11 12:54:07 +03:00
Dmitry Stogov 2068ce9adf Use RT_CONSTANT() or CT_CONSTANT() macro depending on ZEND_ACC_DONE_PASS_TWO flag 2019-10-11 12:54:07 +03:00