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