source: trunk/processor/processor.m4 @ 724

Last change on this file since 724 was 724, checked in by moo, 3 years ago

merge from trunk

  • Property svn:eol-style set to native
File size: 26.5 KB
RevLine 
[1]1dnl ================
2/* {{{ Pre-declare */
3DECL_STRUCT_P_FUNC(`zval')
4DECL_STRUCT_P_FUNC(`zval_ptr')
5DECL_STRUCT_P_FUNC(`zend_op_array')
6DECL_STRUCT_P_FUNC(`zend_class_entry')
[95]7#ifdef HAVE_XCACHE_CONSTANT
8DECL_STRUCT_P_FUNC(`zend_constant')
9#endif
[1]10DECL_STRUCT_P_FUNC(`zend_function')
11DECL_STRUCT_P_FUNC(`xc_entry_t')
12#ifdef ZEND_ENGINE_2
13DECL_STRUCT_P_FUNC(`zend_property_info')
14#endif
15/* }}} */
16dnl ====================================================
17dnl {{{ zend_compiled_variable
18#ifdef IS_CV
19DEF_STRUCT_P_FUNC(`zend_compiled_variable', , `
20    DISPATCH(int, name_len)
[103]21    PROC_ZSTRING_L(, name, name_len)
[1]22    DISPATCH(ulong, hash_value)
23')
24#endif
25dnl }}}
26dnl {{{ zend_uint
27DEF_STRUCT_P_FUNC(`zend_uint', , `
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 }}}
36dnl {{{ int
37#ifndef ZEND_ENGINE_2
38DEF_STRUCT_P_FUNC(`int', , `
39    IFCOPY(`*dst = *src;')
40    IFDPRINT(`
41        INDENT()
42        fprintf(stderr, "%d\n", src[0]);
43    ')
44    DONE_SIZE(sizeof(src[0]))
45')
46#endif
47dnl }}}
48dnl {{{ zend_try_catch_element
49#ifdef ZEND_ENGINE_2
50DEF_STRUCT_P_FUNC(`zend_try_catch_element', , `
51    DISPATCH(zend_uint, try_op)
52    DISPATCH(zend_uint, catch_op)
53')
54#endif /* ifdef ZEND_ENGINE_2 */
55dnl }}}
56dnl {{{ zend_brk_cont_element
57DEF_STRUCT_P_FUNC(`zend_brk_cont_element', , `
[194]58#ifdef ZEND_ENGINE_2_2
59    DISPATCH(int, start)
60#endif
[1]61    DISPATCH(int, cont)
62    DISPATCH(int, brk)
63    DISPATCH(int, parent)
64')
65dnl }}}
66DEF_HASH_TABLE_FUNC(`HashTable_zval_ptr',           `zval_ptr')
67DEF_HASH_TABLE_FUNC(`HashTable_zend_function',      `zend_function')
68#ifdef ZEND_ENGINE_2
69DEF_HASH_TABLE_FUNC(`HashTable_zend_property_info', `zend_property_info')
70#endif
71DEF_STRUCT_P_FUNC(`zval', , `dnl {{{
72    IFDASM(`do {
73        zval_dtor(dst);
74        *dst = *src;
75        zval_copy_ctor(dst);
[487]76        Z_SET_REFCOUNT(*dst, 1);
[1]77        DONE(value)
78        DONE(type)
[485]79#ifdef ZEND_ENGINE_2_3
80        DONE(is_ref__gc)
81        DONE(refcount__gc)
82#else
[1]83        DONE(is_ref)
[485]84        DONE(refcount)
[482]85#endif
[1]86    } while(0);
87    ', `
88        dnl IFDASM else
89        /* Variable information */
90dnl {{{ zvalue_value
91        DISABLECHECK(`
[491]92        switch ((Z_TYPE_P(src) & IS_CONSTANT_TYPE_MASK)) {
[1]93            case IS_LONG:
94            case IS_RESOURCE:
95            case IS_BOOL:
96                DISPATCH(long, value.lval)
97                break;
98            case IS_DOUBLE:
99                DISPATCH(double, value.dval)
100                break;
101            case IS_NULL:
102                IFDPRINT(`INDENT()`'fprintf(stderr, "\tNULL\n");')
103                break;
104
105            case IS_CONSTANT:
106#ifdef IS_UNICODE
107                if (UG(unicode)) {
108                    goto proc_unicode;
109                }
110#endif
111            case IS_STRING:
112#ifdef FLAG_IS_BC
113            case FLAG_IS_BC:
114#endif
115                DISPATCH(int, value.str.len)
116                PROC_STRING_L(value.str.val, value.str.len)
117                break;
118#ifdef IS_UNICODE
119            case IS_UNICODE:
120proc_unicode:
[103]121                DISPATCH(int32_t, value.uni.len)
122                PROC_ZSTRING_L(1, value.uni.val, value.uni.len)
[1]123                break;
124#endif
125
126            case IS_ARRAY:
127            case IS_CONSTANT_ARRAY:
128                STRUCT_P(HashTable, value.ht, HashTable_zval_ptr)
129                break;
130
131            case IS_OBJECT:
132                IFNOTMEMCPY(`IFCOPY(`memcpy(dst, src, sizeof(src[0]));')')
133                dnl STRUCT(value.obj)
134#ifndef ZEND_ENGINE_2
135                STRUCT_P(zend_class_entry, value.obj.ce)
136                STRUCT_P(HashTable, value.obj.properties, HashTable_zval_ptr)
137#endif
138                break;
139
140            default:
141                assert(0);
142        }
143        ')
144dnl }}}
145        DONE(value)
146        DISPATCH(zval_data_type, type)
[485]147#ifdef ZEND_ENGINE_2_3
148        DISPATCH(zend_uchar, is_ref__gc)
149#else
[1]150        DISPATCH(zend_uchar, is_ref)
[485]151#endif
152
153#ifdef ZEND_ENGINE_2_3
154        DISPATCH(zend_uint, refcount__gc)
155#elif defined(ZEND_ENGINE_2)
[484]156        DISPATCH(zend_uint, refcount)
157#else
[1]158        DISPATCH(zend_ushort, refcount)
[484]159#endif
[1]160    ')dnl IFDASM
161')
162dnl }}}
163DEF_STRUCT_P_FUNC(`zval_ptr', , `dnl {{{
164    IFDASM(`
165        pushdefFUNC_NAME(`zval')
166        FUNC_NAME (dst, src[0] TSRMLS_CC);
167        popdef(`FUNC_NAME')
168    ', `
169        do {
170            IFCALCCOPY(`
171                if (processor->reference) {
172                    zval_ptr *ppzv;
[231]173                    if (zend_hash_find(&processor->zvalptrs, (char *) &src[0], sizeof(src[0]), (void **) &ppzv) == SUCCESS) {
[1]174                        IFCOPY(`
175                            dst[0] = *ppzv;
176                            /* *dst is updated */
[248]177                            dnl fprintf(stderr, "*dst is set to %p, KIND is_shm %d\n", dst[0], xc_is_shm(dst[0]));
[1]178                        ')
[233]179                        IFCALCSTORE(`processor->have_references = 1;')
[1]180                        IFSTORE(`assert(xc_is_shm(dst[0]));')
181                        IFRESTORE(`assert(!xc_is_shm(dst[0]));')
182                        break;
183                    }
184                }
185            ')
186           
187            ALLOC(dst[0], zval)
188            IFCALCCOPY(`
189                if (processor->reference) {
190                    IFCALC(`
191                        /* make dummy */
192                        zval_ptr pzv = (zval_ptr)-1;
193                    ', `
194                        zval_ptr pzv = dst[0];
[248]195                        FIXPOINTER_EX(zval, pzv)
[1]196                    ')
[231]197                    if (zend_hash_add(&processor->zvalptrs, (char *) &src[0], sizeof(src[0]), (void *) &pzv, sizeof(pzv), NULL) == SUCCESS) {
[1]198                        /* first add, go on */
199                        dnl fprintf(stderr, "mark[%p] = %p\n", src[0], pzv);
200                    }
201                    else {
202                        assert(0);
203                    }
204                }
205            ')
206            IFCOPY(`
207                dnl fprintf(stderr, "copy from %p to %p\n", src[0], dst[0]);
208            ')
[534]209            IFDPRINT(`INDENT()`'fprintf(stderr, "[%p] ", src[0]);')
[4]210            STRUCT_P_EX(zval, dst[0], src[0], `[0]', `', ` ')
[248]211            FIXPOINTER_EX(zval, dst[0])
[1]212        } while (0);
213    ')
214    DONE_SIZE(sizeof(zval_ptr))
215')
216dnl }}}
217dnl {{{ zend_arg_info
218#ifdef ZEND_ENGINE_2
219DEF_STRUCT_P_FUNC(`zend_arg_info', , `
220    DISPATCH(zend_uint, name_len)
[645]221    PROC_ZSTRING_L(, name, name_len)
[1]222    DISPATCH(zend_uint, class_name_len)
[645]223    PROC_ZSTRING_L(, class_name, class_name_len)
[716]224#ifdef ZEND_ENGINE_2_4
225    DISPATCH(zend_uchar, type_hint)
226#else
[1]227    DISPATCH(zend_bool, array_type_hint)
[716]228#endif
[1]229    DISPATCH(zend_bool, allow_null)
230    DISPATCH(zend_bool, pass_by_reference)
[716]231#ifndef ZEND_ENGINE_2_4
[1]232    DISPATCH(zend_bool, return_reference)
233    DISPATCH(int, required_num_args)
[716]234#endif
[1]235')
236#endif
237dnl }}}
[95]238#ifdef HAVE_XCACHE_CONSTANT
239DEF_STRUCT_P_FUNC(`zend_constant', , `dnl {{{
240    STRUCT(zval, value)
241    DISPATCH(int, flags)
242    DISPATCH(uint, name_len)
[218]243    pushdef(`emalloc', `malloc($1)')
244    pushdef(`ecalloc', `calloc($1, $2)')
[505]245    PROC_ZSTRING_N(, name, name_len)
[218]246    popdef(`ecalloc')
247    popdef(`emalloc')
[95]248    DISPATCH(int, module_number)
249')
250dnl }}}
251#endif
[1]252DEF_STRUCT_P_FUNC(`zend_function', , `dnl {{{
253    DISABLECHECK(`
254    switch (src->type) {
255    case ZEND_INTERNAL_FUNCTION:
256    case ZEND_OVERLOADED_FUNCTION:
257        IFNOTMEMCPY(`IFCOPY(`memcpy(dst, src, sizeof(src[0]));')')
258        break;
259
260    case ZEND_USER_FUNCTION:
261    case ZEND_EVAL_CODE:
262        DONE(type)
263        STRUCT(zend_op_array, op_array)
264        break;
265
266    default:
267        assert(0);
268    }
269    ')
270    DONE_SIZE(sizeof(src[0]))
271')
272dnl }}}
273dnl {{{ zend_property_info
274#ifdef ZEND_ENGINE_2
275DEF_STRUCT_P_FUNC(`zend_property_info', , `
276    DISPATCH(zend_uint, flags)
277    DISPATCH(int, name_length)
[103]278    PROC_ZSTRING_L(, name, name_length)
[1]279    DISPATCH(ulong, h)
[716]280#ifdef ZEND_ENGINE_2_4
281    DISPATCH(int, offset)
282#endif
[56]283#ifdef ZEND_ENGINE_2_1
[1]284    DISPATCH(int, doc_comment_len)
[272]285    PROC_ZSTRING_L(, doc_comment, doc_comment_len)
[56]286#endif
[78]287    dnl isnt in php6 yet
[504]288#if defined(ZEND_ENGINE_2_2)
[78]289    PROC_CLASS_ENTRY_P(ce)
290#endif
[1]291')
292#endif
293dnl }}}
294DEF_STRUCT_P_FUNC(`zend_class_entry', , `dnl {{{
[199]295    IFCALCCOPY(`
[1]296        processor->active_class_entry_src = src;
[199]297        IFCOPY(`processor->active_class_entry_dst = dst;')
[1]298    ')
299    DISPATCH(char, type)
300    DISPATCH(zend_uint, name_length)
[103]301    PROC_ZSTRING_L(, name, name_length)
[1]302    IFRESTORE(`
303#ifndef ZEND_ENGINE_2
304        /* just copy parent and resolve on install_class */
305        COPY(parent)
306#else
307        PROC_CLASS_ENTRY_P(parent)
308#endif
309    ', `
310        PROC_CLASS_ENTRY_P(parent)
311    ')
312#ifdef ZEND_ENGINE_2
313    DISPATCH(int, refcount)
314#else
315    STRUCT_P(int, refcount)
316#endif
[716]317#ifndef ZEND_ENGINE_2_4
[1]318    DISPATCH(zend_bool, constants_updated)
[716]319#endif
[1]320#ifdef ZEND_ENGINE_2
321    DISPATCH(zend_uint, ce_flags)
322#endif
323
[721]324#ifdef ZEND_ENGINE_2
325    STRUCT(HashTable, properties_info, HashTable_zend_property_info)
326#endif
327
[716]328#ifdef ZEND_ENGINE_2_4
329    DISPATCH(int, default_properties_count)
330    STRUCT_ARRAY(default_properties_count, zval, default_properties_table)
331    DISPATCH(int, default_static_members_count)
332    STRUCT_ARRAY(default_static_members_count, zval, default_static_members_table)
333    IFCOPY(`dst->static_members_table = &dst->default_static_members_table;')
334    DONE(static_members_table)
335#else
[1]336    IFCOPY(`dst->builtin_functions = src->builtin_functions;')
337    DONE(builtin_functions)
[716]338    STRUCT(HashTable, default_properties, HashTable_zval_ptr)
[721]339#   ifdef ZEND_ENGINE_2_1
[233]340    STRUCT(HashTable, default_static_members, HashTable_zval_ptr)
[1]341    IFCOPY(`dst->static_members = &dst->default_static_members;')
342    DONE(static_members)
[721]343#   elif defined(ZEND_ENGINE_2)
[233]344    STRUCT_P(HashTable, static_members, HashTable_zval_ptr)
[1]345#   endif
[716]346#endif /* ZEND_ENGINE_2_4 */
347
348#ifdef ZEND_ENGINE_2
[1]349    STRUCT(HashTable, constants_table, HashTable_zval_ptr)
350
351    dnl runtime binding: ADD_INTERFACE will deal with it
[716]352    dnl runtime binding: ADD_TRAIT will deal with it
[1]353    IFRESTORE(`
354        if (src->num_interfaces) {
355            CALLOC(dst->interfaces, zend_class_entry*, src->num_interfaces)
[4]356            DONE(`interfaces')
[716]357#   ifdef ZEND_ENGINE_2_4
358            CALLOC(dst->traits, zend_class_entry*, src->num_traits)
359            DONE(`traits')
360            DONE(`trait_aliases')
361            DONE(`trait_precedences')
362#   endif
[1]363        }
364        else {
[716]365            COPYNULL(`interfaces')
366#   ifdef ZEND_ENGINE_2_4
367            COPYNULL(`traits')
368            COPYNULL(`trait_aliases')
369            COPYNULL(`trait_precedences')
370#   endif
[1]371        }
372    ')
373    IFDASM(`
374        if (src->num_interfaces) {
375            /*
[662]376            int i;
[1]377            zval *arr;
378            ALLOC_INIT_ZVAL(arr);
379            array_init(arr);
380            for (i = 0; i < src->num_interfaces; i ++) {
381                zval *zv;
382                ALLOC_INIT_ZVAL(zv);
383                ZVAL_STRING(src->num_interfaces);
384            }
385            add_assoc_zval_ex(dst, ZEND_STRS("interfaces"), arr);
386            */
[4]387            DONE(`interfaces')
[716]388#   ifdef ZEND_ENGINE_2_4
389            DONE(`traits')
390            DONE(`trait_aliases')
391            DONE(`trait_precedences')
392#   endif
[1]393        }
394        else {
[716]395            COPYNULL(`interfaces')
396#   ifdef ZEND_ENGINE_2_4
397            COPYNULL(`traits')
398            COPYNULL(`trait_aliases')
399            COPYNULL(`trait_precedences')
400#   endif
[1]401        }
402    ')
[4]403    IFRESTORE(`', `
404        IFDASM(`', `
405            DONE(`interfaces')
[716]406#   ifdef ZEND_ENGINE_2_4
407            DONE(`traits')
408            DONE(`trait_aliases')
409            DONE(`trait_precedences')
410#   endif
[4]411        ')
412    ')
[1]413    DISPATCH(zend_uint, num_interfaces)
[716]414#   ifdef ZEND_ENGINE_2_4
415    DISPATCH(zend_uint, num_traits)
416#   endif
[1]417
[716]418#   ifdef ZEND_ENGINE_2_4
419    DISABLECHECK(`
420    IFRESTORE(`dst->info.user.filename = processor->entry_src->filepath;', `PROC_STRING(info.user.filename)')
421    DISPATCH(zend_uint, info.user.line_start)
422    DISPATCH(zend_uint, info.user.line_end)
423    DISPATCH(zend_uint, info.user.doc_comment_len)
424    PROC_ZSTRING_L(, info.user.doc_comment, info.user.doc_comment_len)
425    ')
426    DONE(info)
427#   else
[687]428    IFRESTORE(`dst->filename = processor->entry_src->filepath;DONE(filename)', `PROC_STRING(filename)')
[1]429    DISPATCH(zend_uint, line_start)
430    DISPATCH(zend_uint, line_end)
[716]431#       ifdef ZEND_ENGINE_2_1
[1]432    DISPATCH(zend_uint, doc_comment_len)
[272]433    PROC_ZSTRING_L(, doc_comment, doc_comment_len)
[716]434#       endif
435#   endif
436
[1]437    /* # NOT DONE */
438    COPY(serialize_func)
439    COPY(unserialize_func)
440    COPY(iterator_funcs)
441    COPY(create_object)
442    COPY(get_iterator)
443    COPY(interface_gets_implemented)
[716]444#   ifdef ZEND_ENGINE_2_3
[480]445    COPY(get_static_method)
[716]446#   endif
[1]447    COPY(serialize)
448    COPY(unserialize)
449    /* deal with it inside xc_fix_method */
450    SETNULL(constructor)
451    COPY(destructor)
452    COPY(clone)
453    COPY(__get)
454    COPY(__set)
455/* should be >5.1 */
[716]456#   ifdef ZEND_ENGINE_2_1
[1]457    COPY(__unset)
458    COPY(__isset)
[716]459#    if defined(ZEND_ENGINE_2_2) || PHP_MAJOR_VERSION >= 6
[1]460    COPY(__tostring)
[716]461#    endif
462#   endif
[1]463    COPY(__call)
[716]464#   ifdef ZEND_CALLSTATIC_FUNC_NAME
[480]465    COPY(__callstatic)
[716]466#   endif
467#   ifndef ZEND_ENGINE_2_4
[1]468    /* # NOT DONE */
469    COPY(module)
[716]470#   endif
471#else /* ZEND_ENGINE_2 */
[1]472    COPY(handle_function_call)
473    COPY(handle_property_get)
474    COPY(handle_property_set)
475#endif
[89]476    dnl must do after SETNULL(constructor) and dst->parent
[1]477    STRUCT(HashTable, function_table, HashTable_zend_function)
[99]478    IFRESTORE(`dst->function_table.pDestructor = ZEND_FUNCTION_DTOR;')
[199]479    IFCALCCOPY(`
[89]480        processor->active_class_entry_src = NULL;
[199]481        IFCOPY(`processor->active_class_entry_dst = NULL;')
[89]482    ')
[1]483')
484dnl }}}
[716]485#ifdef ZEND_ENGINE_2_4
486undefine(`UNION_znode_op')
487define(`UNION_znode_op', `dnl {{{
[721]488    switch ((src->$1_type & ~EXT_TYPE_UNUSED)) {
489    case IS_CONST:
490    case IS_VAR:
491    case IS_CV:
492    case IS_TMP_VAR:
493    case IS_UNUSED:
494        break;
495
496    default:
497        assert(0);
498    }
499
[716]500    dnl dirty dispatch
501    DISABLECHECK(`
[721]502    switch ((src->$1_type & ~EXT_TYPE_UNUSED)) {
[716]503        case IS_CONST:
504            dnl TODO: fix me, use literals
505            IFDASM(`{
506                zval *zv;
507                ALLOC_INIT_ZVAL(zv);
508                *zv = ((zend_literal *) src->$1.ptr)->constant;
509                zval_copy_ctor(zv);
510                add_assoc_zval_ex(dst, ZEND_STRS("$1.constant"), zv);
511                }
512            ', `
513                DISPATCH(zend_uint, $1.constant)
514            ')
515            break;
516        IFCOPY(`
517            IFNOTMEMCPY(`
518                default:
519                    *dst = *src;
520            ')
521        ', `
522        case IS_VAR:
523        case IS_TMP_VAR:
524        case IS_CV:
525            DISPATCH(zend_uint, $1.var)
526            break;
527        case IS_UNUSED:
528            IFDASM(`DISPATCH(zend_uint, $1.var)')
529            DISPATCH(zend_uint, $1.opline_num)
530            break;
531        ')
532    }
533    ')
534    DONE($1)
535')
536dnl }}}
537#else
[1]538DEF_STRUCT_P_FUNC(`znode', , `dnl {{{
539    DISPATCH(int, op_type)
540
541#ifdef IS_CV
[11]542#   define XCACHE_IS_CV IS_CV
[1]543#else
[11]544/* compatible with zend optimizer */
545#   define XCACHE_IS_CV 16
[1]546#endif
[11]547    assert(src->op_type == IS_CONST ||
548        src->op_type == IS_VAR ||
549        src->op_type == XCACHE_IS_CV ||
[1]550        src->op_type == IS_TMP_VAR ||
551        src->op_type == IS_UNUSED);
552    dnl dirty dispatch
553    DISABLECHECK(`
554    switch (src->op_type) {
555        case IS_CONST:
556            STRUCT(zval, u.constant)
557            break;
558        IFCOPY(`
559            IFNOTMEMCPY(`
560                default:
561                    memcpy(&dst->u, &src->u, sizeof(src->u));
562            ')
563        ', `
564        case IS_VAR:
565        case IS_TMP_VAR:
[310]566        case XCACHE_IS_CV:
[1]567            DISPATCH(zend_uint, u.var)
568            DISPATCH(zend_uint, u.EA.type)
569            break;
570        case IS_UNUSED:
571            IFDASM(`DISPATCH(zend_uint, u.var)')
572            DISPATCH(zend_uint, u.opline_num)
573#ifndef ZEND_ENGINE_2
574            DISPATCH(zend_uint, u.fetch_type)
575#endif
576            DISPATCH(zend_uint, u.EA.type)
577            break;
578        ')
579    }
580    ')
581    DONE(u)
[716]582#if 0
583    DONE(EA)
584#endif
[310]585#undef XCACHE_IS_CV
[1]586')
587dnl }}}
[716]588#endif
[1]589DEF_STRUCT_P_FUNC(`zend_op', , `dnl {{{
590    DISPATCH(zend_uchar, opcode)
[716]591#ifdef ZEND_ENGINE_2_4
592    UNION_znode_op(result)
593    UNION_znode_op(op1)
594    UNION_znode_op(op2)
595#else
[1]596    STRUCT(znode, result)
597    STRUCT(znode, op1)
598    STRUCT(znode, op2)
[716]599#endif
[1]600    DISPATCH(ulong, extended_value)
601    DISPATCH(uint, lineno)
602#ifdef ZEND_ENGINE_2_1
[716]603#ifdef ZEND_ENGINE_2_4
604    DISPATCH(zend_uchar, op1_type)
605    DISPATCH(zend_uchar, op2_type)
606    DISPATCH(zend_uchar, result_type)
607#endif
[1]608    IFCOPY(`
609        switch (src->opcode) {
[515]610#ifdef ZEND_GOTO
611            case ZEND_GOTO:
612#endif
[1]613            case ZEND_JMP:
[716]614                Z_OP(dst->op1).jmp_addr = processor->active_opcodes_dst + (Z_OP(src->op1).jmp_addr - processor->active_opcodes_src);
[1]615                break;
616
617            case ZEND_JMPZ:
618            case ZEND_JMPNZ:
619            case ZEND_JMPZ_EX:
620            case ZEND_JMPNZ_EX:
[485]621#ifdef ZEND_JMP_SET
622            case ZEND_JMP_SET:
623#endif
[716]624                Z_OP(dst->op2).jmp_addr = processor->active_opcodes_dst + (Z_OP(src->op2).jmp_addr - processor->active_opcodes_src);
[1]625                break;
626
627            default:
628                break;
629        }
630    ')
631    DISPATCH(opcode_handler_t, handler)
632#endif
633')
634dnl }}}
[716]635#ifdef ZEND_ENGINE_2_4
636DEF_STRUCT_P_FUNC(`zend_literal', , `dnl {{{
637    STRUCT(zval, constant)
638    DISPATCH(zend_ulong, hash_value)
639    DISPATCH(zend_uint,  cache_slot)
640')
641dnl }}}
642#endif
[1]643DEF_STRUCT_P_FUNC(`zend_op_array', , `dnl {{{
644    IFRESTORE(`
[662]645    const xc_op_array_info_t *op_array_info = &processor->active_op_array_infos_src[processor->active_op_array_index];
[212]646    dnl shadow copy must NOT meet:
647    dnl readonly_protection=on
648    dnl main op_array && have early binding
[548]649#ifdef ZEND_COMPILE_DELAYED_BINDING
650    zend_bool need_early_binding = 0;
651#else
652    zend_bool need_early_binding = processor->php_src->have_early_binding;
653#endif
[662]654    zend_bool shallow_copy = !processor->readonly_protection && !(src == processor->php_src->op_array && need_early_binding);
655    if (shallow_copy) {
656        zend_bool gc_arg_info = 0;
657        int gc_opcodes        = 0;
[1]658        /* really fast shallow copy */
659        memcpy(dst, src, sizeof(src[0]));
660        dst->refcount[0] = 1000;
661        /* deep */
662        STRUCT_P(HashTable, static_variables, HashTable_zval_ptr)
[508]663#ifdef ZEND_ENGINE_2
[662]664        STRUCT_ARRAY(num_args, zend_arg_info, arg_info)
665        gc_arg_info = 1;
[508]666#endif
[687]667        IFRESTORE(`dst->filename = processor->entry_src->filepath;')
[721]668#ifndef ZEND_ENGINE_2_4
[662]669        if (op_array_info->oplineinfo_cnt) {
670            gc_opcodes = 1;
671            COPY_N_EX(last, zend_op, opcodes)
672        }
[721]673#endif
[662]674        if (gc_arg_info || gc_opcodes) {
675            xc_gc_op_array_t gc_op_array;
676#ifdef ZEND_ENGINE_2
677            gc_op_array.num_args = gc_arg_info ? dst->num_args : 0;
678            gc_op_array.arg_info = gc_arg_info ? dst->arg_info : NULL;
679#endif
680            gc_op_array.last     = gc_opcodes > 1 ? dst->last : 0;
681            gc_op_array.opcodes  = gc_opcodes ? dst->opcodes : NULL;
682            xc_gc_add_op_array(&gc_op_array TSRMLS_CC);
683        }
[1]684        define(`SKIPASSERT_ONCE')
685    }
686    else
687    ')
688    do {
689    dnl RESTORE is done above!
690
691    /* Common elements */
692    DISPATCH(zend_uchar, type)
[103]693    PROC_ZSTRING(, function_name)
[1]694#ifdef ZEND_ENGINE_2
695    DISPATCH(zend_uint, fn_flags)
[662]696    STRUCT_ARRAY(num_args, zend_arg_info, arg_info)
[1]697    DISPATCH(zend_uint, num_args)
698    DISPATCH(zend_uint, required_num_args)
[716]699#   ifndef ZEND_ENGINE_2_4
[1]700    DISPATCH(zend_bool, pass_rest_by_reference)
[716]701#   endif
[1]702#else
703    if (src->arg_types) {
704        ALLOC(dst->arg_types, zend_uchar, src->arg_types[0] + 1)
705        IFCOPY(`memcpy(dst->arg_types, src->arg_types, sizeof(src->arg_types[0]) * (src->arg_types[0]+1));')
706        IFDASM(`do {
707            int i;
708            zval *zv;
709            ALLOC_INIT_ZVAL(zv);
710            array_init(zv);
711            for (i = 0; i < src->arg_types[0]; i ++) {
712                add_next_index_long(zv, src->arg_types[i + 1]);
713            }
714            add_assoc_zval_ex(dst, ZEND_STRS("arg_types"), zv);
715        } while (0);')
716        DONE(arg_types)
717    }
718    else {
719        IFDASM(`do {
720            /* empty array */
721            zval *zv;
722            ALLOC_INIT_ZVAL(zv);
723            array_init(zv);
724            add_assoc_zval_ex(dst, ZEND_STRS("arg_types"), zv);
725        } while (0);
726        DONE(arg_types)
727        ', `
728        COPYNULL(arg_types)
729        ')
730    }
731#endif
[716]732#ifndef ZEND_ENGINE_2_4
[1]733    DISPATCH(unsigned char, return_reference)
[716]734#endif
[1]735    /* END of common elements */
736#ifdef IS_UNICODE
[103]737    dnl SETNULL(u_twin)
[1]738#endif
739
740    STRUCT_P(zend_uint, refcount)
741    UNFIXPOINTER(zend_uint, refcount)
[221]742    IFSTORE(`dst->refcount[0] = 1;')
[1]743
744    pushdef(`AFTER_ALLOC', `IFCOPY(`
745        processor->active_opcodes_dst = dst->opcodes;
746        processor->active_opcodes_src = src->opcodes;
747    ')')
[662]748    STRUCT_ARRAY(last, zend_op, opcodes)
[1]749    popdef(`AFTER_ALLOC')
750    DISPATCH(zend_uint, last)
[716]751#ifndef ZEND_ENGINE_2_4
[1]752    IFCOPY(`dst->size = src->last;DONE(size)', `DISPATCH(zend_uint, size)')
[716]753#endif
[1]754
755#ifdef IS_CV
756    STRUCT_ARRAY(last_var, zend_compiled_variable, vars)
757    DISPATCH(int, last_var)
[716]758#   ifndef ZEND_ENGINE_2_4
[1]759    IFCOPY(`dst->size_var = src->last_var;DONE(size_var)', `DISPATCH(zend_uint, size_var)')
[716]760#   endif
[1]761#else
762    dnl zend_cv.m4 is illegal to be made public, don not ask me for it
763    IFDASM(`
[4]764        sinclude(srcdir`/processor/zend_cv.m4')
[1]765        ')
766#endif
767
768    DISPATCH(zend_uint, T)
769
[662]770    STRUCT_ARRAY(last_brk_cont, zend_brk_cont_element, brk_cont_array)
[1]771    DISPATCH(zend_uint, last_brk_cont)
[716]772#ifndef ZEND_ENGINE_2_4
[1]773    DISPATCH(zend_uint, current_brk_cont)
[716]774#endif
[1]775#ifndef ZEND_ENGINE_2
776    DISPATCH(zend_bool, uses_globals)
777#endif
778
779#ifdef ZEND_ENGINE_2
780    STRUCT_ARRAY(last_try_catch, zend_try_catch_element, try_catch_array)
781    DISPATCH(int, last_try_catch)
782#endif
783
784    STRUCT_P(HashTable, static_variables, HashTable_zval_ptr)
785
[716]786#ifndef ZEND_ENGINE_2_4
[95]787    COPY(start_op)
[1]788    DISPATCH(int, backpatch_count)
[716]789#endif
[562]790#ifdef ZEND_ENGINE_2_3
791    DISPATCH(zend_uint, this_var)
792#endif
[1]793
[716]794#ifndef ZEND_ENGINE_2_4
[1]795    DISPATCH(zend_bool, done_pass_two)
[716]796#endif
[562]797    /* 5.0 <= ver < 5.3 */
798#if defined(ZEND_ENGINE_2) && !defined(ZEND_ENGINE_2_3)
[1]799    DISPATCH(zend_bool, uses_this)
800#endif
801
[687]802    IFRESTORE(`dst->filename = processor->entry_src->filepath;DONE(filename)', `PROC_STRING(filename)')
[1]803#ifdef IS_UNICODE
[267]804    IFRESTORE(`
805        COPY(script_encoding)
806    ', `
807        PROC_STRING(script_encoding)
808    ')
[1]809#endif
810#ifdef ZEND_ENGINE_2
811    DISPATCH(zend_uint, line_start)
812    DISPATCH(zend_uint, line_end)
813    DISPATCH(int, doc_comment_len)
[272]814    PROC_ZSTRING_L(, doc_comment, doc_comment_len)
[1]815#endif
[548]816#ifdef ZEND_COMPILE_DELAYED_BINDING
817    DISPATCH(zend_uint, early_binding);
818#endif
[1]819
820    /* reserved */
821    DONE(reserved)
822#if defined(HARDENING_PATCH) && HARDENING_PATCH
823    DISPATCH(zend_bool, created_by_eval)
824#endif
[724]825#ifdef ZEND_ENGINE_2_4
826    DISPATCH(int, last_literal)
827    IFRESTORE(`COPY(literals)', `STRUCT_ARRAY(last_literal, zend_literal, literals)')
828
829    COPYNULL(run_time_cache)
830    COPYNULL(last_cache_slot)
831#endif
[1]832    } while (0);
[684]833    IFRESTORE(`xc_fix_op_array_info(processor->entry_src, processor->php_src, dst, !shallow_copy, op_array_info TSRMLS_CC);')
[189]834
[219]835#ifdef ZEND_ENGINE_2
836    dnl mark it as -1 on store, and lookup parent on restore
837    IFSTORE(`dst->prototype = (processor->active_class_entry_src && src->prototype) ? (zend_function *) -1 : NULL; DONE(prototype)', `
838            IFRESTORE(`do {
839                zend_function *parent;
840                if (src->prototype != NULL
841                 && zend_u_hash_find(&(processor->active_class_entry_dst->parent->function_table),
842                        UG(unicode) ? IS_UNICODE : IS_STRING,
[513]843                        src->function_name, xc_zstrlen(UG(unicode) ? IS_UNICODE : IS_STRING, src->function_name) + 1,
[219]844                        (void **) &parent) == SUCCESS) {
845                    /* see do_inherit_method_check() */
846                    if ((parent->common.fn_flags & ZEND_ACC_ABSTRACT)) {
847                      dst->prototype = parent;
848                    } else if (!(parent->common.fn_flags & ZEND_ACC_CTOR) || (parent->common.prototype && (parent->common.prototype->common.scope->ce_flags & ZEND_ACC_INTERFACE))) {
849                        /* ctors only have a prototype if it comes from an interface */
850                        dst->prototype = parent->common.prototype ? parent->common.prototype : parent;
851                    }
852                    else {
853                        dst->prototype = NULL;
854                    }
855                }
856                else {
857                    dst->prototype = NULL;
858                }
859                DONE(prototype)
860            } while (0);
861            ', `
862                COPYNULL(prototype)
863            ')
864    ')
[716]865
[219]866#endif
867
[189]868#ifdef ZEND_ENGINE_2
[507]869    PROC_CLASS_ENTRY_P(scope)
870    IFCOPY(`
[219]871        if (src->scope) {
[507]872            xc_fix_method(processor, dst TSRMLS_CC);
[189]873        }
874    ')
[507]875#endif
[189]876
877    IFRESTORE(`
878        if (xc_have_op_array_ctor) {
879            zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) xc_zend_extension_op_array_ctor_handler, dst TSRMLS_CC);
880        }
881    ')
[1]882')
883dnl }}}
884
[95]885#ifdef HAVE_XCACHE_CONSTANT
886DEF_STRUCT_P_FUNC(`xc_constinfo_t', , `dnl {{{
887    DISPATCH(zend_uint, key_size)
888#ifdef IS_UNICODE
889    DISPATCH(zend_uchar, type)
890#endif
891    IFRESTORE(`COPY(key)', `
[103]892        PROC_ZSTRING_N(type, key, key_size)
[95]893    ')
[506]894    DISPATCH(ulong, h)
[95]895    STRUCT(zend_constant, constant)
896')
897dnl }}}
898#endif
[662]899DEF_STRUCT_P_FUNC(`xc_op_array_info_t', , `dnl {{{
[721]900#ifdef ZEND_ENGINE_2_4
901    DISPATCH(zend_uint, literalinfo_cnt)
902    DISPATCH_ARRAY(literalinfo_cnt, int, literalinfos)
903#else
[662]904    DISPATCH(zend_uint, oplineinfo_cnt)
905    DISPATCH_ARRAY(oplineinfo_cnt, int, oplineinfos)
[721]906#endif
[662]907')
908dnl }}}
[1]909DEF_STRUCT_P_FUNC(`xc_funcinfo_t', , `dnl {{{
910    DISPATCH(zend_uint, key_size)
911#ifdef IS_UNICODE
912    DISPATCH(zend_uchar, type)
913#endif
914    IFRESTORE(`COPY(key)', `
[103]915        PROC_ZSTRING_N(type, key, key_size)
[1]916    ')
[506]917    DISPATCH(ulong, h)
[662]918    IFRESTORE(`COPY(op_array_info)', `
919        STRUCT(xc_op_array_info_t, op_array_info)
920    ')
921    IFRESTORE(`
[666]922        processor->active_op_array_infos_src = &src->op_array_info;
[662]923        processor->active_op_array_index = 0;
924    ')
[1]925    STRUCT(zend_function, func)
926')
927dnl }}}
928DEF_STRUCT_P_FUNC(`xc_classinfo_t', , `dnl {{{
929    DISPATCH(zend_uint, key_size)
930#ifdef IS_UNICODE
931    DISPATCH(zend_uchar, type)
932#endif
933    IFRESTORE(`COPY(key)', `
[103]934        PROC_ZSTRING_N(type, key, key_size)
[1]935    ')
[506]936    DISPATCH(ulong, h)
[662]937    DISPATCH(zend_uint, methodinfo_cnt)
938    IFRESTORE(`COPY(methodinfos)', `
939        STRUCT_ARRAY(methodinfo_cnt, xc_op_array_info_t, methodinfos)
940    ')
941    IFRESTORE(`
[666]942        processor->active_op_array_infos_src = src->methodinfos;
[662]943        processor->active_op_array_index = 0;
944    ')
[1]945#ifdef ZEND_ENGINE_2
946    STRUCT_P(zend_class_entry, cest)
947#else
948    STRUCT(zend_class_entry, cest)
949#endif
[548]950#ifndef ZEND_COMPILE_DELAYED_BINDING
[212]951    DISPATCH(int, oplineno)
[548]952#endif
[1]953')
954dnl }}}
[268]955#ifdef ZEND_ENGINE_2_1
956DEF_STRUCT_P_FUNC(`xc_autoglobal_t', , `dnl {{{
957    DISPATCH(zend_uint, key_len)
958#ifdef IS_UNICODE
959    DISPATCH(zend_uchar, type)
960#endif
961    IFRESTORE(`COPY(key)', `
962        PROC_ZSTRING_L(type, key, key_len)
963    ')
[506]964    DISPATCH(ulong, h)
[268]965')
966dnl }}}
967#endif
[496]968#ifdef E_STRICT
969DEF_STRUCT_P_FUNC(`xc_compilererror_t', , `dnl {{{
[648]970    DISPATCH(int, type)
[496]971    DISPATCH(uint, lineno)
972    DISPATCH(int, error_len)
973    PROC_STRING_L(error, error_len)
974')
975dnl }}}
976#endif
[1]977DEF_STRUCT_P_FUNC(`xc_entry_data_php_t', , `dnl {{{
[311]978    IFCOPY(`
979        processor->php_dst = dst;
980        processor->php_src = src;
981    ')
982
983    DISPATCH(xc_hash_value_t, hvalue)
984    /* skip */
985    DONE(next)
986    COPY(cache)
987    DISPATCH(xc_md5sum_t, md5)
988    DISPATCH(zend_ulong, refcount)
989
[1]990    DISPATCH(size_t, sourcesize)
[311]991    DISPATCH(zend_ulong, hits)
992    DISPATCH(size_t, size)
[1]993
[662]994    IFRESTORE(`COPY(op_array_info)', `
995        STRUCT(xc_op_array_info_t, op_array_info)
996    ')
997    IFRESTORE(`
998        processor->active_op_array_infos_src = &dst->op_array_info;
999        processor->active_op_array_index = 0;
1000    ')
[1]1001    STRUCT_P(zend_op_array, op_array)
1002
[95]1003#ifdef HAVE_XCACHE_CONSTANT
1004    DISPATCH(zend_uint, constinfo_cnt)
[503]1005    STRUCT_ARRAY(constinfo_cnt, xc_constinfo_t, constinfos)
[95]1006#endif
1007
[1]1008    DISPATCH(zend_uint, funcinfo_cnt)
1009    STRUCT_ARRAY(funcinfo_cnt, xc_funcinfo_t, funcinfos)
1010
1011    DISPATCH(zend_uint, classinfo_cnt)
[662]1012    STRUCT_ARRAY(classinfo_cnt, xc_classinfo_t, classinfos, , IFRESTORE(`processor->active_class_index'))
[268]1013#ifdef ZEND_ENGINE_2_1
1014    DISPATCH(zend_uint, autoglobal_cnt)
[495]1015    IFRESTORE(`
1016        COPY(autoglobals)
1017    ', `
1018        STRUCT_ARRAY(autoglobal_cnt, xc_autoglobal_t, autoglobals)
1019    ')
[268]1020#endif
[496]1021#ifdef E_STRICT
1022    DISPATCH(zend_uint, compilererror_cnt)
1023    IFRESTORE(`
1024        COPY(compilererrors)
1025    ', `
1026        STRUCT_ARRAY(compilererror_cnt, xc_compilererror_t, compilererrors)
1027    ')
1028#endif
[548]1029#ifndef ZEND_COMPILE_DELAYED_BINDING
[212]1030    DISPATCH(zend_bool, have_early_binding)
[548]1031#endif
[311]1032    DISPATCH(zend_bool, have_references)
[1]1033')
1034dnl }}}
1035DEF_STRUCT_P_FUNC(`xc_entry_data_var_t', , `dnl {{{
[230]1036    IFDPRINT(`INDENT()`'fprintf(stderr, "zval:value");')
[4]1037    STRUCT_P_EX(zval_ptr, dst->value, src->value, `value', `', `&')
[311]1038    DISPATCH(zend_bool, have_references)
[1]1039    DONE(value)
1040')
1041dnl }}}
1042dnl {{{ xc_entry_t
1043DEF_STRUCT_P_FUNC(`xc_entry_t', , `
1044    DISPATCH(xc_entry_type_t, type)
1045    DISPATCH(size_t, size)
1046
1047    DISPATCH(xc_hash_value_t, hvalue)
1048    COPY(cache)
1049    /* skip */
1050    DONE(next)
1051
1052    IFSTORE(`dst->refcount = 0; DONE(refcount)', `DISPATCH(long, refcount)')
1053
1054    DISPATCH(time_t, ctime)
1055    DISPATCH(time_t, atime)
1056    DISPATCH(time_t, dtime)
[114]1057    DISPATCH(long, ttl)
[1]1058    DISPATCH(zend_ulong, hits)
1059#ifdef IS_UNICODE
1060    DISPATCH(zend_uchar, name_type)
1061#endif
1062    dnl {{{ name
1063    DISABLECHECK(`
1064#ifdef IS_UNICODE
1065        if (src->name_type == IS_UNICODE) {
1066            DISPATCH(int32_t, name.ustr.len)
1067        }
1068        else {
1069            DISPATCH(int, name.str.len)
1070        }
1071#else
1072        DISPATCH(int, name.str.len)
1073#endif
[103]1074        IFRESTORE(`COPY(name.str.val)', `
1075#ifdef IS_UNICODE
1076            PROC_ZSTRING_L(name_type, name.uni.val, name.uni.len)
1077#else
1078            PROC_STRING_L(name.str.val, name.str.len)
1079#endif
1080        ')
[1]1081    ')
1082    DONE(name)
1083    dnl }}}
1084
1085    dnl {{{ data
1086    DISABLECHECK(`
1087        switch (src->type) {
1088        case XC_TYPE_PHP:
[662]1089            IFCALCCOPY(`COPY(data.php)', `STRUCT_P(xc_entry_data_php_t, data.php)')
[1]1090            break;
[311]1091
[1]1092        case XC_TYPE_VAR:
1093            STRUCT_P(xc_entry_data_var_t, data.var)
1094            break;
[311]1095
[1]1096        default:
1097            assert(0);
1098        }
1099    ')
1100    DONE(data)
1101    dnl }}}
[311]1102    DISPATCH(time_t, mtime)
1103#ifdef HAVE_INODE
1104    DISPATCH(int, device)
1105    DISPATCH(int, inode)
1106#endif
[684]1107
[688]1108    if (src->type == XC_TYPE_PHP) {
1109        DISPATCH(int, filepath_len)
1110        IFRESTORE(`COPY(filepath)', `PROC_STRING_L(filepath, filepath_len)')
1111        DISPATCH(int, dirpath_len)
1112        IFRESTORE(`COPY(dirpath)', `PROC_STRING_L(dirpath, dirpath_len)')
[684]1113#ifdef IS_UNICODE
[688]1114        DISPATCH(int, ufilepath_len)
1115        IFRESTORE(`COPY(ufilepath)', `PROC_USTRING_L(ufilepath, ufilepath_len)')
1116        DISPATCH(int, udirpath_len)
1117        IFRESTORE(`COPY(udirpath)', `PROC_USTRING_L(udirpath, udirpath_len)')
[684]1118#endif
[688]1119    }
1120    else {
1121        DONE(filepath_len)
1122        DONE(filepath)
1123        DONE(dirpath_len)
1124        DONE(dirpath)
1125#ifdef IS_UNICODE
1126        DONE(ufilepath_len)
1127        DONE(ufilepath)
1128        DONE(udirpath_len)
1129        DONE(udirpath)
1130#endif
1131    }
[1]1132')
1133dnl }}}
1134dnl ====================================================
Note: See TracBrowser for help on using the repository browser.