From 703e92c121ac8cc559dc94fd623f11f7824d0e59 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 27 Jul 2021 10:50:31 +0200 Subject: [PATCH] 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. --- ext/opcache/ZendAccelerator.c | 45 ------------------- .../tests/preload_loadable_classes_1.phpt | 2 +- 2 files changed, 1 insertion(+), 46 deletions(-) diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 7ed9f31c10b..1dbb8614072 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -4134,47 +4134,6 @@ static void preload_link(void) } 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) { 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; ret = FAILURE; } - - if (ret == SUCCESS) { - preload_ensure_classes_loadable(); - } } zend_catch { ret = FAILURE; } zend_end_try(); diff --git a/ext/opcache/tests/preload_loadable_classes_1.phpt b/ext/opcache/tests/preload_loadable_classes_1.phpt index 1aa48b81356..4fd463b49c4 100644 --- a/ext/opcache/tests/preload_loadable_classes_1.phpt +++ b/ext/opcache/tests/preload_loadable_classes_1.phpt @@ -19,5 +19,5 @@ var_dump(class_exists('Foo')); ?> --EXPECT-- bool(true) -bool(true) +bool(false) bool(false)