| 1 | dnl ================ |
|---|
| 2 | /* {{{ Pre-declare */ |
|---|
| 3 | DECL_STRUCT_P_FUNC(`zval') |
|---|
| 4 | DECL_STRUCT_P_FUNC(`zval_ptr') |
|---|
| 5 | DECL_STRUCT_P_FUNC(`zval_ptr_nullable') |
|---|
| 6 | DECL_STRUCT_P_FUNC(`zend_op_array') |
|---|
| 7 | DECL_STRUCT_P_FUNC(`zend_class_entry') |
|---|
| 8 | #ifdef HAVE_XCACHE_CONSTANT |
|---|
| 9 | DECL_STRUCT_P_FUNC(`zend_constant') |
|---|
| 10 | #endif |
|---|
| 11 | DECL_STRUCT_P_FUNC(`zend_function') |
|---|
| 12 | DECL_STRUCT_P_FUNC(`xc_entry_t') |
|---|
| 13 | #ifdef ZEND_ENGINE_2 |
|---|
| 14 | DECL_STRUCT_P_FUNC(`zend_property_info') |
|---|
| 15 | #endif |
|---|
| 16 | /* }}} */ |
|---|
| 17 | dnl ==================================================== |
|---|
| 18 | dnl {{{ zend_compiled_variable |
|---|
| 19 | #ifdef IS_CV |
|---|
| 20 | DEF_STRUCT_P_FUNC(`zend_compiled_variable', , ` |
|---|
| 21 | DISPATCH(int, name_len) |
|---|
| 22 | PROC_ZSTRING_L(, name, name_len) |
|---|
| 23 | DISPATCH(ulong, hash_value) |
|---|
| 24 | ') |
|---|
| 25 | #endif |
|---|
| 26 | dnl }}} |
|---|
| 27 | dnl {{{ zend_uint |
|---|
| 28 | DEF_STRUCT_P_FUNC(`zend_uint', , ` |
|---|
| 29 | IFCOPY(`dst[0] = src[0];') |
|---|
| 30 | IFDPRINT(` |
|---|
| 31 | INDENT() |
|---|
| 32 | fprintf(stderr, "%u\n", src[0]); |
|---|
| 33 | ') |
|---|
| 34 | DONE_SIZE(sizeof(src[0])) |
|---|
| 35 | ') |
|---|
| 36 | dnl }}} |
|---|
| 37 | dnl {{{ int |
|---|
| 38 | #ifndef ZEND_ENGINE_2 |
|---|
| 39 | DEF_STRUCT_P_FUNC(`int', , ` |
|---|
| 40 | IFCOPY(`*dst = *src;') |
|---|
| 41 | IFDPRINT(` |
|---|
| 42 | INDENT() |
|---|
| 43 | fprintf(stderr, "%d\n", src[0]); |
|---|
| 44 | ') |
|---|
| 45 | DONE_SIZE(sizeof(src[0])) |
|---|
| 46 | ') |
|---|
| 47 | #endif |
|---|
| 48 | dnl }}} |
|---|
| 49 | dnl {{{ zend_try_catch_element |
|---|
| 50 | #ifdef ZEND_ENGINE_2 |
|---|
| 51 | DEF_STRUCT_P_FUNC(`zend_try_catch_element', , ` |
|---|
| 52 | DISPATCH(zend_uint, try_op) |
|---|
| 53 | DISPATCH(zend_uint, catch_op) |
|---|
| 54 | ') |
|---|
| 55 | #endif /* ifdef ZEND_ENGINE_2 */ |
|---|
| 56 | dnl }}} |
|---|
| 57 | dnl {{{ zend_brk_cont_element |
|---|
| 58 | DEF_STRUCT_P_FUNC(`zend_brk_cont_element', , ` |
|---|
| 59 | #ifdef ZEND_ENGINE_2_2 |
|---|
| 60 | DISPATCH(int, start) |
|---|
| 61 | #endif |
|---|
| 62 | DISPATCH(int, cont) |
|---|
| 63 | DISPATCH(int, brk) |
|---|
| 64 | DISPATCH(int, parent) |
|---|
| 65 | ') |
|---|
| 66 | dnl }}} |
|---|
| 67 | DEF_HASH_TABLE_FUNC(`HashTable_zval_ptr', `zval_ptr') |
|---|
| 68 | DEF_HASH_TABLE_FUNC(`HashTable_zval_ptr_nullable', `zval_ptr_nullable') |
|---|
| 69 | DEF_HASH_TABLE_FUNC(`HashTable_zend_function', `zend_function') |
|---|
| 70 | #ifdef ZEND_ENGINE_2 |
|---|
| 71 | DEF_HASH_TABLE_FUNC(`HashTable_zend_property_info', `zend_property_info') |
|---|
| 72 | #endif |
|---|
| 73 | DEF_STRUCT_P_FUNC(`zval', , `dnl {{{ |
|---|
| 74 | IFDASM(`do { |
|---|
| 75 | zval_dtor(dst); |
|---|
| 76 | *dst = *src; |
|---|
| 77 | zval_copy_ctor(dst); |
|---|
| 78 | Z_SET_REFCOUNT(*dst, 1); |
|---|
| 79 | DONE(value) |
|---|
| 80 | DONE(type) |
|---|
| 81 | #ifdef ZEND_ENGINE_2_3 |
|---|
| 82 | DONE(is_ref__gc) |
|---|
| 83 | DONE(refcount__gc) |
|---|
| 84 | #else |
|---|
| 85 | DONE(is_ref) |
|---|
| 86 | DONE(refcount) |
|---|
| 87 | #endif |
|---|
| 88 | } while(0); |
|---|
| 89 | ', ` |
|---|
| 90 | dnl IFDASM else |
|---|
| 91 | /* Variable information */ |
|---|
| 92 | dnl {{{ zvalue_value |
|---|
| 93 | DISABLECHECK(` |
|---|
| 94 | switch ((Z_TYPE_P(src) & IS_CONSTANT_TYPE_MASK)) { |
|---|
| 95 | case IS_LONG: |
|---|
| 96 | case IS_RESOURCE: |
|---|
| 97 | case IS_BOOL: |
|---|
| 98 | DISPATCH(long, value.lval) |
|---|
| 99 | break; |
|---|
| 100 | case IS_DOUBLE: |
|---|
| 101 | DISPATCH(double, value.dval) |
|---|
| 102 | break; |
|---|
| 103 | case IS_NULL: |
|---|
| 104 | IFDPRINT(`INDENT()`'fprintf(stderr, "\tNULL\n");') |
|---|
| 105 | break; |
|---|
| 106 | |
|---|
| 107 | case IS_CONSTANT: |
|---|
| 108 | #ifdef IS_UNICODE |
|---|
| 109 | if (UG(unicode)) { |
|---|
| 110 | goto proc_unicode; |
|---|
| 111 | } |
|---|
| 112 | #endif |
|---|
| 113 | case IS_STRING: |
|---|
| 114 | #ifdef FLAG_IS_BC |
|---|
| 115 | case FLAG_IS_BC: |
|---|
| 116 | #endif |
|---|
| 117 | DISPATCH(int, value.str.len) |
|---|
| 118 | PROC_STRING_L(value.str.val, value.str.len) |
|---|
| 119 | break; |
|---|
| 120 | #ifdef IS_UNICODE |
|---|
| 121 | case IS_UNICODE: |
|---|
| 122 | proc_unicode: |
|---|
| 123 | DISPATCH(int32_t, value.uni.len) |
|---|
| 124 | PROC_ZSTRING_L(1, value.uni.val, value.uni.len) |
|---|
| 125 | break; |
|---|
| 126 | #endif |
|---|
| 127 | |
|---|
| 128 | case IS_ARRAY: |
|---|
| 129 | case IS_CONSTANT_ARRAY: |
|---|
| 130 | STRUCT_P(HashTable, value.ht, HashTable_zval_ptr) |
|---|
| 131 | break; |
|---|
| 132 | |
|---|
| 133 | case IS_OBJECT: |
|---|
| 134 | IFNOTMEMCPY(`IFCOPY(`memcpy(dst, src, sizeof(src[0]));')') |
|---|
| 135 | dnl STRUCT(value.obj) |
|---|
| 136 | #ifndef ZEND_ENGINE_2 |
|---|
| 137 | STRUCT_P(zend_class_entry, value.obj.ce) |
|---|
| 138 | STRUCT_P(HashTable, value.obj.properties, HashTable_zval_ptr) |
|---|
| 139 | #endif |
|---|
| 140 | break; |
|---|
| 141 | |
|---|
| 142 | default: |
|---|
| 143 | assert(0); |
|---|
| 144 | } |
|---|
| 145 | ') |
|---|
| 146 | dnl }}} |
|---|
| 147 | DONE(value) |
|---|
| 148 | DISPATCH(zval_data_type, type) |
|---|
| 149 | #ifdef ZEND_ENGINE_2_3 |
|---|
| 150 | DISPATCH(zend_uchar, is_ref__gc) |
|---|
| 151 | #else |
|---|
| 152 | DISPATCH(zend_uchar, is_ref) |
|---|
| 153 | #endif |
|---|
| 154 | |
|---|
| 155 | #ifdef ZEND_ENGINE_2_3 |
|---|
| 156 | DISPATCH(zend_uint, refcount__gc) |
|---|
| 157 | #elif defined(ZEND_ENGINE_2) |
|---|
| 158 | DISPATCH(zend_uint, refcount) |
|---|
| 159 | #else |
|---|
| 160 | DISPATCH(zend_ushort, refcount) |
|---|
| 161 | #endif |
|---|
| 162 | ')dnl IFDASM |
|---|
| 163 | ') |
|---|
| 164 | dnl }}} |
|---|
| 165 | DEF_STRUCT_P_FUNC(`zval_ptr', , `dnl {{{ |
|---|
| 166 | IFDASM(` |
|---|
| 167 | pushdefFUNC_NAME(`zval') |
|---|
| 168 | FUNC_NAME (dst, src[0] TSRMLS_CC); |
|---|
| 169 | popdef(`FUNC_NAME') |
|---|
| 170 | ', ` |
|---|
| 171 | do { |
|---|
| 172 | IFCALCCOPY(` |
|---|
| 173 | if (processor->reference) { |
|---|
| 174 | zval_ptr *ppzv; |
|---|
| 175 | if (zend_hash_find(&processor->zvalptrs, (char *) &src[0], sizeof(src[0]), (void **) &ppzv) == SUCCESS) { |
|---|
| 176 | IFCOPY(` |
|---|
| 177 | dst[0] = *ppzv; |
|---|
| 178 | /* *dst is updated */ |
|---|
| 179 | dnl fprintf(stderr, "*dst is set to %p, KIND is_shm %d\n", dst[0], xc_is_shm(dst[0])); |
|---|
| 180 | ') |
|---|
| 181 | IFCALCSTORE(`processor->have_references = 1;') |
|---|
| 182 | IFSTORE(`assert(xc_is_shm(dst[0]));') |
|---|
| 183 | IFRESTORE(`assert(!xc_is_shm(dst[0]));') |
|---|
| 184 | break; |
|---|
| 185 | } |
|---|
| 186 | } |
|---|
| 187 | ') |
|---|
| 188 | |
|---|
| 189 | ALLOC(dst[0], zval) |
|---|
| 190 | IFCALCCOPY(` |
|---|
| 191 | if (processor->reference) { |
|---|
| 192 | IFCALC(` |
|---|
| 193 | /* make dummy */ |
|---|
| 194 | zval_ptr pzv = (zval_ptr)-1; |
|---|
| 195 | ', ` |
|---|
| 196 | zval_ptr pzv = dst[0]; |
|---|
| 197 | FIXPOINTER_EX(zval, pzv) |
|---|
| 198 | ') |
|---|
| 199 | if (zend_hash_add(&processor->zvalptrs, (char *) &src[0], sizeof(src[0]), (void *) &pzv, sizeof(pzv), NULL) == SUCCESS) { |
|---|
| 200 | /* first add, go on */ |
|---|
| 201 | dnl fprintf(stderr, "mark[%p] = %p\n", src[0], pzv); |
|---|
| 202 | } |
|---|
| 203 | else { |
|---|
| 204 | assert(0); |
|---|
| 205 | } |
|---|
| 206 | } |
|---|
| 207 | ') |
|---|
| 208 | IFCOPY(` |
|---|
| 209 | dnl fprintf(stderr, "copy from %p to %p\n", src[0], dst[0]); |
|---|
| 210 | ') |
|---|
| 211 | IFDPRINT(`INDENT()`'fprintf(stderr, "[%p] ", src[0]);') |
|---|
| 212 | STRUCT_P_EX(zval, dst[0], src[0], `[0]', `', ` ') |
|---|
| 213 | FIXPOINTER_EX(zval, dst[0]) |
|---|
| 214 | } while (0); |
|---|
| 215 | ') |
|---|
| 216 | DONE_SIZE(sizeof(zval_ptr)) |
|---|
| 217 | ') |
|---|
| 218 | dnl }}} |
|---|
| 219 | DEF_STRUCT_P_FUNC(`zval_ptr_nullable', , `dnl {{{ |
|---|
| 220 | if (src[0]) { |
|---|
| 221 | STRUCT_P_EX(zval_ptr, dst, src, `', `', ` ') |
|---|
| 222 | } |
|---|
| 223 | else { |
|---|
| 224 | IFCOPY(`COPYNULL_EX(src[0], src)') |
|---|
| 225 | } |
|---|
| 226 | DONE_SIZE(sizeof(zval_ptr_nullable)) |
|---|
| 227 | ') |
|---|
| 228 | dnl }}} |
|---|
| 229 | dnl {{{ zend_arg_info |
|---|
| 230 | #ifdef ZEND_ENGINE_2 |
|---|
| 231 | DEF_STRUCT_P_FUNC(`zend_arg_info', , ` |
|---|
| 232 | DISPATCH(zend_uint, name_len) |
|---|
| 233 | PROC_ZSTRING_L(, name, name_len) |
|---|
| 234 | DISPATCH(zend_uint, class_name_len) |
|---|
| 235 | PROC_ZSTRING_L(, class_name, class_name_len) |
|---|
| 236 | #ifdef ZEND_ENGINE_2_4 |
|---|
| 237 | DISPATCH(zend_uchar, type_hint) |
|---|
| 238 | #else |
|---|
| 239 | DISPATCH(zend_bool, array_type_hint) |
|---|
| 240 | #endif |
|---|
| 241 | DISPATCH(zend_bool, allow_null) |
|---|
| 242 | DISPATCH(zend_bool, pass_by_reference) |
|---|
| 243 | #ifndef ZEND_ENGINE_2_4 |
|---|
| 244 | DISPATCH(zend_bool, return_reference) |
|---|
| 245 | DISPATCH(int, required_num_args) |
|---|
| 246 | #endif |
|---|
| 247 | ') |
|---|
| 248 | #endif |
|---|
| 249 | dnl }}} |
|---|
| 250 | #ifdef HAVE_XCACHE_CONSTANT |
|---|
| 251 | DEF_STRUCT_P_FUNC(`zend_constant', , `dnl {{{ |
|---|
| 252 | STRUCT(zval, value) |
|---|
| 253 | DISPATCH(int, flags) |
|---|
| 254 | DISPATCH(uint, name_len) |
|---|
| 255 | pushdef(`estrndup', `zend_strndup') |
|---|
| 256 | PROC_ZSTRING_N(, name, name_len) |
|---|
| 257 | popdef(`estrndup') |
|---|
| 258 | DISPATCH(int, module_number) |
|---|
| 259 | ') |
|---|
| 260 | dnl }}} |
|---|
| 261 | #endif |
|---|
| 262 | DEF_STRUCT_P_FUNC(`zend_function', , `dnl {{{ |
|---|
| 263 | DISABLECHECK(` |
|---|
| 264 | switch (src->type) { |
|---|
| 265 | case ZEND_INTERNAL_FUNCTION: |
|---|
| 266 | case ZEND_OVERLOADED_FUNCTION: |
|---|
| 267 | IFNOTMEMCPY(`IFCOPY(`memcpy(dst, src, sizeof(src[0]));')') |
|---|
| 268 | break; |
|---|
| 269 | |
|---|
| 270 | case ZEND_USER_FUNCTION: |
|---|
| 271 | case ZEND_EVAL_CODE: |
|---|
| 272 | DONE(type) |
|---|
| 273 | STRUCT(zend_op_array, op_array) |
|---|
| 274 | break; |
|---|
| 275 | |
|---|
| 276 | default: |
|---|
| 277 | assert(0); |
|---|
| 278 | } |
|---|
| 279 | ') |
|---|
| 280 | DONE_SIZE(sizeof(src[0])) |
|---|
| 281 | ') |
|---|
| 282 | dnl }}} |
|---|
| 283 | dnl {{{ zend_property_info |
|---|
| 284 | #ifdef ZEND_ENGINE_2 |
|---|
| 285 | DEF_STRUCT_P_FUNC(`zend_property_info', , ` |
|---|
| 286 | DISPATCH(zend_uint, flags) |
|---|
| 287 | DISPATCH(int, name_length) |
|---|
| 288 | PROC_ZSTRING_L(, name, name_length) |
|---|
| 289 | DISPATCH(ulong, h) |
|---|
| 290 | #ifdef ZEND_ENGINE_2_4 |
|---|
| 291 | DISPATCH(int, offset) |
|---|
| 292 | #endif |
|---|
| 293 | #ifdef ZEND_ENGINE_2_1 |
|---|
| 294 | DISPATCH(int, doc_comment_len) |
|---|
| 295 | PROC_ZSTRING_L(, doc_comment, doc_comment_len) |
|---|
| 296 | #endif |
|---|
| 297 | dnl isnt in php6 yet |
|---|
| 298 | #if defined(ZEND_ENGINE_2_2) |
|---|
| 299 | PROC_CLASS_ENTRY_P(ce) |
|---|
| 300 | #endif |
|---|
| 301 | ') |
|---|
| 302 | #endif |
|---|
| 303 | dnl }}} |
|---|
| 304 | DEF_STRUCT_P_FUNC(`zend_class_entry', , `dnl {{{ |
|---|
| 305 | IFCALCCOPY(` |
|---|
| 306 | processor->active_class_entry_src = src; |
|---|
| 307 | IFCOPY(`processor->active_class_entry_dst = dst;') |
|---|
| 308 | ') |
|---|
| 309 | DISPATCH(char, type) |
|---|
| 310 | DISPATCH(zend_uint, name_length) |
|---|
| 311 | PROC_ZSTRING_L(, name, name_length) |
|---|
| 312 | IFRESTORE(` |
|---|
| 313 | #ifndef ZEND_ENGINE_2 |
|---|
| 314 | /* just copy parent and resolve on install_class */ |
|---|
| 315 | COPY(parent) |
|---|
| 316 | #else |
|---|
| 317 | PROC_CLASS_ENTRY_P(parent) |
|---|
| 318 | #endif |
|---|
| 319 | ', ` |
|---|
| 320 | PROC_CLASS_ENTRY_P(parent) |
|---|
| 321 | ') |
|---|
| 322 | #ifdef ZEND_ENGINE_2 |
|---|
| 323 | DISPATCH(int, refcount) |
|---|
| 324 | #else |
|---|
| 325 | STRUCT_P(int, refcount) |
|---|
| 326 | #endif |
|---|
| 327 | #ifndef ZEND_ENGINE_2_4 |
|---|
| 328 | DISPATCH(zend_bool, constants_updated) |
|---|
| 329 | #endif |
|---|
| 330 | #ifdef ZEND_ENGINE_2 |
|---|
| 331 | DISPATCH(zend_uint, ce_flags) |
|---|
| 332 | #endif |
|---|
| 333 | |
|---|
| 334 | #ifdef ZEND_ENGINE_2 |
|---|
| 335 | STRUCT(HashTable, properties_info, HashTable_zend_property_info) |
|---|
| 336 | #endif |
|---|
| 337 | |
|---|
| 338 | #ifdef ZEND_ENGINE_2_4 |
|---|
| 339 | DISPATCH(int, default_properties_count) |
|---|
| 340 | STRUCT_ARRAY(default_properties_count, zval_ptr_nullable, default_properties_table) |
|---|
| 341 | DISPATCH(int, default_static_members_count) |
|---|
| 342 | STRUCT_ARRAY(default_static_members_count, zval_ptr_nullable, default_static_members_table) |
|---|
| 343 | IFCOPY(`dst->static_members_table = dst->default_static_members_table;') |
|---|
| 344 | DONE(static_members_table) |
|---|
| 345 | #else |
|---|
| 346 | IFCOPY(`dst->builtin_functions = src->builtin_functions;') |
|---|
| 347 | DONE(builtin_functions) |
|---|
| 348 | STRUCT(HashTable, default_properties, HashTable_zval_ptr) |
|---|
| 349 | # ifdef ZEND_ENGINE_2_1 |
|---|
| 350 | STRUCT(HashTable, default_static_members, HashTable_zval_ptr) |
|---|
| 351 | IFCOPY(`dst->static_members = &dst->default_static_members;') |
|---|
| 352 | DONE(static_members) |
|---|
| 353 | # elif defined(ZEND_ENGINE_2) |
|---|
| 354 | STRUCT_P(HashTable, static_members, HashTable_zval_ptr) |
|---|
| 355 | # endif |
|---|
| 356 | #endif /* ZEND_ENGINE_2_4 */ |
|---|
| 357 | |
|---|
| 358 | #ifdef ZEND_ENGINE_2 |
|---|
| 359 | STRUCT(HashTable, constants_table, HashTable_zval_ptr) |
|---|
| 360 | |
|---|
| 361 | dnl runtime binding: ADD_INTERFACE will deal with it |
|---|
| 362 | dnl runtime binding: ADD_TRAIT will deal with it |
|---|
| 363 | IFRESTORE(` |
|---|
| 364 | if (src->num_interfaces) { |
|---|
| 365 | CALLOC(dst->interfaces, zend_class_entry*, src->num_interfaces) |
|---|
| 366 | DONE(`interfaces') |
|---|
| 367 | } |
|---|
| 368 | else { |
|---|
| 369 | COPYNULL(`interfaces') |
|---|
| 370 | } |
|---|
| 371 | # ifdef ZEND_ENGINE_2_4 |
|---|
| 372 | if (src->num_traits) { |
|---|
| 373 | CALLOC(dst->traits, zend_class_entry*, src->num_traits) |
|---|
| 374 | DONE(`traits') |
|---|
| 375 | DONE(`trait_aliases') |
|---|
| 376 | DONE(`trait_precedences') |
|---|
| 377 | } |
|---|
| 378 | else { |
|---|
| 379 | COPYNULL(`traits') |
|---|
| 380 | COPYNULL(`trait_aliases') |
|---|
| 381 | COPYNULL(`trait_precedences') |
|---|
| 382 | } |
|---|
| 383 | # endif |
|---|
| 384 | ') |
|---|
| 385 | IFDASM(` |
|---|
| 386 | if (src->num_interfaces) { |
|---|
| 387 | /* |
|---|
| 388 | int i; |
|---|
| 389 | zval *arr; |
|---|
| 390 | ALLOC_INIT_ZVAL(arr); |
|---|
| 391 | array_init(arr); |
|---|
| 392 | for (i = 0; i < src->num_interfaces; i ++) { |
|---|
| 393 | zval *zv; |
|---|
| 394 | ALLOC_INIT_ZVAL(zv); |
|---|
| 395 | ZVAL_STRING(src->num_interfaces); |
|---|
| 396 | } |
|---|
| 397 | add_assoc_zval_ex(dst, ZEND_STRS("interfaces"), arr); |
|---|
| 398 | */ |
|---|
| 399 | DONE(`interfaces') |
|---|
| 400 | } |
|---|
| 401 | else { |
|---|
| 402 | COPYNULL(`interfaces') |
|---|
| 403 | } |
|---|
| 404 | # ifdef ZEND_ENGINE_2_4 |
|---|
| 405 | if (src->num_traits) { |
|---|
| 406 | DONE(`traits') |
|---|
| 407 | DONE(`trait_aliases') |
|---|
| 408 | DONE(`trait_precedences') |
|---|
| 409 | } |
|---|
| 410 | else { |
|---|
| 411 | COPYNULL(`traits') |
|---|
| 412 | COPYNULL(`trait_aliases') |
|---|
| 413 | COPYNULL(`trait_precedences') |
|---|
| 414 | } |
|---|
| 415 | # endif |
|---|
| 416 | ') |
|---|
| 417 | IFRESTORE(`', ` |
|---|
| 418 | IFDASM(`', ` |
|---|
| 419 | DONE(`interfaces') |
|---|
| 420 | # ifdef ZEND_ENGINE_2_4 |
|---|
| 421 | DONE(`traits') |
|---|
| 422 | DONE(`trait_aliases') |
|---|
| 423 | DONE(`trait_precedences') |
|---|
| 424 | # endif |
|---|
| 425 | ') |
|---|
| 426 | ') |
|---|
| 427 | DISPATCH(zend_uint, num_interfaces) |
|---|
| 428 | # ifdef ZEND_ENGINE_2_4 |
|---|
| 429 | DISPATCH(zend_uint, num_traits) |
|---|
| 430 | # endif |
|---|
| 431 | |
|---|
| 432 | # ifdef ZEND_ENGINE_2_4 |
|---|
| 433 | DISABLECHECK(` |
|---|
| 434 | IFRESTORE(`dst->info.user.filename = processor->entry_src->filepath;', `PROC_STRING(info.user.filename)') |
|---|
| 435 | DISPATCH(zend_uint, info.user.line_start) |
|---|
| 436 | DISPATCH(zend_uint, info.user.line_end) |
|---|
| 437 | DISPATCH(zend_uint, info.user.doc_comment_len) |
|---|
| 438 | PROC_ZSTRING_L(, info.user.doc_comment, info.user.doc_comment_len) |
|---|
| 439 | ') |
|---|
| 440 | DONE(info) |
|---|
| 441 | # else |
|---|
| 442 | IFRESTORE(`dst->filename = processor->entry_src->filepath;DONE(filename)', `PROC_STRING(filename)') |
|---|
| 443 | DISPATCH(zend_uint, line_start) |
|---|
| 444 | DISPATCH(zend_uint, line_end) |
|---|
| 445 | # ifdef ZEND_ENGINE_2_1 |
|---|
| 446 | DISPATCH(zend_uint, doc_comment_len) |
|---|
| 447 | PROC_ZSTRING_L(, doc_comment, doc_comment_len) |
|---|
| 448 | # endif |
|---|
| 449 | # endif |
|---|
| 450 | |
|---|
| 451 | /* # NOT DONE */ |
|---|
| 452 | COPY(serialize_func) |
|---|
| 453 | COPY(unserialize_func) |
|---|
| 454 | COPY(iterator_funcs) |
|---|
| 455 | COPY(create_object) |
|---|
| 456 | COPY(get_iterator) |
|---|
| 457 | COPY(interface_gets_implemented) |
|---|
| 458 | # ifdef ZEND_ENGINE_2_3 |
|---|
| 459 | COPY(get_static_method) |
|---|
| 460 | # endif |
|---|
| 461 | COPY(serialize) |
|---|
| 462 | COPY(unserialize) |
|---|
| 463 | /* deal with it inside xc_fix_method */ |
|---|
| 464 | SETNULL(constructor) |
|---|
| 465 | COPY(destructor) |
|---|
| 466 | COPY(clone) |
|---|
| 467 | COPY(__get) |
|---|
| 468 | COPY(__set) |
|---|
| 469 | /* should be >5.1 */ |
|---|
| 470 | # ifdef ZEND_ENGINE_2_1 |
|---|
| 471 | COPY(__unset) |
|---|
| 472 | COPY(__isset) |
|---|
| 473 | # if defined(ZEND_ENGINE_2_2) || PHP_MAJOR_VERSION >= 6 |
|---|
| 474 | COPY(__tostring) |
|---|
| 475 | # endif |
|---|
| 476 | # endif |
|---|
| 477 | COPY(__call) |
|---|
| 478 | # ifdef ZEND_CALLSTATIC_FUNC_NAME |
|---|
| 479 | COPY(__callstatic) |
|---|
| 480 | # endif |
|---|
| 481 | # ifndef ZEND_ENGINE_2_4 |
|---|
| 482 | /* # NOT DONE */ |
|---|
| 483 | COPY(module) |
|---|
| 484 | # endif |
|---|
| 485 | #else /* ZEND_ENGINE_2 */ |
|---|
| 486 | COPY(handle_function_call) |
|---|
| 487 | COPY(handle_property_get) |
|---|
| 488 | COPY(handle_property_set) |
|---|
| 489 | #endif |
|---|
| 490 | dnl must do after SETNULL(constructor) and dst->parent |
|---|
| 491 | STRUCT(HashTable, function_table, HashTable_zend_function) |
|---|
| 492 | IFRESTORE(`dst->function_table.pDestructor = ZEND_FUNCTION_DTOR;') |
|---|
| 493 | IFCALCCOPY(` |
|---|
| 494 | processor->active_class_entry_src = NULL; |
|---|
| 495 | IFCOPY(`processor->active_class_entry_dst = NULL;') |
|---|
| 496 | ') |
|---|
| 497 | ') |
|---|
| 498 | dnl }}} |
|---|
| 499 | #ifdef ZEND_ENGINE_2_4 |
|---|
| 500 | undefine(`UNION_znode_op') |
|---|
| 501 | define(`UNION_znode_op', `dnl {{{ |
|---|
| 502 | #ifndef NDEBUG |
|---|
| 503 | switch ((src->$1_type ifelse($1, `result', & ~EXT_TYPE_UNUSED))) { |
|---|
| 504 | case IS_CONST: |
|---|
| 505 | case IS_VAR: |
|---|
| 506 | case IS_CV: |
|---|
| 507 | case IS_TMP_VAR: |
|---|
| 508 | case IS_UNUSED: |
|---|
| 509 | break; |
|---|
| 510 | |
|---|
| 511 | default: |
|---|
| 512 | assert(0); |
|---|
| 513 | } |
|---|
| 514 | #endif |
|---|
| 515 | |
|---|
| 516 | dnl dirty dispatch |
|---|
| 517 | DISABLECHECK(` |
|---|
| 518 | switch ((src->$1_type ifelse($1, `result', & ~EXT_TYPE_UNUSED))) { |
|---|
| 519 | case IS_CONST: |
|---|
| 520 | ifelse($1, `result', ` |
|---|
| 521 | DISPATCH(zend_uint, $1.constant) |
|---|
| 522 | ', ` |
|---|
| 523 | IFDASM(`{ |
|---|
| 524 | zval *zv; |
|---|
| 525 | ALLOC_INIT_ZVAL(zv); |
|---|
| 526 | *zv = src->$1.literal->constant; |
|---|
| 527 | zval_copy_ctor(zv); |
|---|
| 528 | add_assoc_zval_ex(dst, ZEND_STRS("$1.constant"), zv); |
|---|
| 529 | } |
|---|
| 530 | ', ` |
|---|
| 531 | IFCOPY(` |
|---|
| 532 | dst->$1 = src->$1; |
|---|
| 533 | ', ` |
|---|
| 534 | DISPATCH(zend_uint, $1.constant) |
|---|
| 535 | ') |
|---|
| 536 | ') |
|---|
| 537 | ') |
|---|
| 538 | break; |
|---|
| 539 | IFCOPY(` |
|---|
| 540 | IFNOTMEMCPY(` |
|---|
| 541 | default: |
|---|
| 542 | $1 = $2; |
|---|
| 543 | ') |
|---|
| 544 | ', ` |
|---|
| 545 | case IS_VAR: |
|---|
| 546 | case IS_TMP_VAR: |
|---|
| 547 | case IS_CV: |
|---|
| 548 | DISPATCH(zend_uint, $1.var) |
|---|
| 549 | break; |
|---|
| 550 | case IS_UNUSED: |
|---|
| 551 | IFDASM(`DISPATCH(zend_uint, $1.var)') |
|---|
| 552 | DISPATCH(zend_uint, $1.opline_num) |
|---|
| 553 | break; |
|---|
| 554 | ') |
|---|
| 555 | } |
|---|
| 556 | ') |
|---|
| 557 | DONE($1) |
|---|
| 558 | ') |
|---|
| 559 | dnl }}} |
|---|
| 560 | #else |
|---|
| 561 | DEF_STRUCT_P_FUNC(`znode', , `dnl {{{ |
|---|
| 562 | DISPATCH(int, op_type) |
|---|
| 563 | |
|---|
| 564 | #ifdef IS_CV |
|---|
| 565 | # define XCACHE_IS_CV IS_CV |
|---|
| 566 | #else |
|---|
| 567 | /* compatible with zend optimizer */ |
|---|
| 568 | # define XCACHE_IS_CV 16 |
|---|
| 569 | #endif |
|---|
| 570 | assert(src->op_type == IS_CONST || |
|---|
| 571 | src->op_type == IS_VAR || |
|---|
| 572 | src->op_type == XCACHE_IS_CV || |
|---|
| 573 | src->op_type == IS_TMP_VAR || |
|---|
| 574 | src->op_type == IS_UNUSED); |
|---|
| 575 | dnl dirty dispatch |
|---|
| 576 | DISABLECHECK(` |
|---|
| 577 | switch (src->op_type) { |
|---|
| 578 | case IS_CONST: |
|---|
| 579 | STRUCT(zval, u.constant) |
|---|
| 580 | break; |
|---|
| 581 | IFCOPY(` |
|---|
| 582 | IFNOTMEMCPY(` |
|---|
| 583 | default: |
|---|
| 584 | memcpy(&dst->u, &src->u, sizeof(src->u)); |
|---|
| 585 | ') |
|---|
| 586 | ', ` |
|---|
| 587 | case IS_VAR: |
|---|
| 588 | case IS_TMP_VAR: |
|---|
| 589 | case XCACHE_IS_CV: |
|---|
| 590 | DISPATCH(zend_uint, u.var) |
|---|
| 591 | DISPATCH(zend_uint, u.EA.type) |
|---|
| 592 | break; |
|---|
| 593 | case IS_UNUSED: |
|---|
| 594 | IFDASM(`DISPATCH(zend_uint, u.var)') |
|---|
| 595 | DISPATCH(zend_uint, u.opline_num) |
|---|
| 596 | #ifndef ZEND_ENGINE_2 |
|---|
| 597 | DISPATCH(zend_uint, u.fetch_type) |
|---|
| 598 | #endif |
|---|
| 599 | DISPATCH(zend_uint, u.EA.type) |
|---|
| 600 | break; |
|---|
| 601 | ') |
|---|
| 602 | } |
|---|
| 603 | ') |
|---|
| 604 | DONE(u) |
|---|
| 605 | #if 0 |
|---|
| 606 | DONE(EA) |
|---|
| 607 | #endif |
|---|
| 608 | #undef XCACHE_IS_CV |
|---|
| 609 | ') |
|---|
| 610 | dnl }}} |
|---|
| 611 | #endif |
|---|
| 612 | DEF_STRUCT_P_FUNC(`zend_op', , `dnl {{{ |
|---|
| 613 | DISPATCH(zend_uchar, opcode) |
|---|
| 614 | #ifdef ZEND_ENGINE_2_4 |
|---|
| 615 | IFRESTORE(`', ` |
|---|
| 616 | switch (src->opcode) { |
|---|
| 617 | case ZEND_BIND_TRAITS: |
|---|
| 618 | ((zend_op *) src)->op2_type = IS_UNUSED; |
|---|
| 619 | break; |
|---|
| 620 | } |
|---|
| 621 | ') |
|---|
| 622 | UNION_znode_op(result) |
|---|
| 623 | UNION_znode_op(op1) |
|---|
| 624 | UNION_znode_op(op2) |
|---|
| 625 | #else |
|---|
| 626 | STRUCT(znode, result) |
|---|
| 627 | STRUCT(znode, op1) |
|---|
| 628 | STRUCT(znode, op2) |
|---|
| 629 | #endif |
|---|
| 630 | DISPATCH(ulong, extended_value) |
|---|
| 631 | DISPATCH(uint, lineno) |
|---|
| 632 | #ifdef ZEND_ENGINE_2_1 |
|---|
| 633 | #ifdef ZEND_ENGINE_2_4 |
|---|
| 634 | DISPATCH(zend_uchar, op1_type) |
|---|
| 635 | DISPATCH(zend_uchar, op2_type) |
|---|
| 636 | DISPATCH(zend_uchar, result_type) |
|---|
| 637 | #endif |
|---|
| 638 | IFCOPY(` |
|---|
| 639 | pushdef(`UNION_znode_op_literal', ` |
|---|
| 640 | if (dst->$1_type == IS_CONST) { |
|---|
| 641 | IFSTORE(` |
|---|
| 642 | dst->$1.constant = src->$1.literal - processor->active_op_array_src->literals; |
|---|
| 643 | dst->$1.literal = &processor->active_op_array_dst->literals[dst->$1.constant]; |
|---|
| 644 | ') |
|---|
| 645 | } |
|---|
| 646 | ') |
|---|
| 647 | UNION_znode_op_literal(op1) |
|---|
| 648 | UNION_znode_op_literal(op2) |
|---|
| 649 | popdef(`UNION_znode_op_literal') |
|---|
| 650 | switch (src->opcode) { |
|---|
| 651 | #ifdef ZEND_GOTO |
|---|
| 652 | case ZEND_GOTO: |
|---|
| 653 | #endif |
|---|
| 654 | case ZEND_JMP: |
|---|
| 655 | assert(Z_OP(src->op1).jmp_addr >= processor->active_opcodes_src && Z_OP(src->op1).jmp_addr - processor->active_opcodes_src < processor->active_op_array_src->last); |
|---|
| 656 | Z_OP(dst->op1).jmp_addr = processor->active_opcodes_dst + (Z_OP(src->op1).jmp_addr - processor->active_opcodes_src); |
|---|
| 657 | assert(Z_OP(dst->op1).jmp_addr >= processor->active_opcodes_dst && Z_OP(dst->op1).jmp_addr - processor->active_opcodes_dst < processor->active_op_array_dst->last); |
|---|
| 658 | break; |
|---|
| 659 | |
|---|
| 660 | case ZEND_JMPZ: |
|---|
| 661 | case ZEND_JMPNZ: |
|---|
| 662 | case ZEND_JMPZ_EX: |
|---|
| 663 | case ZEND_JMPNZ_EX: |
|---|
| 664 | #ifdef ZEND_JMP_SET |
|---|
| 665 | case ZEND_JMP_SET: |
|---|
| 666 | #endif |
|---|
| 667 | assert(Z_OP(src->op2).jmp_addr >= processor->active_opcodes_src && Z_OP(src->op2).jmp_addr - processor->active_opcodes_src < processor->active_op_array_src->last); |
|---|
| 668 | Z_OP(dst->op2).jmp_addr = processor->active_opcodes_dst + (Z_OP(src->op2).jmp_addr - processor->active_opcodes_src); |
|---|
| 669 | assert(Z_OP(dst->op2).jmp_addr >= processor->active_opcodes_dst && Z_OP(dst->op2).jmp_addr - processor->active_opcodes_dst < processor->active_op_array_dst->last); |
|---|
| 670 | break; |
|---|
| 671 | |
|---|
| 672 | default: |
|---|
| 673 | break; |
|---|
| 674 | } |
|---|
| 675 | ') |
|---|
| 676 | DISPATCH(opcode_handler_t, handler) |
|---|
| 677 | #endif |
|---|
| 678 | ') |
|---|
| 679 | dnl }}} |
|---|
| 680 | #ifdef ZEND_ENGINE_2_4 |
|---|
| 681 | DEF_STRUCT_P_FUNC(`zend_literal', , `dnl {{{ |
|---|
| 682 | STRUCT(zval, constant) |
|---|
| 683 | DISPATCH(zend_ulong, hash_value) |
|---|
| 684 | DISPATCH(zend_uint, cache_slot) |
|---|
| 685 | ') |
|---|
| 686 | dnl }}} |
|---|
| 687 | #endif |
|---|
| 688 | DEF_STRUCT_P_FUNC(`zend_op_array', , `dnl {{{ |
|---|
| 689 | IFRESTORE(` |
|---|
| 690 | const xc_op_array_info_t *op_array_info = &processor->active_op_array_infos_src[processor->active_op_array_index++]; |
|---|
| 691 | dnl shadow copy must NOT meet: |
|---|
| 692 | dnl readonly_protection=on |
|---|
| 693 | dnl main op_array && have early binding |
|---|
| 694 | #ifdef ZEND_COMPILE_DELAYED_BINDING |
|---|
| 695 | zend_bool need_early_binding = 0; |
|---|
| 696 | #else |
|---|
| 697 | zend_bool need_early_binding = processor->php_src->have_early_binding; |
|---|
| 698 | #endif |
|---|
| 699 | zend_bool shallow_copy = !processor->readonly_protection && !(src == processor->php_src->op_array && need_early_binding); |
|---|
| 700 | if (shallow_copy) { |
|---|
| 701 | zend_bool gc_arg_info = 0; |
|---|
| 702 | zend_bool gc_opcodes = 0; |
|---|
| 703 | /* really fast shallow copy */ |
|---|
| 704 | memcpy(dst, src, sizeof(src[0])); |
|---|
| 705 | dst->refcount[0] = 1000; |
|---|
| 706 | /* deep */ |
|---|
| 707 | STRUCT_P(HashTable, static_variables, HashTable_zval_ptr) |
|---|
| 708 | #ifdef ZEND_ENGINE_2 |
|---|
| 709 | STRUCT_ARRAY(num_args, zend_arg_info, arg_info) |
|---|
| 710 | gc_arg_info = 1; |
|---|
| 711 | #endif |
|---|
| 712 | dst->filename = processor->entry_src->filepath; |
|---|
| 713 | #ifdef ZEND_ENGINE_2_4 |
|---|
| 714 | if (src->literals /* || op_array_info->literalsinfo_cnt */) { |
|---|
| 715 | gc_opcodes = 1; |
|---|
| 716 | } |
|---|
| 717 | #else |
|---|
| 718 | if (op_array_info->oplineinfo_cnt) { |
|---|
| 719 | gc_opcodes = 1; |
|---|
| 720 | } |
|---|
| 721 | #endif |
|---|
| 722 | if (gc_opcodes) { |
|---|
| 723 | zend_op *opline, *end; |
|---|
| 724 | COPY_N_EX(last, zend_op, opcodes) |
|---|
| 725 | |
|---|
| 726 | for (opline = dst->opcodes, end = opline + src->last; opline < end; ++opline) { |
|---|
| 727 | #ifdef ZEND_ENGINE_2_4 |
|---|
| 728 | pushdef(`UNION_znode_op_literal', ` |
|---|
| 729 | if (opline->$1_type == IS_CONST) { |
|---|
| 730 | opline->$1.constant = opline->$1.literal - src->literals; |
|---|
| 731 | opline->$1.literal = &dst->literals[opline->$1.constant]; |
|---|
| 732 | } |
|---|
| 733 | ') |
|---|
| 734 | UNION_znode_op_literal(op1) |
|---|
| 735 | UNION_znode_op_literal(op2) |
|---|
| 736 | popdef(`UNION_znode_op_literal') |
|---|
| 737 | #endif |
|---|
| 738 | |
|---|
| 739 | switch (opline->opcode) { |
|---|
| 740 | #ifdef ZEND_GOTO |
|---|
| 741 | case ZEND_GOTO: |
|---|
| 742 | #endif |
|---|
| 743 | case ZEND_JMP: |
|---|
| 744 | Z_OP(opline->op1).jmp_addr = dst->opcodes + (Z_OP(opline->op1).jmp_addr - src->opcodes); |
|---|
| 745 | break; |
|---|
| 746 | |
|---|
| 747 | case ZEND_JMPZ: |
|---|
| 748 | case ZEND_JMPNZ: |
|---|
| 749 | case ZEND_JMPZ_EX: |
|---|
| 750 | case ZEND_JMPNZ_EX: |
|---|
| 751 | #ifdef ZEND_JMP_SET |
|---|
| 752 | case ZEND_JMP_SET: |
|---|
| 753 | #endif |
|---|
| 754 | Z_OP(opline->op2).jmp_addr = dst->opcodes + (Z_OP(opline->op2).jmp_addr - src->opcodes); |
|---|
| 755 | break; |
|---|
| 756 | |
|---|
| 757 | default: |
|---|
| 758 | break; |
|---|
| 759 | } |
|---|
| 760 | } |
|---|
| 761 | } |
|---|
| 762 | if (gc_arg_info || gc_opcodes) { |
|---|
| 763 | xc_gc_op_array_t gc_op_array; |
|---|
| 764 | #ifdef ZEND_ENGINE_2 |
|---|
| 765 | gc_op_array.num_args = gc_arg_info ? dst->num_args : 0; |
|---|
| 766 | gc_op_array.arg_info = gc_arg_info ? dst->arg_info : NULL; |
|---|
| 767 | #endif |
|---|
| 768 | gc_op_array.opcodes = gc_opcodes ? dst->opcodes : NULL; |
|---|
| 769 | xc_gc_add_op_array(&gc_op_array TSRMLS_CC); |
|---|
| 770 | } |
|---|
| 771 | define(`SKIPASSERT_ONCE') |
|---|
| 772 | } |
|---|
| 773 | else |
|---|
| 774 | ') |
|---|
| 775 | do { |
|---|
| 776 | dnl RESTORE is done above! |
|---|
| 777 | |
|---|
| 778 | /* Common elements */ |
|---|
| 779 | DISPATCH(zend_uchar, type) |
|---|
| 780 | PROC_ZSTRING(, function_name) |
|---|
| 781 | #ifdef ZEND_ENGINE_2 |
|---|
| 782 | DISPATCH(zend_uint, fn_flags) |
|---|
| 783 | STRUCT_ARRAY(num_args, zend_arg_info, arg_info) |
|---|
| 784 | DISPATCH(zend_uint, num_args) |
|---|
| 785 | DISPATCH(zend_uint, required_num_args) |
|---|
| 786 | # ifndef ZEND_ENGINE_2_4 |
|---|
| 787 | DISPATCH(zend_bool, pass_rest_by_reference) |
|---|
| 788 | # endif |
|---|
| 789 | #else |
|---|
| 790 | if (src->arg_types) { |
|---|
| 791 | ALLOC(dst->arg_types, zend_uchar, src->arg_types[0] + 1) |
|---|
| 792 | IFCOPY(`memcpy(dst->arg_types, src->arg_types, sizeof(src->arg_types[0]) * (src->arg_types[0]+1));') |
|---|
| 793 | IFDASM(`do { |
|---|
| 794 | int i; |
|---|
| 795 | zval *zv; |
|---|
| 796 | ALLOC_INIT_ZVAL(zv); |
|---|
| 797 | array_init(zv); |
|---|
| 798 | for (i = 0; i < src->arg_types[0]; i ++) { |
|---|
| 799 | add_next_index_long(zv, src->arg_types[i + 1]); |
|---|
| 800 | } |
|---|
| 801 | add_assoc_zval_ex(dst, ZEND_STRS("arg_types"), zv); |
|---|
| 802 | } while (0);') |
|---|
| 803 | DONE(arg_types) |
|---|
| 804 | } |
|---|
| 805 | else { |
|---|
| 806 | IFDASM(`do { |
|---|
| 807 | /* empty array */ |
|---|
| 808 | zval *zv; |
|---|
| 809 | ALLOC_INIT_ZVAL(zv); |
|---|
| 810 | array_init(zv); |
|---|
| 811 | add_assoc_zval_ex(dst, ZEND_STRS("arg_types"), zv); |
|---|
| 812 | } while (0); |
|---|
| 813 | DONE(arg_types) |
|---|
| 814 | ', ` |
|---|
| 815 | COPYNULL(arg_types) |
|---|
| 816 | ') |
|---|
| 817 | } |
|---|
| 818 | #endif |
|---|
| 819 | #ifndef ZEND_ENGINE_2_4 |
|---|
| 820 | DISPATCH(unsigned char, return_reference) |
|---|
| 821 | #endif |
|---|
| 822 | /* END of common elements */ |
|---|
| 823 | #ifdef IS_UNICODE |
|---|
| 824 | dnl SETNULL(u_twin) |
|---|
| 825 | #endif |
|---|
| 826 | |
|---|
| 827 | STRUCT_P(zend_uint, refcount) |
|---|
| 828 | UNFIXPOINTER(zend_uint, refcount) |
|---|
| 829 | IFSTORE(`dst->refcount[0] = 1;') |
|---|
| 830 | |
|---|
| 831 | #ifdef ZEND_ENGINE_2_4 |
|---|
| 832 | dnl before copying opcodes |
|---|
| 833 | DISPATCH(int, last_literal) |
|---|
| 834 | STRUCT_ARRAY(last_literal, zend_literal, literals) |
|---|
| 835 | #endif |
|---|
| 836 | |
|---|
| 837 | pushdef(`AFTER_ALLOC', `IFCOPY(` |
|---|
| 838 | #ifndef NDEBUG |
|---|
| 839 | processor->active_op_array_dst = dst; |
|---|
| 840 | processor->active_op_array_src = src; |
|---|
| 841 | #endif |
|---|
| 842 | processor->active_opcodes_dst = dst->opcodes; |
|---|
| 843 | processor->active_opcodes_src = src->opcodes; |
|---|
| 844 | ')') |
|---|
| 845 | STRUCT_ARRAY(last, zend_op, opcodes) |
|---|
| 846 | popdef(`AFTER_ALLOC') |
|---|
| 847 | DISPATCH(zend_uint, last) |
|---|
| 848 | #ifndef ZEND_ENGINE_2_4 |
|---|
| 849 | IFCOPY(`dst->size = src->last;DONE(size)', `DISPATCH(zend_uint, size)') |
|---|
| 850 | #endif |
|---|
| 851 | |
|---|
| 852 | #ifdef IS_CV |
|---|
| 853 | STRUCT_ARRAY(last_var, zend_compiled_variable, vars) |
|---|
| 854 | DISPATCH(int, last_var) |
|---|
| 855 | # ifndef ZEND_ENGINE_2_4 |
|---|
| 856 | IFCOPY(`dst->size_var = src->last_var;DONE(size_var)', `DISPATCH(zend_uint, size_var)') |
|---|
| 857 | # endif |
|---|
| 858 | #else |
|---|
| 859 | dnl zend_cv.m4 is illegal to be made public, don not ask me for it |
|---|
| 860 | IFDASM(` |
|---|
| 861 | sinclude(srcdir`/processor/zend_cv.m4') |
|---|
| 862 | ') |
|---|
| 863 | #endif |
|---|
| 864 | |
|---|
| 865 | DISPATCH(zend_uint, T) |
|---|
| 866 | |
|---|
| 867 | STRUCT_ARRAY(last_brk_cont, zend_brk_cont_element, brk_cont_array) |
|---|
| 868 | DISPATCH(zend_uint, last_brk_cont) |
|---|
| 869 | #ifndef ZEND_ENGINE_2_4 |
|---|
| 870 | DISPATCH(zend_uint, current_brk_cont) |
|---|
| 871 | #endif |
|---|
| 872 | #ifndef ZEND_ENGINE_2 |
|---|
| 873 | DISPATCH(zend_bool, uses_globals) |
|---|
| 874 | #endif |
|---|
| 875 | |
|---|
| 876 | #ifdef ZEND_ENGINE_2 |
|---|
| 877 | STRUCT_ARRAY(last_try_catch, zend_try_catch_element, try_catch_array) |
|---|
| 878 | DISPATCH(int, last_try_catch) |
|---|
| 879 | #endif |
|---|
| 880 | |
|---|
| 881 | STRUCT_P(HashTable, static_variables, HashTable_zval_ptr) |
|---|
| 882 | |
|---|
| 883 | #ifndef ZEND_ENGINE_2_4 |
|---|
| 884 | COPY(start_op) |
|---|
| 885 | DISPATCH(int, backpatch_count) |
|---|
| 886 | #endif |
|---|
| 887 | #ifdef ZEND_ENGINE_2_3 |
|---|
| 888 | DISPATCH(zend_uint, this_var) |
|---|
| 889 | #endif |
|---|
| 890 | |
|---|
| 891 | #ifndef ZEND_ENGINE_2_4 |
|---|
| 892 | DISPATCH(zend_bool, done_pass_two) |
|---|
| 893 | #endif |
|---|
| 894 | /* 5.0 <= ver < 5.3 */ |
|---|
| 895 | #if defined(ZEND_ENGINE_2) && !defined(ZEND_ENGINE_2_3) |
|---|
| 896 | DISPATCH(zend_bool, uses_this) |
|---|
| 897 | #endif |
|---|
| 898 | |
|---|
| 899 | IFRESTORE(`dst->filename = processor->entry_src->filepath;DONE(filename)', `PROC_STRING(filename)') |
|---|
| 900 | #ifdef IS_UNICODE |
|---|
| 901 | IFRESTORE(` |
|---|
| 902 | COPY(script_encoding) |
|---|
| 903 | ', ` |
|---|
| 904 | PROC_STRING(script_encoding) |
|---|
| 905 | ') |
|---|
| 906 | #endif |
|---|
| 907 | #ifdef ZEND_ENGINE_2 |
|---|
| 908 | DISPATCH(zend_uint, line_start) |
|---|
| 909 | DISPATCH(zend_uint, line_end) |
|---|
| 910 | DISPATCH(int, doc_comment_len) |
|---|
| 911 | PROC_ZSTRING_L(, doc_comment, doc_comment_len) |
|---|
| 912 | #endif |
|---|
| 913 | #ifdef ZEND_COMPILE_DELAYED_BINDING |
|---|
| 914 | DISPATCH(zend_uint, early_binding); |
|---|
| 915 | #endif |
|---|
| 916 | |
|---|
| 917 | /* reserved */ |
|---|
| 918 | DONE(reserved) |
|---|
| 919 | #if defined(HARDENING_PATCH) && HARDENING_PATCH |
|---|
| 920 | DISPATCH(zend_bool, created_by_eval) |
|---|
| 921 | #endif |
|---|
| 922 | #ifdef ZEND_ENGINE_2_4 |
|---|
| 923 | COPYNULL(run_time_cache) |
|---|
| 924 | COPYNULL(last_cache_slot) |
|---|
| 925 | #endif |
|---|
| 926 | } while (0); |
|---|
| 927 | IFRESTORE(`xc_fix_op_array_info(processor->entry_src, processor->php_src, dst, !shallow_copy, op_array_info TSRMLS_CC);') |
|---|
| 928 | |
|---|
| 929 | #ifdef ZEND_ENGINE_2 |
|---|
| 930 | dnl mark it as -1 on store, and lookup parent on restore |
|---|
| 931 | IFSTORE(`dst->prototype = (processor->active_class_entry_src && src->prototype) ? (zend_function *) -1 : NULL; DONE(prototype)', ` |
|---|
| 932 | IFRESTORE(`do { |
|---|
| 933 | zend_function *parent; |
|---|
| 934 | if (src->prototype != NULL |
|---|
| 935 | && zend_u_hash_find(&(processor->active_class_entry_dst->parent->function_table), |
|---|
| 936 | UG(unicode) ? IS_UNICODE : IS_STRING, |
|---|
| 937 | src->function_name, xc_zstrlen(UG(unicode) ? IS_UNICODE : IS_STRING, src->function_name) + 1, |
|---|
| 938 | (void **) &parent) == SUCCESS) { |
|---|
| 939 | /* see do_inherit_method_check() */ |
|---|
| 940 | if ((parent->common.fn_flags & ZEND_ACC_ABSTRACT)) { |
|---|
| 941 | dst->prototype = parent; |
|---|
| 942 | } else if (!(parent->common.fn_flags & ZEND_ACC_CTOR) || (parent->common.prototype && (parent->common.prototype->common.scope->ce_flags & ZEND_ACC_INTERFACE))) { |
|---|
| 943 | /* ctors only have a prototype if it comes from an interface */ |
|---|
| 944 | dst->prototype = parent->common.prototype ? parent->common.prototype : parent; |
|---|
| 945 | } |
|---|
| 946 | else { |
|---|
| 947 | dst->prototype = NULL; |
|---|
| 948 | } |
|---|
| 949 | } |
|---|
| 950 | else { |
|---|
| 951 | dst->prototype = NULL; |
|---|
| 952 | } |
|---|
| 953 | DONE(prototype) |
|---|
| 954 | } while (0); |
|---|
| 955 | ', ` |
|---|
| 956 | COPYNULL(prototype) |
|---|
| 957 | ') |
|---|
| 958 | ') |
|---|
| 959 | |
|---|
| 960 | #endif |
|---|
| 961 | |
|---|
| 962 | #ifdef ZEND_ENGINE_2 |
|---|
| 963 | PROC_CLASS_ENTRY_P(scope) |
|---|
| 964 | IFCOPY(` |
|---|
| 965 | if (src->scope) { |
|---|
| 966 | xc_fix_method(processor, dst TSRMLS_CC); |
|---|
| 967 | } |
|---|
| 968 | ') |
|---|
| 969 | #endif |
|---|
| 970 | |
|---|
| 971 | IFRESTORE(` |
|---|
| 972 | if (xc_have_op_array_ctor) { |
|---|
| 973 | zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) xc_zend_extension_op_array_ctor_handler, dst TSRMLS_CC); |
|---|
| 974 | } |
|---|
| 975 | ') |
|---|
| 976 | ') |
|---|
| 977 | dnl }}} |
|---|
| 978 | |
|---|
| 979 | #ifdef HAVE_XCACHE_CONSTANT |
|---|
| 980 | DEF_STRUCT_P_FUNC(`xc_constinfo_t', , `dnl {{{ |
|---|
| 981 | DISPATCH(zend_uint, key_size) |
|---|
| 982 | #ifdef IS_UNICODE |
|---|
| 983 | DISPATCH(zend_uchar, type) |
|---|
| 984 | #endif |
|---|
| 985 | IFRESTORE(`COPY(key)', ` |
|---|
| 986 | PROC_ZSTRING_N(type, key, key_size) |
|---|
| 987 | ') |
|---|
| 988 | DISPATCH(ulong, h) |
|---|
| 989 | STRUCT(zend_constant, constant) |
|---|
| 990 | ') |
|---|
| 991 | dnl }}} |
|---|
| 992 | #endif |
|---|
| 993 | DEF_STRUCT_P_FUNC(`xc_op_array_info_t', , `dnl {{{ |
|---|
| 994 | #ifdef ZEND_ENGINE_2_4 |
|---|
| 995 | DISPATCH(zend_uint, literalinfo_cnt) |
|---|
| 996 | DISPATCH_ARRAY(literalinfo_cnt, int, literalinfos) |
|---|
| 997 | #else |
|---|
| 998 | DISPATCH(zend_uint, oplineinfo_cnt) |
|---|
| 999 | DISPATCH_ARRAY(oplineinfo_cnt, int, oplineinfos) |
|---|
| 1000 | #endif |
|---|
| 1001 | ') |
|---|
| 1002 | dnl }}} |
|---|
| 1003 | DEF_STRUCT_P_FUNC(`xc_funcinfo_t', , `dnl {{{ |
|---|
| 1004 | DISPATCH(zend_uint, key_size) |
|---|
| 1005 | #ifdef IS_UNICODE |
|---|
| 1006 | DISPATCH(zend_uchar, type) |
|---|
| 1007 | #endif |
|---|
| 1008 | IFRESTORE(`COPY(key)', ` |
|---|
| 1009 | PROC_ZSTRING_N(type, key, key_size) |
|---|
| 1010 | ') |
|---|
| 1011 | DISPATCH(ulong, h) |
|---|
| 1012 | IFRESTORE(`COPY(op_array_info)', ` |
|---|
| 1013 | STRUCT(xc_op_array_info_t, op_array_info) |
|---|
| 1014 | ') |
|---|
| 1015 | IFRESTORE(` |
|---|
| 1016 | processor->active_op_array_infos_src = &src->op_array_info; |
|---|
| 1017 | processor->active_op_array_index = 0; |
|---|
| 1018 | ') |
|---|
| 1019 | STRUCT(zend_function, func) |
|---|
| 1020 | ') |
|---|
| 1021 | dnl }}} |
|---|
| 1022 | DEF_STRUCT_P_FUNC(`xc_classinfo_t', , `dnl {{{ |
|---|
| 1023 | DISPATCH(zend_uint, key_size) |
|---|
| 1024 | #ifdef IS_UNICODE |
|---|
| 1025 | DISPATCH(zend_uchar, type) |
|---|
| 1026 | #endif |
|---|
| 1027 | IFRESTORE(`COPY(key)', ` |
|---|
| 1028 | PROC_ZSTRING_N(type, key, key_size) |
|---|
| 1029 | ') |
|---|
| 1030 | DISPATCH(ulong, h) |
|---|
| 1031 | DISPATCH(zend_uint, methodinfo_cnt) |
|---|
| 1032 | IFRESTORE(`COPY(methodinfos)', ` |
|---|
| 1033 | STRUCT_ARRAY(methodinfo_cnt, xc_op_array_info_t, methodinfos) |
|---|
| 1034 | ') |
|---|
| 1035 | IFRESTORE(` |
|---|
| 1036 | processor->active_op_array_infos_src = src->methodinfos; |
|---|
| 1037 | processor->active_op_array_index = 0; |
|---|
| 1038 | ') |
|---|
| 1039 | #ifdef ZEND_ENGINE_2 |
|---|
| 1040 | STRUCT_P(zend_class_entry, cest) |
|---|
| 1041 | #else |
|---|
| 1042 | STRUCT(zend_class_entry, cest) |
|---|
| 1043 | #endif |
|---|
| 1044 | #ifndef ZEND_COMPILE_DELAYED_BINDING |
|---|
| 1045 | DISPATCH(int, oplineno) |
|---|
| 1046 | #endif |
|---|
| 1047 | ') |
|---|
| 1048 | dnl }}} |
|---|
| 1049 | #ifdef ZEND_ENGINE_2_1 |
|---|
| 1050 | DEF_STRUCT_P_FUNC(`xc_autoglobal_t', , `dnl {{{ |
|---|
| 1051 | DISPATCH(zend_uint, key_len) |
|---|
| 1052 | #ifdef IS_UNICODE |
|---|
| 1053 | DISPATCH(zend_uchar, type) |
|---|
| 1054 | #endif |
|---|
| 1055 | IFRESTORE(`COPY(key)', ` |
|---|
| 1056 | PROC_ZSTRING_L(type, key, key_len) |
|---|
| 1057 | ') |
|---|
| 1058 | DISPATCH(ulong, h) |
|---|
| 1059 | ') |
|---|
| 1060 | dnl }}} |
|---|
| 1061 | #endif |
|---|
| 1062 | #ifdef E_STRICT |
|---|
| 1063 | DEF_STRUCT_P_FUNC(`xc_compilererror_t', , `dnl {{{ |
|---|
| 1064 | DISPATCH(int, type) |
|---|
| 1065 | DISPATCH(uint, lineno) |
|---|
| 1066 | DISPATCH(int, error_len) |
|---|
| 1067 | PROC_STRING_L(error, error_len) |
|---|
| 1068 | ') |
|---|
| 1069 | dnl }}} |
|---|
| 1070 | #endif |
|---|
| 1071 | DEF_STRUCT_P_FUNC(`xc_entry_data_php_t', , `dnl {{{ |
|---|
| 1072 | IFCOPY(` |
|---|
| 1073 | processor->php_dst = dst; |
|---|
| 1074 | processor->php_src = src; |
|---|
| 1075 | ') |
|---|
| 1076 | |
|---|
| 1077 | DISPATCH(xc_hash_value_t, hvalue) |
|---|
| 1078 | /* skip */ |
|---|
| 1079 | DONE(next) |
|---|
| 1080 | COPY(cache) |
|---|
| 1081 | DISPATCH(xc_md5sum_t, md5) |
|---|
| 1082 | DISPATCH(zend_ulong, refcount) |
|---|
| 1083 | |
|---|
| 1084 | DISPATCH(size_t, sourcesize) |
|---|
| 1085 | DISPATCH(zend_ulong, hits) |
|---|
| 1086 | DISPATCH(size_t, size) |
|---|
| 1087 | |
|---|
| 1088 | IFRESTORE(`COPY(op_array_info)', ` |
|---|
| 1089 | STRUCT(xc_op_array_info_t, op_array_info) |
|---|
| 1090 | ') |
|---|
| 1091 | IFRESTORE(` |
|---|
| 1092 | processor->active_op_array_infos_src = &dst->op_array_info; |
|---|
| 1093 | processor->active_op_array_index = 0; |
|---|
| 1094 | ') |
|---|
| 1095 | STRUCT_P(zend_op_array, op_array) |
|---|
| 1096 | |
|---|
| 1097 | #ifdef HAVE_XCACHE_CONSTANT |
|---|
| 1098 | DISPATCH(zend_uint, constinfo_cnt) |
|---|
| 1099 | STRUCT_ARRAY(constinfo_cnt, xc_constinfo_t, constinfos) |
|---|
| 1100 | #endif |
|---|
| 1101 | |
|---|
| 1102 | DISPATCH(zend_uint, funcinfo_cnt) |
|---|
| 1103 | STRUCT_ARRAY(funcinfo_cnt, xc_funcinfo_t, funcinfos) |
|---|
| 1104 | |
|---|
| 1105 | DISPATCH(zend_uint, classinfo_cnt) |
|---|
| 1106 | STRUCT_ARRAY(classinfo_cnt, xc_classinfo_t, classinfos, , IFRESTORE(`processor->active_class_index')) |
|---|
| 1107 | #ifdef ZEND_ENGINE_2_1 |
|---|
| 1108 | DISPATCH(zend_uint, autoglobal_cnt) |
|---|
| 1109 | IFRESTORE(` |
|---|
| 1110 | COPY(autoglobals) |
|---|
| 1111 | ', ` |
|---|
| 1112 | STRUCT_ARRAY(autoglobal_cnt, xc_autoglobal_t, autoglobals) |
|---|
| 1113 | ') |
|---|
| 1114 | #endif |
|---|
| 1115 | #ifdef E_STRICT |
|---|
| 1116 | DISPATCH(zend_uint, compilererror_cnt) |
|---|
| 1117 | IFRESTORE(` |
|---|
| 1118 | COPY(compilererrors) |
|---|
| 1119 | ', ` |
|---|
| 1120 | STRUCT_ARRAY(compilererror_cnt, xc_compilererror_t, compilererrors) |
|---|
| 1121 | ') |
|---|
| 1122 | #endif |
|---|
| 1123 | #ifndef ZEND_COMPILE_DELAYED_BINDING |
|---|
| 1124 | DISPATCH(zend_bool, have_early_binding) |
|---|
| 1125 | #endif |
|---|
| 1126 | DISPATCH(zend_bool, have_references) |
|---|
| 1127 | ') |
|---|
| 1128 | dnl }}} |
|---|
| 1129 | DEF_STRUCT_P_FUNC(`xc_entry_data_var_t', , `dnl {{{ |
|---|
| 1130 | IFDPRINT(`INDENT()`'fprintf(stderr, "zval:value");') |
|---|
| 1131 | STRUCT_P_EX(zval_ptr, dst->value, src->value, `value', `', `&') |
|---|
| 1132 | DISPATCH(zend_bool, have_references) |
|---|
| 1133 | DONE(value) |
|---|
| 1134 | ') |
|---|
| 1135 | dnl }}} |
|---|
| 1136 | dnl {{{ xc_entry_t |
|---|
| 1137 | DEF_STRUCT_P_FUNC(`xc_entry_t', , ` |
|---|
| 1138 | DISPATCH(xc_entry_type_t, type) |
|---|
| 1139 | DISPATCH(size_t, size) |
|---|
| 1140 | |
|---|
| 1141 | DISPATCH(xc_hash_value_t, hvalue) |
|---|
| 1142 | COPY(cache) |
|---|
| 1143 | /* skip */ |
|---|
| 1144 | DONE(next) |
|---|
| 1145 | |
|---|
| 1146 | IFSTORE(`dst->refcount = 0; DONE(refcount)', `DISPATCH(long, refcount)') |
|---|
| 1147 | |
|---|
| 1148 | DISPATCH(time_t, ctime) |
|---|
| 1149 | DISPATCH(time_t, atime) |
|---|
| 1150 | DISPATCH(time_t, dtime) |
|---|
| 1151 | DISPATCH(long, ttl) |
|---|
| 1152 | DISPATCH(zend_ulong, hits) |
|---|
| 1153 | #ifdef IS_UNICODE |
|---|
| 1154 | DISPATCH(zend_uchar, name_type) |
|---|
| 1155 | #endif |
|---|
| 1156 | dnl {{{ name |
|---|
| 1157 | DISABLECHECK(` |
|---|
| 1158 | #ifdef IS_UNICODE |
|---|
| 1159 | if (src->name_type == IS_UNICODE) { |
|---|
| 1160 | DISPATCH(int32_t, name.ustr.len) |
|---|
| 1161 | } |
|---|
| 1162 | else { |
|---|
| 1163 | DISPATCH(int, name.str.len) |
|---|
| 1164 | } |
|---|
| 1165 | #else |
|---|
| 1166 | DISPATCH(int, name.str.len) |
|---|
| 1167 | #endif |
|---|
| 1168 | IFRESTORE(`COPY(name.str.val)', ` |
|---|
| 1169 | #ifdef IS_UNICODE |
|---|
| 1170 | PROC_ZSTRING_L(name_type, name.uni.val, name.uni.len) |
|---|
| 1171 | #else |
|---|
| 1172 | PROC_STRING_L(name.str.val, name.str.len) |
|---|
| 1173 | #endif |
|---|
| 1174 | ') |
|---|
| 1175 | ') |
|---|
| 1176 | DONE(name) |
|---|
| 1177 | dnl }}} |
|---|
| 1178 | |
|---|
| 1179 | dnl {{{ data |
|---|
| 1180 | DISABLECHECK(` |
|---|
| 1181 | switch (src->type) { |
|---|
| 1182 | case XC_TYPE_PHP: |
|---|
| 1183 | IFCALCCOPY(`COPY(data.php)', `STRUCT_P(xc_entry_data_php_t, data.php)') |
|---|
| 1184 | break; |
|---|
| 1185 | |
|---|
| 1186 | case XC_TYPE_VAR: |
|---|
| 1187 | STRUCT_P(xc_entry_data_var_t, data.var) |
|---|
| 1188 | break; |
|---|
| 1189 | |
|---|
| 1190 | default: |
|---|
| 1191 | assert(0); |
|---|
| 1192 | } |
|---|
| 1193 | ') |
|---|
| 1194 | DONE(data) |
|---|
| 1195 | dnl }}} |
|---|
| 1196 | DISPATCH(time_t, mtime) |
|---|
| 1197 | #ifdef HAVE_INODE |
|---|
| 1198 | DISPATCH(int, device) |
|---|
| 1199 | DISPATCH(int, inode) |
|---|
| 1200 | #endif |
|---|
| 1201 | |
|---|
| 1202 | if (src->type == XC_TYPE_PHP) { |
|---|
| 1203 | DISPATCH(int, filepath_len) |
|---|
| 1204 | IFRESTORE(`COPY(filepath)', `PROC_STRING_L(filepath, filepath_len)') |
|---|
| 1205 | DISPATCH(int, dirpath_len) |
|---|
| 1206 | IFRESTORE(`COPY(dirpath)', `PROC_STRING_L(dirpath, dirpath_len)') |
|---|
| 1207 | #ifdef IS_UNICODE |
|---|
| 1208 | DISPATCH(int, ufilepath_len) |
|---|
| 1209 | IFRESTORE(`COPY(ufilepath)', `PROC_USTRING_L(ufilepath, ufilepath_len)') |
|---|
| 1210 | DISPATCH(int, udirpath_len) |
|---|
| 1211 | IFRESTORE(`COPY(udirpath)', `PROC_USTRING_L(udirpath, udirpath_len)') |
|---|
| 1212 | #endif |
|---|
| 1213 | } |
|---|
| 1214 | else { |
|---|
| 1215 | DONE(filepath_len) |
|---|
| 1216 | DONE(filepath) |
|---|
| 1217 | DONE(dirpath_len) |
|---|
| 1218 | DONE(dirpath) |
|---|
| 1219 | #ifdef IS_UNICODE |
|---|
| 1220 | DONE(ufilepath_len) |
|---|
| 1221 | DONE(ufilepath) |
|---|
| 1222 | DONE(udirpath_len) |
|---|
| 1223 | DONE(udirpath) |
|---|
| 1224 | #endif |
|---|
| 1225 | } |
|---|
| 1226 | ') |
|---|
| 1227 | dnl }}} |
|---|
| 1228 | dnl ==================================================== |
|---|