source: trunk/processor/processor.m4

Last change on this file was 1578, checked in by moo, 6 weeks ago

cacher: fix more var caching leaks

  • Property svn:eol-style set to native
File size: 37.5 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')
25dnl }}}
[837]26#endif
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)
[484]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')
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;
[1496]665                    zval *srczv = &dasm->active_op_array_src->literals[SRC(`$1.constant')].constant;
666                    ALLOC_ZVAL(zv);
667                    MAKE_COPY_ZVAL(&srczv, zv);
[1461]668                    add_assoc_zval_ex(DST(), XCACHE_STRS("$1.constant"), zv);
[716]669                }
[822]670                ', `
671                    IFCOPY(`
[1380]672                        DST(`$1') = SRC(`$1');
[822]673                    ', `
[843]674                        PROCESS(zend_uint, $1.constant)
[822]675                    ')
676                ')
[716]677            ')
678            break;
679        IFCOPY(`
680            IFNOTMEMCPY(`
681                default:
[1438]682                    DST(`$1') = SRC(`$1');
[716]683            ')
684        ', `
685        case IS_VAR:
686        case IS_TMP_VAR:
687        case IS_CV:
[843]688            PROCESS(zend_uint, $1.var)
[716]689            break;
690        case IS_UNUSED:
[843]691            IFDASM(`PROCESS(zend_uint, $1.var)')
692            PROCESS(zend_uint, $1.opline_num)
[716]693            break;
694        ')
695    }
696    ')
697    DONE($1)
698')
699dnl }}}
700#else
[1]701DEF_STRUCT_P_FUNC(`znode', , `dnl {{{
[843]702    PROCESS(xc_op_type, op_type)
[1]703
704#ifdef IS_CV
[11]705#   define XCACHE_IS_CV IS_CV
[1]706#else
[11]707/* compatible with zend optimizer */
708#   define XCACHE_IS_CV 16
[1]709#endif
[1380]710    assert(SRC(`op_type') == IS_CONST ||
711        SRC(`op_type') == IS_VAR ||
712        SRC(`op_type') == XCACHE_IS_CV ||
713        SRC(`op_type') == IS_TMP_VAR ||
714        SRC(`op_type') == IS_UNUSED);
[1]715    dnl dirty dispatch
716    DISABLECHECK(`
[1380]717    switch (SRC(`op_type')) {
[1]718        case IS_CONST:
719            STRUCT(zval, u.constant)
720            break;
721        IFCOPY(`
722            IFNOTMEMCPY(`
723                default:
[1438]724                    DST(`u') = SRC(`u');
[1]725            ')
726        ', `
727        case IS_VAR:
728        case IS_TMP_VAR:
[310]729        case XCACHE_IS_CV:
[843]730            PROCESS(zend_uint, u.var)
731            PROCESS(zend_uint, u.EA.type)
[1]732            break;
733        case IS_UNUSED:
[843]734            IFDASM(`PROCESS(zend_uint, u.var)')
735            PROCESS(zend_uint, u.opline_num)
[1321]736#ifndef ZEND_ENGINE_2
737            PROCESS(zend_uint, u.fetch_type)
738#endif
[843]739            PROCESS(zend_uint, u.EA.type)
[1]740            break;
741        ')
742    }
743    ')
744    DONE(u)
[716]745#if 0
746    DONE(EA)
747#endif
[310]748#undef XCACHE_IS_CV
[1]749')
750dnl }}}
[716]751#endif
[1]752DEF_STRUCT_P_FUNC(`zend_op', , `dnl {{{
[843]753    PROCESS(xc_opcode, opcode)
[716]754#ifdef ZEND_ENGINE_2_4
[830]755    IFRESTORE(`', `
[1380]756    switch (SRC(`opcode')) {
[830]757    case ZEND_BIND_TRAITS:
[1461]758        ((zend_op *) SRC())->op2_type = IS_UNUSED;
[830]759        break;
760    }
761    ')
[716]762    UNION_znode_op(result)
763    UNION_znode_op(op1)
764    UNION_znode_op(op2)
765#else
[1]766    STRUCT(znode, result)
767    STRUCT(znode, op1)
768    STRUCT(znode, op2)
[716]769#endif
[843]770    PROCESS(ulong, extended_value)
771    PROCESS(uint, lineno)
[716]772#ifdef ZEND_ENGINE_2_4
[843]773    PROCESS(zend_uchar, op1_type)
774    PROCESS(zend_uchar, op2_type)
775    PROCESS(zend_uchar, result_type)
[716]776#endif
[1]777    IFCOPY(`
[873]778        assert(processor->active_op_array_src);
779        assert(processor->active_op_array_dst);
[832]780#ifdef ZEND_ENGINE_2_4
[822]781        pushdef(`UNION_znode_op_literal', `
[1380]782            if (SRC(`$1_type') == IS_CONST) {
783                DST(`$1').constant = SRC(`$1.literal') - processor->active_op_array_src->literals;
784                DST(`$1').literal = &processor->active_op_array_dst->literals[DST(`$1').constant];
[822]785            }
786        ')
787        UNION_znode_op_literal(op1)
788        UNION_znode_op_literal(op2)
[832]789#endif
[822]790        popdef(`UNION_znode_op_literal')
[1321]791#ifdef ZEND_ENGINE_2
[1380]792        switch (SRC(`opcode')) {
[1321]793#   ifdef ZEND_GOTO
[515]794            case ZEND_GOTO:
[1321]795#   endif
[1]796            case ZEND_JMP:
[1321]797#   ifdef ZEND_FAST_CALL
[1213]798            case ZEND_FAST_CALL:
[1321]799#   endif
[1385]800                assert(Z_OP(SRC(`op1')).jmp_addr >= processor->active_op_array_src->opcodes);
801                assert(Z_OP(SRC(`op1')).jmp_addr - processor->active_op_array_src->opcodes < processor->active_op_array_src->last);
[1380]802                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]803                assert(Z_OP(DST(`op1')).jmp_addr >= processor->active_op_array_dst->opcodes);
804                assert(Z_OP(DST(`op1')).jmp_addr - processor->active_op_array_dst->opcodes < processor->active_op_array_dst->last);
[1471]805                RELOCATE_EX(zend_op, `Z_OP(DST(`op1')).jmp_addr')
[1]806                break;
807
808            case ZEND_JMPZ:
809            case ZEND_JMPNZ:
810            case ZEND_JMPZ_EX:
811            case ZEND_JMPNZ_EX:
[1321]812#   ifdef ZEND_JMP_SET
[485]813            case ZEND_JMP_SET:
[1321]814#   endif
815#   ifdef ZEND_JMP_SET_VAR
[875]816            case ZEND_JMP_SET_VAR:
[1321]817#   endif
[1385]818                assert(Z_OP(SRC(`op2')).jmp_addr >= processor->active_op_array_src->opcodes);
819                assert(Z_OP(SRC(`op2')).jmp_addr - processor->active_op_array_src->opcodes < processor->active_op_array_src->last);
[1380]820                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]821                assert(Z_OP(DST(`op2')).jmp_addr >= processor->active_op_array_dst->opcodes);
822                assert(Z_OP(DST(`op2')).jmp_addr - processor->active_op_array_dst->opcodes < processor->active_op_array_dst->last);
[1471]823                RELOCATE_EX(zend_op, `Z_OP(DST(`op2')).jmp_addr')
[1]824                break;
825
826            default:
827                break;
828        }
[1321]829#   endif
[1]830    ')
[1321]831#ifdef ZEND_ENGINE_2
[843]832    PROCESS(opcode_handler_t, handler)
[1321]833#endif
[1]834')
835dnl }}}
[716]836#ifdef ZEND_ENGINE_2_4
837DEF_STRUCT_P_FUNC(`zend_literal', , `dnl {{{
838    STRUCT(zval, constant)
[843]839    PROCESS(zend_ulong, hash_value)
840    PROCESS(zend_uint,  cache_slot)
[716]841')
842dnl }}}
843#endif
[1]844DEF_STRUCT_P_FUNC(`zend_op_array', , `dnl {{{
[873]845    IFCOPY(`
[1461]846        processor->active_op_array_dst = DST();
847        processor->active_op_array_src = SRC();
[873]848    ')
[930]849    IFDASM(`
[1461]850        dasm->active_op_array_src = SRC();
[930]851    ')
[873]852    {
[1]853    IFRESTORE(`
[771]854    const xc_op_array_info_t *op_array_info = &processor->active_op_array_infos_src[processor->active_op_array_index++];
[212]855    dnl shadow copy must NOT meet:
856    dnl readonly_protection=on
857    dnl main op_array && have early binding
[548]858#ifdef ZEND_COMPILE_DELAYED_BINDING
859    zend_bool need_early_binding = 0;
860#else
861    zend_bool need_early_binding = processor->php_src->have_early_binding;
862#endif
[1461]863    zend_bool shallow_copy = !processor->readonly_protection && !(SRC() == processor->php_src->op_array && need_early_binding);
[662]864    if (shallow_copy) {
865        zend_bool gc_arg_info = 0;
[822]866        zend_bool gc_opcodes  = 0;
[1238]867#ifdef ZEND_ENGINE_2_4
868        zend_bool gc_literals = 0;
869#endif
[1]870        /* really fast shallow copy */
[1461]871        memcpy(DST(), SRC(), sizeof(SRC()[0]));
[1381]872        DST(`refcount') = &XG(op_array_dummy_refcount_holder);
[1388]873        XG(op_array_dummy_refcount_holder) = ((zend_uint) -1) / 2;
[1196]874#ifdef ZEND_ACC_ALIAS
875        if ((processor->active_class_entry_src && (processor->active_class_entry_src->ce_flags & ZEND_ACC_TRAIT))) {
876            PROC_ZSTRING(, function_name)
877        }
878#endif
[1]879        /* deep */
880        STRUCT_P(HashTable, static_variables, HashTable_zval_ptr)
[1321]881#ifdef ZEND_ENGINE_2
[1478]882        if (SRC(`arg_info')) {
883            gc_arg_info = 1;
884            STRUCT_ARRAY(zend_uint, num_args, zend_arg_info, arg_info)
885        }
[1321]886#endif
[1530]887        DST(`filename') = processor->entry_php_src->filepath.str;
[1478]888
[822]889#ifdef ZEND_ENGINE_2_4
[1530]890        if (SRC(`literals') && op_array_info->constantinfo_cnt) {
[822]891            gc_opcodes = 1;
[1478]892            gc_literals = 1;
[822]893        }
894#else
[1530]895        if (op_array_info->constantinfo_cnt) {
[1382]896            gc_opcodes = 1;
[822]897        }
898#endif
[1478]899
[1238]900#ifdef ZEND_ENGINE_2_4
901        if (gc_literals) {
902            dnl used when copying opcodes
903            COPY_N_EX(last_literal, zend_literal, literals)
904        }
905#endif
[822]906        if (gc_opcodes) {
[779]907            zend_op *opline, *end;
[662]908            COPY_N_EX(last, zend_op, opcodes)
[779]909
[1380]910            for (opline = DST(`opcodes'), end = opline + SRC(`last'); opline < end; ++opline) {
[822]911#ifdef ZEND_ENGINE_2_4
912                pushdef(`UNION_znode_op_literal', `
913                    if (opline->$1_type == IS_CONST) {
[1380]914                        opline->$1.literal = &DST(`literals[opline->$1.literal - SRC(`literals')]');
[822]915                    }
916                ')
917                UNION_znode_op_literal(op1)
918                UNION_znode_op_literal(op2)
919                popdef(`UNION_znode_op_literal')
920#endif
921
[779]922                switch (opline->opcode) {
923#ifdef ZEND_GOTO
924                    case ZEND_GOTO:
925#endif
926                    case ZEND_JMP:
[1213]927#ifdef ZEND_FAST_CALL
928                    case ZEND_FAST_CALL:
929#endif
[1321]930#ifdef ZEND_ENGINE_2
[1380]931                        Z_OP(opline->op1).jmp_addr = &DST(`opcodes[Z_OP(opline->op1).jmp_addr') - SRC(`opcodes')];
[1321]932#endif
[779]933                        break;
934
935                    case ZEND_JMPZ:
936                    case ZEND_JMPNZ:
937                    case ZEND_JMPZ_EX:
938                    case ZEND_JMPNZ_EX:
939#ifdef ZEND_JMP_SET
940                    case ZEND_JMP_SET:
941#endif
[875]942#ifdef ZEND_JMP_SET_VAR
943            case ZEND_JMP_SET_VAR:
944#endif
[1321]945#ifdef ZEND_ENGINE_2
[1380]946                        Z_OP(opline->op2).jmp_addr = &DST(`opcodes[Z_OP(opline->op2).jmp_addr') - SRC(`opcodes')];
[1321]947#endif
[779]948                        break;
949
950                    default:
951                        break;
952                }
953            }
[662]954        }
[1240]955        if (gc_arg_info || gc_opcodes
956#ifdef ZEND_ENGINE_2_4
957         || gc_literals
958#endif
959        ) {
[662]960            xc_gc_op_array_t gc_op_array;
[1321]961#ifdef ZEND_ENGINE_2
[1380]962            gc_op_array.num_args = gc_arg_info ? DST(`num_args') : 0;
963            gc_op_array.arg_info = gc_arg_info ? DST(`arg_info') : NULL;
[1321]964#endif
[1380]965            gc_op_array.opcodes  = gc_opcodes ? DST(`opcodes') : NULL;
[1238]966#ifdef ZEND_ENGINE_2_4
[1380]967            gc_op_array.literals = gc_literals ? DST(`literals') : NULL;
[1238]968#endif
[662]969            xc_gc_add_op_array(&gc_op_array TSRMLS_CC);
970        }
[880]971        IFAUTOCHECK(`xc_autocheck_skip = 1;')
[1]972    }
973    else
974    ')
975    do {
976    dnl RESTORE is done above!
977
978    /* Common elements */
[843]979    PROCESS(zend_uchar, type)
[103]980    PROC_ZSTRING(, function_name)
[1321]981#ifdef ZEND_ENGINE_2
[843]982    PROCESS(zend_uint, fn_flags)
[917]983    STRUCT_ARRAY(zend_uint, num_args, zend_arg_info, arg_info)
[843]984    PROCESS(zend_uint, num_args)
985    PROCESS(zend_uint, required_num_args)
[716]986#   ifndef ZEND_ENGINE_2_4
[843]987    PROCESS(zend_bool, pass_rest_by_reference)
[716]988#   endif
[1321]989#else
[1380]990    if (SRC(`arg_types')) {
991        ALLOC(`DST(`arg_types')', zend_uchar, SRC(`arg_types[0]') + 1)
992        IFCOPY(`memcpy(DST(`arg_types'), SRC(`arg_types'), sizeof(SRC(`arg_types[0]')) * (SRC(`arg_types[0]')+1));')
[1321]993        IFDASM(`do {
994            int i;
995            zval *zv;
996            ALLOC_INIT_ZVAL(zv);
997            array_init(zv);
[1380]998            for (i = 0; i < SRC(`arg_types[0]'); i ++) {
999                add_next_index_long(zv, SRC(`arg_types[i + 1]'));
[1321]1000            }
[1461]1001            add_assoc_zval_ex(DST(), ZEND_STRS("arg_types"), zv);
[1321]1002        } while (0);')
1003        DONE(arg_types)
1004    }
1005    else {
1006        COPYNULL(arg_types)
1007    }
1008#endif
[716]1009#ifndef ZEND_ENGINE_2_4
[843]1010    PROCESS(unsigned char, return_reference)
[716]1011#endif
[1]1012    /* END of common elements */
1013#ifdef IS_UNICODE
[103]1014    dnl SETNULL(u_twin)
[1]1015#endif
1016
[1471]1017    IFSTORE(`pushdef(`RELOCATE_EX')')
[1]1018    STRUCT_P(zend_uint, refcount)
[1381]1019    IFSTORE(`
[1471]1020        popdef(`RELOCATE_EX')
[1381]1021        DST(`refcount[0]') = 1;
[1471]1022        RELOCATE(zend_uint, refcount)
[1381]1023    ')
[1]1024
[822]1025#ifdef ZEND_ENGINE_2_4
[873]1026    dnl used when copying opcodes
[917]1027    STRUCT_ARRAY(int, last_literal, zend_literal, literals)
[843]1028    PROCESS(int, last_literal)
[822]1029#endif
1030
[873]1031    dnl uses literals
[917]1032    STRUCT_ARRAY(zend_uint, last, zend_op, opcodes)
[843]1033    PROCESS(zend_uint, last)
[716]1034#ifndef ZEND_ENGINE_2_4
[1380]1035    IFCOPY(`DST(`size') = SRC(`last');DONE(size)', `PROCESS(zend_uint, size)')
[716]1036#endif
[1]1037
1038#ifdef IS_CV
[917]1039    STRUCT_ARRAY(int, last_var, zend_compiled_variable, vars)
[843]1040    PROCESS(int, last_var)
[716]1041#   ifndef ZEND_ENGINE_2_4
[1380]1042    IFCOPY(`DST(`size_var') = SRC(`last_var');DONE(size_var)', `PROCESS(zend_uint, size_var)')
[716]1043#   endif
[1]1044#else
1045    dnl zend_cv.m4 is illegal to be made public, don not ask me for it
1046    IFDASM(`
[1473]1047        sinclude(__dir__`/zend_cv.m4')
[1]1048        ')
1049#endif
1050
[843]1051    PROCESS(zend_uint, T)
[1]1052
[1214]1053#ifdef ZEND_ENGINE_2_5
[1213]1054    PROCESS(zend_uint, nested_calls)
1055    PROCESS(zend_uint, used_stack)
1056#endif
1057
[917]1058    STRUCT_ARRAY(last_brk_cont_t, last_brk_cont, zend_brk_cont_element, brk_cont_array)
1059    PROCESS(last_brk_cont_t, last_brk_cont)
[716]1060#ifndef ZEND_ENGINE_2_4
[843]1061    PROCESS(zend_uint, current_brk_cont)
[716]1062#endif
[1321]1063#ifndef ZEND_ENGINE_2
1064    PROCESS(zend_bool, uses_globals)
1065#endif
[1]1066
[1321]1067#ifdef ZEND_ENGINE_2
[917]1068    STRUCT_ARRAY(int, last_try_catch, zend_try_catch_element, try_catch_array)
[843]1069    PROCESS(int, last_try_catch)
[1321]1070#endif
[1213]1071#ifdef ZEND_ENGINE_2_5
1072    PROCESS(zend_bool, has_finally_block)
1073#endif
[1]1074
1075    STRUCT_P(HashTable, static_variables, HashTable_zval_ptr)
1076
[716]1077#ifndef ZEND_ENGINE_2_4
[1440]1078    COPYPOINTER(start_op)
[843]1079    PROCESS(int, backpatch_count)
[716]1080#endif
[562]1081#ifdef ZEND_ENGINE_2_3
[843]1082    PROCESS(zend_uint, this_var)
[562]1083#endif
[1]1084
[716]1085#ifndef ZEND_ENGINE_2_4
[843]1086    PROCESS(zend_bool, done_pass_two)
[716]1087#endif
[562]1088    /* 5.0 <= ver < 5.3 */
1089#if defined(ZEND_ENGINE_2) && !defined(ZEND_ENGINE_2_3)
[843]1090    PROCESS(zend_bool, uses_this)
[1]1091#endif
1092
[1530]1093    IFRESTORE(`DST(`filename') = processor->entry_php_src->filepath.str; DONE(filename)', `PROC_STRING(filename)')
[1]1094#ifdef IS_UNICODE
[267]1095    IFRESTORE(`
[1440]1096        COPYPOINTER(script_encoding)
[267]1097    ', `
1098        PROC_STRING(script_encoding)
1099    ')
[1]1100#endif
[1321]1101#ifdef ZEND_ENGINE_2
[843]1102    PROCESS(zend_uint, line_start)
1103    PROCESS(zend_uint, line_end)
1104    PROCESS(int, doc_comment_len)
[272]1105    PROC_ZSTRING_L(, doc_comment, doc_comment_len)
[1321]1106#endif
[548]1107#ifdef ZEND_COMPILE_DELAYED_BINDING
[843]1108    PROCESS(zend_uint, early_binding);
[548]1109#endif
[1]1110
1111    /* reserved */
1112    DONE(reserved)
1113#if defined(HARDENING_PATCH) && HARDENING_PATCH
[843]1114    PROCESS(zend_bool, created_by_eval)
[1]1115#endif
[724]1116#ifdef ZEND_ENGINE_2_4
[839]1117    SETNULL(run_time_cache)
[843]1118    PROCESS(int, last_cache_slot)
[724]1119#endif
[1]1120    } while (0);
[1530]1121    IFRESTORE(`xc_fix_op_array_info(processor->entry_php_src, DST(), shallow_copy, op_array_info TSRMLS_CC);')
[189]1122
[1321]1123#ifdef ZEND_ENGINE_2
[219]1124    dnl mark it as -1 on store, and lookup parent on restore
[1380]1125    IFSTORE(`DST(`prototype') = (processor->active_class_entry_src && SRC(`prototype')) ? (zend_function *) -1 : NULL;', `
[839]1126        IFRESTORE(`do {
1127            zend_function *parent;
[1380]1128            if (SRC(`prototype') != NULL
[839]1129             && zend_u_hash_find(&(processor->active_class_entry_dst->parent->function_table),
1130                    UG(unicode) ? IS_UNICODE : IS_STRING,
[1380]1131                    SRC(`function_name'), xc_zstrlen(UG(unicode) ? IS_UNICODE : IS_STRING, SRC(`function_name')) + 1,
[839]1132                    (void **) &parent) == SUCCESS) {
1133                /* see do_inherit_method_check() */
1134                if ((parent->common.fn_flags & ZEND_ACC_ABSTRACT)) {
[1380]1135                    DST(`prototype') = parent;
[839]1136                } else if (!(parent->common.fn_flags & ZEND_ACC_CTOR) || (parent->common.prototype && (parent->common.prototype->common.scope->ce_flags & ZEND_ACC_INTERFACE))) {
1137                    /* ctors only have a prototype if it comes from an interface */
[1380]1138                    DST(`prototype') = parent->common.prototype ? parent->common.prototype : parent;
[219]1139                }
1140                else {
[1380]1141                    DST(`prototype') = NULL;
[219]1142                }
[839]1143            }
1144            else {
[1380]1145                DST(`prototype') = NULL;
[839]1146            }
1147        } while (0);
1148        ')
[219]1149    ')
[839]1150    DONE(prototype)
[716]1151
[1321]1152#endif
1153
1154#ifdef ZEND_ENGINE_2
[507]1155    PROC_CLASS_ENTRY_P(scope)
1156    IFCOPY(`
[1380]1157        if (SRC(`scope')) {
[1461]1158            xc_fix_method(processor, DST() TSRMLS_CC);
[189]1159        }
1160    ')
[1321]1161#endif
[189]1162
1163    IFRESTORE(`
1164        if (xc_have_op_array_ctor) {
[1461]1165            zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) xc_zend_extension_op_array_ctor_handler, DST() TSRMLS_CC);
[189]1166        }
1167    ')
[873]1168    }
1169    IFCOPY(`
1170        processor->active_op_array_dst = NULL;
1171        processor->active_op_array_src = NULL;
1172    ')
[930]1173    IFDASM(`
1174        dasm->active_op_array_src = NULL;
1175    ')
[1]1176')
1177dnl }}}
1178
[95]1179#ifdef HAVE_XCACHE_CONSTANT
1180DEF_STRUCT_P_FUNC(`xc_constinfo_t', , `dnl {{{
[843]1181    PROCESS(zend_uint, key_size)
[95]1182#ifdef IS_UNICODE
[843]1183    PROCESS(zend_uchar, type)
[95]1184#endif
[1440]1185    IFRESTORE(`COPYPOINTER(key)', `
[103]1186        PROC_ZSTRING_N(type, key, key_size)
[95]1187    ')
[843]1188    PROCESS(ulong, h)
[95]1189    STRUCT(zend_constant, constant)
1190')
1191dnl }}}
1192#endif
[877]1193IFRESTORE(`', `
[1530]1194DEF_STRUCT_P_FUNC(`xc_constant_info_t', , `dnl {{{
[843]1195    PROCESS(zend_uint, index)
1196    PROCESS(zend_uint, info)
[832]1197')
1198dnl }}}
[662]1199DEF_STRUCT_P_FUNC(`xc_op_array_info_t', , `dnl {{{
[1530]1200    PROCESS(zend_uint, constantinfo_cnt)
1201    STRUCT_ARRAY(zend_uint, constantinfo_cnt, xc_constant_info_t, constantinfos)
[662]1202')
1203dnl }}}
[877]1204')
[1]1205DEF_STRUCT_P_FUNC(`xc_funcinfo_t', , `dnl {{{
[843]1206    PROCESS(zend_uint, key_size)
[1]1207#ifdef IS_UNICODE
[843]1208    PROCESS(zend_uchar, type)
[1]1209#endif
[1440]1210    IFRESTORE(`COPYPOINTER(key)', `
[103]1211        PROC_ZSTRING_N(type, key, key_size)
[1]1212    ')
[843]1213    PROCESS(ulong, h)
[1440]1214    IFRESTORE(`COPYPOINTER(op_array_info)', `
[662]1215        STRUCT(xc_op_array_info_t, op_array_info)
1216    ')
1217    IFRESTORE(`
[1380]1218        processor->active_op_array_infos_src = &SRC(`op_array_info');
[662]1219        processor->active_op_array_index = 0;
1220    ')
[1]1221    STRUCT(zend_function, func)
1222')
1223dnl }}}
1224DEF_STRUCT_P_FUNC(`xc_classinfo_t', , `dnl {{{
[843]1225    PROCESS(zend_uint, key_size)
[1]1226#ifdef IS_UNICODE
[843]1227    PROCESS(zend_uchar, type)
[1]1228#endif
[1440]1229    IFRESTORE(`COPYPOINTER(key)', `
[103]1230        PROC_ZSTRING_N(type, key, key_size)
[1]1231    ')
[843]1232    PROCESS(ulong, h)
1233    PROCESS(zend_uint, methodinfo_cnt)
[1440]1234    IFRESTORE(`COPYPOINTER(methodinfos)', `
[917]1235        STRUCT_ARRAY(zend_uint, methodinfo_cnt, xc_op_array_info_t, methodinfos)
[662]1236    ')
[1530]1237#ifdef ZEND_ENGINE_2
1238    PROCESS(zend_uint, constantinfo_cnt)
1239    IFRESTORE(`COPYPOINTER(constantinfos)', `
1240        STRUCT_ARRAY(zend_uint, constantinfo_cnt, xc_constant_info_t, constantinfos)
1241    ')
1242#endif
[662]1243    IFRESTORE(`
[1380]1244        processor->active_op_array_infos_src = SRC(`methodinfos');
[662]1245        processor->active_op_array_index = 0;
1246    ')
[1321]1247#ifdef ZEND_ENGINE_2
1248    STRUCT_P(zend_class_entry, cest)
1249#else
1250    STRUCT(zend_class_entry, cest)
1251#endif
[1530]1252#ifdef ZEND_ENGINE_2
1253    IFRESTORE(`xc_fix_class_info(processor->entry_php_src, DST(), 0 TSRMLS_CC);')
1254#endif
[548]1255#ifndef ZEND_COMPILE_DELAYED_BINDING
[843]1256    PROCESS(int, oplineno)
[548]1257#endif
[1]1258')
1259dnl }}}
[877]1260IFRESTORE(`', `
[268]1261#ifdef ZEND_ENGINE_2_1
1262DEF_STRUCT_P_FUNC(`xc_autoglobal_t', , `dnl {{{
[843]1263    PROCESS(zend_uint, key_len)
[268]1264#ifdef IS_UNICODE
[843]1265    PROCESS(zend_uchar, type)
[268]1266#endif
[1440]1267    IFRESTORE(`COPYPOINTER(key)', `
[268]1268        PROC_ZSTRING_L(type, key, key_len)
1269    ')
[843]1270    PROCESS(ulong, h)
[268]1271')
1272dnl }}}
1273#endif
[877]1274')
1275IFRESTORE(`', `
[1051]1276#ifdef XCACHE_ERROR_CACHING
[496]1277DEF_STRUCT_P_FUNC(`xc_compilererror_t', , `dnl {{{
[843]1278    PROCESS(int, type)
1279    PROCESS(uint, lineno)
1280    PROCESS(int, error_len)
[496]1281    PROC_STRING_L(error, error_len)
1282')
1283dnl }}}
1284#endif
[877]1285')
[1]1286DEF_STRUCT_P_FUNC(`xc_entry_data_php_t', , `dnl {{{
[311]1287    IFCOPY(`
[1461]1288        processor->php_dst = DST();
1289        processor->php_src = SRC();
[311]1290    ')
1291
1292    /* skip */
1293    DONE(next)
[854]1294    PROCESS(xc_hash_value_t, hvalue)
[843]1295    PROCESS(xc_md5sum_t, md5)
1296    PROCESS(zend_ulong, refcount)
[311]1297
[843]1298    PROCESS(zend_ulong, hits)
1299    PROCESS(size_t, size)
[1]1300
[1440]1301    IFRESTORE(`COPYPOINTER(op_array_info)', `
[662]1302        STRUCT(xc_op_array_info_t, op_array_info)
1303    ')
1304    IFRESTORE(`
[1380]1305        processor->active_op_array_infos_src = &DST(`op_array_info');
[662]1306        processor->active_op_array_index = 0;
1307    ')
[1]1308    STRUCT_P(zend_op_array, op_array)
1309
[95]1310#ifdef HAVE_XCACHE_CONSTANT
[843]1311    PROCESS(zend_uint, constinfo_cnt)
[917]1312    STRUCT_ARRAY(zend_uint, constinfo_cnt, xc_constinfo_t, constinfos)
[95]1313#endif
1314
[843]1315    PROCESS(zend_uint, funcinfo_cnt)
[917]1316    STRUCT_ARRAY(zend_uint, funcinfo_cnt, xc_funcinfo_t, funcinfos)
[1]1317
[843]1318    PROCESS(zend_uint, classinfo_cnt)
[1481]1319    STRUCT_ARRAY(zend_uint, classinfo_cnt, xc_classinfo_t, classinfos, , IFCOPY(`processor->active_class_index'))
[268]1320#ifdef ZEND_ENGINE_2_1
[843]1321    PROCESS(zend_uint, autoglobal_cnt)
[495]1322    IFRESTORE(`
[1440]1323        COPYPOINTER(autoglobals)
[495]1324    ', `
[917]1325        STRUCT_ARRAY(zend_uint, autoglobal_cnt, xc_autoglobal_t, autoglobals)
[495]1326    ')
[268]1327#endif
[1051]1328#ifdef XCACHE_ERROR_CACHING
[843]1329    PROCESS(zend_uint, compilererror_cnt)
[496]1330    IFRESTORE(`
[1440]1331        COPYPOINTER(compilererrors)
[496]1332    ', `
[917]1333        STRUCT_ARRAY(zend_uint, compilererror_cnt, xc_compilererror_t, compilererrors)
[496]1334    ')
1335#endif
[548]1336#ifndef ZEND_COMPILE_DELAYED_BINDING
[843]1337    PROCESS(zend_bool, have_early_binding)
[548]1338#endif
[843]1339    PROCESS(zend_bool, have_references)
[1]1340')
1341dnl }}}
[837]1342DEF_STRUCT_P_FUNC(`xc_entry_t', , `dnl {{{
[1]1343    /* skip */
1344    DONE(next)
[851]1345    PROCESS(size_t, size)
[1]1346
[843]1347    PROCESS(time_t, ctime)
1348    PROCESS(time_t, atime)
1349    PROCESS(time_t, dtime)
1350    PROCESS(long, ttl)
1351    PROCESS(zend_ulong, hits)
[866]1352    DONE(name) dnl handle in xc_entry_php_t and xc_entry_var_t
[851]1353')
1354dnl }}}
[1530]1355DEF_STRUCT_P_FUNC(`xc_constant_string_t', , `dnl {{{
1356    PROCESS(size_t, len)
1357    IFRESTORE(`COPYPOINTER(str)', `PROC_STRING_L(str, len)')
1358')
1359dnl }}}
1360#ifdef IS_UNICODE
1361DEF_STRUCT_P_FUNC(`xc_constant_u_string_t', , `dnl {{{
1362    PROCESS(size_t, len)
1363    IFRESTORE(`COPYPOINTER(str)', `PROC_USTRING_L(str, len)')
1364')
1365dnl }}}
1366#endif
[851]1367DEF_STRUCT_P_FUNC(`xc_entry_php_t', , `dnl {{{
1368    STRUCT(xc_entry_t, entry)
[866]1369    DISABLECHECK(`
1370        PROCESS(int, entry.name.str.len)
[1440]1371        IFRESTORE(`COPYPOINTER(entry.name.str.val)', `
[866]1372            PROC_STRING_L(entry.name.str.val, entry.name.str.len)
1373        ')
1374    ')
1375
[1440]1376    IFCALCCOPY(`COPYPOINTER(php)', `STRUCT_P(xc_entry_data_php_t, php)')
[851]1377
[1380]1378    IFSTORE(`DST(`refcount') = 0; DONE(refcount)', `PROCESS(long, refcount)')
[851]1379    PROCESS(time_t, file_mtime)
[859]1380    PROCESS(size_t, file_size)
[1201]1381    PROCESS(size_t, file_device)
1382    PROCESS(size_t, file_inode)
[684]1383
[1530]1384    STRUCT(xc_constant_string_t, filepath)
[1521]1385#ifdef ZEND_ENGINE_2_3
[1530]1386    STRUCT(xc_constant_string_t, dirpath)
[1521]1387#endif
[684]1388#ifdef IS_UNICODE
[1530]1389    STRUCT(xc_constant_u_string_t, u_filepath)
1390    STRUCT(xc_constant_u_string_t, u_dirpath)
[684]1391#endif
[1]1392')
1393dnl }}}
[854]1394DEF_STRUCT_P_FUNC(`xc_entry_var_t', , `dnl {{{
[1558]1395    IFCALCSTORE(`xc_entry_var_t *vsrc = /* const_cast */ (xc_entry_var_t *) src;')
[1564]1396    IFRESTORE(`processor->entry_var_src = src;')
[1558]1397
1398    dnl restore is done in foot.m4
[854]1399    STRUCT(xc_entry_t, entry)
1400
[866]1401#ifdef IS_UNICODE
1402    PROCESS(zend_uchar, name_type)
1403#endif
1404    dnl {{{ entry.name
1405    DISABLECHECK(`
1406#ifdef IS_UNICODE
[1380]1407        if (SRC(`name_type') == IS_UNICODE) {
[866]1408            PROCESS(int32_t, entry.name.ustr.len)
1409        }
1410        else {
1411            PROCESS(int, entry.name.str.len)
1412        }
1413#else
1414        PROCESS(int, entry.name.str.len)
1415#endif
[1440]1416        IFRESTORE(`COPYPOINTER(entry.name.str.val)', `
[866]1417#ifdef IS_UNICODE
1418            PROC_ZSTRING_L(name_type, entry.name.uni.val, entry.name.uni.len)
1419#else
1420            PROC_STRING_L(entry.name.str.val, entry.name.str.len)
1421#endif
1422        ')
1423    ')
1424    dnl }}}
1425
[854]1426    IFDPRINT(`INDENT()`'fprintf(stderr, "zval:value");')
[1380]1427    STRUCT_P_EX(zval_ptr, DST(`value'), SRC(`value'), `value', `', `&')
[1576]1428    DONE(value)
[1572]1429#if 0
1430    IFSTORE(`
1431    {
1432        HashTable *ht;
1433        zval **zv;
[1558]1434
[1576]1435        assert(Z_TYPE_P(DST(`value')) == IS_ARRAY);
1436        ht = Z_ARRVAL_P(DST(`value'));
[1572]1437        assert(ht->nNumOfElements == 1);
1438        fprintf(stderr, "key %s\n", ht->pListHead->arKey);
1439
1440        zv = (zval **) ht->pListHead->pData;
1441        assert(Z_TYPE_PP(zv) == IS_ARRAY);
1442        assert(Z_ARRVAL_PP(zv) == ht);
[1576]1443        fprintf(stderr, "refcount=%d\n", Z_REFCOUNT(*DST(`value')));
1444        fprintf(stderr, "refcount=%d\n", Z_REFCOUNT(**zv));
[1572]1445    }
1446    ')
1447#endif
1448
[1558]1449#ifdef ZEND_ENGINE_2
1450    IFCALC(`
[1568]1451        dnl objects = collect_from(value + objects);
[1558]1452        pushdef(`src', `vsrc')
[1568]1453        SRC(objects_count) = xc_vector_size(&processor->objects);
1454        SRC(objects) = xc_vector_detach(zend_object, &processor->objects);
[1558]1455        popdef(`src')
[1568]1456        xc_vector_destroy(&processor->objects);
[1558]1457    ')
1458    dnl must be after calc .value
1459    PROCESS(zend_uint, objects_count)
1460    STRUCT_ARRAY(zend_uint, objects_count, zend_object, objects)
1461    IFSTORE(`{
1462        /* no longer needed */
1463        if (vsrc->objects_count) {
1464            efree(vsrc->objects);
1465            vsrc->objects_count = 0;
1466            vsrc->objects = NULL;
1467            zend_hash_destroy(&processor->handle_to_index);
1468        }
1469    }')
1470#endif
1471
1472    dnl classe_
1473    IFCALC(`
[1568]1474        dnl class_names = collect_from(objects);
[1558]1475        pushdef(`src', `vsrc')
1476        SRC(class_names_count) = xc_vector_size(&processor->class_names);
1477        SRC(class_names) = xc_vector_detach(xc_constant_string_t, &processor->class_names);
1478        popdef(`src')
1479        xc_vector_destroy(&processor->class_names);
1480    ')
1481    PROCESS(zend_uint, class_names_count)
1482    STRUCT_ARRAY(zend_uint, class_names_count, xc_constant_string_t, class_names)
1483    IFSTORE(`
1484        /* no longer needed */
1485        if (vsrc->class_names_count) {
1486            efree(vsrc->class_names);
1487            vsrc->class_names_count = 0;
1488            vsrc->class_names = NULL;
1489            zend_hash_destroy(&processor->class_name_to_index);
1490        }
1491    ')
1492
[854]1493    PROCESS(zend_bool, have_references)
1494')
1495dnl }}}
[1]1496dnl ====================================================
Note: See TracBrowser for help on using the repository browser.