Commit Graph

167 Commits

Author SHA1 Message Date
Dmitry Stogov
c6e895aec2 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Disable type narrowing optimization when we contruct SSA for JIT
2021-11-29 15:53:16 +03:00
Dmitry Stogov
b1a1ed380f Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed incorrect narrowing to double
2021-11-25 15:15:01 +03:00
Dmitry Stogov
ecc4d1326b Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed incorrect refcountion inference for BW_NOT
2021-11-25 13:53:26 +03:00
Dmitry Stogov
97f0c0b189 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed incorrect DCE for ADD_ARRAY_ELEMENT instruction
2021-11-25 13:35:54 +03:00
Nikita Popov
51ae5c5397 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix bug #81652
2021-11-24 15:19:33 +01:00
Máté Kocsis
20fb26e55c
Add more specific array return type hints for various extensions - part 2
ext/ftp, ext/gmp, ext/intl

Closes GH-7433
2021-11-17 10:56:27 +01:00
Dmitry Stogov
f313b65acb Optimize closures nested in other closures 2021-11-15 13:32:42 +03:00
Dmitry Stogov
fb582f4230 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  JIT: Fixed reference-counting inference
2021-11-15 10:40:35 +03:00
Dmitry Stogov
9bd490dc33 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed incorrect reference counter inference
2021-11-08 20:54:45 +03:00
Nikita Popov
e5c2ad45dd Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Drop pi nodes for both old/new pred in replace_predecessor
2021-11-08 14:57:16 +01:00
Máté Kocsis
d02b9b953d
Add more specific array return type hints for various extensions - part 1
ext/bz2, ext/calendar, ext/dba, ext/enchant

Closes GH-7432
2021-11-07 08:46:25 +01:00
Dmitry Stogov
22a171a0b5 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed type inference for FETCH_DIM_W without use
2021-11-03 19:45:30 +03:00
Dmitry Stogov
d4a7e4d1ff Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed incorrect assumption about reference counting
2021-11-01 20:28:33 +03:00
Nikita Popov
a89546d8b3 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Handle FETCH_DIM_R after FETCH_DIM_FUNC_ARG in inference
2021-11-01 14:27:14 +01:00
Nikita Popov
3d38960979 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix range inference hang
2021-11-01 12:32:04 +01:00
Nikita Popov
64878757be Fix scdf loop var free check for phi vars
The variable may come from a phi node, in which case we should
take the defining block from it.

Fixes oss-fuzz #40453.
2021-11-01 11:03:17 +01:00
Nikita Popov
1f19401ffa Handle operand replacement in JMP_NULL
In this case it's not sufficient to replace the JMP_NULL operand,
as it keeps the temporary alive and there may be more uses later.
Fix this by generalizing existing handling for other similar opcodes
like CASE/SWITCH and LIST_R.

Fixes oss-fuzz 5820123475214336.
2021-10-19 15:19:02 +02:00
Dmitry Stogov
bdebefaa61 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed incorrect optimization that may cause JIT assertion
2021-10-18 23:20:53 +03:00
Nikita Popov
9c1d7b43e9 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Don't replace tmp with cv in YIELD argument
2021-10-12 14:27:07 +02:00
Dmitry Stogov
1208fe932a Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed type inference for COPY_TMP
2021-10-11 16:56:40 +03:00
Nikita Popov
f0cf999223 Preserve key/value type invariant in range() type inference
Don't set PACKED key type if no value type is set.

Fixes oss-fuzz 6718410667458560.
2021-10-11 12:41:46 +02:00
Dmitry Stogov
04064187c2 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed type inference (ASSIGN_OP with typed reference may cause type conversion)
2021-10-11 10:50:06 +03:00
Nikita Popov
41789e1fc9 Regenerate optimizer info
While the stub definitions were updated, the generated optimizer
info was stale.
2021-10-08 11:40:38 +02:00
Máté Kocsis
d9e5e63032
Add more specific array return type hints for various extensions - part 6 (#7474) 2021-10-07 14:29:29 +02:00
Dmitry Stogov
0b5d62e39c Fixed type inference that may cause JIT failure
PHP allows to override a method that returns non-reference with a method
that returns a reference. This mean that we cannot use prototypes to
predict return types of a child functions.
2021-10-06 14:55:34 +03:00
Nikita Popov
3661c1932c Fix array cast type inference wrt packed arrays
Use KEY_LONG instead of PACKED if it's possible for the array to
be empty. It won't be packed in that case.

Fixes oss-fuzz #39650.
2021-10-06 10:50:44 +02:00
Nikita Popov
f455894bb6 Don't start new block after loop free
This reverts the change from 493c91c742.
Starting a new block means that in the common case where the loop var
free is not unreachable, we'll always merge back the block.

Instead fix the original problem by explicitly removing instructions
apart from the loop var free in block pass.
2021-10-06 10:13:15 +02:00
Dmitry Stogov
41dc14792e Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed SSA construction
2021-10-05 16:14:58 +03:00
Nikita Popov
20a784e026 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  POST_INC_OBJ/POST_DEC_OBJ don't have optional result
2021-10-05 12:05:57 +02:00
Nikita Popov
493c91c742 Start new block after loop free
In the attached test case we ended up not updating a leftover
MATCH jump in the unreachable_free block. There's different ways
this can be addressed, but in this case we can just make sure that
a new block is started after the loop free, which will allow it
to be dropped as unreachable. We only need to retain the free
itself for live-range reconstruction.

Fixes oss-fuzz #39516.
2021-10-04 16:59:46 +02:00
Nikita Popov
5cdbfa897c Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix cache slot assignment for ASSIGN_OBJ_OP
2021-09-30 14:34:50 +02:00
Nikita Popov
944d653b3d Fix inference for INIT_ARRAY with illegal offset type
Extract assign_dim_array_result_type() helper that can be reused
for INIT_ARRAY and implements all this logic correctly.

Fixes oss-fuzz 5156868775870464.
2021-09-29 11:09:04 +02:00
Nikita Popov
69eb6e04a7 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix ASSIGN_DIM result inference with typed refs
  Remove outdated code in ASSIGN_DIM type inference
2021-09-28 14:14:29 +02:00
Nikita Popov
2b71df71a1 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix type inference and SCCP with typed references
2021-09-28 12:59:24 +02:00
Nikita Popov
1e4a9a4999 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix block marking for two arm math
2021-09-28 10:38:22 +02:00
Nikita Popov
0015fc9a8e Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix relative offsets when copying JMPZNZ
2021-09-27 16:20:04 +02:00
Nikita Popov
b86fdf84f0 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Start block at loop var free
2021-09-27 11:58:53 +02:00
Nikita Popov
b7ec15f7fe Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix DCE of unreachable phi in cycle
2021-09-27 11:26:56 +02:00
Nikita Popov
d5e80c1c0c Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Handle pi nodes in replace_predecessor
2021-09-27 10:48:23 +02:00
Nikita Popov
c9762be566 Don't treat expression exit as terminator
Same as with throw expressions, this may remove later temporary
consuming instructions and thus eliminate live ranges, resulting
in a memory leak. We make use of the same hack and don't consider
exit a terminator if used in an expression context.
2021-09-23 10:26:07 +02:00
Nikita Popov
2dc8c7b3a7 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix ASSIGN_STATIC_PROP_REF type inference
2021-09-22 15:55:42 +02:00
Dmitry Stogov
cffba945e5 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed type inference
2021-09-22 15:32:16 +03:00
Nikita Popov
a846547ed4 Fix range() return type inference for undef operand
This results in a long range.
2021-09-21 17:03:18 +02:00
Nikita Popov
37337507ec Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Don't unconditionally add array value type for undef
2021-09-21 14:54:34 +02:00
Nikita Popov
55582a2527 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Don't replace values in unreachable code in sccp
2021-09-20 13:12:43 +02:00
Nikita Popov
bda1ee9511 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix FETCH_OBJ_IS type inference
2021-09-17 17:05:42 +02:00
Nikita Popov
e0e5b59d2e Try harder to clean up unreachable loop free block
While we can't drop the loop free, we can drop other instructions
in the same block. We should also indicate that it no longer has
predecessors.
2021-09-17 16:32:29 +02:00
Nikita Popov
3191f83146 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Don't const evaluate increment of array in SCCP
2021-09-16 14:43:28 +02:00
Nikita Popov
91aa78f9b4 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix may_throw for ASSIGN_OBJ
2021-09-16 12:47:04 +02:00
Nikita Popov
ce105f655a Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Handle undef assignment to typed ref
2021-09-15 10:58:41 +02:00