Commit graph

776 commits

Author SHA1 Message Date
Nikita Popov
62a9f97381 Move preload_autoload assignment into preload_load()
We need to set the preload autoloader even if preloading happened
in a different process. accel_preload() will only run in one.

In particular, this fixes the behavior if preload_user is used.
2021-05-19 12:55:46 +02:00
George Peter Banyard
c40231afbf
Mark various functions with void arguments.
This fixes a bunch of [-Wstrict-prototypes] warning,
because in C func() and func(void) have different semantics.
2021-05-12 14:55:53 +01:00
KsaR
01b3fc03c3
Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
Nikita Popov
dd86987b2c
Replay warnings during inheritance (#6928)
Since 3e6b447979 it is again possible to have
warnings (deprecations) during inheritance, and more such functionality is
likely in the future. This is a problem, because such warnings will only be
shown on the first request if the opcache inheritance cache is used. This
currently causes test failures in --repeat builds.

Fix this by uplifting the error recording functionality from opcache to Zend,
and then using it to persist a warning trace in the inheritance cache, which
can then be used to replay the warnings on subsequent executions.
2021-04-29 16:37:53 +02:00
Nikita Popov
e8e7c04a3a Use common struct to store error information
This is needed by both fibers and opcache (and GH-6903 also uses it),
so make it a common structure that can be used by any functionality
storing warnings/errors.
2021-04-29 11:50:54 +02:00
Nikita Popov
a1c6ee2164 Convert error filename to zend_string
Error handling functions/callbacks now accept the error filename
as a zend_string* instead of a const char*.
2021-04-23 11:05:14 +02:00
Nikita Popov
e0e19fd955 Fix file cache
We should only access xlat if this is called from persist, not
when it is called from file cache.
2021-04-09 16:52:18 +02:00
Nikita Popov
4ce5d2ea88 Add known strings for jit autoglobals
We always create interned strings for all autoglobals anyway, so
we might as well add known strings to make them more widely usable.
2021-04-09 15:37:59 +02:00
Nikita Popov
ce4afd50a9 Remove special handling of method named during preloading
Nowadays op_arrays always hold a ref to the function_name, even
if they are fully shared. As such, I don't believe that this code
is necessary anymore, and it interferes with the code that
releases function_names the appropriate number of times while
persisting.
2021-04-09 15:08:46 +02:00
Nikita Popov
46ee57e910 Don't leak accel key if interning fails 2021-04-09 14:24:07 +02:00
Nikita Popov
46a884bb67 Don't leak include_path if it cannot be interned 2021-04-09 13:05:27 +02:00
Dmitry Stogov
d8e4fbae62 Fast Class Cache
This is generalization of idea, that was previously usesd for caching
resolution of class_entries in zend_type. Now very similar mechanizm is
used for general zend_string into zend_class_entry resolution.

Interned zend_string with IS_STR_CLASS_NAME_MAP_PTR GC_FLAG uses its
refcount to adress corresponding zend_class_entry cache slot.
The refcount keeps an offset to this slot from CG(map_ptr_base).
Flag may be checked by ZSTR_HAS_CE_CACHE(str), cache slot may be read by
ZSTR_GET_CE_CACHE(str) and set by ZSTR_SET_CE_CACHE(str, ce).
2021-04-08 23:37:40 +03:00
Dmitry Stogov
22019a1edd Fixed unintended string duplication 2021-04-05 17:55:42 +03:00
Dmitry Stogov
a6dd92f820 Remove reference to $GLOBALS. We don't create an actual variable for $GLOBALS any more . 2021-03-31 12:28:23 +03:00
Dmitry Stogov
8c001d5ba3 We don't create an actual variable for $GLOBALS any more. 2021-03-30 15:12:10 +03:00
Dmitry Stogov
849ae12e7a Simplify auto-globals checks 2021-03-30 13:56:29 +03:00
Dmitry Stogov
8ed8cf86a9 Use zend_string* instead of char* 2021-03-22 14:56:16 +03:00
Dmitry Stogov
c732ab400a Change Zend Stream API to use zend_string* instead of char*.
This allows to eliminate re-calculation of string lenght and hash value.
See the detailed list of changes in UPGRADING.INTERNALS.
2021-03-16 20:31:36 +03:00
Dmitry Stogov
65859fe17e Inheritance cache optimization 2021-03-11 13:42:35 +03:00
Nikita Popov
5d160e309e Fix static variable behavior with inheritance
When a method is inherited, the static variables will now always
use the initial values, rather than the values at the time of
inheritance. As such, behavior no longer depends on whether
inheritance happens before or after a method has been called.

This is implemented by always keeping static_variables as the
original values, and static_variables_ptr as the modified copy.

Closes GH-6705.
2021-02-18 11:18:19 +01:00
Dmitry Stogov
6aea64c444 Reuse single map_ptr slot for indentical class names 2021-02-10 15:22:09 +03:00
Dmitry Stogov
4b79dba932 Added Inheritance Cache.
This is a new transparent technology that eliminates overhead of PHP class inheritance.

PHP  classes are compiled and cached (by opcahce) separately, however their "linking" was done at run-time - on each request. The process of "linking" may involve a number of compatibility checks and borrowing methods/properties/constants form parent and traits. This takes significant time, but the result is the same on each request.

Inheritance Cache performs "linking" for unique set of all the depending classes (parent, interfaces, traits, property types, method types involved into compatibility checks) once and stores result in opcache shared memory. As a part of the this patch, I removed limitations for immutable classes (unresolved constants, typed properties and covariant type checks). So now all classes stored in opcache are "immutable". They may be lazily loaded into process memory, if necessary, but this usually occurs just once (on first linking).

The patch shows 8% improvement on Symphony "Hello World" app.
2021-02-09 22:53:57 +03:00
Nikita Popov
ce79d9476c Merge branch 'PHP-8.0'
* PHP-8.0:
  Try SIGTERM before SIGKILL in opcache restart
2021-02-04 17:07:39 +01:00
Nikita Popov
0c6ff5eafa Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Try SIGTERM before SIGKILL in opcache restart
2021-02-04 17:07:30 +01:00
Nikita Popov
8b7aaad7d6 Try SIGTERM before SIGKILL in opcache restart
SIGTERM is subject to HANDLE_BLOCK_INTERRUPTIONS(), which will
allow code to exit critical sections before it gets terminated.

Closes GH-6493.
2021-02-04 17:07:18 +01:00
Nikita Popov
83be073abe Move optimizer into core
This only moves the files, adjusts the build system, exports APIs
and does minor fixups to make sure the code builds.

This does not yet try to make the optimizer usable independently
of opcache.

Closes GH-6642.
2021-01-28 10:38:25 +01:00
Nikita Popov
3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
Nikita Popov
f9942b061d Merge branch 'PHP-8.0'
* PHP-8.0:
  JIT disabled build fix.
2020-12-15 09:51:51 +01:00
David Carlier
1e6c7e776c JIT disabled build fix.
Closes GH-6514.
2020-12-15 09:51:16 +01:00
Dmitry Stogov
c3c7b673d1 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80506 (Immediate SIGSEGV upon ini_set("opcache.jit_debug", 1))
2020-12-14 15:28:27 +03:00
Dmitry Stogov
a12e7affd7 Fixed bug #80506 (Immediate SIGSEGV upon ini_set("opcache.jit_debug", 1)) 2020-12-14 15:26:11 +03:00
Dmitry Stogov
034270d69a Merge branch 'PHP-8.0'
* PHP-8.0:
  Disable JIT with incompatible third-party extensions
2020-11-30 13:59:33 +03:00
Dmitry Stogov
d5a82e2c4e Disable JIT with incompatible third-party extensions 2020-11-30 13:58:34 +03:00
Nikita Popov
6808968c89 Backport preloading trait fixup fixes
This cherry-picks 33969c2252 and
2effbfd871 from PHP-8.0.

The issues these commits fix could also manifest in PHP 7.4, and
a commenter on bug #80307 reports this this might indeed be
happening.
2020-11-05 16:35:08 +01:00
Nikita Popov
046143859d Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixup trait methods even if no traits are used
2020-11-05 13:16:31 +01:00
Nikita Popov
2effbfd871 Fixup trait methods even if no traits are used
Trait methods might be non-trivially inherited, in which case we
may have to perform fixup in classes that do not directly use any
traits.
2020-11-05 13:15:32 +01:00
Nikita Popov
1fea175765 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix multiple trait fixup
2020-11-05 12:11:20 +01:00
Nikita Popov
33969c2252 Fix multiple trait fixup
If a trait method is inherited, preloading trait fixup might be
performed on it multiple times. Usually this is fine, because
the opcodes pointer will have already been updated, and will thus
not be found in the xlat table.

However, it can happen that the new opcodes pointer is the same
as one of the old opcodes pointers, if the pointer has been reused
by the allocator. In this case we will look up the wrong op array
and overwrite the trait method with an unrelated trait method.

We fix this by indexing the xlat table not by the opcodes pointer,
but by the refcount pointer. The refcount pointer is not changed
during optimization, and accurately represents which op arrays
should use the same opcodes.

Fixes bug #80307. The test case does not reproduce the bug, because
this depends on a lot of "luck" with the allocator. The test case
merely illustrates a case where orig_op_array would have been NULL
in the original code.
2020-11-05 12:04:39 +01:00
Nikita Popov
313a56add0 Merge branch 'PHP-8.0'
* PHP-8.0:
  End output handlers in preload shutdown
2020-11-04 16:05:48 +01:00
Nikita Popov
7c7c6b0d73 End output handlers in preload shutdown
Same as in php_request_shutdown(), we need to end any active
output handlers, as these may no longer be safe to execute
lateron.
2020-11-04 16:05:24 +01:00
Nikita Popov
d0a07cd0fa Merge branch 'PHP-8.0'
* PHP-8.0:
  Report parse errors during preloading
2020-11-03 16:25:08 +01:00
Nikita Popov
b009573f4e Report parse errors during preloading 2020-11-03 16:24:54 +01:00
Nikita Popov
fa15f03241 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't ignore internal classes during preloading
2020-11-03 11:51:29 +01:00
Nikita Popov
51b5f7d67d Don't ignore internal classes during preloading
When preloading, it's fine to make use of internal class information,
as we do not support Windows. It is also necessary to allow proper
variance checks against internal classes.
2020-11-03 11:50:14 +01:00
Nikita Popov
ac5486b832 Merge branch 'PHP-8.0'
* PHP-8.0:
  Preserve trait method alias name during preloading
2020-11-03 10:57:01 +01:00
Nikita Popov
6f2431860b Preserve trait method alias name during preloading 2020-11-03 10:55:59 +01:00
Nikita Popov
e0054fc942 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug #79643: Invalid memory read when opcache.interned_strings_buffer is 0
2020-10-20 12:51:17 +02:00
Nikita Popov
cf04707938 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix bug #79643: Invalid memory read when opcache.interned_strings_buffer is 0
2020-10-20 12:51:08 +02:00
twosee
d134c0ac05 Fix bug #79643: Invalid memory read when opcache.interned_strings_buffer is 0 2020-10-20 12:50:28 +02:00
Nikita Popov
cfb272defc Add zend_accel_error_noreturn() helper
Avoid confusing the compiler when code relies on the fact that
LOG_FATAL/LOG_ERROR will bailout/abort.
2020-10-19 16:09:03 +02:00