|
19 | 19 |
|
20 | 20 | #include "zend.h"
|
21 | 21 | #include "zend_API.h"
|
| 22 | +#include "zend_gc.h" |
22 | 23 | #include "zend_ini.h"
|
23 | 24 | #include "zend_vm.h"
|
24 | 25 | #include "zend_exceptions.h"
|
|
27 | 28 | #include "zend_mmap.h"
|
28 | 29 | #include "zend_compile.h"
|
29 | 30 | #include "zend_closures.h"
|
| 31 | +#include "zend_generators.h" |
30 | 32 |
|
31 | 33 | #include "zend_fibers.h"
|
32 | 34 | #include "zend_fibers_arginfo.h"
|
@@ -763,7 +765,25 @@ static HashTable *zend_fiber_object_gc(zend_object *object, zval **table, int *n
|
763 | 765 | HashTable *lastSymTable = NULL;
|
764 | 766 | zend_execute_data *ex = fiber->execute_data;
|
765 | 767 | for (; ex; ex = ex->prev_execute_data) {
|
766 |
| - HashTable *symTable = zend_unfinished_execution_gc_ex(ex, ex->func && ZEND_USER_CODE(ex->func->type) ? ex->call : NULL, buf, false); |
| 768 | + HashTable *symTable; |
| 769 | + if (ZEND_CALL_INFO(ex) & ZEND_CALL_GENERATOR) { |
| 770 | + /* The generator object is stored in ex->return_value */ |
| 771 | + zend_generator *generator = (zend_generator*)ex->return_value; |
| 772 | + /* There are two cases to consider: |
| 773 | + * - If the generator is currently running, the Generator's GC |
| 774 | + * handler will ignore it because it is not collectable. However, |
| 775 | + * in this context the generator is suspended in Fiber::suspend() |
| 776 | + * and may be collectable, so we can inspect it. |
| 777 | + * - If the generator is not running, the Generator's GC handler |
| 778 | + * will inspect it. In this case we have to skip the frame. |
| 779 | + */ |
| 780 | + if (!(generator->flags & ZEND_GENERATOR_CURRENTLY_RUNNING)) { |
| 781 | + continue; |
| 782 | + } |
| 783 | + symTable = zend_generator_frame_gc(buf, generator); |
| 784 | + } else { |
| 785 | + symTable = zend_unfinished_execution_gc_ex(ex, ex->func && ZEND_USER_CODE(ex->func->type) ? ex->call : NULL, buf, false); |
| 786 | + } |
767 | 787 | if (symTable) {
|
768 | 788 | if (lastSymTable) {
|
769 | 789 | zval *val;
|
|
0 commit comments