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

3808 Commits

Author SHA1 Message Date
Dmitry Stogov
48d050ef72 JIT: Disable recursive call optimization for VM without global register variables
A tail-call to VM handler from recursively called function may lead to
pass control to incorrect stack frame.
2021-09-21 14:30:56 +03:00
Nikita Popov
95e0cc06a2 Fix missing undef checks for comparisons 2021-09-21 12:06:32 +02:00
Dmitry Stogov
0e0f50b413 JIT x86: Fixed incorrect EX(func) initialization for recursive calls 2021-09-21 13:01:27 +03: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
015cafa38c JIT: keep register value across call 2021-09-17 17:58:24 +03: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
Dmitry Stogov
236e7aef01 JIT: Fixed call chain construction 2021-09-15 17:27:05 +03: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
10e9f6b340 Fix func/class name use after free on opcache OOM condition
This can occur on opcache OOM conditions, where the function/class
names are not interned and the script does not get cached. In
that case the functions/classes get transferred from the persistent
script to the global tables, without incrementing the key refcount.
To mirror that, we should also not try to free the keys when freeing
the persistent script. For this by setting the number of elements
to zero, which will free only the hashtable structure itself.
2021-09-14 12:00:44 +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
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
Hao Sun
cfb21e8dc1 JIT: Fixed exit from CALL VM with GCC Global Register Variables
PHP JIT supports three configurations: HYRBID, CALL with global register
variables feature(CALL+GRV for short), and CALL+noGRV.

CALL+GRV mode can be built with the following commands:

```
  php Zend/zend_vm_gen.php --with-vm-kind=CALL
  ./buildconf -f; ./configure; make
```

About 230 test cases failed for tracing JIT under CALL+GRV mode on both
x86 and arm64 machines.

For CALL+GRV mode, the condition to determine whether the execution of
an oparray is finished, is "opline == NULL". See function execute_ex()
around line "if (UNEXPECTED(!OPLINE)) {".

However, such cleanup operation is missing for the JIT wrapper
zend_jit_trace_counter_helper(), and the trace_halt stub function.

Tests:
1. test cases: all .phpt test cases under "Zend/tests/ tests/
ext/opcache/tests/jit/".
2. both JIT/x86 and JIT/arm64: function JIT, tracing JIT and tracing JIT
with "--repeat 3"
3. execution modes: NTS/ZTS, HYBRID/CALL+GRV/CALL+noGRV

In my local test, these test cases passed under all JIT configrations.
2021-09-13 11:35:12 +03: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
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
Nikita Popov
bac054dbf3 Check whether expected types are present for compound op jit
zend_jit_long_math_helper() implicitly assumes that the operands
MAY_BE_LONG (but can also have additional types). It will normally
only be called if this is guaranteed. However, for compound
array/object assignment ops this was not check. Generalize the
existing check for assign_op to apply to these as well.

Of course, we could also make the code support this correctly,
but I don't think it makes sense to JIT these if the type we're
specializing for is not present.

Closes GH-7481.
2021-09-09 14:32:14 +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
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
Nikita Popov
de7ba3e737 Fix repeated file cache unserialization of zval string
The IS_UNSERIALIZED check here does not work if the string is
interned (serialized with file_cache_only=0) but unserialization
happens with file_cache_only=1. In this case the unserializde
string will be in the str area after mem, which is not included
in the script size, and which is also not accessible at this
point without threading through more information. Work around
the problem by checking for the serialized representation instead.
2021-08-18 12:38:27 +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
8fbeebec34 Fixed typo 2021-07-22 16:14:26 +03:00
Dmitry Stogov
17b5fe13e2 Added test 2021-07-21 19:29:59 +03:00
Dmitry Stogov
053c56f52e Fixed bug #81226 (Integer overflow behavior is different with JIT enabled) 2021-07-21 19:28:43 +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
Christoph M. Becker
ef77d3c89f Fix #81206: Multiple PHP processes crash with JIT enabled
We need to avoid resetting the JIT for all SAPIs, but we need to
initialize the JIT handlers even when only reattaching on Windows.

Closes GH-7208.
2021-07-19 23:45:37 +02:00
Dmitry Stogov
15abbea5e7 Avoid ASAN integer overflow warnings 2021-07-19 14:53:23 +03: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