Skip to content

[DRAFT] [WIP] Initial zend_class_alias #18789

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 24 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Autoload with zvals
  • Loading branch information
DanielEScherzer committed Jun 9, 2025
commit 009cdf12084b84c16618a75b091814d1525cd47d
2 changes: 1 addition & 1 deletion Zend/zend_execute.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ZEND_API extern void (*zend_execute_ex)(zend_execute_data *execute_data);
ZEND_API extern void (*zend_execute_internal)(zend_execute_data *execute_data, zval *return_value);

/* The lc_name may be stack allocated! */
ZEND_API extern zend_class_entry *(*zend_autoload)(zend_string *name, zend_string *lc_name);
ZEND_API extern zval *(*zend_autoload)(zend_string *name, zend_string *lc_name);

void init_executor(void);
void shutdown_executor(void);
Expand Down
7 changes: 5 additions & 2 deletions Zend/zend_execute_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

ZEND_API void (*zend_execute_ex)(zend_execute_data *execute_data);
ZEND_API void (*zend_execute_internal)(zend_execute_data *execute_data, zval *return_value);
ZEND_API zend_class_entry *(*zend_autoload)(zend_string *name, zend_string *lc_name);
ZEND_API zval *(*zend_autoload)(zend_string *name, zend_string *lc_name);

#ifdef ZEND_WIN32
ZEND_TLS HANDLE tq_timer = NULL;
Expand Down Expand Up @@ -1270,7 +1270,10 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *
EG(filename_override) = NULL;
EG(lineno_override) = -1;
zend_exception_save();
ce = zend_autoload(autoload_name, lc_name);
zval *ce_zval = zend_autoload(autoload_name, lc_name);
if (ce_zval) {
ce = Z_PTR_P(ce_zval);
}
zend_exception_restore();
EG(filename_override) = previous_filename;
EG(lineno_override) = previous_lineno;
Expand Down
12 changes: 4 additions & 8 deletions ext/spl/php_spl.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ static bool autoload_func_info_equals(
&& alfi1->closure == alfi2->closure;
}

static zend_class_entry *spl_perform_autoload(zend_string *class_name, zend_string *lc_name) {
static zval *spl_perform_autoload(zend_string *class_name, zend_string *lc_name) {
if (!spl_autoload_functions) {
return NULL;
}
Expand Down Expand Up @@ -444,13 +444,9 @@ static zend_class_entry *spl_perform_autoload(zend_string *class_name, zend_stri
break;
}

if (ZSTR_HAS_CE_CACHE(class_name) && ZSTR_GET_CE_CACHE(class_name)) {
return (zend_class_entry*)ZSTR_GET_CE_CACHE(class_name);
} else {
zend_class_entry *ce = zend_hash_find_ptr(EG(class_table), lc_name);
if (ce) {
return ce;
}
zval *ce_ptr = zend_hash_find(EG(class_table), lc_name);
if (ce_ptr) {
return ce_ptr;
}

zend_hash_move_forward_ex(spl_autoload_functions, &pos);
Expand Down