Instead decide whether a function returned by reference or by value
by checking whether the return value has REFERENCE type. This means
that functions returning by reference must always return a reference
and functions returning by value must not return a reference.
- with opcache all IS_CONST operands are not refcounted (scalars, interned strings or immutable arrays)
- without opcache IS_CONST operands are not shared between processes or threads and may use common reference counters
"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).
Squashed commit of the following:
commit 0361dbe356
Author: Andrea Faulds <ajf@ajf.me>
Date: Fri Mar 25 16:59:20 2016 +0000
UPGRADING and NEWS
commit dca9d4a36c
Author: Andrea Faulds <ajf@ajf.me>
Date: Fri Mar 25 16:45:18 2016 +0000
Add tests contributed by @jesseschalken
commit e557f77eab
Author: Andrea Faulds <ajf@ajf.me>
Date: Fri Mar 25 16:44:51 2016 +0000
Rebuild VM
commit 70942e4c3c
Author: Andrea Faulds <ajf@ajf.me>
Date: Wed Feb 24 13:12:26 2016 +0000
Add test for evaluation order of nested list() keys
commit ed3592e80c
Author: Andrea Faulds <ajf@ajf.me>
Date: Wed Feb 24 12:42:04 2016 +0000
Add test for evaluation order
commit 589756cbcc
Author: Andrea Faulds <ajf@ajf.me>
Date: Tue Jan 19 17:29:34 2016 +0000
Allow arbitrary expressions for key
commit 3f622077c3
Author: Andrea Faulds <ajf@ajf.me>
Date: Tue Jan 19 17:45:10 2016 +0000
Remove compile-time HANDLE_NUMERIC (see bug #63217)
commit bab758119a
Author: Andrea Faulds <ajf@ajf.me>
Date: Sun Jan 17 01:20:26 2016 +0000
Handle numeric strings
commit 14bfe93ddc
Author: Andrea Faulds <ajf@ajf.me>
Date: Sun Jan 17 01:09:36 2016 +0000
Allow trailing comma
commit f4c8b2cb30
Author: Andrea Faulds <ajf@ajf.me>
Date: Sat Jan 16 23:47:11 2016 +0000
Add tests
commit 0085884a61
Author: Andrea Faulds <ajf@ajf.me>
Date: Sat Jan 16 22:24:23 2016 +0000
Handle non-integer/string opcodes
commit e572d2d0ad
Author: Andrea Faulds <ajf@ajf.me>
Date: Sat Jan 16 21:10:33 2016 +0000
Disallow mixing keyed and unkeyed list() elements
commit cede13ccfe
Author: Andrea Faulds <ajf@ajf.me>
Date: Sun Jan 10 20:46:44 2016 +0000
list() with keys (no foreach or tests)
This means we no longer allocate an unused VAR for the retval of
instructions that support unused results.
Nearly all instructions already used the result variable only if
it was used. The only exception to this was the return value
variable for internal function call results. I've adjusted the code
to use a stack zval for the unused return case now. As we have
retval specialization now, we know that it doesn't matter.
This opcodes inserts a local CV into the closure static variable
table. This replaces the previous mechanism of having static
variables marked as LEXICAL, which perform a symtable lookup
during copying.
This means a) functions which contain closures no longer have to
rebuild their symtable (better performance) and b) we can now track
used variables in SSA.
The DECLARE_(ANON_)INHERITED_CLASS(_DELAYED) opcodes were
referencing the parent ce VAR through extended_value. This is
hacky and we can't track the def-use chain in SSA.
To avoid this, the layout of declaration opcodes is changed
as follows: op1 points to the lcname and rtd_key literals, in
that order. (For anon/lambda declarations only one of lcname or
rtd_key is present.) This frees up op2, which is now used to
reference the parent ce VAR in inheriting declarations. The
jmp offset for anon class declarations is moved frop op2 to
extended_value.
The changes were applied both to class and function declarations
to keep everything symmetric.
FE_FREE does not unregister the iter for plain arrays. So always
wrap into a REF wrapper, even if not strictly necessary, in
RESET_RW. Alternatively we could use a flag to distinguish plain
positions and interators.
Also added a check for leaked iterators in shutdown_executor.
This does not collide with NO_AUTOLOAD -- missing classes will be
silenced, but invalid use of self etc will result in an exception
instead of a fatal error.
- All helpers now may be declatred and called without ZEND_VM_HELPER_EX() and ZEND_VM_DISPATCH_TO_HELPER_EX() macros
- ZEND_VM_HELPER() may declare few arguments
- ZEND_VM_DISPATCH_TO_HELPER() may pass few parameters
- ZEND_VM_INLINE_HELPER() may be used to declare inline helpers (it won't be inlined in SWITH/GOTO executors)
Squashed commit of the following:
commit f11ca0e7a5
Author: Dmitry Stogov <dmitry@zend.com>
Date: Tue Dec 8 12:38:42 2015 +0300
Fixed test expectation
commit 211f873f54
Author: Dmitry Stogov <dmitry@zend.com>
Date: Tue Dec 8 12:28:38 2015 +0300
Embed zend_class_constant.flags into zend_class_constants.value.u2.access_flags
commit 51deab84b2
Author: Dmitry Stogov <dmitry@zend.com>
Date: Mon Dec 7 11:18:55 2015 +0300
Fixed issues found by Nikita
commit 544dbd5b47
Author: Dmitry Stogov <dmitry@zend.com>
Date: Sat Dec 5 02:41:05 2015 +0300
Refactored immplementation of https://wiki.php.net/rfc/class_const_visibility
@reeze created an RFC here and I emailed internals here and didn't get any responses positive/negative.
- Added ZEND_VM_LAST_OPCODE macro
- Use better names LINE->OPLINE, REL_LINE->REL_OPLINE, FCALL->FAST_CALL, FRET->FAST_RET
- Added ISSET flag to extended value of ZEND_ISSET_ISEMPTY_VAR opcode
This is generalized solution for Bob's idea of speed up self::method() calls without ZEND_FETCH_CLASS.
At first, it adds few new opcodes to separate class related behaviour:
FETCH_STATIC_PROP_R
FETCH_STATIC_PROP_W
FETCH_STATIC_PROP_RW
FETCH_STATIC_PROP_FUNC_ARG
FETCH_STATIC_PROP_UNSET
FETCH_STATIC_PROP_IS
UNSET_STATIC_PROP
ISSET_ISEMPTY_STATIC_PROP
FETCH_CLASS_CONSTANT
At seconds, it enables IS_UNUSED operand to fetch (self, parent or static without separate FETCH_CLASS) for new opcodes and the following ones:
INIT_STATIC_METHOD_CALL
NEW
END_INSTANCEOF
Finaly, opcache optimizer had to be fixed to support new opcodes.
This replaces add_new with update for the RW case. This should not
be problematic for performance, as this branch throws a notice.
Alternatively add_new could also be replaced with add. I went with
update, because it makes $a[0] += 1 behavior the same as
$a[0] = $a[0] + 1.
As it turns out, there is actually no reason to prevent this, it even was a bigger BC break than expected...
Also fixes a memory leak (the Closure leaks) when calling internal functions via Closure by moving it out of leave helper onto caller side for TOP_CODE:
$z = new SplStack; $z->push(20);
$x = (new ReflectionMethod("SplStack", "pop"))->getClosure($z);
var_dump($x());
It is by far the most used branch; compilers tended here to split the branches via an &2, &1 check, now it only does an &3 check and prefers ZEND_CALL_NESTED_FUNCTION branch
This fix is actually made for array acessing bug fix (#70262) which is
discarded since we have another better fix, anyway now seems this is still useful
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.