mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Immutable clases and op_arrays.
Squashed commit of the following: commitcd0c36c3f9
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 commit4740dabb84
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. commitad7a78b253
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Oct 17 11:46:30 2018 +0300 Added comment commit0276ea5187
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Oct 17 11:42:43 2018 +0300 Added type cast commitc63fc5d5f1
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Oct 17 11:36:51 2018 +0300 Moved static class members initialization into the proper place. commitb945548e93
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Oct 17 11:21:03 2018 +0300 Removed redundand assertion commitd5a4108840
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Oct 17 11:19:13 2018 +0300 Removed duplicate code commit8dadca8864
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. commit9ef07c88bd
Author: Dmitry Stogov <dmitry@zend.com> Date: Wed Oct 17 10:48:29 2018 +0300 typo commita06f0f3d3a
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 commit94099586ec
Author: Dmitry Stogov <dmitry@zend.com> Date: Mon Oct 15 23:34:01 2018 +0300 Immutable clases and op_arrays
This commit is contained in:
parent
ad6738e886
commit
d57cd36e47
31 changed files with 838 additions and 348 deletions
|
@ -76,6 +76,7 @@ void init_op_array(zend_op_array *op_array, zend_uchar type, int initial_ops_siz
|
|||
op_array->last_live_range = 0;
|
||||
|
||||
op_array->static_variables = NULL;
|
||||
ZEND_MAP_PTR_INIT(op_array->static_variables_ptr, &op_array->static_variables);
|
||||
op_array->last_try_catch = 0;
|
||||
|
||||
op_array->fn_flags = 0;
|
||||
|
@ -83,8 +84,8 @@ void init_op_array(zend_op_array *op_array, zend_uchar type, int initial_ops_siz
|
|||
op_array->last_literal = 0;
|
||||
op_array->literals = NULL;
|
||||
|
||||
op_array->run_time_cache = NULL;
|
||||
op_array->cache_size = 0;
|
||||
ZEND_MAP_PTR_INIT(op_array->run_time_cache, NULL);
|
||||
op_array->cache_size = zend_op_array_extension_handles * sizeof(void*);
|
||||
|
||||
memset(op_array->reserved, 0, ZEND_MAX_RESERVED_RESOURCES * sizeof(void*));
|
||||
|
||||
|
@ -145,11 +146,7 @@ ZEND_API void zend_cleanup_internal_class_data(zend_class_entry *ce)
|
|||
zval *p = static_members;
|
||||
zval *end = p + ce->default_static_members_count;
|
||||
|
||||
#ifdef ZTS
|
||||
CG(static_members_table)[ce->static_members_table_idx] = NULL;
|
||||
#else
|
||||
ce->static_members_table = NULL;
|
||||
#endif
|
||||
ZEND_MAP_PTR_SET(ce->static_members_table, NULL);
|
||||
while (p != end) {
|
||||
i_zval_ptr_dtor(p);
|
||||
p++;
|
||||
|
@ -213,7 +210,21 @@ ZEND_API void destroy_zend_class(zval *zv)
|
|||
zend_class_entry *ce = Z_PTR_P(zv);
|
||||
zend_function *fn;
|
||||
|
||||
if (--ce->refcount > 0) {
|
||||
if (ce->ce_flags & ZEND_ACC_IMMUTABLE) {
|
||||
zend_op_array *op_array;
|
||||
|
||||
if (ce->default_static_members_count) {
|
||||
zend_cleanup_internal_class_data(ce);
|
||||
}
|
||||
if (ce->ce_flags & ZEND_HAS_STATIC_IN_METHODS) {
|
||||
ZEND_HASH_FOREACH_PTR(&ce->function_table, op_array) {
|
||||
if (op_array->type == ZEND_USER_FUNCTION) {
|
||||
destroy_op_array(op_array);
|
||||
}
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
}
|
||||
return;
|
||||
} else if (--ce->refcount > 0) {
|
||||
return;
|
||||
}
|
||||
switch (ce->type) {
|
||||
|
@ -305,6 +316,9 @@ ZEND_API void destroy_zend_class(zval *zv)
|
|||
p++;
|
||||
}
|
||||
free(ce->default_static_members_table);
|
||||
if (ZEND_MAP_PTR(ce->static_members_table) != &ce->default_static_members_table) {
|
||||
zend_cleanup_internal_class_data(ce);
|
||||
}
|
||||
}
|
||||
zend_hash_destroy(&ce->properties_info);
|
||||
zend_string_release_ex(ce->name, 1);
|
||||
|
@ -355,17 +369,18 @@ ZEND_API void destroy_op_array(zend_op_array *op_array)
|
|||
{
|
||||
uint32_t i;
|
||||
|
||||
if (op_array->static_variables &&
|
||||
!(GC_FLAGS(op_array->static_variables) & IS_ARRAY_IMMUTABLE)) {
|
||||
if (GC_DELREF(op_array->static_variables) == 0) {
|
||||
zend_array_destroy(op_array->static_variables);
|
||||
if (op_array->static_variables) {
|
||||
HashTable *ht = ZEND_MAP_PTR_GET(op_array->static_variables_ptr);
|
||||
if (ht && !(GC_FLAGS(ht) & IS_ARRAY_IMMUTABLE)) {
|
||||
if (GC_DELREF(ht) == 0) {
|
||||
zend_array_destroy(ht);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (op_array->run_time_cache
|
||||
&& (op_array->fn_flags & ZEND_ACC_HEAP_RT_CACHE)) {
|
||||
efree(op_array->run_time_cache);
|
||||
op_array->run_time_cache = NULL;
|
||||
if ((op_array->fn_flags & ZEND_ACC_HEAP_RT_CACHE)
|
||||
&& ZEND_MAP_PTR(op_array->run_time_cache)) {
|
||||
efree(ZEND_MAP_PTR(op_array->run_time_cache));
|
||||
}
|
||||
|
||||
if (!op_array->refcount || --(*op_array->refcount) > 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue