Changeset 268
- Timestamp:
- 10/29/2006 02:05:01 AM (3 years ago)
- Location:
- trunk
- Files:
-
- 7 modified
-
processor/processor.m4 (modified) (2 diffs)
-
utils.c (modified) (7 diffs)
-
utils.h (modified) (1 diff)
-
xcache-zh-gb2312.ini (modified) (1 diff)
-
xcache.c (modified) (7 diffs)
-
xcache.h (modified) (3 diffs)
-
xcache.ini (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/processor/processor.m4
r267 r268 708 708 ') 709 709 dnl }}} 710 #ifdef ZEND_ENGINE_2_1 711 DEF_STRUCT_P_FUNC(`xc_autoglobal_t', , `dnl {{{ 712 DISPATCH(zend_uint, key_len) 713 #ifdef IS_UNICODE 714 DISPATCH(zend_uchar, type) 715 #endif 716 IFRESTORE(`COPY(key)', ` 717 PROC_ZSTRING_L(type, key, key_len) 718 ') 719 ') 720 dnl }}} 721 #endif 710 722 DEF_STRUCT_P_FUNC(`xc_entry_data_php_t', , `dnl {{{ 711 723 zend_uint i; … … 736 748 ') 737 749 STRUCT_ARRAY(classinfo_cnt, xc_classinfo_t, classinfos) 750 #ifdef ZEND_ENGINE_2_1 751 DISPATCH(zend_uint, autoglobal_cnt) 752 STRUCT_ARRAY(autoglobal_cnt, xc_autoglobal_t, autoglobals) 753 #endif 738 754 DISPATCH(zend_bool, have_early_binding) 739 755 popdef(`BEFORE_LOOP') -
trunk/utils.c
r264 r268 511 511 #define OG(x) (sandbox->orig_##x) 512 512 /* }}} */ 513 #ifdef ZEND_ENGINE_2_1 514 static zend_bool xc_auto_global_callback(char *name, uint name_len TSRMLS_DC) /* {{{ */ 515 { 516 zend_auto_global *auto_global; 517 if (zend_u_hash_find(CG(auto_globals), UG(unicode) ? IS_UNICODE : IS_STRING, ZSTR(name), name_len + 1, (void **) &auto_global) == FAILURE) { 518 return 1; 519 } 520 return 0; 521 } 522 /* }}} */ 523 static int xc_auto_global_arm(zend_auto_global *auto_global TSRMLS_DC) /* {{{ */ 524 { 525 if (auto_global->auto_global_callback) { 526 auto_global->armed = 1; 527 auto_global->auto_global_callback = xc_auto_global_callback; 528 } 529 else { 530 auto_global->armed = 0; 531 } 532 return ZEND_HASH_APPLY_KEEP; 533 } 534 /* }}} */ 535 #endif 513 536 xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC) /* {{{ */ 514 537 { … … 535 558 EG(class_table) = CG(class_table); 536 559 560 #ifdef ZEND_ENGINE_2_1 561 OG(auto_globals) = CG(auto_globals); 562 CG(auto_globals) = &TG(auto_globals); 563 #endif 564 537 565 TG(included_files) = &EG(included_files); 538 566 … … 543 571 zend_hash_init_ex(&TG(function_table), 128, NULL, OG(function_table)->pDestructor, 0, 0); 544 572 zend_hash_init_ex(&TG(class_table), 16, NULL, OG(class_table)->pDestructor, 0, 0); 573 #ifdef ZEND_ENGINE_2_1 574 zend_hash_init_ex(&TG(auto_globals), 8, NULL, OG(auto_globals)->pDestructor, 0, 0); 575 { 576 zend_auto_global tmp_autoglobal; 577 578 zend_hash_copy(&TG(auto_globals), OG(auto_globals), NULL, (void *) &tmp_autoglobal, sizeof(tmp_autoglobal)); 579 zend_hash_apply(&TG(auto_globals), (apply_func_t) xc_auto_global_arm TSRMLS_CC); 580 } 581 #endif 545 582 546 583 sandbox->filename = filename; … … 592 629 b = b->pListNext; 593 630 } 631 632 #ifdef ZEND_ENGINE_2_1 633 /* trigger auto_globals jit */ 634 for (b = TG(auto_globals).pListHead; b != NULL; b = b->pListNext) { 635 zend_auto_global *auto_global = (zend_auto_global *) b->pData; 636 /* check if actived */ 637 if (auto_global->auto_global_callback && !auto_global->armed) { 638 zend_u_is_auto_global(BUCKET_KEY_TYPE(b), ZSTR(BUCKET_KEY_S(b)), auto_global->name_len TSRMLS_CC); 639 } 640 } 641 #endif 642 594 643 xc_undo_pass_two(CG(active_op_array) TSRMLS_CC); 595 644 xc_foreach_early_binding_class(CG(active_op_array), xc_early_binding_cb, (void *) sandbox TSRMLS_CC); … … 609 658 CG(class_table) = OG(class_table); 610 659 EG(class_table) = CG(class_table); 660 #ifdef ZEND_ENGINE_2_1 661 CG(auto_globals) = OG(auto_globals); 662 #endif 611 663 612 664 if (install) { … … 624 676 TG(function_table).pDestructor = NULL; 625 677 TG(class_table).pDestructor = NULL; 678 #ifdef ZEND_ENGINE_2_1 679 TG(auto_globals).pDestructor = NULL; 680 #endif 626 681 } 627 682 … … 632 687 zend_hash_destroy(&TG(function_table)); 633 688 zend_hash_destroy(&TG(class_table)); 689 #ifdef ZEND_ENGINE_2_1 690 zend_hash_destroy(&TG(auto_globals)); 691 #endif 634 692 zend_hash_destroy(TG(included_files)); 635 693 -
trunk/utils.h
r212 r268 49 49 HashTable *orig_function_table; 50 50 HashTable *orig_class_table; 51 HashTable *orig_auto_globals; 51 52 HashTable tmp_function_table; 52 53 HashTable tmp_class_table; 54 HashTable tmp_auto_globals; 53 55 } xc_sandbox_t; 54 56 -
trunk/xcache-zh-gb2312.ini
r204 r268 9 9 ;; ��Win32 ϵͳ: 10 10 ; extension = php_xcache.dll 11 12 ; ��� php5.1 ���ϰ汾�� XCache, ���������13 auto_globals_jit = Off14 11 15 12 [xcache.admin] -
trunk/xcache.c
r254 r268 500 500 add_assoc_long_ex(ei, ZEND_STRS("function_cnt"), php->funcinfo_cnt); 501 501 add_assoc_long_ex(ei, ZEND_STRS("class_cnt"), php->classinfo_cnt); 502 #ifdef ZEND_ENGINE_2_1 503 add_assoc_long_ex(ei, ZEND_STRS("autoglobal_cnt"),php->autoglobal_cnt); 504 #endif 502 505 break; 503 506 case XC_TYPE_VAR: … … 580 583 UNISW(0, ci->type), ci->key, ci->key_size TSRMLS_CC); 581 584 } 585 586 #ifdef ZEND_ENGINE_2_1 587 /* trigger auto_globals jit */ 588 for (i = 0; i < p->autoglobal_cnt; i ++) { 589 xc_autoglobal_t *aginfo = &p->autoglobals[i]; 590 /* 591 zend_auto_global *auto_global; 592 if (zend_u_hash_find(CG(auto_globals), aginfo->type, aginfo->key, aginfo->key_len+1, (void **) &auto_global)==SUCCESS) { 593 if (auto_global->armed) { 594 auto_global->armed = auto_global->auto_global_callback(auto_global->name, auto_global->name_len TSRMLS_CC); 595 } 596 } 597 */ 598 zend_u_is_auto_global(aginfo->type, aginfo->key, aginfo->key_len TSRMLS_CC); 599 } 600 #endif 582 601 583 602 i = 1; … … 949 968 950 969 #ifdef HAVE_XCACHE_CONSTANT 951 php.constinfo_cnt = zend_hash_num_elements(EG(zend_constants)) - old_constinfo_cnt; 952 #endif 953 php.funcinfo_cnt = zend_hash_num_elements(CG(function_table)) - old_funcinfo_cnt; 954 php.classinfo_cnt = zend_hash_num_elements(CG(class_table)) - old_classinfo_cnt; 970 php.constinfo_cnt = zend_hash_num_elements(EG(zend_constants)) - old_constinfo_cnt; 971 #endif 972 php.funcinfo_cnt = zend_hash_num_elements(CG(function_table)) - old_funcinfo_cnt; 973 php.classinfo_cnt = zend_hash_num_elements(CG(class_table)) - old_classinfo_cnt; 974 #ifdef ZEND_ENGINE_2_1 975 /* {{{ count php.autoglobal_cnt */ { 976 Bucket *b; 977 978 php.autoglobal_cnt = 0; 979 for (b = CG(auto_globals)->pListHead; b != NULL; b = b->pListNext) { 980 zend_auto_global *auto_global = (zend_auto_global *) b->pData; 981 /* check if actived */ 982 if (auto_global->auto_global_callback && !auto_global->armed) { 983 php.autoglobal_cnt ++; 984 } 985 } 986 } 987 /* }}} */ 988 #endif 955 989 956 990 #define X_ALLOC_N(var, cnt) do { \ … … 967 1001 968 1002 #ifdef HAVE_XCACHE_CONSTANT 969 X_ALLOC_N(constinfos, constinfo_cnt); 970 #endif 971 X_ALLOC_N(funcinfos, funcinfo_cnt); 972 X_ALLOC_N(classinfos, classinfo_cnt); 1003 X_ALLOC_N(constinfos, constinfo_cnt); 1004 #endif 1005 X_ALLOC_N(funcinfos, funcinfo_cnt); 1006 X_ALLOC_N(classinfos, classinfo_cnt); 1007 #ifdef ZEND_ENGINE_2_1 1008 X_ALLOC_N(autoglobals, autoglobal_cnt); 1009 #endif 973 1010 #undef X_ALLOC 974 1011 /* }}} */ … … 1006 1043 1007 1044 #undef COPY_H 1008 /* for ZE1, cest need to fix inside store */ 1045 1046 /* for ZE1, cest need to be fixed inside store */ 1047 1048 #ifdef ZEND_ENGINE_2_1 1049 /* scan for acatived auto globals */ 1050 i = 0; 1051 for (b = CG(auto_globals)->pListHead; b != NULL; b = b->pListNext) { 1052 zend_auto_global *auto_global = (zend_auto_global *) b->pData; 1053 /* check if actived */ 1054 if (auto_global->auto_global_callback && !auto_global->armed) { 1055 xc_autoglobal_t *data = &php.autoglobals[i ++]; 1056 1057 assert(i < php.autoglobal_cnt); 1058 UNISW(NOTHING, data->type = b->key.type;) 1059 if (UNISW(1, b->key.type == IS_STRING)) { 1060 ZSTR_S(data->key) = BUCKET_KEY_S(b); 1061 } 1062 else { 1063 ZSTR_U(data->key) = BUCKET_KEY_U(b); 1064 } 1065 data->key_len = b->nKeyLength - 1; 1066 } 1067 } 1068 #endif 1009 1069 } 1010 1070 /* }}} */ … … 1036 1096 err_##var: 1037 1097 1098 #ifdef ZEND_ENGINE_2_1 1099 X_FREE(autoglobals) 1100 #endif 1038 1101 X_FREE(classinfos) 1039 1102 X_FREE(funcinfos) … … 1100 1163 efree(xce.data.php->var); \ 1101 1164 } 1165 #ifdef ZEND_ENGINE_2_1 1166 X_FREE(autoglobals) 1167 #endif 1102 1168 X_FREE(classinfos) 1103 1169 X_FREE(funcinfos) -
trunk/xcache.h
r263 r268 128 128 add_assoc_zval_ex(arg, key, key_len, value) 129 129 130 # define zend_u_is_auto_global(type, name, name_len) \ 131 zend_is_auto_global(name, name_len) 130 132 #endif 131 133 /* }}} */ … … 221 223 } xc_funcinfo_t; 222 224 /* }}} */ 225 #ifdef ZEND_ENGINE_2_1 226 /* {{{ xc_autoglobal_t */ 227 typedef struct { 228 #ifdef IS_UNICODE 229 zend_uchar type; 230 #endif 231 zstr key; 232 zend_uint key_len; 233 } xc_autoglobal_t; 234 /* }}} */ 235 #endif 223 236 typedef enum { XC_TYPE_PHP, XC_TYPE_VAR } xc_entry_type_t; 224 237 /* {{{ xc_entry_data_php_t */ … … 244 257 xc_classinfo_t *classinfos; 245 258 zend_bool have_early_binding; 259 260 #ifdef ZEND_ENGINE_2_1 261 zend_uint autoglobal_cnt; 262 xc_autoglobal_t *autoglobals; 263 #endif 246 264 } xc_entry_data_php_t; 247 265 /* }}} */ -
trunk/xcache.ini
r204 r268 9 9 ;; or win32: 10 10 ; extension = php_xcache.dll 11 12 ; required for >=php5.1 if you turn XCache on13 auto_globals_jit = Off14 11 15 12 [xcache.admin]

