1
0
mirror of https://github.com/php/php-src.git synced 2026-03-30 04:02:19 +02:00
Commit Graph

2648 Commits

Author SHA1 Message Date
Dmitry Stogov
dc3c8c75da Prefer optimization without JMPZNZ instruction 2019-10-04 12:52:46 +03:00
Dmitry Stogov
bf56daa8c8 Remove "finally" restriction. 2019-10-04 02:53:24 +03:00
Dmitry Stogov
204660fd9a Simplify protection from infinity loops 2019-10-04 02:04:00 +03:00
Dmitry Stogov
3a78c3aaf5 Moved non-constant JMP optimizations from pass1 to pass3.
Removed useless "break"s, that stopped optimization too early.
2019-10-04 00:27:49 +03:00
Dmitry Stogov
39d1e50b2d Avoid "$a = $a + ..." to "$a += ..." conversion (compound assignments work slower).
Added DFA optimization patters (e.g. "$a = $a + 1" to "++$a"), that previously worked only for compound assignments.
2019-10-03 16:33:17 +03:00
Dmitry Stogov
de3c1eb85e Move obvious optimization patterns from pass1 directly to compiler 2019-10-03 14:57:20 +03:00
Dmitry Stogov
a5465728c2 Added missing rules 2019-10-03 14:56:02 +03:00
Dmitry Stogov
c1de93efbe Fixed comments 2019-10-03 13:55:58 +03:00
Dmitry Stogov
59c828a8c4 Added missing rules 2019-10-03 13:54:08 +03:00
Dmitry Stogov
1e4c553e0d Cleanup JMP optimization rules 2019-10-03 04:26:40 +03:00
Dmitry Stogov
6cac8d5b3b Optimizer cleanup
- all rules from pass2 moved to pass1
- all JMP unrelated rules from pass3 moved to pass1
- pass3 keeps only JMP optimization rules
- pass2.c is removed
- pass1_5.c remaned to pass1.c ("_5" was related to PHP 5)
2019-10-03 02:18:16 +03:00
Nikita Popov
a653240bd7 Prune opcache func info
Remove opcache func info for some functions which have arg info
with same or better accuracy (this is incomplete, we can drop more).
2019-10-02 10:54:47 +02: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
Nikita Popov
34e7c2daf0 Merge branch 'PHP-7.4' 2019-09-27 10:49:25 +02:00
Nikita Popov
a6c9c7c2b8 Handle resources used as array keys consistently
Resources used as array keys are generally handled by throwing a
notice and converting the resource to the resource handle. The only
exception is the [$resource => null] syntax, where this was treated
as an illegal offset type instead. However, this also only happened
for VM evaluations, the AST evaluator did handle resources correctly.
2019-09-27 10:40:41 +02:00
Nikita Popov
a66c60cce3 Throw Error when writing property of non-object
This removes object auto-vivification support.

This also means that we can remove the corresponding special
handling for typed properites: We no longer need to check that a
property is convertible to stdClass if such a conversion might
take place indirectly due to a nested property write.

Additionally OBJ_W style operations now no longer modify the
object operand, and as such we no longer need to treat op1 as a
def in SSA form.

The next step would be to actually compile the whole LHS of OBJ_W
operations in R rather than W mode, but that causes issues with
SimpleXML, whose object handlers depend on the current compilation
structure.

Part of https://wiki.php.net/rfc/engine_warnings.
2019-09-27 10:11:47 +02:00
Tyson Andre
e8d2097bdc Update opcache zend_func_info after wbmp/xml_parser changes
See UPGRADING on the master branch.

```
- GD:
  . The deprecated function image2wbmp() has been removed.
    RFC: https://wiki.php.net/rfc/image2wbmp
  . The deprecated functions png2wbmp() and jpeg2wbmp() have been removed.
    RFC: https://wiki.php.net/rfc/deprecate-png-jpeg-2wbmp
- XML:
  . xml_parser_create(_ns) will now return an XmlParser object rather than a
    resource.
```
2019-09-27 10:06:36 +02:00
Dmitry Stogov
7d7b20ea91 Don't generate useless stubs 2019-09-26 23:21:48 +03:00
Dmitry Stogov
cf33837d75 Cleanup CFG optimization 2019-09-25 17:30:59 +03:00
Nikita Popov
a369430b00 Avoid signed shift 2019-09-24 11:36:05 +02: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
Nikita Popov
9e8ba7891e Change representation of zend_type from type code to MAY_BE_* mask
This switches zend_type from storing a single IS_* type code to
storing a MAY_BE_* type mask. Right now most code still assumes
that there is only a single type in the mask (or two together
with MAY_BE_NULL). But this will make it a lot simpler to introduce
union types.

An additional advantage (and why I'm doing this separately), is
that a number of special cases no longer need to be handled
separately: We can do a single mask & (1 << type) check to handle
all simple types, booleans (true|false) and null.
2019-09-23 15:31:35 +02:00
Dmitry Stogov
ddfb3d6056 Fixed 32-bit JIT 2019-09-19 21:53:36 +03:00
Nikita Popov
edfcf2d81f Merge branch 'PHP-7.4' 2019-09-19 17:22:34 +02:00
Nikita Popov
5bee9c9062 Merge branch 'PHP-7.3' into PHP-7.4 2019-09-19 17:22:28 +02:00
Nikita Popov
85e7668129 Merge branch 'PHP-7.2' into PHP-7.3 2019-09-19 17:21:45 +02:00
Nikita Popov
003c13d7bc Fix iterable return type optimization 2019-09-19 17:21:00 +02:00
Nikita Popov
cdd4e591a4 Don't make argument nullable based on AST null initializer
Closes GH-4720.
2019-09-19 11:27:00 +02:00
Dmitry Stogov
2aefd11211 Optimize access to thread local cache.
This patch saves one CPU instruction on each "_tsrm_ls_cache" access in ZTS CLI/CGI/FPM builds.
This reduce typical instruction sequence for EG(current_execute_data) access from 4 to 3 CPU instructions.
2019-09-18 14:03:07 +03:00
Nikita Popov
8af9043766 Merge branch 'PHP-7.4' 2019-09-17 12:18:01 +02:00
Nikita Popov
62b440ffbb Merge branch 'PHP-7.3' into PHP-7.4 2019-09-17 12:09:06 +02:00
Nikita Popov
f98684b06c Merge branch 'PHP-7.2' into PHP-7.3 2019-09-17 12:08:57 +02:00
Tyson Andre
29bced9521 Fix opcache return type for get_headers in zend_func_info
https://www.php.net/manual/en/function.get-headers.php#refsect1-function.get-headers-examples
shows that it will return string keys when the second argument is
non-zero. I've verified that this is the case.

This bug was there since the initial commit in c88ffa9a56.

Closes GH-4702.
2019-09-17 12:08:29 +02:00
Christoph M. Becker
9b9fac78b0 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #78429: opcache_compile_file(__FILE__); segfaults
2019-09-16 16:01:49 +02:00
Christoph M. Becker
20f73d3d8f Fix #78429: opcache_compile_file(__FILE__); segfaults
We have to ensure that OPcache has been properly started up when
`opcache_compile_file()` is called.
2019-09-16 16:01:09 +02:00
Dmitry Stogov
78a890e45f Merge branch 'PHP-7.4'
* PHP-7.4:
  Make constant and copy propagation only for IS_TMP_VAR operands
2019-09-13 12:39:45 +03:00
Dmitry Stogov
af9b127fed Make constant and copy propagation only for IS_TMP_VAR operands 2019-09-13 12:38:57 +03:00
Nikita Popov
f61f122b9a Merge branch 'PHP-7.4' 2019-09-12 16:41:45 +02:00
Nikita Popov
4b9ebd837b Allow throwing exception while loading parent class
This is a fix for symfony/symfony#32995.

The behavior is:

* Throwing exception when loading parent/interface is allowed
  (and we will also throw one if the class is simply not found).
* If this happens, the bucket key for the class is reset, so
  it's possibly to try registering the same class again.
* However, if the class has already been used due to a variance
  obligation, the exception is upgraded to a fatal error, as we
  cannot safely unregister the class stub anymore.
2019-09-12 16:41:18 +02:00
Nikita Popov
c70bab7b24 Merge branch 'PHP-7.4' 2019-09-11 09:53:18 +02:00
Nikita Popov
0a24cd4e7c Preloading: Fix handling of static vars in inherited methods
Part of bug #78512.
2019-09-11 09:53:10 +02:00
Dmitry Stogov
628fd6ec71 clenup 2019-09-09 22:40:28 +03:00
Dmitry Stogov
f43fe067e9 Avoid hash value recalculation on each counter update 2019-09-09 21:25:54 +03:00