Commit graph

65 commits

Author SHA1 Message Date
Nikita Popov
d1a012b602 Support more than two successors in opcache CFG 2017-04-10 22:18:24 +02:00
Thomas Punt
9f08aff3fd Remove superfluous allocation checks around ZMM-based functions 2017-04-02 00:58:19 +02:00
Dmitry Stogov
6af1ffb57d Allow SSA construction with source information about CV used as result 2017-03-30 20:14:01 +03:00
Dmitry Stogov
6a31872307 Merge branch 'PHP-7.1'
* PHP-7.1:
  Fixed pointer allignment
2017-03-07 10:18:57 +03:00
Dmitry Stogov
d9231b1667 Fixed pointer allignment 2017-03-07 10:18:34 +03:00
Sammy Kaye Powers
dac6c639bb Update copyright headers to 2017 2017-01-04 11:23:42 -06:00
Sammy Kaye Powers
9e29f841ce Update copyright headers to 2017 2017-01-02 09:30:12 -06:00
Dmitry Stogov
b9122dad1b Merge branch 'PHP-7.1'
* PHP-7.1:
  typo
2016-10-31 21:39:50 +03:00
Dmitry Stogov
d3325ff771 typo 2016-10-31 21:39:34 +03:00
Dmitry Stogov
dcf4bdb844 Merge branch 'PHP-7.1'
* PHP-7.1:
  Fixed reference-counter inference
2016-10-31 19:51:50 +03:00
Dmitry Stogov
e696927e48 Fixed reference-counter inference 2016-10-31 19:51:19 +03:00
Nikita Popov
f58701fe6f Merge branch 'PHP-7.1' 2016-10-16 00:04:23 +02:00
Nikita Popov
659cc278e2 Various RC inference fixes 2016-10-15 23:58:29 +02:00
Dmitry Stogov
f924893ab9 Merge branch 'PHP-7.1'
* PHP-7.1:
  Updated reference-counting inferece rules. The previous rules refected PHP-5 behavior and were completely wrong for PHP-7. (e.g. scalars don't have reference counters at all). This change shouldn't affect anything, because results of this inference are not used yet.
  Fix NEWS after re-roll of RC3
2016-10-06 11:16:43 +03:00
Dmitry Stogov
b2d53e47ed Updated reference-counting inferece rules.
The previous rules refected PHP-5 behavior and were completely wrong for PHP-7. (e.g. scalars don't have reference counters at all).
This change shouldn't affect anything, because results of this inference are not used yet.
2016-10-06 11:08:01 +03:00
Dmitry Stogov
a05cdd03ff Merge branch 'PHP-7.1'
* PHP-7.1:
  Prevent optimization of huge functions.
2016-09-16 14:03:56 +03:00
Dmitry Stogov
846441ab4b Prevent optimization of huge functions. 2016-09-16 14:03:05 +03:00
Dmitry Stogov
7edaed6fba Merge branch 'PHP-7.1'
* PHP-7.1:
  op_arrays may be optimized independetly and "script" might be NULL
2016-08-23 13:18:51 +03:00
Dmitry Stogov
129e8dadf4 op_arrays may be optimized independetly and "script" might be NULL 2016-08-23 13:17:53 +03:00
Nikita Popov
89f6377971 Return true for is_object() on Incomplete_Class 2016-08-15 23:13:09 +02:00
Dmitry Stogov
871cd76af4 clanup 2016-06-29 17:53:39 +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
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
Xinchen Hui
da511f255a Typo & cleanup 2016-05-27 16:17:07 +08: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
b5bdb40cb5 Fix phi placement for pi targets
If the pi target has multiple predecessors, we need to place a
phi there. However it's not possible to express this in terms of
dominance frontiers, so we need to explicitly add it to the phi
set.

This does not yet solve the problem of non-minimal SSA for the
case where the target has multiple predecessors, but dominates
all predecessors (apart from the one creating the pi) -- but
that's an existing issue.
2016-05-12 22:08:28 +02:00
Nikita Popov
b1c3c9a525 Explicitly construct phi set during def propagation
Previously the phi set was first computed during def propagation
and then computed again (per-block) during actual phi placement.
This commit changes this to store the phi set computed during
def propagation.

This makes SSA construction slightly faster (5%), but the main
purpose here is to pave the way for the next commit.

This also fixes a potential issue with the handling of irreducible
loops -- they generated additional phis, but these were not
accounted for in def propagation. (Though I'm not sure if we can
even have any irreducible loops right now.)
2016-05-12 22:08:28 +02:00
Nikita Popov
434e0fb3a5 Take pi defs into account when propagating defs
Previously pi placement happened after initial phi placement.
Afterwards a second phi placement pass was performed, however it
incorrectly only placed phis on the dominance frontier, rather
than the iterated dominance frontier.

This is fixed by moving pi placement before the propagation of
defs on the iterated DFs, and adding a def for each added pi.

While this ensures that we generate correct conservative SSA, there
is still one remaining case in which we may generate non-minimal
SSA form. Consider:

   |1|
    |pi
    v
   |2|<--\
    |    |
    \----/

The pi is semanically located along the edge 1->2, however we place
it (and its def point) in 2, thus leading to the generation of an
additional (trivial) phi in 2.

Conflicts:
	ext/opcache/Optimizer/zend_ssa.c
2016-04-24 21:46:20 +02:00
Nikita Popov
721be3e0c1 Make pi placement independent of phi placement
This interdependence is problematic because we can't propagate pi
def points in the initial dominance frontier propagation. The used
rule for multiple-predecessor blocks may also miss cases where
placing the pi would have been useful.

The new heuristic for pi placement checks that a) the variable is
live-in and b) for the "from" block that generated the pi, the
other successor does not dominate all other predecessors of the
"to" block.

The purpose of case b) may be illustrated with an example:

    if (is_int($i)) {
        // place pi here
    }
    // but don't place pi here

The reason we do not want to place the second pi is that we generally
place pis in positive+negative pairs, and in this case the pair
would merge in a phi and cancel out, so we get no useful information
out of it.
2016-04-24 21:45:22 +02:00
Nikita Popov
65faf0a5a2 Drop some unnecessary checks 2016-04-24 17:15:46 +02:00
Nikita Popov
cafe78d12a Introduce ZEND_BITSET_FOREACH macros 2016-04-24 17:05:13 +02:00
Nikita Popov
304e5ae3d6 Adjust DFG allocation size
Now we need one set less...
2016-04-21 23:49:37 +02:00
Nikita Popov
a5944f8dd5 Merge def and gen sets
For live-variable analysis it does not matter if def includes
variables that are previously use in the same block, the data flow
equations still have the same result. As such there is no need to
compute separate gen & def sets.

I'm keeping the name "def", because use of "gen" in this context is
pretty confusing (gen is usually the use set, not the def set).
2016-04-21 23:32:01 +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
8921449785 Added missing "break" 2016-04-07 18:27:49 +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
Kalle Sommer Nielsen
fc49f1c411 Fix build 2016-03-17 03:53:01 +01:00
Dmitry Stogov
8c2d55962e Combine conditions 2016-02-11 23:11:19 +03: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
Nikita Popov
80c15ac784 Move pi placement into separate function
Non-functional change, just moving code. This makes it easier to
change the order of operations.
2016-02-02 17:39:59 +01:00
Nikita Popov
c2fea2a46d Respect RC_INFERENCE during DFG construction
To avoid inserting phis that are only relevant with rc inference
enabled. Suprisingly, this affects only 0.8% of phis.
2016-01-24 23:04:06 +01:00
Nikita Popov
cf6aa46dbd Fix SSA for ZEND_YIELD
Yield-by-ref defs a ref var, yield-by-var only defs an rc1/rcn var
if rc inference is used.

Also move BIND_LEXICAL where it belongs in DFG construction.
2016-01-24 23:03:50 +01:00
Nikita Popov
5662d73528 Add support for Pi type constraints
Supports TYPE_CHECK and IS_IDENTICAL for now.
2016-01-19 22:09:29 +01:00
Dmitry Stogov
6579e48417 Introduced BIND_STATIC opcode instead of FETCH_R/FETCH_W(static)+ASSIGN/ASSIGN_REF (similar to BIND_GLOBAL).
In the future we may refer to static variable by index instead of name, to eliminate hash lookup.
2016-01-12 12:20:35 +03:00
Nikita Popov
0e936db801 Make PI construction human-readable
Also makes it easy to add PIs for TI.
2016-01-11 21:53:22 +01:00
Lior Kaplan
71c1980025 Happy new year (Update copyright to 2016) 2016-01-01 20:06:12 +02:00
Nikita Popov
65e456f364 Introduce BIND_LEXICAL
This opcodes inserts a local CV into the closure static variable
table. This replaces the previous mechanism of having static
variables marked as LEXICAL, which perform a symtable lookup
during copying.

This means a) functions which contain closures no longer have to
rebuild their symtable (better performance) and b) we can now track
used variables in SSA.
2015-12-29 23:14:53 +01:00
Nikita Popov
33870c525a Don't reuse SSA var in UNSET_VAR
Instead use the SSA var that UNSET_VAR actually defines. Otherwise
we get issues trying to DCE unsets.
2015-12-26 23:33:58 +01:00