Commit Graph

974 Commits

Author SHA1 Message Date
Dmitry Stogov
60dca2295d Initialize static_members_table 2019-07-22 12:02:16 +03:00
Dmitry Stogov
9a833438d1 Delay EG(exception) check on slow path 2019-07-08 13:56:34 +03:00
Nikita Popov
3698303540 Fix arginfo leak in disable_functions
Arginfo is allocated if types are used, we need to free it.
2019-06-28 16:38:46 +02:00
Nikita Popov
8f8fcbbd39 Support full variance if autoloading is used
Keep track of delayed variance obligations and check them after
linking a class is otherwise finished. Obligations may either be
unresolved method compatibility (because the necessecary classes
aren't available yet) or open parent/interface dependencies. The
latter occur because we allow the use of not fully linked classes
as parents/interfaces now.

An important aspect of the implementation is we do not require
classes involved in variance checks to be fully linked in order for
the class to be fully linked. Because the involved types do have to
exist in the class table (as partially linked classes) and we do
check these for correct variance, we have the guarantee that either
those classes will successfully link lateron or generate an error,
but there is no way to actually use them until that point and as
such no possibility of violating the variance contract. This is
important because it ensures that a class declaration always either
errors or will produce an immediately usable class afterwards --
there are no cases where the finalization of the class declaration
has to be delayed until a later time, as earlier variants of this
patch did.

Because variance checks deal with classes in various stages of
linking, we need to use a special instanceof implementation that
supports this, and also introduce finer-grained flags that tell us
which parts have been linked already and which haven't.

Class autoloading for variance checks is delayed into a separate
stage after the class is otherwise linked and before delayed
variance obligations are processed. This separation is needed to
handle cases like A extends B extends C, where B is the autoload
root, but C is required to check variance. This could end up
loading C while the class structure of B is in an inconsistent
state.
2019-06-11 13:09:33 +02: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
Joe Watkins
ff96f25b12
Revert "Fix bug #62397 - disable_functions does not work with eval."
This reverts commit 050d299364.
2019-06-03 11:20:12 +02:00
Dmitry Stogov
1df9f238fe Better hot/cold code splitting 2019-05-31 12:20:21 +03:00
Dmitry Stogov
e14d77335c Mark "cold" functions 2019-05-29 11:48:41 +03:00
Joe Watkins
cc598d1ea9
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  disabled functions must not have return type
  Restore the execute bit for run-tests.php
2019-05-29 08:30:55 +02:00
Joe Watkins
6c73b2088a
Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  disabled functions must not have return type
2019-05-29 08:30:41 +02:00
Joe Watkins
7821cc3b9f
disabled functions must not have return type 2019-05-29 08:30:08 +02:00
Nikita Popov
e6fac86dc3 Accept flags argument in zend_lookup_class_ex()
Instead of a single boolean, so we have space for extension here.
2019-05-27 09:36:25 +02:00
Benjamin Eberlei
050d299364 Fix bug #62397 - disable_functions does not work with eval. 2019-05-14 23:49:55 +02:00
Nikita Popov
e9aa0337ab Fix more dl() interned string assertions 2019-04-18 12:14:07 +02:00
Nikita Popov
4aa78b67e7 Merge branch 'PHP-7.3' into PHP-7.4 2019-04-18 12:10:09 +02:00
Nikita Popov
a5b7f3bd81 Fix more dl() interned string assertions 2019-04-18 12:08:09 +02:00
Nikita Popov
ed4c24274b Fix dl() module unloading in post deactivate
FOREACH_END_DEL() does not call the destructor by itself, we need to
explicitly call it. Due to the missing dtor call the functions were
not unregistered early, which resulted in later shutdown segfaults.
2019-04-18 10:10:15 +02:00
Dmitry Stogov
93c6a32b7c Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed dl() function. It failed in DEBUG build without opcache because of assert during string interning.
2019-04-17 19:32:34 +03:00
Dmitry Stogov
ac12cc85aa Fixed dl() function. It failed in DEBUG build without opcache because of assert during string interning. 2019-04-17 19:31:28 +03:00
Dmitry Stogov
a1b7ccdfc6 Fixed bug #77877 (call_user_func() passes $this to satatic methods). 2019-04-11 14:24:04 +03:00
Nikita Popov
abc457fe1d Fixed bug #74345
Export zend_release_fcall_info_cache(). It is only necessary to
call it if the fcc may not have been used -- if it is passed to
zend_call_function() and friends, then they will take care of
freeing trampolines.
2019-03-20 12:06:42 +01:00
Nikita Popov
ac79d42ba6 Free trampolines from get_closure in is_callable
Also extract this logic into a function, as it's duplicated a few times.
2019-03-11 14:00:33 +01:00
Dmitry Stogov
2ed013c38a Use "quick" macro variants for known argument numbers 2019-02-18 17:52:33 +03:00
Nikita Popov
3cafa7f4df Assign (un)serialize_func during compilation
This avoids writing this cache at runtime, which is illegal if
preloading is used.

Not every serialize/unserialize function actually belongs to the
Serializable interface, but I think it's not a problem to assign
these anyway -- whether they are used ultimately depends on whether
Serializable is implemented.

Alternatively it might make sense to just drop these entirely. I
don't think this is performance critical functionality.
2019-02-15 11:20:28 +01:00
Dmitry Stogov
43a7d95016 Fixed bug #77613 (method visibility change) (reverted ZEND_ACC_CTOR and ZEND_ACC_DTOR flags removal) 2019-02-14 13:12:50 +03:00
Peter Kokot
92ac598aab Remove local variables
This patch removes the so called local variables defined per
file basis for certain editors to properly show tab width, and
similar settings. These are mainly used by Vim and Emacs editors
yet with recent changes the once working definitions don't work
anymore in Vim without custom plugins or additional configuration.
Neither are these settings synced across the PHP code base.

A simpler and better approach is EditorConfig and fixing code
using some code style fixing tools in the future instead.

This patch also removes the so called modelines for Vim. Modelines
allow Vim editor specifically to set some editor configuration such as
syntax highlighting, indentation style and tab width to be set in the
first line or the last 5 lines per file basis. Since the php test
files have syntax highlighting already set in most editors properly and
EditorConfig takes care of the indentation settings, this patch removes
these as well for the Vim 6.0 and newer versions.

With the removal of local variables for certain editors such as
Emacs and Vim, the footer is also probably not needed anymore when
creating extensions using ext_skel.php script.

Additionally, Vim modelines for setting php syntax and some editor
settings has been removed from some *.phpt files.  All these are
mostly not relevant for phpt files neither work properly in the
middle of the file.
2019-02-03 21:03:00 +01:00
Zeev Suraski
a81202ac49 Adios, yearly copyright ranges 2019-01-30 11:48:28 +01:00
Dmitry Stogov
fd41b99d58 Merge branch 'PHP-7.3'
* PHP-7.3:
  Fixed bug #77494 (Disabling class causes segfault on member access)
2019-01-24 13:08:00 +03:00
Dmitry Stogov
aa9a8dbda3 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fixed bug #77494 (Disabling class causes segfault on member access)
2019-01-24 13:07:31 +03:00
Dmitry Stogov
73f222d722 Fixed bug #77494 (Disabling class causes segfault on member access) 2019-01-24 13:06:36 +03:00
Dmitry Stogov
e6182bd4ea Improved ZEND_TRY_ASSIGN... API to avoid unnecessary double copying and reduce code bloat. 2019-01-18 00:53:48 +03: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
Dmitry Stogov
493f830355 Reuse add_property_zval_ex() instead of code duplication 2018-12-19 17:24:56 +03:00
Dmitry Stogov
d356f6d72b Removed add_get_assoc_*() and add_get_index_*() API functions 2018-12-19 16:47:48 +03:00
Dmitry Stogov
85e1df6fdc Replace add_index_zval() and add_next_index_zval() functions by macros 2018-12-19 16:43:38 +03:00
Dmitry Stogov
cec091176c Replace zend_hash_apply... with ZEND_HASH_FOREACH... 2018-12-19 02:49:56 +03:00
Zeev Suraski
9afce019e0 Future-proof email addresses 2018-11-01 18:35:32 +02: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
6f91090f6a Inlining in the most frequently used code paths 2018-10-23 12:46:44 +03:00
Dmitry Stogov
d57cd36e47 Immutable clases and op_arrays.
Squashed commit of the following:

commit cd0c36c3f9
Merge: 4740dabb84 ad6738e886
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Oct 17 14:43:38 2018 +0300

    Merge branch 'master' into immutable

    * master:
      Remove the "auto" encoding
      Fixed bug #77025
      Add vtbls for EUC-TW encoding

commit 4740dabb84
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Oct 17 14:12:28 2018 +0300

    Reverted back ce->iterator_funcs_ptr. Initialize ce->iterator_funcs_ptr fields in immutable classes.

commit ad7a78b253
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Oct 17 11:46:30 2018 +0300

    Added comment

commit 0276ea5187
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Oct 17 11:42:43 2018 +0300

    Added type cast

commit c63fc5d5f1
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Oct 17 11:36:51 2018 +0300

    Moved static class members initialization into the proper place.

commit b945548e93
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Oct 17 11:21:03 2018 +0300

    Removed redundand assertion

commit d5a4108840
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Oct 17 11:19:13 2018 +0300

    Removed duplicate code

commit 8dadca8864
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Oct 17 11:05:43 2018 +0300

    Hide offset encoding magic in ZEND_MAP_PTR_IS_OFFSET(), ZEND_MAP_PTR_OFFSET2PTR() and ZEND_MAP_PTR_PTR2OFFSET() macros.

commit 9ef07c88bd
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Oct 17 10:48:29 2018 +0300

    typo

commit a06f0f3d3a
Merge: 94099586ec 3412345ffe
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Oct 17 10:47:07 2018 +0300

    Merge branch 'master' into immutable

    * master:
      Remove unused variable makefile_am_files
      Classify object handlers are required/optional
      Add support for getting SKIP_TAGSTART and SKIP_WHITE options
      Remove some obsolete config_vars.mk occurrences
      Remove bsd_converted from .gitignore
      Remove configuration parser and scanners ignores
      Remove obsolete buildconf.stamp from .gitignore
      [ci skip] Add magicdata.patch exception to .gitignore
      Remove outdated ext/spl/examples items from .gitignore
      Remove unused test.inc in ext/iconv/tests

commit 94099586ec
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Mon Oct 15 23:34:01 2018 +0300

    Immutable clases and op_arrays
2018-10-17 15:52:50 +03:00
Nikita Popov
1cfbb21790 Classify object handlers are required/optional 2018-10-16 20:53:59 +02:00
Peter Kokot
902d39a3a7 Trim trailing whitespace in source code files 2018-10-13 14:14:50 +02:00
Dmitry Stogov
a2e8334613 Allocate only necessary space for static properties of internal classes in ZTS mode. 2018-10-01 19:05:31 +03:00
Dmitry Stogov
b634ded197 Class constants and default property values can't be IS_REFERENCE anymore. 2018-09-18 18:46:10 +03:00
Dmitry Stogov
689c6fb188 Replace ZEND_ACC_ANON_BOUND, ZEND_ACC_UNRESOLVED_PARENT and ZEND_ACC_UNRESOLVED_INTERFACES with single ZEND_ACC_LINKED. 2018-09-18 11:41:40 +03:00
Peter Kokot
b189c2432a Remove HAVE_STDARG_H
The C89 standard and later defines the `<stdarg.h>` header as part of
the standard headers [1]. On current systems it is always present and
can be included unconditionally.

Checking for presence and functionality of the `<stdarg.h>` header and
variadic function is not relevant anymore on current systems since this
is always available.

Also Autoconf suggests relying on at least C89 or above [2] and [3].

The following files were regenerated with re2c 1.0.3:
- Zend/zend_language_scanner.c
- Zend/zend_language_scanner_defs.h

Refs:
[1] https://port70.net/~nsz/c/c89/c89-draft.html#4.1.2
[2] http://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/headers.m4
[3] https://www.gnu.org/software/autoconf/manual/autoconf-2.69/autoconf.html
2018-09-18 05:44:56 +02:00
Nikita Popov
dfa166e7ed Remove unused ZEND_FILE_LINE in i_zval_ptr_dtor 2018-09-16 17:16:26 +02:00
Dmitry Stogov
72bf2def6b Make visibilty check in is_callable() to be consistent with zend_std_get_method() 2018-09-13 12:24:59 +03:00
Dmitry Stogov
8939c4d96b Get rid of ZEND_ACC_CTOR, ZEND_ACC_DTOR and ZEND_ACC_IMPLEMENTED_ABSTRACT 2018-09-05 13:16:10 +03:00
Massimiliano Braglia
2527a0fcfd Fixed bug #75797
Fix zend_register_class_alias_ex() to use non-persistent strings
for (non-persistent) userland classes.
2018-08-22 13:39:08 +02:00