Commit Graph

944 Commits

Author SHA1 Message Date
Dmitry Stogov
ccf18da450 Eliminated checks for (func->op_array.fn_flags & ZEND_ACC_GENERATOR) in fast path of DO_FCALL* handlers.
This slightly improves calls to regular function and method calls in cost of a bit slower generator initialization.
Separate call frame for generators, allocated on heap, now created by ZEND_GENERATOR_CREATE instruction.
2016-05-13 01:40:15 +03: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
Dmitry Stogov
7b94b958cc Intern some known (and offten used) strings. 2016-05-12 13:47:22 +03:00
Dmitry Stogov
13ea086945 Merge branch 'PHP-7.0'
* PHP-7.0:
  The "flock" structure has to be writable on AIX.
2016-05-10 17:53:43 +03:00
Dmitry Stogov
f7372f648f Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
  The "flock" structure has to be writable on AIX.
2016-05-10 17:53:33 +03:00
Dmitry Stogov
90f43caf5b The "flock" structure has to be writable on AIX. 2016-05-10 17:50:14 +03:00
Dmitry Stogov
8ae695cd75 Fixed possible crash 2016-05-06 12:36:21 +03:00
Dmitry Stogov
6d52492906 Update comments consistently (#var0 -> #v) 2016-05-05 14:41:34 +03:00
Dmitry Stogov
542402afdb Refactor DFA pass for better readability 2016-05-05 14:37:41 +03:00
Nikita Popov
35e7573a33 Merge branch 'PHP-7.0'
Conflicts:
	ext/opcache/Optimizer/block_pass.c
2016-05-05 00:01:56 +02:00
Nikita Popov
0691e7a8e1 Fix JMPZ, JMPZNZ_EX chain optimization
The result_type was not copied, resulting in a corrupted JMPZ_EX.
Fix can be verified by inspecting the opcodes of the following
function (it should not contain any _EX opcodes):

function test() {
    if ($a && $b) {
        echo "a";
    }

    if ($b || $c || $d) {
        echo "b";
    }
}

Conflicts:
	ext/opcache/Optimizer/block_pass.c
2016-05-05 00:00:56 +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
Dmitry Stogov
6499162ff0 - get rid of EG(scope). zend_get_executed_scope() should be used instead.
- ichanged zval_update_constant_ex(). Use IS_TYPE_IMMUTABLE flag on shared constants and AST, instead of "inline_change" parameter.
2016-04-28 04:13:34 +03:00
Nikita Popov
d94b9545d6 Support known static/method calls in call graph
For this purpose extract the function lookup call into a helper
zend_optimizer_get_called_func().
2016-04-27 17:10:45 +02:00
Nikita Popov
4f54c15cb1 Ct bind private/final $this method call args
The test covers two edge-cases wrt opcache support.
2016-04-27 17:10:44 +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
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
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
Nikita Popov
4a568dd7c9 Drop left-over debugging statement in block pass 2016-04-16 20:23:23 +02:00
Nikita Popov
64f91774f2 Remove IS_VAR_RET_REF flag
Instead decide whether a function returned by reference or by value
by checking whether the return value has REFERENCE type. This means
that functions returning by reference must always return a reference
and functions returning by value must not return a reference.
2016-04-15 15:32:20 +02:00
Dmitry Stogov
d57505e234 Merge branch 'master' of git.php.net:php-src
* 'master' of git.php.net:php-src:
  Fixed bug #72014 (Including a file with anonymous classes multiple times leads to fatal error)
2016-04-14 16:08:54 +03:00
Dmitry Stogov
b73517c1a1 Use DO_FCALL_BY_NAME instead of DO_FCALL, if possible 2016-04-14 16:07:28 +03:00
Xinchen Hui
17c3aa9dd1 Merge branch 'PHP-7.0'
* PHP-7.0:
  Fixed bug #72014 (Including a file with anonymous classes multiple times leads to fatal error)
2016-04-14 20:21:34 +08:00
Xinchen Hui
8a17b1a241 Fixed bug #72014 (Including a file with anonymous classes multiple times leads to fatal error) 2016-04-14 20:21:19 +08:00
Xinchen Hui
4fafd7309c Merge branch 'PHP-7.0'
* PHP-7.0:
  This only make sense on *nix
2016-04-12 15:31:35 +08:00
Xinchen Hui
9458f54969 This only make sense on *nix 2016-04-12 15:31:21 +08:00
Lior Kaplan
bffd78fa77 Merge branch 'PHP-7.0'
* PHP-7.0:
  Enable configure without opcache-file and huge-code-pages
2016-04-09 16:35:50 +03:00
Lior Kaplan
c6c44c3629 Enable configure without opcache-file and huge-code-pages
This doesn't chagne the default (yes for both features), but respects
--disable-opcache-file and --disable-huge-code-pages configure flags if given.
2016-04-09 15:57:57 +03:00
Xinchen Hui
3e7b429663 We should always serialize the op->handler 2016-04-09 01:43:28 -07:00
Lior Kaplan
2875ac9c00 Merge branch 'PHP-7.0'
* PHP-7.0:
  opcache config.m4: Use = for comparison
2016-04-09 01:38:37 +03:00
Lior Kaplan
403c3f95fe Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
  opcache config.m4: Use = for comparison
2016-04-09 01:35:30 +03:00
Lior Kaplan
c1f597d9a1 opcache config.m4: Use = for comparison 2016-04-08 22:38:07 +03:00
Nikita Popov
3ad0e1d6ca Fix static method arg binding in traits 2016-04-08 01:48:21 +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
Anatol Belski
2ead9be91b Merge branch 'PHP-7.0'
* PHP-7.0:
  make opcache lockfile path configurable
2016-04-06 13:50:24 +02:00
Fatih ACAR
d54eafb349 make opcache lockfile path configurable
Signed-off-by: William Dauchy <william@gandi.net>
Signed-off-by: Baptiste Daroussin <baptiste.daroussin@gandi.net>
Signed-off-by: Fatih Acar <fatih.acar@gandi.net>
2016-04-06 13:29:52 +02: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
Andrea Faulds
d6fc6d4ae6 Fix memory leak
Leak was introduced in c88ffa9a56.
2016-03-30 14:16:07 +01:00
Andrea Faulds
1e82ad8038 Warn about invalid strings in arithmetic
Squashed commit of the following:

commit e05d3b6732
Author: Andrea Faulds <ajf@ajf.me>
Date:   Wed Mar 30 01:43:35 2016 +0100

    UPGRADING and NEWS

commit 6caf1d4585
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sun Mar 20 21:18:33 2016 +0000

    Fixes

commit 6dadb1b0ef
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sun Feb 14 02:15:01 2016 +0000

    Add test for numeric string errors in assignment

commit bd5f04e8dd
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sat Feb 13 23:53:05 2016 +0000

    Add test for numeric string errors

commit c72e92f16d
Author: Andrea Faulds <ajf@ajf.me>
Date:   Tue Jan 26 23:28:33 2016 +0000

    Add test for scientific notation in integer operations

commit d94c08852d
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sun Feb 14 01:25:57 2016 +0000

    Disable optimiser evaluation for numeric string errors

commit 30ee954ed1
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sun Feb 14 01:46:25 2016 +0000

    fixup

commit a6403b79e0
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sat Feb 13 22:00:27 2016 +0000

    Do not convert error-causing numeric strings ahead-of-time

commit f9dc354014
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sat Feb 13 19:15:38 2016 +0000

    Disable compile-time evaluation for numeric string errors

commit e05b0cc849
Author: Andrea Faulds <ajf@ajf.me>
Date:   Fri Feb 5 11:42:26 2016 +0000

    Make _zval_get_long_func_noisy function for inlining

commit 84d66321a5
Author: Andrea Faulds <ajf@ajf.me>
Date:   Tue Jan 26 23:10:00 2016 +0000

    Update tests

commit 5ac4a0cc4b
Author: Andrea Faulds <ajf@ajf.me>
Date:   Tue Jan 26 22:08:19 2016 +0000

    Use is_numeric_string_ex for zval_get_long etc.

commit c21f088485
Author: Andrea Faulds <ajf@ajf.me>
Date:   Thu Jan 7 21:13:04 2016 +0000

    Update tests

commit 63e214cf81
Author: Andrea Faulds <ajf@ajf.me>
Date:   Wed Jan 6 00:28:01 2016 +0000

    Warn on non-/bad numeric strings in arithmetic
2016-03-30 01:44:27 +01:00
Nikita Popov
b867bd1c8d Fix FETCH_CLASS_SELF comparisons
Turns out those don't form a bitfield.
2016-03-26 22:45:23 +01:00