From: Dmitry Stogov Date: Fri, 21 Jun 2019 07:06:35 +0000 (+0300) Subject: Additional fix for bug #78185 (File cache no longer works) X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1707f6645a2f80fd529c9f987317b73ae94dba93;p=php Additional fix for bug #78185 (File cache no longer works) --- diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 986b955787..d5be7a93a2 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -2946,11 +2946,11 @@ static int accel_post_startup(void) #ifdef HAVE_JIT if (ZCG(accel_directives).jit && ZCG(accel_directives).jit_buffer_size && - ZSMMG(reserved)) { - zend_jit_startup(ZCG(accel_directives).jit, ZSMMG(reserved), jit_size, reattached); + ZSMMG(reserved) && + zend_jit_startup(ZCG(accel_directives).jit, ZSMMG(reserved), jit_size, reattached) == SUCCESS) { + ZCG(jit_enabled) = 1; } else { - ZCG(accel_directives).jit = 0; - ZCG(accel_directives).jit_buffer_size = 0; + ZCG(jit_enabled) = 0; } #endif zend_shared_alloc_save_state(); diff --git a/ext/opcache/ZendAccelerator.h b/ext/opcache/ZendAccelerator.h index 27a9dce7da..ae59a3d283 100644 --- a/ext/opcache/ZendAccelerator.h +++ b/ext/opcache/ZendAccelerator.h @@ -220,6 +220,9 @@ typedef struct _zend_accel_globals { void *arena_mem; zend_persistent_script *current_persistent_script; zend_bool is_immutable_class; +#ifdef HAVE_JIT + zend_bool jit_enabled; +#endif /* cache to save hash lookup on the same INCLUDE opcode */ const zend_op *cache_opline; zend_persistent_script *cache_persistent_script; diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c index 292653311a..551d5ad09d 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -464,7 +464,7 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS) php_info_print_table_row(2, "File Cache", "Disabled"); } #if HAVE_JIT - if (ZCG(accel_directives).jit) { + if (ZCG(jit_enabled)) { php_info_print_table_row(2, "JIT", "Enabled"); } else { php_info_print_table_row(2, "JIT", "Disabled"); diff --git a/ext/opcache/zend_file_cache.c b/ext/opcache/zend_file_cache.c index 0e4d7748c9..4079c8bf1c 100644 --- a/ext/opcache/zend_file_cache.c +++ b/ext/opcache/zend_file_cache.c @@ -903,7 +903,7 @@ int zend_file_cache_script_store(zend_persistent_script *script, int in_shm) #ifdef HAVE_JIT /* FIXME: dump jited codes out to file cache? */ - if (ZCG(accel_directives).jit) { + if (ZCG(jit_enabled)) { return FAILURE; } #endif diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c index f4df9a301b..5d2d6ba315 100644 --- a/ext/opcache/zend_persist.c +++ b/ext/opcache/zend_persist.c @@ -538,7 +538,7 @@ static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_sc ZCG(mem) = (void*)((char*)ZCG(mem) + ZEND_ALIGNED_SIZE(zend_extensions_op_array_persist(op_array, ZCG(mem)))); #ifdef HAVE_JIT - if (ZCG(accel_directives).jit && + if (ZCG(jit_enabled) && ZEND_JIT_LEVEL(ZCG(accel_directives).jit) <= ZEND_JIT_LEVEL_OPT_FUNCS && !ZCG(current_persistent_script)->corrupted) { zend_jit_op_array(op_array, ZCG(current_persistent_script) ? &ZCG(current_persistent_script)->script : NULL); @@ -1078,7 +1078,7 @@ zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script ZCG(mem) = (void*)((char*)ZCG(mem) + script->arena_size); #ifdef HAVE_JIT - if (ZCG(accel_directives).jit && for_shm) { + if (ZCG(jit_enabled) && for_shm) { zend_jit_unprotect(); } #endif @@ -1097,7 +1097,7 @@ zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script ZCSG(map_ptr_last) = CG(map_ptr_last); #ifdef HAVE_JIT - if (ZCG(accel_directives).jit && for_shm) { + if (ZCG(jit_enabled) && for_shm) { if (ZEND_JIT_LEVEL(ZCG(accel_directives).jit) >= ZEND_JIT_LEVEL_OPT_SCRIPT) { zend_jit_script(&script->script); }