Changeset 17
- Timestamp:
- 12/17/04 23:42:34 (4 years ago)
- Files:
-
- eaccelerator/trunk/eaccelerator.c (modified) (55 diffs)
- eaccelerator/trunk/eaccelerator_version.h (modified) (1 diff)
- eaccelerator/trunk/optimize.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
eaccelerator/trunk/eaccelerator.c
r12 r17 24 24 +----------------------------------------------------------------------+ 25 25 | Author(s): Dmitry Stogov <mmcache@turckware.ru> | 26 | Seung Woo <segv@sayclub.com> | 27 | Everaldo Canuto <everaldo_canuto@yahoo.com.br> | 26 28 +----------------------------------------------------------------------+ 27 29 $Id$ … … 163 165 #ifdef ZEND_ENGINE_2 164 166 zend_uint num_args; 167 zend_uint required_num_args; 165 168 zend_arg_info *arg_info; 166 169 zend_bool pass_rest_by_reference; … … 169 172 #endif 170 173 char *function_name; 174 char *function_name_lc; 171 175 #ifdef ZEND_ENGINE_2 172 176 char* scope_name; … … 197 201 char type; 198 202 char *name; 203 char *name_lc; 199 204 uint name_length; 200 205 char *parent; … … 207 212 HashTable constants_table; 208 213 zend_uint num_interfaces; 209 214 char **interfaces; 215 zend_class_iterator_funcs iterator_funcs; 216 217 zend_object_value (*create_object)(zend_class_entry *class_type TSRMLS_DC); 218 zend_object_iterator *(*get_iterator)(zend_class_entry *ce, zval *object TSRMLS_DC); 219 int (*interface_gets_implemented)(zend_class_entry *iface, zend_class_entry *class_type TSRMLS_DC); /* a class implements this interface */ 220 210 221 char *filename; 211 222 zend_uint line_start; … … 401 412 #include <stdio.h> 402 413 static FILE *F_fp; 414 415 static void binary_print(char *p, int len) { 416 while (len--) { 417 fputc(*p++, F_fp); 418 } 419 fputc('\n', F_fp); 420 } 421 422 static void log_hashkeys(char *p, HashTable *ht) 423 { 424 Bucket *b; 425 int i = 0; 426 427 b = ht->pListHead; 428 429 fputs(p, F_fp); 430 while (b) { 431 fprintf(F_fp, "[%d] ", i); 432 binary_print(b->arKey, b->nKeyLength); 433 434 b = b->pListNext; 435 i++; 436 } 437 } 403 438 404 439 static void pad(TSRMLS_D) { … … 1234 1269 /******************************************************************************/ 1235 1270 1236 static inline void calc_string(char* str, int len TSRMLS_DC) { 1271 #ifndef DEBUG 1272 inline 1273 #endif 1274 static 1275 void calc_string(char* str, int len TSRMLS_DC) { 1237 1276 if (len > MAX_DUP_STR_LEN || zend_hash_add(&MMCG(strings), str, len, &str, sizeof(char*), NULL) == SUCCESS) { 1238 1277 EACCELERATOR_ALIGN(MMCG(mem)); … … 1368 1407 for (i = 0; i < from->num_args; i++) { 1369 1408 if (from->arg_info[i].name) { 1370 calc_string(from->arg_info[i].name,from->arg_info[i].name_len TSRMLS_CC);1409 calc_string(from->arg_info[i].name,from->arg_info[i].name_len+1 TSRMLS_CC); 1371 1410 } 1372 1411 if (from->arg_info[i].class_name) { 1373 calc_string(from->arg_info[i].class_name,from->arg_info[i].class_name_len TSRMLS_CC);1412 calc_string(from->arg_info[i].class_name,from->arg_info[i].class_name_len+1 TSRMLS_CC); 1374 1413 } 1375 1414 } … … 1447 1486 1448 1487 static void calc_class_entry(zend_class_entry* from TSRMLS_DC) { 1488 int i; 1489 1449 1490 if (from->type != ZEND_USER_CLASS) { 1450 1491 debug_printf("[%d] EACCELERATOR can't cache internal class \"%s\"\n", getpid(), from->name); … … 1467 1508 calc_string(from->parent->name, from->parent->name_length + 1 TSRMLS_CC); 1468 1509 } 1469 1470 1510 #ifdef ZEND_ENGINE_2 1511 #if 0 1512 // what's problem. why from->interfaces[i] == 0x5a5a5a5a ? 1513 for (i=0; i<from->num_interfaces; i++) { 1514 if (from->interfaces[i]) { 1515 calc_string(from->interfaces[i]->name, from->interfaces[i]->name_length); 1516 } 1517 } 1518 #endif 1471 1519 if (from->filename != NULL) { 1472 1520 calc_string(from->filename, strlen(from->filename)+1 TSRMLS_CC); … … 1722 1770 #ifdef DEBUG 1723 1771 pad(TSRMLS_C); 1724 fprintf(F_fp, "[%d] store_op_array: %s \n", getpid(),1725 from->function_name ? from->function_name : "(top)" );1772 fprintf(F_fp, "[%d] store_op_array: %s [scope=%s]\n", getpid(), 1773 from->function_name ? from->function_name : "(top)", from->scope ? from->scope->name : "NULL"); 1726 1774 fflush(F_fp); 1727 1775 #endif … … 1742 1790 #ifdef ZEND_ENGINE_2 1743 1791 to->num_args = from->num_args; 1792 to->required_num_args = from->required_num_args; 1744 1793 if (from->num_args > 0) { 1745 1794 zend_uint i; … … 1749 1798 for (i = 0; i < from->num_args; i++) { 1750 1799 if (from->arg_info[i].name) { 1751 to->arg_info[i].name = store_string(from->arg_info[i].name,from->arg_info[i].name_len TSRMLS_CC);1800 to->arg_info[i].name = store_string(from->arg_info[i].name,from->arg_info[i].name_len+1 TSRMLS_CC); 1752 1801 to->arg_info[i].name_len = from->arg_info[i].name_len; 1753 1802 } 1754 1803 if (from->arg_info[i].class_name) { 1755 to->arg_info[i].class_name = store_string(from->arg_info[i].class_name,from->arg_info[i].class_name_len TSRMLS_CC);1804 to->arg_info[i].class_name = store_string(from->arg_info[i].class_name,from->arg_info[i].class_name_len+1 TSRMLS_CC); 1756 1805 to->arg_info[i].class_name_len = from->arg_info[i].class_name_len; 1757 1806 } 1758 1807 to->arg_info[i].allow_null = from->arg_info[i].allow_null; 1759 1808 to->arg_info[i].pass_by_reference = from->arg_info[i].pass_by_reference; 1809 to->arg_info[i].return_reference = from->arg_info[i].return_reference; 1760 1810 } 1761 1811 } … … 1774 1824 */ 1775 1825 to->function_name = store_string(from->function_name, strlen(from->function_name)+1 TSRMLS_CC); 1776 zend_str_tolower(to->function_name, strlen(from->function_name)); 1826 // XXX: revert 1827 // zend_str_tolower(to->function_name, strlen(from->function_name)); 1777 1828 } 1778 1829 #ifdef ZEND_ENGINE_2 … … 1790 1841 { 1791 1842 to->scope_name = store_string(q->arKey, q->nKeyLength TSRMLS_CC); 1792 to->scope_name_len = q->nKeyLength; 1843 to->scope_name_len = q->nKeyLength - 1; 1844 #ifdef DEBUG 1845 pad(TSRMLS_C); fprintf(F_fp, "[%d] find scope '%s' in CG(class_table) save hashkey '%s' [%08x] as to->scope_name\n", 1846 getpid(), from->scope->name ? from->scope->name : "NULL", q->arKey, to->scope_name); fflush(F_fp); 1847 #endif 1793 1848 break; 1794 1849 } 1795 1850 q = q->pListNext; 1851 } 1852 if (to->scope_name == NULL) 1853 { 1854 #ifdef DEBUG 1855 pad(TSRMLS_C); fprintf(F_fp, "[%d] could not find scope '%s' in CG(class_table), saving it to NULL\n", getpid(), from->scope->name ? from->scope->name : "NULL"); fflush(F_fp); 1856 #endif 1796 1857 } 1797 1858 } … … 1895 1956 static eaccelerator_class_entry* store_class_entry(zend_class_entry* from TSRMLS_DC) { 1896 1957 eaccelerator_class_entry *to; 1958 int i; 1897 1959 1898 1960 EACCELERATOR_ALIGN(MMCG(mem)); … … 1907 1969 to->static_members = NULL; 1908 1970 to->num_interfaces = from->num_interfaces; 1971 1972 #if 0 1973 // i need to check more. why this field is null. 1974 // 1975 for (i=0; i<from->num_interfaces; i++) { 1976 if (from->interfaces[i]) { 1977 to->interfaces[i] = store_string(from->interfaces[i]->name, from->interfaces[i]->name_length); 1978 } 1979 } 1980 #endif 1981 1909 1982 #endif 1910 1983 1911 1984 #ifdef DEBUG 1912 1985 pad(TSRMLS_C); 1913 fprintf(F_fp, "[%d] store_class_entry: %s \n", getpid(), from->name? from->name : "(top)");1986 fprintf(F_fp, "[%d] store_class_entry: %s parent was '%s'\n", getpid(), from->name? from->name : "(top)", from->parent ? from->parent->name : "NULL"); 1914 1987 fflush(F_fp); 1915 1988 MMCG(xpad)++; … … 1918 1991 if (from->name != NULL) { 1919 1992 to->name = store_string(from->name, from->name_length+1 TSRMLS_CC); 1920 zend_str_tolower(to->name, from->name_length); 1993 //XXX: revert 1994 // zend_str_tolower(to->name, from->name_length); 1921 1995 } 1922 1996 if (from->parent != NULL && from->parent->name) { 1923 1997 to->parent = store_string(from->parent->name, from->parent->name_length+1 TSRMLS_CC); 1924 zend_str_tolower(to->parent, from->parent->name_length); 1998 //XXX: revert 1999 // zend_str_tolower(to->parent, from->parent->name_length); 1925 2000 } 1926 2001 … … 1932 2007 */ 1933 2008 #ifdef ZEND_ENGINE_2 1934 to->line_start = from->line_start; 1935 to->line_end = from->line_end; 1936 to->doc_comment_len = from->doc_comment_len; 2009 to->line_start = from->line_start; 2010 to->line_end = from->line_end; 2011 to->doc_comment_len = from->doc_comment_len; 2012 to->iterator_funcs = from->iterator_funcs; 2013 to->create_object = from->create_object; 2014 to->get_iterator = from->get_iterator; 2015 to->interface_gets_implemented = from->interface_gets_implemented; 2016 1937 2017 if (from->filename != NULL) { 1938 2018 to->filename = store_string(from->filename, strlen(from->filename)+1 TSRMLS_CC); … … 1972 2052 char *x; 1973 2053 2054 #ifdef DEBUG 2055 pad(TSRMLS_C); fprintf(F_fp, "[%d] eaccelerator_store_int: key='%s'\n", getpid(), key); fflush(F_fp); 2056 #endif 2057 1974 2058 MMCG(compress) = 1; 1975 2059 zend_hash_init(&MMCG(strings), 0, NULL, NULL, 0); … … 1988 2072 q = NULL; 1989 2073 while (c != NULL) { 2074 #ifdef DEBUG 2075 pad(TSRMLS_C); fprintf(F_fp, "[%d] eaccelerator_store_int: class hashkey=", getpid()); binary_print(c->arKey, c->nKeyLength); fflush(F_fp); 2076 #endif 1990 2077 EACCELERATOR_ALIGN(MMCG(mem)); 1991 2078 fc = (mm_fc_entry*)MMCG(mem); … … 2012 2099 q = NULL; 2013 2100 while (f != NULL) { 2101 #ifdef DEBUG 2102 pad(TSRMLS_C); fprintf(F_fp, "[%d] eaccelerator_store_int: function hashkey='%s'\n", getpid(), f->arKey); fflush(F_fp); 2103 #endif 2014 2104 EACCELERATOR_ALIGN(MMCG(mem)); 2015 2105 fc = (mm_fc_entry*)MMCG(mem); … … 2285 2375 2286 2376 static zend_op_array* restore_op_array(zend_op_array *to, eaccelerator_op_array *from TSRMLS_DC) { 2287 zend_ internal_function* function;2377 zend_function* function; 2288 2378 2289 2379 #ifdef DEBUG … … 2310 2400 to->type = from->type; 2311 2401 #ifdef ZEND_ENGINE_2 2402 /* this is internal function's case 2403 * struct zend_internal_function 2404 zend_uchar type; 2405 char *function_name; 2406 zend_class_entry *scope; 2407 zend_uint fn_flags; 2408 union _zend_function *prototype; 2409 zend_uint num_args; 2410 zend_uint required_num_args; 2411 zend_arg_info *arg_info; 2412 zend_bool pass_rest_by_reference; 2413 unsigned char return_reference; 2414 */ 2415 /* 2416 * typedef struct _zend_internal_function { 2417 * // Common elements 2418 * zend_uchar type; 2419 * char *function_name; 2420 * zend_class_entry *scope; 2421 * zend_uint fn_flags; 2422 * union _zend_function *prototype; 2423 * zend_uint num_args; 2424 * zend_uint required_num_args; 2425 * zend_arg_info *arg_info; 2426 * zend_bool pass_rest_by_reference; 2427 * unsigned char return_reference; 2428 * // END of common elements 2429 * 2430 * void (*handler)(INTERNAL_FUNCTION_PARAMETERS); 2431 * } zend_internal_function; 2432 */ 2312 2433 to->num_args = from->num_args; 2434 to->required_num_args = from->required_num_args; 2313 2435 to->arg_info = from->arg_info; 2314 2436 to->pass_rest_by_reference = from->pass_rest_by_reference; … … 2317 2439 #endif 2318 2440 to->function_name = from->function_name; 2441 2442 int fname_len; 2443 char *fname_lc; 2444 2445 if (to->function_name) 2446 { 2447 fname_len = strlen(to->function_name); 2448 fname_lc = zend_str_tolower_dup(to->function_name, fname_len); 2449 } 2319 2450 #ifdef ZEND_ENGINE_2 2320 to->scope = MMCG(class_entry); 2321 to->fn_flags = from->fn_flags; 2322 if (to->scope == NULL && from->scope_name != NULL) 2323 { 2324 if (zend_hash_find(CG(class_table), 2325 (void *)from->scope_name, from->scope_name_len, 2326 (void **)&to->scope) == SUCCESS) 2327 { 2328 to->scope = *(zend_class_entry**)to->scope; 2329 } 2330 else 2331 { 2332 debug_printf("[%d] EACCELERATOR can't restore parent class " 2333 "\"%s\" of function \"%s\"\n", getpid(), 2334 (char*)from->scope_name, to->function_name); 2335 to->scope = NULL; 2336 } 2337 } 2451 to->fn_flags = from->fn_flags; 2452 2453 /* segv74: 2454 * to->scope = MMCG(class_entry) 2455 * 2456 * if from->scope_name == NULL, 2457 * ; MMCG(class) == NULL : we are in function or outside function. 2458 * ; MMCG(class) != NULL : inherited method not defined in current file, should have to find. 2459 * just LINK (zend_op_array *) to to original entry in parent, 2460 * but, with what? !!! I don't know PARENT CLASS NAME !!!! 2461 * 2462 * 2463 * if from->scope_name != NULL, 2464 * ; we are in class member function 2465 * 2466 * ; we have to find appropriate (zend_class_entry*) to->scope for name from->scope_name 2467 * ; if we find in CG(class_table), link to it. 2468 * ; if fail, it should be MMCG(class_entry) 2469 * 2470 * am I right here ? ;-( 2471 */ 2472 if (from->scope_name != NULL) 2473 { 2474 char *from_scope_lc = zend_str_tolower_dup(from->scope_name, from->scope_name_len); 2475 if (zend_hash_find(CG(class_table), (void *)from_scope_lc, from->scope_name_len+1, (void **)&to->scope) != SUCCESS) 2476 { 2477 #ifdef DEBUG 2478 pad(TSRMLS_C); fprintf(F_fp, "[%d] can't find '%s' in hash. use MMCG(class_entry).\n", getpid(), from_scope_lc); fflush(F_fp); 2479 #endif 2480 to->scope = MMCG(class_entry); 2481 } 2482 else 2483 { 2484 #ifdef DEBUG 2485 pad(TSRMLS_C); fprintf(F_fp, "[%d] found '%s' in hash\n", getpid(), from_scope_lc); fflush(F_fp); 2486 #endif 2487 to->scope = *(zend_class_entry **)(to->scope); 2488 } 2489 efree(from_scope_lc); 2490 } 2491 else 2492 { 2493 #ifdef DEBUG 2494 pad(TSRMLS_C); fprintf(F_fp, "[%d] from is NULL\n", getpid()); fflush(F_fp); 2495 #endif 2496 if (MMCG(class_entry)) 2497 { 2498 zend_class_entry *p; 2499 2500 for (p = MMCG(class_entry)->parent; p; p = p->parent) 2501 { 2502 #ifdef DEBUG 2503 pad(TSRMLS_C); fprintf(F_fp, "[%d] checking parent '%s' have '%s'\n", getpid(), p->name, fname_lc); fflush(F_fp); 2504 #endif 2505 if (zend_hash_find(&p->function_table, fname_lc, fname_len+1, (void **) &function)==SUCCESS) 2506 { 2507 #ifdef DEBUG 2508 pad(TSRMLS_C); fprintf(F_fp, "[%d] '%s' has '%s' of scope '%s'\n", getpid(), p->name, fname_lc, function->common.scope->name); fflush(F_fp); 2509 #endif 2510 to->scope = function->common.scope; 2511 break; 2512 } 2513 } 2514 } 2515 else 2516 to->scope = NULL; 2517 } 2518 2519 #ifdef DEBUG 2520 pad(TSRMLS_C); 2521 fprintf(F_fp, "[%d] %s's scope is '%s'\n", getpid(), 2522 from->function_name ? from->function_name : "(top)", to->scope ? to->scope->name : "NULL"); 2523 fflush(F_fp); 2524 #endif 2525 #if 0 2338 2526 if (to->scope != NULL) 2339 2527 { 2340 2528 unsigned int len = strlen(to->function_name); 2341 2529 char *lcname = zend_str_tolower_dup(to->function_name, len); 2530 char *lc_to_name = zend_str_tolower_dup(to->scope->name, to->scope->name_length); 2342 2531 /* 2343 2532 * HOESH: this one probably the old style constructor, … … 2351 2540 */ 2352 2541 2542 /* segv74: I got a question. 2543 * 2544 * I think that, this code is reconstructing zend_class_entry thing. 2545 * is it right doing this here? 2546 * 2547 * IMHO, we can do this job in restore_class_entry(). 2548 * it's not good for readablity, and dosen't have performace gain. 2549 */ 2550 #ifdef DEBUG 2551 pad(TSRMLS_C); 2552 fprintf(F_fp, " scope: %s[%d], method name: %s[%d] (%d) : to->scope->constructor=0x%08x\n", 2553 lcname, to->scope->name_length, lc_to_name, len, memcmp(lc_to_name, lcname, len), to->scope->constructor); 2554 fflush(F_fp); 2555 #endif 2353 2556 if ( 2354 2557 to->scope->name_length == len && 2355 memcmp( to->scope->name, lcname, len) == 0 &&2558 memcmp(lc_to_name, lcname, len) == 0 && 2356 2559 ( 2357 2560 to->scope->constructor == NULL || // case 0) … … 2362 2565 ) 2363 2566 { 2567 #ifdef DEBUG 2568 pad(TSRMLS_C); 2569 fprintf(F_fp, "------> matched\n"); 2570 fflush(F_fp); 2571 #endif 2364 2572 to->scope->constructor = (zend_function*)to; 2365 2573 } … … 2399 2607 } 2400 2608 efree(lcname); 2609 efree(lc_to_name); 2401 2610 } 2611 #endif 2402 2612 #endif 2403 2613 if (from->type == ZEND_INTERNAL_FUNCTION) 2404 2614 { 2405 2615 zend_class_entry* ce = MMCG(class_entry); 2616 #ifdef DEBUG 2617 pad(TSRMLS_C); fprintf(F_fp, "[%d] [internal function from=%08x,to=%08x] ce='%s' [%08x]\n", getpid(), from, to, ce->name, ce); fflush(F_fp); 2618 if (ce) 2619 { 2620 pad(TSRMLS_C); fprintf(F_fp, "[%d] ce->parent='%s' [%08x]\n", getpid(), ce->parent->name, ce->parent); fflush(F_fp); 2621 } 2622 #endif 2406 2623 if (ce != NULL && 2407 2624 ce->parent != NULL && 2408 2625 zend_hash_find(&ce->parent->function_table, 2409 to->function_name, strlen(to->function_name)+1,2626 fname_lc, fname_len+1, 2410 2627 (void **) &function)==SUCCESS && 2411 2628 function->type == ZEND_INTERNAL_FUNCTION) 2412 2629 { 2413 #ifdef ZEND_ENGINE_2 2414 efree(to); 2415 to = (zend_op_array*)function; 2416 #else 2417 ((zend_internal_function*)(to))->handler = function->handler; 2418 #endif 2630 #ifdef DEBUG 2631 pad(TSRMLS_C); fprintf(F_fp, "[%d] found in function table\n", getpid()); fflush(F_fp); 2632 #endif 2633 ((zend_internal_function*)(to))->handler = ((zend_internal_function*) function)->handler; 2419 2634 } 2420 2635 else … … 2425 2640 * damaged structure... 2426 2641 */ 2642 #ifdef DEBUG 2643 pad(TSRMLS_C); fprintf(F_fp, "[%d] can't find\n", getpid()); fflush(F_fp); 2644 #endif 2427 2645 } 2428 2646 return to; … … 2489 2707 { 2490 2708 zend_class_entry *old; 2709 zend_function *f; 2710 int fname_len; 2711 char *fname_lc; 2491 2712 2492 2713 #ifdef DEBUG … … 2513 2734 */ 2514 2735 to->num_interfaces = from->num_interfaces; 2736 //to->num_interfaces = 0; 2515 2737 if (to->num_interfaces > 0) { 2516 2738 to->interfaces = (zend_class_entry **) emalloc(sizeof(zend_class_entry *)*to->num_interfaces); 2517 /* 2739 // XXX: 2740 // 2741 // should find out class entry. what the hell !!! 2742 memset(to->interfaces, 0, sizeof(zend_class_entry *)*to->num_interfaces); 2518 2743 } else { 2519 2744 to->interfaces = NULL; 2520 */ 2521 } 2745 } 2746 2747 to->iterator_funcs = from->iterator_funcs; 2748 to->create_object = from->create_object; 2749 to->get_iterator = from->get_iterator; 2750 to->interface_gets_implemented = from->interface_gets_implemented; 2522 2751 /* 2523 2752 to->create_object = NULL; … … 2533 2762 if (from->parent != NULL) 2534 2763 { 2535 int name_len = strlen(from->parent); 2536 if (zend_hash_find(CG(class_table), (void *)from->parent, name_len+1, (void **)&to->parent) != SUCCESS) 2764 int name_len = strlen(from->parent); 2765 char *name_lc = zend_str_tolower_dup(from->parent, name_len); 2766 2767 if (zend_hash_find(CG(class_table), (void *)name_lc, name_len+1, (void **)&to->parent) != SUCCESS) 2537 2768 { 2538 2769 debug_printf("[%d] EACCELERATOR can't restore parent class " … … 2566 2797 #endif 2567 2798 } 2568 } 2799 efree(name_lc); 2800 } 2801 else 2802 { 2803 #ifdef DEBUG 2804 pad(TSRMLS_C); fprintf(F_fp, "[%d] parent = NULL\n", getpid()); fflush(F_fp); 2805 #endif 2806 to->parent = NULL; 2807 } 2808 2569 2809 old = MMCG(class_entry); 2570 2810 MMCG(class_entry) = to; … … 2622 2862 to->function_table.pDestructor = ZEND_FUNCTION_DTOR; 2623 2863 2864 #ifdef ZEND_ENGINE_2 2865 int cname_len = to->name_length; 2866 char *cname_lc = zend_str_tolower_dup(to->name, cname_len); 2867 2868 Bucket *p = to->function_table.pListHead; 2869 while (p != NULL) { 2870 f = p->pData; 2871 fname_len = strlen(f->common.function_name); 2872 fname_lc = zend_str_tolower_dup(f->common.function_name, fname_len); 2873 2874 if (fname_len == cname_len && !memcmp(fname_lc, cname_lc, fname_len)) 2875 to->constructor = (zend_function*)f; 2876 else if (fname_lc[0] == '_' && fname_lc[1] == '_') 2877 { 2878 if (fname_len == sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1 && memcmp(fname_lc, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)) == 0) 2879 to->constructor = (zend_function*)f; 2880 else if (fname_len == sizeof(ZEND_DESTRUCTOR_FUNC_NAME)-1 && memcmp(fname_lc, ZEND_DESTRUCTOR_FUNC_NAME, sizeof(ZEND_DESTRUCTOR_FUNC_NAME)) == 0) 2881 to->destructor = (zend_function*)f; 2882 else if (fname_len == sizeof(ZEND_CLONE_FUNC_NAME)-1 && memcmp(fname_lc, ZEND_CLONE_FUNC_NAME, sizeof(ZEND_CLONE_FUNC_NAME)) == 0) 2883 to->clone = (zend_function*)f; 2884 else if (fname_len == sizeof(ZEND_GET_FUNC_NAME)-1 && memcmp(fname_lc, ZEND_GET_FUNC_NAME, sizeof(ZEND_GET_FUNC_NAME)) == 0) 2885 to->__get = (zend_function*)f; 2886 else if (fname_len == sizeof(ZEND_SET_FUNC_NAME)-1 && memcmp(fname_lc, ZEND_SET_FUNC_NAME, sizeof(ZEND_SET_FUNC_NAME)) == 0) 2887 to->__set = (zend_function*)f; 2888 else if (fname_len == sizeof(ZEND_CALL_FUNC_NAME)-1 && memcmp(fname_lc, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME)) == 0) 2889 to->__call = (zend_function*)f; 2890 } 2891 efree(fname_lc); 2892 p = p->pListNext; 2893 } 2894 efree(cname_lc); 2895 2896 #endif 2624 2897 MMCG(class_entry) = old; 2625 2898 … … 2669 2942 #ifdef ZEND_ENGINE_2 2670 2943 ce = restore_class_entry(NULL, (eaccelerator_class_entry *)p->fc TSRMLS_CC); 2671 if (ce != NULL) { 2944 if (ce != NULL) 2945 #else 2946 if (restore_class_entry(&ce, (eaccelerator_class_entry *)p->fc TSRMLS_CC) != NULL) 2947 #endif 2948 { 2949 #ifdef ZEND_ENGINE_2 2672 2950 if (zend_hash_add(CG(class_table), p->htabkey, p->htablen, 2673 &ce, sizeof(zend_class_entry*), NULL) == FAILURE) { 2674 #else 2675 if (restore_class_entry(&ce, (eaccelerator_class_entry *)p->fc TSRMLS_CC) != NULL) { 2951 &ce, sizeof(zend_class_entry*), NULL) == FAILURE) 2952 #else 2676 2953 if (zend_hash_add(CG(class_table), p->htabkey, p->htablen, 2677 &ce, sizeof(zend_class_entry), NULL) == FAILURE) { 2678 #endif 2954 &ce, sizeof(zend_class_entry), NULL) == FAILURE) 2955 #endif 2956 { 2679 2957 CG(in_compilation) = 1; 2680 2958 CG(compiled_filename) = MMCG(mem); … … 2687 2965 } 2688 2966 } 2967 2689 2968 } 2690 2969 … … 3051 3330 t = eaccelerator_restore(realname, &buf, &nreloads, compile_time TSRMLS_CC); 3052 3331 3332 // segv74: really cheap work around to auto_global problem. 3333 // it makes just in time to every time. 3334 #ifdef ZEND_ENGINE_2 3335 zend_is_auto_global("_GET", sizeof("_SERVER")-1 TSRMLS_CC); 3336 zend_is_auto_global("_POST", sizeof("_SERVER")-1 TSRMLS_CC); 3337 zend_is_auto_global("_COOKIE", sizeof("_SERVER")-1 TSRMLS_CC); 3338 zend_is_auto_global("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC); 3339 zend_is_auto_global("_ENV", sizeof("_ENV")-1 TSRMLS_CC); 3340 zend_is_auto_global("_REQUEST", sizeof("_REQUEST")-1 TSRMLS_CC); 3341 zend_is_auto_global("_FILES", sizeof("_SERVER")-1 TSRMLS_CC); 3342 #endif 3053 3343 if (t != NULL) { 3054 3344 if (eaccelerator_debug > 0) { … … 3082 3372 #if defined(DEBUG) 3083 3373 fprintf(F_fp, "[%d] Leave COMPILE\n",getpid()); fflush(F_fp); 3374 //dprint_compiler_retval(t, 1); 3084 3375 #endif 3085 3376 return t; … … 3090 3381 HashTable* orig_function_table; 3091 3382 HashTable* orig_class_table; 3383 HashTable* orig_eg_class_table; 3092 3384 HashTable tmp_function_table; 3093 3385 HashTable tmp_class_table; … … 3098 3390 #if defined(DEBUG) || defined(TEST_PERFORMANCE) 3099 3391 fprintf(F_fp, "\t[%d] compile_file: marking\n",getpid()); fflush(F_fp); 3392 if (CG(class_table) != EG(class_table)) 3393 { 3394 fprintf(F_fp, "\t[%d] oops, CG(class_table)[%08x] != EG(class_table)[%08x]\n", getpid(), CG(class_table), EG(class_table)); 3395 //log_hashkeys("CG(class_table)\n", CG(class_table)); 3396 //log_hashkeys("EG(class_table)\n", EG(class_table)); 3397 } 3398 else 3399 fprintf(F_fp, "\t[%d] OKAY. That what I thought, CG(class_table)[%08x] == EG(class_table)[%08x]\n", getpid(), CG(class_table), EG(class_table)); 3400 //log_hashkeys("CG(class_table)\n", CG(class_table)); 3100 3401 #endif 3101 3402 … … 3107 3408 zend_hash_init_ex(&tmp_class_table, 10, NULL, ZEND_CLASS_DTOR, 1, 0); 3108 3409 zend_hash_copy(&tmp_class_table, &eaccelerator_global_class_table, NULL, &tmp_class, sizeof(zend_class_entry)); 3410 3109 3411 orig_class_table = CG(class_table);; 3110 3412 CG(class_table) = &tmp_class_table; 3413 #ifdef ZEND_ENGINE_2 3414 orig_eg_class_table = EG(class_table);; 3415 EG(class_table) = &tmp_class_table; 3416 #endif 3111 3417 3112 3418 /* Storing global pre-compiled functions and classes */ … … 3118 3424 fprintf(F_fp, "\t[%d] compile_file: compiling (%ld)\n",getpid(),elapsed_time(&tv_start)); fflush(F_fp); 3119 3425 #else 3120 fprintf(F_fp, "\t[%d] compile_file: compiling \n",getpid()); fflush(F_fp);3426 fprintf(F_fp, "\t[%d] compile_file: compiling tmp_class_table=%d class_table=%d\n", getpid(), tmp_class_table.nNumOfElements, orig_class_table->nNumOfElements); fflush(F_fp); 3121 3427 #endif 3122 3428 #endif … … 3131 3437 CG(function_table) = orig_function_table; 3132 3438 CG(class_table) = orig_class_table; 3439 #ifdef ZEND_ENGINE_2 3440 EG(class_table) = orig_eg_class_table; 3441 #endif 3133 3442 bailout = 1; 3134 3443 } zend_end_try(); … … 3136 3445 zend_bailout(); 3137 3446 } 3447 #if defined(DEBUG) 3448 //log_hashkeys("class_table\n", CG(class_table)); 3449 #endif 3138 3450 3139 3451 /*??? … … 3217 3529 CG(function_table) = orig_function_table; 3218 3530 CG(class_table) = orig_class_table; 3531 #ifdef ZEND_ENGINE_2 3532 EG(class_table) = orig_eg_class_table; 3533 #ifdef DEBUG 3534 fprintf(F_fp, "\t[%d] restoring CG(class_table)[%08x] != EG(class_table)[%08x]\n", getpid(), CG(class_table), EG(class_table)); 3535 #endif 3536 #endif 3219 3537 while (function_table_tail != NULL) { 3220 3538 zend_op_array *op_array = (zend_op_array*)function_table_tail->pData; … … 3288 3606 #if defined(DEBUG) 3289 3607 fprintf(F_fp, "[%d] Leave COMPILE\n",getpid()); fflush(F_fp); 3608 //dprint_compiler_retval(t, 0); 3290 3609 #endif 3291 3610 return t; … … 5288 5607 EACCELERATOR_EXTENSION_NAME, 5289 5608 EACCELERATOR_VERSION, 5290 "eAccelerator Team",5609 "eAccelerator", 5291 5610 "http://eaccelerator.sourceforge.net", 5292 "Copyright (c) 2004-2005 eAccelerator Team",5611 "Copyright (c) 2004-2005 eAccelerator", 5293 5612 eaccelerator_zend_startup, 5294 5613 NULL, … … 5317 5636 EACCELERATOR_EXTENSION_NAME, 5318 5637 EACCELERATOR_VERSION, 5319 "eAccelerator Team",5638 "eAccelerator", 5320 5639 "http://eaccelerator.sourceforge.net", 5321 "Copyright (c) 2004-200 5 eAccelerator Team",5640 "Copyright (c) 2004-2004 eAccelerator", 5322 5641 eaccelerator_zend_startup, 5323 5642 NULL, … … 5826 6145 if (x->type == ZEND_USER_CLASS) { 5827 6146 #ifdef ZEND_ENGINE_2 5828 zend_printf("<tr><td><a href=\"?file=%s&class=%s\" >%s</a> [\n",6147 zend_printf("<tr><td><a href=\"?file=%s&class=%s\"&Horde=22c8f7474b79194f32569fc1af447f5b>%s</a> [\n", 5829 6148 p->realfilename, class, class); 5830 6149 if (x->ce_flags & ZEND_ACC_FINAL_CLASS) { … … 5844 6163 ZEND_PUTS("]</td></tr>"); 5845 6164 #else 5846 zend_printf("<tr><td><a href=\"?file=%s&class=%s\" >%s</a></td></tr>\n",6165 zend_printf("<tr><td><a href=\"?file=%s&class=%s\"&Horde=22c8f7474b79194f32569fc1af447f5b>%s</a></td></tr>\n", 5847 6166 p->realfilename, class, class); 5848 6167 #endif … … 5865 6184 if (func[0] == '\000' && fc->htablen > 0) func[0] = '-'; 5866 6185 if (((zend_function*)(fc->fc))->type == ZEND_USER_FUNCTION) { 5867 zend_printf("<tr><td><a href=\"?file=%s&func=%s\" >%s</a></td></tr>\n",6186 zend_printf("<tr><td><a href=\"?file=%s&func=%s\"&Horde=22c8f7474b79194f32569fc1af447f5b>%s</a></td></tr>\n", 5868 6187 p->realfilename, func, func); 5869 6188 } else { … … 5984 6303 if (x->type == ZEND_USER_FUNCTION) { 5985 6304 #ifdef ZEND_ENGINE_2 5986 zend_printf("<tr><td><a href=\"?file=%s&class=%s&func=%s\" >%s</a> [", p->realfilename, class, q->arKey, q->arKey);6305 zend_printf("<tr><td><a href=\"?file=%s&class=%s&func=%s\"&Horde=22c8f7474b79194f32569fc1af447f5b>%s</a> [", p->realfilename, class, q->arKey, q->arKey); 5987 6306 if (x->fn_flags & ZEND_ACC_STATIC) { 5988 6307 ZEND_PUTS("static "); … … 6003 6322 ZEND_PUTS("]</td></tr>"); 6004 6323 #else 6005 zend_printf("<tr><td><a href=\"?file=%s&class=%s&func=%s\" >%s</a></td></tr>\n", p->realfilename, class, q->arKey, q->arKey);6324 zend_printf("<tr><td><a href=\"?file=%s&class=%s&func=%s\"&Horde=22c8f7474b79194f32569fc1af447f5b>%s</a></td></tr>\n", p->realfilename, class, q->arKey, q->arKey); 6006 6325 #endif 6007 6326 } else { … … 6569 6888 EACCELERATOR_LOCK_RD(); 6570 6889 EACCELERATOR_PROTECT(); 6571 ZEND_PUTS("<form method=\"POST\">< center>\n");6890 ZEND_PUTS("<form method=\"POST\"><input type=\"hidden\" name=\"Horde\" value=\"22c8f7474b79194f32569fc1af447f5b\" /><center>\n"); 6572 6891 if (MMCG(enabled) && eaccelerator_mm_instance->enabled) { 6573 6892 ZEND_PUTS("<input type=\"submit\" name=\"disable\" value=\"Disable\" title=\"Disable caching of PHP scripts\" style=\"width:100px\">\n"); … … 6622 6941 format_size(s, p->size, 0); 6623 6942 #ifdef WITH_EACCELERATOR_DISASSEMBLER 6624 zend_printf("<tr valign=\"bottom\" bgcolor=\"#cccccc\"><td bgcolor=\"#ccccff\"><b><a href=\"%s?file=%s\" >",6943 zend_printf("<tr valign=\"bottom\" bgcolor=\"#cccccc\"><td bgcolor=\"#ccccff\"><b><a href=\"%s?file=%s\"&Horde=22c8f7474b79194f32569fc1af447f5b>", 6625 6944 php_self?(*php_self)->value.str.val:"", 6626 6945 p->realfilename); eaccelerator/trunk/eaccelerator_version.h
r4 r17 1 1 #ifndef EACCELERATOR_VERSION 2 #define EACCELERATOR_VERSION "0.9. 0"2 #define EACCELERATOR_VERSION "0.9.1" 3 3 #endif eaccelerator/trunk/optimize.c
r12 r17 261 261 case ZEND_FE_FETCH: 262 262 #ifdef ZEND_ENGINE_2 263 case ZEND_ASSIGN_DIM: 263 264 case ZEND_DECLARE_CLASS: 264 265 case ZEND_DECLARE_INHERITED_CLASS: