Commit Graph

131 Commits

Author SHA1 Message Date
Nikita Popov
df79277de3 Revert "Fetch for read in nested property assignments"
This reverts commit bb43a3822e.

After thinking about this a bit more, this is now going to be
a complete solution for the "readonly properties" case, for example:

    unset($foo->readOnly->bar);

should also be legal and

    $foo->readOnly['bar'] = 42;

should also be legal if $foo->readOnly is not an array but an
ArrayAccess object.

I think it may be better to distinguish better on the BP_VAR flag
level. Reverting for now.
2020-03-18 14:54:43 +01:00
Nikita Popov
bb43a3822e Fetch for read in nested property assignments
$a->b->c = 'd';

is now compiled the same way as

    $b = $a->b;
    $b->c = 'd';

That is, we perform a read fetch on $a->b, rather than a write
fetch.

This is possible, because PHP 8 removed auto-vivification support
for objects, so $a->b->c = 'd' may no longer modify $a->b proper
(i.e. not counting interior mutability of the object).

Closes GH-5250.
2020-03-18 12:08:06 +01:00
Nikita Popov
d933591674 Add support for $obj::class
This allows $obj::class, which gives the same result as get_class($obj).
Anything other than an object results in TypeError.

RFC: https://wiki.php.net/rfc/class_name_literal_on_object

Closes GH-5065.
2020-02-11 12:16:30 +01:00
Dmitry Stogov
77bf144d52 Inline hot parts of bitwise instructions into hybrid VM 2020-01-14 13:47:10 +03:00
Nikita Popov
9c9a833f9c Actually remove the YIELD key specialization
I only adjusted the code before, without switching to TMPVAR.
2019-10-09 14:11:07 +02:00
Nikita Popov
da3b245715 Reduce YIELD_FROM specialization
Generator delegation is a complex compound operation, it does not
make a lot of sense to optimize refcounting here to this degree.
2019-10-09 13:53:07 +02:00
Nikita Popov
2aba10be4a Reduce ZEND_THROW specialization
Throwing is very expensive due to the need of gathering the backtrace,
so it makes little sense to optimize refcounting to this degree.
2019-10-09 13:17:25 +02:00
Dmitry Stogov
6e226c188c Change ZEND_RECV and ZEND_RECV_VARIADIC to use extended_value for cache slot (instead of op2), to be consistent with ZEND_RECV_INIT. 2019-09-23 22:28:56 +03:00
Dmitry Stogov
853b426ecf Avoid over-specialization 2019-07-24 19:51:56 +03:00
Nikita Popov
1eb706179f Avoid references in TMP var
Make sure we deref the OBJ_IS result, because we store it in a TMP
var, which is not allowed to contain references and will cause
assertion failures in the unspecialized VM.

This also partially reverts fd463a9a60,
which merged the TMP and VAR specializations of COALESCE to work
around this bug.

An alternative would be to change the result type of OBJ_IS back
to VAR.
2019-07-24 10:07:26 +02:00
Dmitry Stogov
d5943f5a11 Use run-time cache to avoid repeatable hash lookups when creating anonymous functions and classes 2019-07-19 10:43:49 +03:00
Dmitry Stogov
b065fbde19 ZEND_DECLARE_ANON_CLASS doesn't need to skip anything now. It's immediatelly followed by ZEND_NEW. 2019-07-19 10:09:26 +03:00
Dmitry Stogov
ef1a1a0698 Separate "cold" parts of comparison instructions 2019-07-11 20:44:39 +03:00
Dmitry Stogov
be94c0c3c6 Separate "cold" parts of binary op instructions 2019-07-11 18:23:08 +03:00
Dmitry Stogov
1305d9c0d2 Fixed opcode description 2019-07-08 11:20:46 +03:00
Dmitry Stogov
48ca5a1e17 Replace ZEND_ASSIGN_ADD (and others) by ZEND_ASSIGN_OP, ZEND_ASSIGN_DIM_OP, ZEND_ASSGIN_OBJ_OP and ZEND_ASSIGN_STATIC_PROP_OP 2019-07-05 12:03:25 +03:00
Dmitry Stogov
ef05eab432 Improve zend_binary_assign_op helpers.
Reorder opcode numbers to make ADD-POW and ASSIGN_ADD-ASSIGN_POW opcodes sequencional.
2019-07-04 17:25:43 +03:00
Dmitry Stogov
56b8b165f8 Optimization of INC/DEC helpers 2019-07-03 10:33:03 +03:00
Dmitry Stogov
e8f1f70101 Reduce overhead of delayed early binding 2019-06-25 14:20:41 +03:00
Nikita Popov
89b2d88659 Register class before fetching parent
We want the class declaration to be available while compiling the
parent class.
2019-06-11 13:09:33 +02:00
Dmitry Stogov
1814308e49 Don't specialize "cold" handlers 2019-05-31 00:31:57 +03:00
Dmitry Stogov
4e567ed1da Removed useless specialization. Specialized handlers called not specialized helpers. 2019-05-31 00:15:25 +03:00
CHU Zhaowei
e829d08729 Implement spread operator in arrays
RFC: https://wiki.php.net/rfc/spread_operator_for_array

Closes GH-3640.
2019-05-13 14:42:43 +02:00
Dmitry Stogov
d4bef4ce7b Avoid useless code duplication, because of unused specialization 2019-02-15 17:49:39 +03:00
Zeev Suraski
a81202ac49 Adios, yearly copyright ranges 2019-01-30 11:48:28 +01:00
Nikita Popov
a50198d0fe Implement ??= operator
RFC: https://wiki.php.net/rfc/null_coalesce_equal_operator

$a ??= $b is $a ?? ($a = $b), with the difference that $a is only
evaluated once, to the degree that this is possible. In particular
in $a[foo()] ?? $b function foo() is only ever called once.
However, the variable access themselves will be reevaluated.
2019-01-22 11:12:04 +01:00
Nikita Popov
e219ec144e Implement typed properties
RFC: https://wiki.php.net/rfc/typed_properties_v2

This is a squash of PR #3734, which is a squash of PR #3313.

Co-authored-by: Bob Weinand <bobwei9@hotmail.com>
Co-authored-by: Joe Watkins <krakjoe@php.net>
Co-authored-by: Dmitry Stogov <dmitry@zend.com>
2019-01-11 15:49:06 +01:00
Michael Moravec
f5044a12dd Implement ZEND_ARRAY_KEY_EXISTS opcode to speed up array_key_exists() 2018-12-26 23:54:11 +03:00
Zeev Suraski
54dc07f3dc Update email addresses. We're still @Zend, but future proofing it... 2018-11-01 17:20:07 +02:00
Dmitry Stogov
d140df58e6 Keep information about unresolved interfaces in zend_class_entry->interface_names.
Move interface implementation code into ZEND_DECLARE_*CLASS opcodes.
Remove ZEND_ADD_INTERFACE and ZEND_VERIFY_ABSTRACT_CLASS opcodes.
2018-08-23 17:16:28 +03:00
Dmitry Stogov
67397970b2 Replace zend_class_entry->traits by persistent zend_class_entry->trait_names.
Move trait binding code into ZEND_DECLARE_*CLASS opcodes.
Remove ZEND_ADD_TRIAIT and ZEND_BIND_TRAITS opcodes.
2018-08-23 02:02:26 +03:00
Dmitry Stogov
6d88e1ccd6 Don't use second operand of BIND_STATIC instruction. 2018-08-21 12:22:04 +03:00
Xinchen Hui
fd463a9a60 Fixed bug #76752 (Crash in ZEND_COALESCE_SPEC_TMP_HANDLER - assertion in _get_zval_ptr_tmp failed). 2018-08-17 12:19:31 +08:00
Dmitry Stogov
f950128cd6 Encode parent class name as IS_CONST operand in DECLARE_INHERITED_CLASS and DECLARE_ANON_INHERITED_CLASS opcodes (eliminate FETCH_CLAS
S opcode).
2018-07-25 13:40:47 +03:00
Dmitry Stogov
1597b56619 Inline few small opcode handlers into hybrid executor 2018-06-07 16:30:53 +03:00
Nikita Popov
b0af9ac733 Avoid live range references in opcodes
Don't store the live range of the freed variable for FREE_ON_RETURN
frees, instead look it up at runtime. As this is an extremely
unlikely codepath (in particular, it requires a loop variable with
a throwing destructor), saving the runtime lookup of the live range
is not worth the extra complexity this adds everywhere else.
2018-02-16 21:30:48 +01:00
Haitao Lv
5206f79987
fix unknown opcode overflow error 2018-02-12 09:27:55 +01:00
Dmitry Stogov
ca035f26aa Moved "zval.u2.cache_slot" into free room of "zend_op" 2018-02-05 19:41:47 +03:00
Dmitry Stogov
3a794d39f0 Avoid repeatable ARG_SHOULD_BE_SENT_BY_REF() checks in FETCH_*FUNC_ARG and following SEND_VAR_EX. Perform the check once in a new CHECK_FUNC_ARG opcode and reuse in the following FETCH_*FUNC_ARG and SEND_FUNC_ARG (SEND_VAR_EX replacement). 2018-02-05 19:40:06 +03:00
Dmitry Stogov
ba298725d1 Changed CATCH instruction format (extended_value moved into op2, op2 into result, result into extended_value) 2018-01-31 22:39:30 +03:00
Dmitry Stogov
9c7fb529ce Changed FETCH_CONSTANT instruction format (extended_value moved into op1) 2018-01-31 18:15:25 +03:00
Dmitry Stogov
f67f455ef7 Changed FETCH_CLASS instruction format (extended_value moved into op1) 2018-01-31 18:14:43 +03:00
Dmitry Stogov
267b78550e Use fastcall calling convention 2018-01-16 10:33:41 +03:00
Xinchen Hui
a6519d0514 year++ 2018-01-02 12:57:58 +08:00
Dmitry Stogov
5c8f8f8fce Use ZEND_FAST_CONCAT instead of ZEND_CONCAT for CONST operands. 2017-12-29 13:54:18 +03:00
Dmitry Stogov
f010423335 Use IS_EQUAL instead of CASE when first operand is CV or CONST. Removed CASE handlers that duplicated IS_EQUAL. 2017-12-29 12:57:58 +03:00
Dmitry Stogov
27206f9cc5 Removed useless specialization 2017-12-29 12:02:50 +03:00
Dmitry Stogov
66a604171c Array addition is not commutative 2017-12-15 14:40:19 +03:00
Dmitry Stogov
588f1df7a2 Remove duplicate handlers for commutative operations 2017-12-15 13:42:54 +03:00
David Walker
6d4de4cf05 Implement list() reference assignments
Support list() reference assignments of the form:

    list(&$a, list(&$b, $c)) = $d;

RFC: https://wiki.php.net/rfc/list_reference_assignment
2017-12-09 13:39:52 +01:00