summaryrefslogtreecommitdiff
path: root/Zend/zend_execute.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix #49555: Improve "function must be a string" error messageNikita Popov2020-01-081-2/+2
| | | | | Be more specific for the individual cases and provide relevant type information.
* Add warning and convert to exception in string offset assignment:George Peter Banyard2020-01-071-7/+11
| | | | | | | | Convert the empty string assignment to an Error as per RFC [1] Add a warning that only the first byte will be assigned to the offset if provided a needle that is longer than one byte. [1] https://wiki.php.net/rfc/engine_warnings
* Merge branch 'PHP-7.4'Nikita Popov2019-12-301-0/+2
|\ | | | | | | | | * PHP-7.4: Properly propagate url_stat exceptions during include
| * Properly propagate url_stat exceptions during includeNikita Popov2019-12-301-0/+2
| | | | | | | | | | Make sure we abort operations early, and that we don't emit additional warnings or errors if an exception has been thrown.
* | Merge branch 'PHP-7.4'Nikita Popov2019-12-191-1/+1
|\ \ | |/ | | | | | | * PHP-7.4: Avoid signed integer overflow in string offset check
| * Avoid signed integer overflow in string offset checkNikita Popov2019-12-191-1/+1
| | | | | | | | Cast to size_t before performing operations instead of afterwards.
* | Merge branch 'PHP-7.4'Nikita Popov2019-12-181-3/+0
|\ \ | |/ | | | | | | * PHP-7.4: Fix leak in assign_ref with function
| * Fix leak in assign_ref with functionNikita Popov2019-12-181-3/+0
| | | | | | | | | | As far as I can see, the retval copying is already done in all callers of this function, so it should not be duplicated here.
* | Merge branch 'PHP-7.4'Nikita Popov2019-12-181-1/+3
|\ \ | |/ | | | | | | * PHP-7.4: Fix const/cv freeing on failed reference assignment
| * Fix const/cv freeing on failed reference assignmentNikita Popov2019-12-181-1/+3
| |
* | Fix leak of dynamic property name in address helperNikita Popov2019-12-171-4/+9
| |
* | Merge branch 'PHP-7.4'Dmitry Stogov2019-12-091-0/+7
|\ \ | |/ | | | | | | * PHP-7.4: Export zend_init_func_run_time_cache()
| * Export zend_init_func_run_time_cache()Dmitry Stogov2019-12-091-0/+7
| |
* | Remove unused functionNikita Popov2019-12-061-9/+0
| |
* | Optimize return type checkingNikita Popov2019-12-061-15/+21
| | | | | | | | Split off the fast-path case and avoid redundant checks.
* | Implement union typesNikita Popov2019-11-081-219/+323
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-16/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Fix consistency issues with array accesses warnings/exceptionsMáté Kocsis2019-11-061-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | * Change a number of "resource used as offset" notices to warnings, which were previously missed. * Throw the "resource used as offset" warning for isset() as well. * Make array_key_exists() behavior with regard to different key types consistent with isset() and normal array accesses. All key types now use the usual coercions and array/object keys throw TypeError. Closes GH-4887.
* | Remove support for array_key_exists() with objectsNikita Popov2019-11-041-23/+15
| |
* | Check type is set when verifying variadic argsNikita Popov2019-10-251-1/+2
| | | | | | | | | | | | | | Weird that there was no test for this... This code is somewhat inefficient, because it will be performed for every arg, rather than only once.
* | Remove unnecessary type checks in verify_missing_return_typeNikita Popov2019-10-241-13/+9
| | | | | | | | | | We don't emit VERIFY_RETURN_TYPE for void functions, so there's no need to check it here. It's always an error.
* | Don't check ZEND_TYPE_IS_SET() in zend_check_type()Nikita Popov2019-10-241-7/+6
| | | | | | | | | | Usually this function is only used if we already know that there is a type. Add checks to the places where we don't.
* | Merge branch 'PHP-7.4'Nikita Popov2019-10-231-1/+1
|\ \ | |/ | | | | | | * PHP-7.4: Don't autoload when checking property types
| * Don't autoload when checking property typesNikita Popov2019-10-231-1/+1
| | | | | | | | | | | | | | | | | | Noticed while working on union types: We do not load argument and return types during type checks, but we do load property types. I'm normalizing the behavior towards the existing status quo (not loading), though we may consider loading everywhere (all types, and instanceof) in order to properly support class aliases.
* | JIT: Handle typed refs in assign dimNikita Popov2019-10-231-5/+2
| |
* | Pass cache slot when printing type errorsNikita Popov2019-10-171-38/+29
| | | | | | | | Instead of using a separate ce.
* | Merge branch 'PHP-7.4'Nikita Popov2019-10-101-4/+7
|\ \ | |/
| * Return error_zval form get_property_ptr_ptr on exceptionNikita Popov2019-10-101-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | This goes in the reverse direction of 4463acb9513dfb62206760c49b3da1fe4d92f40a. After looking around a bit, it seems that we already check for Z_ISERROR_P() on the get_property_ptr_ptr return value in other places. So do this in zend_fetch_property_address() as well, and also make sure that EG(error_zval) is indeed returned on exception in get_property_ptr_ptr. In particular, this fixes the duplicate exceptions that we used to get because first get_property_ptr_ptr threw one and then read_property throws the same exception again.
* | Merge branch 'PHP-7.4'Nikita Popov2019-10-101-5/+4
|\ \ | |/
| * Explicitly check for exceptions in by-ref obj prop assignNikita Popov2019-10-101-1/+1
| | | | | | | | | | | | | | | | Relying on setting ERROR if an exception happened during the property address fetch is both a bit fragile and may pessimize other codepaths that will check for exceptions in the VM. Adding an extra exception check instead, which should also allow us to drop the use of ERROR in this area in master.
* | Merge branch 'PHP-7.4'Nikita Popov2019-10-101-0/+1
|\ \ | |/
| * Fix leak on "Cannot assign by reference to overloaded object" errorNikita Popov2019-10-101-0/+1
| |
* | SAMRT BRANCH improvement.Dmitry Stogov2019-10-091-6/+6
| | | | | | | | | | Avoid need of insertion NOP opcoes between unrelated SMART BRANCH instruction and following JMPZ/JMPNZ. Now instead of checking the opcode of following instruction, the same information is encoded into SMART BRANH result_type.
* | Merge branch 'PHP-7.4'Nikita Popov2019-10-081-0/+6
|\ \ | |/
| * Handle "non well formed" exception during ZPPNikita Popov2019-10-081-0/+6
| | | | | | | | | | | | | | | | | | | | Previously if the "non well formed" notice was converted into an exception we'd still end up executing the function. Also drop the now unnecessary EG(exception) checks in the engine. Additionally remote a bogus exception in zend_is_callable: It should only be writing to error, but not directly throwing.
* | Fixed Zend/tests/bug70785.phpt on builds wothout global regestersDmitry Stogov2019-10-081-4/+3
| |
* | Encapsulate all SMART BRANCH related logic inside macros. Result of SMART ↵Dmitry Stogov2019-10-081-33/+35
| | | | | | | | BRANCH may be uninitialized (on exception).
* | Merge branch 'PHP-7.4'Nikita Popov2019-10-081-0/+1
|\ \ | |/
| * Fixed bug #78644Nikita Popov2019-10-081-0/+1
| | | | | | | | | | | | Make sure the initialize the result of FETCH_OBJ_UNSET operations. I'm using a NULL value rather than ERROR here, because the latter no longer exists in master.
* | Check num required args is correct in debug buildsNikita Popov2019-10-071-0/+27
| | | | | | | | | | Also replace the assertion failure with an E_CORE_ERROR that includes the function name, so these are easier to debug.
* | Convert some notices to warningsNikita Popov2019-10-021-8/+8
| | | | | | | | Part of https://wiki.php.net/rfc/engine_warnings.
* | Remove most uses of the ERROR typeNikita Popov2019-09-301-35/+30
| | | | | | | | | | | | | | | | | | It is now only used to signal exceptions for property reads. ERROR zvals are never returned back to the VM anymore, so there's no need to check for them when receiving a VAR. Also return MAY_BE_ERROR, as ERROR is now no longer relevant for inference.
* | Promote write "use scalar as array" warning to ErrorNikita Popov2019-09-271-2/+2
| |
* | Convert "Illegal offset type" warnings to exceptionsNikita Popov2019-09-271-2/+2
| |
* | Convert "cannot add element" warning to exceptionNikita Popov2019-09-271-1/+1
| |
* | Throw Error when writing property of non-objectNikita Popov2019-09-271-112/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This removes object auto-vivification support. This also means that we can remove the corresponding special handling for typed properites: We no longer need to check that a property is convertible to stdClass if such a conversion might take place indirectly due to a nested property write. Additionally OBJ_W style operations now no longer modify the object operand, and as such we no longer need to treat op1 as a def in SSA form. The next step would be to actually compile the whole LHS of OBJ_W operations in R rather than W mode, but that causes issues with SimpleXML, whose object handlers depend on the current compilation structure. Part of https://wiki.php.net/rfc/engine_warnings.
* | Add check_only parameter to get_closure handlerChristoph M. Becker2019-09-241-1/+1
| | | | | | | | | | | | | | | | | | | | `get_closure` handlers are called to check whether an object is callable, and to actually get the closure, respectively. The behavior of the handler might differ for these two cases, particularly the handler may throw in the latter case, but should not in the former. Therefore we add a `check_only` parameter, to be able to distinguish the desired purpose.
* | Use ZEND_TYPE_IS_SET() when checking for property typesNikita Popov2019-09-231-4/+5
| | | | | | | | | | Instead of a simple if or 0 comparison. This would no longer work if zend_type is a struct.
* | Canonicalize typed properties error messageNikita Popov2019-09-231-17/+6
| | | | | | | | | | | | | | | | | | We have lots of other typed properties related error messages of the form "assign X to typed property Y::$z of type A", so use th same format for the primary message as well. Special-casing things like classes and nullability is not going to scale with future type-system extensions, and I don't think it really adds clarity either.
* | Change representation of zend_type from type code to MAY_BE_* maskNikita Popov2019-09-231-170/+150
| | | | | | | | | | | | | | | | | | | | | | | | | | This switches zend_type from storing a single IS_* type code to storing a MAY_BE_* type mask. Right now most code still assumes that there is only a single type in the mask (or two together with MAY_BE_NULL). But this will make it a lot simpler to introduce union types. An additional advantage (and why I'm doing this separately), is that a number of special cases no longer need to be handled separately: We can do a single mask & (1 << type) check to handle all simple types, booleans (true|false) and null.