Dmitry Stogov
ccf18da450
Eliminated checks for (func->op_array.fn_flags & ZEND_ACC_GENERATOR) in fast path of DO_FCALL* handlers.
...
This slightly improves calls to regular function and method calls in cost of a bit slower generator initialization.
Separate call frame for generators, allocated on heap, now created by ZEND_GENERATOR_CREATE instruction.
2016-05-13 01:40:15 +03:00
Dmitry Stogov
8a7a913a7a
Use main VM stack for generators. Only single call frame for generator itself is allocated on heap, call frames for nested functions are allocated on main VM stack. In case "yield" used in context of another function call, call stack has to be frozen and then restored.
2016-05-12 00:44:18 +03:00
Dmitry Stogov
2578d08033
Fixed compilation warnings
2016-04-29 14:44:56 +03:00
Dmitry Stogov
747a482b9c
Don't initialize EX(call)->symbol_table on each function call.
...
Keep it uninitialized, and check ZEND_CALL_HAS_SYMBOL_TABLE flag when necessary.
2016-04-28 15:17:24 +03:00
Dmitry Stogov
6499162ff0
- get rid of EG(scope). zend_get_executed_scope() should be used instead.
...
- ichanged zval_update_constant_ex(). Use IS_TYPE_IMMUTABLE flag on shared constants and AST, instead of "inline_change" parameter.
2016-04-28 04:13:34 +03:00
Bob Weinand
5085352464
Fix generator being a cycle to itself
2016-04-18 23:55:16 +02:00
Nikita Popov
2eff141444
Merge branch 'PHP-7.0'
2016-04-07 12:30:06 +02:00
Nikita Popov
aad4ecebf8
Fixed bug #71980
2016-04-07 12:29:59 +02:00
Dmitry Stogov
e7730fece6
Fised possible use-after-free
2016-04-04 09:35:48 +03:00
Dmitry Stogov
7abfaac901
Merge zend_execute_data->called_scope into zend_execute_data->This.
...
"called_scope" made sense only for static method calls, for dynamic calls it was always equal to the class of $this.
Now EG(This) may store IS_OBJECT + $this or IS_UNUSED + "called_scope" (of course, "called_scope" may be NULL).
Some code might need to be adopted to support this change.
Checks (Z_OBJ(EX(This))) might need to be converted into (Z_TYPE(EX(This)) == IS_OBJECT).
2016-04-01 16:17:49 +03:00
Dmitry Stogov
86a1aeed22
Flags ZEND_CALL_RELEASE_THIS and ZEND_CALL_CLOSURE should never be set together.
...
Closures keep responsibility for releasing $this theirselves.
2016-03-31 18:58:13 +03:00
Kalle Sommer Nielsen
9583cb84a2
Fix build
2016-03-17 03:41:36 +01:00
Bob Weinand
77ca527c91
Merge branch 'PHP-7.0'
2016-02-15 22:43:58 +01:00
Bob Weinand
23b770f31f
Fixed bug #71601 (finally block not executed after yield from)
2016-02-15 22:37:21 +01:00
Nikita Popov
c0c73f7083
Fix bug #69989
...
This should cover all the basic cycles. Anything further would
require scanning the call stack and live temporaries.
2016-02-12 18:52:53 +01:00
Nikita Popov
f75be35312
Support partial GC for unfinished generators
...
This doesn't cover everything yet, but should be a good start for
cycled in unfinished generators.
2016-02-11 16:38:30 +01:00
Nikita Popov
1322672c0b
Fix dangling send target when using yield from
...
Also drop some unnecessary TRY_DELREFs -- leftovers from the days
when null was refcounted.
2016-02-11 16:25:16 +01:00
Nikita Popov
aa3f44a395
Crude generator GC for value/key/retval
...
These values remain live after the generator has been closed, so
they are particularly susceptible to leaking cycles.
2016-02-10 19:03:02 +01:00
Bob Weinand
83cb751047
Fix accidental zval_dtor() usage
2016-01-07 15:12:50 +01:00
Bob Weinand
033d608771
Fixed bug #71297 (Memory leak with yield from)
2016-01-07 11:56:21 +01:00
Xinchen Hui
97a9470d97
bump year which is missed in rev 49493a2
2016-01-02 17:56:11 +08:00
Bob Weinand
559ede17e1
Fixed bug #71013 (Incorrect exception handler with yield from)
2015-12-06 02:45:19 +01:00
Bob Weinand
2de8915dea
Fixed bug causing exception not being thrown immediately into a generator yielding from an array
2015-11-25 23:09:44 +01:00
Bob Weinand
73a92964ff
Fixed bug #70965 (yield from with a common iterator primes too much)
2015-11-25 09:54:24 +01:00
Bob Weinand
80d9dcafe0
Fixed bug #70904 (yield from incorrectly marks valid generator as finished)
2015-11-24 23:43:34 +01:00
Bob Weinand
c9988a1e69
Remove superfluous branches
2015-09-20 02:59:30 +02:00
Bob Weinand
14af0f6dcb
Set expectations in generator handling
2015-09-20 02:19:31 +02:00
Bob Weinand
5ece3ec71c
Fix bogus traces with ReflectionGenerator::getTrace()
2015-08-20 23:24:28 +02:00
Dmitry Stogov
71af54e5f6
Mark error and exception functions as "cold" (Matt's idea)
2015-08-19 14:40:56 +03:00
Dmitry Stogov
715d5d2855
Get rid of implicit type casting in GC_*() macros in Zend/zend_types.h.
...
This prevented compilation warnings and disclosed few incorrect usages in Zend/zend_vm_def.h and ext/dom/xpath.c.
Now explicit type casting may be required on call site.
This may break some C extension code, but it shoulfn't be a problem to add explicit casting.
2015-08-13 13:56:29 +03:00
Xinchen Hui
3eabf2bf19
"This" is C++ keyword
2015-07-30 11:30:34 +08:00
Aaron Piotrowski
5df893ce3c
Use NULL where possible for exception class
...
Matches usage of zend_throw_exception()/zend_throw_exception_ex().
2015-07-07 12:10:55 -05:00
Aaron Piotrowski
22c38b2ef5
Remove need to pass error level
2015-07-03 17:53:41 -05:00
Aaron Piotrowski
5a99c07ecc
Enable throwing custom exceptions from errors
2015-07-03 17:53:40 -05:00
Aaron Piotrowski
ed1b64877d
Switch position of ce in exception ce variable names
2015-07-03 09:45:03 -05:00
Aaron Piotrowski
a812a74c2e
Change zend_exception_get_default() to zend_exception_ce
2015-07-03 09:44:48 -05:00
Rasmus Lerdorf
41774bceff
Fix more minor mistakes in the proto comments
2015-06-23 15:47:33 -04:00
Nikita Popov
ea5c66ec93
Avoid op_num = -1 in unfinished generator cleanup
...
Also add two tests showing that the -1 substraction in the
computation of op_num is really necessary.
2015-06-23 20:17:30 +02:00
Nikita Popov
f58ebb3609
Load/restore VM stack before unfinished generator cleanup
2015-06-20 19:09:25 +02:00
Nikita Popov
ddf41d3aeb
Fix generator memory leak
...
Make sure HANDLE_EXCEPTION and generator unwinds stay in sync in
the future by extracting a common function.
2015-06-20 18:37:28 +02:00
Dmitry Stogov
1c754f0b71
Get rid of more ZVAL_ZVAL() macros
2015-06-12 13:33:14 +03:00
Dmitry Stogov
8e10e8f921
Avoid zval duplication in ZVAL_ZVAL() macro (it was necessary only in few places).
...
Switch from ZVAL_ZVAL() to simpler macros where possible (it makes sense to review remaining places)
2015-06-12 12:33:23 +03:00
Nikita Popov
580eb56fb7
Merge branch 'PHP-5.6'
...
Conflicts:
Zend/zend_generators.c
2015-06-11 17:44:51 +02:00
Nikita Popov
8405265578
Fix bug #69740
2015-06-11 17:40:10 +02:00
Bob Weinand
c6a6b9746d
Fix memleak in generators using symtable
2015-05-14 17:17:39 +02:00
Dmitry Stogov
bdbe121098
Fixed $this release
2015-05-07 17:26:01 +03:00
Bob Weinand
4376373da3
Fix yield from with iterator (first element missing)
2015-04-21 19:42:23 +02:00
Nikita Popov
9a0cb734a3
Fix memory error when throwing into a generator
...
throw_exception_internal will access opline+1, which is not always
defined at the current opline of the generator. To avoid this
decrement the opline before throwing (so the throw occurs at the
YIELD opcode instead of one after it).
2015-04-17 22:19:41 +02:00
Dmitry Stogov
a759967dd1
Mark call frames to closures with ZEND_CALL_CLOSURE flag to avoid expensive check at zend_leave_helper()
2015-04-16 12:16:03 +03:00
Bob Weinand
4e76d58b2b
Fix object leak for yield from (added proper refcounting)
2015-04-15 21:42:27 +02:00