Changeset 1380 in svn for trunk/processor/processor.m4


Ignore:
Timestamp:
2013-09-22T16:45:46+02:00 (22 months ago)
Author:
Xuefer
Message:

make use of SRC/DST widely

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/processor/processor.m4

    r1321 r1380  
    262262DEF_STRUCT_P_FUNC(`zend_function', , `dnl {{{
    263263    DISABLECHECK(`
    264     switch (src->type) {
     264    switch (SRC(`type')) {
    265265    case ZEND_INTERNAL_FUNCTION:
    266266    case ZEND_OVERLOADED_FUNCTION:
     
    394394    STRUCT_ARRAY(int, default_static_members_count, zval_ptr_nullable, default_static_members_table)
    395395    PROCESS(int, default_static_members_count)
    396     IFCOPY(`dst->static_members_table = dst->default_static_members_table;')
     396    IFCOPY(`DST(`static_members_table') = DST(`default_static_members_table');')
    397397    DONE(static_members_table)
    398398#else
    399     IFCOPY(`dst->builtin_functions = src->builtin_functions;')
     399    IFCOPY(`DST(`builtin_functions') = SRC(`builtin_functions');')
    400400    DONE(builtin_functions)
    401401    STRUCT(HashTable, default_properties, HashTable_zval_ptr)
    402402#   ifdef ZEND_ENGINE_2_1
    403403    STRUCT(HashTable, default_static_members, HashTable_zval_ptr)
    404     IFCOPY(`dst->static_members = &dst->default_static_members;')
     404    IFCOPY(`DST(`static_members') = &DST(`default_static_members');')
    405405    DONE(static_members)
    406406#   elif defined(ZEND_ENGINE_2)
     
    426426#else
    427427    IFRESTORE(`
    428         if (src->num_interfaces) {
    429             CALLOC(dst->interfaces, zend_class_entry*, src->num_interfaces)
     428        if (SRC(`num_interfaces')) {
     429            CALLOC(DST(`interfaces'), zend_class_entry*, SRC(`num_interfaces'))
    430430            DONE(`interfaces')
    431431        }
     
    441441#   ifdef ZEND_ENGINE_2_4
    442442    DISABLECHECK(`
    443     IFRESTORE(`dst->info.user.filename = processor->entry_php_src->filepath;', `PROC_STRING(info.user.filename)')
     443    IFRESTORE(`DST(`info.user.filename') = processor->entry_php_src->filepath;', `PROC_STRING(info.user.filename)')
    444444    PROCESS(zend_uint, info.user.line_start)
    445445    PROCESS(zend_uint, info.user.line_end)
     
    449449    DONE(info)
    450450#   else
    451     IFRESTORE(`dst->filename = processor->entry_php_src->filepath;DONE(filename)', `PROC_STRING(filename)')
     451    IFRESTORE(`DST(`filename') = processor->entry_php_src->filepath;DONE(filename)', `PROC_STRING(filename)')
    452452    PROCESS(zend_uint, line_start)
    453453    PROCESS(zend_uint, line_end)
     
    501501    dnl must do after SETNULL(constructor) and dst->parent
    502502    STRUCT(HashTable, function_table, HashTable_zend_function)
    503     IFRESTORE(`dst->function_table.pDestructor = ZEND_FUNCTION_DTOR;')
     503    IFRESTORE(`DST(`function_table.pDestructor') = ZEND_FUNCTION_DTOR;')
    504504    IFCALCCOPY(`
    505505        processor->active_class_entry_src = NULL;
     
    512512define(`UNION_znode_op', `dnl {{{
    513513#ifndef NDEBUG
    514     switch ((src->$1_type ifelse($1, `result', & ~EXT_TYPE_UNUSED))) {
     514    switch ((SRC(`$1_type') ifelse($1, `result', & ~EXT_TYPE_UNUSED))) {
    515515    case IS_CONST:
    516516    case IS_VAR:
     
    527527    dnl dirty dispatch
    528528    DISABLECHECK(`
    529     switch ((src->$1_type ifelse($1, `result', & ~EXT_TYPE_UNUSED))) {
     529    switch ((SRC(`$1_type') ifelse($1, `result', & ~EXT_TYPE_UNUSED))) {
    530530        case IS_CONST:
    531531            ifelse($1, `result', `
     
    535535                    zval *zv;
    536536                    ALLOC_INIT_ZVAL(zv);
    537                     *zv = dasm->active_op_array_src->literals[src->$1.constant].constant;
     537                    *zv = dasm->active_op_array_src->literals[SRC(`$1.constant')].constant;
    538538                    zval_copy_ctor(zv);
    539539                    add_assoc_zval_ex(dst, XCACHE_STRS("$1.constant"), zv);
     
    541541                ', `
    542542                    IFCOPY(`
    543                         dst->$1 = src->$1;
     543                        DST(`$1') = SRC(`$1');
    544544                    ', `
    545545                        PROCESS(zend_uint, $1.constant)
     
    579579#   define XCACHE_IS_CV 16
    580580#endif
    581     assert(src->op_type == IS_CONST ||
    582         src->op_type == IS_VAR ||
    583         src->op_type == XCACHE_IS_CV ||
    584         src->op_type == IS_TMP_VAR ||
    585         src->op_type == IS_UNUSED);
     581    assert(SRC(`op_type') == IS_CONST ||
     582        SRC(`op_type') == IS_VAR ||
     583        SRC(`op_type') == XCACHE_IS_CV ||
     584        SRC(`op_type') == IS_TMP_VAR ||
     585        SRC(`op_type') == IS_UNUSED);
    586586    dnl dirty dispatch
    587587    DISABLECHECK(`
    588     switch (src->op_type) {
     588    switch (SRC(`op_type')) {
    589589        case IS_CONST:
    590590            STRUCT(zval, u.constant)
     
    593593            IFNOTMEMCPY(`
    594594                default:
    595                     memcpy(&dst->u, &src->u, sizeof(src->u));
     595                    memcpy(&DST(`u'), &SRC(`u'), sizeof(SRC(`u')));
    596596            ')
    597597        ', `
     
    625625#ifdef ZEND_ENGINE_2_4
    626626    IFRESTORE(`', `
    627     switch (src->opcode) {
     627    switch (SRC(`opcode')) {
    628628    case ZEND_BIND_TRAITS:
    629629        ((zend_op *) src)->op2_type = IS_UNUSED;
     
    651651#ifdef ZEND_ENGINE_2_4
    652652        pushdef(`UNION_znode_op_literal', `
    653             if (src->$1_type == IS_CONST) {
    654                 dst->$1.constant = src->$1.literal - processor->active_op_array_src->literals;
    655                 dst->$1.literal = &processor->active_op_array_dst->literals[dst->$1.constant];
     653            if (SRC(`$1_type') == IS_CONST) {
     654                DST(`$1').constant = SRC(`$1.literal') - processor->active_op_array_src->literals;
     655                DST(`$1').literal = &processor->active_op_array_dst->literals[DST(`$1').constant];
    656656            }
    657657        ')
     
    661661        popdef(`UNION_znode_op_literal')
    662662#ifdef ZEND_ENGINE_2
    663         switch (src->opcode) {
     663        switch (SRC(`opcode')) {
    664664#   ifdef ZEND_GOTO
    665665            case ZEND_GOTO:
     
    669669            case ZEND_FAST_CALL:
    670670#   endif
    671                 assert(Z_OP(src->op1).jmp_addr >= processor->active_op_array_src->opcodes && Z_OP(src->op1).jmp_addr - processor->active_op_array_src->opcodes < processor->active_op_array_src->last);
    672                 Z_OP(dst->op1).jmp_addr = processor->active_op_array_dst->opcodes + (Z_OP(src->op1).jmp_addr - processor->active_op_array_src->opcodes);
    673                 assert(Z_OP(dst->op1).jmp_addr >= processor->active_op_array_dst->opcodes && Z_OP(dst->op1).jmp_addr - processor->active_op_array_dst->opcodes < processor->active_op_array_dst->last);
     671                assert(Z_OP(SRC(`op1')).jmp_addr >= processor->active_op_array_src->opcodes && Z_OP(SRC(`op1')).jmp_addr - processor->active_op_array_src->opcodes < processor->active_op_array_src->last);
     672                Z_OP(DST(`op1')).jmp_addr = processor->active_op_array_dst->opcodes + (Z_OP(SRC(`op1')).jmp_addr - processor->active_op_array_src->opcodes);
     673                assert(Z_OP(DST(`op1')).jmp_addr >= processor->active_op_array_dst->opcodes && Z_OP(DST(`op1')).jmp_addr - processor->active_op_array_dst->opcodes < processor->active_op_array_dst->last);
    674674                break;
    675675
     
    684684            case ZEND_JMP_SET_VAR:
    685685#   endif
    686                 assert(Z_OP(src->op2).jmp_addr >= processor->active_op_array_src->opcodes && Z_OP(src->op2).jmp_addr - processor->active_op_array_src->opcodes < processor->active_op_array_src->last);
    687                 Z_OP(dst->op2).jmp_addr = processor->active_op_array_dst->opcodes + (Z_OP(src->op2).jmp_addr - processor->active_op_array_src->opcodes);
    688                 assert(Z_OP(dst->op2).jmp_addr >= processor->active_op_array_dst->opcodes && Z_OP(dst->op2).jmp_addr - processor->active_op_array_dst->opcodes < processor->active_op_array_dst->last);
     686                assert(Z_OP(SRC(`op2')).jmp_addr >= processor->active_op_array_src->opcodes && Z_OP(SRC(`op2')).jmp_addr - processor->active_op_array_src->opcodes < processor->active_op_array_src->last);
     687                Z_OP(DST(`op2')).jmp_addr = processor->active_op_array_dst->opcodes + (Z_OP(SRC(`op2')).jmp_addr - processor->active_op_array_src->opcodes);
     688                assert(Z_OP(DST(`op2')).jmp_addr >= processor->active_op_array_dst->opcodes && Z_OP(DST(`op2')).jmp_addr - processor->active_op_array_dst->opcodes < processor->active_op_array_dst->last);
    689689                break;
    690690
     
    735735        /* really fast shallow copy */
    736736        memcpy(dst, src, sizeof(src[0]));
    737         dst->refcount[0] = 1000;
     737        DST(`refcount[0]') = 1000;
    738738#ifdef ZEND_ACC_ALIAS
    739739        if ((processor->active_class_entry_src && (processor->active_class_entry_src->ce_flags & ZEND_ACC_TRAIT))) {
     
    747747        gc_arg_info = 1;
    748748#endif
    749         dst->filename = processor->entry_php_src->filepath;
    750 #ifdef ZEND_ENGINE_2_4
    751         if (src->literals) {
     749        DST(`filename') = processor->entry_php_src->filepath;
     750#ifdef ZEND_ENGINE_2_4
     751        if (SRC(`literals')) {
    752752            gc_opcodes = 1;
    753753            if (op_array_info->literalinfo_cnt) {
     
    757757#else
    758758        if (op_array_info->oplineinfo_cnt) {
    759             gc_opcodes = 1;
     759            dnl gc_opcodes = 1;
    760760        }
    761761#endif
     
    770770            COPY_N_EX(last, zend_op, opcodes)
    771771
    772             for (opline = dst->opcodes, end = opline + src->last; opline < end; ++opline) {
     772            for (opline = DST(`opcodes'), end = opline + SRC(`last'); opline < end; ++opline) {
    773773#ifdef ZEND_ENGINE_2_4
    774774                pushdef(`UNION_znode_op_literal', `
    775775                    if (opline->$1_type == IS_CONST) {
    776                         opline->$1.literal = &dst->literals[opline->$1.literal - src->literals];
     776                        opline->$1.literal = &DST(`literals[opline->$1.literal - SRC(`literals')]');
    777777                    }
    778778                ')
     
    791791#endif
    792792#ifdef ZEND_ENGINE_2
    793                         Z_OP(opline->op1).jmp_addr = &dst->opcodes[Z_OP(opline->op1).jmp_addr - src->opcodes];
     793                        Z_OP(opline->op1).jmp_addr = &DST(`opcodes[Z_OP(opline->op1).jmp_addr') - SRC(`opcodes')];
    794794#endif
    795795                        break;
     
    806806#endif
    807807#ifdef ZEND_ENGINE_2
    808                         Z_OP(opline->op2).jmp_addr = &dst->opcodes[Z_OP(opline->op2).jmp_addr - src->opcodes];
     808                        Z_OP(opline->op2).jmp_addr = &DST(`opcodes[Z_OP(opline->op2).jmp_addr') - SRC(`opcodes')];
    809809#endif
    810810                        break;
     
    822822            xc_gc_op_array_t gc_op_array;
    823823#ifdef ZEND_ENGINE_2
    824             gc_op_array.num_args = gc_arg_info ? dst->num_args : 0;
    825             gc_op_array.arg_info = gc_arg_info ? dst->arg_info : NULL;
    826 #endif
    827             gc_op_array.opcodes  = gc_opcodes ? dst->opcodes : NULL;
    828 #ifdef ZEND_ENGINE_2_4
    829             gc_op_array.literals = gc_literals ? dst->literals : NULL;
     824            gc_op_array.num_args = gc_arg_info ? DST(`num_args') : 0;
     825            gc_op_array.arg_info = gc_arg_info ? DST(`arg_info') : NULL;
     826#endif
     827            gc_op_array.opcodes  = gc_opcodes ? DST(`opcodes') : NULL;
     828#ifdef ZEND_ENGINE_2_4
     829            gc_op_array.literals = gc_literals ? DST(`literals') : NULL;
    830830#endif
    831831            xc_gc_add_op_array(&gc_op_array TSRMLS_CC);
     
    850850#   endif
    851851#else
    852     if (src->arg_types) {
    853         ALLOC(dst->arg_types, zend_uchar, src->arg_types[0] + 1)
    854         IFCOPY(`memcpy(dst->arg_types, src->arg_types, sizeof(src->arg_types[0]) * (src->arg_types[0]+1));')
     852    if (SRC(`arg_types')) {
     853        ALLOC(`DST(`arg_types')', zend_uchar, SRC(`arg_types[0]') + 1)
     854        IFCOPY(`memcpy(DST(`arg_types'), SRC(`arg_types'), sizeof(SRC(`arg_types[0]')) * (SRC(`arg_types[0]')+1));')
    855855        IFDASM(`do {
    856856            int i;
     
    858858            ALLOC_INIT_ZVAL(zv);
    859859            array_init(zv);
    860             for (i = 0; i < src->arg_types[0]; i ++) {
    861                 add_next_index_long(zv, src->arg_types[i + 1]);
     860            for (i = 0; i < SRC(`arg_types[0]'); i ++) {
     861                add_next_index_long(zv, SRC(`arg_types[i + 1]'));
    862862            }
    863863            add_assoc_zval_ex(dst, ZEND_STRS("arg_types"), zv);
     
    879879    STRUCT_P(zend_uint, refcount)
    880880    UNFIXPOINTER(zend_uint, refcount)
    881     IFSTORE(`dst->refcount[0] = 1;')
     881    IFSTORE(`DST(`refcount[0]') = 1;')
    882882
    883883#ifdef ZEND_ENGINE_2_4
     
    891891    PROCESS(zend_uint, last)
    892892#ifndef ZEND_ENGINE_2_4
    893     IFCOPY(`dst->size = src->last;DONE(size)', `PROCESS(zend_uint, size)')
     893    IFCOPY(`DST(`size') = SRC(`last');DONE(size)', `PROCESS(zend_uint, size)')
    894894#endif
    895895
     
    898898    PROCESS(int, last_var)
    899899#   ifndef ZEND_ENGINE_2_4
    900     IFCOPY(`dst->size_var = src->last_var;DONE(size_var)', `PROCESS(zend_uint, size_var)')
     900    IFCOPY(`DST(`size_var') = SRC(`last_var');DONE(size_var)', `PROCESS(zend_uint, size_var)')
    901901#   endif
    902902#else
     
    949949#endif
    950950
    951     IFRESTORE(`dst->filename = processor->entry_php_src->filepath;DONE(filename)', `PROC_STRING(filename)')
     951    IFRESTORE(`DST(`filename') = processor->entry_php_src->filepath;DONE(filename)', `PROC_STRING(filename)')
    952952#ifdef IS_UNICODE
    953953    IFRESTORE(`
     
    981981#ifdef ZEND_ENGINE_2
    982982    dnl mark it as -1 on store, and lookup parent on restore
    983     IFSTORE(`dst->prototype = (processor->active_class_entry_src && src->prototype) ? (zend_function *) -1 : NULL;', `
     983    IFSTORE(`DST(`prototype') = (processor->active_class_entry_src && SRC(`prototype')) ? (zend_function *) -1 : NULL;', `
    984984        IFRESTORE(`do {
    985985            zend_function *parent;
    986             if (src->prototype != NULL
     986            if (SRC(`prototype') != NULL
    987987             && zend_u_hash_find(&(processor->active_class_entry_dst->parent->function_table),
    988988                    UG(unicode) ? IS_UNICODE : IS_STRING,
    989                     src->function_name, xc_zstrlen(UG(unicode) ? IS_UNICODE : IS_STRING, src->function_name) + 1,
     989                    SRC(`function_name'), xc_zstrlen(UG(unicode) ? IS_UNICODE : IS_STRING, SRC(`function_name')) + 1,
    990990                    (void **) &parent) == SUCCESS) {
    991991                /* see do_inherit_method_check() */
    992992                if ((parent->common.fn_flags & ZEND_ACC_ABSTRACT)) {
    993                     dst->prototype = parent;
     993                    DST(`prototype') = parent;
    994994                } else if (!(parent->common.fn_flags & ZEND_ACC_CTOR) || (parent->common.prototype && (parent->common.prototype->common.scope->ce_flags & ZEND_ACC_INTERFACE))) {
    995995                    /* ctors only have a prototype if it comes from an interface */
    996                     dst->prototype = parent->common.prototype ? parent->common.prototype : parent;
     996                    DST(`prototype') = parent->common.prototype ? parent->common.prototype : parent;
    997997                }
    998998                else {
    999                     dst->prototype = NULL;
     999                    DST(`prototype') = NULL;
    10001000                }
    10011001            }
    10021002            else {
    1003                 dst->prototype = NULL;
     1003                DST(`prototype') = NULL;
    10041004            }
    10051005        } while (0);
     
    10131013    PROC_CLASS_ENTRY_P(scope)
    10141014    IFCOPY(`
    1015         if (src->scope) {
     1015        if (SRC(`scope')) {
    10161016            xc_fix_method(processor, dst TSRMLS_CC);
    10171017        }
     
    10791079    ')
    10801080    IFRESTORE(`
    1081         processor->active_op_array_infos_src = &src->op_array_info;
     1081        processor->active_op_array_infos_src = &SRC(`op_array_info');
    10821082        processor->active_op_array_index = 0;
    10831083    ')
     
    10991099    ')
    11001100    IFRESTORE(`
    1101         processor->active_op_array_infos_src = src->methodinfos;
     1101        processor->active_op_array_infos_src = SRC(`methodinfos');
    11021102        processor->active_op_array_index = 0;
    11031103    ')
     
    11571157    ')
    11581158    IFRESTORE(`
    1159         processor->active_op_array_infos_src = &dst->op_array_info;
     1159        processor->active_op_array_infos_src = &DST(`op_array_info');
    11601160        processor->active_op_array_index = 0;
    11611161    ')
     
    12181218    IFCALCCOPY(`COPY(php)', `STRUCT_P(xc_entry_data_php_t, php)')
    12191219
    1220     IFSTORE(`dst->refcount = 0; DONE(refcount)', `PROCESS(long, refcount)')
     1220    IFSTORE(`DST(`refcount') = 0; DONE(refcount)', `PROCESS(long, refcount)')
    12211221    PROCESS(time_t, file_mtime)
    12221222    PROCESS(size_t, file_size)
     
    12451245    DISABLECHECK(`
    12461246#ifdef IS_UNICODE
    1247         if (src->name_type == IS_UNICODE) {
     1247        if (SRC(`name_type') == IS_UNICODE) {
    12481248            PROCESS(int32_t, entry.name.ustr.len)
    12491249        }
     
    12651265
    12661266    IFDPRINT(`INDENT()`'fprintf(stderr, "zval:value");')
    1267     STRUCT_P_EX(zval_ptr, dst->value, src->value, `value', `', `&')
     1267    STRUCT_P_EX(zval_ptr, DST(`value'), SRC(`value'), `value', `', `&')
    12681268    PROCESS(zend_bool, have_references)
    12691269    DONE(value)
Note: See TracChangeset for help on using the changeset viewer.