From: Nikita Popov Date: Thu, 7 Feb 2019 10:10:12 +0000 (+0100) Subject: Remove --disable-opcache-filecache option X-Git-Tag: php-7.4.0alpha1~1123^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c32da66e129897f4f103ecc6319332f160ee52ea;p=php Remove --disable-opcache-filecache option This is no longer an experimental feature, and we have the ability to control this at runtime via an ini setting. --- diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index c783977a43..d26692d538 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -41,13 +41,10 @@ #include "zend_virtual_cwd.h" #include "zend_accelerator_util_funcs.h" #include "zend_accelerator_hash.h" +#include "zend_file_cache.h" #include "ext/pcre/php_pcre.h" #include "ext/standard/md5.h" -#ifdef HAVE_OPCACHE_FILE_CACHE -# include "zend_file_cache.h" -#endif - #ifndef ZEND_WIN32 #include #endif @@ -114,9 +111,7 @@ zend_accel_shared_globals *accel_shared_globals = NULL; zend_bool accel_startup_ok = 0; static char *zps_failure_reason = NULL; char *zps_api_failure_reason = NULL; -#ifdef HAVE_OPCACHE_FILE_CACHE zend_bool file_cache_only = 0; /* process uses file cache only */ -#endif #if ENABLE_FILE_CACHE_FALLBACK zend_bool fallback_process = 0; /* process uses file cache fallback */ #endif @@ -457,11 +452,9 @@ zend_string* ZEND_FASTCALL accel_new_interned_string(zend_string *str) uint32_t pos, *hash_slot; zend_string *s; -#ifdef HAVE_OPCACHE_FILE_CACHE if (UNEXPECTED(file_cache_only)) { return str; } -#endif if (IS_ACCEL_INTERNED(str)) { /* this is already an interned string */ @@ -1278,11 +1271,9 @@ int zend_accel_invalidate(const char *filename, size_t filename_len, zend_bool f return FAILURE; } -#ifdef HAVE_OPCACHE_FILE_CACHE if (ZCG(accel_directives).file_cache) { zend_file_cache_invalidate(realpath); } -#endif persistent_script = zend_accel_hash_find(&ZCSG(hash), realpath); if (persistent_script && !persistent_script->corrupted) { @@ -1349,7 +1340,6 @@ static zend_always_inline zend_bool is_phar_file(zend_string *filename) !strstr(ZSTR_VAL(filename), "://"); } -#ifdef HAVE_OPCACHE_FILE_CACHE static zend_persistent_script *store_script_in_file_cache(zend_persistent_script *new_persistent_script) { uint32_t memory_used; @@ -1415,7 +1405,6 @@ static zend_persistent_script *cache_script_in_file_cache(zend_persistent_script *from_shared_memory = 1; return store_script_in_file_cache(new_persistent_script); } -#endif static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_script *new_persistent_script, const char *key, unsigned int key_length, int *from_shared_memory) { @@ -1429,11 +1418,9 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr } orig_compiler_options = CG(compiler_options); -#ifdef HAVE_OPCACHE_FILE_CACHE if (ZCG(accel_directives).file_cache) { CG(compiler_options) |= ZEND_COMPILE_WITH_FILE_CACHE; } -#endif if (!zend_optimize_script(&new_persistent_script->script, ZCG(accel_directives).optimization_level, ZCG(accel_directives).opt_debug_level)) { CG(compiler_options) = orig_compiler_options; return new_persistent_script; @@ -1466,12 +1453,10 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr ZSMMG(memory_exhausted) = 1; zend_accel_schedule_restart_if_necessary(ACCEL_RESTART_HASH); zend_shared_alloc_unlock(); -#ifdef HAVE_OPCACHE_FILE_CACHE if (ZCG(accel_directives).file_cache) { new_persistent_script = store_script_in_file_cache(new_persistent_script); *from_shared_memory = 1; } -#endif return new_persistent_script; } @@ -1526,12 +1511,10 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr zend_shared_alloc_destroy_xlat_table(); zend_accel_schedule_restart_if_necessary(ACCEL_RESTART_OOM); zend_shared_alloc_unlock(); -#ifdef HAVE_OPCACHE_FILE_CACHE if (ZCG(accel_directives).file_cache) { new_persistent_script = store_script_in_file_cache(new_persistent_script); *from_shared_memory = 1; } -#endif return new_persistent_script; } @@ -1581,13 +1564,11 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr zend_shared_alloc_unlock(); -#ifdef HAVE_OPCACHE_FILE_CACHE if (ZCG(accel_directives).file_cache) { SHM_PROTECT(); zend_file_cache_script_store(new_persistent_script, 1); SHM_UNPROTECT(); } -#endif *from_shared_memory = 1; return new_persistent_script; @@ -1734,11 +1715,9 @@ static zend_persistent_script *opcache_compile_file(zend_file_handle *file_handl CG(compiler_options) |= ZEND_COMPILE_DELAYED_BINDING; CG(compiler_options) |= ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION; CG(compiler_options) |= ZEND_COMPILE_IGNORE_OTHER_FILES; -#ifdef HAVE_OPCACHE_FILE_CACHE if (ZCG(accel_directives).file_cache) { CG(compiler_options) |= ZEND_COMPILE_WITH_FILE_CACHE; } -#endif op_array = *op_array_p = accelerator_orig_compile_file(file_handle, type); CG(compiler_options) = orig_compiler_options; } zend_catch { @@ -1801,7 +1780,6 @@ static zend_persistent_script *opcache_compile_file(zend_file_handle *file_handl return new_persistent_script; } -#ifdef HAVE_OPCACHE_FILE_CACHE zend_op_array *file_cache_compile_file(zend_file_handle *file_handle, int type) { zend_persistent_script *persistent_script; @@ -1873,7 +1851,6 @@ zend_op_array *file_cache_compile_file(zend_file_handle *file_handle, int type) return op_array; } -#endif /* zend_compile() replacement */ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type) @@ -1886,17 +1863,13 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type) if (!file_handle->filename || !ZCG(enabled) || !accel_startup_ok) { /* The Accelerator is disabled, act as if without the Accelerator */ return accelerator_orig_compile_file(file_handle, type); -#ifdef HAVE_OPCACHE_FILE_CACHE } else if (file_cache_only) { return file_cache_compile_file(file_handle, type); -#endif } else if ((!ZCG(counted) && !ZCSG(accelerator_enabled)) || (ZCSG(restart_in_progress) && accel_restart_is_active())) { -#ifdef HAVE_OPCACHE_FILE_CACHE if (ZCG(accel_directives).file_cache) { return file_cache_compile_file(file_handle, type); } -#endif return accelerator_orig_compile_file(file_handle, type); } @@ -1980,11 +1953,9 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type) */ if (!ZCG(counted)) { if (accel_activate_add() == FAILURE) { -#ifdef HAVE_OPCACHE_FILE_CACHE if (ZCG(accel_directives).file_cache) { return file_cache_compile_file(file_handle, type); } -#endif return accelerator_orig_compile_file(file_handle, type); } ZCG(counted) = 1; @@ -2051,12 +2022,10 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type) } } -#ifdef HAVE_OPCACHE_FILE_CACHE /* Check the second level cache */ if (!persistent_script && ZCG(accel_directives).file_cache) { persistent_script = zend_file_cache_script_load(file_handle); } -#endif /* If script was not found or invalidated by validate_timestamps */ if (!persistent_script) { @@ -2070,11 +2039,9 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type) if (ZSMMG(memory_exhausted) || ZCSG(restart_pending)) { SHM_PROTECT(); HANDLE_UNBLOCK_INTERRUPTIONS(); -#ifdef HAVE_OPCACHE_FILE_CACHE if (ZCG(accel_directives).file_cache) { return file_cache_compile_file(file_handle, type); } -#endif return accelerator_orig_compile_file(file_handle, type); } @@ -2186,9 +2153,7 @@ static int persistent_stream_open_function(const char *filename, zend_file_handl static zend_string* persistent_zend_resolve_path(const char *filename, size_t filename_len) { if (ZCG(enabled) && accel_startup_ok && -#ifdef HAVE_OPCACHE_FILE_CACHE !file_cache_only && -#endif (ZCG(counted) || ZCSG(accelerator_enabled)) && !ZCSG(restart_in_progress)) { @@ -2310,11 +2275,9 @@ int accel_activate(INIT_FUNC_ARGS) ZCG(cwd_key_len) = 0; ZCG(cwd_check) = 1; -#ifdef HAVE_OPCACHE_FILE_CACHE if (file_cache_only) { return SUCCESS; } -#endif #ifndef ZEND_WIN32 if (ZCG(accel_directives).validate_root) { @@ -2834,12 +2797,8 @@ static int accel_post_startup(void) /********************************************/ /* End of non-SHM dependent initializations */ /********************************************/ -#ifdef HAVE_OPCACHE_FILE_CACHE file_cache_only = ZCG(accel_directives).file_cache_only; if (!file_cache_only) { -#else - if (1) { -#endif switch (zend_shared_alloc_startup(ZCG(accel_directives).memory_consumption)) { case ALLOC_SUCCESS: if (zend_accel_init_shm() == FAILURE) { @@ -2887,7 +2846,6 @@ static int accel_post_startup(void) zend_shared_alloc_unlock(); SHM_PROTECT(); -#ifdef HAVE_OPCACHE_FILE_CACHE } else if (!ZCG(accel_directives).file_cache) { accel_startup_ok = 0; zend_accel_error(ACCEL_LOG_FATAL, "opcache.file_cache_only is set without a proper setting of opcache.file_cache"); @@ -2897,7 +2855,6 @@ static int accel_post_startup(void) /* Init auto-global strings */ zend_accel_init_auto_globals(); -#endif } #if ENABLE_FILE_CACHE_FALLBACK file_cache_fallback: @@ -2983,9 +2940,7 @@ void accel_shutdown(void) preload_shutdown(); } -#ifdef HAVE_OPCACHE_FILE_CACHE _file_cache_only = file_cache_only; -#endif accel_reset_pcre_cache(); diff --git a/ext/opcache/ZendAccelerator.h b/ext/opcache/ZendAccelerator.h index 547fc49867..47ce1bb9f4 100644 --- a/ext/opcache/ZendAccelerator.h +++ b/ext/opcache/ZendAccelerator.h @@ -104,7 +104,7 @@ extern int lock_file; # endif #endif -#if defined(HAVE_OPCACHE_FILE_CACHE) && defined(ZEND_WIN32) +#if defined(ZEND_WIN32) # define ENABLE_FILE_CACHE_FALLBACK 1 #else # define ENABLE_FILE_CACHE_FALLBACK 0 @@ -188,11 +188,9 @@ typedef struct _zend_accel_directives { #ifndef ZEND_WIN32 char *lockfile_path; #endif -#ifdef HAVE_OPCACHE_FILE_CACHE char *file_cache; zend_bool file_cache_only; zend_bool file_cache_consistency_checks; -#endif #if ENABLE_FILE_CACHE_FALLBACK zend_bool file_cache_fallback; #endif @@ -284,9 +282,7 @@ typedef struct _zend_accel_shared_globals { } zend_accel_shared_globals; extern zend_bool accel_startup_ok; -#ifdef HAVE_OPCACHE_FILE_CACHE extern zend_bool file_cache_only; -#endif #if ENABLE_FILE_CACHE_FALLBACK extern zend_bool fallback_process; #endif diff --git a/ext/opcache/config.m4 b/ext/opcache/config.m4 index 392f4c65a3..fedf31bcca 100644 --- a/ext/opcache/config.m4 +++ b/ext/opcache/config.m4 @@ -3,19 +3,12 @@ dnl config.m4 for extension opcache PHP_ARG_ENABLE(opcache, whether to enable Zend OPcache support, [ --disable-opcache Disable Zend OPcache support], yes) -PHP_ARG_ENABLE(opcache-file, whether to enable file based caching, -[ --disable-opcache-file Disable file based caching], yes, no) - PHP_ARG_ENABLE(huge-code-pages, whether to enable copying PHP CODE pages into HUGE PAGES, [ --disable-huge-code-pages Disable copying PHP CODE pages into HUGE PAGES], yes, no) if test "$PHP_OPCACHE" != "no"; then - if test "$PHP_OPCACHE_FILE" = "yes"; then - AC_DEFINE(HAVE_OPCACHE_FILE_CACHE, 1, [Define to enable file based caching (experimental)]) - fi - if test "$PHP_HUGE_CODE_PAGES" = "yes"; then AC_DEFINE(HAVE_HUGE_CODE_PAGES, 1, [Define to enable copying PHP CODE pages into HUGE PAGES (experimental)]) fi diff --git a/ext/opcache/config.w32 b/ext/opcache/config.w32 index 1d78f7e548..fba1b1bef1 100644 --- a/ext/opcache/config.w32 +++ b/ext/opcache/config.w32 @@ -1,15 +1,9 @@ ARG_ENABLE("opcache", "whether to enable Zend OPcache support", "yes"); -ARG_ENABLE("opcache-file", "whether to enable file based caching", "yes"); - /* var PHP_OPCACHE_PGO = false; */ if (PHP_OPCACHE != "no") { - if (PHP_OPCACHE_FILE == "yes") { - AC_DEFINE('HAVE_OPCACHE_FILE_CACHE', 1, 'Define to enable file based caching (experimental)'); - } - ZEND_EXTENSION('opcache', "\ ZendAccelerator.c \ zend_accelerator_blacklist.c \ diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c index 2c5b829d57..65db85115b 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -245,7 +245,6 @@ static ZEND_INI_MH(OnEnable) } } -#ifdef HAVE_OPCACHE_FILE_CACHE static ZEND_INI_MH(OnUpdateFileCache) { if (new_value) { @@ -270,7 +269,6 @@ static ZEND_INI_MH(OnUpdateFileCache) OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage); return SUCCESS; } -#endif ZEND_INI_BEGIN() STD_PHP_INI_BOOLEAN("opcache.enable" , "1", PHP_INI_ALL, OnEnable, enabled , zend_accel_globals, accel_globals) @@ -312,11 +310,9 @@ ZEND_INI_BEGIN() STD_PHP_INI_ENTRY("opcache.mmap_base", NULL, PHP_INI_SYSTEM, OnUpdateString, accel_directives.mmap_base, zend_accel_globals, accel_globals) #endif -#ifdef HAVE_OPCACHE_FILE_CACHE STD_PHP_INI_ENTRY("opcache.file_cache" , NULL , PHP_INI_SYSTEM, OnUpdateFileCache, accel_directives.file_cache, zend_accel_globals, accel_globals) STD_PHP_INI_ENTRY("opcache.file_cache_only" , "0" , PHP_INI_SYSTEM, OnUpdateBool, accel_directives.file_cache_only, zend_accel_globals, accel_globals) STD_PHP_INI_ENTRY("opcache.file_cache_consistency_checks" , "1" , PHP_INI_SYSTEM, OnUpdateBool, accel_directives.file_cache_consistency_checks, zend_accel_globals, accel_globals) -#endif #if ENABLE_FILE_CACHE_FALLBACK STD_PHP_INI_ENTRY("opcache.file_cache_fallback" , "1" , PHP_INI_SYSTEM, OnUpdateBool, accel_directives.file_cache_fallback, zend_accel_globals, accel_globals) #endif @@ -404,12 +400,10 @@ void zend_accel_override_file_functions(void) { zend_function *old_function; if (ZCG(enabled) && accel_startup_ok && ZCG(accel_directives).file_override_enabled) { -#ifdef HAVE_OPCACHE_FILE_CACHE if (file_cache_only) { zend_accel_error(ACCEL_LOG_WARNING, "file_override_enabled has no effect when file_cache_only is set"); return; } -#endif /* override file_exists */ if ((old_function = zend_hash_str_find_ptr(CG(function_table), "file_exists", sizeof("file_exists")-1)) != NULL) { orig_file_exists = old_function->internal_function.handler; @@ -440,11 +434,7 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS) php_info_print_table_start(); if (ZCG(enabled) && accel_startup_ok && -#ifdef HAVE_OPCACHE_FILE_CACHE ((ZCG(counted) || ZCSG(accelerator_enabled)) || file_cache_only) -#else - (ZCG(counted) || ZCSG(accelerator_enabled)) -#endif ) { php_info_print_table_row(2, "Opcode Caching", "Up and Running"); } else { @@ -455,7 +445,6 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS) } else { php_info_print_table_row(2, "Optimization", "Disabled"); } -#ifdef HAVE_OPCACHE_FILE_CACHE if (!file_cache_only) { php_info_print_table_row(2, "SHM Cache", "Enabled"); } else { @@ -473,7 +462,6 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS) php_info_print_table_row(2, "Startup", "OK"); } } else -#endif if (ZCG(enabled)) { if (!accel_startup_ok || zps_api_failure_reason) { php_info_print_table_row(2, "Startup Failed", zps_api_failure_reason); @@ -611,7 +599,6 @@ static ZEND_FUNCTION(opcache_get_status) /* Trivia */ add_assoc_bool(return_value, "opcache_enabled", ZCG(enabled) && (ZCG(counted) || ZCSG(accelerator_enabled))); -#ifdef HAVE_OPCACHE_FILE_CACHE if (ZCG(accel_directives).file_cache) { add_assoc_string(return_value, "file_cache", ZCG(accel_directives).file_cache); } @@ -619,7 +606,6 @@ static ZEND_FUNCTION(opcache_get_status) add_assoc_bool(return_value, "file_cache_only", 1); return; } -#endif add_assoc_bool(return_value, "cache_full", ZSMMG(memory_exhausted)); add_assoc_bool(return_value, "restart_pending", ZCSG(restart_pending)); @@ -770,11 +756,9 @@ static ZEND_FUNCTION(opcache_get_configuration) add_assoc_string(&directives, "opcache.lockfile_path", STRING_NOT_NULL(ZCG(accel_directives).lockfile_path)); #endif -#ifdef HAVE_OPCACHE_FILE_CACHE add_assoc_string(&directives, "opcache.file_cache", ZCG(accel_directives).file_cache ? ZCG(accel_directives).file_cache : ""); add_assoc_bool(&directives, "opcache.file_cache_only", ZCG(accel_directives).file_cache_only); add_assoc_bool(&directives, "opcache.file_cache_consistency_checks", ZCG(accel_directives).file_cache_consistency_checks); -#endif add_assoc_zval(return_value, "directives", &directives); diff --git a/ext/opcache/zend_file_cache.c b/ext/opcache/zend_file_cache.c index 008e5007ac..782b734c5b 100644 --- a/ext/opcache/zend_file_cache.c +++ b/ext/opcache/zend_file_cache.c @@ -27,8 +27,6 @@ #include "ext/standard/md5.h" #endif -#ifdef HAVE_OPCACHE_FILE_CACHE - #include "ZendAccelerator.h" #include "zend_file_cache.h" #include "zend_shared_alloc.h" @@ -1691,5 +1689,3 @@ void zend_file_cache_invalidate(zend_string *full_path) zend_file_cache_unlink(filename); efree(filename); } - -#endif /* HAVE_OPCACHE_FILE_CACHE */ diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c index 920843affa..188c31ea31 100644 --- a/ext/opcache/zend_persist.c +++ b/ext/opcache/zend_persist.c @@ -29,7 +29,6 @@ #include "zend_operators.h" #include "zend_interfaces.h" -#ifdef HAVE_OPCACHE_FILE_CACHE #define zend_set_str_gc_flags(str) do { \ if (file_cache_only) { \ GC_TYPE_INFO(str) = IS_STRING | (IS_STR_INTERNED << GC_FLAGS_SHIFT); \ @@ -37,11 +36,6 @@ GC_TYPE_INFO(str) = IS_STRING | ((IS_STR_INTERNED | IS_STR_PERMANENT) << GC_FLAGS_SHIFT); \ } \ } while (0) -#else -#define zend_set_str_gc_flags(str) do {\ - GC_TYPE_INFO(str) = IS_STRING | ((IS_STR_INTERNED | IS_STR_PERMANENT) << GC_FLAGS_SHIFT); \ -} while (0) -#endif #define zend_accel_store_string(str) do { \ zend_string *new_str = zend_shared_alloc_get_xlat_entry(str); \