zend_globals.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. /*
  2. +----------------------------------------------------------------------+
  3. | Zend Engine |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 2.00 of the Zend 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. | http://www.zend.com/license/2_00.txt. |
  11. | If you did not receive a copy of the Zend license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@zend.com so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Authors: Andi Gutmans <andi@php.net> |
  16. | Zeev Suraski <zeev@php.net> |
  17. +----------------------------------------------------------------------+
  18. */
  19. #ifndef ZEND_GLOBALS_H
  20. #define ZEND_GLOBALS_H
  21. #include <setjmp.h>
  22. #include "zend_globals_macros.h"
  23. #include "zend_stack.h"
  24. #include "zend_ptr_stack.h"
  25. #include "zend_hash.h"
  26. #include "zend_llist.h"
  27. #include "zend_objects.h"
  28. #include "zend_objects_API.h"
  29. #include "zend_modules.h"
  30. #include "zend_float.h"
  31. #include "zend_multibyte.h"
  32. #include "zend_multiply.h"
  33. #include "zend_arena.h"
  34. /* Define ZTS if you want a thread-safe Zend */
  35. /*#undef ZTS*/
  36. #ifdef ZTS
  37. BEGIN_EXTERN_C()
  38. ZEND_API extern int compiler_globals_id;
  39. ZEND_API extern int executor_globals_id;
  40. ZEND_API extern size_t compiler_globals_offset;
  41. ZEND_API extern size_t executor_globals_offset;
  42. END_EXTERN_C()
  43. #endif
  44. #define SYMTABLE_CACHE_SIZE 32
  45. #include "zend_compile.h"
  46. /* excpt.h on Digital Unix 4.0 defines function_table */
  47. #undef function_table
  48. typedef struct _zend_vm_stack *zend_vm_stack;
  49. typedef struct _zend_ini_entry zend_ini_entry;
  50. typedef struct _zend_fiber_context zend_fiber_context;
  51. typedef struct _zend_fiber zend_fiber;
  52. struct _zend_compiler_globals {
  53. zend_stack loop_var_stack;
  54. zend_class_entry *active_class_entry;
  55. zend_string *compiled_filename;
  56. int zend_lineno;
  57. zend_op_array *active_op_array;
  58. HashTable *function_table; /* function symbol table */
  59. HashTable *class_table; /* class table */
  60. HashTable *auto_globals;
  61. /* Refer to zend_yytnamerr() in zend_language_parser.y for meaning of values */
  62. zend_uchar parse_error;
  63. bool in_compilation;
  64. bool short_tags;
  65. bool unclean_shutdown;
  66. bool ini_parser_unbuffered_errors;
  67. zend_llist open_files;
  68. struct _zend_ini_parser_param *ini_parser_param;
  69. bool skip_shebang;
  70. bool increment_lineno;
  71. bool variable_width_locale; /* UTF-8, Shift-JIS, Big5, ISO 2022, EUC, etc */
  72. bool ascii_compatible_locale; /* locale uses ASCII characters as singletons */
  73. /* and don't use them as lead/trail units */
  74. zend_string *doc_comment;
  75. uint32_t extra_fn_flags;
  76. uint32_t compiler_options; /* set of ZEND_COMPILE_* constants */
  77. zend_oparray_context context;
  78. zend_file_context file_context;
  79. zend_arena *arena;
  80. HashTable interned_strings;
  81. const zend_encoding **script_encoding_list;
  82. size_t script_encoding_list_size;
  83. bool multibyte;
  84. bool detect_unicode;
  85. bool encoding_declared;
  86. zend_ast *ast;
  87. zend_arena *ast_arena;
  88. zend_stack delayed_oplines_stack;
  89. HashTable *memoized_exprs;
  90. int memoize_mode;
  91. void *map_ptr_real_base;
  92. void *map_ptr_base;
  93. size_t map_ptr_size;
  94. size_t map_ptr_last;
  95. HashTable *delayed_variance_obligations;
  96. HashTable *delayed_autoloads;
  97. HashTable *unlinked_uses;
  98. zend_class_entry *current_linking_class;
  99. uint32_t rtd_key_counter;
  100. zend_stack short_circuiting_opnums;
  101. };
  102. struct _zend_executor_globals {
  103. zval uninitialized_zval;
  104. zval error_zval;
  105. /* symbol table cache */
  106. zend_array *symtable_cache[SYMTABLE_CACHE_SIZE];
  107. /* Pointer to one past the end of the symtable_cache */
  108. zend_array **symtable_cache_limit;
  109. /* Pointer to first unused symtable_cache slot */
  110. zend_array **symtable_cache_ptr;
  111. zend_array symbol_table; /* main symbol table */
  112. HashTable included_files; /* files already included */
  113. JMP_BUF *bailout;
  114. int error_reporting;
  115. int exit_status;
  116. HashTable *function_table; /* function symbol table */
  117. HashTable *class_table; /* class table */
  118. HashTable *zend_constants; /* constants table */
  119. zval *vm_stack_top;
  120. zval *vm_stack_end;
  121. zend_vm_stack vm_stack;
  122. size_t vm_stack_page_size;
  123. struct _zend_execute_data *current_execute_data;
  124. zend_class_entry *fake_scope; /* used to avoid checks accessing properties */
  125. uint32_t jit_trace_num; /* Used by tracing JIT to reference the currently running trace */
  126. zend_long precision;
  127. int ticks_count;
  128. uint32_t persistent_constants_count;
  129. uint32_t persistent_functions_count;
  130. uint32_t persistent_classes_count;
  131. HashTable *in_autoload;
  132. bool full_tables_cleanup;
  133. /* for extended information support */
  134. bool no_extensions;
  135. bool vm_interrupt;
  136. bool timed_out;
  137. zend_long hard_timeout;
  138. #ifdef ZEND_WIN32
  139. OSVERSIONINFOEX windows_version_info;
  140. #endif
  141. HashTable regular_list;
  142. HashTable persistent_list;
  143. int user_error_handler_error_reporting;
  144. zval user_error_handler;
  145. zval user_exception_handler;
  146. zend_stack user_error_handlers_error_reporting;
  147. zend_stack user_error_handlers;
  148. zend_stack user_exception_handlers;
  149. zend_error_handling_t error_handling;
  150. zend_class_entry *exception_class;
  151. /* timeout support */
  152. zend_long timeout_seconds;
  153. int capture_warnings_during_sccp;
  154. HashTable *ini_directives;
  155. HashTable *modified_ini_directives;
  156. zend_ini_entry *error_reporting_ini_entry;
  157. zend_objects_store objects_store;
  158. zend_object *exception, *prev_exception;
  159. const zend_op *opline_before_exception;
  160. zend_op exception_op[3];
  161. struct _zend_module_entry *current_module;
  162. bool active;
  163. zend_uchar flags;
  164. zend_long assertions;
  165. uint32_t ht_iterators_count; /* number of allocated slots */
  166. uint32_t ht_iterators_used; /* number of used slots */
  167. HashTableIterator *ht_iterators;
  168. HashTableIterator ht_iterators_slots[16];
  169. void *saved_fpu_cw_ptr;
  170. #if XPFPA_HAVE_CW
  171. XPFPA_CW_DATATYPE saved_fpu_cw;
  172. #endif
  173. zend_function trampoline;
  174. zend_op call_trampoline_op;
  175. HashTable weakrefs;
  176. bool exception_ignore_args;
  177. zend_long exception_string_param_max_len;
  178. zend_get_gc_buffer get_gc_buffer;
  179. zend_fiber_context *main_fiber_context;
  180. zend_fiber_context *current_fiber_context;
  181. /* Active instance of Fiber. */
  182. zend_fiber *active_fiber;
  183. /* Default fiber C stack size. */
  184. zend_long fiber_stack_size;
  185. /* If record_errors is enabled, all emitted diagnostics will be recorded,
  186. * in addition to being processed as usual. */
  187. bool record_errors;
  188. uint32_t num_errors;
  189. zend_error_info **errors;
  190. void *reserved[ZEND_MAX_RESERVED_RESOURCES];
  191. };
  192. #define EG_FLAGS_INITIAL (0)
  193. #define EG_FLAGS_IN_SHUTDOWN (1<<0)
  194. #define EG_FLAGS_OBJECT_STORE_NO_REUSE (1<<1)
  195. #define EG_FLAGS_IN_RESOURCE_SHUTDOWN (1<<2)
  196. struct _zend_ini_scanner_globals {
  197. zend_file_handle *yy_in;
  198. zend_file_handle *yy_out;
  199. unsigned int yy_leng;
  200. unsigned char *yy_start;
  201. unsigned char *yy_text;
  202. unsigned char *yy_cursor;
  203. unsigned char *yy_marker;
  204. unsigned char *yy_limit;
  205. int yy_state;
  206. zend_stack state_stack;
  207. zend_string *filename;
  208. int lineno;
  209. /* Modes are: ZEND_INI_SCANNER_NORMAL, ZEND_INI_SCANNER_RAW, ZEND_INI_SCANNER_TYPED */
  210. int scanner_mode;
  211. };
  212. typedef enum {
  213. ON_TOKEN,
  214. ON_FEEDBACK,
  215. ON_STOP
  216. } zend_php_scanner_event;
  217. struct _zend_php_scanner_globals {
  218. zend_file_handle *yy_in;
  219. zend_file_handle *yy_out;
  220. unsigned int yy_leng;
  221. unsigned char *yy_start;
  222. unsigned char *yy_text;
  223. unsigned char *yy_cursor;
  224. unsigned char *yy_marker;
  225. unsigned char *yy_limit;
  226. int yy_state;
  227. zend_stack state_stack;
  228. zend_ptr_stack heredoc_label_stack;
  229. zend_stack nest_location_stack; /* for syntax error reporting */
  230. bool heredoc_scan_ahead;
  231. int heredoc_indentation;
  232. bool heredoc_indentation_uses_spaces;
  233. /* original (unfiltered) script */
  234. unsigned char *script_org;
  235. size_t script_org_size;
  236. /* filtered script */
  237. unsigned char *script_filtered;
  238. size_t script_filtered_size;
  239. /* input/output filters */
  240. zend_encoding_filter input_filter;
  241. zend_encoding_filter output_filter;
  242. const zend_encoding *script_encoding;
  243. /* initial string length after scanning to first variable */
  244. int scanned_string_len;
  245. /* hooks */
  246. void (*on_event)(
  247. zend_php_scanner_event event, int token, int line,
  248. const char *text, size_t length, void *context);
  249. void *on_event_context;
  250. };
  251. #endif /* ZEND_GLOBALS_H */