42#define STRING_NOT_NULL(s) (NULL == (s)?"":s)
43#define MIN_ACCEL_FILES 200
44#define MAX_ACCEL_FILES 1000000
46#define MAX_INTERNED_STRINGS_BUFFER_SIZE ((zend_long)MIN( \
49 (ZEND_STRING_TABLE_POS_MAX - sizeof(zend_string_table)) / (1024 * 1024 / ZEND_STRING_TABLE_POS_ALIGNMENT), \
51 UINT32_MAX / (32 * 1024 * sizeof(zend_string_table_pos_t)) \
54 (SIZE_MAX - sizeof(zend_accel_shared_globals)) / (1024 * 1024) \
56#define TOKENTOSTR(X) #X
62static int validate_api_restriction(
void)
64 if (
ZCG(accel_directives).restrict_api && *
ZCG(accel_directives).restrict_api) {
67 if (!
SG(request_info).path_translated ||
69 memcmp(
SG(request_info).path_translated,
ZCG(accel_directives).restrict_api,
len) != 0) {
89 *
p = memsize * (1024 * 1024);
135 if (percentage <= 0 || percentage > 50) {
139 *
p = (double)percentage / 100.0;
148 return OnUpdateBool(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
157 ZCG(accelerator_enabled) = 0;
177 _access(
ZSTR_VAL(new_value), 06) != 0) {
184 OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
192 return OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
212 if (
val >= 0 &&
val < 256) {
317#if ENABLE_FILE_CACHE_FALLBACK
320#ifdef HAVE_HUGE_CODE_PAGES
353static
int filename_is_in_cache(
zend_string *filename)
360 if (persistent_script && !persistent_script->
corrupted) {
361 if (
ZCG(accel_directives).validate_timestamps) {
385 return filename_is_in_cache(
Z_STR_P(
zv));
436 if ((old_function = zend_hash_str_find_ptr(
CG(function_table),
"file_exists",
sizeof(
"file_exists")-1)) !=
NULL) {
440 if ((old_function = zend_hash_str_find_ptr(
CG(function_table),
"is_file",
sizeof(
"is_file")-1)) !=
NULL) {
444 if ((old_function = zend_hash_str_find_ptr(
CG(function_table),
"is_readable",
sizeof(
"is_readable")-1)) !=
NULL) {
479 if (
ZCG(accel_directives).file_cache) {
485 if (
JIT_G(enabled)) {
509 zend_string *start_time, *restart_time, *force_restart_time;
545 zend_string_release(start_time);
547 if (
ZCSG(last_restart_time)) {
550 zend_string_release(restart_time);
555 if (
ZCSG(force_restart_time)) {
558 zend_string_release(force_restart_time);
593 zval persistent_script_report;
596 struct timeval exec_time;
597 struct timeval fetch_time;
604 for (i = 0; i<
ZCSG(
hash).max_num_entries; i++) {
605 for (cache_entry =
ZCSG(
hash).hash_table[i]; cache_entry; cache_entry = cache_entry->
next) {
610 if (cache_entry->
indirect)
continue;
615 add_assoc_str(&persistent_script_report,
"full_path", zend_string_dup(script->
script.
filename, 0));
621 if (
len > 0 && str[
len - 1] ==
'\n')
len--;
622 add_assoc_stringl(&persistent_script_report,
"last_used", str,
len);
624 if (
ZCG(accel_directives).validate_timestamps) {
644 zval memory_usage, statistics, scripts;
645 bool fetch_scripts = 1;
651 if (!validate_api_restriction()) {
662 add_assoc_bool(
return_value,
"opcache_enabled",
ZCG(accelerator_enabled));
664 if (
ZCG(accel_directives).file_cache) {
665 add_assoc_string(
return_value,
"file_cache",
ZCG(accel_directives).file_cache);
674 add_assoc_bool(
return_value,
"restart_in_progress",
ZCSG(restart_in_progress));
680 add_assoc_long(&memory_usage,
"wasted_memory",
ZSMMG(wasted_shared_memory));
681 add_assoc_double(&memory_usage,
"current_wasted_percentage", (((
double)
ZSMMG(wasted_shared_memory))/
ZCG(accel_directives).memory_consumption)*100.0);
682 add_assoc_zval(
return_value,
"memory_usage", &memory_usage);
685 zval interned_strings_usage;
690 add_assoc_long(&interned_strings_usage,
"free_memory", (
char*)
ZCSG(interned_strings).
end - (
char*)
ZCSG(interned_strings).
top);
691 add_assoc_long(&interned_strings_usage,
"number_of_strings",
ZCSG(interned_strings).nNumOfElements);
692 add_assoc_zval(
return_value,
"interned_strings_usage", &interned_strings_usage);
697 add_assoc_long(&statistics,
"num_cached_scripts",
ZCSG(
hash).num_direct_entries);
698 add_assoc_long(&statistics,
"num_cached_keys",
ZCSG(
hash).num_entries);
699 add_assoc_long(&statistics,
"max_cached_keys",
ZCSG(
hash).max_num_entries);
701 add_assoc_long(&statistics,
"start_time",
ZCSG(start_time));
702 add_assoc_long(&statistics,
"last_restart_time",
ZCSG(last_restart_time));
703 add_assoc_long(&statistics,
"oom_restarts",
ZCSG(oom_restarts));
704 add_assoc_long(&statistics,
"hash_restarts",
ZCSG(hash_restarts));
705 add_assoc_long(&statistics,
"manual_restarts",
ZCSG(manual_restarts));
706 add_assoc_long(&statistics,
"misses",
ZSMMG(memory_exhausted)?
ZCSG(misses):
ZCSG(misses)-
ZCSG(blacklist_misses));
707 add_assoc_long(&statistics,
"blacklist_misses",
ZCSG(blacklist_misses));
709 add_assoc_double(&statistics,
"blacklist_miss_ratio", reqs?(((
double)
ZCSG(blacklist_misses))/reqs)*100.0:0);
710 add_assoc_double(&statistics,
"opcache_hit_rate", reqs?(((
double)
ZCSG(hits))/reqs)*100.0:0);
711 add_assoc_zval(
return_value,
"opcache_statistics", &statistics);
713 if (
ZCSG(preload_script)) {
716 add_assoc_long(&statistics,
"memory_consumption",
ZCSG(preload_script)->dynamic_members.memory_consumption);
718 if (zend_hash_num_elements(&
ZCSG(preload_script)->script.function_table)) {
725 add_assoc_zval(&statistics,
"functions", &scripts);
728 if (zend_hash_num_elements(&
ZCSG(preload_script)->script.class_table)) {
740 add_assoc_zval(&statistics,
"classes", &scripts);
743 if (
ZCSG(saved_scripts)) {
751 add_assoc_zval(&statistics,
"scripts", &scripts);
753 add_assoc_zval(
return_value,
"preload_statistics", &statistics);
758 if (accelerator_get_scripts(&scripts)) {
776 zval directives, version, blacklist;
782 if (!validate_api_restriction()) {
790 add_assoc_bool(&directives,
"opcache.enable",
ZCG(enabled));
791 add_assoc_bool(&directives,
"opcache.enable_cli",
ZCG(accel_directives).enable_cli);
792 add_assoc_bool(&directives,
"opcache.use_cwd",
ZCG(accel_directives).use_cwd);
793 add_assoc_bool(&directives,
"opcache.validate_timestamps",
ZCG(accel_directives).validate_timestamps);
794 add_assoc_bool(&directives,
"opcache.validate_permission",
ZCG(accel_directives).validate_permission);
796 add_assoc_bool(&directives,
"opcache.validate_root",
ZCG(accel_directives).validate_root);
798 add_assoc_bool(&directives,
"opcache.dups_fix",
ZCG(accel_directives).ignore_dups);
799 add_assoc_bool(&directives,
"opcache.revalidate_path",
ZCG(accel_directives).revalidate_path);
801 add_assoc_long(&directives,
"opcache.log_verbosity_level",
ZCG(accel_directives).log_verbosity_level);
802 add_assoc_long(&directives,
"opcache.memory_consumption",
ZCG(accel_directives).memory_consumption);
803 add_assoc_long(&directives,
"opcache.interned_strings_buffer",
ZCG(accel_directives).interned_strings_buffer);
804 add_assoc_long(&directives,
"opcache.max_accelerated_files",
ZCG(accel_directives).max_accelerated_files);
805 add_assoc_double(&directives,
"opcache.max_wasted_percentage",
ZCG(accel_directives).max_wasted_percentage);
806 add_assoc_long(&directives,
"opcache.force_restart_timeout",
ZCG(accel_directives).force_restart_timeout);
807 add_assoc_long(&directives,
"opcache.revalidate_freq",
ZCG(accel_directives).revalidate_freq);
808 add_assoc_string(&directives,
"opcache.preferred_memory_model",
STRING_NOT_NULL(
ZCG(accel_directives).memory_model));
809 add_assoc_string(&directives,
"opcache.blacklist_filename",
STRING_NOT_NULL(
ZCG(accel_directives).user_blacklist_filename));
810 add_assoc_long(&directives,
"opcache.max_file_size",
ZCG(accel_directives).max_file_size);
813 add_assoc_bool(&directives,
"opcache.protect_memory",
ZCG(accel_directives).protect_memory);
814 add_assoc_bool(&directives,
"opcache.save_comments",
ZCG(accel_directives).save_comments);
815 add_assoc_bool(&directives,
"opcache.record_warnings",
ZCG(accel_directives).record_warnings);
816 add_assoc_bool(&directives,
"opcache.enable_file_override",
ZCG(accel_directives).file_override_enabled);
817 add_assoc_long(&directives,
"opcache.optimization_level",
ZCG(accel_directives).optimization_level);
820 add_assoc_string(&directives,
"opcache.lockfile_path",
STRING_NOT_NULL(
ZCG(accel_directives).lockfile_path));
822 add_assoc_string(&directives,
"opcache.mmap_base",
STRING_NOT_NULL(
ZCG(accel_directives).mmap_base));
825 add_assoc_string(&directives,
"opcache.file_cache",
ZCG(accel_directives).file_cache ?
ZCG(accel_directives).file_cache :
"");
826 add_assoc_bool(&directives,
"opcache.file_cache_only",
ZCG(accel_directives).
file_cache_only);
827 add_assoc_bool(&directives,
"opcache.file_cache_consistency_checks",
ZCG(accel_directives).file_cache_consistency_checks);
828#if ENABLE_FILE_CACHE_FALLBACK
829 add_assoc_bool(&directives,
"opcache.file_cache_fallback",
ZCG(accel_directives).file_cache_fallback);
832 add_assoc_long(&directives,
"opcache.file_update_protection",
ZCG(accel_directives).file_update_protection);
833 add_assoc_long(&directives,
"opcache.opt_debug_level",
ZCG(accel_directives).opt_debug_level);
834 add_assoc_string(&directives,
"opcache.restrict_api",
STRING_NOT_NULL(
ZCG(accel_directives).restrict_api));
835#ifdef HAVE_HUGE_CODE_PAGES
836 add_assoc_bool(&directives,
"opcache.huge_code_pages",
ZCG(accel_directives).huge_code_pages);
840 add_assoc_string(&directives,
"opcache.preload_user",
STRING_NOT_NULL(
ZCG(accel_directives).preload_user));
843 add_assoc_string(&directives,
"opcache.cache_id",
STRING_NOT_NULL(
ZCG(accel_directives).cache_id));
846 add_assoc_string(&directives,
"opcache.jit",
JIT_G(
options));
847 add_assoc_long(&directives,
"opcache.jit_buffer_size",
JIT_G(buffer_size));
848 add_assoc_long(&directives,
"opcache.jit_debug",
JIT_G(
debug));
849 add_assoc_long(&directives,
"opcache.jit_bisect_limit",
JIT_G(bisect_limit));
850 add_assoc_long(&directives,
"opcache.jit_blacklist_root_trace",
JIT_G(blacklist_root_trace));
851 add_assoc_long(&directives,
"opcache.jit_blacklist_side_trace",
JIT_G(blacklist_side_trace));
852 add_assoc_long(&directives,
"opcache.jit_hot_func",
JIT_G(hot_func));
853 add_assoc_long(&directives,
"opcache.jit_hot_loop",
JIT_G(hot_loop));
854 add_assoc_long(&directives,
"opcache.jit_hot_return",
JIT_G(hot_return));
855 add_assoc_long(&directives,
"opcache.jit_hot_side_exit",
JIT_G(hot_side_exit));
856 add_assoc_long(&directives,
"opcache.jit_max_exit_counters",
JIT_G(max_exit_counters));
857 add_assoc_long(&directives,
"opcache.jit_max_loop_unrolls",
JIT_G(max_loop_unrolls));
858 add_assoc_long(&directives,
"opcache.jit_max_polymorphic_calls",
JIT_G(max_polymorphic_calls));
859 add_assoc_long(&directives,
"opcache.jit_max_recursive_calls",
JIT_G(max_recursive_calls));
860 add_assoc_long(&directives,
"opcache.jit_max_recursive_returns",
JIT_G(max_recursive_returns));
861 add_assoc_long(&directives,
"opcache.jit_max_root_traces",
JIT_G(max_root_traces));
862 add_assoc_long(&directives,
"opcache.jit_max_side_traces",
JIT_G(max_side_traces));
863 add_assoc_double(&directives,
"opcache.jit_prof_threshold",
JIT_G(prof_threshold));
864 add_assoc_long(&directives,
"opcache.jit_max_trace_length",
JIT_G(max_trace_length));
867 add_assoc_zval(
return_value,
"directives", &directives);
871 add_assoc_string(&version,
"version",
PHP_VERSION);
888 if (!validate_api_restriction()) {
917 if (!validate_api_restriction()) {
951 uint32_t orig_compiler_options;
964 orig_execute_data =
EG(current_execute_data);
965 orig_compiler_options =
CG(compiler_options);
977 EG(current_execute_data) = orig_execute_data;
982 CG(compiler_options) = orig_compiler_options;
984 if(op_array !=
NULL) {
1003 if (!validate_api_restriction()) {
1007 if (!
ZCG(accelerator_enabled)) {
zend_accel_globals accel_globals
zend_result validate_timestamp_and_record_ex(zend_persistent_script *persistent_script, zend_file_handle *file_handle)
zend_result zend_accel_invalidate(zend_string *filename, bool force)
zend_result accelerator_shm_read_lock(void)
zend_op_array * persistent_compile_file(zend_file_handle *file_handle, int type)
void zend_accel_schedule_restart(zend_accel_restart_reason reason)
zend_string * accel_make_persistent_key(zend_string *str)
void accelerator_shm_read_unlock(void)
zend_result accel_post_deactivate(void)
void accel_shutdown(void)
zend_accel_shared_globals * accel_shared_globals
const char * zps_api_failure_reason
#define ACCELERATOR_PRODUCT_NAME
struct _zend_persistent_script zend_persistent_script
#define ENABLE_FILE_CACHE_FALLBACK
struct _zend_accel_globals zend_accel_globals
error_log(string $message, int $message_type=0, ?string $destination=null, ?string $additional_headers=null)
zend_ffi_ctype_name_buf buf
hash(string $algo, string $data, bool $binary=false, array $options=[])
opcache_is_script_cached(string $filename)
opcache_get_configuration()
opcache_get_status(bool $include_scripts=true)
opcache_invalidate(string $filename, bool $force=false)
opcache_jit_blacklist(Closure $closure)
opcache_compile_file(string $filename)
php_info_print_table_start()
php_info_print_table_row(2, "PDO Driver for Firebird", "enabled")
php_info_print_table_end()
PHPAPI zend_string * php_format_date(const char *format, size_t format_len, time_t ts, bool localtime)
localtime(?int $timestamp=null, bool $associative=false)
unsigned const char * end
#define STD_PHP_INI_ENTRY
#define STD_PHP_INI_BOOLEAN
PHP_JSON_API size_t int options
unsigned char key[REFLECTION_KEY_LEN]
zend_accel_hash_entry * next
zend_string * function_name
unsigned int memory_consumption
struct _zend_persistent_script::zend_persistent_script_dynamic_members dynamic_members
zend_internal_function internal_function
ZEND_API ZEND_COLD void zend_error(int type, const char *format,...)
#define INTERNAL_FUNCTION_PARAMETERS
#define INTERNAL_FUNCTION_PARAM_PASSTHRU
ZEND_API zend_result add_next_index_stringl(zval *arg, const char *str, size_t length)
ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec,...)
ZEND_API zend_result zend_startup_module(zend_module_entry *module)
ZEND_API zend_result add_next_index_str(zval *arg, zend_string *str)
#define ZEND_PARSE_PARAMETERS_END()
#define ZEND_MINIT_FUNCTION
#define zend_parse_parameters_none()
#define Z_PARAM_STR(dest)
#define ZEND_PARSE_PARAMETERS_START(min_num_args, max_num_args)
#define ZEND_NAMED_FUNCTION(name)
#define ZEND_FUNCTION(name)
#define ZEND_MSHUTDOWN_FUNCTION
void zend_accel_blacklist_apply(zend_blacklist *blacklist, blacklist_apply_func_arg_t func, void *argument)
zend_blacklist accel_blacklist
struct _zend_blacklist_entry zend_blacklist_entry
void zend_accel_error(int type, const char *format,...)
#define ACCEL_LOG_WARNING
void * zend_accel_hash_find(zend_accel_hash *accel_hash, zend_string *key)
struct _zend_accel_hash_entry zend_accel_hash_entry
int start_accel_module(void)
#define STRING_NOT_NULL(s)
void zend_accel_override_file_functions(void)
#define MAX_INTERNED_STRINGS_BUFFER_SIZE
void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS)
ZEND_API const zend_function * zend_get_closure_method_def(zend_object *obj)
ZEND_API zend_class_entry * zend_ce_closure
#define ZEND_COMPILE_WITHOUT_EXECUTION
#define ZEND_USER_CODE(type)
ZEND_API void destroy_op_array(zend_op_array *op_array)
#define ZEND_COMPILE_PRELOAD
struct _zend_op_array zend_op_array
ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle)
void(ZEND_FASTCALL * zif_handler)(INTERNAL_FUNCTION_PARAMETERS)
#define ZEND_CALL_ARG(call, n)
ZEND_API zval * zend_get_constant_str(const char *name, size_t name_len)
ZEND_API void(ZEND_FASTCALL *zend_touch_vm_stack_data)(void *vm_stack_data)
union _zend_function zend_function
ZEND_API zval *ZEND_FASTCALL zend_hash_update(HashTable *ht, zend_string *key, zval *pData)
#define ZEND_HASH_MAP_FOREACH_PTR(ht, _ptr)
#define ZEND_HASH_FOREACH_END()
#define ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(ht, _key, _val)
ZEND_API bool zend_ini_parse_bool(zend_string *str)
ZEND_API zend_long zend_ini_parse_quantity_warn(zend_string *value, zend_string *setting)
#define ZEND_INI_STAGE_SHUTDOWN
#define ZEND_INI_STAGE_STARTUP
#define UNREGISTER_INI_ENTRIES()
#define REGISTER_INI_ENTRIES()
#define DISPLAY_INI_ENTRIES()
#define ZEND_INI_MH(name)
#define ZEND_INI_STAGE_DEACTIVATE
#define ZEND_INI_GET_ADDR()
struct _zend_file_handle zend_file_handle
struct _zend_jit_globals zend_jit_globals
zend_jit_globals jit_globals
ZEND_EXT_API void zend_jit_blacklist_function(zend_op_array *op_array)
#define ZEND_JIT_TRACE_MAX_CALL_DEPTH
#define ZEND_JIT_TRACE_MAX_LOOPS_UNROLL
#define ZEND_JIT_TRACE_MAX_LENGTH
int zend_jit_debug_config(zend_long old_val, zend_long new_val, int stage)
int zend_jit_config(zend_string *jit_options, int stage)
#define ZEND_JIT_TRACE_MAX_RET_DEPTH
ZEND_EXT_API void zend_jit_status(zval *ret)
#define ZEND_JIT_DEFAULT_BUFFER_SIZE
struct _zend_string zend_string
#define ZEND_MODULE_INFO_FUNC_ARGS
#define NO_MODULE_GLOBALS
#define STANDARD_MODULE_HEADER
struct _zend_module_entry zend_module_entry
#define STANDARD_MODULE_PROPERTIES_EX
#define DEFAULT_OPTIMIZATION_LEVEL
#define UNEXPECTED(condition)
void zend_shared_alloc_lock(void)
const char * zend_accel_get_shared_model(void)
void zend_shared_alloc_unlock(void)
size_t zend_shared_alloc_get_free_memory(void)
ZEND_API void zend_stream_init_filename_ex(zend_file_handle *handle, zend_string *filename)
#define Z_STRVAL_P(zval_p)
#define Z_ARRVAL_P(zval_p)
#define Z_STRLEN_P(zval_p)
struct _zend_execute_data zend_execute_data
#define IS_ABSOLUTE_PATH(path, len)