Changeset 344 for eaccelerator/trunk/ea_restore.c
- Timestamp:
- 06/19/08 18:01:31 (7 months ago)
- Files:
-
- eaccelerator/trunk/ea_restore.c (modified) (33 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
eaccelerator/trunk/ea_restore.c
r331 r344 36 36 #include "zend_API.h" 37 37 #include "zend_extensions.h" 38 #ifdef ZEND_ENGINE_2_139 38 #include "zend_vm.h" 40 #endif41 39 42 40 #ifndef INCOMPLETE_CLASS … … 52 50 #endif 53 51 54 #ifdef ZEND_ENGINE_255 52 /* pointer to the properties_info hashtable destructor */ 56 53 dtor_func_t properties_info_dtor = NULL; … … 72 69 zend_hash_destroy(&dummy_class_entry.constants_table); 73 70 zend_hash_destroy(&dummy_class_entry.properties_info); 74 # ifdef ZEND_ENGINE_2_175 71 zend_hash_destroy(&dummy_class_entry.default_static_members); 76 # endif77 # if defined(ZEND_ENGINE_2) && !defined(ZEND_ENGINE_2_1)78 zend_hash_destroy(dummy_class_entry.static_members);79 FREE_HASHTABLE(dummy_class_entry.static_members);80 # endif81 72 return property_dtor; 82 73 } 83 #endif84 74 85 75 /******************************************************************************/ … … 92 82 fixup_hash(base, from, (fixup_bucket_t)fixup_zval TSRMLS_CC) 93 83 94 #ifdef ZEND_ENGINE_295 84 static void fixup_property_info(char *base, zend_property_info * from TSRMLS_DC) 96 85 { 97 86 FIXUP(base, from->name); 98 #ifdef ZEND_ENGINE_2_199 87 FIXUP(base, from->doc_comment); 100 #endif 101 } 102 #endif 88 } 103 89 104 90 static void fixup_hash(char *base, HashTable * source, … … 165 151 zend_op *end; 166 152 167 #ifdef ZEND_ENGINE_2168 153 if (from->num_args > 0) { 169 154 zend_uint i; … … 174 159 } 175 160 } 176 #else177 FIXUP(base, from->arg_types);178 #endif179 161 FIXUP(base, from->function_name); 180 #ifdef ZEND_ENGINE_2181 162 FIXUP(base, from->scope_name); 182 #endif183 163 if (from->type == ZEND_INTERNAL_FUNCTION) { 184 164 return; … … 200 180 if (opline->op2.op_type == IS_CONST) 201 181 fixup_zval(base, &opline->op2.u.constant TSRMLS_CC); 202 #ifdef ZEND_ENGINE_2203 182 switch (opline->opcode) { 204 183 case ZEND_JMP: … … 212 191 break; 213 192 } 214 # ifdef ZEND_ENGINE_2_1215 193 ZEND_VM_SET_OPCODE_HANDLER(opline); 216 # elif defined(ZEND_ENGINE_2)217 opline->handler = zend_opcode_handlers[opline->opcode];218 # else219 opline->handler = get_opcode_handler(opline->opcode TSRMLS_CC);220 # endif221 222 #endif223 194 } 224 195 EAG(compress) = 1; 225 196 } 226 197 FIXUP(base, from->brk_cont_array); 227 #ifdef ZEND_ENGINE_2228 198 FIXUP(base, from->try_catch_array); 229 #endif230 199 if (from->static_variables != NULL) { 231 200 FIXUP(base, from->static_variables); 232 201 fixup_zval_hash(base, from->static_variables); 233 202 } 234 #ifdef ZEND_ENGINE_2_1235 203 if (from->vars != NULL) { 236 204 int i; … … 240 208 } 241 209 } 242 #endif243 210 FIXUP(base, from->filename); 244 211 #ifdef INCLUDE_DOC_COMMENTS 245 #ifdef ZEND_ENGINE_2246 212 FIXUP(base, from->doc_comment); 247 #endif248 213 #endif 249 214 } … … 253 218 FIXUP(base, from->name); 254 219 FIXUP(base, from->parent); 255 #ifdef ZEND_ENGINE_2256 220 FIXUP(base, from->filename); 257 221 fixup_zval_hash(base, &from->constants_table); … … 259 223 fixup_hash(base, &from->properties_info, 260 224 (fixup_bucket_t) fixup_property_info TSRMLS_CC); 261 # ifdef ZEND_ENGINE_2_1262 225 fixup_zval_hash(base, &from->default_static_members); 263 226 if (from->static_members != NULL) { … … 267 230 } 268 231 } 269 # else270 if (from->static_members != NULL) {271 FIXUP(base, from->static_members);272 fixup_zval_hash(base, from->static_members);273 }274 # endif275 #else276 fixup_zval_hash(base, &from->default_properties);277 #endif278 232 fixup_hash(base, &from->function_table,(fixup_bucket_t) fixup_op_array TSRMLS_CC); 279 233 } … … 433 387 void *ptr; 434 388 } function; 435 #ifdef ZEND_ENGINE_2436 389 int fname_len = 0; 437 390 char *fname_lc = NULL; 438 #endif439 391 440 392 DBG(ea_debug_pad, (EA_DEBUG TSRMLS_CC)); … … 458 410 } 459 411 to->type = from->type; 460 #ifdef ZEND_ENGINE_2461 412 to->num_args = from->num_args; 462 413 to->required_num_args = from->required_num_args; 463 414 to->arg_info = from->arg_info; 464 415 to->pass_rest_by_reference = from->pass_rest_by_reference; 465 #else466 to->arg_types = from->arg_types;467 #endif468 416 to->function_name = from->function_name; 469 417 470 #ifdef ZEND_ENGINE_2471 418 if (to->function_name) { 472 419 fname_len = strlen(to->function_name); … … 538 485 DBG(ea_debug_printf, (EA_DEBUG, "[%d] %s's scope is '%s'\n", getpid(), 539 486 from->function_name ? from->function_name : "(top)", to->scope ? to->scope->name : "NULL")); 540 #endif541 487 if (from->type == ZEND_INTERNAL_FUNCTION) { 542 488 zend_class_entry *class_entry = EAG(class_entry); … … 551 497 if (class_entry != NULL && class_entry->parent != NULL && 552 498 zend_hash_find(&class_entry->parent->function_table, 553 #ifdef ZEND_ENGINE_2554 499 fname_lc, fname_len + 1, 555 #else556 to->function_name, strlen(to->function_name) + 1,557 #endif558 500 &function.ptr) == SUCCESS && function.v->type == ZEND_INTERNAL_FUNCTION) { 559 501 DBG(ea_debug_pad, (EA_DEBUG TSRMLS_CC)); … … 567 509 DBG(ea_debug_printf, (EA_DEBUG, "[%d] can't find\n", getpid())); 568 510 } 569 #ifdef ZEND_ENGINE_2570 511 /* hrak: slight memleak here. dont forget to free the lowercase function name! */ 571 512 if (fname_lc != NULL) { … … 576 517 /* this gets set by zend_do_inheritance */ 577 518 to->prototype = NULL; 578 #endif579 519 return to; 580 520 } 581 #ifdef ZEND_ENGINE_2582 521 /* hrak: slight memleak here. dont forget to free the lowercase function name! */ 583 522 if (fname_lc != NULL) { 584 523 efree(fname_lc); 585 524 } 586 #endif587 525 to->opcodes = from->opcodes; 588 526 to->last = to->size = from->last; … … 599 537 to->filename = from->filename; 600 538 601 #ifdef ZEND_ENGINE_2602 539 to->try_catch_array = from->try_catch_array; 603 540 to->last_try_catch = from->last_try_catch; … … 613 550 to->doc_comment = NULL; 614 551 #endif 615 #else616 to->uses_globals = from->uses_globals;617 #endif618 552 if (from->static_variables) { 619 553 to->static_variables = restore_zval_hash(NULL, from->static_variables); 620 554 to->static_variables->pDestructor = ZVAL_PTR_DTOR; 621 #ifndef ZEND_ENGINE_2622 555 if (EAG(class_entry) != NULL) { 623 556 Bucket *p = to->static_variables->pListHead; … … 627 560 } 628 561 } 629 #endif 630 } 631 632 #ifdef ZEND_ENGINE_2_1 562 } 563 633 564 to->vars = from->vars; 634 565 to->last_var = from->last_var; 635 566 to->size_var = 0; 636 #endif637 567 638 568 /* disable deletion in destroy_op_array */ … … 648 578 } 649 579 650 #ifdef ZEND_ENGINE_2651 580 static zend_property_info *restore_property_info(zend_property_info * 652 581 from TSRMLS_DC) … … 656 585 to->name = emalloc(from->name_length + 1); 657 586 memcpy(to->name, from->name, from->name_length + 1); 658 # ifdef ZEND_ENGINE_2_1 659 # ifdef INCLUDE_DOC_COMMENTS 587 #ifdef INCLUDE_DOC_COMMENTS 660 588 if (from->doc_comment != NULL) { 661 589 to->doc_comment = emalloc(from->doc_comment_len + 1); 662 590 memcpy(to->doc_comment, from->doc_comment, from->doc_comment_len + 1); 663 591 } 664 # else 665 to->doc_comment_len = 0; 666 to->doc_comment = NULL; 667 # endif 668 # ifdef ZEND_ENGINE_2_2 592 # ifdef ZEND_ENGINE_2_2 669 593 to->ce = EAG(class_entry); 670 # endif671 # endif594 # endif 595 #endif 672 596 return to; 673 597 } 674 #endif675 598 676 599 /* restore the parent class with the given name for the given class */ 677 600 static void restore_class_parent(char *parent, int len, zend_class_entry * to TSRMLS_DC) 678 601 { 679 #ifdef ZEND_ENGINE_2680 602 zend_class_entry** parent_ptr = NULL; 681 603 if (zend_lookup_class(parent, len, &parent_ptr TSRMLS_CC) != SUCCESS) 682 #else683 char *name_lc = estrndup(parent, len);684 zend_str_tolower(name_lc, len);685 if (zend_hash_find(CG(class_table), (void *) name_lc, len + 1, (void **) &to->parent) != SUCCESS)686 #endif687 604 { 688 605 ea_debug_error("[%d] EACCELERATOR can't restore parent class \"%s\" of class \"%s\"\n", getpid(), (char *) parent, to->name); … … 690 607 } else { 691 608 /* parent found */ 692 #ifdef ZEND_ENGINE_2693 609 to->parent = *parent_ptr; 694 #endif695 610 DBG(ea_debug_printf, (EA_DEBUG, "restore_class_parent: found parent %s..\n", to->parent->name)); 696 611 DBG(ea_debug_printf, (EA_DEBUG, "restore_class_parent: parent type=%d child type=%d\n", to->parent->type, to->type)); 697 612 } 698 #ifndef ZEND_ENGINE_2 699 efree(name_lc); 700 #endif 701 } 702 703 #ifdef ZEND_ENGINE_2 613 } 614 704 615 static void restore_class_methods(zend_class_entry * to TSRMLS_DC) 705 616 { … … 738 649 memcmp(fname_lc, ZEND_SET_FUNC_NAME, sizeof(ZEND_SET_FUNC_NAME)) == 0) 739 650 to->__set = f; 740 # ifdef ZEND_ENGINE_2_1741 651 else if (fname_len == sizeof(ZEND_UNSET_FUNC_NAME) - 1 && 742 652 memcmp(fname_lc, ZEND_UNSET_FUNC_NAME, sizeof(ZEND_UNSET_FUNC_NAME)) == 0) … … 745 655 memcmp(fname_lc, ZEND_ISSET_FUNC_NAME, sizeof(ZEND_ISSET_FUNC_NAME)) == 0) 746 656 to->__isset = f; 747 # endif748 657 else if (fname_len == sizeof(ZEND_CALL_FUNC_NAME) - 1 && 749 658 memcmp(fname_lc, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME)) == 0) … … 766 675 efree(cname_lc); 767 676 } 768 #endif769 677 770 678 static zend_class_entry *restore_class_entry(zend_class_entry * to, ea_class_entry * from TSRMLS_DC) … … 792 700 EAG(class_entry) = to; 793 701 794 #ifdef ZEND_ENGINE_2795 702 to->ce_flags = from->ce_flags; 796 703 to->num_interfaces = from->num_interfaces; … … 828 735 to->properties_info.pDestructor = properties_info_dtor; 829 736 830 # ifdef ZEND_ENGINE_2_1831 737 /* restore default_static_members */ 832 738 restore_zval_hash(&to->default_static_members, &from->default_static_members); … … 840 746 to->static_members = &(to->default_static_members); 841 747 } 842 # else843 if (from->static_members != NULL) {844 ALLOC_HASHTABLE(to->static_members);845 restore_zval_hash(to->static_members, from->static_members);846 to->static_members->pDestructor = ZVAL_PTR_DTOR;847 }848 # endif849 #else850 to->refcount = emalloc(sizeof(*to->refcount));851 *to->refcount = 1;852 853 restore_zval_hash(&to->default_properties, &from->default_properties);854 to->default_properties.pDestructor = ZVAL_PTR_DTOR;855 /* Clearing references */856 {857 Bucket *p = to->default_properties.pListHead;858 while (p != NULL) {859 ((zval *) (p->pDataPtr))->refcount = 1;860 p = p->pListNext;861 }862 }863 #endif864 748 865 749 if (from->parent != NULL) { … … 874 758 to->function_table.pDestructor = ZEND_FUNCTION_DTOR; 875 759 876 #ifdef ZEND_ENGINE_2877 760 restore_class_methods(to TSRMLS_CC); 878 #endif879 761 880 762 if (to->parent) { 881 #ifdef ZEND_ENGINE_2882 763 zend_do_inheritance(to, to->parent TSRMLS_CC); 883 #else884 zend_do_inheritance(to, to->parent);885 #endif886 764 } 887 765 EAG(class_entry) = old; … … 904 782 CG(in_compilation) = 1; 905 783 CG(compiled_filename) = EAG(mem); 906 #ifdef ZEND_ENGINE_2907 784 CG(zend_lineno) = op_array.line_start; 908 #else909 CG(zend_lineno) = op_array.opcodes[0].lineno;910 #endif911 785 zend_error(E_ERROR, "Cannot redeclare %s()", p->htabkey); 912 786 } … … 919 793 void restore_class(ea_fc_entry * p TSRMLS_DC) 920 794 { 921 #ifdef ZEND_ENGINE_2922 795 zend_class_entry *ce; 923 #else924 zend_class_entry ce;925 #endif926 796 927 797 if ((p->htabkey[0] == '\000') && zend_hash_exists(CG(class_table), p->htabkey, p->htablen)) { 928 798 return; 929 799 } 930 #ifdef ZEND_ENGINE_2931 800 ce = restore_class_entry(NULL, (ea_class_entry *) p->fc TSRMLS_CC); 932 801 if (ce != NULL) 933 #else934 if (restore_class_entry(&ce, (ea_class_entry *) p->fc TSRMLS_CC) != NULL)935 #endif936 802 { 937 #ifdef ZEND_ENGINE_2938 803 if (zend_hash_add(CG(class_table), p->htabkey, p->htablen, &ce, sizeof(zend_class_entry *), NULL) == FAILURE) 939 #else940 if (zend_hash_add(CG(class_table), p->htabkey, p->htablen, &ce, sizeof(zend_class_entry), NULL) == FAILURE)941 #endif942 804 { 943 805 CG(in_compilation) = 1; 944 806 CG(compiled_filename) = EAG(mem); 945 #ifdef ZEND_ENGINE_2946 807 CG(zend_lineno) = ce->line_start; 947 #else948 CG(zend_lineno) = 0;949 #endif950 808 zend_error(E_ERROR, "Cannot redeclare class %s", p->htabkey); 951 809 }