Commit Graph

1569 Commits

Author SHA1 Message Date
Nikita Popov
f841388781 Don't autoload when checking property types
Noticed while working on union types: We do not load argument and
return types during type checks, but we do load property types.

I'm normalizing the behavior towards the existing status quo (not
loading), though we may consider loading everywhere (all types,
and instanceof) in order to properly support class aliases.
2019-10-23 12:21:30 +02:00
Nikita Popov
5a076e670a Return error_zval form get_property_ptr_ptr on exception
This goes in the reverse direction of 4463acb951.
After looking around a bit, it seems that we already check for
Z_ISERROR_P() on the get_property_ptr_ptr return value in other places.
So do this in zend_fetch_property_address() as well, and also make
sure that EG(error_zval) is indeed returned on exception in
get_property_ptr_ptr.

In particular, this fixes the duplicate exceptions that we used to
get because first get_property_ptr_ptr threw one and then
read_property throws the same exception again.
2019-10-10 15:14:04 +02:00
Nikita Popov
4463acb951 Explicitly check for exceptions in by-ref obj prop assign
Relying on setting ERROR if an exception happened during the
property address fetch is both a bit fragile and may pessimize
other codepaths that will check for exceptions in the VM. Adding
an extra exception check instead, which should also allow us to
drop the use of ERROR in this area in master.
2019-10-10 14:41:35 +02:00
Nikita Popov
382f9b28e8 Fix leak on "Cannot assign by reference to overloaded object" error 2019-10-10 10:07:54 +02:00
Nikita Popov
21148679d1 Handle "non well formed" exception during ZPP
Previously if the "non well formed" notice was converted into an
exception we'd still end up executing the function.

Also drop the now unnecessary EG(exception) checks in the engine.

Additionally remote a bogus exception in zend_is_callable: It
should only be writing to error, but not directly throwing.
2019-10-08 17:17:49 +02:00
Nikita Popov
ad3ddf46f9 Fixed bug #78644
Make sure the initialize the result of FETCH_OBJ_UNSET operations.
I'm using a NULL value rather than ERROR here, because the latter
no longer exists in master.
2019-10-08 14:32:49 +02:00
Dmitry Stogov
51d9f32dbe Fixed bug #78531 (Crash when using undefined variable as object 2019-09-13 01:42:02 +03:00
Dmitry Stogov
697266a84e Eliminate checks using ZEND_CONST_COND() macro 2019-09-12 18:29:19 +03:00
Nikita Popov
b6f76aca54 Improve exception handling for abstract/deprecated calls
Reuse existing arg freeing loop instead of duplicating it.

Additionally also handle deprecated in DO_FCALL_BY_NAME.
2019-09-04 15:19:21 +02:00
Nikita Popov
4bb7282742 Fix handling of abstract/deprecated exception
The exception mechanism assumes that exceptions from DO_FCALL are
already happening after the function call. This means that we are
currently leaking the passed arguments, and I think we can also
corrupt the VM stack due to incorrect frame linking in some cases
(there are assertion failures if the VM stack page size is reduced).

Instead handle the stack frame freeing manually for this special
case.
2019-09-04 12:46:00 +02:00
Dmitry Stogov
d1fd4607d0 Inline zend_zval_ptr() in executor explicitely (only on hot paths) 2019-08-06 16:28:42 +03:00
Nikita Popov
99d4b2bddc Mark _get_zval_ptr_deref as unused 2019-07-24 20:51:19 +02:00
Nikita Popov
9e4603f772 Try to fix macos build
By avoiding unused variable opline warnings. Also clean up the
replacement of ZEND_VM_SPEC -- we were sometimes treating it as
an always-defined constant with a value (what it actually is) and
sometimes as a conditionally defined constant (which it isn't, but
which still worked thanks to the specializer). Switch to only
treating it as a constant with a value.
2019-07-24 09:44:55 +02:00
Nikita Popov
0ba7c3eadf Deprecate array_key_exists() on objects 2019-07-22 11:39:52 +02:00
Dmitry Stogov
ee5828205e Separate "cold" and common unspecialized code 2019-07-17 00:52:26 +03:00
Nikita Popov
a0f450a023 Remove unused _get_zval_ptr_cv_BP_VAR_UNSET function
To fix the macos -Werror build.
2019-07-16 15:53:55 +02:00
Dmitry Stogov
1d4c38421a Delay IS_UNDEF checks 2019-07-16 11:16:45 +03:00
Dmitry Stogov
ef1a1a0698 Separate "cold" parts of comparison instructions 2019-07-11 20:44:39 +03:00
Nikita Popov
c42b7dd6d3 Throw notice on array access on illegal type
No notice is thrown for list() accesses, because we did not come
to an agreement regarding patterns like

    while ([$key, $value] = yield $it->next()) { ... }

where silent null access may be desirable.

No effort is made to suppress multiple notices in access chains
likes $x[0][0][0], because the technical complexity this causes
does not seem worthwhile.

RFC: https://wiki.php.net/rfc/notice-for-non-valid-array-container
2019-07-10 12:02:14 +02:00
Nikita Popov
2bca35eacc Rename support_strings to !is_list
In preparation for more behavior that depends on whether it it is
a list() access. Using support_strings for that would be
confusing.
2019-07-10 11:10:17 +02: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
09041151de Better optimization in RELEASE build. ZEND_ASSERT(s) prevented optimization 2019-07-03 20:19:56 +03:00
Dmitry Stogov
56b8b165f8 Optimization of INC/DEC helpers 2019-07-03 10:33:03 +03:00
Dmitry Stogov
baa883d3fc Fixed build without global register variables 2019-07-02 11:03:22 +03:00
Dmitry Stogov
cbbd473bdd Separate slow code 2019-07-02 01:16:34 +03:00
Dmitry Stogov
f2b6b2eee8 Micro-optimization 2019-07-01 16:57:25 +03:00
Dmitry Stogov
e1e8e670df Cleanup 2019-06-21 11:43:17 +03:00
Nikita Popov
eaafb69eea Change indexing scheme for symtable_cache
symtable_cache_ptr now points to the first unused symtable_cache
entry, rahter than the last used one. This avoids taking a pointer
to the minus first element of the array, which is UB. Instead we
take a pointer to the end plus one, which is not UB.
2019-06-20 16:21:39 +02:00
Nikita Popov
268b5fec8e Fixed bug #78182 2019-06-19 16:35:12 +02:00
Nikita Popov
b64107531b Fixed bug #78151 2019-06-13 09:37:30 +02:00
Joe Watkins
175c7bf6fe
Revert "micro-optimization"
This reverts commit 374f769982.
2019-06-12 20:04:47 +02:00
Nikita Popov
080e2316cf Mark some operand fetching funs as ATTRIBUTE_UNUSED
Whether these are used depends on VM specialization.
2019-06-12 13:17:25 +02:00
Dmitry Stogov
374f769982 micro-optimization 2019-06-10 16:43:20 +03:00
Nikita Popov
7780ba9660 Try to fix Windows build 2019-06-06 14:56:42 +02:00
Dmitry Stogov
a95014dc10 Reduce over-specialization for quite seldom instructions 2019-06-06 13:13:09 +03:00
Dmitry Stogov
457392fa64 Cheaper checks for exceptions thrown from __toString() 2019-06-06 01:47:22 +03:00
Nikita Popov
a31f46421d Allow exceptions in __toString()
RFC: https://wiki.php.net/rfc/tostring_exceptions

And convert some object to string conversion related recoverable
fatal errors into Error exceptions.

Improve exception safety of internal code performing string
conversions.
2019-06-05 14:25:07 +02:00
Dmitry Stogov
ee56552913 Disable "bad" optimisations only for emulation loop 2019-05-30 20:35:30 +03:00
Dmitry Stogov
b06f05bf47 zend_assign_to_variable() optimization 2019-05-29 13:58:37 +03:00
Dmitry Stogov
0d102515bf zend_do_fcall_overloaded() doesn't have to be exported 2019-05-29 10:32:30 +03:00
Dmitry Stogov
f9e8015847 Removed ability to compile PHP without EX(run_time_cache). ZEND_EX_USE_RUN_TIME_CACHE was always defined. 2019-05-15 11:06:26 +03:00
Peter Kokot
ec518aef10 Remove unused functions
- _get_zval_ptr_cv_deref_BP_VAR_UNSET
- _get_zval_ptr_cv_deref_BP_VAR_IS
- _get_zval_ptr_cv_deref_BP_VAR_RW
- _get_zval_ptr_cv_deref_BP_VAR_W
2019-05-09 19:07:24 +02:00
Peter Kokot
3c92b79ea0 Remove unused functions
- zend_mm_bitset_find_zero
- zend_mm_bitset_find_one
- zend_mm_bitset_find_zero_and_set
- zend_is_by_ref_func_arg_fetch
2019-05-08 22:02:39 +02:00
CrazyMiaoo
9df15fc26b Add gcc global register for aarch64 2019-04-22 14:29:30 +03:00
Dmitry Stogov
cb3cfc9ff8 Removed tests that always (or almost always) true 2019-04-15 13:18:16 +03:00
Dmitry Stogov
55cc280429 Backported call frame initialization improvement 2019-04-12 02:35:42 +03:00
Dmitry Stogov
88a2268d6b Replace "ZEND_CALL_CTOR" hack by additional live-range 2019-04-12 00:49:45 +03:00
Dmitry Stogov
fe0a0897ba Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Repare SWITCH VM
2019-04-09 01:17:10 +03:00
Markus Staab
87b62fe7bc
typo 2019-04-05 07:57:43 +02:00