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