这里阅读的php版本为PHP-7.1.0 RC3,阅读代码的平台为linux
CG
CG是从全局的compiler_global中获取属性值,里面存储的就是编译过程使用到的全局变量。
01 | struct _zend_compiler_globals { |
02 | zend_stack loop_var_stack; |
04 | zend_class_entry *active_class_entry; |
06 | zend_string *compiled_filename; |
10 | zend_op_array *active_op_array; |
12 | HashTable *function_table; |
13 | HashTable *class_table; |
15 | HashTable filenames_table; |
17 | HashTable *auto_globals; |
19 | zend_bool parse_error; |
20 | zend_bool in_compilation; |
23 | zend_bool unclean_shutdown; |
25 | zend_bool ini_parser_unbuffered_errors; |
27 | zend_llist open_files; |
29 | struct _zend_ini_parser_param *ini_parser_param; |
31 | uint32_t start_lineno; |
32 | zend_bool increment_lineno; |
34 | zend_string *doc_comment; |
35 | uint32_t extra_fn_flags; |
37 | uint32_t compiler_options; |
39 | HashTable const_filenames; |
41 | zend_oparray_context context; |
42 | zend_file_context file_context; |
46 | zend_string *empty_string; |
47 | zend_string *one_char_string[256]; |
48 | zend_string **known_strings; |
49 | uint32_t known_strings_count; |
51 | HashTable interned_strings; |
53 | const zend_encoding **script_encoding_list; |
54 | size_t script_encoding_list_size; |
56 | zend_bool detect_unicode; |
57 | zend_bool encoding_declared; |
60 | zend_arena *ast_arena; |
62 | zend_stack delayed_oplines_stack; |
65 | zval **static_members_table; |
66 | int last_static_member; |
SG
01 | SG是从全局的sapi_global中获取属性值 |
04 | typedef struct _sapi_globals_struct { |
06 | sapi_request_info request_info; |
07 | sapi_headers_struct sapi_headers; |
08 | int64_t read_post_bytes; |
09 | unsigned char post_read; |
10 | unsigned char headers_sent; |
11 | zend_stat_t global_stat; |
12 | char *default_mimetype; |
13 | char *default_charset; |
14 | HashTable *rfc1867_uploaded_files; |
15 | zend_long post_max_size; |
17 | zend_bool sapi_started; |
18 | double global_request_time; |
19 | HashTable known_post_content_types; |
21 | zend_fcall_info_cache fci_cache; |
22 | } sapi_globals_struct; |
EG
EG是从executor_globals中获取变量
02 | struct _zend_executor_globals { |
03 | zval uninitialized_zval; |
07 | zend_array *symtable_cache[SYMTABLE_CACHE_SIZE]; |
08 | zend_array **symtable_cache_limit; |
09 | zend_array **symtable_cache_ptr; |
11 | zend_array symbol_table; |
13 | HashTable included_files; |
20 | HashTable *function_table; |
21 | HashTable *class_table; |
22 | HashTable *zend_constants; |
26 | zend_vm_stack vm_stack; |
28 | struct _zend_execute_data *current_execute_data; |
29 | zend_class_entry *fake_scope; |
35 | HashTable *in_autoload; |
36 | zend_function *autoload_func; |
37 | zend_bool full_tables_cleanup; |
40 | zend_bool no_extensions; |
42 | zend_bool vm_interrupt; |
44 | zend_long hard_timeout; |
47 | OSVERSIONINFOEX windows_version_info; |
50 | HashTable regular_list; |
51 | HashTable persistent_list; |
53 | int user_error_handler_error_reporting; |
54 | zval user_error_handler; |
55 | zval user_exception_handler; |
56 | zend_stack user_error_handlers_error_reporting; |
57 | zend_stack user_error_handlers; |
58 | zend_stack user_exception_handlers; |
60 | zend_error_handling_t error_handling; |
61 | zend_class_entry *exception_class; |
64 | zend_long timeout_seconds; |
68 | HashTable *ini_directives; |
69 | HashTable *modified_ini_directives; |
70 | zend_ini_entry *error_reporting_ini_entry; |
72 | zend_objects_store objects_store; |
73 | zend_object *exception, *prev_exception; |
74 | const zend_op *opline_before_exception; |
75 | zend_op exception_op[3]; |
77 | struct _zend_module_entry *current_module; |
80 | zend_bool valid_symbol_table; |
84 | uint32_t ht_iterators_count; |
85 | uint32_t ht_iterators_used; |
86 | HashTableIterator *ht_iterators; |
87 | HashTableIterator ht_iterators_slots[16]; |
89 | void *saved_fpu_cw_ptr; |
91 | XPFPA_CW_DATATYPE saved_fpu_cw; |
94 | zend_function trampoline; |
95 | zend_op call_trampoline_op; |
97 | void *reserved[ZEND_MAX_RESERVED_RESOURCES]; |