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

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

use vector for objects/object_handles

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