summaryrefslogtreecommitdiff
path: root/ext/opcache/zend_file_cache.c
Commit message (Collapse)AuthorAgeFilesLines
* Use zend_string* instead of char*Dmitry Stogov2021-03-221-1/+1
|
* Implement enumsIlija Tovilo2021-03-171-9/+23
| | | | | | | | RFC: https://wiki.php.net/rfc/enumerations Co-authored-by: Nikita Popov <nikita.ppv@gmail.com> Closes GH-6489.
* Avoid unnecessary static_variables persistenceNikita Popov2021-03-171-18/+20
| | | | | | | static_variables should be treated the same way as all other op_array components nowadays (only static_variables_ptr is special). There's no need to persist/serialize it is separately per shared op_array.
* Reference dynamic functions through dynamic_defsNikita Popov2021-03-011-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, dynamically declared functions and closures are inserted into the function table under a runtime definition key, and then later possibly renamed. When opcache is not used and a file containing a closure is repeatedly included, this leads to a very large memory leak, as the no longer needed closure declarations will never be freed (https://bugs.php.net/bug.php?id=76982). With this patch, dynamic functions are instead stored in a dynamic_func_defs member on the op_array, which opcodes reference by index. When the parent op_array is destroyed, the dynamic_func_defs it contains are also destroyed (unless they are stilled used elsewhere, e.g. because they have been bound, or are used by a live closure). This resolves the fundamental part of the leak, though doesn't completely fix it yet due to some arena allocations. The main non-obvious change here is to static variable handling: We can't destroy static_variables_ptr in destroy_op_array, as e.g. that would clear the static variables in a dynamic function when the op_array containing it is destroyed. Static variable destruction is separated out for this reason (we already do static variable destruction separately for normal functions, so we only need to handle main scripts). Closes GH-5595.
* Allow pointer to end of memory in IS_UNSERIALIZED()Nikita Popov2021-02-241-2/+4
| | | | | | We already use <= for IS_SERIALIZED(), but the same general problem can also occur for IS_UNSERIALIZED(). We don't seem to hit this in practice prior to GH-5595 though.
* Fix static variable behavior with inheritanceNikita Popov2021-02-181-2/+6
| | | | | | | | | | | | 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.
* Unserialize op_array->scope before passing to ↵Dmitry Stogov2021-02-101-2/+3
| | | | | | zend_file_cache_unserialize_type(). Don't use scope of closures.
* Reuse single map_ptr slot for indentical class namesDmitry Stogov2021-02-101-7/+12
|
* Added Inheritance Cache.Dmitry Stogov2021-02-091-33/+44
| | | | | | | | | | 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.
* Add system ID entropy APISammy Kaye Powers2020-09-181-4/+5
| | | | | | The `zend_system_id` is a (true global) system ID that fingerprints a process state. When extensions add engine hooks during MINIT/startup, entropy is added the system ID for each hook. This allows extensions to identify that changes have been made to the engine since the last PHP process restart. Closes GH-5871
* Merge branch 'PHP-7.4'Nikita Popov2020-08-111-34/+46
|\ | | | | | | | | * PHP-7.4: Fixed bug #79917
| * Fixed bug #79917Nikita Popov2020-08-111-34/+46
| | | | | | | | | | | | | | | | | | op_arrays can be shared on two levels: Either the op_array is completely shared, or it is distinct but shares all members (apart from static_variables). The the op_array is distinct, we need to make sure to properly initialize the MAP_PTR structures.
* | Merge branch 'PHP-7.4'Nikita Popov2020-08-051-1/+1
|\ \ | |/ | | | | | | | | | | * PHP-7.4: Fixed bug #79930 Fix iov_base pointer type for illumos Backport bless_tests.php changes from PHP 8
| * Merge branch 'PHP-7.3' into PHP-7.4Nikita Popov2020-08-051-1/+1
| |\ | | | | | | | | | | | | * PHP-7.3: Fix iov_base pointer type for illumos
| | * Fix iov_base pointer type for illumosDavid Carlier2020-08-051-1/+1
| | | | | | | | | | | | | | | | | | | | | These systems has two versions of the iovec interface dependent on compiler flags passed, the legacy version causing little build issue. Closes GH-5939.
* | | Implement named parametersNikita Popov2020-07-311-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From an engine perspective, named parameters mainly add three concepts: * The SEND_* opcodes now accept a CONST op2, which is the argument name. For now, it is looked up by linear scan and runtime cached. * This may leave UNDEF arguments on the stack. To avoid having to deal with them in other places, a CHECK_UNDEF_ARGS opcode is used to either replace them with defaults, or error. * For variadic functions, EX(extra_named_params) are collected and need to be freed based on ZEND_CALL_HAS_EXTRA_NAMED_PARAMS. RFC: https://wiki.php.net/rfc/named_params Closes GH-5357.
* | | Implement nullsafe ?-> operatorIlija Tovilo2020-07-241-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | RFC: https://wiki.php.net/rfc/nullsafe_operator Closes GH-5619. Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
* | | Implement match expressionIlija Tovilo2020-07-091-0/+1
| | | | | | | | | | | | | | | | | | RFC: https://wiki.php.net/rfc/match_expression_v2 Closes GH-5371.
* | | Cache __unserialize() instead of unserialize()Nikita Popov2020-06-261-4/+4
| | | | | | | | | | | | | | | We should use these cache slots for the new object serialization mechanism rather than the old one.
* | | Change GC_COLLECTABLE flag into GC_NOT_COLLECTABLE to simplify GC_MAY_LEAK() ↵Dmitry Stogov2020-06-151-1/+1
| | | | | | | | | | | | check
* | | Add AttributesBenjamin Eberlei2020-06-041-0/+67
| | | | | | | | | | | | Co-authored-by: Martin Schröder <m.schroeder2007@gmail.com>
* | | Add support for replaying warnings in opcacheNikita Popov2020-05-201-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | If opcache.record_warnings is enabled, opcache will record compilation warnings and replay them when the file is included again. The primary use case I have in mind for this is automated testing of the opcache file cache. This resolves bug #76535.
* | | Merge branch 'PHP-7.4'Nikita Popov2020-05-201-18/+15
|\ \ \ | |/ / | | | | | | | | | | | | * PHP-7.4: Fix static property indirections in file cache Don't require rc=1 for function static variables
| * | Fix static property indirections in file cacheNikita Popov2020-05-201-18/+15
| | | | | | | | | | | | | | | | | | If the class is already linked, we need to serialize and unserialize INDIRECTed static properties. Normally these would be set up when copying from cache.
| * | Fixed bug #79055Nikita Popov2020-01-021-37/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | Fix file cache serialization of property types. I'm changing the overall type serialization format to perform additional adjustments in order to yield a plausible pointer for zend_type, rather than using an entirely separate serialization format, as was previously done. That would have been annoying to extend to the case of CE pointers.
| * | Extract functions for file cache type serializationNikita Popov2020-01-021-17/+29
| | | | | | | | | | | | This is already done in master.
* | | JIT refactoring to allow run-time changes of JIT options (triggers, ↵Dmitry Stogov2020-05-181-1/+5
| | | | | | | | | | | | optimization_level, debug flags, etc)
* | | Use zend_type inside type listsNikita Popov2020-01-171-22/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of having a completely independent encoding for type list entries. This is going to use more memory, but I'm not particularly concerned about that, as type unions that contain multiple classes should be uncommon. On the other hand, this allows us to treat top-level types and types inside lists mostly the same. A new ZEND_TYPE_FOREACH macros allows to transparently treat list and non-list types the same way. I'm not using it everywhere it could be used for now, just the places that seemed most obvious. Of course, this will make any future type system changes much simpler, as it will not be necessary to duplicate all logic two times.
* | | Merge branch 'PHP-7.4'Nikita Popov2020-01-021-1/+9
|\ \ \ | |/ / | | | | | | | | | | | | * PHP-7.4: Fix file cache run_time_cache unserialization Update ZCSG(map_ptr_last) only if for_shm
| * | Fix file cache run_time_cache unserializationNikita Popov2020-01-021-1/+9
| | | | | | | | | | | | | | | | | | If the script was serialized as file_cache_only (thus non-immutable) and then gets unserialized into SHM, we need to allocate a new run_time_cache slot and can't use the serialized arena pointer.
* | | Implement union typesNikita Popov2019-11-081-28/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to RFC: https://wiki.php.net/rfc/union_types_v2 The type representation now makes use of both the pointer payload and the type mask at the same time. Additionall, zend_type_list is introduced as a new kind of pointer payload, which is used to store multiple class types. Each of the class types is a tagged pointer, which may be either a class name or class entry. The latter is only used for typed properties, while arguments/returns will instead use cache slots. A type list can contain a mix of both names and CEs at the same time, as not all classes may be resolvable. One thing this is missing is support for union types in arginfo and stubs, which I want to handle separately. I've also dropped the special object code from the JIT implementation for now -- I plan to add this back in a different form at a later time. For now I did not want to include non-trivial JIT changes together with large functional changes. Another possible piece of follow-up work is to implement "iterable" as an internal alias for "array|Traversable". I believe this will eliminate quite a few special-cases that had to be implemented. Closes GH-4838.
* | | Make zend_type a 2-field structNikita Popov2019-11-081-31/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We now store the pointer payload and the type mask separately. This is in preparation for union types, where we will be using both at the same time. To avoid increasing the size of arginfo structures, the pass_by_reference and is_variadic fields are now stored as part of the type_mask (8-bit are reserved for custom use). Different types of pointer payloads are distinguished based on bits in the type_mask.
* | | Merge branch 'PHP-7.4'Joe Watkins2019-10-141-3/+6
|\ \ \ | |/ / | | | | | | | | | * PHP-7.4: Fix checksum calculation for opcache
| * | Merge branch 'PHP-7.3' into PHP-7.4Joe Watkins2019-10-141-3/+6
| |\ \ | | |/ | | | | | | | | | * PHP-7.3: Fix checksum calculation for opcache
| | * Merge branch 'PHP-7.2' into PHP-7.3Joe Watkins2019-10-141-3/+6
| | |\ | | | | | | | | | | | | | | | | * PHP-7.2: Fix checksum calculation for opcache
| | | * Fix checksum calculation for opcacheMitch Hagstrand2019-10-141-3/+6
| | | |
* | | | Merge branch 'PHP-7.4'Dmitry Stogov2019-07-191-2/+0
|\ \ \ \ | |/ / / | | | | | | | | | | | | * PHP-7.4: ZEND_DECLARE_ANON_CLASS doesn't need to skip anything now. It's immediatelly followed by ZEND_NEW.
| * | | ZEND_DECLARE_ANON_CLASS doesn't need to skip anything now. It's immediatelly ↵Dmitry Stogov2019-07-191-2/+0
| | | | | | | | | | | | | | | | followed by ZEND_NEW.
* | | | Merge branch 'PHP-7.4'Christoph M. Becker2019-07-171-20/+1
|\ \ \ \ | |/ / / | | | | | | | | | | | | * PHP-7.4: Allow multiple cache instances per user/host on Windows
| * | | Allow multiple cache instances per user/host on WindowsChristoph M. Becker2019-07-171-20/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Formerly, there was at most a single OPcache instance per user and the so called system ID (which is determined from the PHP version). Sometimes multiple OPcaches might be desired, though, particularly for unrelated CLI scripts, which may even be necessary (e.g. for our test suite in parallel mode). We therefore introduce a new INI directive `opcache.cache_id` which allows to configure independent OPcache instances for the same user. We also use `GetUserNameW()` instead of `php_win32_get_username()`, because the latter retrieves the user name encoded in the `default_charset`, which can obviously yield different results for different charsets, leading to OPcache "incompatibilities". Slightly worse, some characters may not even be encodeable in the `default_charset` and would be replaced by question marks, which could result in different users sharing the same OPcache. We also refactor, and re-use existing APIs to avoid duplicated code.
* | | | Merge branch 'PHP-7.4'Nikita Popov2019-07-011-0/+12
|\ \ \ \ | |/ / /
| * | | Msan: Unpoison buffer written by file cacheNikita Popov2019-07-011-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | It would be great if this were fully initialized, but it's not really a problem either (as long as we don't care about reproducible file cache), so ignore this for now.
* | | | Additional fix for bug #78185 (File cache no longer works)Dmitry Stogov2019-06-211-1/+1
| | | |
* | | | Merge branch 'PHP-7.4'Christoph M. Becker2019-06-201-1/+1
|\ \ \ \ | |/ / / | | | | | | | | | | | | * PHP-7.4: Fix #78189: file cache strips last character of uname hash
| * | | Merge branch 'PHP-7.3' into PHP-7.4Christoph M. Becker2019-06-201-1/+1
| |\ \ \ | | |/ / | | | | | | | | | | | | * PHP-7.3: Fix #78189: file cache strips last character of uname hash
| | * | Merge branch 'PHP-7.2' into PHP-7.3Christoph M. Becker2019-06-201-1/+1
| | |\ \ | | | |/ | | | | | | | | | | | | * PHP-7.2: Fix #78189: file cache strips last character of uname hash
| | | * Fix #78189: file cache strips last character of uname hashChristoph M. Becker2019-06-201-1/+1
| | | | | | | | | | | | | | | | | | | | We must not forget to increase `len` by one to cater to the directory separator.
| | | * Fix potential OPcache file cache related issuesAnatol Belski2019-04-111-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To solve issues detected during testing, we backport the following commits to PHP 7.2: 129c5c1181bf344b37e13fd6dc5dfe76c13d7208 9ac133a0b3863ca4d9659140154ee237e5f4669a ce72bc6b658c335dd37393d0beb28584e6805e97
* | | | Merge branch 'PHP-7.4'Joe Watkins2019-06-181-4/+4
|\ \ \ \ | |/ / / | | | | | | | | | | | | * PHP-7.4: Turn system_id into a true global
| * | | Turn system_id into a true globalChristoph M. Becker2019-06-181-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | The system_id is identical for all threads and can be computed during module startup, so there is no need to calculate and store it for each thread.