1
0
mirror of https://github.com/php/php-src.git synced 2026-04-24 08:28:26 +02:00
Commit Graph

1379 Commits

Author SHA1 Message Date
Tyson Andre f7c44ef2a0 Make opcache infer array_key_exists is non-null bool
array_key_exists now throws a TypeError instead of returning null
for invalid arguments after 14bdb0cfc7
2019-11-20 00:11:51 +03:00
Nikita Popov bb41a1b7e7 Fix str_pad rc info
This fixes at least part of bug #78811.
2019-11-15 12:37:24 +01:00
Dmitry Stogov 36afe4e39e Optimize $x === null into is_null($x) 2019-11-12 13:49:55 +03:00
Dmitry Stogov bd45881014 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed wrong constant usage
2019-11-12 13:00:37 +03:00
Dmitry Stogov 49fcbb4810 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed wrong constant usage
2019-11-12 13:00:27 +03:00
Dmitry Stogov 9083e178f6 Fixed wrong constant usage 2019-11-12 12:59:50 +03:00
Nikita Popov 999e32b65a Implement union types
According to RFC: https://wiki.php.net/rfc/union_types_v2

The type representation now makes use of both the pointer payload
and the type mask at the same time. Additionall, zend_type_list is
introduced as a new kind of pointer payload, which is used to store
multiple class types. Each of the class types is a tagged pointer,
which may be either a class name or class entry. The latter is only
used for typed properties, while arguments/returns will instead use
cache slots. A type list can contain a mix of both names and CEs at
the same time, as not all classes may be resolvable.

One thing this is missing is support for union types in arginfo
and stubs, which I want to handle separately.

I've also dropped the special object code from the JIT implementation
for now -- I plan to add this back in a different form at a later time.
For now I did not want to include non-trivial JIT changes together
with large functional changes.

Another possible piece of follow-up work is to implement "iterable"
as an internal alias for "array|Traversable". I believe this will
eliminate quite a few special-cases that had to be implemented.

Closes GH-4838.
2019-11-08 15:15:48 +01:00
Nikita Popov ac4e0f0852 Make zend_type a 2-field struct
We now store the pointer payload and the type mask separately. This
is in preparation for union types, where we will be using both at
the same time.

To avoid increasing the size of arginfo structures, the
pass_by_reference and is_variadic fields are now stored as part of
the type_mask (8-bit are reserved for custom use).

Different types of pointer payloads are distinguished based on bits
in the type_mask.
2019-11-08 15:15:48 +01:00
Nikita Popov 7d056fc6c0 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #78747
2019-10-25 12:53:24 +02:00
Nikita Popov 4d8541debb Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #78747
2019-10-25 12:50:26 +02:00
Nikita Popov 74699533e5 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fixed bug #78747
2019-10-25 12:50:12 +02:00
Nikita Popov 5249993814 Fixed bug #78747 2019-10-25 12:47:18 +02:00
Nikita Popov 225a02f3d6 Merge branch 'PHP-7.4'
* PHP-7.4:
  Optimize VERIFY_RETURN_TYPE for TMP operands as well
2019-10-25 11:41:41 +02:00
Nikita Popov 6aece7be0a Optimize VERIFY_RETURN_TYPE for TMP operands as well
Only exclude CONST operands, which use a different instruction
format (they have a return operand).
2019-10-25 11:37:19 +02:00
Nikita Popov 711e2a1216 Merge branch 'PHP-7.4'
* PHP-7.4:
  Check class linking in VERIFY_RETURN_TYPE optimization
  Simplify travis setup scripts
2019-10-25 11:25:49 +02:00
Nikita Popov f07565b0eb Check class linking in VERIFY_RETURN_TYPE optimization
instanceof_function() requires linked classes. I'm not reusing
unlinked_instanceof() here, because it performs class loading,
which wouldn't be right here, I think.
2019-10-25 11:24:32 +02:00
Dmitry Stogov cef1960ce7 Use "const" qualifier 2019-10-14 21:49:08 +03:00
Dmitry Stogov 4273865bba Drop checkpoint that leaded to use after free 2019-10-14 13:37:22 +03:00
Dmitry Stogov 5197d0cd5e Reduced number of CFG pass iterations 2019-10-14 11:37:10 +03:00
Dmitry Stogov 2068ce9adf Use RT_CONSTANT() or CT_CONSTANT() macro depending on ZEND_ACC_DONE_PASS_TWO flag 2019-10-11 12:54:07 +03:00
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
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