source: svn/trunk/processor/processor.m4

Last change on this file was 1594, checked in by Xuefer, 2 months ago

disable warning, only eanble it for debugging

  • Property svn:eol-style set to native
File size: 37.7 KB
RevLine 
[1]1dnl ================
2/* {{{ Pre-declare */
3DECL_STRUCT_P_FUNC(`zval')
4DECL_STRUCT_P_FUNC(`zval_ptr')
[825]5DECL_STRUCT_P_FUNC(`zval_ptr_nullable')
[1]6DECL_STRUCT_P_FUNC(`zend_op_array')
7DECL_STRUCT_P_FUNC(`zend_class_entry')
[95]8#ifdef HAVE_XCACHE_CONSTANT
9DECL_STRUCT_P_FUNC(`zend_constant')
10#endif
[1]11DECL_STRUCT_P_FUNC(`zend_function')
[856]12DECL_STRUCT_P_FUNC(`xc_entry_var_t')
13DECL_STRUCT_P_FUNC(`xc_entry_php_t')
[1321]14#ifdef ZEND_ENGINE_2
[1]15DECL_STRUCT_P_FUNC(`zend_property_info')
[1321]16#endif
[1]17/* }}} */
18dnl ====================================================
19#ifdef IS_CV
[837]20DEF_STRUCT_P_FUNC(`zend_compiled_variable', , `dnl {{{
[843]21    PROCESS(int, name_len)
[103]22    PROC_ZSTRING_L(, name, name_len)
[843]23    PROCESS(ulong, hash_value)
[1]24')
[837]25dnl }}}
[1]26#endif
[837]27DEF_STRUCT_P_FUNC(`zend_uint', , `dnl {{{
[1461]28    IFCOPY(`DST()[0] = SRC()[0];')
[1]29    IFDPRINT(`
30        INDENT()
[1461]31        fprintf(stderr, "%u\n", SRC()[0]);
[1]32    ')
[1461]33    DONE_SIZE(sizeof(SRC()[0]))
[1]34')
35dnl }}}
[1321]36#ifndef ZEND_ENGINE_2
37DEF_STRUCT_P_FUNC(`int', , `dnl {{{
[1461]38    IFCOPY(`*DST() = *SRC();')
[1321]39    IFDPRINT(`
40        INDENT()
[1461]41        fprintf(stderr, "%d\n", SRC()[0]);
[1321]42    ')
[1461]43    DONE_SIZE(sizeof(SRC()[0]))
[1321]44')
45dnl }}}
46#endif
47#ifdef ZEND_ENGINE_2
[837]48DEF_STRUCT_P_FUNC(`zend_try_catch_element', , `dnl {{{
[843]49    PROCESS(zend_uint, try_op)
50    PROCESS(zend_uint, catch_op)
[1213]51#ifdef ZEND_ENGINE_2_5
52    PROCESS(zend_uint, finally_op)
53    PROCESS(zend_uint, finally_end)
54#endif
[1]55')
56dnl }}}
[1321]57#endif
[837]58DEF_STRUCT_P_FUNC(`zend_brk_cont_element', , `dnl {{{
[194]59#ifdef ZEND_ENGINE_2_2
[843]60    PROCESS(int, start)
[194]61#endif
[843]62    PROCESS(int, cont)
63    PROCESS(int, brk)
64    PROCESS(int, parent)
[1]65')
66dnl }}}
67DEF_HASH_TABLE_FUNC(`HashTable_zval_ptr',           `zval_ptr')
68DEF_HASH_TABLE_FUNC(`HashTable_zend_function',      `zend_function')
[1321]69#ifdef ZEND_ENGINE_2
[1]70DEF_HASH_TABLE_FUNC(`HashTable_zend_property_info', `zend_property_info')
[1321]71#endif
[1486]72#ifdef IS_CONSTANT_AST
[1487]73define(`ZEND_AST_HELPER', `dnl {{{
74{
[1486]75    IFCALCCOPY(`
[1487]76        size_t zend_ast_size = ($1->kind == ZEND_CONST)
[1486]77         ? sizeof(zend_ast) + sizeof(zval)
78         : sizeof(zend_ast) + sizeof(zend_ast *) * ($1->children - 1);
79    ')
80
81    pushdef(`ALLOC_SIZE_HELPER', `zend_ast_size')
82    $2
83    popdef(`ALLOC_SIZE_HELPER')
[1487]84}
[1486]85')
[1487]86dnl }}}
[1486]87DEF_STRUCT_P_FUNC(`zend_ast', , `dnl {{{
88        zend_ushort i;
89        PROCESS(zend_ushort, kind)
90        PROCESS(zend_ushort, children)
91        DONE(u)
92        DISABLECHECK(`
93            if (SRC()->kind == ZEND_CONST) {
94                assert(SRC()->u.val);
95                IFCOPY(`
[1487]96                    DST()->u.val = (zval *) (DST() + 1);
[1486]97                    memcpy(DST()->u.val, SRC()->u.val, sizeof(zval));
98                ')
[1488]99                STRUCT_P_EX(zval, DST()->u.val, SRC()->u.val, `[]', `', ` ')
[1486]100                RELOCATE_EX(zval, DST()->u.val)
101            }
102            else {
103                for (i = 0; i < SRC()->children; ++i) {
104                    zend_ast *src_ast = (&SRC()->u.child)[i];
[1487]105                    if (src_ast) {
106                        ZEND_AST_HELPER(`src_ast', `
107                            ALLOC(`(&DST()->u.child)[i]', zend_ast)
[1488]108                            STRUCT_P_EX(zend_ast, (&DST()->u.child)[i], src_ast, `[]', `', ` ')
[1487]109                        ')
110                        RELOCATE_EX(zend_ast, (&DST()->u.child)[i])
111                    }
112                    else {
[1491]113                        SETNULL_EX(`(&DST()->u.child)[i]', `[]')
[1487]114                    }
[1486]115                }
116            }
117        ')
118')
119dnl }}}
120#endif
[1558]121DEF_STRUCT_P_FUNC(`zend_object', , `dnl {{{
122    IFCALC(`
123        xc_var_collect_class(processor, SRC(ce) TSRMLS_CC);
124        DONE(ce)
125    ', `IFSTORE(`
[1564]126        DST(ce) = (zend_class_entry *) xc_var_store_ce(processor, SRC(ce) TSRMLS_CC);
[1558]127        DONE(ce)
128    ', `IFRESTORE(`
[1560]129        assert(processor->index_to_ce);
[1564]130        DST(ce) = processor->index_to_ce[(size_t) SRC(ce)];
[1558]131        DONE(ce)
132    ', `
[1560]133        PROCESS_SCALAR(ce, lu, unsigned long)
[1558]134    ')')')
135
136    STRUCT_P(HashTable, properties, HashTable_zval_ptr)
137#ifdef ZEND_ENGINE_2_4
138    dnl TODO: how to rebuild properties_table
139    STRUCT_ARRAY(int, ce->default_properties_count, zval_ptr, properties_table)
140#endif
141#ifdef ZEND_ENGINE_2
142    COPYNULL(`guards')
143#endif
144')
145dnl }}}
146#ifdef ZEND_ENGINE_2
147DEF_STRUCT_P_FUNC(`zend_object_value', , `dnl {{{
148    IFCALC(`
149        xc_var_collect_object(processor, SRC(handle) TSRMLS_CC);
150        DONE(handle)
151    ', `IFSTORE(`
[1564]152        DST(handle) = (zend_object_handle) xc_var_store_handle(processor, SRC(handle) TSRMLS_CC);
[1558]153        DONE(handle)
154    ', `IFRESTORE(`
[1564]155        DST(handle) = xc_var_restore_handle(processor, (size_t) SRC(handle) TSRMLS_CC);
[1558]156        DONE(handle)
157    ', `
158        PROCESS(zend_object_handle, handle)
159    ')')')
160    COPY(handlers)
161')
162dnl }}}
163#endif
[1]164DEF_STRUCT_P_FUNC(`zval', , `dnl {{{
165    IFDASM(`do {
[1461]166        zval_dtor(DST());
167        *DST() = *SRC();
168        zval_copy_ctor(DST());
169        Z_SET_REFCOUNT(*DST(), 1);
[1]170        DONE(value)
171        DONE(type)
[485]172#ifdef ZEND_ENGINE_2_3
173        DONE(is_ref__gc)
174        DONE(refcount__gc)
175#else
[1]176        DONE(is_ref)
[485]177        DONE(refcount)
[482]178#endif
[1]179    } while(0);
180    ', `
181        dnl IFDASM else
182        /* Variable information */
183dnl {{{ zvalue_value
184        DISABLECHECK(`
[1461]185        switch ((Z_TYPE_P(SRC()) & IS_CONSTANT_TYPE_MASK)) {
[1]186            case IS_LONG:
187            case IS_BOOL:
[843]188                PROCESS(long, value.lval)
[1]189                break;
190            case IS_DOUBLE:
[843]191                PROCESS(double, value.dval)
[1]192                break;
193            case IS_NULL:
194                IFDPRINT(`INDENT()`'fprintf(stderr, "\tNULL\n");')
195                break;
196
197            case IS_CONSTANT:
198#ifdef IS_UNICODE
199                if (UG(unicode)) {
200                    goto proc_unicode;
201                }
202#endif
203            case IS_STRING:
204#ifdef FLAG_IS_BC
205            case FLAG_IS_BC:
206#endif
[843]207                PROCESS(int, value.str.len)
[1546]208                IFRESTORE(`
209                    TRACE("%p, %p, %d", src->value.str.val, processor->entry_php_src->filepath.str, src->value.str.val == processor->entry_php_src->filepath.str);
210                ')
[1]211                PROC_STRING_L(value.str.val, value.str.len)
[1546]212                dnl IFSTORE(`
213                dnl     TRACE("%s, %d", dst->value.str.val, dst->value.str.val == processor->entry_php_dst->filepath.str);
214                dnl ')
[1]215                break;
216#ifdef IS_UNICODE
217            case IS_UNICODE:
218proc_unicode:
[843]219                PROCESS(int32_t, value.uni.len)
[103]220                PROC_ZSTRING_L(1, value.uni.val, value.uni.len)
[1]221                break;
222#endif
223
224            case IS_ARRAY:
[1486]225#ifdef IS_CONSTANT_ARRAY
[1]226            case IS_CONSTANT_ARRAY:
[1486]227#endif
228                assert(SRC()->value.ht);
[1]229                STRUCT_P(HashTable, value.ht, HashTable_zval_ptr)
230                break;
231
[1486]232#ifdef IS_CONSTANT_AST
233            case IS_CONSTANT_AST:
234                assert(SRC()->value.ast);
235                ZEND_AST_HELPER(`SRC()->value.ast', `STRUCT_P(zend_ast, value.ast)')
236                break;
237#endif
238
[1]239            case IS_OBJECT:
[1558]240#ifdef ZEND_ENGINE_2
241                STRUCT(zend_object_value, value.obj)
242#else
243                STRUCT(zend_object, value.obj)
[1321]244#endif
[1]245                break;
246
247            default:
[1558]248                /* IS_RESOURCE */
249                IFCOPY(`Z_TYPE_P(DST()) = IS_LONG;')
250                PROCESS(long, value.lval)
251                break;
[1]252        }
253        ')
254dnl }}}
255        DONE(value)
[917]256        PROCESS(xc_zval_type_t, type)
[485]257#ifdef ZEND_ENGINE_2_3
[843]258        PROCESS(zend_uchar, is_ref__gc)
[485]259#else
[843]260        PROCESS(zend_uchar, is_ref)
[485]261#endif
262
263#ifdef ZEND_ENGINE_2_3
[843]264        PROCESS(zend_uint, refcount__gc)
[1321]265#elif defined(ZEND_ENGINE_2)
266        PROCESS(zend_uint, refcount)
[1281]267#else
[1321]268        PROCESS(zend_ushort, refcount)
[484]269#endif
[1]270    ')dnl IFDASM
271')
272dnl }}}
273DEF_STRUCT_P_FUNC(`zval_ptr', , `dnl {{{
274    IFDASM(`
275        pushdefFUNC_NAME(`zval')
[1461]276        FUNC_NAME (dasm, DST(), SRC()[0] TSRMLS_CC);
[1]277        popdef(`FUNC_NAME')
278    ', `
279        do {
280            IFCALCCOPY(`
[1468]281                if (processor->handle_reference) {
[1]282                    zval_ptr *ppzv;
[1461]283                    if (zend_hash_find(&processor->zvalptrs, (char *) &SRC()[0], sizeof(SRC()[0]), (void **) &ppzv) == SUCCESS) {
[1]284                        IFCOPY(`
[1461]285                            DST()[0] = *ppzv;
[1578]286                            IFSTORE(`
287                                Z_ADDREF(**DST());
288                                TRACE("add refcount to %d", Z_REFCOUNT(**DST()));
289                            ')
[1461]290                            /* *DST() is updated */
[1578]291                            TRACE("*DST() is set to %p, PROCESSOR_TYPE is_shm %d", (void *) DST()[0], xc_is_shm(DST()[0]));
[1]292                        ')
[233]293                        IFCALCSTORE(`processor->have_references = 1;')
[1461]294                        IFSTORE(`assert(xc_is_shm(DST()[0]));')
295                        IFRESTORE(`assert(!xc_is_shm(DST()[0]));')
[1]296                        break;
297                    }
298                }
299            ')
300           
[1461]301            ALLOC(DST()[0], zval)
[1]302            IFCALCCOPY(`
[1468]303                if (processor->handle_reference) {
[1]304                    IFCALC(`
305                        /* make dummy */
306                        zval_ptr pzv = (zval_ptr)-1;
307                    ', `
[1461]308                        zval_ptr pzv = DST()[0];
[1471]309                        RELOCATE_EX(zval, pzv)
[1]310                    ')
[1461]311                    if (zend_hash_add(&processor->zvalptrs, (char *) &SRC()[0], sizeof(SRC()[0]), (void *) &pzv, sizeof(pzv), NULL) == SUCCESS) { /* first add, go on */
[1572]312                        dnl IFSTORE(`fprintf(stderr, "mark[%p] = %p\n", (void *) SRC()[0], (void *) pzv);')
[1]313                    }
314                    else {
315                        assert(0);
316                    }
317                }
318            ')
319            IFCOPY(`
[1578]320                TRACE("copy from %p to %p", SRC()[0], DST()[0]);
[1]321            ')
[1461]322            IFDPRINT(`INDENT()`'fprintf(stderr, "[%p] ", (void *) SRC()[0]);')
323            STRUCT_P_EX(zval, DST()[0], SRC()[0], `[0]', `', ` ')
[1577]324            dnl set refcount here instead of struct zval?
[1578]325            IFSTORE(`
326                Z_SET_REFCOUNT(**DST(), 1);
327                TRACE("set refcount to %d", Z_REFCOUNT(**DST()));
328            ')
[1471]329            RELOCATE_EX(zval, DST()[0])
[1]330        } while (0);
331    ')
332    DONE_SIZE(sizeof(zval_ptr))
333')
334dnl }}}
[825]335DEF_STRUCT_P_FUNC(`zval_ptr_nullable', , `dnl {{{
[1461]336    if (SRC()[0]) {
[1287]337        pushdef(`DASM_STRUCT_DIRECT')
[1461]338        STRUCT_P_EX(zval_ptr, DST(), SRC(), `', `', ` ')
[1287]339        popdef(`DASM_STRUCT_DIRECT')
[825]340    }
341    else {
[1461]342        IFCOPY(`COPYNULL_EX(DST()[0], SRC())')
[825]343    }
344    DONE_SIZE(sizeof(zval_ptr_nullable))
345')
346dnl }}}
[1321]347#ifdef ZEND_ENGINE_2
[837]348DEF_STRUCT_P_FUNC(`zend_arg_info', , `dnl {{{
[843]349    PROCESS(zend_uint, name_len)
[645]350    PROC_ZSTRING_L(, name, name_len)
[843]351    PROCESS(zend_uint, class_name_len)
[645]352    PROC_ZSTRING_L(, class_name, class_name_len)
[716]353#ifdef ZEND_ENGINE_2_4
[843]354    PROCESS(zend_uchar, type_hint)
[1297]355#elif defined(ZEND_ENGINE_2_1)
[843]356    PROCESS(zend_bool, array_type_hint)
[716]357#endif
[1486]358#ifdef ZEND_ENGINE_2_6
359    PROCESS(zend_uchar, pass_by_reference)
360#endif
[843]361    PROCESS(zend_bool, allow_null)
[1486]362
363#ifdef ZEND_ENGINE_2_6
364    PROCESS(zend_bool, is_variadic)
365#else
[843]366    PROCESS(zend_bool, pass_by_reference)
[1486]367#endif
368
[716]369#ifndef ZEND_ENGINE_2_4
[843]370    PROCESS(zend_bool, return_reference)
371    PROCESS(int, required_num_args)
[716]372#endif
[1]373')
[837]374dnl }}}
[1321]375#endif
[95]376#ifdef HAVE_XCACHE_CONSTANT
377DEF_STRUCT_P_FUNC(`zend_constant', , `dnl {{{
378    STRUCT(zval, value)
[843]379    PROCESS(int, flags)
380    PROCESS(uint, name_len)
[828]381    pushdef(`estrndup', `zend_strndup')
[505]382    PROC_ZSTRING_N(, name, name_len)
[828]383    popdef(`estrndup')
[843]384    PROCESS(int, module_number)
[95]385')
386dnl }}}
387#endif
[1]388DEF_STRUCT_P_FUNC(`zend_function', , `dnl {{{
389    DISABLECHECK(`
[1380]390    switch (SRC(`type')) {
[1]391    case ZEND_INTERNAL_FUNCTION:
392    case ZEND_OVERLOADED_FUNCTION:
[1461]393        IFNOTMEMCPY(`IFCOPY(`memcpy(DST(), SRC(), sizeof(SRC()[0]));')')
[1]394        break;
395
396    case ZEND_USER_FUNCTION:
397    case ZEND_EVAL_CODE:
398        DONE(type)
399        STRUCT(zend_op_array, op_array)
400        break;
401
402    default:
403        assert(0);
404    }
405    ')
[1461]406    DONE_SIZE(sizeof(SRC()[0]))
[1]407')
408dnl }}}
[1321]409#ifdef ZEND_ENGINE_2
[837]410DEF_STRUCT_P_FUNC(`zend_property_info', , `dnl {{{
[843]411    PROCESS(zend_uint, flags)
412    PROCESS(int, name_length)
[103]413    PROC_ZSTRING_L(, name, name_length)
[843]414    PROCESS(ulong, h)
[716]415#ifdef ZEND_ENGINE_2_4
[843]416    PROCESS(int, offset)
[716]417#endif
[56]418#ifdef ZEND_ENGINE_2_1
[843]419    PROCESS(int, doc_comment_len)
[272]420    PROC_ZSTRING_L(, doc_comment, doc_comment_len)
[56]421#endif
[78]422    dnl isnt in php6 yet
[504]423#if defined(ZEND_ENGINE_2_2)
[78]424    PROC_CLASS_ENTRY_P(ce)
425#endif
[1]426')
[837]427dnl }}}
[1321]428#endif
[837]429#ifdef ZEND_ENGINE_2_4
430DEF_STRUCT_P_FUNC(`zend_trait_method_reference', , `dnl {{{
[843]431    PROCESS(unsigned int, mname_len)
[837]432    PROC_STRING_L(method_name, mname_len)
433    COPYNULL(ce)
[843]434    PROCESS(unsigned int, cname_len)
[837]435    PROC_STRING_L(class_name, cname_len)
436')
[1]437dnl }}}
[837]438DEF_STRUCT_P_FUNC(`zend_trait_alias', , `dnl {{{
439    STRUCT_P(zend_trait_method_reference, trait_method)
[843]440    PROCESS(unsigned int, alias_len)
[837]441    PROC_STRING_L(alias, alias_len)
[843]442    PROCESS(zend_uint, modifiers)
[1232]443#ifndef ZEND_ENGINE_2_5
[837]444    COPYNULL(function)
[1232]445#endif
[837]446')
447dnl }}}
448DEF_STRUCT_P_FUNC(`zend_trait_precedence', , `dnl {{{
449    STRUCT_P(zend_trait_method_reference, trait_method)
[843]450    PROCESS_ARRAY(, xc_ztstring, exclude_from_classes, zend_class_entry*)
[1232]451#ifndef ZEND_ENGINE_2_5
[837]452    COPYNULL(function)
[1232]453#endif
[837]454')
455dnl }}}
456DEF_STRUCT_P_FUNC(`zend_trait_alias_ptr', , `dnl {{{
457    IFDASM(`
458        pushdefFUNC_NAME(`zend_trait_alias')
[1461]459        FUNC_NAME (dasm, DST(), SRC()[0] TSRMLS_CC);
[837]460        popdef(`FUNC_NAME')
461    ', `
[1461]462        ALLOC(DST()[0], zend_trait_alias)
463        STRUCT_P_EX(zend_trait_alias, DST()[0], SRC()[0], `[0]', `', ` ')
[1471]464        RELOCATE_EX(zend_trait_alias, DST()[0])
[837]465    ')
466    DONE_SIZE(sizeof(zend_trait_alias))
467')
468dnl }}}
469DEF_STRUCT_P_FUNC(`zend_trait_precedence_ptr', , `dnl {{{
470    IFDASM(`
471        pushdefFUNC_NAME(`zend_trait_precedence')
[1461]472        FUNC_NAME (dasm, DST(), SRC()[0] TSRMLS_CC);
[837]473        popdef(`FUNC_NAME')
474    ', `
[1461]475        ALLOC(DST()[0], zend_trait_precedence)
476        STRUCT_P_EX(zend_trait_precedence, DST()[0], SRC()[0], `[0]', `', ` ')
[1471]477        RELOCATE_EX(zend_trait_precedence, DST()[0])
[837]478    ')
479    DONE_SIZE(sizeof(zend_trait_precedence))
480')
481dnl }}}
482#endif
[1]483DEF_STRUCT_P_FUNC(`zend_class_entry', , `dnl {{{
[199]484    IFCALCCOPY(`
[1461]485        processor->active_class_entry_src = SRC();
486        IFCOPY(`processor->active_class_entry_dst = DST();')
[1]487    ')
[843]488    PROCESS(char, type)
489    PROCESS(zend_uint, name_length)
[103]490    PROC_ZSTRING_L(, name, name_length)
[1321]491    IFRESTORE(`
492#ifndef ZEND_ENGINE_2
493        /* just copy parent and resolve on install_class */
[1440]494        COPYPOINTER(parent)
[1321]495#else
496        PROC_CLASS_ENTRY_P(parent)
497#endif
498    ', `
499        PROC_CLASS_ENTRY_P(parent)
500    ')
501#ifdef ZEND_ENGINE_2
[843]502    PROCESS(int, refcount)
[1321]503#else
504    STRUCT_P(int, refcount)
505#endif
[716]506#ifndef ZEND_ENGINE_2_4
[843]507    PROCESS(zend_bool, constants_updated)
[716]508#endif
[1321]509#ifdef ZEND_ENGINE_2
[843]510    PROCESS(zend_uint, ce_flags)
[1321]511#endif
[1]512
[1321]513#ifdef ZEND_ENGINE_2
[721]514    STRUCT(HashTable, properties_info, HashTable_zend_property_info)
[1321]515#endif
[721]516
[716]517#ifdef ZEND_ENGINE_2_4
[917]518    STRUCT_ARRAY(int, default_properties_count, zval_ptr_nullable, default_properties_table)
[843]519    PROCESS(int, default_properties_count)
[917]520    STRUCT_ARRAY(int, default_static_members_count, zval_ptr_nullable, default_static_members_table)
[843]521    PROCESS(int, default_static_members_count)
[1380]522    IFCOPY(`DST(`static_members_table') = DST(`default_static_members_table');')
[716]523    DONE(static_members_table)
524#else
[1380]525    IFCOPY(`DST(`builtin_functions') = SRC(`builtin_functions');')
[1]526    DONE(builtin_functions)
[716]527    STRUCT(HashTable, default_properties, HashTable_zval_ptr)
[721]528#   ifdef ZEND_ENGINE_2_1
[233]529    STRUCT(HashTable, default_static_members, HashTable_zval_ptr)
[1380]530    IFCOPY(`DST(`static_members') = &DST(`default_static_members');')
[1]531    DONE(static_members)
[1321]532#   elif defined(ZEND_ENGINE_2)
[233]533    STRUCT_P(HashTable, static_members, HashTable_zval_ptr)
[1]534#   endif
[716]535#endif /* ZEND_ENGINE_2_4 */
536
[1321]537#ifdef ZEND_ENGINE_2
[1]538    STRUCT(HashTable, constants_table, HashTable_zval_ptr)
539
[837]540#ifdef ZEND_ENGINE_2_2
[1]541    dnl runtime binding: ADD_INTERFACE will deal with it
[837]542    COPYNULL(`interfaces')
[844]543    COPYZERO(`num_interfaces')
[837]544
545#   ifdef ZEND_ENGINE_2_4
[716]546    dnl runtime binding: ADD_TRAIT will deal with it
[837]547    COPYNULL(traits)
[844]548    COPYZERO(num_traits)
[917]549    STRUCT_ARRAY(, , zend_trait_alias_ptr, trait_aliases)
550    STRUCT_ARRAY(, , zend_trait_precedence_ptr, trait_precedences)
[837]551#   endif
552#else
[1]553    IFRESTORE(`
[1380]554        if (SRC(`num_interfaces')) {
555            CALLOC(DST(`interfaces'), zend_class_entry*, SRC(`num_interfaces'))
[4]556            DONE(`interfaces')
[825]557        }
558        else {
559            COPYNULL(`interfaces')
560        }
[837]561    ', `
562        DONE(`interfaces')
[1]563    ')
[843]564    PROCESS(zend_uint, num_interfaces)
[837]565#endif
[1]566
[716]567#   ifdef ZEND_ENGINE_2_4
568    DISABLECHECK(`
[1530]569    IFRESTORE(`DST(`info.user.filename') = processor->entry_php_src->filepath.str;', `PROC_STRING(info.user.filename)')
[843]570    PROCESS(zend_uint, info.user.line_start)
571    PROCESS(zend_uint, info.user.line_end)
572    PROCESS(zend_uint, info.user.doc_comment_len)
[716]573    PROC_ZSTRING_L(, info.user.doc_comment, info.user.doc_comment_len)
574    ')
575    DONE(info)
576#   else
[1530]577    IFRESTORE(`DST(`filename') = processor->entry_php_src->filepath.str;DONE(filename)', `PROC_STRING(filename)')
[843]578    PROCESS(zend_uint, line_start)
579    PROCESS(zend_uint, line_end)
580    PROCESS(zend_uint, doc_comment_len)
[272]581    PROC_ZSTRING_L(, doc_comment, doc_comment_len)
[716]582#   endif
583
[1]584    /* # NOT DONE */
[1297]585#   ifdef ZEND_ENGINE_2_1
[1440]586    PROCESS_CTEXTPOINTER(serialize_func)
587    PROCESS_CTEXTPOINTER(unserialize_func)
[1297]588#   endif
[1440]589    PROCESS_CTEXTPOINTER(iterator_funcs)
590    PROCESS_CTEXTPOINTER(create_object)
591    PROCESS_CTEXTPOINTER(get_iterator)
592    PROCESS_CTEXTPOINTER(interface_gets_implemented)
[716]593#   ifdef ZEND_ENGINE_2_3
[1440]594    PROCESS_CTEXTPOINTER(get_static_method)
[716]595#   endif
[1297]596#   ifdef ZEND_ENGINE_2_1
[1440]597    PROCESS_CTEXTPOINTER(serialize)
598    PROCESS_CTEXTPOINTER(unserialize)
[1297]599#   endif
[1]600    /* deal with it inside xc_fix_method */
601    SETNULL(constructor)
[1440]602    PROCESS_CTEXTPOINTER(destructor)
603    PROCESS_CTEXTPOINTER(clone)
604    PROCESS_CTEXTPOINTER(__get)
605    PROCESS_CTEXTPOINTER(__set)
[1]606/* should be >5.1 */
[716]607#   ifdef ZEND_ENGINE_2_1
[1440]608    PROCESS_CTEXTPOINTER(__unset)
609    PROCESS_CTEXTPOINTER(__isset)
[1486]610#   endif
[1490]611    PROCESS_CTEXTPOINTER(__call)
612#   ifdef ZEND_CALLSTATIC_FUNC_NAME
613    PROCESS_CTEXTPOINTER(__callstatic)
614#   endif
[1486]615# if defined(ZEND_ENGINE_2_2) || PHP_MAJOR_VERSION >= 6
[1440]616    PROCESS_CTEXTPOINTER(__tostring)
[1486]617# endif
618# if defined(ZEND_ENGINE_2_6)
619    PROCESS_CTEXTPOINTER(__debugInfo)
620# endif
[716]621#   ifndef ZEND_ENGINE_2_4
[1]622    /* # NOT DONE */
[1440]623    PROCESS_CTEXTPOINTER(module)
[716]624#   endif
[1321]625#else /* ZEND_ENGINE_2 */
[1440]626    PROCESS_CTEXTPOINTER(handle_function_call)
627    PROCESS_CTEXTPOINTER(handle_property_get)
628    PROCESS_CTEXTPOINTER(handle_property_set)
[1321]629#endif
[1461]630    dnl must do after SETNULL(constructor) and DST()->parent
[1]631    STRUCT(HashTable, function_table, HashTable_zend_function)
[1380]632    IFRESTORE(`DST(`function_table.pDestructor') = ZEND_FUNCTION_DTOR;')
[199]633    IFCALCCOPY(`
[89]634        processor->active_class_entry_src = NULL;
[199]635        IFCOPY(`processor->active_class_entry_dst = NULL;')
[89]636    ')
[1]637')
638dnl }}}
[716]639#ifdef ZEND_ENGINE_2_4
640undefine(`UNION_znode_op')
641define(`UNION_znode_op', `dnl {{{
[822]642#ifndef NDEBUG
[1380]643    switch ((SRC(`$1_type') ifelse($1, `result', & ~EXT_TYPE_UNUSED))) {
[721]644    case IS_CONST:
645    case IS_VAR:
646    case IS_CV:
647    case IS_TMP_VAR:
648    case IS_UNUSED:
649        break;
650
651    default:
652        assert(0);
653    }
[822]654#endif
[721]655
[716]656    dnl dirty dispatch
657    DISABLECHECK(`
[1380]658    switch ((SRC(`$1_type') ifelse($1, `result', & ~EXT_TYPE_UNUSED))) {
[716]659        case IS_CONST:
[822]660            ifelse($1, `result', `
[843]661                PROCESS(zend_uint, $1.constant)
[822]662            ', `
663                IFDASM(`{
664                    zval *zv;
[1592]665                    zval *srczv;
[1594]666                    PROCESS(zend_uint, $1.var)
667                    if (SRC(`$1.constant') < dasm->active_op_array_src->last_literal) {
668                        srczv = &dasm->active_op_array_src->literals[SRC(`$1.constant')].constant;
669                        ALLOC_ZVAL(zv);
670                        MAKE_COPY_ZVAL(&srczv, zv);
671                        add_assoc_zval_ex(DST(), XCACHE_STRS("$1.constant"), zv);
[1592]672                    }
[1594]673                    else {
674                        dnl fprintf(stderr, "opcode %s $1 want literal %d\n", xc_get_opcode(SRC(`opcode')), SRC(`$1.constant'));
675                    }
[716]676                }
[822]677                ', `
678                    IFCOPY(`
[1380]679                        DST(`$1') = SRC(`$1');
[822]680                    ', `
[843]681                        PROCESS(zend_uint, $1.constant)
[822]682                    ')
683                ')
[716]684            ')
685            break;
686        IFCOPY(`
687            IFNOTMEMCPY(`
688                default:
[1438]689                    DST(`$1') = SRC(`$1');
[716]690            ')
691        ', `
692        case IS_VAR:
693        case IS_TMP_VAR:
694        case IS_CV:
[843]695            PROCESS(zend_uint, $1.var)
[716]696            break;
697        case IS_UNUSED:
[843]698            IFDASM(`PROCESS(zend_uint, $1.var)')
699            PROCESS(zend_uint, $1.opline_num)
[716]700            break;
701        ')
702    }
703    ')
704    DONE($1)
705')
706dnl }}}
707#else
[1]708DEF_STRUCT_P_FUNC(`znode', , `dnl {{{
[843]709    PROCESS(xc_op_type, op_type)
[1]710
711#ifdef IS_CV
[11]712#   define XCACHE_IS_CV IS_CV
[1]713#else
[11]714/* compatible with zend optimizer */
715#   define XCACHE_IS_CV 16
[1]716#endif
[1380]717    assert(SRC(`op_type') == IS_CONST ||
718        SRC(`op_type') == IS_VAR ||
719        SRC(`op_type') == XCACHE_IS_CV ||
720        SRC(`op_type') == IS_TMP_VAR ||
721        SRC(`op_type') == IS_UNUSED);
[1]722    dnl dirty dispatch
723    DISABLECHECK(`
[1380]724    switch (SRC(`op_type')) {
[1]725        case IS_CONST:
726            STRUCT(zval, u.constant)
727            break;
728        IFCOPY(`
729            IFNOTMEMCPY(`
730                default:
[1438]731                    DST(`u') = SRC(`u');
[1]732            ')
733        ', `
734        case IS_VAR:
735        case IS_TMP_VAR:
[310]736        case XCACHE_IS_CV:
[843]737            PROCESS(zend_uint, u.var)
738            PROCESS(zend_uint, u.EA.type)
[1]739            break;
740        case IS_UNUSED:
[843]741            IFDASM(`PROCESS(zend_uint, u.var)')
742            PROCESS(zend_uint, u.opline_num)
[1321]743#ifndef ZEND_ENGINE_2
744            PROCESS(zend_uint, u.fetch_type)
745#endif
[843]746            PROCESS(zend_uint, u.EA.type)
[1]747            break;
748        ')
749    }
750    ')
751    DONE(u)
[716]752#if 0
753    DONE(EA)
754#endif
[310]755#undef XCACHE_IS_CV
[1]756')
757dnl }}}
[716]758#endif
[1]759DEF_STRUCT_P_FUNC(`zend_op', , `dnl {{{
[843]760    PROCESS(xc_opcode, opcode)
[716]761#ifdef ZEND_ENGINE_2_4
[830]762    IFRESTORE(`', `
[1380]763    switch (SRC(`opcode')) {
[830]764    case ZEND_BIND_TRAITS:
[1461]765        ((zend_op *) SRC())->op2_type = IS_UNUSED;
[830]766        break;
767    }
768    ')
[716]769    UNION_znode_op(result)
770    UNION_znode_op(op1)
771    UNION_znode_op(op2)
772#else
[1]773    STRUCT(znode, result)
774    STRUCT(znode, op1)
775    STRUCT(znode, op2)
[716]776#endif
[843]777    PROCESS(ulong, extended_value)
778    PROCESS(uint, lineno)
[716]779#ifdef ZEND_ENGINE_2_4
[843]780    PROCESS(zend_uchar, op1_type)
781    PROCESS(zend_uchar, op2_type)
782    PROCESS(zend_uchar, result_type)
[716]783#endif
[1]784    IFCOPY(`
[873]785        assert(processor->active_op_array_src);
786        assert(processor->active_op_array_dst);
[832]787#ifdef ZEND_ENGINE_2_4
[822]788        pushdef(`UNION_znode_op_literal', `
[1380]789            if (SRC(`$1_type') == IS_CONST) {
790                DST(`$1').constant = SRC(`$1.literal') - processor->active_op_array_src->literals;
791                DST(`$1').literal = &processor->active_op_array_dst->literals[DST(`$1').constant];
[822]792            }
793        ')
794        UNION_znode_op_literal(op1)
795        UNION_znode_op_literal(op2)
[832]796#endif
[822]797        popdef(`UNION_znode_op_literal')
[1321]798#ifdef ZEND_ENGINE_2
[1380]799        switch (SRC(`opcode')) {
[1321]800#   ifdef ZEND_GOTO
[515]801            case ZEND_GOTO:
[1321]802#   endif
[1]803            case ZEND_JMP:
[1321]804#   ifdef ZEND_FAST_CALL
[1213]805            case ZEND_FAST_CALL:
[1321]806#   endif
[1385]807                assert(Z_OP(SRC(`op1')).jmp_addr >= processor->active_op_array_src->opcodes);
808                assert(Z_OP(SRC(`op1')).jmp_addr - processor->active_op_array_src->opcodes < processor->active_op_array_src->last);
[1380]809                Z_OP(DST(`op1')).jmp_addr = processor->active_op_array_dst->opcodes + (Z_OP(SRC(`op1')).jmp_addr - processor->active_op_array_src->opcodes);
[1385]810                assert(Z_OP(DST(`op1')).jmp_addr >= processor->active_op_array_dst->opcodes);
811                assert(Z_OP(DST(`op1')).jmp_addr - processor->active_op_array_dst->opcodes < processor->active_op_array_dst->last);
[1471]812                RELOCATE_EX(zend_op, `Z_OP(DST(`op1')).jmp_addr')
[1]813                break;
814
815            case ZEND_JMPZ:
816            case ZEND_JMPNZ:
817            case ZEND_JMPZ_EX:
818            case ZEND_JMPNZ_EX:
[1321]819#   ifdef ZEND_JMP_SET
[485]820            case ZEND_JMP_SET:
[1321]821#   endif
822#   ifdef ZEND_JMP_SET_VAR
[875]823            case ZEND_JMP_SET_VAR:
[1321]824#   endif
[1385]825                assert(Z_OP(SRC(`op2')).jmp_addr >= processor->active_op_array_src->opcodes);
826                assert(Z_OP(SRC(`op2')).jmp_addr - processor->active_op_array_src->opcodes < processor->active_op_array_src->last);
[1380]827                Z_OP(DST(`op2')).jmp_addr = processor->active_op_array_dst->opcodes + (Z_OP(SRC(`op2')).jmp_addr - processor->active_op_array_src->opcodes);
[1385]828                assert(Z_OP(DST(`op2')).jmp_addr >= processor->active_op_array_dst->opcodes);
829                assert(Z_OP(DST(`op2')).jmp_addr - processor->active_op_array_dst->opcodes < processor->active_op_array_dst->last);
[1471]830                RELOCATE_EX(zend_op, `Z_OP(DST(`op2')).jmp_addr')
[1]831                break;
832
833            default:
834                break;
835        }
[1321]836#   endif
[1]837    ')
[1321]838#ifdef ZEND_ENGINE_2
[843]839    PROCESS(opcode_handler_t, handler)
[1321]840#endif
[1]841')
842dnl }}}
[716]843#ifdef ZEND_ENGINE_2_4
844DEF_STRUCT_P_FUNC(`zend_literal', , `dnl {{{
845    STRUCT(zval, constant)
[843]846    PROCESS(zend_ulong, hash_value)
847    PROCESS(zend_uint,  cache_slot)
[716]848')
849dnl }}}
850#endif
[1]851DEF_STRUCT_P_FUNC(`zend_op_array', , `dnl {{{
[873]852    IFCOPY(`
[1461]853        processor->active_op_array_dst = DST();
854        processor->active_op_array_src = SRC();
[873]855    ')
[930]856    IFDASM(`
[1461]857        dasm->active_op_array_src = SRC();
[930]858    ')
[873]859    {
[1]860    IFRESTORE(`
[771]861    const xc_op_array_info_t *op_array_info = &processor->active_op_array_infos_src[processor->active_op_array_index++];
[212]862    dnl shadow copy must NOT meet:
863    dnl readonly_protection=on
864    dnl main op_array && have early binding
[548]865#ifdef ZEND_COMPILE_DELAYED_BINDING
866    zend_bool need_early_binding = 0;
867#else
868    zend_bool need_early_binding = processor->php_src->have_early_binding;
869#endif
[1461]870    zend_bool shallow_copy = !processor->readonly_protection && !(SRC() == processor->php_src->op_array && need_early_binding);
[662]871    if (shallow_copy) {
872        zend_bool gc_arg_info = 0;
[822]873        zend_bool gc_opcodes  = 0;
[1238]874#ifdef ZEND_ENGINE_2_4
875        zend_bool gc_literals = 0;
876#endif
[1]877        /* really fast shallow copy */
[1461]878        memcpy(DST(), SRC(), sizeof(SRC()[0]));
[1381]879        DST(`refcount') = &XG(op_array_dummy_refcount_holder);
[1388]880        XG(op_array_dummy_refcount_holder) = ((zend_uint) -1) / 2;
[1196]881#ifdef ZEND_ACC_ALIAS
882        if ((processor->active_class_entry_src && (processor->active_class_entry_src->ce_flags & ZEND_ACC_TRAIT))) {
883            PROC_ZSTRING(, function_name)
884        }
885#endif
[1]886        /* deep */
887        STRUCT_P(HashTable, static_variables, HashTable_zval_ptr)
[1321]888#ifdef ZEND_ENGINE_2
[1478]889        if (SRC(`arg_info')) {
890            gc_arg_info = 1;
891            STRUCT_ARRAY(zend_uint, num_args, zend_arg_info, arg_info)
892        }
[1321]893#endif
[1530]894        DST(`filename') = processor->entry_php_src->filepath.str;
[1478]895
[822]896#ifdef ZEND_ENGINE_2_4
[1530]897        if (SRC(`literals') && op_array_info->constantinfo_cnt) {
[822]898            gc_opcodes = 1;
[1478]899            gc_literals = 1;
[822]900        }
901#else
[1530]902        if (op_array_info->constantinfo_cnt) {
[1382]903            gc_opcodes = 1;
[822]904        }
905#endif
[1478]906
[1238]907#ifdef ZEND_ENGINE_2_4
908        if (gc_literals) {
909            dnl used when copying opcodes
910            COPY_N_EX(last_literal, zend_literal, literals)
911        }
912#endif
[822]913        if (gc_opcodes) {
[779]914            zend_op *opline, *end;
[662]915            COPY_N_EX(last, zend_op, opcodes)
[779]916
[1380]917            for (opline = DST(`opcodes'), end = opline + SRC(`last'); opline < end; ++opline) {
[822]918#ifdef ZEND_ENGINE_2_4
919                pushdef(`UNION_znode_op_literal', `
920                    if (opline->$1_type == IS_CONST) {
[1380]921                        opline->$1.literal = &DST(`literals[opline->$1.literal - SRC(`literals')]');
[822]922                    }
923                ')
924                UNION_znode_op_literal(op1)
925                UNION_znode_op_literal(op2)
926                popdef(`UNION_znode_op_literal')
927#endif
928
[779]929                switch (opline->opcode) {
930#ifdef ZEND_GOTO
931                    case ZEND_GOTO:
932#endif
933                    case ZEND_JMP:
[1213]934#ifdef ZEND_FAST_CALL
935                    case ZEND_FAST_CALL:
936#endif
[1321]937#ifdef ZEND_ENGINE_2
[1380]938                        Z_OP(opline->op1).jmp_addr = &DST(`opcodes[Z_OP(opline->op1).jmp_addr') - SRC(`opcodes')];
[1321]939#endif
[779]940                        break;
941
942                    case ZEND_JMPZ:
943                    case ZEND_JMPNZ:
944                    case ZEND_JMPZ_EX:
945                    case ZEND_JMPNZ_EX:
946#ifdef ZEND_JMP_SET
947                    case ZEND_JMP_SET:
948#endif
[875]949#ifdef ZEND_JMP_SET_VAR
950            case ZEND_JMP_SET_VAR:
951#endif
[1321]952#ifdef ZEND_ENGINE_2
[1380]953                        Z_OP(opline->op2).jmp_addr = &DST(`opcodes[Z_OP(opline->op2).jmp_addr') - SRC(`opcodes')];
[1321]954#endif
[779]955                        break;
956
957                    default:
958                        break;
959                }
960            }
[662]961        }
[1240]962        if (gc_arg_info || gc_opcodes
963#ifdef ZEND_ENGINE_2_4
964         || gc_literals
965#endif
966        ) {
[662]967            xc_gc_op_array_t gc_op_array;
[1321]968#ifdef ZEND_ENGINE_2
[1380]969            gc_op_array.num_args = gc_arg_info ? DST(`num_args') : 0;
970            gc_op_array.arg_info = gc_arg_info ? DST(`arg_info') : NULL;
[1321]971#endif
[1380]972            gc_op_array.opcodes  = gc_opcodes ? DST(`opcodes') : NULL;
[1238]973#ifdef ZEND_ENGINE_2_4
[1380]974            gc_op_array.literals = gc_literals ? DST(`literals') : NULL;
[1238]975#endif
[662]976            xc_gc_add_op_array(&gc_op_array TSRMLS_CC);
977        }
[880]978        IFAUTOCHECK(`xc_autocheck_skip = 1;')
[1]979    }
980    else
981    ')
982    do {
983    dnl RESTORE is done above!
984
985    /* Common elements */
[843]986    PROCESS(zend_uchar, type)
[103]987    PROC_ZSTRING(, function_name)
[1321]988#ifdef ZEND_ENGINE_2
[843]989    PROCESS(zend_uint, fn_flags)
[917]990    STRUCT_ARRAY(zend_uint, num_args, zend_arg_info, arg_info)
[843]991    PROCESS(zend_uint, num_args)
992    PROCESS(zend_uint, required_num_args)
[716]993#   ifndef ZEND_ENGINE_2_4
[843]994    PROCESS(zend_bool, pass_rest_by_reference)
[716]995#   endif
[1321]996#else
[1380]997    if (SRC(`arg_types')) {
998        ALLOC(`DST(`arg_types')', zend_uchar, SRC(`arg_types[0]') + 1)
999        IFCOPY(`memcpy(DST(`arg_types'), SRC(`arg_types'), sizeof(SRC(`arg_types[0]')) * (SRC(`arg_types[0]')+1));')
[1321]1000        IFDASM(`do {
1001            int i;
1002            zval *zv;
1003            ALLOC_INIT_ZVAL(zv);
1004            array_init(zv);
[1380]1005            for (i = 0; i < SRC(`arg_types[0]'); i ++) {
1006                add_next_index_long(zv, SRC(`arg_types[i + 1]'));
[1321]1007            }
[1461]1008            add_assoc_zval_ex(DST(), ZEND_STRS("arg_types"), zv);
[1321]1009        } while (0);')
1010        DONE(arg_types)
1011    }
1012    else {
1013        COPYNULL(arg_types)
1014    }
1015#endif
[716]1016#ifndef ZEND_ENGINE_2_4
[843]1017    PROCESS(unsigned char, return_reference)
[716]1018#endif
[1]1019    /* END of common elements */
1020#ifdef IS_UNICODE
[103]1021    dnl SETNULL(u_twin)
[1]1022#endif
1023
[1471]1024    IFSTORE(`pushdef(`RELOCATE_EX')')
[1]1025    STRUCT_P(zend_uint, refcount)
[1381]1026    IFSTORE(`
[1471]1027        popdef(`RELOCATE_EX')
[1381]1028        DST(`refcount[0]') = 1;
[1471]1029        RELOCATE(zend_uint, refcount)
[1381]1030    ')
[1]1031
[822]1032#ifdef ZEND_ENGINE_2_4
[873]1033    dnl used when copying opcodes
[917]1034    STRUCT_ARRAY(int, last_literal, zend_literal, literals)
[843]1035    PROCESS(int, last_literal)
[822]1036#endif
1037
[873]1038    dnl uses literals
[917]1039    STRUCT_ARRAY(zend_uint, last, zend_op, opcodes)
[843]1040    PROCESS(zend_uint, last)
[716]1041#ifndef ZEND_ENGINE_2_4
[1380]1042    IFCOPY(`DST(`size') = SRC(`last');DONE(size)', `PROCESS(zend_uint, size)')
[716]1043#endif
[1]1044
1045#ifdef IS_CV
[917]1046    STRUCT_ARRAY(int, last_var, zend_compiled_variable, vars)
[843]1047    PROCESS(int, last_var)
[716]1048#   ifndef ZEND_ENGINE_2_4
[1380]1049    IFCOPY(`DST(`size_var') = SRC(`last_var');DONE(size_var)', `PROCESS(zend_uint, size_var)')
[716]1050#   endif
[1]1051#else
1052    dnl zend_cv.m4 is illegal to be made public, don not ask me for it
1053    IFDASM(`
[1473]1054        sinclude(__dir__`/zend_cv.m4')
[1]1055        ')
1056#endif
1057
[843]1058    PROCESS(zend_uint, T)
[1]1059
[1214]1060#ifdef ZEND_ENGINE_2_5
[1213]1061    PROCESS(zend_uint, nested_calls)
1062    PROCESS(zend_uint, used_stack)
1063#endif
1064
[917]1065    STRUCT_ARRAY(last_brk_cont_t, last_brk_cont, zend_brk_cont_element, brk_cont_array)
1066    PROCESS(last_brk_cont_t, last_brk_cont)
[716]1067#ifndef ZEND_ENGINE_2_4
[843]1068    PROCESS(zend_uint, current_brk_cont)
[716]1069#endif
[1321]1070#ifndef ZEND_ENGINE_2
1071    PROCESS(zend_bool, uses_globals)
1072#endif
[1]1073
[1321]1074#ifdef ZEND_ENGINE_2
[917]1075    STRUCT_ARRAY(int, last_try_catch, zend_try_catch_element, try_catch_array)
[843]1076    PROCESS(int, last_try_catch)
[1321]1077#endif
[1213]1078#ifdef ZEND_ENGINE_2_5
1079    PROCESS(zend_bool, has_finally_block)
1080#endif
[1]1081
1082    STRUCT_P(HashTable, static_variables, HashTable_zval_ptr)
1083
[716]1084#ifndef ZEND_ENGINE_2_4
[1440]1085    COPYPOINTER(start_op)
[843]1086    PROCESS(int, backpatch_count)
[716]1087#endif
[562]1088#ifdef ZEND_ENGINE_2_3
[843]1089    PROCESS(zend_uint, this_var)
[562]1090#endif
[1]1091
[716]1092#ifndef ZEND_ENGINE_2_4
[843]1093    PROCESS(zend_bool, done_pass_two)
[716]1094#endif
[562]1095    /* 5.0 <= ver < 5.3 */
1096#if defined(ZEND_ENGINE_2) && !defined(ZEND_ENGINE_2_3)
[843]1097    PROCESS(zend_bool, uses_this)
[1]1098#endif
1099
[1530]1100    IFRESTORE(`DST(`filename') = processor->entry_php_src->filepath.str; DONE(filename)', `PROC_STRING(filename)')
[1]1101#ifdef IS_UNICODE
[267]1102    IFRESTORE(`
[1440]1103        COPYPOINTER(script_encoding)
[267]1104    ', `
1105        PROC_STRING(script_encoding)
1106    ')
[1]1107#endif
[1321]1108#ifdef ZEND_ENGINE_2
[843]1109    PROCESS(zend_uint, line_start)
1110    PROCESS(zend_uint, line_end)
1111    PROCESS(int, doc_comment_len)
[272]1112    PROC_ZSTRING_L(, doc_comment, doc_comment_len)
[1321]1113#endif
[548]1114#ifdef ZEND_COMPILE_DELAYED_BINDING
[843]1115    PROCESS(zend_uint, early_binding);
[548]1116#endif
[1]1117
1118    /* reserved */
1119    DONE(reserved)
1120#if defined(HARDENING_PATCH) && HARDENING_PATCH
[843]1121    PROCESS(zend_bool, created_by_eval)
[1]1122#endif
[724]1123#ifdef ZEND_ENGINE_2_4
[839]1124    SETNULL(run_time_cache)
[843]1125    PROCESS(int, last_cache_slot)
[724]1126#endif
[1]1127    } while (0);
[1530]1128    IFRESTORE(`xc_fix_op_array_info(processor->entry_php_src, DST(), shallow_copy, op_array_info TSRMLS_CC);')
[189]1129
[1321]1130#ifdef ZEND_ENGINE_2
[219]1131    dnl mark it as -1 on store, and lookup parent on restore
[1380]1132    IFSTORE(`DST(`prototype') = (processor->active_class_entry_src && SRC(`prototype')) ? (zend_function *) -1 : NULL;', `
[839]1133        IFRESTORE(`do {
1134            zend_function *parent;
[1380]1135            if (SRC(`prototype') != NULL
[839]1136             && zend_u_hash_find(&(processor->active_class_entry_dst->parent->function_table),
1137                    UG(unicode) ? IS_UNICODE : IS_STRING,
[1380]1138                    SRC(`function_name'), xc_zstrlen(UG(unicode) ? IS_UNICODE : IS_STRING, SRC(`function_name')) + 1,
[839]1139                    (void **) &parent) == SUCCESS) {
1140                /* see do_inherit_method_check() */
1141                if ((parent->common.fn_flags & ZEND_ACC_ABSTRACT)) {
[1380]1142                    DST(`prototype') = parent;
[839]1143                } else if (!(parent->common.fn_flags & ZEND_ACC_CTOR) || (parent->common.prototype && (parent->common.prototype->common.scope->ce_flags & ZEND_ACC_INTERFACE))) {
1144                    /* ctors only have a prototype if it comes from an interface */
[1380]1145                    DST(`prototype') = parent->common.prototype ? parent->common.prototype : parent;
[219]1146                }
1147                else {
[1380]1148                    DST(`prototype') = NULL;
[219]1149                }
[839]1150            }
1151            else {
[1380]1152                DST(`prototype') = NULL;
[839]1153            }
1154        } while (0);
1155        ')
[219]1156    ')
[839]1157    DONE(prototype)
[716]1158
[1321]1159#endif
1160
1161#ifdef ZEND_ENGINE_2
[507]1162    PROC_CLASS_ENTRY_P(scope)
1163    IFCOPY(`
[1380]1164        if (SRC(`scope')) {
[1461]1165            xc_fix_method(processor, DST() TSRMLS_CC);
[189]1166        }
[507]1167    ')
[1321]1168#endif
[189]1169
1170    IFRESTORE(`
1171        if (xc_have_op_array_ctor) {
[1461]1172            zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) xc_zend_extension_op_array_ctor_handler, DST() TSRMLS_CC);
[189]1173        }
1174    ')
[873]1175    }
1176    IFCOPY(`
1177        processor->active_op_array_dst = NULL;
1178        processor->active_op_array_src = NULL;
1179    ')
[930]1180    IFDASM(`
1181        dasm->active_op_array_src = NULL;
1182    ')
[1]1183')
1184dnl }}}
1185
[95]1186#ifdef HAVE_XCACHE_CONSTANT
1187DEF_STRUCT_P_FUNC(`xc_constinfo_t', , `dnl {{{
[843]1188    PROCESS(zend_uint, key_size)
[95]1189#ifdef IS_UNICODE
[843]1190    PROCESS(zend_uchar, type)
[95]1191#endif
[1440]1192    IFRESTORE(`COPYPOINTER(key)', `
[103]1193        PROC_ZSTRING_N(type, key, key_size)
[95]1194    ')
[843]1195    PROCESS(ulong, h)
[95]1196    STRUCT(zend_constant, constant)
1197')
1198dnl }}}
1199#endif
[877]1200IFRESTORE(`', `
[1530]1201DEF_STRUCT_P_FUNC(`xc_constant_info_t', , `dnl {{{
[843]1202    PROCESS(zend_uint, index)
1203    PROCESS(zend_uint, info)
[832]1204')
1205dnl }}}
[662]1206DEF_STRUCT_P_FUNC(`xc_op_array_info_t', , `dnl {{{
[1530]1207    PROCESS(zend_uint, constantinfo_cnt)
1208    STRUCT_ARRAY(zend_uint, constantinfo_cnt, xc_constant_info_t, constantinfos)
[662]1209')
1210dnl }}}
[877]1211')
[1]1212DEF_STRUCT_P_FUNC(`xc_funcinfo_t', , `dnl {{{
[843]1213    PROCESS(zend_uint, key_size)
[1]1214#ifdef IS_UNICODE
[843]1215    PROCESS(zend_uchar, type)
[1]1216#endif
[1440]1217    IFRESTORE(`COPYPOINTER(key)', `
[103]1218        PROC_ZSTRING_N(type, key, key_size)
[1]1219    ')
[843]1220    PROCESS(ulong, h)
[1440]1221    IFRESTORE(`COPYPOINTER(op_array_info)', `
[662]1222        STRUCT(xc_op_array_info_t, op_array_info)
1223    ')
1224    IFRESTORE(`
[1380]1225        processor->active_op_array_infos_src = &SRC(`op_array_info');
[662]1226        processor->active_op_array_index = 0;
1227    ')
[1]1228    STRUCT(zend_function, func)
1229')
1230dnl }}}
1231DEF_STRUCT_P_FUNC(`xc_classinfo_t', , `dnl {{{
[843]1232    PROCESS(zend_uint, key_size)
[1]1233#ifdef IS_UNICODE
[843]1234    PROCESS(zend_uchar, type)
[1]1235#endif
[1440]1236    IFRESTORE(`COPYPOINTER(key)', `
[103]1237        PROC_ZSTRING_N(type, key, key_size)
[1]1238    ')
[843]1239    PROCESS(ulong, h)
1240    PROCESS(zend_uint, methodinfo_cnt)
[1440]1241    IFRESTORE(`COPYPOINTER(methodinfos)', `
[917]1242        STRUCT_ARRAY(zend_uint, methodinfo_cnt, xc_op_array_info_t, methodinfos)
[662]1243    ')
[1530]1244#ifdef ZEND_ENGINE_2
1245    PROCESS(zend_uint, constantinfo_cnt)
1246    IFRESTORE(`COPYPOINTER(constantinfos)', `
1247        STRUCT_ARRAY(zend_uint, constantinfo_cnt, xc_constant_info_t, constantinfos)
1248    ')
1249#endif
[662]1250    IFRESTORE(`
[1380]1251        processor->active_op_array_infos_src = SRC(`methodinfos');
[662]1252        processor->active_op_array_index = 0;
1253    ')
[1321]1254#ifdef ZEND_ENGINE_2
1255    STRUCT_P(zend_class_entry, cest)
1256#else
1257    STRUCT(zend_class_entry, cest)
1258#endif
[1530]1259#ifdef ZEND_ENGINE_2
1260    IFRESTORE(`xc_fix_class_info(processor->entry_php_src, DST(), 0 TSRMLS_CC);')
1261#endif
[548]1262#ifndef ZEND_COMPILE_DELAYED_BINDING
[843]1263    PROCESS(int, oplineno)
[548]1264#endif
[1]1265')
1266dnl }}}
[877]1267IFRESTORE(`', `
[268]1268#ifdef ZEND_ENGINE_2_1
1269DEF_STRUCT_P_FUNC(`xc_autoglobal_t', , `dnl {{{
[843]1270    PROCESS(zend_uint, key_len)
[268]1271#ifdef IS_UNICODE
[843]1272    PROCESS(zend_uchar, type)
[268]1273#endif
[1440]1274    IFRESTORE(`COPYPOINTER(key)', `
[268]1275        PROC_ZSTRING_L(type, key, key_len)
1276    ')
[843]1277    PROCESS(ulong, h)
[268]1278')
1279dnl }}}
1280#endif
[877]1281')
1282IFRESTORE(`', `
[1051]1283#ifdef XCACHE_ERROR_CACHING
[496]1284DEF_STRUCT_P_FUNC(`xc_compilererror_t', , `dnl {{{
[843]1285    PROCESS(int, type)
1286    PROCESS(uint, lineno)
1287    PROCESS(int, error_len)
[496]1288    PROC_STRING_L(error, error_len)
1289')
1290dnl }}}
1291#endif
[877]1292')
[1]1293DEF_STRUCT_P_FUNC(`xc_entry_data_php_t', , `dnl {{{
[311]1294    IFCOPY(`
[1461]1295        processor->php_dst = DST();
1296        processor->php_src = SRC();
[311]1297    ')
1298
1299    /* skip */
1300    DONE(next)
[854]1301    PROCESS(xc_hash_value_t, hvalue)
[843]1302    PROCESS(xc_md5sum_t, md5)
1303    PROCESS(zend_ulong, refcount)
[311]1304
[843]1305    PROCESS(zend_ulong, hits)
1306    PROCESS(size_t, size)
[1]1307
[1440]1308    IFRESTORE(`COPYPOINTER(op_array_info)', `
[662]1309        STRUCT(xc_op_array_info_t, op_array_info)
1310    ')
1311    IFRESTORE(`
[1380]1312        processor->active_op_array_infos_src = &DST(`op_array_info');
[662]1313        processor->active_op_array_index = 0;
1314    ')
[1]1315    STRUCT_P(zend_op_array, op_array)
1316
[95]1317#ifdef HAVE_XCACHE_CONSTANT
[843]1318    PROCESS(zend_uint, constinfo_cnt)
[917]1319    STRUCT_ARRAY(zend_uint, constinfo_cnt, xc_constinfo_t, constinfos)
[95]1320#endif
1321
[843]1322    PROCESS(zend_uint, funcinfo_cnt)
[917]1323    STRUCT_ARRAY(zend_uint, funcinfo_cnt, xc_funcinfo_t, funcinfos)
[1]1324
[843]1325    PROCESS(zend_uint, classinfo_cnt)
[1481]1326    STRUCT_ARRAY(zend_uint, classinfo_cnt, xc_classinfo_t, classinfos, , IFCOPY(`processor->active_class_index'))
[268]1327#ifdef ZEND_ENGINE_2_1
[843]1328    PROCESS(zend_uint, autoglobal_cnt)
[495]1329    IFRESTORE(`
[1440]1330        COPYPOINTER(autoglobals)
[495]1331    ', `
[917]1332        STRUCT_ARRAY(zend_uint, autoglobal_cnt, xc_autoglobal_t, autoglobals)
[495]1333    ')
[268]1334#endif
[1051]1335#ifdef XCACHE_ERROR_CACHING
[843]1336    PROCESS(zend_uint, compilererror_cnt)
[496]1337    IFRESTORE(`
[1440]1338        COPYPOINTER(compilererrors)
[496]1339    ', `
[917]1340        STRUCT_ARRAY(zend_uint, compilererror_cnt, xc_compilererror_t, compilererrors)
[496]1341    ')
1342#endif
[548]1343#ifndef ZEND_COMPILE_DELAYED_BINDING
[843]1344    PROCESS(zend_bool, have_early_binding)
[548]1345#endif
[843]1346    PROCESS(zend_bool, have_references)
[1]1347')
1348dnl }}}
[837]1349DEF_STRUCT_P_FUNC(`xc_entry_t', , `dnl {{{
[1]1350    /* skip */
1351    DONE(next)
[851]1352    PROCESS(size_t, size)
[1]1353
[843]1354    PROCESS(time_t, ctime)
1355    PROCESS(time_t, atime)
1356    PROCESS(time_t, dtime)
1357    PROCESS(long, ttl)
1358    PROCESS(zend_ulong, hits)
[866]1359    DONE(name) dnl handle in xc_entry_php_t and xc_entry_var_t
[851]1360')
1361dnl }}}
[1530]1362DEF_STRUCT_P_FUNC(`xc_constant_string_t', , `dnl {{{
1363    PROCESS(size_t, len)
1364    IFRESTORE(`COPYPOINTER(str)', `PROC_STRING_L(str, len)')
1365')
1366dnl }}}
1367#ifdef IS_UNICODE
1368DEF_STRUCT_P_FUNC(`xc_constant_u_string_t', , `dnl {{{
1369    PROCESS(size_t, len)
1370    IFRESTORE(`COPYPOINTER(str)', `PROC_USTRING_L(str, len)')
1371')
1372dnl }}}
1373#endif
[851]1374DEF_STRUCT_P_FUNC(`xc_entry_php_t', , `dnl {{{
1375    STRUCT(xc_entry_t, entry)
[866]1376    DISABLECHECK(`
1377        PROCESS(int, entry.name.str.len)
[1440]1378        IFRESTORE(`COPYPOINTER(entry.name.str.val)', `
[866]1379            PROC_STRING_L(entry.name.str.val, entry.name.str.len)
1380        ')
1381    ')
1382
[1440]1383    IFCALCCOPY(`COPYPOINTER(php)', `STRUCT_P(xc_entry_data_php_t, php)')
[851]1384
[1380]1385    IFSTORE(`DST(`refcount') = 0; DONE(refcount)', `PROCESS(long, refcount)')
[851]1386    PROCESS(time_t, file_mtime)
[859]1387    PROCESS(size_t, file_size)
[1201]1388    PROCESS(size_t, file_device)
1389    PROCESS(size_t, file_inode)
[684]1390
[1530]1391    STRUCT(xc_constant_string_t, filepath)
[1521]1392#ifdef ZEND_ENGINE_2_3
[1530]1393    STRUCT(xc_constant_string_t, dirpath)
[1521]1394#endif
[684]1395#ifdef IS_UNICODE
[1530]1396    STRUCT(xc_constant_u_string_t, u_filepath)
1397    STRUCT(xc_constant_u_string_t, u_dirpath)
[684]1398#endif
[1]1399')
1400dnl }}}
[854]1401DEF_STRUCT_P_FUNC(`xc_entry_var_t', , `dnl {{{
[1558]1402    IFCALCSTORE(`xc_entry_var_t *vsrc = /* const_cast */ (xc_entry_var_t *) src;')
[1564]1403    IFRESTORE(`processor->entry_var_src = src;')
[1558]1404
1405    dnl restore is done in foot.m4
[854]1406    STRUCT(xc_entry_t, entry)
1407
[866]1408#ifdef IS_UNICODE
1409    PROCESS(zend_uchar, name_type)
1410#endif
1411    dnl {{{ entry.name
1412    DISABLECHECK(`
1413#ifdef IS_UNICODE
[1380]1414        if (SRC(`name_type') == IS_UNICODE) {
[866]1415            PROCESS(int32_t, entry.name.ustr.len)
1416        }
1417        else {
1418            PROCESS(int, entry.name.str.len)
1419        }
1420#else
1421        PROCESS(int, entry.name.str.len)
1422#endif
[1440]1423        IFRESTORE(`COPYPOINTER(entry.name.str.val)', `
[866]1424#ifdef IS_UNICODE
1425            PROC_ZSTRING_L(name_type, entry.name.uni.val, entry.name.uni.len)
1426#else
1427            PROC_STRING_L(entry.name.str.val, entry.name.str.len)
1428#endif
1429        ')
1430    ')
1431    dnl }}}
1432
[854]1433    IFDPRINT(`INDENT()`'fprintf(stderr, "zval:value");')
[1380]1434    STRUCT_P_EX(zval_ptr, DST(`value'), SRC(`value'), `value', `', `&')
[1576]1435    DONE(value)
[1572]1436#if 0
1437    IFSTORE(`
1438    {
1439        HashTable *ht;
1440        zval **zv;
[1558]1441
[1576]1442        assert(Z_TYPE_P(DST(`value')) == IS_ARRAY);
1443        ht = Z_ARRVAL_P(DST(`value'));
[1572]1444        assert(ht->nNumOfElements == 1);
1445        fprintf(stderr, "key %s\n", ht->pListHead->arKey);
1446
1447        zv = (zval **) ht->pListHead->pData;
1448        assert(Z_TYPE_PP(zv) == IS_ARRAY);
1449        assert(Z_ARRVAL_PP(zv) == ht);
[1576]1450        fprintf(stderr, "refcount=%d\n", Z_REFCOUNT(*DST(`value')));
1451        fprintf(stderr, "refcount=%d\n", Z_REFCOUNT(**zv));
[1572]1452    }
1453    ')
1454#endif
1455
[1558]1456#ifdef ZEND_ENGINE_2
1457    IFCALC(`
[1568]1458        dnl objects = collect_from(value + objects);
[1558]1459        pushdef(`src', `vsrc')
[1568]1460        SRC(objects_count) = xc_vector_size(&processor->objects);
1461        SRC(objects) = xc_vector_detach(zend_object, &processor->objects);
[1558]1462        popdef(`src')
[1568]1463        xc_vector_destroy(&processor->objects);
[1558]1464    ')
1465    dnl must be after calc .value
1466    PROCESS(zend_uint, objects_count)
1467    STRUCT_ARRAY(zend_uint, objects_count, zend_object, objects)
1468    IFSTORE(`{
1469        /* no longer needed */
1470        if (vsrc->objects_count) {
1471            efree(vsrc->objects);
1472            vsrc->objects_count = 0;
1473            vsrc->objects = NULL;
1474            zend_hash_destroy(&processor->handle_to_index);
1475        }
1476    }')
1477#endif
1478
1479    dnl classe_
1480    IFCALC(`
[1568]1481        dnl class_names = collect_from(objects);
[1558]1482        pushdef(`src', `vsrc')
1483        SRC(class_names_count) = xc_vector_size(&processor->class_names);
1484        SRC(class_names) = xc_vector_detach(xc_constant_string_t, &processor->class_names);
1485        popdef(`src')
1486        xc_vector_destroy(&processor->class_names);
1487    ')
1488    PROCESS(zend_uint, class_names_count)
1489    STRUCT_ARRAY(zend_uint, class_names_count, xc_constant_string_t, class_names)
1490    IFSTORE(`
1491        /* no longer needed */
1492        if (vsrc->class_names_count) {
1493            efree(vsrc->class_names);
1494            vsrc->class_names_count = 0;
1495            vsrc->class_names = NULL;
1496            zend_hash_destroy(&processor->class_name_to_index);
1497        }
1498    ')
1499
[854]1500    PROCESS(zend_bool, have_references)
1501')
1502dnl }}}
[1]1503dnl ====================================================
Note: See TracBrowser for help on using the repository browser.