1
0
mirror of https://github.com/php/php-src.git synced 2026-04-18 21:41:22 +02:00
Commit Graph

769 Commits

Author SHA1 Message Date
Dmitry Stogov
7a93a8a6fd JIT: Fixed JIT for FETCH_OBJ when op1 is a reference of non-object 2021-09-22 14:52:25 +03:00
Dmitry Stogov
19854371ed Tracing JIT: Fixed bug in register allocator.
Type of variable might need to be checked (using type guard) before loading to register.
2021-09-22 00:43:56 +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
f4bcf8c393 Check for undef var in typed property assignment
Without this check the assignment would actually silently succeed,
not just skip the warning.
2021-09-21 14:09:26 +02:00
Nikita Popov
95e0cc06a2 Fix missing undef checks for comparisons 2021-09-21 12:06:32 +02:00
Dmitry Stogov
f0f774a129 JIT x86: Fixed register clobbering in code produced for "$x[$y] %= $z". 2021-09-21 10:42:53 +03: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
Dmitry Stogov
01cfd5e4f9 JIT: Fixed incorrect assignment of undefined variable 2021-09-17 18:35:55 +03: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
Dmitry Stogov
04209de93c JIT: Fixed warning when assign undefined variable to property 2021-09-17 16:22:06 +03:00
Nikita Popov
d46b10296e Don't jit FE_RESET_R with undef operand
The implementation currently assumes that the operand is always
an array, but this did not account for a possibly undef operand.
2021-09-17 12:04:21 +02:00
Dmitry Stogov
5e3eaf14fe JIT: Fixed memory leak in BOOL_NOT when opearnd ia a reference to bool 2021-09-16 17:18:51 +03:00
Nikita Popov
83f283f5ea Undef result on throwing typed reference assignment 2021-09-16 15:48:10 +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
7257e7e5aa Handle SWITCH_STRING with optimized away FREE
This can happen in degenerate cases where we know that the
SWITCH_STRING argument is not refcounted. We should be treating it
in the same way as SWITCH_LONG here.
2021-09-16 11:31:06 +02:00
Nikita Popov
6de8b08f60 Don't undef result operand if there is none
The mod_by_zero and negative_shift helper may also be used by
ASSIGN_OP, in which case there is not necessarily a result operand.
If the stars aligned just right, this used to clobber other parts
of the call frame.

For these two helpers, check whether the result_type is TMP/VAR
before setting to UNDEF:
2021-09-15 14:49:13 +02:00
Nikita Popov
3ee85ccd4a Handle undef assignment to typed ref 2021-09-15 10:58:01 +02:00
Nikita Popov
10bbff8758 Fix JIT for recursive call with too few args
We may not generate labels for all leading RECVs. Don't generate
a direct jump if we have less arguments than required.
2021-09-14 15:15:14 +02: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
e7663785a7 Handle undef value in assign_dim jit
We should report the undefined variable here and convert it to
null. Passing on undef is particularly insidious here, because
a write_dimension handler may insert it into a hash table
(observed with WeakMap).
2021-09-13 11:09:00 +02:00
Nikita Popov
8c3d33a054 Also make sure binary op operands can't be undef
Otherwise we will end up passing undef to xyz_function etc, which
is not permitted.
2021-09-09 15:08:08 +02:00
Dmitry Stogov
06275d940c JIT: fixed MUL+SEND optimization when MUL throws an exception 2021-09-08 17:53:23 +03:00
Nikita Popov
e22fb46127 Save register before throwing undef var notice
Otherwise we may clobber it while throwing the undef var notice.
This makes the implementation for assign_dim_op line up with
fetch_dim.
2021-09-08 14:45:49 +02:00
Nikita Popov
b0e16f0e4f Fix jump after zend_jit_invalid_property_assign()
This is supposed to go to the FREE_OP_DATA, currently it crashes.
2021-09-08 12:27:54 +02:00
Nikita Popov
47ccdecf00 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #81353
2021-08-16 15:04:57 +02:00
Nikita Popov
d1e956ff31 Fixed bug #81353
A user-defined error handler should not be invoked for preload
warnings. We are in a partially shut-down state at that point.
2021-08-16 15:04:17 +02:00
Dmitry Stogov
17b5fe13e2 Added test 2021-07-21 19:29:59 +03:00
Dmitry Stogov
a9991fbf28 Fixed Bug #80959 (infinite loop in building cfg during JIT compilation) 2021-07-21 14:32:44 +03:00
Dmitry Stogov
02acc5ad3b Fixed Bug #81255 (Memory leak in PHPUnit with functional JIT) 2021-07-20 22:14:32 +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
Hao Sun
c5d93aeee9 Fixed incorrec immediate encoding when using LEA optimization 2021-07-19 14:51:08 +03:00
Dmitry Stogov
c0e4932816 Fixed bug #81249 (Intermittent property assignment failure with JIT enabled) 2021-07-19 12:11:09 +03:00
Dmitry Stogov
ee981619ce Skip test on 32-bit system 2021-07-19 10:49:43 +03:00
Dmitry Stogov
9cd437138e Fixed bug #81225 (Wrong result with pow operator with JIT enabled) 2021-07-19 10:39:52 +03: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
Dmitry Stogov
ac65f6af6e Fixed bug #81051 (Broken property type handling after incrementing reference) 2021-05-27 15:22:34 +03: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
twosee
a3e6735999 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80900

# Conflicts:
#	ext/opcache/Optimizer/sccp.c
2021-04-14 00:15:06 +08:00
twosee
7c6cf09463 Fixed bug #80900
SCCP optimization marks the wrong target feasible when the constant is of the incorrect type.

Closes GH-6861.
2021-04-14 00:07:32 +08:00
Nikita Popov
59b2a899ca Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix DCE of FREE of COALESCE
2021-04-08 17:01:19 +02:00
Nikita Popov
0826a54836 Fix DCE of FREE of COALESCE
When encountering the following SSA graph:

    BB1:
    #2.T1 [string] = COALESCE #1.CV0($str) [null, string] BB2

    BB2:
    #5.T1 [string] = QM_ASSIGN string("")

    BB3:
    #7.X1 [string] = Phi(#2.X1 [string], #5.X1 [string])
    FREE #7.T1 [string]

We would currently determine that #7, #5 are dead, and eliminate
the FREE and QM_ASSIGN. However, we cannot eliminate #2, as
COALESCE is also responsible for control flow.

Fix this my marking all non-CV phis as live to start with. This
can be relaxed to check the kind of the source instruction, but
I couldn't immediately come up with a case where it would be
useful.
2021-04-08 17:01:13 +02:00
Dmitry Stogov
7e494d9225 Fixed bug #80861 (erronous array key overflow in 2D array with JIT) 2021-03-17 22:59:59 +03:00
Dmitry Stogov
faf1567212 Fixed bug #80839 (PHP problem with JIT) 2021-03-17 16:55:09 +03:00
Dmitry Stogov
957cb13a49 Fixed bug #80802: (zend_jit_fetch_indirect_var assert failure with tracing JIT) 2021-03-01 23:57:20 +03:00
Nikita Popov
e857936518 Fixed bug #80805
Handle missing result_var in binary_op_result_type.

(cherry picked from commit 8446e28275)
2021-03-01 15:13:15 +01:00