Skip to content

Commit 8f25490

Browse files
committed
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.
1 parent f037d49 commit 8f25490

3 files changed

Lines changed: 5 additions & 14 deletions

File tree

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(in_autoload), 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(in_autoload));
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(in_autoload), 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(in_autoload), 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 in_autoload;
224224

225225
zend_long hard_timeout;
226226
void *stack_base;

0 commit comments

Comments
 (0)