Commit Graph

5631 Commits

Author SHA1 Message Date
nielsdos
3189a9f94a Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix allocation loop in zend_shared_alloc_startup()
2023-05-24 20:11:48 +02:00
nielsdos
bbcf9e7107 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix allocation loop in zend_shared_alloc_startup()
2023-05-24 20:09:56 +02:00
nielsdos
6267601f84 Fix allocation loop in zend_shared_alloc_startup()
The break is outside the if, so if it succeeds or not this will always
stop after the first loop iteration instead of trying more allocators if
the first one fails.

Closes GH-11306.
2023-05-24 20:09:14 +02:00
LoongT4o
a2af8ac371
Fix the JIT buffer relocation failure at the corner case (#11266)
Avoid missing possible candidates due to the large address range of the free segment.
Eg, 

48000000-49400000 r-xs 08000000 00:0f 39322841               segment1
7ffff2ec8000-7ffff2f49000 rw-p 00000000 00:00 0              segment2
7ffff6fae000-7ffff735c000 r-xp 00200000 08:02 11538515       /usr/local/sbin/php-fpm

original code will miss the opportunity between [7ffff2ec** - 7ffff2ec8000].

Fix issue #11265.

Signed-off-by: Long, Tao <tao.long@intel.com>
Signed-off-by: Dmitry Stogov <dmitrystogov@gmail.com>
2023-05-23 14:49:19 +03:00
nielsdos
24ff7eee3f Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-11245 (In some specific cases SWITCH with one default statement will cause segfault)
2023-05-23 00:36:55 +02:00
nielsdos
f6563442db Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-11245 (In some specific cases SWITCH with one default statement will cause segfault)
2023-05-23 00:34:33 +02:00
Niels Dossche
5cad1a7176 Fix GH-11245 (In some specific cases SWITCH with one default statement will cause segfault)
The block optimizer pass allows the use of sources of the preceding
block if the block is a follower and not a target. This causes issues
when trying to remove FREE instructions: if the source is not in the
block of the FREE, then the FREE and source are still removed. Therefore
the other successor blocks, which must consume or FREE the temporary,
will still contain the FREE opline. This opline will now refer to a
temporary that doesn't exist anymore, which most of the time results in
a crash. For these kind of non-local scenarios, we'll let the SSA
based optimizations handle those cases.

Closes GH-11251.
2023-05-23 00:33:25 +02:00
Ilija Tovilo
0600f513b3
Implement delayed early binding for classes without parents
Normally, we add classes without parents (and no interfaces or traits) directly
to the class map, early binding the class. However, if the same class has
already been registered, we would instead just add a ZEND_DECLARE_CLASS
instruction and let the handler throw a duplicate class declaration exception.

However, with opcache, if on the next request the files are included in the
opposite order, we won't perform early binding. To fix this, create a
ZEND_DECLARE_CLASS_DELAYED instruction instead and handle classes without
parents accordingly, skipping any linking for classes that are already linked in
delayed early binding.

Fixes GH-8846
2023-05-15 10:25:33 +02:00
Sara
6bd546462c
Cacheline demote to improve performance (#11101)
Once code is emitted to JIT buffer, hint the hardware to
demote the corresponding cache lines to more distant level
so other CPUs can access them more quickly.
This gets nearly 1% performance gain on our workload.

Signed-off-by: Xue,Wang   <xue1.wang@intel.com>
Signed-off-by: Tao,Su     <tao.su@intel.com>
Signed-off-by: Hu,chen    <hu1.chen@intel.com>
2023-05-15 10:28:43 +03:00
Ilija Tovilo
e0af7c332d
Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix delayed early binding class redeclaration error
2023-05-12 19:29:27 +02:00
Ilija Tovilo
e3499130f1
Fix delayed early binding class redeclaration error
If we bind the class to the runtime slot even if we're not the ones who have
performed early binding we'll miss the redeclaration error in the
ZEND_DECLARE_CLASS_DELAYED handler.

Closes GH-11226
2023-05-12 19:29:04 +02:00
nielsdos
41cda46b70 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix too wide OR and AND range inference
2023-05-02 20:20:15 +02:00
nielsdos
e1fc246444 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix too wide OR and AND range inference
2023-05-02 20:18:05 +02:00
nielsdos
fbf5216ca0 Fix too wide OR and AND range inference
There is a typo which causes the AND and OR range inference to infer a
wider range than necessary. Fix this typo. There are many ranges for
which the inference is too wide, I just picked one for AND and one for
OR that I found through symbolic execution.

In this example test, the previous range inferred for test_or was [-27..-1]
instead of [-20..-1].
And the previous range inferred for test_and was [-32..-25]
instead of [-28..-25].

Closes GH-11170.
2023-05-02 20:08:59 +02:00
Dmitry Stogov
56d1cc7842 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fixed GH-11127 (JIT fault)
2023-05-02 20:33:34 +03:00
Dmitry Stogov
c155949905 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fixed GH-11127 (JIT fault)
2023-05-02 20:33:19 +03:00
Dmitry Stogov
ed0b593c11
Fixed GH-11127 (JIT fault)
* Fixed GH-11127 (JIT fault)

* Added test

* Add new line
2023-05-02 20:32:48 +03:00
Sara
0e5ac62f4e
Add configuration opcache.jit_max_trace_length (#11173)
Max length of a single trace. A long trace generates long JITTed
code, which influences the performance slightly.
opcache.jit_max_trace_length range is [4,1024], the default value
is 1024.


Reviewed-by:   Su, Tao   <tao.su@intel.com>

Signed-off-by: Wang, Xue <xue1.wang@intel.com>
2023-05-02 18:47:13 +03:00
yang yuhan
f127e6581a
JIT: Align JIT stubs (#11149)
Fixed phpGH-11120

Signed-off-by: PeterYang12 <yuhan.yang@intel.com>
2023-05-02 12:34:49 +03:00
Dmitry Stogov
f0122664fe Merge branch 'PHP-8.2'
* PHP-8.2:
  JIT: Fixed inaccurate range inference usage for UNDEF/NULL/FALSE
2023-05-02 12:04:11 +03:00
Dmitry Stogov
7e50735140 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  JIT: Fixed inaccurate range inference usage for UNDEF/NULL/FALSE
2023-05-02 12:04:03 +03:00
Dmitry Stogov
25ad171f63 JIT: Fixed inaccurate range inference usage for UNDEF/NULL/FALSE
Fixes oss-fuzz #58459
2023-05-02 12:02:20 +03:00
nielsdos
56f916e703 Merge branch 'PHP-8.2'
* PHP-8.2:
  Set error_log to an empty value if the test relies on that feature
2023-04-24 23:25:27 +02:00
nielsdos
7300659391 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Set error_log to an empty value if the test relies on that feature
2023-04-24 23:23:45 +02:00
Niels Dossche
691ff9f845 Set error_log to an empty value if the test relies on that feature
Some tests fail if the error_log is overriden by the loaded ini
configuration. Explicitly set it to an empty value to prevent the
failures.
See https://github.com/php/php-src/issues/10737#issuecomment-1452899299

Closes GH-10772.
2023-04-24 23:19:15 +02:00
Máté Kocsis
414f71a902
Typed class constants (#10444)
RFC: https://wiki.php.net/rfc/typed_class_constants

Co-Authored-By: Ben <7127204+moliata@users.noreply.github.com>
Co-Authored-By: Bob Weinand <3154871+bwoebi@users.noreply.github.com>
Co-Authored-By: Ilija Tovilo <ilija.tovilo@me.com>
2023-04-16 22:20:26 +02:00
Dmitry Stogov
0660fb5282 Merge branch 'PHP-8.2'
* PHP-8.2:
  Allow FETCH_OBJ_W and FETCH_STATIC_PROP_W to return INDIRECT/UNDEF zval for uninitialized typed properties (#11048)
2023-04-10 23:25:42 +03:00
Dmitry Stogov
e14ac1caee Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Allow FETCH_OBJ_W and FETCH_STATIC_PROP_W to return INDIRECT/UNDEF zval for uninitialized typed properties (#11048)
2023-04-10 23:25:08 +03:00
Dmitry Stogov
0c65b396d6
Allow FETCH_OBJ_W and FETCH_STATIC_PROP_W to return INDIRECT/UNDEF zval for uninitialized typed properties (#11048) 2023-04-10 23:19:17 +03:00
Ilija Tovilo
9a250cc9d6
Add separate static property through trait if parent already declares it
Fixes GH-10935
Closes GH-10937
2023-04-06 14:27:24 +02:00
Dmitry Stogov
e1c6fb76c0
JIT support for delayed destructor for zend_assign_to_typed_ref/prop 2023-04-04 18:55:47 +02:00
Dmitry Stogov
24acb4f134
Delay destructor for zend_std_write_property 2023-04-04 18:55:47 +02:00
Joan Miquel
9e8614233c
Add ngx-php to opcache supported sapis (#11013)
This SAPI embed PHP in Nginx server.
https://github.com/rryqszq4/ngx-php

And in the Techempower benchmarks, it's the fastest PHP SAPI.
https://www.techempower.com/benchmarks/#section=data-r20
2023-04-04 16:58:59 +02:00
Máté Kocsis
f42992f580
Remove name field from the zend_constant struct (#10954)
As global constant names are case-sensitive now, we don't have to store them separately above the constant table.
2023-04-03 22:13:47 +02:00
Dmitry Stogov
9a8123142e Merge branch 'PHP-8.2'
* PHP-8.2:
  Tracing JIT: Fixed incorrect code generation fofr SEND-ing of result of ASSIGN to typed reference
2023-04-03 18:15:59 +03:00
Dmitry Stogov
962aac698e Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Tracing JIT: Fixed incorrect code generation fofr SEND-ing of result of ASSIGN to typed reference
2023-04-03 18:15:46 +03:00
Dmitry Stogov
8a749c79d0 Tracing JIT: Fixed incorrect code generation fofr SEND-ing of result of ASSIGN to typed reference 2023-04-03 18:15:41 +03:00
Ilija Tovilo
50f58c8923
Add ASAN XLEAK support
Only disable LSAN instead of skipping the test. This way we can still detect
memory issues which is arguably more important anyway.

Closes GH-10996
2023-04-03 08:02:19 +02:00
Dmitry Stogov
22d5d146e5 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix incorrect optimization
2023-03-27 17:58:35 +03:00
Dmitry Stogov
1f5d9534ae Fix incorrect optimization
Fixes oss-fuzz #57482
2023-03-27 17:57:54 +03:00
Ilija Tovilo
b73b70f097
Rename --with-opcache-capstone to --with-capstone (#10952) 2023-03-27 12:59:27 +02:00
George Peter Banyard
d7c351ea54
Propagate UTF-8 flag during Rope operations (#10915) 2023-03-26 14:18:46 +01:00
Michael Orlitzky
87922411bf
Use capstone explicitly, drop oprofile (GH 10876) (#10918)
* ext/opcache/config.m4: new --with-opcache-capstone flag.

Until now, libcapstone has been detected "automagically" and used for
JIT disassembly whenever it is available on the system used to compile
PHP. This can have some unintended consequences, however: many users
have capstone installed for some other purpose, and are surprised to
find that PHP breaks when capstone is later uninstalled.

To address this, we have introduced a new --with-opcache-capstone flag
that is disabled by default, and that makes the user's preference
explicit. It is ignored unless the JIT is enabled.

* ext/opcache: drop support for the oprofile JIT profiler.

Recently we have replaced the "automagic" detection of capstone at
build time with a --with-opcache-capstone flag. The detection of
oprofile causes similar problems and would likely have the same
solution; however, it was suggested that we might remove oprofile
altogether. So, this commit removes it:

  * Remove the detection bits from ext/opcache/config.m4.
  * Drop HAVE_OPROFILE ifdef blocks.
  * Delete ext/opcache/jit/zend_jit_oprofile.c.
  * Undefine the ZEND_JIT_DEBUG_OPROFILE constant.
2023-03-25 15:12:34 +01:00
Ilija Tovilo
9d5f2f1343
Use new ZSTR_INIT_LITERAL macro (#10879) 2023-03-20 16:19:05 +01:00
Arnaud Le Blanc
bdd782e267 Merge branch 'PHP-8.2'
* PHP-8.2:
  Remove xfail from tests that do not fail anymore (#10871)
2023-03-17 18:15:03 +01:00
Arnaud Le Blanc
d87b670544 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Remove xfail from tests that do not fail anymore (#10871)
2023-03-17 18:13:31 +01:00
Arnaud Le Blanc
53763e14b7
Remove xfail from tests that do not fail anymore (#10871) 2023-03-17 18:12:51 +01:00
Niels Dossche
f9375dc723 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix module shutdown crash during ZTS JIT shutdown
2023-03-13 20:12:37 +01:00
Niels Dossche
ae39069051 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix module shutdown crash during ZTS JIT shutdown
2023-03-13 20:12:30 +01:00
Niels Dossche
b3e28e2290 Fix module shutdown crash during ZTS JIT shutdown
Commit a21195650e fixed a leak by adding a TSRM destructor for the
JIT globals in ZTS mode. In case the main thread shuts down the TSRM, it
will call all the destructors. The JIT globals destructor will be
invoked, but will always access the main thread globals using JIT_G.
This means that instead of freeing the JIT globals in the different
threads, the one in the main thread is freed repeatedly over and over,
crashing PHP. Fix it by always passing the pointer instead of relying on
JIT_G.

Closes GH-10835.
2023-03-13 20:12:13 +01:00