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

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

support for reference value

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