php内核分析(三)-全局变量

简介:

这里阅读的php版本为PHP-7.1.0 RC3,阅读代码的平台为linux

CG

CG是从全局的compiler_global中获取属性值,里面存储的就是编译过程使用到的全局变量。

struct _zend_compiler_globals {
    zend_stack loop_var_stack;

    zend_class_entry *active_class_entry;

    zend_string *compiled_filename;

    int zend_lineno;

    zend_op_array *active_op_array;

    HashTable *function_table;    /* function symbol table */
    HashTable *class_table;        /* class table */

    HashTable filenames_table;

    HashTable *auto_globals;

    zend_bool parse_error;
    zend_bool in_compilation;
    zend_bool short_tags;

    zend_bool unclean_shutdown;

    zend_bool ini_parser_unbuffered_errors;

    zend_llist open_files;

    struct _zend_ini_parser_param *ini_parser_param;

    uint32_t start_lineno; // 执行文件开始执行的行号
    zend_bool increment_lineno;

    zend_string *doc_comment;
    uint32_t extra_fn_flags;

    uint32_t compiler_options; /* set of ZEND_COMPILE_* constants */

    HashTable const_filenames;

    zend_oparray_context context;
    zend_file_context file_context;

    zend_arena *arena;

    zend_string *empty_string;
    zend_string *one_char_string[256];
    zend_string **known_strings;
    uint32_t    known_strings_count;

    HashTable interned_strings;

    const zend_encoding **script_encoding_list;
    size_t script_encoding_list_size;
    zend_bool multibyte;
    zend_bool detect_unicode;
    zend_bool encoding_declared;

    zend_ast *ast;
    zend_arena *ast_arena;

    zend_stack delayed_oplines_stack;

#ifdef ZTS
    zval **static_members_table;
    int last_static_member;
#endif
};

SG

SG是从全局的sapi_global中获取属性值

// TODO:更新
typedef struct _sapi_globals_struct {
    void *server_context;
    sapi_request_info request_info; // 请求信息
    sapi_headers_struct sapi_headers;
    int64_t read_post_bytes;
    unsigned char post_read;
    unsigned char headers_sent;
    zend_stat_t global_stat;
    char *default_mimetype;
    char *default_charset;
    HashTable *rfc1867_uploaded_files;
    zend_long post_max_size;
    int options;
    zend_bool sapi_started;
    double global_request_time;
    HashTable known_post_content_types;
    zval callback_func;
    zend_fcall_info_cache fci_cache;
} sapi_globals_struct;

EG

EG是从executor_globals中获取变量

// TODO: 更新
struct _zend_executor_globals {
    zval uninitialized_zval;
    zval error_zval;

    /* symbol table cache */
    zend_array *symtable_cache[SYMTABLE_CACHE_SIZE];
    zend_array **symtable_cache_limit;
    zend_array **symtable_cache_ptr;

    zend_array symbol_table;        /* main symbol table */

    HashTable included_files;    /* files already included */

    JMP_BUF *bailout;

    int error_reporting;
    int exit_status;

    HashTable *function_table;    /* function symbol table */
    HashTable *class_table;        /* class table */
    HashTable *zend_constants;    /* constants table */

    zval          *vm_stack_top;
    zval          *vm_stack_end;
    zend_vm_stack  vm_stack;

    struct _zend_execute_data *current_execute_data;
    zend_class_entry *fake_scope; /* used to avoid checks accessing properties */

    zend_long precision;

    int ticks_count;

    HashTable *in_autoload;
    zend_function *autoload_func;
    zend_bool full_tables_cleanup;

    /* for extended information support */
    zend_bool no_extensions;

    zend_bool vm_interrupt;
    zend_bool timed_out;
    zend_long hard_timeout;

#ifdef ZEND_WIN32
    OSVERSIONINFOEX windows_version_info;
#endif

    HashTable regular_list;
    HashTable persistent_list;

    int user_error_handler_error_reporting;
    zval user_error_handler;
    zval user_exception_handler;
    zend_stack user_error_handlers_error_reporting;
    zend_stack user_error_handlers;
    zend_stack user_exception_handlers;

    zend_error_handling_t  error_handling;
    zend_class_entry      *exception_class;

    /* timeout support */
    zend_long timeout_seconds;

    int lambda_count;

    HashTable *ini_directives;
    HashTable *modified_ini_directives;
    zend_ini_entry *error_reporting_ini_entry;

    zend_objects_store objects_store;
    zend_object *exception, *prev_exception;
    const zend_op *opline_before_exception;
    zend_op exception_op[3];

    struct _zend_module_entry *current_module;

    zend_bool active;
    zend_bool valid_symbol_table;

    zend_long assertions;

    uint32_t           ht_iterators_count;     /* number of allocatd slots */
    uint32_t           ht_iterators_used;      /* number of used slots */
    HashTableIterator *ht_iterators;
    HashTableIterator  ht_iterators_slots[16];

    void *saved_fpu_cw_ptr;
#if XPFPA_HAVE_CW
    XPFPA_CW_DATATYPE saved_fpu_cw;
#endif

    zend_function trampoline;
    zend_op       call_trampoline_op;

    void *reserved[ZEND_MAX_RESERVED_RESOURCES];
};


本文转自轩脉刃博客园博客,原文链接:http://www.cnblogs.com/yjf512/p/6097937.html,如需转载请自行联系原作者
相关文章
|
1月前
|
缓存 自然语言处理 PHP
深入PHP内核:理解OPcode和执行生命周期
在PHP的执行过程中,源代码经过词法分析、语法分析等一系列复杂的步骤后,最终会编译成一种叫做“操作码”(OPcode)的中间代码。本文将深入探讨PHP的操作码(OPcode)是什么,它是如何生成的,以及它在整个PHP脚本执行周期中扮演的角色。我们还将了解不同的OPcode优化技术,以及它们如何影响PHP应用程序的性能。通过本文,读者将对PHP的内部工作原理有更深刻的理解,为进一步的性能调优打下坚实的基础。
|
1月前
|
数据采集 前端开发 PHP
深入PHP内核:探索高性能异步编程
【2月更文挑战第24天】在现代Web开发中,提供快速响应和高并发处理能力是至关重要的。传统的同步阻塞模型已无法满足现代互联网服务的需求。本文将深入探讨PHP语言中的异步编程概念,介绍其原理、实现方式以及如何通过异步编程提升应用性能。我们将剖析PHP的多线程扩展,如pthreads,以及事件驱动编程模型,重点关注它们在处理大量并发连接时的优势和潜在问题。此外,文中还将展示如何使用Swoole等高级框架来构建高效的异步应用。最后,我们将讨论异步编程在实际应用中的挑战与未来发展趋势。
16 1
|
1月前
|
数据采集 存储 JavaScript
PHP爬虫技术:利用simple_html_dom库分析汽车之家电动车参数
本文旨在介绍如何利用PHP中的simple_html_dom库结合爬虫代理IP技术来高效采集和分析汽车之家网站的电动车参数。通过实际示例和详细说明,读者将了解如何实现数据分析和爬虫技术的结合应用,从而更好地理解和应用相关技术。
PHP爬虫技术:利用simple_html_dom库分析汽车之家电动车参数
|
9月前
|
PHP
php开发实战分析(4):php调用封装函数包含文件路径自适应不同目录的解决方案($_SERVER[‘DOCUMENT_ROOT‘]与__DIR__魔术常量)
php开发实战分析(4):php调用封装函数包含文件路径自适应不同目录的解决方案($_SERVER[‘DOCUMENT_ROOT‘]与__DIR__魔术常量)
132 0
|
9月前
|
前端开发 JavaScript PHP
php开发实战分析(10):城市区县联动筛选
php开发实战分析(10):城市区县联动筛选
87 1
|
9月前
|
存储 监控 算法
php开发实战分析(9):使用实现短地址的分享的解决方案(第三方短链接服务、数据库自增ID转换、自定义短地址生成算法、自增数字短码)
php开发实战分析(9):使用实现短地址的分享的解决方案(第三方短链接服务、数据库自增ID转换、自定义短地址生成算法、自增数字短码)
184 0
|
9月前
|
SQL 缓存 关系型数据库
php开发实战分析(7):mysql类库操作的高级使用
php开发实战分析(7):mysql类库操作的高级使用
130 0
|
9月前
|
存储 缓存 JSON
php开发实战分析(6):配置文件或缓存文件的生成与调用
php开发实战分析(6):配置文件或缓存文件的生成与调用
103 0
|
9月前
|
存储 缓存 安全
php开发实战分析(5):文件和目录的操作
php开发实战分析(5):文件和目录的操作
105 0
|
9月前
|
SQL 安全 关系型数据库
php开发实战分析(8):mysql类库的操作高级使用API开发(字段操作、权限分配、日期格式、跨表查询,数据分表)
php开发实战分析(8):mysql类库的操作高级使用API开发(字段操作、权限分配、日期格式、跨表查询,数据分表)
299 0