summaryrefslogtreecommitdiff
path: root/Zend/zend_generators.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix bug #69740Nikita Popov2015-06-111-0/+3
|
* Merge branch 'PHP-5.5' into PHP-5.6Nikita Popov2015-03-131-4/+4
|\
| * Fixed bug #69221Nikita Popov2015-03-131-4/+4
| | | | | | | | | | A generator iterator can be created from different zvals - use the object handle to manage references instead.
| * Bump yearXinchen Hui2015-01-151-1/+1
| |
* | bump yearXinchen Hui2015-01-151-1/+1
| |
* | Merge branch 'PHP-5.5' into PHP-5.6Nikita Popov2014-07-021-0/+1
|\ \ | |/
| * Fix bug #67497: eval with parse error causes segfault in generatorNikita Popov2014-07-021-0/+1
| |
| * Bump yearXinchen Hui2014-01-031-1/+1
| |
* | Bump yearXinchen Hui2014-01-031-1/+1
| |
* | Merge branch 'PHP-5.5' into PHP-5.6Nikita Popov2013-12-011-0/+2
|\ \ | |/
| * Fix bug #65764Nikita Popov2013-12-011-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I'm not exactly sure whether this is the right way to fix it. The question is whether Generator::throw() on a newborn generator (i.e. a generator that is not yet at yield expression) should first advance to the first yield and throw the exception there or whether it should instead throw the exception in the caller's context. The old behavior was to throw it at the start of the function (i.e. the very first opcode), which causes issues like the one in #65764. Effectively it's impossible to properly handle the exceptions in this case. For now I choose the variant where the generator advances to the first yield before throwing, as that's consistent with how all other methods on the Generator object currently behave. This does not necessarily match the behavior in other languages, e.g. Python would throw the exception in the caller's context. But then our send() method already has this kind of deviation, so it stays internally consistent at least.
* | Merge branch 'PHP-5.5' into PHP-5.6Nikita Popov2013-11-301-65/+79
|\ \ | |/
| * Cleanup generator closing code a bitNikita Popov2013-11-301-68/+73
| | | | | | | | | | | | | | | | | | | | All code dealing with unfinished execution cleanup is now in a separate function (previously most of it was run even when execution was properly finished. Furthermore some code dealing with unclean shutdowns has been removed, which is no longer necessary, because we no longer try to clean up in this case.
| * Fixed bug #66041: list() fails to unpack yielded ArrayAccess objectNikita Popov2013-11-301-2/+11
| | | | | | | | | | | | Yield return values now use IS_VAR rather than IS_TMP_VAR. This fixes the issue with list() and should also be faster as it avoids doing a zval copy.
* | Merge branch 'PHP-5.5'Nikita Popov2013-09-291-1/+27
|\ \ | |/
| * Fix bug #64979: Wrong behavior of static variables in closure generatorsNikita Popov2013-09-291-1/+27
| |
| * typos (orig)Veres Lajos2013-07-151-1/+1
| |
* | Save a TSRMLS_FETCH() for zval_ptr_dtor in executorNikita Popov2013-09-141-1/+1
| | | | | | | | This gives me about 9% improvement on Zend/bench.php for a zts build.
* | Make use of direct returns in some placesNikita Popov2013-08-311-4/+4
| |
* | typos (orig)Veres Lajos2013-07-151-1/+1
|/
* Don't try to clean up generator stack on unclean shutdownNikita Popov2013-06-291-0/+6
| | | | | | | | | | | This fixes bugs #65035 and #65161. In one of the bugs the issue is that function_state.arguments is NULL, but the arg count is pushed to the stack and the code tries to free it. In the other bug the stack of the generator is freed twice, once in generator_close and later during shutdown. It's rather hard (if at all possible) to do a proper stack cleanup on an unclean shutdown, so I'm just disabling it in this case.
* Remove support for cloning generatorsNikita Popov2013-03-291-170/+1
|
* Add support for non-scalar Iterator keys in foreachNikita Popov2013-03-121-19/+5
| | | | RFC: https://wiki.php.net/rfc/foreach-non-scalar-keys
* Fix bug #63830: Segfault on undefined function call in nested generatorNikita Popov2013-02-011-4/+10
| | | | | | | | This also reverses the destruction order of the pushed arguments to align with how it is done everywhere else. I'm not exactly sure whether this is the right way to fix it, but it seems to work fine.
* Fix segfault when cloning generator with propertiesNikita Popov2013-02-011-7/+19
| | | | | | Rule of thumb: Always implement the object clone handler rather than the object storage clone handler. Actually I think we should drop the latter. It's nearly never usable.
* Fix potential segfault when finally in a generator is run during shutdownNikita Popov2013-01-301-36/+41
| | | | | | | | | | | If a generator is destroyed in a finally block it will resume the generator to run that finally block before freeing the generator. This was done in the object storage free handler. Running user code in the free handler isn't safe though because the free handlers may be run during request shutdown, already after several key components have been shut down. This is avoided by doing the finally handling in the dtor handler. These handlers are run at the start of the shutdown sequence.
* Happy New YearXinchen Hui2013-01-011-1/+1
|
* Implement Generator::throw() methodNikita Popov2012-12-241-5/+44
| | | | | | | Generator::throw($exception) throws an exception into the generator. The exception is thrown at the current point of suspension within the generator. It basically behaves as if the current yield statement were replaced with a throw statement and the generator subsequently resumed.
* Fix crash when last yielded value is a closureNikita Popov2012-12-211-10/+10
| | | | | | | | | | | | If zend_generator_close is called from within zend_generator_resume (e.g. due to a return statement) then all the EGs will still be using the values from the generator. That's why the stack frame has to be the last thing that is dtored, otherwise some other dtor that is using EG(current_execute_data) might access the already freed memory segment. This was the case with the closure dtor. The fix is to move the dtors for key and value to the start of the handler. This way the stack frame is the last thing that is freed.
* Do not add a ref to EX(object) on generator cloneNikita Popov2012-12-201-5/+1
| | | | | If a ref has to be added it will be already added while walking the call slots.
* Fix leak when generator ignores sent valueNikita Popov2012-12-181-8/+3
| | | | | | | When the return value of yield wasn't used it was leaked. This is fixed by using a TMP_VAR return value instead of VAR. TMP_VARs are automatically freed when they aren't used.
* Fix warning of no return in non-void functionXinchen Hui2012-12-141-0/+1
|
* Restored proper generators behaviour in conjunction with "finally". (Nikita)Dmitry Stogov2012-12-121-2/+36
|
* - generators API exported for extensionsDmitry Stogov2012-12-111-3/+3
| | | | - improved RETURN sequence to avoid redundant check if op_array is a generator
* Optimized access to temporary and compiled VM variablesDmitry Stogov2012-12-041-17/+15
|
* - Fixed ZTS buildFelipe Pena2012-11-301-1/+1
|
* . The VM stacks for passing function arguments and syntaticaly nested calls ↵Dmitry Stogov2012-11-301-206/+98
| | | | | | were merged into a single stack. The stack size needed for op_array execution is calculated at compile time and preallocated at once. As result all the stack push operatins don't require checks for stack overflow any more. . Generators implementation was improved using the new VM stack. Now it's a bit more clear and faster.
* Fix bug #63596: finally in generators segfaultsNikita Popov2012-11-241-0/+1
| | | | | EX(fast_ret) wasn't initialized in this case so the code ended up dereferencing an invalid pointer after the jump.
* Improved "finally" im[plementationDmitry Stogov2012-11-221-1/+0
|
* Fixed bug #63428 (The behavior of execute() changed)Xinchen Hui2012-11-041-0/+4
|
* Fixed bug #63132Nikita Popov2012-09-221-0/+57
| | | | | | | | | | | | | | EG(arg_types_stack) is now also backed up when generators are used. This allows the use of yield in nested method calls. This commit adds two new functions to the zend_ptr_stack API: zend_ptr_stack_push_from_memory zend_ptr_stack_pop_into_memory both taking the following arguments: zend_ptr_stack *stack, int count, void **pointers
* Fix two op_array -> function cast warningsNikita Popov2012-09-161-1/+1
|
* - fix build, declarations must be 1st in a contextgit checkout -f masterPierre Joye2012-09-051-3/+6
|
* Fixed bug #62991 (Segfault with generator and closure)Dmitry Stogov2012-09-051-0/+14
|
* Fix typosNikita Popov2012-08-291-3/+3
|
* Fix segfault when traversing a by-ref generator twiceNikita Popov2012-08-291-1/+7
| | | | | | | | If you try to traverse an already closed generator an exception will now be thrown. Furthermore this changes the error for traversing a by-val generator by-ref from an E_ERROR to an Exception.
* Make sure that exception is thrown on rewind() after closing tooNikita Popov2012-08-291-1/+1
|
* Fix several issues and allow rewind only at/before first yieldNikita Popov2012-08-251-10/+39
| | | | | | | | * Trying to resume a generator while it is already running now throws a fatal error. * Trying to use yield in finally while the generator is being force-closed (by GC) throws a fatal error. * Rewinding after the first yield now throws an Exception
* Run finally if generator is closed before finishingNikita Popov2012-08-241-1/+34
|
* Disallow serialization and unserializationNikita Popov2012-08-201-6/+26
|