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

2659 Commits

Author SHA1 Message Date
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
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