Changeset 162
- Timestamp:
- 02/17/06 18:35:50 (3 years ago)
- Files:
-
- eaccelerator/trunk/AUTHORS (modified) (1 diff)
- eaccelerator/trunk/ChangeLog (modified) (2 diffs)
- eaccelerator/trunk/Makefile.in (modified) (1 diff)
- eaccelerator/trunk/content.c (modified) (1 diff)
- eaccelerator/trunk/debug.c (modified) (1 diff)
- eaccelerator/trunk/debug.h (modified) (1 diff)
- eaccelerator/trunk/ea_restore.c (modified) (28 diffs)
- eaccelerator/trunk/ea_restore.h (modified) (1 diff)
- eaccelerator/trunk/ea_store.c (modified) (20 diffs)
- eaccelerator/trunk/eaccelerator.c (modified) (7 diffs)
- eaccelerator/trunk/eaccelerator.h (modified) (3 diffs)
- eaccelerator/trunk/loader.c (modified) (1 diff)
- eaccelerator/trunk/opcodes.c (modified) (9 diffs)
- eaccelerator/trunk/optimize.c (modified) (14 diffs)
- eaccelerator/trunk/webui.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
eaccelerator/trunk/AUTHORS
r150 r162 2 2 - Franck Tabary <franck34 at users.sourceforge.net> 3 3 - Bart Vanbrabant <zoeloelip at users.sourceforge.net> 4 - Hans Rakers <hrak at users.sourceforge.net> 4 5 5 6 Inactive member(s) : eaccelerator/trunk/ChangeLog
r159 r162 1 2006-02-16 Bart Vanbrabant <bart.vanbrabant at zoeloelip.be> 2 3 * Merged PHP_5_1 branch with HEAD 4 5 2006-02-17 Hans Rakers <hans at parse dot nl> 6 7 * PHP_5_1: Some final fixes before merging to HEAD: 8 - Fixed bug #1410723 (handling of class constants by the optimizer) 9 - Fixed backwards compatibility with PHP < 5.1 10 This revision works pretty well in my testing environment, PHP-5.1 support 11 seems to be coming along quite well. Please test with your applications/ 12 in your environment and report back with your experiences or possible problems! 13 1 14 2006-02-15 Bart Vanbrabant <bart.vanbrabant at zoeloelip.be> 2 15 3 16 * Released version 0.9.4 17 18 2006-02-15 Hans Rakers <hans at parse dot nl> 19 20 * PHP_5_1: Fixes for five failing tests found using the test suite created by Bart 21 Tests that failed where: 22 -ctor_dtor_inheritance (failed because __construct, __destruct and __clone were not properly set) 23 -destructor_and_exceptions (failed because inheritance of parent methods was broken, fixed by making sure ea_store doesn't store methods outside scope) 24 -inheritance_002 (failed because __construct, __destruct and __clone were not properly set) 25 -private_members (failed because __construct, __destruct and __clone were not properly set) 26 -type_hinting_003 (failed because array_type_hint introduced in zend_arg_info in PHP-5.1 was ignored) 27 28 2006-02-14 Bart Vanbrabant <bart.vanbrabant at zoeloelip dot be> 29 30 * PHP_5_1: Changed cflags to -O2 from -O3 4 31 5 32 2006-02-09 Bart Vanbrabant <bart.vanbrabant at zoeloelip.be> … … 21 48 * Updated NEWS and bumped up version to 0.9.4-rc2 22 49 * Released 0.9.4-rc2 50 51 2006-02-07 Hans Rakers <hans at parse dot nl> 52 53 * PHP_5_1: Fix for problems with __autoload 54 * PHP_5_1: Fixed compile problems with thread-safe PHP 55 56 2006-02-06 Hans Rakers <hans at parse dot nl> 57 58 * PHP_5_1: Quite some major changes, including but probably not limited to: 59 -Fixed numerous memory leaks 60 -Fixed the handling of empty string variables (as in ""), causing "String is not zero-terminated" warnings when PHP is compiled with --enable-debug 61 -More fixes to the handling of static properties (access checking/inheritance) 62 -Inheritance on restore is now handled by zend_do_inheritance 63 -Fixed handling of ZEND_OP_DATA and ZEND_INIT_METHOD_CALL by the optimizer 64 -Cosmetic fixes (spelling etc.) 65 66 2006-01-16 Hans Rakers <hans at parse dot nl> 67 68 * PHP_5_1: Fix for bug #1401474 (and most likely some more php-5.1 related trouble) 69 static_members handling was incorrect. 70 71 2006-01-12 Hans Rakers <hans at parse dot nl> 72 73 * First batch of PHP-5.1 related changes committed to the newly created 74 PHP_5_1 branch. This is a work in progress, so YMMV. 23 75 24 76 2006-01-10 Bart Vanbrabant <bart.vanbrabant at zoeloelip.be> eaccelerator/trunk/Makefile.in
r134 r162 3 3 LTLIBRARY_SHARED_NAME = eaccelerator.la 4 4 5 EXTRA_CFLAGS = -O 35 EXTRA_CFLAGS = -O2 6 6 7 7 include $(top_srcdir)/build/dynlib.mk eaccelerator/trunk/content.c
r123 r162 594 594 eaccelerator_content_cache_place != eaccelerator_none) { 595 595 596 #ifndef ZEND_ENGINE_2_1 597 /* Doesn't work with php >= 5.1.0 */ 596 598 /* clean garbage */ 597 599 while (EG(garbage_ptr)) { 598 600 zval_ptr_dtor(&EG(garbage)[--EG(garbage_ptr)]); 599 601 } 602 #endif 600 603 601 604 eaccelerator_put(key, key_len, return_value, ttl, eaccelerator_content_cache_place TSRMLS_CC); eaccelerator/trunk/debug.c
r144 r162 291 291 } 292 292 293 /* 294 * This dumps a HashTable to debug output. Taken from zend_hash.c and slightly adapted. 295 */ 296 void ea_debug_hash_display(HashTable * ht) 297 { 298 Bucket *p; 299 uint i; 300 301 fprintf(F_fp, "ht->nTableSize: %d\n", ht->nTableSize); 302 fprintf(F_fp, "ht->nNumOfElements: %d\n", ht->nNumOfElements); 303 304 for (i = 0; i < ht->nTableSize; i++) { 305 p = ht->arBuckets[i]; 306 while (p != NULL) { 307 fprintf(F_fp, "%s <==> 0x%lX\n", p->arKey, p->h); 308 p = p->pNext; 309 } 310 } 311 312 p = ht->pListTail; 313 while (p != NULL) { 314 fprintf(F_fp, "%s <==> 0x%lX\n", p->arKey, p->h); 315 p = p->pListLast; 316 } 317 fflush(F_fp); 318 } 319 293 320 #endif /* #ifdef HAVE_EACCELERATOR */ eaccelerator/trunk/debug.h
r122 r162 72 72 long ea_debug_elapsed_time (struct timeval *tvstart); 73 73 74 void ea_debug_hash_display(HashTable * ht); 75 74 76 #endif /* INCLUDED_DEBUG_H */ eaccelerator/trunk/ea_restore.c
r127 r162 40 40 #include "zend_API.h" 41 41 #include "zend_extensions.h" 42 #ifdef ZEND_ENGINE_2_1 43 #include "zend_vm.h" 44 #endif 42 45 43 46 #ifndef INCOMPLETE_CLASS … … 70 73 71 74 zend_hash_destroy(&dummy_class_entry.default_properties); 75 zend_hash_destroy(&dummy_class_entry.function_table); 76 zend_hash_destroy(&dummy_class_entry.constants_table); 72 77 zend_hash_destroy(&dummy_class_entry.properties_info); 78 # ifdef ZEND_ENGINE_2_1 79 zend_hash_destroy(&dummy_class_entry.default_static_members); 80 # endif 81 # if defined(ZEND_ENGINE_2) && !defined(ZEND_ENGINE_2_1) 73 82 zend_hash_destroy(dummy_class_entry.static_members); 74 zend_hash_destroy(&dummy_class_entry.function_table); 75 FREE_HASHTABLE(dummy_class_entry.static_members); 76 zend_hash_destroy(&dummy_class_entry.constants_table); 77 83 FREE_HASHTABLE(dummy_class_entry.static_members); 84 # endif 78 85 return property_dtor; 79 86 } … … 93 100 { 94 101 FIXUP(from->name); 102 #ifdef ZEND_ENGINE_2_1 103 FIXUP(from->doc_comment); 104 #endif 95 105 } 96 106 #endif … … 222 232 break; 223 233 } 234 # ifdef ZEND_ENGINE_2_1 235 ZEND_VM_SET_OPCODE_HANDLER(opline); 236 # else 224 237 opline->handler = get_opcode_handler(opline->opcode TSRMLS_CC); 238 # endif 239 225 240 #endif 226 241 } … … 235 250 fixup_zval_hash(from->static_variables); 236 251 } 252 #ifdef ZEND_ENGINE_2_1 253 if (from->vars != NULL) { 254 zend_uint i; 255 FIXUP(from->vars); 256 for (i = 0; i < from->last_var; i++) { 257 FIXUP(from->vars[i].name); 258 } 259 } 260 #endif 237 261 FIXUP(from->filename); 238 262 #ifdef ZEND_ENGINE_2 … … 252 276 fixup_hash(&from->properties_info, 253 277 (fixup_bucket_t) fixup_property_info TSRMLS_CC); 278 # ifdef ZEND_ENGINE_2_1 279 fixup_zval_hash(&from->default_static_members); 280 if (from->static_members != NULL) { 281 FIXUP(from->static_members); 282 if (from->static_members != &from->default_static_members) { 283 fixup_zval_hash(from->static_members); 284 } 285 } 286 # else 254 287 if (from->static_members != NULL) { 255 288 FIXUP(from->static_members); 256 289 fixup_zval_hash(from->static_members); 257 290 } 291 # endif 258 292 #else 259 293 fixup_zval_hash(&from->default_properties); … … 278 312 memcpy(p, from, sizeof(zval)); 279 313 restore_zval(p TSRMLS_CC); 314 /* hrak: reset refcount to make sure there is one reference to this val, and prevent memleaks */ 315 p->refcount = 1; 280 316 return p; 281 317 } … … 352 388 case IS_STRING: 353 389 if (zv->value.str.val == NULL || 354 zv->value.str.val == empty_string|| zv->value.str.len == 0) {390 zv->value.str.val == "" || zv->value.str.len == 0) { 355 391 zv->value.str.val = empty_string; 356 392 return; … … 442 478 443 479 ea_debug_pad(EA_DEBUG TSRMLS_CC); 444 ea_debug_printf(EA_DEBUG, "[%d] restore_op_array: %s \n", getpid(),445 from->function_name ? from->function_name : "(top)" );480 ea_debug_printf(EA_DEBUG, "[%d] restore_op_array: %s type=%x\n", getpid(), 481 from->function_name ? from->function_name : "(top)", from->type); 446 482 447 483 if (from->type == ZEND_INTERNAL_FUNCTION) { … … 500 536 if (from->scope_name != NULL) { 501 537 char *from_scope_lc = zend_str_tolower_dup(from->scope_name, from->scope_name_len); 502 if (zend_hash_find (CG(class_table), (void *) from_scope_lc, 503 from->scope_name_len + 1, (void **) &to->scope) != SUCCESS) { 538 if (zend_hash_find (CG(class_table), (void *) from_scope_lc, from->scope_name_len + 1, (void **) &to->scope) != SUCCESS) { 504 539 ea_debug_pad(EA_DEBUG TSRMLS_CC); 505 ea_debug_printf(EA_DEBUG, "[%d] can't find '%s' in hash. use EAG(class_entry).\n", getpid(), from_scope_lc);540 ea_debug_printf(EA_DEBUG, "[%d] can't find '%s' in class_table. use EAG(class_entry).\n", getpid(), from->scope_name); 506 541 to->scope = EAG(class_entry); 507 542 } else { 508 543 ea_debug_pad(EA_DEBUG TSRMLS_CC); 509 ea_debug_printf(EA_DEBUG, "[%d] found '%s' in hash\n", getpid(), from _scope_lc);544 ea_debug_printf(EA_DEBUG, "[%d] found '%s' in hash\n", getpid(), from->scope_name); 510 545 to->scope = *(zend_class_entry **) to->scope; 511 546 } 512 547 efree(from_scope_lc); 513 } else { // zoeloelip: is this needed? scope is always stored 548 } else { // zoeloelip: is this needed? scope is always stored -> hra: no its not :P only if from->scope!=null in ea_store 514 549 ea_debug_pad(EA_DEBUG TSRMLS_CC); 515 550 ea_debug_printf(EA_DEBUG, "[%d] from is NULL\n", getpid()); … … 563 598 ea_debug_pad(EA_DEBUG TSRMLS_CC); 564 599 ea_debug_printf(EA_DEBUG, "[%d] can't find\n", getpid()); 565 } 600 } 601 #ifdef ZEND_ENGINE_2 602 /* hrak: slight memleak here. dont forget to free the lowercase function name! */ 603 if (fname_lc != NULL) { 604 efree(fname_lc); 605 } 606 /* zend_internal_function also contains return_reference in ZE2 */ 607 to->return_reference = from->return_reference; 608 /* this gets set by zend_do_inheritance */ 609 to->prototype = NULL; 610 #endif 566 611 return to; 567 612 } 613 #ifdef ZEND_ENGINE_2 614 /* hrak: slight memleak here. dont forget to free the lowercase function name! */ 615 if (fname_lc != NULL) { 616 efree(fname_lc); 617 } 618 #endif 568 619 to->opcodes = from->opcodes; 569 620 to->last = to->size = from->last; … … 571 622 to->brk_cont_array = from->brk_cont_array; 572 623 to->last_brk_cont = from->last_brk_cont; 573 /*624 574 625 to->current_brk_cont = -1; 575 626 to->static_variables = from->static_variables; 576 to->start_op = to->opcodes; 627 /* to->start_op = to->opcodes; */ 577 628 to->backpatch_count = 0; 578 */629 579 630 to->return_reference = from->return_reference; 580 631 to->done_pass_two = 1; 581 632 to->filename = from->filename; 633 /* if (from->filename != NULL) { 634 size_t len = strlen(from->filename) + 1; 635 to->filename = emalloc(len); 636 memcpy(to->filename, from->filename, len); 637 }*/ 638 582 639 #ifdef ZEND_ENGINE_2 583 640 /* HOESH: try & catch support */ … … 613 670 } 614 671 672 #ifdef ZEND_ENGINE_2_1 673 to->vars = from->vars; 674 to->last_var = from->last_var; 675 to->size_var = 0; 676 /* if (from->vars) { 677 zend_uint i; 678 to->vars = (zend_compiled_variable*)emalloc(from->last_var*sizeof(zend_compiled_variable)); 679 memcpy(to->vars, from->vars, sizeof(zend_compiled_variable) * from->last_var); 680 for (i = 0; i < from->last_var; i ++) { 681 to->vars[i].name = estrndup(from->vars[i].name, from->vars[i].name_len); 682 } 683 }*/ 684 #endif 685 615 686 /* disable deletion in destroy_op_array */ 616 687 ++EAG(refcount_helper); … … 634 705 to->name = emalloc(from->name_length + 1); 635 706 memcpy(to->name, from->name, from->name_length + 1); 707 #ifdef ZEND_ENGINE_2_1 708 if (from->doc_comment != NULL) { 709 to->doc_comment = emalloc(from->doc_comment_len+1); 710 memcpy(to->doc_comment, from->doc_comment, from->doc_comment_len+1); 711 } 712 #endif 636 713 return to; 637 714 } … … 642 719 zend_class_entry * to TSRMLS_DC) 643 720 { 644 #ifdef ZEND_ENGINE_2 645 char *name_lc = zend_str_tolower_dup(parent, len); 646 if (zend_hash_find(CG(class_table), (void *) name_lc, len + 1, (void **) &to->parent) != SUCCESS) 721 ea_debug_printf(EA_DEBUG, "restore_class_parent: restoring parent class %s of class %s\n", (char *) parent, to->name); 722 #ifdef ZEND_ENGINE_2 723 /* char *name_lc = zend_str_tolower_dup(parent, len); 724 if (zend_hash_find(CG(class_table), (void *) name_lc, len + 1, (void **) &to->parent) != SUCCESS)*/ 725 zend_class_entry** parent_ptr = NULL; 726 if (zend_lookup_class(parent, len, &parent_ptr TSRMLS_CC) != SUCCESS) 647 727 #else 648 728 if (zend_hash_find(CG(class_table), (void *) parent, len + 1, (void **) &to->parent) != SUCCESS) … … 655 735 #ifdef ZEND_ENGINE_2 656 736 /* inherit parent methods */ 657 to->parent = *(zend_class_entry **) to->parent; 737 to->parent = *parent_ptr; 738 to->parent->refcount++; 739 ea_debug_printf(EA_DEBUG, "restore_class_parent: found parent %s..\n", to->parent->name); 740 ea_debug_printf(EA_DEBUG, "restore_class_parent: parent type=%d child type=%d\n", to->parent->type, to->type); 658 741 to->constructor = to->parent->constructor; 659 742 to->destructor = to->parent->destructor; 660 743 to->clone = to->parent->clone; 661 to->__get = to->parent->__get;744 /* to->__get = to->parent->__get; 662 745 to->__set = to->parent->__set; 746 # ifdef ZEND_ENGINE_2_1 747 to->__unset = to->parent->__unset; 748 to->__isset = to->parent->__isset; 749 to->serialize_func = to->parent->serialize_func; 750 to->unserialize_func = to->parent->unserialize_func; 751 # endif 663 752 to->__call = to->parent->__call; 664 753 to->create_object = to->parent->create_object; … … 666 755 to->handle_property_get = to->parent->handle_property_get; 667 756 to->handle_property_set = to->parent->handle_property_set; 668 to->handle_function_call = to->parent->handle_function_call; 669 #endif 670 } 671 #ifdef ZEND_ENGINE_2 672 efree(name_lc);757 to->handle_function_call = to->parent->handle_function_call;*/ 758 #endif 759 } 760 #ifdef ZEND_ENGINE_2 761 /*efree(name_lc);*/ 673 762 #endif 674 763 } … … 689 778 fname_len = strlen(f->common.function_name); 690 779 fname_lc = zend_str_tolower_dup(f->common.function_name, fname_len); 780 ea_debug_printf(EA_DEBUG, "restore_class_methods: restoring function:%s scope:%s parent=%x scope=%x\n", fname_lc, ZEND_FN_SCOPE_NAME(f), to->parent, f->common.scope); 691 781 692 782 if (fname_len == cname_len && !memcmp(fname_lc, cname_lc, fname_len) && … … 709 799 memcmp(fname_lc, ZEND_SET_FUNC_NAME, sizeof(ZEND_SET_FUNC_NAME)) == 0) 710 800 to->__set = f; 801 # ifdef ZEND_ENGINE_2_1 802 else if (fname_len == sizeof(ZEND_UNSET_FUNC_NAME) - 1 && 803 memcmp(fname_lc, ZEND_UNSET_FUNC_NAME, sizeof(ZEND_UNSET_FUNC_NAME)) == 0) 804 to->__unset = f; 805 else if (fname_len == sizeof(ZEND_ISSET_FUNC_NAME) - 1 && 806 memcmp(fname_lc, ZEND_ISSET_FUNC_NAME, sizeof(ZEND_ISSET_FUNC_NAME)) == 0) 807 to->__isset = f; 808 # endif 711 809 else if (fname_len == sizeof(ZEND_CALL_FUNC_NAME) - 1 && 712 810 memcmp(fname_lc, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME)) == 0) … … 725 823 zend_class_entry *old; 726 824 zend_function *f = NULL; 727 int fname_len = 0; 728 char *fname_lc = NULL; 729 #ifdef ZEND_ENGINE_2 730 int cname_len; 731 char *cname_lc; 825 /* int fname_len = 0; hrak: seems rather unused 826 char *fname_lc = NULL; */ 827 #ifdef ZEND_ENGINE_2 828 /* int cname_len; hrak: same here 829 char *cname_lc; */ 732 830 Bucket *p; 733 831 union _zend_function *old_ctor; … … 735 833 736 834 ea_debug_pad(EA_DEBUG TSRMLS_CC); 737 ea_debug_printf(EA_DEBUG, "[%d] re tore_class_entry: %s\n", getpid(), from->name ? from->name : "(top)");835 ea_debug_printf(EA_DEBUG, "[%d] restore_class_entry: %s\n", getpid(), from->name ? from->name : "(top)"); 738 836 #ifdef DEBUG 739 837 EAG(xpad)++; 740 838 #endif 741 742 839 if (to == NULL) { 743 840 to = emalloc(sizeof(zend_class_entry)); … … 753 850 #ifdef ZEND_ENGINE_2 754 851 to->ce_flags = from->ce_flags; 755 /*756 to->static_members = NULL;757 */758 852 to->num_interfaces = from->num_interfaces; 759 853 if (to->num_interfaces > 0) { 854 /* hrak: Allocate the slots which will later be populated by ZEND_ADD_INTERFACE */ 760 855 to->interfaces = (zend_class_entry **) emalloc(sizeof(zend_class_entry *) * to->num_interfaces); 761 // should find out class entry. what the hell !!!762 856 memset(to->interfaces, 0, sizeof(zend_class_entry *) * to->num_interfaces); 763 857 } else { … … 766 860 767 861 to->iterator_funcs = from->iterator_funcs; 862 to->create_object = from->create_object; 768 863 to->get_iterator = from->get_iterator; 769 864 to->interface_gets_implemented = from->interface_gets_implemented; … … 776 871 } 777 872 778 if (from->parent != NULL) {779 restore_class_parent(from->parent, strlen(from->parent), to TSRMLS_CC);780 } else {781 ea_debug_pad(EA_DEBUG TSRMLS_CC);782 ea_debug_printf(EA_DEBUG, "[%d] parent = NULL\n", getpid());783 to->parent = NULL;784 }785 786 873 old = EAG(class_entry); 787 874 EAG(class_entry) = to; … … 793 880 to->line_end = from->line_end; 794 881 to->doc_comment_len = from->doc_comment_len; 795 if (from->filename != NULL) {882 /* if (from->filename != NULL) { 796 883 size_t len = strlen(from->filename) + 1; 797 884 to->filename = emalloc(len); 798 885 memcpy(to->filename, from->filename, len); 799 } 886 }*/ 887 to->filename = from->filename; 800 888 if (from->doc_comment != NULL) { 801 889 to->doc_comment = emalloc(from->doc_comment_len + 1); … … 814 902 to->properties_info.pDestructor = properties_info_dtor; 815 903 904 # ifdef ZEND_ENGINE_2_1 905 /* restore default_static_members */ 906 restore_zval_hash(&to->default_static_members, &from->default_static_members); 907 to->default_static_members.pDestructor = ZVAL_PTR_DTOR; 908 909 ea_debug_printf(EA_DEBUG, "restore_class_entry: static_members=%x, default_static_members=%x\n", from->static_members, &from->default_static_members); 910 if (from->static_members != &(from->default_static_members)) { 911 ALLOC_HASHTABLE(to->static_members); 912 restore_zval_hash(to->static_members, from->static_members); 913 to->static_members->pDestructor = ZVAL_PTR_DTOR; 914 } else { 915 to->static_members = &(to->default_static_members); 916 } 917 ea_debug_printf(EA_DEBUG, "restore_class_entry: to->static_members=%x, to->default_static_members=%x\n", to->static_members, &to->default_static_members); 918 # else 816 919 if (from->static_members != NULL) { 817 920 ALLOC_HASHTABLE(to->static_members); 818 921 restore_zval_hash(to->static_members, from->static_members); 819 922 to->static_members->pDestructor = ZVAL_PTR_DTOR; 820 /* 821 } else { 822 ALLOC_HASHTABLE(to->static_members); 823 zend_hash_init_ex(to->static_members, 0, NULL, ZVAL_PTR_DTOR, 0, 0); 824 */ 825 } 923 } 924 # endif 826 925 #else 827 926 to->refcount = emalloc(sizeof(*to->refcount)); … … 839 938 } 840 939 #endif 940 if (from->parent != NULL) { 941 restore_class_parent(from->parent, strlen(from->parent), to TSRMLS_CC); 942 } else { 943 ea_debug_pad(EA_DEBUG TSRMLS_CC); 944 ea_debug_printf(EA_DEBUG, "[%d] parent = NULL\n", getpid()); 945 to->parent = NULL; 946 } 947 841 948 restore_hash(&to->function_table, &from->function_table, 842 949 (restore_bucket_t) restore_op_array_ptr TSRMLS_CC); … … 846 953 restore_class_methods(to TSRMLS_CC); 847 954 #endif 955 if (to->parent) 956 zend_do_inheritance(to, to->parent TSRMLS_CC); 848 957 EAG(class_entry) = old; 849 958 eaccelerator/trunk/ea_restore.h
r124 r162 35 35 void fixup_class_entry (eaccelerator_class_entry * from TSRMLS_DC); 36 36 37 void restore_zval(zval * zv TSRMLS_DC); 37 38 void restore_class(mm_fc_entry *p TSRMLS_DC); 38 39 void restore_function(mm_fc_entry *p TSRMLS_DC); eaccelerator/trunk/ea_store.c
r124 r162 83 83 EAG(mem) += sizeof(zend_property_info); 84 84 calc_string(from->name, from->name_length + 1 TSRMLS_CC); 85 #ifdef ZEND_ENGINE_2_1 86 if (from->doc_comment != NULL) { 87 calc_string(from->doc_comment, from->doc_comment_len + 1 TSRMLS_CC); 88 } 89 #endif 85 90 } 86 91 … … 118 123 case IS_CONSTANT: 119 124 case IS_STRING: 120 if (zv->value.str.val == NULL || zv->value.str.val == empty_string|| zv->value.str.len == 0) {121 } else { 125 /* if (zv->value.str.val == NULL || zv->value.str.len == 0) { 126 } else {*/ 122 127 calc_string(zv->value.str.val, zv->value.str.len + 1 TSRMLS_CC); 123 } 128 /* }*/ 124 129 break; 125 130 case IS_ARRAY: … … 247 252 calc_zval_hash(from->static_variables); 248 253 } 254 #ifdef ZEND_ENGINE_2_1 255 if (from->vars != NULL) { 256 zend_uint i; 257 EACCELERATOR_ALIGN(EAG(mem)); 258 EAG(mem) += sizeof(zend_compiled_variable) * from->last_var; 259 for (i = 0; i < from->last_var; i ++) { 260 calc_string(from->vars[i].name, from->vars[i].name_len+1 TSRMLS_CC); 261 } 262 } 263 #endif 249 264 if (from->filename != NULL) 250 265 calc_string(from->filename, strlen(from->filename) + 1 TSRMLS_CC); … … 270 285 calc_string(from->parent->name, from->parent->name_length + 1 TSRMLS_CC); 271 286 #ifdef ZEND_ENGINE_2 272 #if 0273 // what's problem. why from->interfaces[i] == 0x5a5a5a5a ?274 for (i = 0; i < from->num_interfaces; i++) {275 if (from->interfaces[i]) {276 calc_string(from->interfaces[i]->name,277 from->interfaces[i]->name_length);278 }279 }280 #endif281 287 if (from->filename != NULL) 282 288 calc_string(from->filename, strlen(from->filename) + 1 TSRMLS_CC); … … 286 292 calc_zval_hash(&from->constants_table); 287 293 calc_zval_hash(&from->default_properties); 294 288 295 calc_hash(&from->properties_info, (calc_bucket_t) calc_property_info); 296 297 # ifdef ZEND_ENGINE_2_1 298 calc_zval_hash(&from->default_static_members); 299 if ((from->static_members != NULL) && (from->static_members != &from->default_static_members)) { 300 # else 289 301 if (from->static_members != NULL) { 302 # endif 290 303 EACCELERATOR_ALIGN(EAG(mem)); 291 304 EAG(mem) += sizeof(HashTable); … … 368 381 369 382 typedef void *(*store_bucket_t) (void *TSRMLS_DC); 370 371 #define store_hash_ex(to, from, start, store_bucket) \ 372 store_hash_int(to, from, start, store_bucket TSRMLS_CC) 373 374 #define store_hash(to, from, store_bucket) \ 375 store_hash_ex(to, from, (from)->pListHead, store_bucket) 383 typedef void *(*check_bucket_t) (Bucket*, va_list); 384 385 #define store_hash_ex(to, from, start, store_bucket, check_bucket, ...) \ 386 store_hash_int(to, from, start, store_bucket, check_bucket, __VA_ARGS__) 387 388 #define store_hash(to, from, store_bucket, check_bucket, ...) \ 389 store_hash_ex(to, from, (from)->pListHead, store_bucket, check_bucket, __VA_ARGS__) 376 390 377 391 #define store_zval_hash(to, from) \ 378 store_hash(to, from, (store_bucket_t)store_zval_ptr )392 store_hash(to, from, (store_bucket_t)store_zval_ptr, NULL, NULL) 379 393 380 394 #define store_zval_hash_ex(to, from, start) \ 381 store_hash_ex(to, from, start, (store_bucket_t)store_zval_ptr )395 store_hash_ex(to, from, start, (store_bucket_t)store_zval_ptr, NULL) 382 396 383 397 static zval *store_zval_ptr(zval * from TSRMLS_DC) … … 393 407 394 408 static void store_hash_int(HashTable * target, HashTable * source, 395 Bucket * start, store_bucket_t copy_bucket TSRMLS_DC) 409 Bucket * start, store_bucket_t copy_bucket, 410 check_bucket_t check_bucket, ...) 396 411 { 397 412 Bucket *p, *np, *prev_p; 413 TSRMLS_FETCH(); 398 414 399 415 memcpy(target, source, sizeof(HashTable)); … … 416 432 np = NULL; 417 433 while (p) { 434 /* If a check function has been defined, run it */ 435 if (check_bucket) { 436 va_list args; 437 va_start(args, check_bucket); 438 439 /* If the check function returns ZEND_HASH_APPLY_REMOVE, don't store this record, skip over it */ 440 if(check_bucket(p, args)) { 441 p = p->pListNext; 442 target->nNumOfElements--; 443 /* skip to next itteration */ 444 continue; 445 } 446 va_end(args); 447 } 448 418 449 EACCELERATOR_ALIGN(EAG(mem)); 419 450 np = (Bucket *) EAG(mem); … … 466 497 case IS_CONSTANT: 467 498 case IS_STRING: 468 if (zv->value.str.val == NULL || 469 zv->value.str.val == empty_string || zv->value.str.len == 0) { 470 zv->value.str.val = empty_string; 471 zv->value.str.len = 0; 472 } else { 473 zv->value.str.val = store_string(zv->value.str.val, zv->value.str.len + 1 TSRMLS_CC); 474 } 499 zv->value.str.val = store_string(zv->value.str.val, zv->value.str.len + 1 TSRMLS_CC); 475 500 break; 476 501 case IS_ARRAY: … … 516 541 517 542 ea_debug_pad(EA_DEBUG TSRMLS_CC); 518 ea_debug_printf(EA_DEBUG, "[%d] store_op_array: %s [scope=%s ]\n",543 ea_debug_printf(EA_DEBUG, "[%d] store_op_array: %s [scope=%s type=%x]\n", 519 544 getpid(), from->function_name ? from->function_name : "(top)", 520 545 #ifdef ZEND_ENGINE_2 … … 523 548 "NULL" 524 549 #endif 550 , from->type 525 551 ); 526 552 … … 555 581 to->arg_info[i].class_name_len = from->arg_info[i].class_name_len; 556 582 } 583 # ifdef ZEND_ENGINE_2_1 584 /* php 5.1 introduces this in zend_arg_info for array type hinting */ 585 to->arg_info[i].array_type_hint = from->arg_info[i].array_type_hint; 586 # endif 557 587 to->arg_info[i].allow_null = from->arg_info[i].allow_null; 558 588 to->arg_info[i].pass_by_reference = from->arg_info[i].pass_by_reference; … … 595 625 #endif 596 626 597 if (from->type == ZEND_INTERNAL_FUNCTION) 598 return to; 627 if (from->type == ZEND_INTERNAL_FUNCTION) { 628 #ifdef ZEND_ENGINE_2 629 /* zend_internal_function also contains return_reference in ZE2 */ 630 to->return_reference = from->return_reference; 631 #endif 632 return to; 633 } 599 634 600 635 to->opcodes = from->opcodes; … … 672 707 store_zval_hash(to->static_variables, from->static_variables); 673 708 } 709 #ifdef ZEND_ENGINE_2_1 710 if (from->vars != NULL) { 711 zend_uint i; 712 EACCELERATOR_ALIGN(EAG(mem)); 713 to->last_var = from->last_var; 714 to->vars = (zend_compiled_variable*)EAG(mem); 715 EAG(mem) += sizeof(zend_compiled_variable) * from->last_var; 716 memcpy(to->vars, from->vars, sizeof(zend_compiled_variable) * from->last_var); 717 for (i = 0; i < from->last_var; i ++) { 718 to->vars[i].name = store_string(from->vars[i].name, from->vars[i].name_len+1 TSRMLS_CC); 719 } 720 } else { 721 to->last_var = 0; 722 to->vars = NULL; 723 } 724 #endif 674 725 if (from->filename != NULL) { 675 to->filename = store_string( to->filename, strlen(from->filename) + 1 TSRMLS_CC);726 to->filename = store_string(from->filename, strlen(from->filename) + 1 TSRMLS_CC); 676 727 } 677 728 #ifdef ZEND_ENGINE_2 … … 694 745 memcpy(to, from, sizeof(zend_property_info)); 695 746 to->name = store_string(from->name, from->name_length + 1 TSRMLS_CC); 747 #ifdef ZEND_ENGINE_2_1 748 to->doc_comment_len = from->doc_comment_len; 749 if (from->doc_comment != NULL) { 750 to->doc_comment = store_string(from->doc_comment, from->doc_comment_len + 1 TSRMLS_CC); 751 } 752 #endif 696 753 return to; 697 754 } 698 #endif 755 756 /* 757 * The following two functions handle access checking of properties (public/private/protected) 758 * and control proper inheritance during copying of the properties_info and (default_)static_members hashes 759 * 760 * Both functions return ZEND_HASH_APPLY_REMOVE if the property to be copied needs to be skipped, or 761 * ZEND_HASH_APPLY_KEEP if the property needs to be copied over into the cache. 762 * 763 * If the property is skipped due to access restrictions, or it needs inheritance of its value from the 764 * parent, the restore phase will take care of that. 765 * 766 * Most of the logic behind all this can be found in zend_compile.c, functions zend_do_inheritance and 767 * zend_do_inherit_property_access_check 768 */ 769 static int store_property_access_check(Bucket * p, va_list args) 770 { 771 zend_class_entry *from = va_arg(args, zend_class_entry*); 772 zend_class_entry *parent = from->parent; 773 774 ea_debug_printf(EA_DEBUG, "[%d] store_property_access_check enter. from=%x parent=%x arKey=%s\n", getpid(), from, parent, p->arKey); 775 776 if (parent) { 777 // hra: TODO - do some usefull stuff :) 778 // check for ACC_PRIVATE etc. 779 // for now, just return keep 780 } 781 ea_debug_printf(EA_DEBUG, "[%d] store_property_access_check result: keep\n", getpid()); 782 return ZEND_HASH_APPLY_KEEP; 783 } 784 785 static int store_static_member_access_check(Bucket * p, va_list args) 786 { 787 zend_class_entry *from = va_arg(args, zend_class_entry*); 788 zend_class_entry *parent = from->parent; 789 zend_property_info *pinfo, *cinfo = NULL; 790 zval **pprop = NULL; 791 zval **cprop = p->pData; 792 char *mname, *cname = NULL; 793 794 /* Check if this is a parent class. If so, copy unconditionally */ 795 if (parent) { 796 /* unpack the \0classname\0membername\0 style property name to seperate vars */ 797 zend_unmangle_property_name(p->arKey, &cname, &mname); 798 ea_debug_printf(EA_DEBUG, "[%d] store_static_member_access_check: cname=%s, mname=%s\n", getpid(), cname, mname); 799 800 /* lookup the member's info in parent and child */ 801 if((zend_hash_find(&parent->properties_info, mname, strlen(mname)+1, (void**)&pinfo) == SUCCESS) && 802 (zend_hash_find(&from->properties_info, mname, strlen(mname)+1, (void**)&cinfo) == SUCCESS)) { 803 /* don't copy this static property if protected in parent and static public in child. 804 inheritance will handle this properly on restore */ 805 if(cinfo->flags & ZEND_ACC_STATIC && (pinfo->flags & ZEND_ACC_PROTECTED && cinfo->flags & ZEND_ACC_PUBLIC)) { 806 ea_debug_printf(EA_DEBUG, "[%d] store_static_member_access_check: child static public, parent protected, result: skip\n", getpid()); 807 return ZEND_HASH_APPLY_REMOVE; 808 } 809 /* If the static member points to the same value in parent and child, remove for proper inheritance during restore */ 810 # ifdef ZEND_ENGINE_2_1 811 if(zend_hash_quick_find(&parent->default_static_members, p->arKey, p->nKeyLength, p->h, (void**)&pprop) == SUCCESS) { 812 # else 813 if(zend_hash_quick_find(&parent->static_members, p->arKey, p->nKeyLength, p->h, (void**)&pprop) == SUCCESS) { 814 # endif 815 ea_debug_printf(EA_DEBUG, "[%d] store_static_member_access_check: SUCCESS looking up arKey\n",getpid()); 816 ea_debug_printf(EA_DEBUG, "[%d] store_static_member_access_check: pprop=%x cprop=%x\n",getpid(), *pprop, *cprop); 817 if(*pprop ==