mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Use more compact representation for packed arrays.
- for packed arrays we store just an array of zvals without keys. - the elements of packed array are accessible throuf as ht->arPacked[i] instead of ht->arData[i] - in addition to general ZEND_HASH_FOREACH_* macros, we introduced similar familied for packed (ZEND_HASH_PACKED_FORECH_*) and real hashes (ZEND_HASH_MAP_FOREACH_*) - introduced an additional family of macros to access elements of array (packed or real hashes) ZEND_ARRAY_ELEMET_SIZE, ZEND_ARRAY_ELEMET_EX, ZEND_ARRAY_ELEMET, ZEND_ARRAY_NEXT_ELEMENT, ZEND_ARRAY_PREV_ELEMENT - zend_hash_minmax() prototype was changed to compare only values Because of smaller data set, this patch may show performance improvement on some apps and benchmarks that use packed arrays. (~1% on PHP-Parser) TODO: - sapi/phpdbg needs special support for packed arrays (WATCH_ON_BUCKET). - zend_hash_sort_ex() may require converting packed arrays to hash.
This commit is contained in:
parent
0eb603e3bb
commit
90b7bde615
89 changed files with 3302 additions and 1664 deletions
|
@ -280,7 +280,7 @@ ZEND_API void zend_shutdown_executor_values(bool fast_shutdown)
|
|||
if (EG(full_tables_cleanup)) {
|
||||
zend_hash_reverse_apply(EG(zend_constants), clean_non_persistent_constant_full);
|
||||
} else {
|
||||
ZEND_HASH_REVERSE_FOREACH_STR_KEY_VAL(EG(zend_constants), key, zv) {
|
||||
ZEND_HASH_MAP_REVERSE_FOREACH_STR_KEY_VAL(EG(zend_constants), key, zv) {
|
||||
zend_constant *c = Z_PTR_P(zv);
|
||||
if (_idx == EG(persistent_constants_count)) {
|
||||
break;
|
||||
|
@ -291,12 +291,12 @@ ZEND_API void zend_shutdown_executor_values(bool fast_shutdown)
|
|||
}
|
||||
efree(c);
|
||||
zend_string_release_ex(key, 0);
|
||||
} ZEND_HASH_FOREACH_END_DEL();
|
||||
} ZEND_HASH_MAP_FOREACH_END_DEL();
|
||||
}
|
||||
|
||||
/* Release static properties and static variables prior to the final GC run,
|
||||
* as they may hold GC roots. */
|
||||
ZEND_HASH_REVERSE_FOREACH_VAL(EG(function_table), zv) {
|
||||
ZEND_HASH_MAP_REVERSE_FOREACH_VAL(EG(function_table), zv) {
|
||||
zend_op_array *op_array = Z_PTR_P(zv);
|
||||
if (op_array->type == ZEND_INTERNAL_FUNCTION) {
|
||||
break;
|
||||
|
@ -309,7 +309,7 @@ ZEND_API void zend_shutdown_executor_values(bool fast_shutdown)
|
|||
}
|
||||
}
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
ZEND_HASH_REVERSE_FOREACH_VAL(EG(class_table), zv) {
|
||||
ZEND_HASH_MAP_REVERSE_FOREACH_VAL(EG(class_table), zv) {
|
||||
zend_class_entry *ce = Z_PTR_P(zv);
|
||||
|
||||
if (ce->default_static_members_count) {
|
||||
|
@ -323,7 +323,7 @@ ZEND_API void zend_shutdown_executor_values(bool fast_shutdown)
|
|||
} else if (ce->type == ZEND_USER_CLASS && !(ce->ce_flags & ZEND_ACC_IMMUTABLE)) {
|
||||
/* Constants may contain objects, destroy the values before the object store. */
|
||||
zend_class_constant *c;
|
||||
ZEND_HASH_FOREACH_PTR(&ce->constants_table, c) {
|
||||
ZEND_HASH_MAP_FOREACH_PTR(&ce->constants_table, c) {
|
||||
if (c->ce == ce) {
|
||||
zval_ptr_dtor_nogc(&c->value);
|
||||
ZVAL_UNDEF(&c->value);
|
||||
|
@ -333,7 +333,7 @@ ZEND_API void zend_shutdown_executor_values(bool fast_shutdown)
|
|||
|
||||
if (ce->ce_flags & ZEND_HAS_STATIC_IN_METHODS) {
|
||||
zend_op_array *op_array;
|
||||
ZEND_HASH_FOREACH_PTR(&ce->function_table, op_array) {
|
||||
ZEND_HASH_MAP_FOREACH_PTR(&ce->function_table, op_array) {
|
||||
if (op_array->type == ZEND_USER_FUNCTION) {
|
||||
if (ZEND_MAP_PTR(op_array->static_variables_ptr)) {
|
||||
HashTable *ht = ZEND_MAP_PTR_GET(op_array->static_variables_ptr);
|
||||
|
@ -412,22 +412,22 @@ void shutdown_executor(void) /* {{{ */
|
|||
zend_hash_reverse_apply(EG(function_table), clean_non_persistent_function_full);
|
||||
zend_hash_reverse_apply(EG(class_table), clean_non_persistent_class_full);
|
||||
} else {
|
||||
ZEND_HASH_REVERSE_FOREACH_STR_KEY_VAL(EG(function_table), key, zv) {
|
||||
ZEND_HASH_MAP_REVERSE_FOREACH_STR_KEY_VAL(EG(function_table), key, zv) {
|
||||
zend_function *func = Z_PTR_P(zv);
|
||||
if (_idx == EG(persistent_functions_count)) {
|
||||
break;
|
||||
}
|
||||
destroy_op_array(&func->op_array);
|
||||
zend_string_release_ex(key, 0);
|
||||
} ZEND_HASH_FOREACH_END_DEL();
|
||||
} ZEND_HASH_MAP_FOREACH_END_DEL();
|
||||
|
||||
ZEND_HASH_REVERSE_FOREACH_STR_KEY_VAL(EG(class_table), key, zv) {
|
||||
ZEND_HASH_MAP_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();
|
||||
} ZEND_HASH_MAP_FOREACH_END_DEL();
|
||||
}
|
||||
|
||||
while (EG(symtable_cache_ptr) > EG(symtable_cache)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue