Nikita Popov
ee89e228f6
Allow yielding during function calls
...
During function calls arguments are pushed onto the stack. Now these are
backed up on yield and restored on resume. This requires memcpy'ing them,
but there doesn't seem to be any better way to do it.
Also this fixes the issue with exceptions thrown during function calls.
2012-05-31 00:00:30 +02:00
Nikita Popov
0033a52521
Allow throwing exceptions from generators
...
The missing piece is how one can find the next stack frame, which is
required for dtor'ing arguments pushed to the stack. As the generator
execute_data does not live on the stack one can't use it to figure out the
start of the next stack frame. So there must be some other method.
2012-05-30 16:28:33 +02:00
Nikita Popov
8790160235
Add auto-increment keys
...
When no key is explicitely yielded PHP will used auto-incrementing keys
as a fallback. They behave the same as with arrays, i.e. the key is the
successor of the largest previously used integer key.
2012-05-30 05:05:49 +02:00
Nikita Popov
bc08c2cf94
Add support for yielding keys
...
Keys are yielded using the
yield $key => $value
syntax. Currently this is implemented as a statement only and not as an
expression, because conflicts arise considering nesting and use in arrays:
yield yield $a => $b;
// could be either
yield (yield $a) => $b;
// or
yield (yield $a => $b);
Once I find some way to resolve these conflicts this should be available
as an expression too.
Also the key yielding code is rather copy-and-past-y for the value yielding
code, so that should be factored out.
2012-05-30 02:44:06 +02:00
Nikita Popov
ad525c288a
Allow to use yield without value
...
If the generator is used as a coroutine it often doesn't make sense to yield
anything. In this case one can simply receive values using
$value = yield;
The yield here will simply yield NULL.
2012-05-29 17:53:11 +02:00
Nikita Popov
3600914ced
Add support for $generator->send()
...
Yield now is an expression and the return value is the value passed to
$generator->send(). By default (i.e. if ->next() is called) the value is
NULL.
Unlike in Python ->send() can be run without priming the generator with a
->next() call first.
2012-05-29 17:34:33 +02:00
Nikita Popov
b770b221e0
Make the GOTO and SWITCH VMs work again
2012-05-29 02:31:56 +02:00
Nikita Popov
4aab08b64c
Properly free resources when generator return value not used
...
To keep things clean two new functions are introduced:
zend_clean_and_cache_symbol_table(HashTable *symbol_table)
zend_free_compiled_variables(zval ***CVs, int num)
2012-05-28 06:43:18 +02:00
Nikita Popov
9f52c5c226
Fix generator creation when execute_data is not nested
...
This happens primarily when the generator is invoked from some internal
place like a dynamic function call.
2012-05-27 22:48:21 +02:00
Nikita Popov
64a643a4e3
Free loop variables
...
If the generator is closed before it has finished running, it may happen
that some FREE or SWITCH_FREE opcodes haven't been executed and memory is
leaked.
This fixes it by walking the brk_cont_array and manually freeing the
variables.
2012-05-27 17:14:20 +02:00
Nikita Popov
247bb737d5
Add support for generator methods
2012-05-27 03:50:31 +02:00
Nikita Popov
d49d3971e6
Close generator on return
2012-05-26 23:59:22 +02:00
Nikita Popov
5bb3a995c2
Implement return for generators
...
For generators ZEND_RETURN directly calls ZEND_VM_RETURN(), thus passing
execution back to the caller (zend_generator_resume).
This commit also adds a check that only return; is used in generators and
not return $value;.
2012-05-26 23:07:40 +02:00
Nikita Popov
fafce58683
Add YIELD opcode implementation
2012-05-26 22:44:53 +02:00
Nikita Popov
f627be5254
Add support for executing a zend_execute_data
...
This adds another function execute_ex(), which accepts a zend_execute_data
struct to run (contrary to execute(), which accepts a zend_op_array from
which it initialized the execute_data).
This needs a bit more cleanup.
2012-05-26 17:53:13 +02:00
Nikita Popov
9ce9a7e639
Add initial code for suspending execution
...
This is just some initial code, which is still quite broken (and needs to be
moved so it can be reused.)
2012-05-23 14:20:25 +02:00
Nikita Popov
5e763d9420
Allocate execute_data using malloc for generators
...
Generators need to switch the execute_data very often. If the execute_data
is allocated on the VM stack this operation would require to always copy
the structure (which is quite large). That's why the execution context is
allocated on the heap instead (only for generators obviously).
2012-05-22 23:17:59 +02:00
Nikita Popov
46fa26ab85
Make generator functions return a Generator object
...
Right now generator functions simply immediately return a new Generator
object (no suspension yet).
2012-05-20 14:45:01 +02:00
Nikita Popov
1cec3f12cc
Add ZEND_SUSPEND_AND_RETURN_GENERATOR opcode
...
If the function is a generator this opcode will be invoked right after
receiving the function arguments.
The current implementation is just a dummy.
2012-05-19 23:19:21 +02:00
Stanislav Malyshev
d03900dc92
fix bug #61782 - __clone/__destruct do not match other methods when checking access controls
2012-05-14 11:03:21 -07:00
Stanislav Malyshev
a0dff6fdca
fix bug #61782 - __clone/__destruct do not match other methods when checking access controls
2012-05-13 14:40:44 -07:00
Xinchen Hui
565892d4c0
Implement const array/string dereference
...
RFC:https://wiki.php.net/rfc/constdereference
2012-04-17 10:06:17 +08:00
Xinchen Hui
0876d7bb89
MFH: Fixed bug #61011 (Crash when an exception is thrown by __autoload accessing a static property)
2012-03-02 03:12:15 +00:00
Xinchen Hui
229e55632d
Fixed bug #61011 (Crash when an exception is thrown by __autoload accessing a static property)
2012-02-25 13:56:59 +00:00
Dmitry Stogov
3fe072f8a9
Fixed (disabled) inline-caching for ZEND_OVERLOADED_FUNCTION methods
2012-01-30 10:51:02 +00:00
Dmitry Stogov
c95937e902
Fixed (disabled) inline-caching for ZEND_OVERLOADED_FUNCTION methods
2012-01-30 10:51:02 +00:00
Xinchen Hui
3a8a5bc843
WS, merged from trunk cause this issue, sorry
2012-01-26 01:28:37 +00:00
Xinchen Hui
bbd6ab2054
WS, merged from trunk cause this issue, sorry
2012-01-26 01:28:37 +00:00
Xinchen Hui
1207451239
Fixed bug #60825 (Segfault when running symfony 2 tests)
2012-01-26 01:21:35 +00:00
Xinchen Hui
a222954a45
Re-fixed bug #60825 (Segfault when running symfony 2 tests)
2012-01-24 14:39:45 +00:00
Xinchen Hui
cf54cc736b
Fixed bug #60825 (Segfault when running symfony 2 tests)
2012-01-21 17:13:53 +00:00
Felipe Pena
8775a37559
- Year++
2012-01-01 13:15:04 +00:00
Felipe Pena
4e19825281
- Year++
2012-01-01 13:15:04 +00:00
Stanislav Malyshev
327a5828cd
Fix warning on non-numeric offsets
2011-12-22 03:22:42 +00:00
Stanislav Malyshev
0610ca459a
Fix warning on non-numeric offsets
2011-12-22 03:22:42 +00:00
Stanislav Malyshev
1f4f33afcf
implement the solution for isset/string offsets, fix bug #60362
2011-12-19 02:05:03 +00:00
Stanislav Malyshev
622412d8e6
implement the solution for isset/string offsets, fix bug #60362
2011-12-19 02:05:03 +00:00
Dmitry Stogov
cacf363957
Fixed bug #60104 (Segmentation Fault in pdo_sqlite when using sqliteCreateFunction())
2011-11-08 10:11:25 +00:00
Dmitry Stogov
e86830273b
Fixed bug #60104 (Segmentation Fault in pdo_sqlite when using sqliteCreateFunction())
2011-11-08 10:11:25 +00:00
Xinchen Hui
cae2f1381f
Fix bug #60169 Conjunction of ternary and list crashes PHP
2011-11-03 03:59:41 +00:00
Xinchen Hui
a9dbbf6dea
Fix bug #60169 Conjunction of ternary and list crashes PHP
2011-11-03 03:59:41 +00:00
Arnaud Le Blanc
ea5a61e39b
Improved ternary operator performance when returning arrays
2011-10-18 19:42:42 +00:00
Arnaud Le Blanc
07b7ba8b40
Improved ternary operator performance when returning arrays
2011-10-18 19:42:42 +00:00
Dmitry Stogov
4a25a7740d
Fixed ZE specific compile warnings (Bug #55629 )
2011-09-13 13:29:35 +00:00
Dmitry Stogov
e43ff1359e
Fixed ZE specific compile warnings (Bug #55629 )
2011-09-13 13:29:35 +00:00
Dmitry Stogov
5e923d23b4
Fixed bug #55305 (ref lost: 1st ref instantiated in class def, 2nd ref made w/o instantiating)
2011-08-01 15:23:16 +00:00
Dmitry Stogov
d4a80cfa8d
Fixed bug #55305 (ref lost: 1st ref instantiated in class def, 2nd ref made w/o instantiating)
2011-08-01 15:23:16 +00:00
Dmitry Stogov
a0974f2d59
Fixed bug #54305 (Crash in gc_remove_zval_from_buffer)
2011-07-11 10:31:49 +00:00
Dmitry Stogov
0f3e70fe01
Fixed bug #54305 (Crash in gc_remove_zval_from_buffer)
2011-07-11 10:31:49 +00:00
Felipe Pena
31a69cd480
- Year++
2011-07-10 13:05:32 +00:00
Felipe Pena
327a9d45c9
- Year++
2011-07-10 13:05:32 +00:00
Dmitry Stogov
3931078e7f
Fixed bug #55135 (Array keys are no longer type casted in unset())
2011-07-06 12:04:02 +00:00
Dmitry Stogov
b7e124004f
Fixed bug #55135 (Array keys are no longer type casted in unset())
2011-07-06 12:04:02 +00:00
Felipe Pena
66ac89a00b
- Added indirect method call through array variable (FR Bug #47160 )
2011-06-06 21:42:05 +00:00
Felipe Pena
be3889456b
- Added indirect method call through array variable (FR Bug #47160 )
2011-06-06 21:42:05 +00:00
Felipe Pena
32b5f8a1a3
- Added new parameter parsing option (p - for valid path (string without null byte in the middle))
...
# The tests will be fixed in the next commits
2011-06-06 21:28:16 +00:00
Felipe Pena
4737910b69
- Added new parameter parsing option (p - for valid path (string without null byte in the middle))
...
# The tests will be fixed in the next commits
2011-06-06 21:28:16 +00:00
Dmitry Stogov
c270347c0b
MFH: Arithmetic speedup. Inlined most probable code-paths for arithmetic operations directly into executor.
2011-05-31 12:05:25 +00:00
Dmitry Stogov
b7eb3c1c5a
Arithmetic speedup. Inlined most probable code-paths for arithmetic operations directly into executor.
2011-05-23 08:05:44 +00:00
Dmitry Stogov
6eedfb9b3a
Fixed direct threaded executor (php zend_vm_gen.php --with-vm-kind=GOTO)
2011-05-05 16:02:11 +00:00
Dmitry Stogov
9fb4cd1a91
Fixed bug #54585 (track_errors causes segfault)
2011-04-25 07:50:07 +00:00
Dmitry Stogov
821d7169d9
Fixed bug #54367 (Use of closure causes problem in ArrayAccess).
2011-04-20 12:59:18 +00:00
Dmitry Stogov
8c06867e11
Fixed bug #54262 (Crash when assigning value to a dimension in a non-array)
2011-03-16 11:14:33 +00:00
Stanislav Malyshev
8efa208e0b
fix UMR when variable name is an object and __toString is used
...
# zend_call_function checks IS_REF on This
2011-03-16 05:25:02 +00:00
Felipe Pena
0203cc3d44
- Year++
2011-01-01 02:17:06 +00:00
Dmitry Stogov
c35fc78890
Fixed bug #53511 (Exceptions are lost in case an exception is thrown in catch operator)
2010-12-09 16:38:37 +00:00
Dmitry Stogov
7628da98c4
Removed support for break/continue $var syntax
2010-11-24 12:19:56 +00:00
Dmitry Stogov
68e154b1bf
reduced size of temp_variariable
2010-10-22 14:51:07 +00:00
Dmitry Stogov
968bdc576c
Simplified foreach() handling, we don't have to inctrement/decrement refcount twice
2010-10-22 13:59:23 +00:00
Dmitry Stogov
d12098eeec
Fixed crash on attempt to insert reference to string offset into an array
2010-10-22 11:05:22 +00:00
Dmitry Stogov
635f3aff75
Removed redundant check
2010-10-22 09:56:39 +00:00
Dmitry Stogov
fa3f0bb63f
Fixed bug #51008 (Zend/tests/bug45877.phpt fails)
2010-10-05 11:28:56 +00:00
Dmitry Stogov
e3bb93480a
Regenerated
2010-09-15 07:39:57 +00:00
Dmitry Stogov
2188f26c45
Fixed bug #52614 (Memory leak when writing on uninitialized variable returned from method call)
2010-08-25 09:14:36 +00:00
Dmitry Stogov
8a6d73b084
improved performance of @ (silence) operator
2010-08-18 13:58:13 +00:00
Dmitry Stogov
f48999ca3b
Optimization of ASSIGN instruction
2010-08-11 15:34:06 +00:00
Dmitry Stogov
e0b728597b
Optimization (IS_TMP_VARs don't need reference counting)
2010-08-10 15:24:19 +00:00
Dmitry Stogov
523b965cd4
Prevent generation of long strings
2010-08-10 14:44:50 +00:00
Dmitry Stogov
39b4a5eea7
Additional specialization
2010-07-27 09:50:35 +00:00
Dmitry Stogov
d30073a2dc
Removed deprecated check
2010-07-26 12:40:32 +00:00
Dmitry Stogov
5a2ee8ecea
Use proper fetch types
2010-07-19 15:04:51 +00:00
Dmitry Stogov
c1336009c2
Removed invalid checks
2010-07-19 14:34:34 +00:00
Dmitry Stogov
ca4de03eed
ZEND_FETCH_*_R operations simplified and can't be used with EXT_TYPE_UNUSED flag any more. Thit is very rare and useless case. ZEND_FREE might be required after them instead.
2010-07-16 13:38:09 +00:00
Dmitry Stogov
8aad91d14a
Simplified string offset reading
2010-07-16 11:44:30 +00:00
Dmitry Stogov
ab67865d21
Fixed bug #52237 (Crash when passing the reference of the property of a non-object)
2010-07-05 09:08:35 +00:00
Dmitry Stogov
09943e56cd
Removed redundant code
2010-06-22 14:15:08 +00:00
Dmitry Stogov
d868733cc3
Fixed bug #52041 (Memory leak when writing on uninitialized variable returned from function)
2010-06-15 08:22:51 +00:00
Felipe Pena
d97ae93616
- Let's generate this #ifdef only on zend_vm_execute.h
2010-06-07 23:04:30 +00:00
Felipe Pena
efcb21b0dd
- Update
2010-06-07 14:51:12 +00:00
Pierre Joye
90b9853a3c
- show the free_op1 warning only once, until a fix is applied
2010-06-06 20:32:51 +00:00
Dmitry Stogov
04dd48ceca
Fixed exception handling in GOTO VM
2010-05-24 14:46:31 +00:00
Dmitry Stogov
c5237d82bf
Added caches to eliminate repeatable run-time bindings of functions, classes, constants, methods and properties
2010-05-24 14:11:39 +00:00
Felipe Pena
5d701938a3
- Added check for constant creation on Traits
...
- Simplified trait flag check
- Test++ :)
2010-05-07 11:09:35 +00:00
Dmitry Stogov
277f271a83
Added compiler hints
2010-05-06 12:52:27 +00:00
Dmitry Stogov
d5800f881c
Optimized access to static properties using executor specialization. A constant class name may be used as a direct operand of ZEND_FETCH_* instruction without previous ZEND_FETCH_CLASS.
2010-05-06 10:27:35 +00:00
Felipe Pena
e431cec023
- Fix trait flag identification
2010-05-04 18:31:40 +00:00
Felipe Pena
45a536fc7c
- Added check for abstract class
...
abstract class foo { }
class T { use foo; } // T cannot use foo - it is not a trait
- Added check for trait on NEW
trait a { }
new a; // Cannot instantiate trait a
# Tests for errors comming soon :)
2010-05-04 18:21:00 +00:00
Dmitry Stogov
4ff3000850
ws
2010-04-27 12:23:29 +00:00
Dmitry Stogov
c58b131e29
- Reimplemented ZEND_INIT_FCALL_BY_NAME and ZEND_INIT_NS_FCALL_BY_NAME to use literals instead of additional operands
...
- Optimized access to global constants
2010-04-27 12:09:13 +00:00
David Soria Parra
08b9fdc8a3
Add DTrace probes
2010-04-24 13:32:30 +00:00