source: svn/trunk/processor/processor.m4 @ 1572

Last change on this file since 1572 was 1572, checked in by Xuefer, 5 years ago

support for reference value

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