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