php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
ZendAccelerator.h
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Zend OPcache |
4 +----------------------------------------------------------------------+
5 | Copyright (c) The PHP Group |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | https://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
15 | Authors: Andi Gutmans <andi@php.net> |
16 | Zeev Suraski <zeev@php.net> |
17 | Stanislav Malyshev <stas@zend.com> |
18 | Dmitry Stogov <dmitry@php.net> |
19 +----------------------------------------------------------------------+
20*/
21
22#ifndef ZEND_ACCELERATOR_H
23#define ZEND_ACCELERATOR_H
24
25#ifdef HAVE_CONFIG_H
26# include <config.h>
27#endif
28
29#define ACCELERATOR_PRODUCT_NAME "Zend OPcache"
30/* 2 - added Profiler support, on 20010712 */
31/* 3 - added support for Optimizer's encoded-only-files mode */
32/* 4 - works with the new Optimizer, that supports the file format with licenses */
33/* 5 - API 4 didn't really work with the license-enabled file format. v5 does. */
34/* 6 - Monitor was removed from ZendPlatform.so, to a module of its own */
35/* 7 - Optimizer was embedded into Accelerator */
36/* 8 - Standalone Open Source Zend OPcache */
37#define ACCELERATOR_API_NO 8
38
39#ifdef ZEND_WIN32
40# include "zend_config.w32.h"
41#else
42#include "zend_config.h"
43# include <sys/time.h>
44# include <sys/resource.h>
45#endif
46
47#ifdef HAVE_UNISTD_H
48# include <unistd.h>
49#endif
50
51#include "zend_extensions.h"
52#include "zend_compile.h"
53#include "zend_API.h"
54
58
59#ifndef PHPAPI
60# ifdef ZEND_WIN32
61# define PHPAPI __declspec(dllimport)
62# else
63# define PHPAPI
64# endif
65#endif
66
67#ifndef ZEND_EXT_API
68# ifdef ZEND_WIN32
69# define ZEND_EXT_API __declspec(dllexport)
70# elif defined(__GNUC__) && __GNUC__ >= 4
71# define ZEND_EXT_API __attribute__ ((visibility("default")))
72# else
73# define ZEND_EXT_API
74# endif
75#endif
76
77#ifdef ZEND_WIN32
78# ifndef MAXPATHLEN
79# include "win32/ioutil.h"
80# define MAXPATHLEN PHP_WIN32_IOUTIL_MAXPATHLEN
81# endif
82# include <direct.h>
83#else
84# ifndef MAXPATHLEN
85# define MAXPATHLEN 4096
86# endif
87# include <sys/param.h>
88#endif
89
90/*** file locking ***/
91#ifndef ZEND_WIN32
92extern int lock_file;
93#endif
94
95#if defined(ZEND_WIN32)
96# define ENABLE_FILE_CACHE_FALLBACK 1
97#else
98# define ENABLE_FILE_CACHE_FALLBACK 0
99#endif
100
101#ifdef ZEND_WIN32
102typedef unsigned __int64 accel_time_t;
103#else
104typedef time_t accel_time_t;
105#endif
106
108 ACCEL_RESTART_OOM, /* restart because of out of memory */
109 ACCEL_RESTART_HASH, /* restart because of hash overflow */
110 ACCEL_RESTART_USER /* restart scheduled by opcache_reset() */
112
119
122 zend_long compiler_halt_offset; /* position of __HALT_COMPILER or -1 */
123 int ping_auto_globals_mask; /* which autoglobals are used by the script */
124 accel_time_t timestamp; /* the script modification time */
127 bool empty;
128 uint32_t num_warnings;
132
133 void *mem; /* shared memory area used by script structures */
134 size_t size; /* size of used shared memory */
135
143
160#ifndef ZEND_WIN32
162#endif
166#ifdef ZEND_WIN32
167 char *mmap_base;
168#endif
171
177#ifndef ZEND_WIN32
179#endif
183#if ENABLE_FILE_CACHE_FALLBACK
184 bool file_cache_fallback;
185#endif
186#ifdef HAVE_HUGE_CODE_PAGES
187 bool huge_code_pages;
188#endif
189 char *preload;
190#ifndef ZEND_WIN32
192#endif
193#ifdef ZEND_WIN32
194 char *cache_id;
195#endif
197
198typedef struct _zend_accel_globals {
199 bool counted; /* the process uses shared memory */
201 bool locked; /* thread obtained exclusive lock */
202 bool accelerator_enabled; /* accelerator enabled for current request */
205 zend_string *cwd; /* current working directory or NULL */
206 zend_string *include_path; /* current value of "include_path" directive */
207 char include_path_key[32]; /* key of current "include_path" */
208 char cwd_key[32]; /* key of current working directory */
215 time_t last_restart_time; /* used to synchronize SHM and in-process caches */
217#ifndef ZEND_WIN32
219#endif
222 /* preallocated shared-memory block to save current script */
223 void *mem;
225 /* cache to save hash lookup on the same INCLUDE opcode */
228 /* preallocated buffer for keys */
231
240
241typedef uint32_t zend_string_table_pos_t;
242
243#define ZEND_STRING_TABLE_POS_MAX UINT32_MAX
244#define ZEND_STRING_TABLE_POS_ALIGNMENT 8
245
247 /* Cache Data Structures */
251 zend_ulong oom_restarts; /* number of restarts because of out of memory */
252 zend_ulong hash_restarts; /* number of restarts because of hash overflow */
253 zend_ulong manual_restarts; /* number of restarts scheduled by opcache_reset() */
254 zend_accel_hash hash; /* hash table for cached scripts */
255
258
259 /* Directives & Maintenance */
267#ifdef ZEND_WIN32
268 LONGLONG mem_usage;
269 LONGLONG restart_in;
270#endif
273
274 /* Preloading */
277
278 /* uninitialized HashTable Support */
280
281 /* Tracing JIT */
283 const void **jit_exit_groups;
284
285 /* Interned Strings Support (must be the last element) */
288
289#ifdef ZEND_WIN32
290extern char accel_uname_id[32];
291#endif
292extern bool accel_startup_ok;
293extern bool file_cache_only;
294#if ENABLE_FILE_CACHE_FALLBACK
295extern bool fallback_process;
296#endif
297
299#define ZCSG(element) (accel_shared_globals->element)
300
301#ifdef ZTS
302# define ZCG(v) ZEND_TSRMG(accel_globals_id, zend_accel_globals *, v)
303extern int accel_globals_id;
304# ifdef COMPILE_DL_OPCACHE
306# endif
307#else
308# define ZCG(v) (accel_globals.v)
310#endif
311
312extern const char *zps_api_failure_reason;
313
315
316void accel_shutdown(void);
317ZEND_RINIT_FUNCTION(zend_accelerator);
324zend_result zend_accel_invalidate(zend_string *filename, bool force);
327
330
331#define IS_ACCEL_INTERNED(str) \
332 ((char*)(str) >= (char*)ZCSG(interned_strings).start && (char*)(str) < (char*)ZCSG(interned_strings).top)
333
335
337
339
340/* memory write protection */
341#define SHM_PROTECT() \
342 do { \
343 if (ZCG(accel_directives).protect_memory) { \
344 zend_accel_shared_protect(true); \
345 } \
346 } while (0)
347
348#define SHM_UNPROTECT() \
349 do { \
350 if (ZCG(accel_directives).protect_memory) { \
351 zend_accel_shared_protect(false); \
352 } \
353 } while (0)
354
355#endif /* ZEND_ACCELERATOR_H */
zend_accel_globals accel_globals
zend_result validate_timestamp_and_record_ex(zend_persistent_script *persistent_script, zend_file_handle *file_handle)
accel_time_t zend_get_file_handle_timestamp(zend_file_handle *file_handle, size_t *size)
void zend_accel_schedule_restart_if_necessary(zend_accel_restart_reason reason)
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)
zend_result validate_timestamp_and_record(zend_persistent_script *persistent_script, zend_file_handle *file_handle)
void zend_accel_schedule_restart(zend_accel_restart_reason reason)
zend_string * accel_make_persistent_key(zend_string *str)
bool file_cache_only
void accelerator_shm_read_unlock(void)
zend_result accel_post_deactivate(void)
void accel_shutdown(void)
bool accel_startup_ok
zend_accel_shared_globals * accel_shared_globals
const char * zps_api_failure_reason
#define ZEND_STRING_TABLE_POS_ALIGNMENT
uint32_t zend_accel_get_class_name_map_ptr(zend_string *type_name)
uint32_t zend_string_table_pos_t
struct _zend_persistent_script zend_persistent_script
struct _zend_string_table zend_string_table
zend_string *ZEND_FASTCALL accel_new_interned_string(zend_string *str)
_zend_accel_restart_reason
@ ACCEL_RESTART_USER
@ ACCEL_RESTART_HASH
@ ACCEL_RESTART_OOM
struct _zend_early_binding zend_early_binding
time_t accel_time_t
struct _zend_accel_shared_globals zend_accel_shared_globals
struct _zend_accel_directives zend_accel_directives
enum _zend_accel_restart_reason zend_accel_restart_reason
struct _zend_accel_globals zend_accel_globals
zend_ffi_type * type
Definition ffi.c:3812
new_type size
Definition ffi.c:4365
zend_persistent_script * current_persistent_script
zend_accel_directives accel_directives
const zend_op * cache_opline
size_t preloaded_internal_run_time_cache_size
zend_string * include_path
zend_persistent_script * cache_persistent_script
void * preloaded_internal_run_time_cache
zend_accel_restart_reason restart_reason
zend_persistent_script ** saved_scripts
uint32_t uninitialized_bucket[-HT_MIN_MASK]
zend_persistent_script * preload_script
ZEND_SET_ALIGNED(ZEND_STRING_TABLE_POS_ALIGNMENT, zend_string_table interned_strings)
zend_string * lc_parent_name
zend_early_binding * early_bindings
struct _zend_persistent_script::zend_persistent_script_dynamic_members dynamic_members
zend_error_info ** warnings
zend_string * saved_top
struct _zend_error_info zend_error_info
#define ZEND_TSRMLS_CACHE_EXTERN()
Definition zend.h:67
#define ZEND_RINIT_FUNCTION
Definition zend_API.h:1076
struct _zend_accel_hash zend_accel_hash
struct _zend_op zend_op
struct _zend_op_array zend_op_array
ZEND_API void(ZEND_FASTCALL *zend_touch_vm_stack_data)(void *vm_stack_data)
struct _zend_file_handle zend_file_handle
int32_t zend_long
Definition zend_long.h:42
uint32_t zend_ulong
Definition zend_long.h:43
struct _zend_string zend_string
struct _zend_script zend_script
#define END_EXTERN_C()
#define ZEND_FASTCALL
#define BEGIN_EXTERN_C()
int lock_file
struct _zend_array HashTable
Definition zend_types.h:386
ZEND_RESULT_CODE zend_result
Definition zend_types.h:64
#define HT_MIN_MASK
Definition zend_types.h:431