[1] | 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 | DECL_STRUCT_P_FUNC(`zend_function') |
---|
| 8 | DECL_STRUCT_P_FUNC(`xc_entry_t') |
---|
| 9 | #ifdef ZEND_ENGINE_2 |
---|
| 10 | DECL_STRUCT_P_FUNC(`zend_property_info') |
---|
| 11 | #endif |
---|
| 12 | /* }}} */ |
---|
| 13 | dnl ==================================================== |
---|
| 14 | dnl {{{ zend_compiled_variable |
---|
| 15 | #ifdef IS_CV |
---|
| 16 | DEF_STRUCT_P_FUNC(`zend_compiled_variable', , ` |
---|
| 17 | DISPATCH(int, name_len) |
---|
| 18 | PROC_USTRING_L(, name, name_len) |
---|
| 19 | DISPATCH(ulong, hash_value) |
---|
| 20 | ') |
---|
| 21 | #endif |
---|
| 22 | dnl }}} |
---|
| 23 | dnl {{{ zend_uint |
---|
| 24 | DEF_STRUCT_P_FUNC(`zend_uint', , ` |
---|
| 25 | IFCOPY(`dst[0] = src[0];') |
---|
| 26 | IFDPRINT(` |
---|
| 27 | INDENT() |
---|
| 28 | fprintf(stderr, "%u\n", src[0]); |
---|
| 29 | ') |
---|
| 30 | DONE_SIZE(sizeof(src[0])) |
---|
| 31 | ') |
---|
| 32 | dnl }}} |
---|
| 33 | dnl {{{ int |
---|
| 34 | #ifndef ZEND_ENGINE_2 |
---|
| 35 | DEF_STRUCT_P_FUNC(`int', , ` |
---|
| 36 | IFCOPY(`*dst = *src;') |
---|
| 37 | IFDPRINT(` |
---|
| 38 | INDENT() |
---|
| 39 | fprintf(stderr, "%d\n", src[0]); |
---|
| 40 | ') |
---|
| 41 | DONE_SIZE(sizeof(src[0])) |
---|
| 42 | ') |
---|
| 43 | #endif |
---|
| 44 | dnl }}} |
---|
| 45 | dnl {{{ zend_try_catch_element |
---|
| 46 | #ifdef ZEND_ENGINE_2 |
---|
| 47 | DEF_STRUCT_P_FUNC(`zend_try_catch_element', , ` |
---|
| 48 | DISPATCH(zend_uint, try_op) |
---|
| 49 | DISPATCH(zend_uint, catch_op) |
---|
| 50 | ') |
---|
| 51 | #endif /* ifdef ZEND_ENGINE_2 */ |
---|
| 52 | dnl }}} |
---|
| 53 | dnl {{{ zend_brk_cont_element |
---|
| 54 | DEF_STRUCT_P_FUNC(`zend_brk_cont_element', , ` |
---|
| 55 | DISPATCH(int, cont) |
---|
| 56 | DISPATCH(int, brk) |
---|
| 57 | DISPATCH(int, parent) |
---|
| 58 | ') |
---|
| 59 | dnl }}} |
---|
| 60 | DEF_HASH_TABLE_FUNC(`HashTable_zval_ptr', `zval_ptr') |
---|
| 61 | DEF_HASH_TABLE_FUNC(`HashTable_zend_function', `zend_function') |
---|
| 62 | #ifdef ZEND_ENGINE_2 |
---|
| 63 | DEF_HASH_TABLE_FUNC(`HashTable_zend_property_info', `zend_property_info') |
---|
| 64 | #endif |
---|
| 65 | DEF_STRUCT_P_FUNC(`zval', , `dnl {{{ |
---|
| 66 | IFDASM(`do { |
---|
| 67 | zval_dtor(dst); |
---|
| 68 | *dst = *src; |
---|
| 69 | zval_copy_ctor(dst); |
---|
| 70 | ZVAL_REFCOUNT(dst) = 1; |
---|
| 71 | DONE(value) |
---|
| 72 | DONE(refcount) |
---|
| 73 | DONE(type) |
---|
| 74 | DONE(is_ref) |
---|
| 75 | } while(0); |
---|
| 76 | return; |
---|
| 77 | ', ` |
---|
| 78 | dnl IFDASM else |
---|
| 79 | /* Variable information */ |
---|
| 80 | dnl {{{ zvalue_value |
---|
| 81 | DISABLECHECK(` |
---|
| 82 | switch (src->type & ~IS_CONSTANT_INDEX) { |
---|
| 83 | case IS_LONG: |
---|
| 84 | case IS_RESOURCE: |
---|
| 85 | case IS_BOOL: |
---|
| 86 | DISPATCH(long, value.lval) |
---|
| 87 | break; |
---|
| 88 | case IS_DOUBLE: |
---|
| 89 | DISPATCH(double, value.dval) |
---|
| 90 | break; |
---|
| 91 | case IS_NULL: |
---|
| 92 | IFDPRINT(`INDENT()`'fprintf(stderr, "\tNULL\n");') |
---|
| 93 | break; |
---|
| 94 | |
---|
| 95 | case IS_CONSTANT: |
---|
| 96 | #ifdef IS_UNICODE |
---|
| 97 | if (UG(unicode)) { |
---|
| 98 | goto proc_unicode; |
---|
| 99 | } |
---|
| 100 | #endif |
---|
| 101 | case IS_STRING: |
---|
| 102 | #ifdef FLAG_IS_BC |
---|
| 103 | case FLAG_IS_BC: |
---|
| 104 | #endif |
---|
| 105 | DISPATCH(int, value.str.len) |
---|
| 106 | PROC_STRING_L(value.str.val, value.str.len) |
---|
| 107 | break; |
---|
| 108 | #ifdef IS_UNICODE |
---|
| 109 | case IS_UNICODE: |
---|
| 110 | proc_unicode: |
---|
| 111 | DISPATCH(int32_t, value.ustr.len) |
---|
| 112 | PROC_USTRING_L(1, value.ustr.val, value.ustr.len) |
---|
| 113 | break; |
---|
| 114 | #endif |
---|
| 115 | |
---|
| 116 | case IS_ARRAY: |
---|
| 117 | case IS_CONSTANT_ARRAY: |
---|
| 118 | STRUCT_P(HashTable, value.ht, HashTable_zval_ptr) |
---|
| 119 | break; |
---|
| 120 | |
---|
| 121 | case IS_OBJECT: |
---|
| 122 | IFNOTMEMCPY(`IFCOPY(`memcpy(dst, src, sizeof(src[0]));')') |
---|
| 123 | dnl STRUCT(value.obj) |
---|
| 124 | #ifndef ZEND_ENGINE_2 |
---|
| 125 | STRUCT_P(zend_class_entry, value.obj.ce) |
---|
| 126 | STRUCT_P(HashTable, value.obj.properties, HashTable_zval_ptr) |
---|
| 127 | #endif |
---|
| 128 | break; |
---|
| 129 | |
---|
| 130 | default: |
---|
| 131 | assert(0); |
---|
| 132 | } |
---|
| 133 | ') |
---|
| 134 | dnl }}} |
---|
| 135 | DONE(value) |
---|
| 136 | DISPATCH(zval_data_type, type) |
---|
| 137 | DISPATCH(zend_uchar, is_ref) |
---|
| 138 | DISPATCH(zend_ushort, refcount) |
---|
| 139 | ')dnl IFDASM |
---|
| 140 | ') |
---|
| 141 | dnl }}} |
---|
| 142 | DEF_STRUCT_P_FUNC(`zval_ptr', , `dnl {{{ |
---|
| 143 | IFDASM(` |
---|
| 144 | pushdefFUNC_NAME(`zval') |
---|
| 145 | FUNC_NAME (dst, src[0] TSRMLS_CC); |
---|
| 146 | popdef(`FUNC_NAME') |
---|
| 147 | ', ` |
---|
| 148 | do { |
---|
| 149 | IFCALCCOPY(` |
---|
| 150 | if (processor->reference) { |
---|
| 151 | zval_ptr *ppzv; |
---|
| 152 | if (zend_hash_find(&processor->zvalptrs, (char *)src[0], sizeof(src[0]), (void**)&ppzv) == SUCCESS) { |
---|
| 153 | IFCOPY(` |
---|
| 154 | dst[0] = *ppzv; |
---|
| 155 | /* *dst is updated */ |
---|
| 156 | dnl fprintf(stderr, "*dst is set to %p\n", dst[0]); |
---|
| 157 | ') |
---|
| 158 | IFSTORE(`assert(xc_is_shm(dst[0]));') |
---|
| 159 | IFRESTORE(`assert(!xc_is_shm(dst[0]));') |
---|
| 160 | break; |
---|
| 161 | } |
---|
| 162 | } |
---|
| 163 | ') |
---|
| 164 | |
---|
| 165 | ALLOC(dst[0], zval) |
---|
| 166 | IFCALCCOPY(` |
---|
| 167 | if (processor->reference) { |
---|
| 168 | IFCALC(` |
---|
| 169 | /* make dummy */ |
---|
| 170 | zval_ptr pzv = (zval_ptr)-1; |
---|
| 171 | ', ` |
---|
| 172 | zval_ptr pzv = dst[0]; |
---|
| 173 | ') |
---|
| 174 | if (zend_hash_add(&processor->zvalptrs, (char *)src[0], sizeof(src[0]), (void*)&pzv, sizeof(pzv), NULL) == SUCCESS) { |
---|
| 175 | /* first add, go on */ |
---|
| 176 | dnl fprintf(stderr, "mark[%p] = %p\n", src[0], pzv); |
---|
| 177 | } |
---|
| 178 | else { |
---|
| 179 | assert(0); |
---|
| 180 | } |
---|
| 181 | } |
---|
| 182 | ') |
---|
| 183 | IFCOPY(` |
---|
| 184 | dnl fprintf(stderr, "copy from %p to %p\n", src[0], dst[0]); |
---|
| 185 | ') |
---|
[4] | 186 | STRUCT_P_EX(zval, dst[0], src[0], `[0]', `', ` ') |
---|
[1] | 187 | } while (0); |
---|
| 188 | ') |
---|
| 189 | DONE_SIZE(sizeof(zval_ptr)) |
---|
| 190 | ') |
---|
| 191 | dnl }}} |
---|
| 192 | dnl {{{ zend_arg_info |
---|
| 193 | #ifdef ZEND_ENGINE_2 |
---|
| 194 | DEF_STRUCT_P_FUNC(`zend_arg_info', , ` |
---|
| 195 | DISPATCH(zend_uint, name_len) |
---|
| 196 | PROC_USTRING_L(, name, name_len) |
---|
| 197 | DISPATCH(zend_uint, class_name_len) |
---|
| 198 | PROC_USTRING_L(, class_name, class_name_len) |
---|
| 199 | DISPATCH(zend_bool, array_type_hint) |
---|
| 200 | DISPATCH(zend_bool, allow_null) |
---|
| 201 | DISPATCH(zend_bool, pass_by_reference) |
---|
| 202 | DISPATCH(zend_bool, return_reference) |
---|
| 203 | DISPATCH(int, required_num_args) |
---|
| 204 | ') |
---|
| 205 | #endif |
---|
| 206 | dnl }}} |
---|
| 207 | DEF_STRUCT_P_FUNC(`zend_function', , `dnl {{{ |
---|
| 208 | DISABLECHECK(` |
---|
| 209 | switch (src->type) { |
---|
| 210 | case ZEND_INTERNAL_FUNCTION: |
---|
| 211 | case ZEND_OVERLOADED_FUNCTION: |
---|
| 212 | IFNOTMEMCPY(`IFCOPY(`memcpy(dst, src, sizeof(src[0]));')') |
---|
| 213 | break; |
---|
| 214 | |
---|
| 215 | case ZEND_USER_FUNCTION: |
---|
| 216 | case ZEND_EVAL_CODE: |
---|
| 217 | DONE(type) |
---|
| 218 | STRUCT(zend_op_array, op_array) |
---|
| 219 | break; |
---|
| 220 | |
---|
| 221 | default: |
---|
| 222 | assert(0); |
---|
| 223 | } |
---|
| 224 | ') |
---|
| 225 | DONE_SIZE(sizeof(src[0])) |
---|
| 226 | ') |
---|
| 227 | dnl }}} |
---|
| 228 | dnl {{{ zend_property_info |
---|
| 229 | #ifdef ZEND_ENGINE_2 |
---|
| 230 | DEF_STRUCT_P_FUNC(`zend_property_info', , ` |
---|
| 231 | DISPATCH(zend_uint, flags) |
---|
| 232 | DISPATCH(int, name_length) |
---|
| 233 | PROC_USTRING_L(, name, name_length) |
---|
| 234 | DISPATCH(ulong, h) |
---|
[56] | 235 | #ifdef ZEND_ENGINE_2_1 |
---|
[1] | 236 | DISPATCH(int, doc_comment_len) |
---|
| 237 | PROC_USTRING_L(, doc_comment, doc_comment_len) |
---|
[56] | 238 | #endif |
---|
[1] | 239 | ') |
---|
| 240 | #endif |
---|
| 241 | dnl }}} |
---|
| 242 | DEF_STRUCT_P_FUNC(`zend_class_entry', , `dnl {{{ |
---|
| 243 | IFCOPY(` |
---|
| 244 | processor->active_class_entry_src = src; |
---|
| 245 | processor->active_class_entry_dst = dst; |
---|
| 246 | ') |
---|
| 247 | DISPATCH(char, type) |
---|
| 248 | DISPATCH(zend_uint, name_length) |
---|
| 249 | PROC_USTRING_L(, name, name_length) |
---|
| 250 | IFRESTORE(` |
---|
| 251 | #ifndef ZEND_ENGINE_2 |
---|
| 252 | /* just copy parent and resolve on install_class */ |
---|
| 253 | COPY(parent) |
---|
| 254 | #else |
---|
| 255 | PROC_CLASS_ENTRY_P(parent) |
---|
| 256 | #endif |
---|
| 257 | ', ` |
---|
| 258 | PROC_CLASS_ENTRY_P(parent) |
---|
| 259 | ') |
---|
| 260 | #ifdef ZEND_ENGINE_2 |
---|
| 261 | DISPATCH(int, refcount) |
---|
| 262 | #else |
---|
| 263 | STRUCT_P(int, refcount) |
---|
| 264 | #endif |
---|
| 265 | DISPATCH(zend_bool, constants_updated) |
---|
| 266 | #ifdef ZEND_ENGINE_2 |
---|
| 267 | DISPATCH(zend_uint, ce_flags) |
---|
| 268 | #endif |
---|
| 269 | |
---|
| 270 | STRUCT(HashTable, default_properties, HashTable_zval_ptr) |
---|
| 271 | IFCOPY(`dst->builtin_functions = src->builtin_functions;') |
---|
| 272 | DONE(builtin_functions) |
---|
| 273 | #ifdef ZEND_ENGINE_2 |
---|
| 274 | STRUCT(HashTable, properties_info, HashTable_zend_property_info) |
---|
| 275 | # ifdef ZEND_ENGINE_2_1 |
---|
| 276 | STRUCT(HashTable, default_static_members, HashTable_zval_ptr) |
---|
| 277 | IFCOPY(`dst->static_members = &dst->default_static_members;') |
---|
| 278 | DONE(static_members) |
---|
| 279 | # else |
---|
| 280 | STRUCT_P(HashTable, static_members, HashTable_zval_ptr) |
---|
| 281 | # endif |
---|
| 282 | STRUCT(HashTable, constants_table, HashTable_zval_ptr) |
---|
| 283 | |
---|
| 284 | dnl runtime binding: ADD_INTERFACE will deal with it |
---|
| 285 | IFRESTORE(` |
---|
| 286 | if (src->num_interfaces) { |
---|
| 287 | CALLOC(dst->interfaces, zend_class_entry*, src->num_interfaces) |
---|
[4] | 288 | DONE(`interfaces') |
---|
[1] | 289 | } |
---|
| 290 | else { |
---|
[4] | 291 | COPYNULL(interfaces) |
---|
[1] | 292 | } |
---|
| 293 | ') |
---|
| 294 | IFDASM(` |
---|
| 295 | if (src->num_interfaces) { |
---|
| 296 | /* |
---|
| 297 | zval *arr; |
---|
| 298 | ALLOC_INIT_ZVAL(arr); |
---|
| 299 | array_init(arr); |
---|
| 300 | for (i = 0; i < src->num_interfaces; i ++) { |
---|
| 301 | zval *zv; |
---|
| 302 | ALLOC_INIT_ZVAL(zv); |
---|
| 303 | ZVAL_STRING(src->num_interfaces); |
---|
| 304 | } |
---|
| 305 | add_assoc_zval_ex(dst, ZEND_STRS("interfaces"), arr); |
---|
| 306 | */ |
---|
[4] | 307 | DONE(`interfaces') |
---|
[1] | 308 | } |
---|
| 309 | else { |
---|
[4] | 310 | COPYNULL(interfaces) |
---|
[1] | 311 | } |
---|
| 312 | ') |
---|
[4] | 313 | IFRESTORE(`', ` |
---|
| 314 | IFDASM(`', ` |
---|
| 315 | DONE(`interfaces') |
---|
| 316 | ') |
---|
| 317 | ') |
---|
[1] | 318 | DISPATCH(zend_uint, num_interfaces) |
---|
| 319 | |
---|
| 320 | IFRESTORE(`COPY(filename)', `PROC_STRING(filename)') |
---|
| 321 | DISPATCH(zend_uint, line_start) |
---|
| 322 | DISPATCH(zend_uint, line_end) |
---|
| 323 | #ifdef ZEND_ENGINE_2_1 |
---|
| 324 | DISPATCH(zend_uint, doc_comment_len) |
---|
| 325 | PROC_USTRING_L(, doc_comment, doc_comment_len) |
---|
| 326 | #endif |
---|
| 327 | /* # NOT DONE */ |
---|
| 328 | COPY(serialize_func) |
---|
| 329 | COPY(unserialize_func) |
---|
| 330 | COPY(iterator_funcs) |
---|
| 331 | COPY(create_object) |
---|
| 332 | COPY(get_iterator) |
---|
| 333 | COPY(interface_gets_implemented) |
---|
| 334 | COPY(serialize) |
---|
| 335 | COPY(unserialize) |
---|
| 336 | /* deal with it inside xc_fix_method */ |
---|
| 337 | SETNULL(constructor) |
---|
| 338 | COPY(destructor) |
---|
| 339 | COPY(clone) |
---|
| 340 | COPY(__get) |
---|
| 341 | COPY(__set) |
---|
| 342 | /* should be >5.1 */ |
---|
| 343 | #ifdef ZEND_ENGINE_2_1 |
---|
| 344 | COPY(__unset) |
---|
| 345 | COPY(__isset) |
---|
| 346 | # if PHP_MAJOR_VERSION >= 6 |
---|
| 347 | COPY(__tostring) |
---|
| 348 | # endif |
---|
| 349 | #endif |
---|
| 350 | COPY(__call) |
---|
| 351 | #ifdef IS_UNICODE |
---|
| 352 | SETNULL(u_twin) |
---|
| 353 | #endif |
---|
| 354 | /* # NOT DONE */ |
---|
| 355 | COPY(module) |
---|
| 356 | #else |
---|
| 357 | COPY(handle_function_call) |
---|
| 358 | COPY(handle_property_get) |
---|
| 359 | COPY(handle_property_set) |
---|
| 360 | #endif |
---|
| 361 | dnl must after SETNULL(constructor) |
---|
| 362 | STRUCT(HashTable, function_table, HashTable_zend_function) |
---|
| 363 | IFRESTORE(`dst->function_table.pDestructor = (dtor_func_t) destroy_zend_function;') |
---|
| 364 | ') |
---|
| 365 | dnl }}} |
---|
| 366 | DEF_STRUCT_P_FUNC(`znode', , `dnl {{{ |
---|
| 367 | DISPATCH(int, op_type) |
---|
| 368 | |
---|
| 369 | #ifdef IS_CV |
---|
[11] | 370 | # define XCACHE_IS_CV IS_CV |
---|
[1] | 371 | #else |
---|
[11] | 372 | /* compatible with zend optimizer */ |
---|
| 373 | # define XCACHE_IS_CV 16 |
---|
[1] | 374 | #endif |
---|
[11] | 375 | assert(src->op_type == IS_CONST || |
---|
| 376 | src->op_type == IS_VAR || |
---|
| 377 | src->op_type == XCACHE_IS_CV || |
---|
[1] | 378 | src->op_type == IS_TMP_VAR || |
---|
| 379 | src->op_type == IS_UNUSED); |
---|
[11] | 380 | #undef XCACHE_IS_CV |
---|
[1] | 381 | dnl dirty dispatch |
---|
| 382 | DISABLECHECK(` |
---|
| 383 | switch (src->op_type) { |
---|
| 384 | case IS_CONST: |
---|
| 385 | STRUCT(zval, u.constant) |
---|
| 386 | break; |
---|
| 387 | IFCOPY(` |
---|
| 388 | IFNOTMEMCPY(` |
---|
| 389 | default: |
---|
| 390 | memcpy(&dst->u, &src->u, sizeof(src->u)); |
---|
| 391 | ') |
---|
| 392 | ', ` |
---|
| 393 | case IS_VAR: |
---|
| 394 | case IS_TMP_VAR: |
---|
| 395 | #ifdef IS_CV |
---|
| 396 | case IS_CV: |
---|
| 397 | #else |
---|
| 398 | case 16: |
---|
| 399 | #endif |
---|
| 400 | DISPATCH(zend_uint, u.var) |
---|
| 401 | DISPATCH(zend_uint, u.EA.type) |
---|
| 402 | break; |
---|
| 403 | case IS_UNUSED: |
---|
| 404 | IFDASM(`DISPATCH(zend_uint, u.var)') |
---|
| 405 | DISPATCH(zend_uint, u.opline_num) |
---|
| 406 | #ifndef ZEND_ENGINE_2 |
---|
| 407 | DISPATCH(zend_uint, u.fetch_type) |
---|
| 408 | #endif |
---|
| 409 | DISPATCH(zend_uint, u.EA.type) |
---|
| 410 | break; |
---|
| 411 | ') |
---|
| 412 | } |
---|
| 413 | ') |
---|
| 414 | DONE(u) |
---|
| 415 | ') |
---|
| 416 | dnl }}} |
---|
| 417 | DEF_STRUCT_P_FUNC(`zend_op', , `dnl {{{ |
---|
| 418 | DISPATCH(zend_uchar, opcode) |
---|
| 419 | STRUCT(znode, result) |
---|
| 420 | STRUCT(znode, op1) |
---|
| 421 | STRUCT(znode, op2) |
---|
| 422 | DISPATCH(ulong, extended_value) |
---|
| 423 | DISPATCH(uint, lineno) |
---|
| 424 | #ifdef ZEND_ENGINE_2_1 |
---|
| 425 | IFCOPY(` |
---|
| 426 | switch (src->opcode) { |
---|
| 427 | case ZEND_JMP: |
---|
| 428 | dst->op1.u.jmp_addr = processor->active_opcodes_dst + (src->op1.u.jmp_addr - processor->active_opcodes_src); |
---|
| 429 | break; |
---|
| 430 | |
---|
| 431 | case ZEND_JMPZ: |
---|
| 432 | case ZEND_JMPNZ: |
---|
| 433 | case ZEND_JMPZ_EX: |
---|
| 434 | case ZEND_JMPNZ_EX: |
---|
| 435 | dst->op2.u.jmp_addr = processor->active_opcodes_dst + (src->op2.u.jmp_addr - processor->active_opcodes_src); |
---|
| 436 | break; |
---|
| 437 | |
---|
| 438 | default: |
---|
| 439 | break; |
---|
| 440 | } |
---|
| 441 | ') |
---|
| 442 | DISPATCH(opcode_handler_t, handler) |
---|
| 443 | #endif |
---|
| 444 | ') |
---|
| 445 | dnl }}} |
---|
| 446 | DEF_STRUCT_P_FUNC(`zend_op_array', , `dnl {{{ |
---|
| 447 | IFRESTORE(` |
---|
| 448 | if (!processor->readonly_protection) { |
---|
| 449 | /* really fast shallow copy */ |
---|
| 450 | memcpy(dst, src, sizeof(src[0])); |
---|
| 451 | dst->refcount[0] = 1000; |
---|
| 452 | /* deep */ |
---|
| 453 | STRUCT_P(HashTable, static_variables, HashTable_zval_ptr) |
---|
| 454 | define(`SKIPASSERT_ONCE') |
---|
| 455 | |
---|
| 456 | IFRESTORE(` |
---|
| 457 | #ifdef ZEND_ENGINE_2 |
---|
| 458 | if (dst->scope) { |
---|
| 459 | dst->scope = xc_get_class(processor, (int) dst->scope); |
---|
| 460 | xc_fix_method(processor, dst); |
---|
| 461 | } |
---|
| 462 | #endif |
---|
| 463 | ') |
---|
| 464 | |
---|
| 465 | } |
---|
| 466 | else |
---|
| 467 | ') |
---|
| 468 | do { |
---|
| 469 | dnl RESTORE is done above! |
---|
[11] | 470 | zend_uint ii; |
---|
[1] | 471 | int i; |
---|
| 472 | |
---|
| 473 | /* Common elements */ |
---|
| 474 | DISPATCH(zend_uchar, type) |
---|
| 475 | PROC_USTRING(, function_name) |
---|
| 476 | #ifdef ZEND_ENGINE_2 |
---|
| 477 | IFRESTORE(` |
---|
| 478 | if (dst->scope) { |
---|
| 479 | dst->scope = xc_get_class(processor, (int) dst->scope); |
---|
| 480 | xc_fix_method(processor, dst); |
---|
| 481 | } |
---|
| 482 | DONE(scope) |
---|
| 483 | ', ` |
---|
| 484 | PROC_CLASS_ENTRY_P(scope) |
---|
| 485 | ') |
---|
| 486 | DISPATCH(zend_uint, fn_flags) |
---|
| 487 | /* useless */ |
---|
| 488 | COPY(prototype) |
---|
[11] | 489 | STRUCT_ARRAY_I(num_args, zend_arg_info, arg_info) |
---|
[1] | 490 | DISPATCH(zend_uint, num_args) |
---|
| 491 | DISPATCH(zend_uint, required_num_args) |
---|
| 492 | DISPATCH(zend_bool, pass_rest_by_reference) |
---|
| 493 | #else |
---|
| 494 | if (src->arg_types) { |
---|
| 495 | ALLOC(dst->arg_types, zend_uchar, src->arg_types[0] + 1) |
---|
| 496 | IFCOPY(`memcpy(dst->arg_types, src->arg_types, sizeof(src->arg_types[0]) * (src->arg_types[0]+1));') |
---|
| 497 | IFDASM(`do { |
---|
[11] | 498 | zend_uint ii; |
---|
[1] | 499 | int i; |
---|
| 500 | zval *zv; |
---|
| 501 | ALLOC_INIT_ZVAL(zv); |
---|
| 502 | array_init(zv); |
---|
| 503 | for (i = 0; i < src->arg_types[0]; i ++) { |
---|
| 504 | add_next_index_long(zv, src->arg_types[i + 1]); |
---|
| 505 | } |
---|
| 506 | add_assoc_zval_ex(dst, ZEND_STRS("arg_types"), zv); |
---|
| 507 | } while (0);') |
---|
| 508 | DONE(arg_types) |
---|
| 509 | } |
---|
| 510 | else { |
---|
| 511 | IFDASM(`do { |
---|
| 512 | /* empty array */ |
---|
| 513 | zval *zv; |
---|
| 514 | ALLOC_INIT_ZVAL(zv); |
---|
| 515 | array_init(zv); |
---|
| 516 | add_assoc_zval_ex(dst, ZEND_STRS("arg_types"), zv); |
---|
| 517 | } while (0); |
---|
| 518 | DONE(arg_types) |
---|
| 519 | ', ` |
---|
| 520 | COPYNULL(arg_types) |
---|
| 521 | ') |
---|
| 522 | } |
---|
| 523 | #endif |
---|
| 524 | DISPATCH(unsigned char, return_reference) |
---|
| 525 | /* END of common elements */ |
---|
| 526 | #ifdef IS_UNICODE |
---|
| 527 | SETNULL(u_twin) |
---|
| 528 | #endif |
---|
| 529 | |
---|
| 530 | STRUCT_P(zend_uint, refcount) |
---|
| 531 | UNFIXPOINTER(zend_uint, refcount) |
---|
| 532 | |
---|
| 533 | pushdef(`AFTER_ALLOC', `IFCOPY(` |
---|
| 534 | processor->active_opcodes_dst = dst->opcodes; |
---|
| 535 | processor->active_opcodes_src = src->opcodes; |
---|
| 536 | ')') |
---|
[11] | 537 | STRUCT_ARRAY_I(last, zend_op, opcodes) |
---|
[1] | 538 | popdef(`AFTER_ALLOC') |
---|
| 539 | DISPATCH(zend_uint, last) |
---|
| 540 | IFCOPY(`dst->size = src->last;DONE(size)', `DISPATCH(zend_uint, size)') |
---|
| 541 | |
---|
| 542 | #ifdef IS_CV |
---|
| 543 | STRUCT_ARRAY(last_var, zend_compiled_variable, vars) |
---|
| 544 | DISPATCH(int, last_var) |
---|
| 545 | IFCOPY(`dst->size_var = src->last_var;DONE(size_var)', `DISPATCH(zend_uint, size_var)') |
---|
| 546 | #else |
---|
| 547 | dnl zend_cv.m4 is illegal to be made public, don not ask me for it |
---|
| 548 | IFDASM(` |
---|
[4] | 549 | sinclude(srcdir`/processor/zend_cv.m4') |
---|
[1] | 550 | ') |
---|
| 551 | #endif |
---|
| 552 | |
---|
| 553 | DISPATCH(zend_uint, T) |
---|
| 554 | |
---|
[11] | 555 | STRUCT_ARRAY_I(last_brk_cont, zend_brk_cont_element, brk_cont_array) |
---|
[1] | 556 | DISPATCH(zend_uint, last_brk_cont) |
---|
| 557 | DISPATCH(zend_uint, current_brk_cont) |
---|
| 558 | #ifndef ZEND_ENGINE_2 |
---|
| 559 | DISPATCH(zend_bool, uses_globals) |
---|
| 560 | #endif |
---|
| 561 | |
---|
| 562 | #ifdef ZEND_ENGINE_2 |
---|
| 563 | STRUCT_ARRAY(last_try_catch, zend_try_catch_element, try_catch_array) |
---|
| 564 | DISPATCH(int, last_try_catch) |
---|
| 565 | #endif |
---|
| 566 | |
---|
| 567 | STRUCT_P(HashTable, static_variables, HashTable_zval_ptr) |
---|
| 568 | |
---|
| 569 | IFCOPY(`dst->start_op = src->start_op;') |
---|
| 570 | DONE(start_op) |
---|
| 571 | DISPATCH(int, backpatch_count) |
---|
| 572 | |
---|
| 573 | DISPATCH(zend_bool, done_pass_two) |
---|
| 574 | #ifdef ZEND_ENGINE_2 |
---|
| 575 | DISPATCH(zend_bool, uses_this) |
---|
| 576 | #endif |
---|
| 577 | |
---|
| 578 | IFRESTORE(`COPY(filename)', `PROC_STRING(filename)') |
---|
| 579 | #ifdef IS_UNICODE |
---|
| 580 | PROC_STRING(script_encoding) |
---|
| 581 | #endif |
---|
| 582 | #ifdef ZEND_ENGINE_2 |
---|
| 583 | DISPATCH(zend_uint, line_start) |
---|
| 584 | DISPATCH(zend_uint, line_end) |
---|
| 585 | DISPATCH(int, doc_comment_len) |
---|
| 586 | PROC_USTRING_L(, doc_comment, doc_comment_len) |
---|
| 587 | #endif |
---|
| 588 | |
---|
| 589 | /* reserved */ |
---|
| 590 | DONE(reserved) |
---|
| 591 | #if defined(HARDENING_PATCH) && HARDENING_PATCH |
---|
| 592 | DISPATCH(zend_bool, created_by_eval) |
---|
| 593 | #endif |
---|
| 594 | } while (0); |
---|
| 595 | ') |
---|
| 596 | dnl }}} |
---|
| 597 | |
---|
| 598 | DEF_STRUCT_P_FUNC(`xc_funcinfo_t', , `dnl {{{ |
---|
| 599 | DISPATCH(zend_uint, key_size) |
---|
| 600 | #ifdef IS_UNICODE |
---|
| 601 | DISPATCH(zend_uchar, type) |
---|
| 602 | #endif |
---|
| 603 | IFRESTORE(`COPY(key)', ` |
---|
| 604 | PROC_USTRING_N(type, key, key_size) |
---|
| 605 | ') |
---|
| 606 | STRUCT(zend_function, func) |
---|
| 607 | ') |
---|
| 608 | dnl }}} |
---|
| 609 | DEF_STRUCT_P_FUNC(`xc_classinfo_t', , `dnl {{{ |
---|
| 610 | DISPATCH(zend_uint, key_size) |
---|
| 611 | #ifdef IS_UNICODE |
---|
| 612 | DISPATCH(zend_uchar, type) |
---|
| 613 | #endif |
---|
| 614 | IFRESTORE(`COPY(key)', ` |
---|
| 615 | PROC_USTRING_N(type, key, key_size) |
---|
| 616 | ') |
---|
| 617 | #ifdef ZEND_ENGINE_2 |
---|
| 618 | STRUCT_P(zend_class_entry, cest) |
---|
| 619 | #else |
---|
| 620 | STRUCT(zend_class_entry, cest) |
---|
| 621 | #endif |
---|
| 622 | ') |
---|
| 623 | dnl }}} |
---|
| 624 | DEF_STRUCT_P_FUNC(`xc_entry_data_php_t', , `dnl {{{ |
---|
| 625 | zend_uint i; |
---|
| 626 | |
---|
| 627 | #ifdef HAVE_INODE |
---|
| 628 | DISPATCH(int, device) |
---|
| 629 | DISPATCH(int, inode) |
---|
| 630 | #endif |
---|
| 631 | DISPATCH(size_t, sourcesize) |
---|
| 632 | |
---|
| 633 | DISPATCH(time_t, mtime) |
---|
| 634 | |
---|
| 635 | STRUCT_P(zend_op_array, op_array) |
---|
| 636 | |
---|
| 637 | DISPATCH(zend_uint, funcinfo_cnt) |
---|
| 638 | STRUCT_ARRAY(funcinfo_cnt, xc_funcinfo_t, funcinfos) |
---|
| 639 | |
---|
| 640 | DISPATCH(zend_uint, classinfo_cnt) |
---|
| 641 | pushdef(`BEFORE_LOOP', ` |
---|
| 642 | IFCOPY(` |
---|
| 643 | processor->active_class_num = i + 1; |
---|
| 644 | ') |
---|
| 645 | ') |
---|
| 646 | STRUCT_ARRAY(classinfo_cnt, xc_classinfo_t, classinfos) |
---|
| 647 | popdef(`BEFORE_LOOP') |
---|
| 648 | ') |
---|
| 649 | dnl }}} |
---|
| 650 | DEF_STRUCT_P_FUNC(`xc_entry_data_var_t', , `dnl {{{ |
---|
| 651 | DISPATCH(time_t, etime) |
---|
| 652 | IFSTORE(` |
---|
| 653 | if (processor->reference) { |
---|
| 654 | if (zend_hash_add(&processor->zvalptrs, (char *)&src->value, sizeof(&src->value), (void*)&src->value, sizeof(src->value), NULL) == SUCCESS) { |
---|
| 655 | dnl fprintf(stderr, "mark[%p] = %p\n", &src->value, &dst->value); |
---|
| 656 | } |
---|
| 657 | else { |
---|
| 658 | assert(0); |
---|
| 659 | } |
---|
| 660 | } |
---|
| 661 | ') |
---|
[4] | 662 | STRUCT_P_EX(zval_ptr, dst->value, src->value, `value', `', `&') |
---|
[1] | 663 | DONE(value) |
---|
| 664 | ') |
---|
| 665 | dnl }}} |
---|
| 666 | dnl {{{ xc_entry_t |
---|
| 667 | DEF_STRUCT_P_FUNC(`xc_entry_t', , ` |
---|
| 668 | IFCOPY(` |
---|
| 669 | processor->xce_dst = dst; |
---|
| 670 | processor->xce_src = src; |
---|
| 671 | ') |
---|
| 672 | DISPATCH(xc_entry_type_t, type) |
---|
| 673 | DISPATCH(size_t, size) |
---|
| 674 | |
---|
| 675 | DISPATCH(xc_hash_value_t, hvalue) |
---|
| 676 | COPY(cache) |
---|
| 677 | /* skip */ |
---|
| 678 | DONE(next) |
---|
| 679 | |
---|
| 680 | IFSTORE(`dst->refcount = 0; DONE(refcount)', `DISPATCH(long, refcount)') |
---|
| 681 | |
---|
| 682 | DISPATCH(time_t, ctime) |
---|
| 683 | DISPATCH(time_t, atime) |
---|
| 684 | DISPATCH(time_t, dtime) |
---|
| 685 | DISPATCH(zend_ulong, hits) |
---|
| 686 | #ifdef IS_UNICODE |
---|
| 687 | DISPATCH(zend_uchar, name_type) |
---|
| 688 | #endif |
---|
| 689 | dnl {{{ name |
---|
| 690 | DISABLECHECK(` |
---|
| 691 | #ifdef IS_UNICODE |
---|
| 692 | if (src->name_type == IS_UNICODE) { |
---|
| 693 | DISPATCH(int32_t, name.ustr.len) |
---|
| 694 | } |
---|
| 695 | else { |
---|
| 696 | DISPATCH(int, name.str.len) |
---|
| 697 | } |
---|
| 698 | #else |
---|
| 699 | DISPATCH(int, name.str.len) |
---|
| 700 | #endif |
---|
| 701 | IFRESTORE(`COPY(name.str.val)', `PROC_USTRING_L(name_type, name.str.val, name.str.len)') |
---|
| 702 | ') |
---|
| 703 | DONE(name) |
---|
| 704 | dnl }}} |
---|
| 705 | |
---|
| 706 | dnl {{{ data |
---|
| 707 | DISABLECHECK(` |
---|
| 708 | switch (src->type) { |
---|
| 709 | case XC_TYPE_PHP: |
---|
| 710 | STRUCT_P(xc_entry_data_php_t, data.php) |
---|
| 711 | break; |
---|
| 712 | case XC_TYPE_VAR: |
---|
| 713 | STRUCT_P(xc_entry_data_var_t, data.var) |
---|
| 714 | break; |
---|
| 715 | default: |
---|
| 716 | assert(0); |
---|
| 717 | } |
---|
| 718 | ') |
---|
| 719 | DONE(data) |
---|
| 720 | dnl }}} |
---|
| 721 | ') |
---|
| 722 | dnl }}} |
---|
| 723 | dnl ==================================================== |
---|