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

139 Commits

Author SHA1 Message Date
Dmitry Stogov b7e1eecd54 Avoid generation of "jmp" to next instruction 2019-12-17 15:42:02 +03:00
Dmitry Stogov 97bba4ffd6 Make "exception_handler_undef" stub to check EG(opline_before_exception) and undefine corresponnding result variable, if necessary.
This fixes few invalid "exception_handler_undef" usages.
2019-12-17 14:09:26 +03:00
Dmitry Stogov ebf35cc8e8 Fixed operation with result in CPU register 2019-12-06 17:16:46 +03:00
Dmitry Stogov 990b556761 Use cheaper code for overflow +/-1 2019-12-06 14:04:58 +03:00
Lucas Martín c0e049656c Fix typo in xmm15 register 2019-12-01 12:28:19 +01:00
Dmitry Stogov f8f48ce8f5 Refactor JIT to reduce back-end dependency from SSA representation.
This commit shouldn't change JIT behavior, but it adds asserts, that may catch wrong-cases occasionally passed before.
2019-11-29 19:07:17 +03:00
Dmitry Stogov b7241adf5e typos 2019-11-28 13:23:17 +03:00
Dmitry Stogov 36175b3c3d Fixed wrong parameteris order 2019-11-27 16:48:01 +03:00
Dmitry Stogov 40ef3196e0 Fixed register allocation 2019-11-27 16:26:43 +03:00
Dmitry Stogov 249e9a63e8 Fixed JIT for LONG->DOUBLE conversion when optimizer disabled 2019-11-27 14:31:24 +03:00
Dmitry Stogov b046a8f7f8 Fixed incorrect JIT compilation 2019-11-26 16:45:19 +03:00
Dmitry Stogov 36afe4e39e Optimize $x === null into is_null($x) 2019-11-12 13:49:55 +03:00
Dmitry Stogov d94c27dcca Fixed JIT for TYPE_CHECK opcode (exception handling in case of undefined argument) 2019-11-12 10:42:29 +03:00
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
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
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 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 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 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
Dmitry Stogov 3f50922aee Fixed incorrect JIT compilation 2019-10-14 16:45:58 +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
Dmitry Stogov 3ad20f80f5 Revert/redo pass_two only once 2019-10-10 23:20:36 +03:00
Dmitry Stogov f6f32f2cf0 SAMRT BRANCH improvement.
Avoid need of insertion NOP opcoes between unrelated SMART BRANCH instruction and following JMPZ/JMPNZ.
Now instead of checking the opcode of following instruction, the same information is encoded into SMART BRANH result_type.
2019-10-09 13:48:39 +03:00
Nikita Popov 2f92957fd3 Convert some notices to warnings
Part of https://wiki.php.net/rfc/engine_warnings.
2019-10-02 10:34:08 +02:00
Nikita Popov 27ad0efb58 Revert "Save opline before fallible arg type check in recv_init jit"
This reverts commit b09bddcaa5.

This causes test failures on macos -- presumably the relevant
difference is that it has no global regs. I suspect that this
is related to the fact that SAVE_VALID_OPLINE may use r0 as
a scratch register, which is already in use. Reverting for now.
2019-10-01 22:16:56 +02:00
Nikita Popov b09bddcaa5 Save opline before fallible arg type check in recv_init jit
The verify arg functions may throw an exception, so we need to save
the opline beforehand. Asan failures could be observed in
Zend/tests/type_declarations/scalar_constant_defaults.phpt
with a ZTS build.
2019-10-01 17:19:27 +02:00
Nikita Popov 01fc1a3057 Remove most uses of the ERROR type
It is now only used to signal exceptions for property reads. ERROR
zvals are never returned back to the VM anymore, so there's no
need to check for them when receiving a VAR.

Also return MAY_BE_ERROR, as ERROR is now no longer relevant for
inference.
2019-09-30 11:35:07 +02:00
Nikita Popov e8b0163e0b Promote write "use scalar as array" warning to Error 2019-09-27 15:49:18 +02:00
Nikita Popov 0ebf2bdba0 Convert "Illegal offset type" warnings to exceptions 2019-09-27 13:00:07 +02:00
Nikita Popov f2b09969db Convert "cannot add element" warning to exception 2019-09-27 13:00:07 +02:00
Dmitry Stogov 7d7b20ea91 Don't generate useless stubs 2019-09-26 23:21:48 +03:00
Dmitry Stogov 1030ff5f5f Use cheaper code for scalar type check 2019-09-23 23:04:08 +03:00
Dmitry Stogov 6e226c188c Change ZEND_RECV and ZEND_RECV_VARIADIC to use extended_value for cache slot (instead of op2), to be consistent with ZEND_RECV_INIT. 2019-09-23 22:28:56 +03:00