<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                在閱讀PHP源碼的時候,會遇到很多宏。如果不了解這些宏的含義,對代碼理解會帶來很多困擾。現在我們就一起來看看CG和EG兩個宏的含義。 ## CG ### 含義 CG的含義是 `compiler_globals`。Zend編譯器相關的全局變量。 ### 作用 大家都知道PHP代碼最終是轉化為Opcode去執行的。在PHP轉換為Opcode過程中需要保存一些信息。這些信息就保存在CG全局變量中。 如果想了解Zend是如何把PHP代碼轉換為Opcode,使用GC全局變量保存了那些信息,可以查看 [Zend/zend_language_scanner.c ](https://github.com/php/php-src/blob/master/Zend/zend_language_scanner.c)文件的 `compile_file(zend_file_handle *file_handle, int type)`方法 ### 代碼 在 [Zend/zend_globals_macros.h ](https://github.com/php/php-src/blob/master/Zend/zend_globals_macros.h)文件中有這個宏的相關代碼。如下: ```c /* Compiler */ #ifdef ZTS <h1>define CG(v) ZEND_TSRMG(compiler_globals_id, zend_compiler_globals *, v)</h1> #else <h1>define CG(v) (compiler_globals.v)</h1> extern ZEND_API struct _zend_compiler_globals compiler_globals; #endif ``` ## EG ### 含義 EG的含義是 `executor_globals`。Zend執行器相關的全局變量。 ### 作用 Zend引擎在執行Opcode的時候,需要記錄一些執行過程中的狀態。如,當前執行的類作用域,當前已經加載了那些文件,等。 ### 代碼 在 [Zend/zend_globals_macros.h](https://github.com/php/php-src/blob/master/Zend/zend_globals_macros.h) 文件中有這個宏的相關代碼。如下: ```c /* Executor */ #ifdef ZTS <h1>define EG(v) ZEND_TSRMG(executor_globals_id, zend_executor_globals *, v)</h1> #else <h1>define EG(v) (executor_globals.v)</h1> extern ZEND_API zend_executor_globals executor_globals; #endif ``` ### 其他 EG和CG有一些數據是共用的。如,`function_table` (存儲方法信息) ,`class_table` (存儲類信息) 。 相關代碼在[Zend/zend_execute_API.c](https://github.com/php/php-src/blob/master/Zend/zend_execute_API.c)的`init_executor`方法中發現如下代碼: ```c void init_executor(void) /* {{{ */ { zend_init_fpu(); ...... EG(function_table) = CG(function_table); EG(class_table) = CG(class_table); ...... } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看