Skip to content

Commit

Permalink
Implemented preloading RFC: https://wiki.php.net/rfc/preload.
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 106c815
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Nov 14 16:36:44 2018 +0300

    Added NEWS entry

commit 1dacd5e
Merge: d516139 ba99aa1
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Nov 14 16:33:37 2018 +0300

    Merge branch 'master' into preload

    * master:
      Fixed issues related to optimization and persitence of classes linked with interfaces, traits or internal classes.
      Added possiblity to avoid signal handlers reinitialization on each request.

commit d516139
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Nov 14 16:13:15 2018 +0300

    Override opcache.preload for testing

commit 162b154
Merge: 45fdd03 8bda225
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Nov 14 15:38:09 2018 +0300

    Merge branch 'master' into preload

    * master: (34 commits)
      Eliminate useless $this related check
      Eliminate useless $this related checks
      Replace zend_parse_method_parameters() by zend_parse_parameters() and avoid useless checks.
      Replace getThis() by EX(This), when additional check is not necessary.
      Fixed tests
      Validate length on socket_write
      Fix compilation on x32
      Fix #77141: Signedness issue in SOAP when precision=-1
      Support SQLite3 @name notation
      Remove lexer files generated by RE2C
      Update libmagic.patch [ci skip]
      Update libmagic.patch [ci skip]
      Fork test with pcre.jit=0
      Rework magic data
      Fix regex
      Fix regex
      Rework magic data
      Sync one more upstream libmagic piece
      Suppress already used warning
      Ignore getaddrinfo failed message
      ...

commit 45fdd03
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Nov 9 13:07:03 2018 +0300

    Properly resolve magic method of preloaded classes inherited from internal ones.

commit 34645ae
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Nov 8 15:29:17 2018 +0300

    Don't preload constants defined during preload script excution.

commit cef0d67
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Nov 7 15:56:54 2018 +0300

    Support for class aliasses

commit 08ffc9a
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Nov 7 15:34:39 2018 +0300

    Resolve constants only in linked classes

commit 8d3429c
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue Nov 6 11:56:39 2018 +0300

    Fixed preloading of references to internal classes.

commit 7ae3a47
Merge: 9b0a53e 049f239
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue Nov 6 11:37:15 2018 +0300

    Merge branch 'master' into preload

    * master:
      Update NEWS [ci skip]
      Update NEWS [ci skip]
      Update libmagic.patch [ci skip]
      Update libmagic.patch [ci skip]
      Declare function proto in header
      Declare function proto in header
      Fix #76825: Undefined symbols ___cpuid_count
      NEWS
      Fix: #77110 undefined symbol zend_string_equal_val in C++ build
      Fix #77105: Use position:sticky for <th> in `phpinfo()`
      Implement handling for JIT recognition when cross compiling
      Backport 7f5f460 for 7.2
      Fix #76348: WSDL_CACHE_MEMORY causes Segmentation fault
      Rework places in libmagic regarding previous CVE-2014-3538 fixes
      Change the way JIT availability is checked
      Fix a test for ldap extension
      Fixed bug #77092
      Future-proof email addresses

commit 9b0a53e
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Nov 2 14:54:44 2018 +0300

    We don't need preload_restart() here

commit 0bd17bd
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Nov 2 14:44:30 2018 +0300

    EG(*) may be not initializd at this point - use CG(*).

commit b610467
Merge: 3a9d90f 67e0138
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Nov 2 11:33:37 2018 +0300

    Merge branch 'master' into preload

    * master:
      Future-proof email addresses...
      Update email addresses.  We're still @zend, but future proofing it...

commit 3a9d90f
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Nov 1 15:19:48 2018 +0300

    Fexed resolution of method clones

commit aea85c6
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Nov 1 11:45:50 2018 +0300

    Prevent inlining of method copied from trait

commit 36b644f
Merge: 7a20781 b91690c
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Nov 1 10:56:02 2018 +0300

    Merge branch 'master' into preload

    * master:
      Fix stray newline that caused this test to fail
      Fix session tests that fail if error_log is set
      This test needs to log to stdout
      Fix error condition
      Fixed bug #77081 ftruncate() changes seek pointer in c mode
      Fix and improve test case

commit 7a20781
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Oct 31 00:52:46 2018 +0300

    Added test

commit 4a57b5d
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Oct 31 00:50:21 2018 +0300

    Fixed preloading of classes linked with traits

commit 68c4f99
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue Oct 30 16:25:14 2018 +0300

    Added test

commit 38ab7ef
Merge: eb6e2c5 bf38e6c
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue Oct 30 16:14:39 2018 +0300

    Merge branch 'master' into preload

    * master:
      Keep original value of "prototype"

commit eb6e2c5
Merge: 5620495 2fefa8c
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue Oct 30 15:35:39 2018 +0300

    Merge branch 'master' into preload

    * master:
      Call function_add_ref() in proper place
      Updated to version 2018.7 (2018g)
      Updated to version 2018.7 (2018g)
      Updated to version 2018.7 (2018g)
      Reslove inherited op_array references once afrer all optimizations.

commit 5620495
Merge: e806cb7 4828fb7
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue Oct 30 10:29:49 2018 +0300

    Merge branch 'master' into preload

    * master:
      [ci skip] Update NEWS
      [ci skip] Update NEWS
      [ci skip] Update NEWS
      fix bug #77079
      Add missing null initialization
      Remove redundant mbfl_string_init calls
      Use zend_string for mbstring last encoding cache

commit e806cb7
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Mon Oct 29 22:32:15 2018 +0300

    Fixed double-free

commit 2f697ef
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Mon Oct 29 22:07:32 2018 +0300

    typo

commit c559f22
Merge: 310631c ea2e678
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Mon Oct 29 21:59:27 2018 +0300

    Merge branch 'master' into preload

    * master:
      Stop Apache if PHP wasn't started successful.
      Execute zend_post_startup() with module_initialized flag set.
      Removed dead code
      Fix mb_strrpos() with encoding passed as 3rd param

commit 310631c
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Mon Oct 29 16:48:42 2018 +0300

    Stop Apache if PHP wasn't started successful.

commit 0a24d7b
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Mon Oct 29 16:25:49 2018 +0300

    Avoid use-after-free in main thread

commit 17a3cb4
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Mon Oct 29 15:25:17 2018 +0300

    Execute zend_post_startup() with module_initialized flag set.

commit 6d4b22c
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Mon Oct 29 14:12:20 2018 +0300

    Override SAPI.ub_write and SAPI.flush for preloading

commit 386c9d3
Merge: d7fbb4d 359f19e
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Mon Oct 29 13:49:24 2018 +0300

    Merge branch 'master' into preload

    * master:
      Optimize substr() edge-case conditions
      [ci skip] Update UPGRADING
      Fix #71592: External entity processing never fails
      Add TIDY_TAG_* constants supported by libtidy 5
      Add is_iterable to opcache Optimizer

commit d7fbb4d
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Oct 26 13:11:54 2018 +0300

    Restore preload state if it was already loaded in another process.

commit 0fe9ea1
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Oct 26 12:29:06 2018 +0300

    Removed dead code

commit 3a2d1bc
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Oct 26 00:19:40 2018 +0300

    Support for builds without ZEND_SIGNALS

commit e6b76ec
Merge: 4531fbf 68694c9
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Oct 25 23:43:25 2018 +0300

    Merge branch 'master' into preload

    * master:
      Don't wrap php_module_shutdown() with zend_try. executor_globals are released in ZTS build, and this leads to crash.
      [ci skip] Fix indentation in UPGRADING.

commit 4531fbf
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Oct 25 22:44:49 2018 +0300

    Disable linking and preloading of classes those parent or one of interface or trait is an internal class.

commit a594a61
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Oct 25 22:30:51 2018 +0300

    Cleanup

    - remove useless ZCSG(saved_map_ptr_last)
    - move preloaded classes/functions clean-up code back into better place

commit ab9a40f
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Oct 25 20:52:51 2018 +0300

    Added support for preloaded classes/functions in ZTS build

commit e3c65db
Merge: 4f57c1e 33e777a
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Oct 25 20:52:26 2018 +0300

    Merge branch 'master' into preload

    * master:
      Improved shared interned strings handling. The previous implementation worked incorrectly in ZTS build. It changed strings only in function/class tables of one thread. Now all threads gets the same shared interned strings. Also, on shutdown, we don't try to replace SHM interned strings back to process strings, but delay dettachment of SHM instead.
      Don't use request heap at shutdown
      Don't optimize function if inference failed
      Fixed bug #77058
      Improve "narrowing" error message
      bump versions

commit 4f57c1e
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Oct 25 15:29:58 2018 +0300

    Cleanup (move preload_shutdown() call to better place)

commit 26587a9
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Oct 25 14:30:51 2018 +0300

    eol

commit d70cb10
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Oct 25 14:30:20 2018 +0300

    cleanup

commit aabe685
Merge: d9fc51b 40808ac
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Oct 25 12:42:51 2018 +0300

    Merge branch 'master' into preload

    * master:
      Remove unused var
      Remove ext/json parser files generated by bison
      Fix run-tests.php for running phpdbg and certain test sections
      Normalize .gitignore

commit d9fc51b
Merge: b5ffba0 b6ef899
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Oct 24 15:59:24 2018 +0300

    Merge branch 'master' into preload

    * master:
      Fixed reseting of interned strings buffer.

commit b5ffba0
Merge: e4a7ef0 a404383
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Oct 24 12:46:28 2018 +0300

    Merge branch 'master' into preload

    * master:
      Fixed build in directory different from source

commit e4a7ef0
Merge: 811f20a d1e14e2
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Oct 24 11:59:43 2018 +0300

    Merge branch 'master' into preload

    * master: (29 commits)
      Make php_plain_files_wrapper to be writable (workaround for swoole)
      Remove phpdbg parser files generated by bison
      Fix conflicts in phpdbg parser
      Refetetch function name on exceptional path to allow better code on fast code path.
      fix typo in sysvsem.c
      Fixed bug #50675
      bump to 7.2.13-dev
      [ci skip] Update NEWS wrt. php-7.3.0RC4 tagging
      Inlining in the most frequently used code paths
      Fixed test failurs introduced by 9c144e0
      Use persistent strings only for persistent connections
      Fix accessibility checks for dynamic properties
      Updated to version 2018.6 (2018f)
      Updated to version 2018.6 (2018f)
      Updated to version 2018.6 (2018f)
      Fix arginfo and clean up fpm_get_status
      Defragment two Zend related Makefile fragments together
      [ci skip] Remove automake and aclocal in comments
      Fix #75282: xmlrpc_encode_request() crashes
      Fix tests for ICU 63.1
      ...

commit 811f20a
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Mon Oct 22 14:10:49 2018 +0300

    Added information about preloading to opcache_get_status()

commit 093e8b1
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Oct 19 13:46:23 2018 +0300

    Added warning message

commit a2ba970
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Oct 19 13:35:40 2018 +0300

    Added test

commit b67e283
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Oct 19 13:33:12 2018 +0300

    Don't preload functions declared at run-time.

commit b0139dc
Merge: a609520 3fe698b
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Oct 19 13:23:14 2018 +0300

    Merge branch 'master' into preload

    * master:
      Mark "top-level" functions.
      Don't initialize static_member_tables during start-up, when inherit internal classes.
      [ci skip] Update NEWS
      [ci skip] Update NEWS
      [ci skip] Update NEWS
      Fix #77035: The phpize and ./configure create redundant .deps file
      Remove outdated PEAR artefacts
      Fix tests/output/bug74815.phpt generating errors.log
      Revert "Use C++ symbols, when C++11 or upper is compiled"
      Use C++ symbols, when C++11 or upper is compiled
      Added new line
      Remove stamp-h
      Move all testing docs to qa.php.net
      Fix a typo in UPGRADING.INTERNALS
      Fix test when it's run on another drive
      [ci skip] Update UPGRADING wrt. tidyp support
      Fixed incorrect reallocation
      Fix #77027: tidy::getOptDoc() not available on Windows
      Run CI tests under opcache.protect_memory=1

commit a609520
Merge: ac8f45f b6ac50f
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Oct 17 17:01:05 2018 +0300

    Merge branch 'master' into preload

    * master:
      Fixed comment
      Micro optimizations
      Mark "top-level" classes

commit ac8f45f
Merge: 632b30b d57cd36
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Oct 17 15:53:41 2018 +0300

    Merge branch 'master' into preload

    * master:
      Immutable clases and op_arrays.

commit 632b30b
Merge: d33908a cd0c36c
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Oct 17 15:04:43 2018 +0300

    Merge branch 'immutable' into preload

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

commit cd0c36c
Merge: 4740dab ad6738e
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 d33908a
Merge: 21e0beb 4740dab
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Oct 17 14:14:23 2018 +0300

    Merge branch 'immutable' into preload

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

commit 4740dab
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 21e0beb
Merge: c78277a ad7a78b
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Oct 17 12:29:59 2018 +0300

    Merge branch 'immutable' into preload

    * immutable:
      Added comment
      Added type cast
      Moved static class members initialization into the proper place.
      Removed redundand assertion
      Removed duplicate code
      Hide offset encoding magic in ZEND_MAP_PTR_IS_OFFSET(), ZEND_MAP_PTR_OFFSET2PTR() and ZEND_MAP_PTR_PTR2OFFSET() macros.
      typo
      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 ad7a78b
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Oct 17 11:46:30 2018 +0300

    Added comment

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

    Added type cast

commit c63fc5d
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 b945548
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Oct 17 11:21:03 2018 +0300

    Removed redundand assertion

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

    Removed duplicate code

commit 8dadca8
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 9ef07c8
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Oct 17 10:48:29 2018 +0300

    typo

commit a06f0f3
Merge: 9409958 3412345
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 c78277a
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue Oct 16 17:25:35 2018 +0300

    Preloadsing support for opcache restart

commit f76a955
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue Oct 16 13:52:36 2018 +0300

    Fixed incorrect signal handlers overriding

commit 0810ce0
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Mon Oct 15 23:38:48 2018 +0300

    An attempt to implemnt "preloading" ability.

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

    Immutable clases and op_arrays
  • Loading branch information
dstogov committed Nov 14, 2018
1 parent ba99aa1 commit f6d227e
Show file tree
Hide file tree
Showing 12 changed files with 1,167 additions and 4 deletions.
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ PHP NEWS
. Changed default of $variant parameter of idn_to_ascii() and idn_to_utf8().
(cmb)

- Opcache:
. Implemented preloading RFC: https://wiki.php.net/rfc/preload. (Dmitry)

- PDO_OCI:
. Implemented FR #76908 (PDO_OCI getColumnMeta() not implemented).
(Valentin Collet, Chris Jones, Remi)
Expand Down
10 changes: 9 additions & 1 deletion Zend/zend.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,13 @@ static void auto_global_dtor(zval *zv) /* {{{ */
static void function_copy_ctor(zval *zv) /* {{{ */
{
zend_function *old_func = Z_FUNC_P(zv);
zend_function *func = pemalloc(sizeof(zend_internal_function), 1);
zend_function *func;

if (old_func->type == ZEND_USER_FUNCTION) {
ZEND_ASSERT(old_func->op_array.fn_flags & ZEND_ACC_IMMUTABLE);
return;
}
func = pemalloc(sizeof(zend_internal_function), 1);
Z_FUNC_P(zv) = func;
memcpy(func, old_func, sizeof(zend_internal_function));
function_add_ref(func);
Expand Down Expand Up @@ -977,14 +982,17 @@ int zend_post_startup(void) /* {{{ */

zend_destroy_rsrc_list(&EG(persistent_list));
free(compiler_globals->function_table);
compiler_globals->function_table = NULL;
free(compiler_globals->class_table);
compiler_globals->class_table = NULL;
if ((script_encoding_list = (zend_encoding **)compiler_globals->script_encoding_list)) {
compiler_globals_ctor(compiler_globals);
compiler_globals->script_encoding_list = (const zend_encoding **)script_encoding_list;
} else {
compiler_globals_ctor(compiler_globals);
}
free(EG(zend_constants));
EG(zend_constants) = NULL;

executor_globals_ctor(executor_globals);
global_persistent_list = &EG(persistent_list);
Expand Down
43 changes: 43 additions & 0 deletions Zend/zend_execute_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,56 @@ void shutdown_executor(void) /* {{{ */
destroy_op_array(&func->op_array);
zend_string_release_ex(key, 0);
} ZEND_HASH_FOREACH_END_DEL();

/* Cleanup preloaded immutable functions */
ZEND_HASH_REVERSE_FOREACH_VAL(EG(function_table), zv) {
zend_op_array *op_array = Z_PTR_P(zv);
if (op_array->type == ZEND_INTERNAL_FUNCTION) {
break;
}
ZEND_ASSERT(op_array->fn_flags & ZEND_ACC_IMMUTABLE);
if (op_array->static_variables) {
HashTable *ht = ZEND_MAP_PTR_GET(op_array->static_variables_ptr);
if (ht) {
ZEND_ASSERT(GC_REFCOUNT(ht) == 1);
zend_array_destroy(ht);
}
}
} ZEND_HASH_FOREACH_END();

ZEND_HASH_REVERSE_FOREACH_STR_KEY_VAL(EG(class_table), key, zv) {
if (_idx == EG(persistent_classes_count)) {
break;
}
destroy_zend_class(zv);
zend_string_release_ex(key, 0);
} ZEND_HASH_FOREACH_END_DEL();

/* Cleanup preloaded immutable classes */
ZEND_HASH_REVERSE_FOREACH_VAL(EG(class_table), zv) {
zend_class_entry *ce = Z_PTR_P(zv);
if (ce->type == ZEND_INTERNAL_CLASS) {
break;
}
ZEND_ASSERT(ce->ce_flags & ZEND_ACC_IMMUTABLE);
if (ce->default_static_members_count) {
zend_cleanup_internal_class_data(ce);
}
if (ce->ce_flags & ZEND_HAS_STATIC_IN_METHODS) {
zend_op_array *op_array;
ZEND_HASH_FOREACH_PTR(&ce->function_table, op_array) {
if (op_array->type == ZEND_USER_FUNCTION) {
if (op_array->static_variables) {
HashTable *ht = ZEND_MAP_PTR_GET(op_array->static_variables_ptr);
if (ht) {
ZEND_ASSERT(GC_REFCOUNT(ht) == 1);
zend_array_destroy(ht);
}
}
}
} ZEND_HASH_FOREACH_END();
}
} ZEND_HASH_FOREACH_END();
}

zend_cleanup_internal_classes();
Expand Down
4 changes: 3 additions & 1 deletion Zend/zend_opcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,9 @@ void zend_class_add_ref(zval *zv)
{
zend_class_entry *ce = Z_PTR_P(zv);

ce->refcount++;
if (!(ce->ce_flags & ZEND_ACC_IMMUTABLE)) {
ce->refcount++;
}
}

ZEND_API void destroy_op_array(zend_op_array *op_array)
Expand Down
Loading

0 comments on commit f6d227e

Please sign in to comment.