php-5.6.26源代码 - opcode执行

 

文件 php-5.6.26/Zend/zend_vm_execute.h

ZEND_API void execute_ex(zend_execute_data *execute_data TSRMLS_DC)
{
    DCL_OPLINE
    zend_bool original_in_execution;



    original_in_execution = EG(in_execution);  // 保存现场
    EG(in_execution) = 1; // 正在执行中 

    if (0) {
zend_vm_enter:
        execute_data = i_create_execute_data_from_op_array(EG(active_op_array), 1 TSRMLS_CC);
    }

    LOAD_REGS();
    LOAD_OPLINE();

    while (1) {
        int ret;
#ifdef ZEND_WIN32
        if (EG(timed_out)) {
            zend_timeout(0);
        }
#endif

        if ((ret = OPLINE->handler(execute_data TSRMLS_CC)) > 0) {  // execute_data.opline->handler(execute_data TSRMLS_CC) //  操作码对应的处理函数
            switch (ret) {
                case 1:
                    EG(in_execution) = original_in_execution; // 还原现场
                    return;
                case 2:
                    goto zend_vm_enter; // 进入虚拟机
                    break;
                case 3:
                    execute_data = EG(current_execute_data);  // 当前正在执行的数据 
                    break;
                default:
                    break;
            }
        }

    }
    zend_error_noreturn(E_ERROR, "Arrived at end of main loop which shouldn't happen");
}

ZEND_API void zend_execute(zend_op_array *op_array TSRMLS_DC)
{
    if (EG(exception)) {
        return;
    } 
    zend_execute_ex(i_create_execute_data_from_op_array(op_array, 0 TSRMLS_CC) TSRMLS_CC); // zend_execute_ex = execute_ex
}

 

posted on 2018-03-23 10:26  周~~  阅读(174)  评论(0编辑  收藏  举报

导航