1
0
mirror of https://github.com/php/php-src.git synced 2026-04-25 17:08:14 +02:00
Commit Graph

4407 Commits

Author SHA1 Message Date
Nikita Popov e7de9b2091 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix func/class name use after free on opcache OOM condition
2021-09-14 12:03:03 +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 8c601edada Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  BIND_STATIC may throw
2021-09-13 17:25:13 +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 133afe8591 Fix JIT call chain check without call opcode
The do_fcall opcode may have been optimized away if an opcode like
exit is present in the arguments. In that case the opcode scan
would go past the end of the op array.
2021-09-13 16:48:38 +02:00
Nikita Popov 86d470f3e0 Reset CE cache slots on opcache reset
Permanent opcache interned strings could have ce_cache pointing to
non-permanent map_ptr slots. On reset, those would be left dangling.
Clear any non-permanent ce_cache slots when the interned string
state is reset.

This was fun to debug...
2021-09-13 15:20:34 +02:00
Nikita Popov 9042c7aac6 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Handle undef value in assign_dim jit
2021-09-13 11:10:03 +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
Dmitry Stogov 971142a12a Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  JIT: Fixed exit from CALL VM with GCC Global Register Variables
2021-09-13 11:40:45 +03: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 f86a963199 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Also make sure binary op operands can't be undef
2021-09-09 15:09:02 +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 b9a6ec2097 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Check whether expected types are present for compound op jit
2021-09-09 14:33:10 +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 679bfb1522 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  JIT: fixed MUL+SEND optimization when MUL throws an exception
2021-09-08 17:57:21 +03:00
Dmitry Stogov 06275d940c JIT: fixed MUL+SEND optimization when MUL throws an exception 2021-09-08 17:53:23 +03:00
Nikita Popov f2bb739eeb Apply fix to ARM JIT as well
This is the same change as e22fb46127,
but for the ARM JIT implementation.
2021-09-08 15:46:35 +02:00
Nikita Popov 4bccf36973 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Save register before throwing undef var notice
2021-09-08 14:46:08 +02: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 8d069d266a Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix jump after zend_jit_invalid_property_assign()
2021-09-08 12:29:05 +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
Dmitry Stogov 487eface86 Fixed ARM JIT failure introduced in d4ed6b635f 2021-09-07 17:18:35 +03:00
Dmitry Stogov 7fcb45dffa JIT: prefer string reallocation instead of allocation/memcpy/deallocation 2021-09-07 15:28:15 +03:00
Dmitry Stogov aed94e2ca8 JIT: improved code for protected properties access 2021-09-07 13:18:14 +03:00
Dmitry Stogov 1bb6cf5396 JIT: eliminate check for undefined constant if there is a persistent constant 2021-09-07 13:17:16 +03:00
Dmitry Stogov d4ed6b635f JIT: Update run_time_cache slot in zend_jit_find_func helper 2021-09-07 13:13:47 +03:00
Máté Kocsis 6a47831e6e Add more specific array return type hints for various extensions - part 3 (#7467) 2021-09-06 12:27:28 +02:00
Dmitry Stogov cbc925e510 Fixed bug #81409 (Incorrect JIT code for ADD with a reference to array) 2021-09-02 11:13:27 +03:00
Dmitry Stogov 66f8866a62 JIT: Fixed call to zend_free_compiled_variables() 2021-09-01 19:10:54 +03:00
Nikita Popov 5b2ddf5a17 Export zend_use_resource_as_offset()
Use a common implementation to generate this error message, as
we do so in quite a few places dealing with array keys.
2021-08-31 10:58:01 +02:00
Dmitry Stogov dad5cfa868 Rename ZREG_FCARG1x/ZREG_FCARG1a into ZREG_FCARG1 2021-08-30 20:38:52 +03:00
Dmitry Stogov f1f4403dc2 Fixed register allocation when ADD/SUB/MUL two references in tracing JIT
The bug was introdueced by 7690fa0bd8 and
leaded to failure in `make test TESTS="-d opcache.jit=1254 --repeat 3 ext/date/tests/bug30096.phpt"`
2021-08-30 19:41:39 +03:00
Dmitry Stogov 7690fa0bd8 JIT: Better code for ADD/SUB/MUL and references in tracing JIT. 2021-08-30 17:02:35 +03:00
Dmitry Stogov 8f601be101 JIT: Allow keeping result of FETCH_CONSTANT in a CPU register 2021-08-30 14:56:51 +03:00
Dmitry Stogov 96c3465513 JIT: Avoid useless EX(func) load 2021-08-30 13:58:23 +03:00
Dmitry Stogov 608d568686 JIT: Avoid reloading of EX(run_time_cache) 2021-08-30 13:19:04 +03:00
Dmitry Stogov 3565d02c6d JIT: Eliminate load of op_array->run_time_cache__ptr and use immediate value for immutable op_arrays if it's known at compile time 2021-08-30 12:26:37 +03:00
Dmitry Stogov 1347d90a23 JIT: Avoid reloading of EX(run_time_cache) 2021-08-30 11:02:30 +03:00
Dmitry Stogov c51b0d9702 JIT: Avoid redundand checks of number of passed arguments 2021-08-30 10:15:54 +03:00
Dmitry Stogov 66a4437c3b Avoid redundand argument type verification 2021-08-29 19:21:01 +03:00
Dmitry Stogov 67d6c2db9f JIT: Optimize zend_vm_stack_free_args()
Avoid code genearation for destructors of immutable parameters of internal functions that cannot be changed in place.
Keep destructors for immutable array parameters, because few function may modufy them in-pace.
2021-08-29 17:49:54 +03: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
Dmitry Stogov 0424ce0c15 Avoid redundand repeatable VM stack overflow checks 2021-08-26 16:50:29 +03:00
Nikita Popov 6434c93a27 Explicitly store real map ptr base
If we only store the biased pointer, the map ptr region will not
be recognized as reachable memory by leak checkers. This is
primarily problematic for fuzzing, because this is persistent
memory that may be reallocated during the request, without being
an actual leak.

Avoid this by simply storing both the real base pointer of the
allocation, as well as the biased base pointer used for accesses.
2021-08-26 12:29:44 +02:00