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