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