Skip to content

Commit 7134e69

Browse files
authored
zend_globals: Embed in_autoload into zend_executor_globals (#21202)
* zend_globals: Embed `in_autoload` into `zend_executor_globals` Nowadays virtually any PHP application is making use of autoloading, making the lazy allocation of the `HashTable` struct a needless pointer indirection. * zend_globals: Rename `in_autoload` to `autoload_current_classnames` The old name `in_autoload` was somewhat misleading by implying a `bool`ean value rather than a `HashTable`. Since the previous change to embed the `HashTable` is breaking anyway, we can also rename it. * UPGRADING.INTERNALS
1 parent 5330e7f commit 7134e69

File tree

4 files changed

+7
-14
lines changed

4 files changed

+7
-14
lines changed

UPGRADING.INTERNALS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ PHP 8.6 INTERNALS UPGRADE NOTES
7070
performed on the result.
7171
. The zend_dval_to_lval_cap() function no longer takes a second
7272
zend_string* parameter.
73+
. EG(in_autoload) was renamed to EG(autoload_current_classnames) and no
74+
longer is a pointer, but a directly embedded HashTable struct.
7375

7476
========================
7577
2. Build system changes

Zend/zend.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,6 @@ static void executor_globals_ctor(zend_executor_globals *executor_globals) /* {{
811811
executor_globals->user_error_handler_error_reporting = 0;
812812
ZVAL_UNDEF(&executor_globals->user_error_handler);
813813
ZVAL_UNDEF(&executor_globals->user_exception_handler);
814-
executor_globals->in_autoload = NULL;
815814
executor_globals->current_execute_data = NULL;
816815
executor_globals->current_module = NULL;
817816
executor_globals->exit_status = 0;

Zend/zend_execute_API.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ void init_executor(void) /* {{{ */
145145
EG(function_table) = CG(function_table);
146146
EG(class_table) = CG(class_table);
147147

148-
EG(in_autoload) = NULL;
149148
EG(error_handling) = EH_NORMAL;
150149
EG(flags) = EG_FLAGS_INITIAL;
151150

@@ -156,6 +155,7 @@ void init_executor(void) /* {{{ */
156155
zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_activator);
157156

158157
zend_hash_init(&EG(included_files), 8, NULL, NULL, 0);
158+
zend_hash_init(&EG(autoload_current_classnames), 8, NULL, NULL, 0);
159159

160160
EG(ticks_count) = 0;
161161

@@ -503,16 +503,13 @@ void shutdown_executor(void) /* {{{ */
503503
}
504504

505505
zend_hash_destroy(&EG(included_files));
506+
zend_hash_destroy(&EG(autoload_current_classnames));
506507

507508
zend_stack_destroy(&EG(user_error_handlers_error_reporting));
508509
zend_stack_destroy(&EG(user_error_handlers));
509510
zend_stack_destroy(&EG(user_exception_handlers));
510511
zend_lazy_objects_destroy(&EG(lazy_objects_store));
511512
zend_objects_store_destroy(&EG(objects_store));
512-
if (EG(in_autoload)) {
513-
zend_hash_destroy(EG(in_autoload));
514-
FREE_HASHTABLE(EG(in_autoload));
515-
}
516513

517514
if (EG(ht_iterators) != EG(ht_iterators_slots)) {
518515
efree(EG(ht_iterators));
@@ -1245,12 +1242,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *
12451242
return NULL;
12461243
}
12471244

1248-
if (EG(in_autoload) == NULL) {
1249-
ALLOC_HASHTABLE(EG(in_autoload));
1250-
zend_hash_init(EG(in_autoload), 8, NULL, NULL, 0);
1251-
}
1252-
1253-
if (zend_hash_add_empty_element(EG(in_autoload), lc_name) == NULL) {
1245+
if (zend_hash_add_empty_element(&EG(autoload_current_classnames), lc_name) == NULL) {
12541246
if (!key) {
12551247
zend_string_release_ex(lc_name, 0);
12561248
}
@@ -1272,7 +1264,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *
12721264
EG(lineno_override) = previous_lineno;
12731265

12741266
zend_string_release_ex(autoload_name, 0);
1275-
zend_hash_del(EG(in_autoload), lc_name);
1267+
zend_hash_del(&EG(autoload_current_classnames), lc_name);
12761268

12771269
if (!key) {
12781270
zend_string_release_ex(lc_name, 0);

Zend/zend_globals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ struct _zend_executor_globals {
220220
zend_atomic_bool vm_interrupt;
221221
zend_atomic_bool timed_out;
222222

223-
HashTable *in_autoload;
223+
HashTable autoload_current_classnames;
224224

225225
zend_long hard_timeout;
226226
void *stack_base;

0 commit comments

Comments
 (0)