summaryrefslogtreecommitdiff
path: root/Zend/zend_vm_def.h
Commit message (Collapse)AuthorAgeFilesLines
* Don't imply SILENT from NO_AUTOLOADNikita Popov2021-03-181-2/+2
| | | | | | We have separate flags for non-autoloading class fetches and silent class fetches. There's no reason why NO_AUTOLOAD should be special-cased to be implicitly silent.
* Add sanity check for type of read_property return valueNikita Popov2021-03-161-0/+5
| | | | | | If an internal class overrides read_property and declared property types, make sure that the returned value matches the declared type (in debug builds).
* Inline "array" part of FE_FETCH_R handler into HYBRID VMDmitry Stogov2021-03-111-91/+121
|
* zend_verify_recv_arg_type_helper is not "cold".Dmitry Stogov2021-03-111-1/+1
|
* Optimized object conversion to array without rebulding properties HashTableDmitry Stogov2021-03-011-0/+5
|
* Reference dynamic functions through dynamic_defsNikita Popov2021-03-011-13/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fix static variable behavior with inheritanceNikita Popov2021-02-181-7/+1
| | | | | | | | | | | | 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.
* Fix unused variable warningNikita Popov2021-02-161-2/+2
|
* Microoptimization of STRLEN and IN_ARRAY opcodes (based on ↵Dmitry Stogov2021-02-161-10/+48
| | | | https://github.com/php/php-src/pull/4981)
* Optimize Traversable unpacking in zend_vm_def.hTyson Andre2021-02-131-24/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The C compiler sees that a dynamic function is being called, so it cannot infer that iter->funcs has not changed. This results in more assembly instructions and slightly more time to execute that code path. Unpacking traversables to arrays(`ZEND_ADD_ARRAY_UNPACK`), starting foreach loops (`ZEND_FE_FETCH*`), etc. are affected. ``` <?php /* * Before: 1.576 seconds * After: 1.474 seconds */ function example() { $start = hrtime(true); $it = new SplFixedArray(1000); $total = 0; for ($i = 0; $i < 100000; $i++) { $total += count([...$it]); } $end = hrtime(true); printf("Elapsed: %.6f\n", ($end - $start) / 1_000_000_000); } example(); ```
* Deprecate passing null to non-nullable arg of internal functionNikita Popov2021-02-111-1/+11
| | | | | | | | | | | | | | | | | | | | | This deprecates passing null to non-nullable scale arguments of internal functions, with the eventual goal of making the behavior consistent with userland functions, where null is never accepted for non-nullable arguments. This change is expected to cause quite a lot of fallout. In most cases, calling code should be adjusted to avoid passing null. In some cases, PHP should be adjusted to make some function arguments nullable. I have already fixed a number of functions before landing this, but feel free to file a bug if you encounter a function that doesn't accept null, but probably should. (The rule of thumb for this to be applicable is that the function must have special behavior for 0 or "", which is distinct from the natural behavior of the parameter.) RFC: https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg Closes GH-6475.
* Use zend_type.ce_cache__ptr for caching class resulution during ↵Dmitry Stogov2021-02-101-1/+1
| | | | argument/result type checks
* Added Inheritance Cache.Dmitry Stogov2021-02-091-3/+5
| | | | | | | | | | 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 support for string keys in array unpackingNikita Popov2021-02-091-16/+26
| | | | | | | | | | | | | This adds support for: $array1 = ['a' => 1, 'b' => 2]; $array2 = ['b' => 3, 'c' => 4]; $array = [...$array1, ...$array2]; // => ['a' => 1, 'b' => 3, 'c' => 4] RFC: https://wiki.php.net/rfc/array_unpacking_string_keys Closes GH-6584.
* Merge branch 'PHP-8.0'Dmitry Stogov2021-01-261-1/+1
|\ | | | | | | | | * PHP-8.0: Allow observer handlers disabling optimization in RETURN opcode handler, that may cause loss value of returned local variable.
| * Allow observer handlers disabling optimization in RETURN opcode handler, ↵Dmitry Stogov2021-01-261-1/+1
| | | | | | | | that may cause loss value of returned local variable.
* | Merge branch 'PHP-8.0'Nikita Popov2021-01-261-1/+1
|\ \ | |/ | | | | | | * PHP-8.0: Fix VAR return type verification
| * Fix VAR return type verificationNikita Popov2021-01-261-1/+1
| | | | | | | | | | | | | | | | | | | | We should also set retval_ref when de-indirecting. Otherwise the retval_ref != retval_ptr comparison below may incorrect assume that we're returning a reference. I don't have a reliable reproducer for this issue, but it sometimes appears in certain configurations in arrow_functions/007.phpt in conjunction with other changes.
* | Add missing resource key warning for unset()Nikita Popov2021-01-261-0/+1
| | | | | | | | | | It was present on other operations, including isset(), but was missing for unset().
* | Replace zend_bool uses with boolNikita Popov2021-01-151-19/+19
| | | | | | | | | | | | | | 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.
* | PHP array cannot refer to EG(symbol_table) any more. Replace corresponding ↵Dmitry Stogov2021-01-111-5/+2
| | | | | | | | checks by ZEND_ASSERT().
* | Remove some INDIRECT handling in VMNikita Popov2021-01-061-29/+8
| |
* | Restrict allowed usages of $GLOBALSNikita Popov2021-01-061-4/+16
|/ | | | | | | | | This restricts allowed usage of $GLOBALS, with the effect that plain PHP arrays can no longer contain INDIRECT elements. RFC: https://wiki.php.net/rfc/restrict_globals_usage Closes GH-6487.
* Provide unused retvals to observersSammy Kaye Powers2020-11-171-9/+17
| | | | | | | Make sure that the return value is available to observers, even if it is not used by the caller. Closes GH-6422.
* [Observer] Save opline before calling begin/end handlersDmitry Stogov2020-11-111-4/+11
|
* Fix handling of throwing undef var in verify returnNikita Popov2020-10-131-1/+4
| | | | | | | | | | If we have an undefined variable and null is not accepted by the return type, we want to throw just the undef var error. In this case this lead to an infinite loop, because we overwrite the exception opline in SAVE_OPLINE and it does not get reset when chaining into a previous exception. Add an assertiong to catch this case earlier.
* Merge branch 'PHP-7.4' into PHP-8.0Nikita Popov2020-10-121-5/+8
|\ | | | | | | | | * PHP-7.4: Avoid non-object in FE_FREE
| * Avoid non-object in FE_FREENikita Popov2020-10-121-5/+8
| | | | | | | | | | | | Even if the properties HT is empty, make sure we still leave an object in the FE_RESET result, so our type inference results stay correct.
* | Merge branch 'PHP-7.4' into PHP-8.0Nikita Popov2020-10-091-10/+20
|\ \ | |/ | | | | | | * PHP-7.4: Fixed bug #80186
| * Fixed bug #80186Nikita Popov2020-10-091-7/+21
| | | | | | | | | | Early exit in FE_RESET if get_properties() returns empty array, as we cannot add HT iterators to zend_empty_array.
* | Fixed incorrect behavior of observer API.Dmitry Stogov2020-10-071-2/+4
| | | | | | | | ZEND_HANDLE_EXCEPTION might call zend_observer_fcall_end() even if exception is cought by function. The fix moved zend_observer_fcall_end() into a right place and remove OBSERVER sepecialization for ZEND_HANDLE_EXCEPTION handler.
* | Promote count() warning to TypeErrorGeorge Peter Banyard2020-09-211-10/+6
| | | | | | | | Closes GH-6180
* | Synchronize GET_CLASS/GET_CALLED_CLASS opcodes with functionsNikita Popov2020-09-211-9/+8
| | | | | | | | | | These error conditions throw in the function implementations, make the opcodes match.
* | Cleanup observer API and add JIT supportDmitry Stogov2020-09-181-11/+11
| |
* | Remove specialization of SPEC(OBSERVER) handlersSammy Kaye Powers2020-09-181-0/+6
| |
* | Fix OSS Fuzz issue: yielding from an aborted generatorBob Weinand2020-09-151-6/+6
| |
* | Fix undef var exception handling in JMP_NULLNikita Popov2020-09-151-2/+1
| | | | | | | | | | | | | | We need to initialize the result variable in the exceptional case as well. Fixes oss-fuzz #25526.
* | Improve error messages mentioning parameters instead of argumentsMáté Kocsis2020-09-091-2/+3
| | | | | | | | Closes GH-5999
* | micro-optimizationDmitry Stogov2020-09-081-5/+3
| |
* | Merge branch 'PHP-7.4'Nikita Popov2020-09-031-0/+1
|\ \ | |/ | | | | | | * PHP-7.4: Fixed bug #80049
| * Merge branch 'PHP-7.3' into PHP-7.4Nikita Popov2020-09-031-0/+1
| |\ | | | | | | | | | | | | * PHP-7.3: Fixed bug #80049
| | * Fixed bug #80049Nikita Popov2020-09-031-0/+1
| | | | | | | | | | | | | | | Type checking may convert to refcounted values, so force freeing of extra args.
* | | Micro-optimizationDmitry Stogov2020-09-021-12/+10
| | |
* | | Add zend_observer APILevi Morrison2020-09-011-10/+23
| | | | | | | | | | | | | | | | | | | | | Closes GH-5857. Co-authored-by: Nikita Popov <nikita.ppv@gmail.com> Co-authored-by: Sammy Powers <sammyk@datadoghq.com>
* | | Fix FE_FETCH_R_SIMPLE specializationNikita Popov2020-09-011-1/+1
| | | | | | | | | | | | | | | | | | After a99d08b5d135fffa1d83b08b056e0080d295d863 the type can include UNDEF. However, UNDEF can only reach FE_FREE, not FE_FETCH. As such, simply ignore this type.
* | | Fix unused variable warningNikita Popov2020-08-281-2/+1
| | |
* | | Remove unnecessary cache_slot argumentsNikita Popov2020-08-281-2/+2
| | | | | | | | | | | | | | | zend_verify_type_error_common() no longer needs the cache_slot, so drop it there and from all users.
* | | Improve type declarations for Zend APIsGeorge Peter Banyard2020-08-281-21/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | Voidification of Zend API which always succeeded Use bool argument types instead of int for boolean arguments Use bool return type for functions which return true/false (1/0) Use zend_result return type for functions which return SUCCESS/FAILURE as they don't follow normal boolean semantics Closes GH-6002
* | | Fix pass by ref error for named paramsNikita Popov2020-08-261-9/+6
| | |
* | | Fix memory leak on unknown named param in iterator unpackNikita Popov2020-08-261-0/+1
| | |