mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Don't force constant resolution for include preloading
Same as with property types, we no longer require that all constants are resolved for preloading to work, it's just an optimization. As such, drop the forced resolution for include-based preloading and just keep the optimization.
This commit is contained in:
parent
645ef62693
commit
703e92c121
2 changed files with 1 additions and 46 deletions
|
@ -4134,47 +4134,6 @@ static void preload_link(void)
|
||||||
} ZEND_HASH_FOREACH_END();
|
} ZEND_HASH_FOREACH_END();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int preload_update_class_constants(zend_class_entry *ce) {
|
|
||||||
/* This is a separate function to work around what appears to be a bug in GCC
|
|
||||||
* maybe-uninitialized analysis. */
|
|
||||||
int result;
|
|
||||||
zend_try {
|
|
||||||
result = preload_try_resolve_constants(ce) ? SUCCESS : FAILURE;
|
|
||||||
} zend_catch {
|
|
||||||
result = FAILURE;
|
|
||||||
} zend_end_try();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void preload_ensure_classes_loadable(void) {
|
|
||||||
/* Run this in a loop, because additional classes may be loaded while updating constants etc. */
|
|
||||||
uint32_t checked_classes_idx = 0;
|
|
||||||
while (1) {
|
|
||||||
zend_class_entry *ce;
|
|
||||||
uint32_t num_classes = zend_hash_num_elements(EG(class_table));
|
|
||||||
if (num_classes == checked_classes_idx) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ZEND_HASH_REVERSE_FOREACH_PTR(EG(class_table), ce) {
|
|
||||||
if (ce->type == ZEND_INTERNAL_CLASS || _idx == checked_classes_idx) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(ce->ce_flags & ZEND_ACC_LINKED)) {
|
|
||||||
/* Only require that already linked classes are loadable, we'll properly check
|
|
||||||
* things when linking additional classes. */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) {
|
|
||||||
preload_update_class_constants(ce);
|
|
||||||
}
|
|
||||||
} ZEND_HASH_FOREACH_END();
|
|
||||||
checked_classes_idx = num_classes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static zend_string *preload_resolve_path(zend_string *filename)
|
static zend_string *preload_resolve_path(zend_string *filename)
|
||||||
{
|
{
|
||||||
if (is_stream_path(ZSTR_VAL(filename))) {
|
if (is_stream_path(ZSTR_VAL(filename))) {
|
||||||
|
@ -4627,10 +4586,6 @@ static int accel_preload(const char *config, bool in_child)
|
||||||
CG(unclean_shutdown) = 1;
|
CG(unclean_shutdown) = 1;
|
||||||
ret = FAILURE;
|
ret = FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == SUCCESS) {
|
|
||||||
preload_ensure_classes_loadable();
|
|
||||||
}
|
|
||||||
} zend_catch {
|
} zend_catch {
|
||||||
ret = FAILURE;
|
ret = FAILURE;
|
||||||
} zend_end_try();
|
} zend_end_try();
|
||||||
|
|
|
@ -19,5 +19,5 @@ var_dump(class_exists('Foo'));
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
bool(true)
|
bool(true)
|
||||||
bool(true)
|
bool(false)
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue