Commit graph

219 commits

Author SHA1 Message Date
Nikita Popov
c7651c2396 Fix a couple of ASSIGN_DIM/OBJ inference bugs
Account for possible null return values better.
2016-09-24 22:43:27 +02:00
Nikita Popov
db801763e4 Add range inference for ZEND_STRLEN
On 32-bit systems we conservatively allow negative lengths.
On 64-bit systems, the range could additionally be restricted to
the canonical 48-bit size.
2016-09-24 22:43:27 +02:00
Dmitry Stogov
902e9ad014 Special handling for $php_errormsg and $http_response_header. 2016-09-15 03:07:31 +03:00
Dmitry Stogov
8cce8172af Merge branch 'PHP-7.1'
* PHP-7.1:
  Fixed type inference bug
2016-09-07 11:36:44 +03:00
Dmitry Stogov
6aa07c9083 Fixed type inference bug 2016-09-07 11:36:14 +03:00
Nikita Popov
daa2b75c76 Fix some sizeof(zend_long) > sizeof(size_t) issues
Fix a couple of mistakes that are only relevant if
sizeof(zend_long) > sizeof(size_t).

* Fix cast order in string offset check: Negation should happen
  after the (zend_long) cast, otherwise sign extension does not
  occur.
* Use Z_UL in zend_inference.
* Use aligned size for HT_USED_SIZE in zend_persist: The issue is
  that on x86-32 uint64_t is considered to be 4-aligned, so the
  alignment assumption does not hold.
2016-09-05 15:33:02 +02:00
Dmitry Stogov
129e8dadf4 op_arrays may be optimized independetly and "script" might be NULL 2016-08-23 13:17:53 +03:00
Xinchen Hui
66a527b8c1 Fixed segfault introduced in 447e57a1e1 2016-08-18 15:37:39 +08:00
Kalle Sommer Nielsen
447e57a1e1 Fixed 7.1 build, decls first please! 2016-08-17 20:26:32 +02:00
Nikita Popov
1a780e6727 Add assertion to prevent type narrowing
Currently type narrowing is always a bug, make sure we know about
it.
2016-08-05 16:30:57 +02:00
Nikita Popov
fc7c81ff54 Fixed bug #72762 2016-08-05 16:27:55 +02:00
Nikita Popov
5f6effed43 Add opcodes to zend_wrong_string_offset() 2016-07-10 15:15:34 +02:00
Aaron Piotrowski
d9a9cf8eca Merge branch 'master' into iterable 2016-07-03 22:42:10 -05:00
Dmitry Stogov
d898344663 Inline simple constant functions 2016-06-30 17:04:25 +03:00
Dmitry Stogov
871cd76af4 clanup 2016-06-29 17:53:39 +03:00
Nikita Popov
2710ce22a0 Remove assert for now 2016-06-28 18:47:29 +02:00
Nikita Popov
cdd58edf42 More type inferences fixes 2016-06-28 11:49:50 +02:00
Dmitry Stogov
1433162083 Fixed compilation warnings 2016-06-21 20:12:29 +03:00
Nikita Popov
811dfba4bf More type inference fixes 2016-06-16 14:25:48 +02:00
Dmitry Stogov
ff363e2e7c Implemented RFC: Replace "Missing argument" warning with "Too few arguments" exception
Squashed commit of the following:

commit 8b45fa2acb
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Jun 16 01:52:50 2016 +0300

    Separate slow path of ZEND_RECV into a cold function.

commit 9e18895ee5
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Jun 15 23:26:28 2016 +0300

    Required argument can't be IS_UNDEF anymore.

commit 662db66e39
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue May 31 17:14:50 2016 +0300

    Replace "Missing argument" warning by "Too few arguments" exception.
2016-06-16 02:32:02 +03:00
Dmitry Stogov
a9512af810 Implemented RFC: Fix inconsistent behavior of $this variable
Squashed commit of the following:

commit bdd3b6895c
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Jun 16 00:19:42 2016 +0300

    Fixed GOTO VM

commit 2f1d7c8b89
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Jun 15 21:01:57 2016 +0300

    Removed unused variable

commit cf749c42b0
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Jun 15 19:06:16 2016 +0300

    Protection from $this reassign through mb_parse_str()

commit 59a9a6c83c
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Jun 15 18:14:50 2016 +0300

    Added type inference rule for FETCH_THIS opcode

commit 73f8d14a85
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Jun 15 18:11:18 2016 +0300

    Restored PHP-7 behavior of isset($this->foo).
    It throws exception if not in object context.
    Removed useless opcode handlers.

commit fa0881381e
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue May 31 12:25:47 2016 +0300

    Changed "Notice: Undefined variable: this" into "Exception: Using $this when not in object context".

commit e32cc528c0
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue May 24 02:02:43 2016 +0300

    Throw exception on attempt to re-assign $this through extract() and parse_str().

commit 41f1531b52
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Mon May 23 22:18:36 2016 +0300

    Fixed inconsistent $this behavior
2016-06-16 02:30:23 +03:00
Nikita Popov
fba6f90ae3 Fix type inference bugs
* Add proper array_key_any|array_of_any|array_of_ref in some more
  places
* strlen() on objects may be null
* IS fetch on string dim may be null
2016-06-15 22:52:48 +02:00
Dmitry Stogov
d12987256a Fixed mistakes in type inference rules. 2016-06-15 23:04:17 +03:00
Nikita Popov
046889518d Add support for "instanceof" pi nodes 2016-06-13 19:03:59 +02:00
Nikita Popov
9877d8f019 Use union for pi constraints
This will make it easier to extend pi constraints without impacting
structure sizes.
2016-06-13 19:03:57 +02:00
Aaron Piotrowski
0dc772c9b4 Add iterable type to opcache 2016-06-10 19:01:27 -05:00
Nikita Popov
be37de1ff1 Use LCA for object(ce) type joins
For B, C extending A the join of object(B) and object(C) should
be object(instanceof A). For simplicity we only handle the class
hierarchy, as computing the least common unique ancestor for
interfaces would be more involved.

Also ignore phi sources that don't have an object type: The join
of null and object(A) is now null|object(A) rather than
null|object.
2016-06-07 20:42:00 +02:00
Nikita Popov
d8a2370884 Cleanup 2016-06-07 20:42:00 +02:00
Dmitry Stogov
80b39b498a Improve type narrowing (check only SSA definitions). 2016-06-06 14:57:02 +03:00
Nikita Popov
543649bd4c Fix correctness issues with type narrowing
Fixes bug #72335.
2016-06-06 14:56:17 +03:00
Dmitry Stogov
b111da96d9 Split ZEND_SEND_VAR_NO_REF into ZEND_SEND_VAR_NO_REF and ZEND_SEND_VAR_NO_REF_EX (similar to ZEND_SEND_VAL) and remove ZEND_ARG_* flags. 2016-05-31 04:06:00 +03:00
Nikita Popov
e745b4cad8 Replace BB end with BB len
And support empty blocks everywhere.
2016-05-24 18:29:44 +02:00
Nikita Popov
dd8379e046 Inference: $a[]= results in long keys 2016-05-14 17:16:32 +02:00
Nikita Popov
6079ba4b0c Inference: Fix undef handling for binary ops
We need to be careful about correctly handling that undef results
in a null value. Otherwise, apart from simply generating incorrect
results, we may also end up performing non-monotonic lattice
transitions, thus causing an infinite type inference loop (see
test).
2016-05-14 17:16:32 +02:00
Nikita Popov
773b377888 Inference: Use common handling for compound assign ops
Extract the inference code for binary operators and then handle all
ASSIGN_* opcodes the same way.
2016-05-14 17:16:32 +02:00
Nikita Popov
c5160d78f1 Add COPY_SSA_OBJ_TYPE macro
Use it consistently in the ASSIGN_* implementations, previously
it was only present in ASSIGN_ADD.
2016-05-14 17:16:32 +02:00
Nikita Popov
94d09163e7 Fix & improve assign_dim inference
Extract a helper function for handling ASSIGN_DIM and ASSIGN_*
with ASSIGN_DIM ev uniformly. Previously the code was copy pasted
for each ASSIGN_* op, but the variable names were not correctly
adjusted (tmp vs orig), so the type inference result was wrong.

Also sligthly improve handling:
 * Result cannot be false, will always be converted to array.
 * If the dim is a CONST string operand, we don't have to assume
   numeric strings.
 * If the inserted value may be undef, the array may contain null.
2016-05-14 17:16:32 +02:00
Dmitry Stogov
172d8552fc Fixed type inference rules. 2016-05-04 23:59:17 +03:00
Nikita Popov
0615c59a4f Mark all $php_errormsg as refs to inhibit optimization 2016-04-30 12:34:01 +02:00
Nikita Popov
55caaac73f Make MAY_BE_ERROR handling more accurate
This ended up causing weird things like MAY_BE_ERROR CVs.

Also make sure that ASSIGN result isn't MAY_BE_REF.
2016-04-21 23:49:20 +02:00
Nikita Popov
4f726be682 Fix SSA for SEND_UNPACK 2016-04-16 22:38:52 +02:00
Dmitry Stogov
aed4249653 Fixed handling of return statement without a value. 2016-04-07 18:59:04 +03:00
Dmitry Stogov
3444c1ae24 Use return type hints for type inference and eliminate useless VERIFY_RETRUN_TYPE opcodes. 2016-04-07 17:34:53 +03:00
Dmitry Stogov
82050dfd3c fixed type inference mistake (typo) 2016-04-01 20:29:54 +03:00
Dmitry Stogov
f3c70f118c Manual CSE 2016-03-31 17:26:27 +03:00
Kalle Sommer Nielsen
fc49f1c411 Fix build 2016-03-17 03:53:01 +01:00
Nikita Popov
47391961dd Mark uses in UNSET_VAR op1 + FE_FETCH_R op2 as no_val 2016-03-14 17:57:07 +01:00
Nikita Popov
a1c48d5e3a Various SSA-related tweaks
* Add FETCH_LIST to inference
* Restrict JMP_SET/COALESCE result type
* Fix typos in range inference
* Add const annotations in zend_ssa.h
* For pi statements dump the associated predecessor block
* If type can be both true and false, dump bool instead
2016-02-28 21:38:34 +01:00
Dmitry Stogov
4095d5f245 Cleanup OP_DATA usage. Now only first operand of OP_DATA is used for ASSIGN_DIM, ASSIGN_OBJ and ASSIGN_OP (DIM/OBJ) instructions. 2016-02-09 13:12:57 +03:00
Dmitry Stogov
f4bec6e137 After DFA pass result of FE_FETCH may be CV 2016-02-09 12:16:17 +03:00