1
0
mirror of https://github.com/php/php-src.git synced 2026-04-05 07:02:33 +02:00
Commit Graph

2671 Commits

Author SHA1 Message Date
Dmitry Stogov
3db5dc44bc JMP optimization cleanup.
Make JMP optimisation in pass3 and JMP optimization from CFG pass to be almost identical.
2019-10-11 11:23:02 +03:00
Dmitry Stogov
3ad20f80f5 Revert/redo pass_two only once 2019-10-10 23:20:36 +03:00
Dmitry Stogov
ca265b04d0 Removed #if HAVE_DFA_PASS 2019-10-10 21:46:24 +03:00
Dmitry Stogov
833821ac24 Eliminate CHECK_VAR instructions for defined CVs 2019-10-10 16:07:31 +03:00
Dmitry Stogov
6a459a8a3f Separate common code and add few more patterns 2019-10-10 12:19:06 +03:00
Dmitry Stogov
0cb977a691 Fixed edge cases introduced by 170ed1f5a7 2019-10-10 11:48:31 +03:00
Dmitry Stogov
d9964efe23 One more place 2019-10-10 02:21:37 +03:00
Dmitry Stogov
bf5d299ef4 Fixed typo 2019-10-10 02:17:50 +03:00
Dmitry Stogov
fa0a17a76f Move ECHO handling into common switch 2019-10-09 23:24:41 +03:00
Dmitry Stogov
fd69af38c8 Cleanup JMP optimization. Remove duplicate code (conditional jums with constant operand) and outdated commented code. 2019-10-09 23:07:32 +03:00
Dmitry Stogov
78a1c8c811 Cleanup JMP optimization pass 2019-10-09 22:52:09 +03:00
Dmitry Stogov
d37f5da75e typo and cleanup 2019-10-09 17:58:35 +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
Dmitry Stogov
170ed1f5a7 Otimize out useless QM_ASSIGN 2019-10-09 09:08:25 +03:00
Remi Collet
3dabce087c Merge branch 'PHP-7.4'
* PHP-7.4:
  add librt for opcache
2019-10-08 10:49:30 +02:00
Remi Collet
e1362b3cf0 add librt for opcache 2019-10-08 10:48:10 +02:00
Dmitry Stogov
b02b81299c Comparison cleanup:
- introduce zend_compare() that returns -1,0,1 dirctly (without intermediate zval)
- remove compare_objects() object handler, and keep only compare() handler
2019-10-07 17:57:49 +03:00
Nikita Popov
fdc133063d Convert count_chars invalid mode error to ValueError 2019-10-07 11:10:05 +02:00
Tyson Andre
dd61edfd7c Update opcache return type info for gd functions
Many of these now have reflection types,
making the old signatures redundant or inaccurate.
(Some methods also throw Errors instead of returning null/false)

Closes GH-4785.
2019-10-07 10:16:50 +02:00
Tyson Andre
02f2056864 Update zend_func_info for pcre/curl/iconv/json
preg_quote and curl_error now have a non-null return type of `string`.

zend_func_info now duplicates many real reflection types
(some of which are now non-null)

Closes GH-4788.
2019-10-07 10:16:31 +02:00
Tyson Andre
52dfe873ab Remove redundant zend_func_info for zlib/hash/session
E.g. hash_equals is outdated - it has a non-null reflection type of bool.

Remove redundant signatures for types that are obviously not reference
counted (`F0`).

Closes GH-4787.
2019-10-07 10:16:08 +02:00
Tyson Andre
d0f7a7e7c9 Remove redundant func info for ctype/bc/fileinfo
This is limited to types that aren't reference counted.
I assume the info that there is exactly one reference
should be preserved (e.g. for bcsqrt)

Closes GH-4786.
2019-10-07 10:15:50 +02:00
Tyson Andre
3c2ba240a9 Update zend_func_info for zend, array extensions
Some of these functions now have real reflection types
and will throw instead of return null/false.

Others provide the exact same reflection type information
that zend_func_info does. (or would after updating outdated types)

Closes GH-4790.
2019-10-07 10:15:30 +02:00
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