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