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

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

closes #342: object caching

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