| 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 | ') |
|---|
| 186 | STRUCT_P_EX(zval, dst[0], src[0], `', ` ') |
|---|
| 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) |
|---|
| 235 | DISPATCH(int, doc_comment_len) |
|---|
| 236 | PROC_USTRING_L(, doc_comment, doc_comment_len) |
|---|
| 237 | ') |
|---|
| 238 | #endif |
|---|
| 239 | dnl }}} |
|---|
| 240 | DEF_STRUCT_P_FUNC(`zend_class_entry', , `dnl {{{ |
|---|
| 241 | IFCOPY(` |
|---|
| 242 | processor->active_class_entry_src = src; |
|---|
| 243 | processor->active_class_entry_dst = dst; |
|---|
| 244 | ') |
|---|
| 245 | DISPATCH(char, type) |
|---|
| 246 | DISPATCH(zend_uint, name_length) |
|---|
| 247 | PROC_USTRING_L(, name, name_length) |
|---|
| 248 | IFRESTORE(` |
|---|
| 249 | #ifndef ZEND_ENGINE_2 |
|---|
| 250 | /* just copy parent and resolve on install_class */ |
|---|
| 251 | COPY(parent) |
|---|
| 252 | #else |
|---|
| 253 | PROC_CLASS_ENTRY_P(parent) |
|---|
| 254 | #endif |
|---|
| 255 | ', ` |
|---|
| 256 | PROC_CLASS_ENTRY_P(parent) |
|---|
| 257 | ') |
|---|
| 258 | #ifdef ZEND_ENGINE_2 |
|---|
| 259 | DISPATCH(int, refcount) |
|---|
| 260 | #else |
|---|
| 261 | STRUCT_P(int, refcount) |
|---|
| 262 | #endif |
|---|
| 263 | DISPATCH(zend_bool, constants_updated) |
|---|
| 264 | #ifdef ZEND_ENGINE_2 |
|---|
| 265 | DISPATCH(zend_uint, ce_flags) |
|---|
| 266 | #endif |
|---|
| 267 | |
|---|
| 268 | STRUCT(HashTable, default_properties, HashTable_zval_ptr) |
|---|
| 269 | IFCOPY(`dst->builtin_functions = src->builtin_functions;') |
|---|
| 270 | DONE(builtin_functions) |
|---|
| 271 | #ifdef ZEND_ENGINE_2 |
|---|
| 272 | STRUCT(HashTable, properties_info, HashTable_zend_property_info) |
|---|
| 273 | # ifdef ZEND_ENGINE_2_1 |
|---|
| 274 | STRUCT(HashTable, default_static_members, HashTable_zval_ptr) |
|---|
| 275 | IFCOPY(`dst->static_members = &dst->default_static_members;') |
|---|
| 276 | DONE(static_members) |
|---|
| 277 | # else |
|---|
| 278 | STRUCT_P(HashTable, static_members, HashTable_zval_ptr) |
|---|
| 279 | # endif |
|---|
| 280 | STRUCT(HashTable, constants_table, HashTable_zval_ptr) |
|---|
| 281 | |
|---|
| 282 | dnl runtime binding: ADD_INTERFACE will deal with it |
|---|
| 283 | IFRESTORE(` |
|---|
| 284 | if (src->num_interfaces) { |
|---|
| 285 | CALLOC(dst->interfaces, zend_class_entry*, src->num_interfaces) |
|---|
| 286 | } |
|---|
| 287 | else { |
|---|
| 288 | COPYNULL_EX(dst->interfaces) |
|---|
| 289 | } |
|---|
| 290 | ') |
|---|
| 291 | IFDASM(` |
|---|
| 292 | if (src->num_interfaces) { |
|---|
| 293 | /* |
|---|
| 294 | zval *arr; |
|---|
| 295 | ALLOC_INIT_ZVAL(arr); |
|---|
| 296 | array_init(arr); |
|---|
| 297 | for (i = 0; i < src->num_interfaces; i ++) { |
|---|
| 298 | zval *zv; |
|---|
| 299 | ALLOC_INIT_ZVAL(zv); |
|---|
| 300 | ZVAL_STRING(src->num_interfaces); |
|---|
| 301 | } |
|---|
| 302 | add_assoc_zval_ex(dst, ZEND_STRS("interfaces"), arr); |
|---|
| 303 | */ |
|---|
| 304 | } |
|---|
| 305 | else { |
|---|
| 306 | COPYNULL_EX(dst->interfaces) |
|---|
| 307 | } |
|---|
| 308 | ') |
|---|
| 309 | DONE(`interfaces') |
|---|
| 310 | DISPATCH(zend_uint, num_interfaces) |
|---|
| 311 | |
|---|
| 312 | IFRESTORE(`COPY(filename)', `PROC_STRING(filename)') |
|---|
| 313 | DISPATCH(zend_uint, line_start) |
|---|
| 314 | DISPATCH(zend_uint, line_end) |
|---|
| 315 | #ifdef ZEND_ENGINE_2_1 |
|---|
| 316 | DISPATCH(zend_uint, doc_comment_len) |
|---|
| 317 | PROC_USTRING_L(, doc_comment, doc_comment_len) |
|---|
| 318 | #endif |
|---|
| 319 | /* # NOT DONE */ |
|---|
| 320 | COPY(serialize_func) |
|---|
| 321 | COPY(unserialize_func) |
|---|
| 322 | COPY(iterator_funcs) |
|---|
| 323 | COPY(create_object) |
|---|
| 324 | COPY(get_iterator) |
|---|
| 325 | COPY(interface_gets_implemented) |
|---|
| 326 | COPY(serialize) |
|---|
| 327 | COPY(unserialize) |
|---|
| 328 | /* deal with it inside xc_fix_method */ |
|---|
| 329 | SETNULL(constructor) |
|---|
| 330 | COPY(destructor) |
|---|
| 331 | COPY(clone) |
|---|
| 332 | COPY(__get) |
|---|
| 333 | COPY(__set) |
|---|
| 334 | /* should be >5.1 */ |
|---|
| 335 | #ifdef ZEND_ENGINE_2_1 |
|---|
| 336 | COPY(__unset) |
|---|
| 337 | COPY(__isset) |
|---|
| 338 | # if PHP_MAJOR_VERSION >= 6 |
|---|
| 339 | COPY(__tostring) |
|---|
| 340 | # endif |
|---|
| 341 | #endif |
|---|
| 342 | COPY(__call) |
|---|
| 343 | #ifdef IS_UNICODE |
|---|
| 344 | SETNULL(u_twin) |
|---|
| 345 | #endif |
|---|
| 346 | /* # NOT DONE */ |
|---|
| 347 | COPY(module) |
|---|
| 348 | #else |
|---|
| 349 | COPY(handle_function_call) |
|---|
| 350 | COPY(handle_property_get) |
|---|
| 351 | COPY(handle_property_set) |
|---|
| 352 | #endif |
|---|
| 353 | dnl must after SETNULL(constructor) |
|---|
| 354 | STRUCT(HashTable, function_table, HashTable_zend_function) |
|---|
| 355 | IFRESTORE(`dst->function_table.pDestructor = (dtor_func_t) destroy_zend_function;') |
|---|
| 356 | ') |
|---|
| 357 | dnl }}} |
|---|
| 358 | DEF_STRUCT_P_FUNC(`znode', , `dnl {{{ |
|---|
| 359 | DISPATCH(int, op_type) |
|---|
| 360 | |
|---|
| 361 | assert(src->op_type == IS_CONST || |
|---|
| 362 | src->op_type == IS_VAR || |
|---|
| 363 | #ifdef IS_CV |
|---|
| 364 | src->op_type == IS_CV || |
|---|
| 365 | #else |
|---|
| 366 | src->op_type == 16 || /* zend optimizer */ |
|---|
| 367 | #endif |
|---|
| 368 | src->op_type == IS_TMP_VAR || |
|---|
| 369 | src->op_type == IS_UNUSED); |
|---|
| 370 | dnl dirty dispatch |
|---|
| 371 | DISABLECHECK(` |
|---|
| 372 | switch (src->op_type) { |
|---|
| 373 | case IS_CONST: |
|---|
| 374 | STRUCT(zval, u.constant) |
|---|
| 375 | break; |
|---|
| 376 | IFCOPY(` |
|---|
| 377 | IFNOTMEMCPY(` |
|---|
| 378 | default: |
|---|
| 379 | memcpy(&dst->u, &src->u, sizeof(src->u)); |
|---|
| 380 | ') |
|---|
| 381 | ', ` |
|---|
| 382 | case IS_VAR: |
|---|
| 383 | case IS_TMP_VAR: |
|---|
| 384 | #ifdef IS_CV |
|---|
| 385 | case IS_CV: |
|---|
| 386 | #else |
|---|
| 387 | case 16: |
|---|
| 388 | #endif |
|---|
| 389 | DISPATCH(zend_uint, u.var) |
|---|
| 390 | DISPATCH(zend_uint, u.EA.type) |
|---|
| 391 | break; |
|---|
| 392 | case IS_UNUSED: |
|---|
| 393 | IFDASM(`DISPATCH(zend_uint, u.var)') |
|---|
| 394 | DISPATCH(zend_uint, u.opline_num) |
|---|
| 395 | #ifndef ZEND_ENGINE_2 |
|---|
| 396 | DISPATCH(zend_uint, u.fetch_type) |
|---|
| 397 | #endif |
|---|
| 398 | DISPATCH(zend_uint, u.EA.type) |
|---|
| 399 | break; |
|---|
| 400 | ') |
|---|
| 401 | } |
|---|
| 402 | ') |
|---|
| 403 | DONE(u) |
|---|
| 404 | ') |
|---|
| 405 | dnl }}} |
|---|
| 406 | DEF_STRUCT_P_FUNC(`zend_op', , `dnl {{{ |
|---|
| 407 | DISPATCH(zend_uchar, opcode) |
|---|
| 408 | STRUCT(znode, result) |
|---|
| 409 | STRUCT(znode, op1) |
|---|
| 410 | STRUCT(znode, op2) |
|---|
| 411 | DISPATCH(ulong, extended_value) |
|---|
| 412 | DISPATCH(uint, lineno) |
|---|
| 413 | #ifdef ZEND_ENGINE_2_1 |
|---|
| 414 | IFCOPY(` |
|---|
| 415 | switch (src->opcode) { |
|---|
| 416 | case ZEND_JMP: |
|---|
| 417 | dst->op1.u.jmp_addr = processor->active_opcodes_dst + (src->op1.u.jmp_addr - processor->active_opcodes_src); |
|---|
| 418 | break; |
|---|
| 419 | |
|---|
| 420 | case ZEND_JMPZ: |
|---|
| 421 | case ZEND_JMPNZ: |
|---|
| 422 | case ZEND_JMPZ_EX: |
|---|
| 423 | case ZEND_JMPNZ_EX: |
|---|
| 424 | dst->op2.u.jmp_addr = processor->active_opcodes_dst + (src->op2.u.jmp_addr - processor->active_opcodes_src); |
|---|
| 425 | break; |
|---|
| 426 | |
|---|
| 427 | default: |
|---|
| 428 | break; |
|---|
| 429 | } |
|---|
| 430 | ') |
|---|
| 431 | DISPATCH(opcode_handler_t, handler) |
|---|
| 432 | #endif |
|---|
| 433 | ') |
|---|
| 434 | dnl }}} |
|---|
| 435 | DEF_STRUCT_P_FUNC(`zend_op_array', , `dnl {{{ |
|---|
| 436 | IFRESTORE(` |
|---|
| 437 | if (!processor->readonly_protection) { |
|---|
| 438 | /* really fast shallow copy */ |
|---|
| 439 | memcpy(dst, src, sizeof(src[0])); |
|---|
| 440 | dst->refcount[0] = 1000; |
|---|
| 441 | /* deep */ |
|---|
| 442 | STRUCT_P(HashTable, static_variables, HashTable_zval_ptr) |
|---|
| 443 | define(`SKIPASSERT_ONCE') |
|---|
| 444 | |
|---|
| 445 | IFRESTORE(` |
|---|
| 446 | #ifdef ZEND_ENGINE_2 |
|---|
| 447 | if (dst->scope) { |
|---|
| 448 | dst->scope = xc_get_class(processor, (int) dst->scope); |
|---|
| 449 | xc_fix_method(processor, dst); |
|---|
| 450 | } |
|---|
| 451 | #endif |
|---|
| 452 | ') |
|---|
| 453 | |
|---|
| 454 | } |
|---|
| 455 | else |
|---|
| 456 | ') |
|---|
| 457 | do { |
|---|
| 458 | dnl RESTORE is done above! |
|---|
| 459 | int i; |
|---|
| 460 | |
|---|
| 461 | /* Common elements */ |
|---|
| 462 | DISPATCH(zend_uchar, type) |
|---|
| 463 | PROC_USTRING(, function_name) |
|---|
| 464 | #ifdef ZEND_ENGINE_2 |
|---|
| 465 | IFRESTORE(` |
|---|
| 466 | if (dst->scope) { |
|---|
| 467 | dst->scope = xc_get_class(processor, (int) dst->scope); |
|---|
| 468 | xc_fix_method(processor, dst); |
|---|
| 469 | } |
|---|
| 470 | DONE(scope) |
|---|
| 471 | ', ` |
|---|
| 472 | PROC_CLASS_ENTRY_P(scope) |
|---|
| 473 | ') |
|---|
| 474 | DISPATCH(zend_uint, fn_flags) |
|---|
| 475 | /* useless */ |
|---|
| 476 | COPY(prototype) |
|---|
| 477 | STRUCT_ARRAY(num_args, zend_arg_info, arg_info) |
|---|
| 478 | DISPATCH(zend_uint, num_args) |
|---|
| 479 | DISPATCH(zend_uint, required_num_args) |
|---|
| 480 | DISPATCH(zend_bool, pass_rest_by_reference) |
|---|
| 481 | #else |
|---|
| 482 | if (src->arg_types) { |
|---|
| 483 | ALLOC(dst->arg_types, zend_uchar, src->arg_types[0] + 1) |
|---|
| 484 | IFCOPY(`memcpy(dst->arg_types, src->arg_types, sizeof(src->arg_types[0]) * (src->arg_types[0]+1));') |
|---|
| 485 | IFDASM(`do { |
|---|
| 486 | int i; |
|---|
| 487 | zval *zv; |
|---|
| 488 | ALLOC_INIT_ZVAL(zv); |
|---|
| 489 | array_init(zv); |
|---|
| 490 | for (i = 0; i < src->arg_types[0]; i ++) { |
|---|
| 491 | add_next_index_long(zv, src->arg_types[i + 1]); |
|---|
| 492 | } |
|---|
| 493 | add_assoc_zval_ex(dst, ZEND_STRS("arg_types"), zv); |
|---|
| 494 | } while (0);') |
|---|
| 495 | DONE(arg_types) |
|---|
| 496 | } |
|---|
| 497 | else { |
|---|
| 498 | IFDASM(`do { |
|---|
| 499 | /* empty array */ |
|---|
| 500 | zval *zv; |
|---|
| 501 | ALLOC_INIT_ZVAL(zv); |
|---|
| 502 | array_init(zv); |
|---|
| 503 | add_assoc_zval_ex(dst, ZEND_STRS("arg_types"), zv); |
|---|
| 504 | } while (0); |
|---|
| 505 | DONE(arg_types) |
|---|
| 506 | ', ` |
|---|
| 507 | COPYNULL(arg_types) |
|---|
| 508 | ') |
|---|
| 509 | } |
|---|
| 510 | #endif |
|---|
| 511 | DISPATCH(unsigned char, return_reference) |
|---|
| 512 | /* END of common elements */ |
|---|
| 513 | #ifdef IS_UNICODE |
|---|
| 514 | SETNULL(u_twin) |
|---|
| 515 | #endif |
|---|
| 516 | |
|---|
| 517 | STRUCT_P(zend_uint, refcount) |
|---|
| 518 | UNFIXPOINTER(zend_uint, refcount) |
|---|
| 519 | |
|---|
| 520 | pushdef(`AFTER_ALLOC', `IFCOPY(` |
|---|
| 521 | processor->active_opcodes_dst = dst->opcodes; |
|---|
| 522 | processor->active_opcodes_src = src->opcodes; |
|---|
| 523 | ')') |
|---|
| 524 | STRUCT_ARRAY(last, zend_op, opcodes) |
|---|
| 525 | popdef(`AFTER_ALLOC') |
|---|
| 526 | DISPATCH(zend_uint, last) |
|---|
| 527 | IFCOPY(`dst->size = src->last;DONE(size)', `DISPATCH(zend_uint, size)') |
|---|
| 528 | |
|---|
| 529 | #ifdef IS_CV |
|---|
| 530 | STRUCT_ARRAY(last_var, zend_compiled_variable, vars) |
|---|
| 531 | DISPATCH(int, last_var) |
|---|
| 532 | IFCOPY(`dst->size_var = src->last_var;DONE(size_var)', `DISPATCH(zend_uint, size_var)') |
|---|
| 533 | #else |
|---|
| 534 | dnl zend_cv.m4 is illegal to be made public, don not ask me for it |
|---|
| 535 | IFDASM(` |
|---|
| 536 | sinclude(`zend_cv.m4') |
|---|
| 537 | ') |
|---|
| 538 | #endif |
|---|
| 539 | |
|---|
| 540 | DISPATCH(zend_uint, T) |
|---|
| 541 | |
|---|
| 542 | STRUCT_ARRAY(last_brk_cont, zend_brk_cont_element, brk_cont_array) |
|---|
| 543 | DISPATCH(zend_uint, last_brk_cont) |
|---|
| 544 | DISPATCH(zend_uint, current_brk_cont) |
|---|
| 545 | #ifndef ZEND_ENGINE_2 |
|---|
| 546 | DISPATCH(zend_bool, uses_globals) |
|---|
| 547 | #endif |
|---|
| 548 | |
|---|
| 549 | #ifdef ZEND_ENGINE_2 |
|---|
| 550 | STRUCT_ARRAY(last_try_catch, zend_try_catch_element, try_catch_array) |
|---|
| 551 | DISPATCH(int, last_try_catch) |
|---|
| 552 | #endif |
|---|
| 553 | |
|---|
| 554 | STRUCT_P(HashTable, static_variables, HashTable_zval_ptr) |
|---|
| 555 | |
|---|
| 556 | IFCOPY(`dst->start_op = src->start_op;') |
|---|
| 557 | DONE(start_op) |
|---|
| 558 | DISPATCH(int, backpatch_count) |
|---|
| 559 | |
|---|
| 560 | DISPATCH(zend_bool, done_pass_two) |
|---|
| 561 | #ifdef ZEND_ENGINE_2 |
|---|
| 562 | DISPATCH(zend_bool, uses_this) |
|---|
| 563 | #endif |
|---|
| 564 | |
|---|
| 565 | IFRESTORE(`COPY(filename)', `PROC_STRING(filename)') |
|---|
| 566 | #ifdef IS_UNICODE |
|---|
| 567 | PROC_STRING(script_encoding) |
|---|
| 568 | #endif |
|---|
| 569 | #ifdef ZEND_ENGINE_2 |
|---|
| 570 | DISPATCH(zend_uint, line_start) |
|---|
| 571 | DISPATCH(zend_uint, line_end) |
|---|
| 572 | DISPATCH(int, doc_comment_len) |
|---|
| 573 | PROC_USTRING_L(, doc_comment, doc_comment_len) |
|---|
| 574 | #endif |
|---|
| 575 | |
|---|
| 576 | /* reserved */ |
|---|
| 577 | DONE(reserved) |
|---|
| 578 | #if defined(HARDENING_PATCH) && HARDENING_PATCH |
|---|
| 579 | DISPATCH(zend_bool, created_by_eval) |
|---|
| 580 | #endif |
|---|
| 581 | } while (0); |
|---|
| 582 | ') |
|---|
| 583 | dnl }}} |
|---|
| 584 | |
|---|
| 585 | DEF_STRUCT_P_FUNC(`xc_funcinfo_t', , `dnl {{{ |
|---|
| 586 | DISPATCH(zend_uint, key_size) |
|---|
| 587 | #ifdef IS_UNICODE |
|---|
| 588 | DISPATCH(zend_uchar, type) |
|---|
| 589 | #endif |
|---|
| 590 | IFRESTORE(`COPY(key)', ` |
|---|
| 591 | PROC_USTRING_N(type, key, key_size) |
|---|
| 592 | ') |
|---|
| 593 | STRUCT(zend_function, func) |
|---|
| 594 | ') |
|---|
| 595 | dnl }}} |
|---|
| 596 | DEF_STRUCT_P_FUNC(`xc_classinfo_t', , `dnl {{{ |
|---|
| 597 | DISPATCH(zend_uint, key_size) |
|---|
| 598 | #ifdef IS_UNICODE |
|---|
| 599 | DISPATCH(zend_uchar, type) |
|---|
| 600 | #endif |
|---|
| 601 | IFRESTORE(`COPY(key)', ` |
|---|
| 602 | PROC_USTRING_N(type, key, key_size) |
|---|
| 603 | ') |
|---|
| 604 | #ifdef ZEND_ENGINE_2 |
|---|
| 605 | STRUCT_P(zend_class_entry, cest) |
|---|
| 606 | #else |
|---|
| 607 | STRUCT(zend_class_entry, cest) |
|---|
| 608 | #endif |
|---|
| 609 | ') |
|---|
| 610 | dnl }}} |
|---|
| 611 | DEF_STRUCT_P_FUNC(`xc_entry_data_php_t', , `dnl {{{ |
|---|
| 612 | zend_uint i; |
|---|
| 613 | |
|---|
| 614 | #ifdef HAVE_INODE |
|---|
| 615 | DISPATCH(int, device) |
|---|
| 616 | DISPATCH(int, inode) |
|---|
| 617 | #endif |
|---|
| 618 | DISPATCH(size_t, sourcesize) |
|---|
| 619 | |
|---|
| 620 | DISPATCH(time_t, mtime) |
|---|
| 621 | |
|---|
| 622 | STRUCT_P(zend_op_array, op_array) |
|---|
| 623 | |
|---|
| 624 | DISPATCH(zend_uint, funcinfo_cnt) |
|---|
| 625 | STRUCT_ARRAY(funcinfo_cnt, xc_funcinfo_t, funcinfos) |
|---|
| 626 | |
|---|
| 627 | DISPATCH(zend_uint, classinfo_cnt) |
|---|
| 628 | pushdef(`BEFORE_LOOP', ` |
|---|
| 629 | IFCOPY(` |
|---|
| 630 | processor->active_class_num = i + 1; |
|---|
| 631 | ') |
|---|
| 632 | ') |
|---|
| 633 | STRUCT_ARRAY(classinfo_cnt, xc_classinfo_t, classinfos) |
|---|
| 634 | popdef(`BEFORE_LOOP') |
|---|
| 635 | ') |
|---|
| 636 | dnl }}} |
|---|
| 637 | DEF_STRUCT_P_FUNC(`xc_entry_data_var_t', , `dnl {{{ |
|---|
| 638 | DISPATCH(time_t, etime) |
|---|
| 639 | IFSTORE(` |
|---|
| 640 | if (processor->reference) { |
|---|
| 641 | if (zend_hash_add(&processor->zvalptrs, (char *)&src->value, sizeof(&src->value), (void*)&src->value, sizeof(src->value), NULL) == SUCCESS) { |
|---|
| 642 | dnl fprintf(stderr, "mark[%p] = %p\n", &src->value, &dst->value); |
|---|
| 643 | } |
|---|
| 644 | else { |
|---|
| 645 | assert(0); |
|---|
| 646 | } |
|---|
| 647 | } |
|---|
| 648 | ') |
|---|
| 649 | STRUCT_P_EX(zval_ptr, dst->value, src->value, `', `&') |
|---|
| 650 | DONE(value) |
|---|
| 651 | ') |
|---|
| 652 | dnl }}} |
|---|
| 653 | dnl {{{ xc_entry_t |
|---|
| 654 | DEF_STRUCT_P_FUNC(`xc_entry_t', , ` |
|---|
| 655 | IFCOPY(` |
|---|
| 656 | processor->xce_dst = dst; |
|---|
| 657 | processor->xce_src = src; |
|---|
| 658 | ') |
|---|
| 659 | DISPATCH(xc_entry_type_t, type) |
|---|
| 660 | DISPATCH(size_t, size) |
|---|
| 661 | |
|---|
| 662 | DISPATCH(xc_hash_value_t, hvalue) |
|---|
| 663 | COPY(cache) |
|---|
| 664 | /* skip */ |
|---|
| 665 | DONE(next) |
|---|
| 666 | |
|---|
| 667 | IFSTORE(`dst->refcount = 0; DONE(refcount)', `DISPATCH(long, refcount)') |
|---|
| 668 | |
|---|
| 669 | DISPATCH(time_t, ctime) |
|---|
| 670 | DISPATCH(time_t, atime) |
|---|
| 671 | DISPATCH(time_t, dtime) |
|---|
| 672 | DISPATCH(zend_ulong, hits) |
|---|
| 673 | #ifdef IS_UNICODE |
|---|
| 674 | DISPATCH(zend_uchar, name_type) |
|---|
| 675 | #endif |
|---|
| 676 | dnl {{{ name |
|---|
| 677 | DISABLECHECK(` |
|---|
| 678 | #ifdef IS_UNICODE |
|---|
| 679 | if (src->name_type == IS_UNICODE) { |
|---|
| 680 | DISPATCH(int32_t, name.ustr.len) |
|---|
| 681 | } |
|---|
| 682 | else { |
|---|
| 683 | DISPATCH(int, name.str.len) |
|---|
| 684 | } |
|---|
| 685 | #else |
|---|
| 686 | DISPATCH(int, name.str.len) |
|---|
| 687 | #endif |
|---|
| 688 | IFRESTORE(`COPY(name.str.val)', `PROC_USTRING_L(name_type, name.str.val, name.str.len)') |
|---|
| 689 | ') |
|---|
| 690 | DONE(name) |
|---|
| 691 | dnl }}} |
|---|
| 692 | |
|---|
| 693 | dnl {{{ data |
|---|
| 694 | DISABLECHECK(` |
|---|
| 695 | switch (src->type) { |
|---|
| 696 | case XC_TYPE_PHP: |
|---|
| 697 | STRUCT_P(xc_entry_data_php_t, data.php) |
|---|
| 698 | break; |
|---|
| 699 | case XC_TYPE_VAR: |
|---|
| 700 | STRUCT_P(xc_entry_data_var_t, data.var) |
|---|
| 701 | break; |
|---|
| 702 | default: |
|---|
| 703 | assert(0); |
|---|
| 704 | } |
|---|
| 705 | ') |
|---|
| 706 | DONE(data) |
|---|
| 707 | dnl }}} |
|---|
| 708 | ') |
|---|
| 709 | dnl }}} |
|---|
| 710 | dnl ==================================================== |
|---|