Commit graph

776 commits

Author SHA1 Message Date
yang yuhan
566100d7fe
Enhance moving PHP code pages into huge pages (#12806)
The former implementation of huge pages for PHP code segments may
fail to map in certain scenarios. For instance, if the initial
'r-x-' segment is not PHP, it will result in a failure to map into
huge pages. Consequently, the optimization for huge pages with PHP
code will no longer be effective.

This patch improves the implementation by accurately matching all
'r-x-' segments until it locates the PHP code segment. Subsequently,
it performs the necessary huge page mapping.


Reviewed-by: chen-hu-97 <hu1.chen@intel.com>

Signed-off-by: PeterYang12 <yuhan.yang@intel.com>
2023-11-29 10:49:23 +03:00
Daniil Gentili
fde41bc713
Report fatal error if JIT cannot be enabled
Closes GH-12403
2023-11-28 00:21:26 +01:00
Ilija Tovilo
874f966cbc
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Avoid JIT warning with opcache.jit_buffer_size=0
2023-10-18 10:49:14 +02:00
Ilija Tovilo
b49e178563
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Avoid JIT warning with opcache.jit_buffer_size=0
2023-10-18 10:49:07 +02:00
Ilija Tovilo
07d81592e9
Avoid JIT warning with opcache.jit_buffer_size=0
Closes GH-12460
2023-10-18 10:46:30 +02:00
Ilija Tovilo
477aadedc7
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Report warning if JIT cannot be enabled
2023-10-11 12:12:30 +02:00
Ilija Tovilo
18942459a2
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Report warning if JIT cannot be enabled
2023-10-11 12:11:59 +02:00
Daniil Gentili
7177461141
Report warning if JIT cannot be enabled
Closes GH-12404
2023-10-11 12:10:48 +02:00
Ilija Tovilo
520fc70245
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Invalidate path even if the file was deleted
2023-10-03 15:32:53 +02:00
Ilija Tovilo
6274970bee
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Invalidate path even if the file was deleted
2023-10-03 15:32:28 +02:00
Mikhail Galanin
f4ab494906
Invalidate path even if the file was deleted
Closes GH-12323
2023-10-03 15:31:39 +02:00
Niels Dossche
0427e26729 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix #80092: ZTS + preload = segfault on shutdown
2023-10-02 19:42:10 +02:00
Niels Dossche
28a909d40a Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix #80092: ZTS + preload = segfault on shutdown
2023-10-02 19:37:09 +02:00
Niels Dossche
bdc87b0f66 Fix #80092: ZTS + preload = segfault on shutdown
After preloading has executed, the executor globals for class_table and
function_table are still referring to the values during preloading.
If no request happens after that then these values will remain dangling
pointers. If then the -v option on CLI or -h option (and possibly
others) on CGI is provided, there is a double free.
Fix it by nulling the pointers explicitly after preloading has finished
to fix it for all SAPIs.

Closes GH-12311.
2023-10-02 19:33:41 +02:00
Jakub Zelenka
5e8c992c78
Reduce impact of stream file path check in filestat
Fix for #76857 introduced slight perf regression so this is an attempt
to fix it. The idea is to re-use stream path check from ZendAccelerator
that should be quicker than strstr.

Signed-off-by: Jakub Zelenka <bukka@php.net>
2023-09-24 16:50:01 +01:00
Ilija Tovilo
b2dbf0a2c6
Remove opcache.consistency_checks
This feature has been broken at least since the tracing JIT and inheritance
cache have been introduced. The attempted fix (GH-10798) was too complex. We
have thus decided to remove this feature for now.

Closes GH-11832
2023-08-02 19:22:30 +02:00
Niels Dossche
e90c96bc8d Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-11715: opcache.interned_strings_buffer either has no effect or opcache_get_status() / phpinfo() is wrong
2023-07-21 13:10:04 +02:00
Niels Dossche
404f1d3700 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-11715: opcache.interned_strings_buffer either has no effect or opcache_get_status() / phpinfo() is wrong
2023-07-21 13:09:44 +02:00
Niels Dossche
ee3f932390 Fix GH-11715: opcache.interned_strings_buffer either has no effect or opcache_get_status() / phpinfo() is wrong
There are a couple of oddities.

1) The interned strings buffer comprises the whole hashtable
   datastructure.
   Therefore, it seems that the interned strings buffer size is the size of
   only said table. However, in the current code it also includes the size
   of the zend_accel_shared_globals.

2) ZCSG(interned_strings).end is computed starting from the accelerator
   globals struct itself. I would expect it to start from the part where
   the interned strings table starts.

3) When computing the used size, it is done using
   ZCSG(interned_strings).end - ZCSG(interned_strings).start. However,
   this does not include the uin32_t slots array because
   ZCSG(interned_strings).start pointers after that array.

This patch corrrects these 3 points.

Closes GH-11717.
2023-07-21 13:04:53 +02:00
Ilija Tovilo
1a0ef2c1cc
Revert "Remove name field from the zend_constant struct (#10954)"
This reverts commit f42992f580.

Closes GH-11604
2023-07-17 22:32:41 +02:00
Niels Dossche
9c5cf6594d Merge branch 'PHP-8.2'
* PHP-8.2:
  Prevent potential deadlock if accelerated globals cannot be allocated
2023-07-17 13:03:11 +02:00
Niels Dossche
8b1d352ed8 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Prevent potential deadlock if accelerated globals cannot be allocated
2023-07-17 13:00:00 +02:00
Niels Dossche
b0bc057e86 Prevent potential deadlock if accelerated globals cannot be allocated
Not sure if this is possible to hit in practice, zend_accel_error_noreturn
doesn't return so the unlock isn't called. Other callsites that use both
zend_accel_error_noreturn and zend_shared_alloc_unlock first perform the
unlocking.

Closes GH-11718.
2023-07-17 12:49:15 +02:00
Ilija Tovilo
ad1b70d67e
Revert "Revert "Remove name field from the zend_constant struct (#10954)""
This reverts commit 9f4bd3040d.
2023-07-04 16:42:40 +02:00
Máté Kocsis
9f4bd3040d
Revert "Remove name field from the zend_constant struct (#10954)"
This reverts commit f42992f580.

Fix GH-11423
2023-07-03 15:16:24 +02:00
nielsdos
1ed68686de Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix DOMElement::append() and DOMElement::prepend() hierarchy checks
  Fix spec compliance error for DOMDocument::getElementsByTagNameNS
  Fix GH-11336: php still tries to unlock the shared memory ZendSem with opcache.file_cache_only=1 but it was never locked
  Fix GH-11338: SplFileInfo empty getBasename with more than one slash
2023-05-30 17:41:54 +02:00
nielsdos
0e7ad40900 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix DOMElement::append() and DOMElement::prepend() hierarchy checks
  Fix spec compliance error for DOMDocument::getElementsByTagNameNS
  Fix GH-11336: php still tries to unlock the shared memory ZendSem with opcache.file_cache_only=1 but it was never locked
  Fix GH-11338: SplFileInfo empty getBasename with more than one slash
2023-05-30 17:38:18 +02:00
Niels Dossche
9c59d22a7b Fix GH-11336: php still tries to unlock the shared memory ZendSem with opcache.file_cache_only=1 but it was never locked
I chose to check for the value of lock_file instead of checking the
file_cache_only, because it is probably a little bit faster and we're
going to access the lock_file variable anyway. It's also more generic.

Closes GH-11341.
2023-05-30 17:32:02 +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
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
Ilija Tovilo
9d5f2f1343
Use new ZSTR_INIT_LITERAL macro (#10879) 2023-03-20 16:19:05 +01:00
Dmitry Stogov
28be84a146 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix Zend/tests/type_declarations/variance/class_order_autoload1.phpt test failre introduced by 44e5c04e55
2023-02-28 23:05:40 +03:00
Dmitry Stogov
dcf2810cd1 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix Zend/tests/type_declarations/variance/class_order_autoload1.phpt test failre introduced by 44e5c04e55
2023-02-28 23:05:30 +03:00
Dmitry Stogov
18b43d2950 Fix Zend/tests/type_declarations/variance/class_order_autoload1.phpt
test failre introduced by 44e5c04e55

This ASSERT-ion path was never reached becuase of the bug fixed by
44e5c04e55. It's possible in case of
circular class dependencies that may resolved by __autoload().
Unfortunately these circular dependencies can't be stored in the
inheritace cahce.
2023-02-28 22:57:52 +03:00
Dmitry Stogov
44e5c04e55 Fix incorrect inheritance cache update (#10719) 2023-02-27 21:47:29 +03:00
Dmitry Stogov
c7a9190124 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix incorrect inheritance cache update (#10719)
2023-02-27 21:39:53 +03:00
Dmitry Stogov
2e3fc8c0ff
Fix incorrect inheritance cache update (#10719) 2023-02-27 21:39:18 +03:00
Niels Dossche
375e7402af
Change implicit enum return value checks to explicit checks (#10703) 2023-02-26 08:56:20 +00:00
David Carlier
c54948378d Merge branch 'PHP-8.2' 2023-02-26 08:19:05 +00:00
David Carlier
bf2e778c71 Merge branch 'PHP-8.1' into PHP-8.2 2023-02-26 08:18:09 +00:00
Niels Dossche
eb7bb3430b Fix format string mistake in accel_move_code_to_huge_pages()
inode is unsigned, so use %lu instead of %ld
2023-02-26 08:12:57 +00:00
Max Kellermann
263b22f374
Make lots of string pointers const (#10646)
This allows using string literals without implicitly casting away the
`const`.
2023-02-21 14:01:37 +00:00
Max Kellermann
04c85a3371 ext/opcache/ZendAccelerator: fix functions to return zend_result
If a function returns SUCCESS or FAILURE, it should be declared to
return the enum that defines those values.
2023-02-18 19:35:58 +00:00
Max Kellermann
a50de37013 ext/opcache/ZendAccelerator: accel_is_inactive() returns bool
It was declared to be `int`, but actually returned `zend_result` enum
values.  However the name of the function suggests it should be
`bool`, so returning something else is error prone.  The function
definition is difficult enough already because the name is negated...
2023-02-18 19:35:58 +00:00
Max Kellermann
413844d626
Zend/zend_types.h: deprecate zend_bool, zend_intptr_t, zend_uintptr_t (#10597)
These types are standard C99.

For compatibility with out-of-tree extensions, keep the typedefs
in main/php.h.
2023-02-18 19:31:28 +00:00
George Peter Banyard
64127b66c6 Concatenating two valid UTF-8 strings produces a valid UTF-8 string
The UTF-8 valid flag needs to be copied upon interning,
otherwise strings that are concatenated at compile time lose this information.

However, if previously this string was interned without the flag it is not added
E.g. in the case the string is an existing class name.

Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
2023-02-02 12:02:36 +00:00
Niels Dossche
dc6fbec037
Fix missing zend_shared_alloc_unlock() (#10405)
This code was refactored and the unlock was forgotten.
The following assertion is triggered in debug mode:
  zend_shared_alloc_lock: Assertion `!(accel_globals.locked)' failed.
And in release mode this likely deadlocks.
Fix this by re-adding the unlock.
2023-01-28 11:48:46 +01:00
George Peter Banyard
3fe8b090d3
Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix incorrect check in zend_internal_call_should_throw()
  Fix incorrect check in cs_8559_5 in map_from_unicode()
  Fix incorrect page_size check
2023-01-25 00:12:32 +00:00
George Peter Banyard
0d9bf101c4
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix incorrect check in cs_8559_5 in map_from_unicode()
  Fix incorrect page_size check
2023-01-25 00:10:56 +00:00