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