1
0
mirror of https://github.com/php/php-src.git synced 2026-04-21 15:08:16 +02:00
Commit Graph

1683 Commits

Author SHA1 Message Date
Dmitry Stogov 292d76d8a4 JIT: Fixed reference-counting inference 2021-11-15 10:39:58 +03:00
Dmitry Stogov 535a0553e8 Fixed incorrect reference counter inference 2021-11-08 20:54:17 +03:00
Nikita Popov 53df29bc29 Drop pi nodes for both old/new pred in replace_predecessor
We also need to drop pi nodes for new_pred here, as the pi node
restriction for new_pred is not necessarily true for control
coming from old_pred as well.

Fixes oss-fuzz #40782.
2021-11-08 14:56:42 +01:00
Dmitry Stogov 66d93c63ff Fixed type inference for FETCH_DIM_W without use 2021-11-03 19:44:38 +03:00
Dmitry Stogov 5c43e0c0ee Fixed incorrect assumption about reference counting 2021-11-01 20:28:05 +03:00
Nikita Popov 2e29817005 Handle FETCH_DIM_R after FETCH_DIM_FUNC_ARG in inference
This can happen if a call is optimized, but FETCH_DIM_FUNC_ARG
cannot be converted to FETCH_DIM_R because it uses an UNUSED op2,
which is not supported by FETCH_DIM_R.

Fixes oss-fuzz 6144185837682688.
2021-11-01 14:26:36 +01:00
Nikita Popov f8ec5a1d4c Fix range inference hang
We shouldn't switch from range to no range for ZEND_DIV and instead
explicitly return an overflowing range. Otherwise the range will
not actually get updated during widening, and we'll perform
essentially infinite narrowing.

Fixes oss-fuzz #40566.
2021-11-01 12:31:34 +01:00
Dmitry Stogov 6bd5271c62 Fixed incorrect optimization that may cause JIT assertion 2021-10-18 23:18:52 +03:00
Nikita Popov 9ebe8494b8 Don't replace tmp with cv in YIELD argument
For by-ref generators, these may have different behavior.

Fixes oss-fuzz 6059739298004992.
2021-10-12 14:26:53 +02:00
Dmitry Stogov a4c41d45cd Fixed type inference for COPY_TMP 2021-10-11 16:56:07 +03:00
Dmitry Stogov ed8ec9d71e Fixed type inference (ASSIGN_OP with typed reference may cause type conversion) 2021-10-11 10:48:49 +03:00
Dmitry Stogov 22ef1fb832 Fixed SSA construction 2021-10-05 16:14:39 +03:00
Nikita Popov c958adce70 POST_INC_OBJ/POST_DEC_OBJ don't have optional result
Possibly we should be encoding this in the opcode metadata, rather
than maintaining a separate list.

Fixes oss-fuzz #39503.
2021-10-05 12:05:39 +02:00
Nikita Popov d0860f67ca Fix cache slot assignment for ASSIGN_OBJ_OP
ASSIGN_OBJ_OP stores the cache slot in OP_DATA, so this ended up
overwriting the binop opcode instread.
2021-09-30 14:34:12 +02:00
Nikita Popov 1bb7ee3207 Fix ASSIGN_DIM result inference with typed refs
Same issue as with ASSIGN. Also make the handling for ASSIGN more
precise, we can only have conversions between scalar values.
2021-09-28 14:14:01 +02:00
Nikita Popov cdc05eba61 Remove outdated code in ASSIGN_DIM type inference
All of these cases throw an exception now rather than returning
null.
2021-09-28 14:14:00 +02:00
Nikita Popov d8c2ff6486 Fix type inference and SCCP with typed references
We can't assume that the return value will be the same as the RHS
if typed references are involved.
2021-09-28 12:59:00 +02:00
Nikita Popov 17d6efc729 Fix block marking for two arm math
This would end up taking the successors_count=2 case, even though
we need to treat SWITCH and MATCH differently. This incorrectly
marked a block as FOLLOW, resulting in incorrect block pass
optimization.

Fixes oss-fuzz #39380.
2021-09-28 10:37:54 +02:00
Nikita Popov 7d483418e2 Fix relative offsets when copying JMPZNZ
This was doing a plain copy of JMPZNZ, even though it encodes
offsets relative to the opline. As such, the offsets would be
relative to target, while they should be relative to opline.
Fix this by recomputing them.

Fixes oss-fuzz #39295.
2021-09-27 16:18:40 +02:00
Nikita Popov 823888c472 Start block at loop var free
This ensures that code directly before the loop var free is
separated out (and will generally be eliminated as unreachable).
This fixes some assumptions we have that unreachable loop var free
blocks start with the loop var free.

Fixes oss-fuzz #39395.
2021-09-27 11:56:37 +02:00
Nikita Popov ddf8910237 Fix DCE of unreachable phi in cycle
We can't remove a trivial phi of the form x = phi(x), because we
don't have a replacement value. We could drop the whole block
though. SCCP would normally do this, but in this particular case
we only determine non-reachability based on type information.

Fixes oss-fuzz #39316.
2021-09-27 11:26:31 +02:00
Nikita Popov 038bc27787 Handle pi nodes in replace_predecessor
If we're removing a predecessor because it already exists during
replacement, we should also drop pi nodes for that predecessor.

Fixes oss-fuzz #39276.
2021-09-27 10:47:47 +02:00
Nikita Popov 983a4fc4a3 Fix ASSIGN_STATIC_PROP_REF type inference
We were not inferring anything for the ASSIGN_STATIC_PROP_REF
result type at all, leaving it as an empty type. In the test
case this results in a live range being incorrectly eliminated,
but this could break in all kinds of other ways as well..
2021-09-22 15:55:25 +02:00
Dmitry Stogov e588f24276 Fixed type inference 2021-09-22 15:30:30 +03:00
Nikita Popov 61445248cb Don't unconditionally add array value type for undef
We have an invariant that an array value type is set if and only
if an array key type is set, which is violated for the case of
undef values for always invalid keys.
2021-09-21 14:54:16 +02:00
Nikita Popov 1b33da5dd2 Don't replace values in unreachable code in sccp
While technically legal, this may cause unexpected situations
(in this example, setting an FE_FREE operand to constant null)
and is suboptimal anyway. It's better to preserve the vacuous type
and drop it later (though we currently don't implement this).
2021-09-20 13:12:26 +02:00
Nikita Popov a49a309386 Fix FETCH_OBJ_IS type inference
Even if the property is typed, null is still a valid return
value in the BP_VAR_IS case. Other cases will throw instead.
2021-09-17 17:05:25 +02:00
Nikita Popov 4c8093a9f1 Don't const evaluate increment of array in SCCP 2021-09-16 14:43:08 +02:00
Nikita Popov 1548418461 Fix may_throw for ASSIGN_OBJ
The code did not account for a number of possible exceptions.
2021-09-16 12:46:53 +02:00
Nikita Popov 3ee85ccd4a Handle undef assignment to typed ref 2021-09-15 10:58:01 +02:00
Nikita Popov 1b376b06fb Fix BIND_STATIC may_throw check
This is supposed to index into arData, not the HashTable itself.
2021-09-14 10:09:32 +02:00
Dmitry Stogov ebd1a0a656 Properly check if BIND_STATIC may throw 2021-09-13 21:57:26 +03:00
Nikita Popov b610dce079 BIND_STATIC may throw
The evaluation of the initializer may throw. This could be refined
by checking whether the initializer is a constant AST. For now
just fix the miscompile.
2021-09-13 17:23:57 +02:00
Nikita Popov 5cae6b9b0d Check that POST_INC/DEC has use in DFA optimization
We'd have usually converted it into a PRE_INC if there is no use,
but that's not guaranteed. If there is no use at this point, make
sure we don't try to use the sentinel value.
2021-09-09 15:48:51 +02:00
Máté Kocsis cdf0550fe5 Fix a few func info entries 2021-08-27 16:45:32 +02:00
Máté Kocsis 492821a302 Fix func info for str_replace() and str_ireplace() 2021-08-27 12:53:44 +02:00
Nikita Popov 9d70946b16 Remove incorrect refcount info for addcslashes()
This function may return the input string.
2021-08-27 12:13:08 +02:00
Nikita Popov cba166469d imagecolorsforindex() cannot return false 2021-08-26 16:36:27 +02:00
Máté Kocsis 780293baec Sync ext/mysqli optimizer func info entries with the stubs 2021-08-26 12:13:42 +02:00
Máté Kocsis 41ab369791 Fix a few optimizer func info
Closes GH-7396
2021-08-24 15:12:18 +02:00
Dmitry Stogov a9991fbf28 Fixed Bug #80959 (infinite loop in building cfg during JIT compilation) 2021-07-21 14:32:44 +03:00
Nikita Popov 051ff33660 Fix bug #81272: Fix func info for functions returning EMPTY_ARRAY
The empty array has refcount > 1, so we should indicate this in
func info. In most cases this renders the func info redundant,
so drop it entirely.
2021-07-20 14:40:17 +02:00
Dmitry Stogov df16fd149b Fixed incorrect type inference for "(array)$null". 2021-06-17 13:03:09 +03:00
Nikita Popov 67cf04f791 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Mitigation for bug #81096
2021-06-10 10:54:21 +02:00
Nikita Popov 3f4bc94b00 Mitigation for bug #81096
This issue is properly fixed by GH-7121 on master. For older
branches, disable the use of range information in SCCP, to
reduce impact of potentially incorrect ranges.
2021-06-10 10:52:53 +02:00
Máté Kocsis ceb0951fa5 mysqli_get_client_info() cannot return null
This method is already deprecated
2021-05-26 17:48:35 +02:00
Nikita Popov 9f6ee9f4d7 Update func info for mysqli_connect 2021-05-26 14:36:21 +02:00
Nikita Popov c446d68f7c Fixed bug #81046
Literal compaction was incorrectly assuming that literals with
the same base literal and the same number of related literals
would be equal. Maybe that was the case historically, but at
least it isn't true in PHP 8, where FETCH_CONSTANT and INIT_METHOD
have distinct literals at the second position.

Fix this by making the cache key a concatenation of all literals,
rather than just the base literal. We still distinguish the number
of related literals based on a bias added to the string hash.
2021-05-17 15:46:49 +02:00
Nikita Popov dd3e56ba24 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #81015
2021-05-06 10:46:30 +02:00
Nikita Popov 178bbe3478 Fixed bug #81015
Make sure that the previous opline is part of the same block,
otherwise it may be non-dominating.

The test case does not fail on PHP-7.4, but I think the general
problem can appear on 7.4 as well, so I'm applying the patch to
that branch.
2021-05-06 10:46:00 +02:00