Changeset 662
- Timestamp:
- 2009-08-03T10:15:53+02:00 (4 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
-
processor/dispatch.m4 (modified) (1 diff)
-
processor/head.m4 (modified) (6 diffs)
-
processor/main.m4 (modified) (2 diffs)
-
processor/processor.m4 (modified) (17 diffs)
-
processor/string.m4 (modified) (2 diffs)
-
processor/struct.m4 (modified) (4 diffs)
-
utils.h (modified) (2 diffs)
-
xcache.c (modified) (13 diffs)
-
xcache.h (modified) (6 diffs)
-
xcache_globals.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/processor/dispatch.m4
r484 r662 28 28 ) 29 29 ') 30 dnl {{{ DISPATCH_ARRAY(1:count, 2:type, 3:elm) 31 define(`DISPATCH_ARRAY', ` 32 if (src->$3) { 33 int i; 34 IFDASM(` 35 zval *arr; 36 ALLOC_INIT_ZVAL(arr); 37 array_init(arr); 38 for (i = 0; i < src->$1; i ++) { 39 ifelse( 40 `$2', `zend_bool', `add_assoc_bool_ex(arr, ZEND_STRS("$3"), src->$3[i] ? 1 : 0);' 41 , `', `', `add_assoc_long_ex(arr, ZEND_STRS("$3"), src->$3[i]);') 42 } 43 add_assoc_zval_ex(dst, ZEND_STRS("$3"), arr); 44 ', ` 45 COPY_N_EX($@) 46 for (i = 0; i < src->$1; i ++) { 47 DISABLECHECK(` 48 DISPATCH(`$2', `$3[i]', `$4') 49 ') 50 } 51 ')dnl IFDASM 52 DONE(`$3') 53 } 54 else { 55 COPYNULL(`$3') 56 } 57 ') 58 dnl }}} -
trunk/processor/head.m4
r645 r662 69 69 const xc_cache_t *cache; 70 70 const zend_class_entry *cache_ce; 71 zend_uint cache_class_ num;71 zend_uint cache_class_index; 72 72 73 73 const zend_op *active_opcodes_src; … … 75 75 const zend_class_entry *active_class_entry_src; 76 76 zend_class_entry *active_class_entry_dst; 77 zend_uint active_class_num; 77 zend_uint active_class_index; 78 zend_uint active_op_array_index; 79 const xc_op_array_info_t *active_op_array_infos_src; 78 80 79 81 zend_bool readonly_protection; /* wheather it's present */ … … 186 188 187 189 if (processor->cache_ce == ce) { 188 return processor->cache_class_ num;190 return processor->cache_class_index + 1; 189 191 } 190 192 for (i = 0; i < php->classinfo_cnt; i ++) { … … 192 194 if (ZCEP_REFCOUNT_PTR(ceptr) == ZCEP_REFCOUNT_PTR(ce)) { 193 195 processor->cache_ce = ceptr; 194 processor->cache_class_ num= i + 1;196 processor->cache_class_index = i + 1; 195 197 return i + 1; 196 198 } … … 199 201 return (zend_ulong) -1; 200 202 } 203 define(`xc_get_class_num', `xc_get_class_numNOTDEFINED') 201 204 /* }}} */ 202 205 /* {{{ xc_get_class */ … … 204 207 static zend_class_entry *xc_get_class(xc_processor_t *processor, zend_ulong class_num) { 205 208 /* must be parent or currrent class */ 206 assert(class_num <= processor->active_class_ num);209 assert(class_num <= processor->active_class_index + 1); 207 210 return CestToCePtr(processor->php_dst->classinfos[class_num - 1].cest); 208 211 } 209 212 #endif 213 define(`xc_get_class', `xc_get_classNOTDEFINED') 210 214 /* }}} */ 211 215 #ifdef ZEND_ENGINE_2 -
trunk/processor/main.m4
r569 r662 150 150 define(`COPY', `IFNOTMEMCPY(`IFCOPY(`dst->$1 = src->$1;')')DONE(`$1')') 151 151 dnl }}} 152 dnl {{{ COPY_N_EX 153 define(`COPY_N_EX', ` 154 ALLOC(`dst->$3', `$2', `src->$1') 155 IFCOPY(` 156 memcpy(dst->$3, src->$3, sizeof(dst->$3[0]) * src->$1); 157 ') 158 ') 159 dnl }}} 160 dnl {{{ COPY_N 161 define(`COPY_N', `COPY_N_EX(`$1',`$2')DONE(`$1')') 162 dnl }}} 152 163 dnl {{{ COPYPOINTER 153 164 define(`COPYPOINTER', `COPY(`$1')') 154 165 dnl }}} 166 dnl {{{ COPYARRAY_EX 167 define(`COPYARRAY_EX', `IFNOTMEMCPY(`IFCOPY(`memcpy(dst->$1, src->$1, sizeof(dst->$1));')')') 168 dnl }}} 155 169 dnl {{{ COPYARRAY 156 define(`COPYARRAY', ` IFNOTMEMCPY(`IFCOPY(`memcpy(dst->$1, src->$1, sizeof(dst->$1));')')DONE(`$1')')170 define(`COPYARRAY', `COPYARRAY_EX(`$1',`$2')DONE(`$1')') 157 171 dnl }}} 158 172 dnl {{{ SETNULL_EX … … 244 258 define(`IFNOTMEMCPY', `ifdef(`USEMEMCPY', `', `$1')') 245 259 REDEF(`KIND', `calc') include(srcdir`/processor/processor.m4') 260 pushdef(`xc_get_class_num', ``xc_get_class_num'($@)') 246 261 REDEF(`KIND', `store') include(srcdir`/processor/processor.m4') 262 popdef(`xc_get_class_num') 263 pushdef(`xc_get_class', ``xc_get_class'($@)') 247 264 REDEF(`KIND', `restore') include(srcdir`/processor/processor.m4') 265 popdef(`xc_get_class') 248 266 249 267 REDEF(`IFNOTMEMCPY', `$1') -
trunk/processor/processor.m4
r648 r662 339 339 if (src->num_interfaces) { 340 340 /* 341 int i; 341 342 zval *arr; 342 343 ALLOC_INIT_ZVAL(arr); … … 499 500 DEF_STRUCT_P_FUNC(`zend_op_array', , `dnl {{{ 500 501 IFRESTORE(` 502 const xc_op_array_info_t *op_array_info = &processor->active_op_array_infos_src[processor->active_op_array_index]; 501 503 dnl shadow copy must NOT meet: 502 504 dnl readonly_protection=on 503 505 dnl main op_array && have early binding 504 zend_uint ii;505 506 #ifdef ZEND_COMPILE_DELAYED_BINDING 506 507 zend_bool need_early_binding = 0; … … 508 509 zend_bool need_early_binding = processor->php_src->have_early_binding; 509 510 #endif 510 if (!processor->readonly_protection && !(src == processor->php_src->op_array && need_early_binding)) { 511 zend_bool shallow_copy = !processor->readonly_protection && !(src == processor->php_src->op_array && need_early_binding); 512 if (shallow_copy) { 513 zend_bool gc_arg_info = 0; 514 int gc_opcodes = 0; 511 515 /* really fast shallow copy */ 512 516 memcpy(dst, src, sizeof(src[0])); … … 515 519 STRUCT_P(HashTable, static_variables, HashTable_zval_ptr) 516 520 #ifdef ZEND_ENGINE_2 517 STRUCT_ARRAY_I(num_args, zend_arg_info, arg_info) 518 xc_gc_add_op_array(dst TSRMLS_CC); 519 #endif 521 STRUCT_ARRAY(num_args, zend_arg_info, arg_info) 522 gc_arg_info = 1; 523 #endif 524 if (op_array_info->oplineinfo_cnt) { 525 gc_opcodes = 1; 526 COPY_N_EX(last, zend_op, opcodes) 527 } 528 if (gc_arg_info || gc_opcodes) { 529 xc_gc_op_array_t gc_op_array; 530 #ifdef ZEND_ENGINE_2 531 gc_op_array.num_args = gc_arg_info ? dst->num_args : 0; 532 gc_op_array.arg_info = gc_arg_info ? dst->arg_info : NULL; 533 #endif 534 gc_op_array.last = gc_opcodes > 1 ? dst->last : 0; 535 gc_op_array.opcodes = gc_opcodes ? dst->opcodes : NULL; 536 xc_gc_add_op_array(&gc_op_array TSRMLS_CC); 537 } 520 538 define(`SKIPASSERT_ONCE') 521 539 } … … 524 542 do { 525 543 dnl RESTORE is done above! 526 zend_uint ii;527 int i;528 544 529 545 /* Common elements */ … … 532 548 #ifdef ZEND_ENGINE_2 533 549 DISPATCH(zend_uint, fn_flags) 534 STRUCT_ARRAY _I(num_args, zend_arg_info, arg_info)550 STRUCT_ARRAY(num_args, zend_arg_info, arg_info) 535 551 DISPATCH(zend_uint, num_args) 536 552 DISPATCH(zend_uint, required_num_args) … … 541 557 IFCOPY(`memcpy(dst->arg_types, src->arg_types, sizeof(src->arg_types[0]) * (src->arg_types[0]+1));') 542 558 IFDASM(`do { 543 zend_uint ii;544 559 int i; 545 560 zval *zv; … … 581 596 processor->active_opcodes_src = src->opcodes; 582 597 ')') 583 STRUCT_ARRAY _I(last, zend_op, opcodes)598 STRUCT_ARRAY(last, zend_op, opcodes) 584 599 popdef(`AFTER_ALLOC') 585 600 DISPATCH(zend_uint, last) … … 599 614 DISPATCH(zend_uint, T) 600 615 601 STRUCT_ARRAY _I(last_brk_cont, zend_brk_cont_element, brk_cont_array)616 STRUCT_ARRAY(last_brk_cont, zend_brk_cont_element, brk_cont_array) 602 617 DISPATCH(zend_uint, last_brk_cont) 603 618 DISPATCH(zend_uint, current_brk_cont) … … 649 664 #endif 650 665 } while (0); 666 IFRESTORE(`xc_fix_op_array_info(processor->php_src, dst, !shallow_copy, op_array_info TSRMLS_CC);') 651 667 652 668 #ifdef ZEND_ENGINE_2 … … 713 729 dnl }}} 714 730 #endif 731 DEF_STRUCT_P_FUNC(`xc_op_array_info_t', , `dnl {{{ 732 DISPATCH(zend_uint, oplineinfo_cnt) 733 DISPATCH_ARRAY(oplineinfo_cnt, int, oplineinfos) 734 ') 735 dnl }}} 715 736 DEF_STRUCT_P_FUNC(`xc_funcinfo_t', , `dnl {{{ 716 737 DISPATCH(zend_uint, key_size) … … 722 743 ') 723 744 DISPATCH(ulong, h) 745 IFRESTORE(`COPY(op_array_info)', ` 746 STRUCT(xc_op_array_info_t, op_array_info) 747 ') 748 IFRESTORE(` 749 processor->active_op_array_infos_src = &dst->op_array_info; 750 processor->active_op_array_index = 0; 751 ') 724 752 STRUCT(zend_function, func) 725 753 ') … … 734 762 ') 735 763 DISPATCH(ulong, h) 764 DISPATCH(zend_uint, methodinfo_cnt) 765 IFRESTORE(`COPY(methodinfos)', ` 766 STRUCT_ARRAY(methodinfo_cnt, xc_op_array_info_t, methodinfos) 767 ') 768 IFRESTORE(` 769 processor->active_op_array_infos_src = dst->methodinfos; 770 processor->active_op_array_index = 0; 771 ') 736 772 #ifdef ZEND_ENGINE_2 737 773 STRUCT_P(zend_class_entry, cest) … … 767 803 #endif 768 804 DEF_STRUCT_P_FUNC(`xc_entry_data_php_t', , `dnl {{{ 769 zend_uint i;770 771 805 IFCOPY(` 772 806 processor->php_dst = dst; … … 785 819 DISPATCH(size_t, size) 786 820 821 DISPATCH(int, filepath_len) 822 IFRESTORE(`COPY(filepath)', `PROC_STRING_L(filepath, filepath_len)') 823 DISPATCH(int, dirpath_len) 824 IFRESTORE(`COPY(dirpath)', `PROC_STRING_L(dirpath, dirpath_len)') 825 #ifdef IS_UNICODE 826 DISPATCH(int, ufilepath_len) 827 IFRESTORE(`COPY(ufilepath)', `PROC_USTRING_L(ufilepath, ufilepath_len)') 828 DISPATCH(int, udirpath_len) 829 IFRESTORE(`COPY(udirpath)', `PROC_USTRING_L(udirpath, udirpath_len)') 830 #endif 831 832 IFRESTORE(`COPY(op_array_info)', ` 833 STRUCT(xc_op_array_info_t, op_array_info) 834 ') 835 IFRESTORE(` 836 processor->active_op_array_infos_src = &dst->op_array_info; 837 processor->active_op_array_index = 0; 838 ') 787 839 STRUCT_P(zend_op_array, op_array) 788 840 … … 796 848 797 849 DISPATCH(zend_uint, classinfo_cnt) 798 pushdef(`BEFORE_LOOP', ` 799 IFCOPY(` 800 processor->active_class_num = i + 1; 801 ') 802 ') 803 STRUCT_ARRAY(classinfo_cnt, xc_classinfo_t, classinfos) 804 popdef(`BEFORE_LOOP') 850 STRUCT_ARRAY(classinfo_cnt, xc_classinfo_t, classinfos, , IFRESTORE(`processor->active_class_index')) 805 851 #ifdef ZEND_ENGINE_2_1 806 852 DISPATCH(zend_uint, autoglobal_cnt) … … 879 925 switch (src->type) { 880 926 case XC_TYPE_PHP: 881 IFCALCCOPY(` DONE(data.php)', `STRUCT_P(xc_entry_data_php_t, data.php)')927 IFCALCCOPY(`COPY(data.php)', `STRUCT_P(xc_entry_data_php_t, data.php)') 882 928 break; 883 929 -
trunk/processor/string.m4
r658 r662 7 7 STRTYPE, `zstr_char', `char', 8 8 `', `', `UChar')) 9 pushdef(`ISTYPE', ifelse( STRTYPE,`zstr_uchar',IS_UNICODE,IS_STRING))9 pushdef(`ISTYPE', ifelse(PTRTYPE,`UChar',IS_UNICODE,IS_STRING)) 10 10 pushdef(`UNI_STRLEN', ifelse( 11 11 STRTYPE, `zstr_uchar', `xc_zstrlen_uchar', 12 12 STRTYPE, `zstr_char', `xc_zstrlen_char', 13 13 `', `', `strlen')) 14 pushdef(`SRCSTR', ifelse(STRTYPE,`char',`ZSTR($2)', `$2'))14 pushdef(`SRCSTR', ifelse(STRTYPE,`char',`ZSTR($2)',STRTYPE,`UChar',`ZSTR($2)',`$2')) 15 15 pushdef(`SRCPTR', ifelse( 16 16 STRTYPE, `zstr_uchar', `ZSTR_U($2)', … … 88 88 dnl PROC_STRING_N(1:name, 2:size, 3:type) 89 89 define(`PROC_STRING_N', `DBG(`$0($*)') DONE(`$1')`'PROC_STRING_N_EX(`dst->$1', `src->$1', `src->$2', `$1', `char')') 90 define(`PROC_USTRING_N', `DBG(`$0($*)') DONE(`$1')`'PROC_STRING_N_EX(`dst->$1', `src->$1', `src->$2', `$1', `UChar')') 90 91 91 92 define(`PROC_STRING_L', `DBG(`$0($*)') PROC_STRING_N(`$1', `$2 + 1')') 93 define(`PROC_USTRING_L', `DBG(`$0($*)') PROC_USTRING_N(`$1', `$2 + 1')') 92 94 define(`PROC_STRING', `DBG(`$0($*)') DONE(`$1')`'PROC_STRING_N_EX(`dst->$1', `src->$1', `strlen(src->$1) + 1', `$1', `char')') 95 define(`PROC_USTRING', `DBG(`$0($*)') DONE(`$1')`'PROC_STRING_N_EX(`dst->$1', `src->$1', `strlen(src->$1) + 1', `$1', `UChar')') 93 96 94 97 dnl {{{ PROC_ZSTRING_N(1:type, 2:name, 3:size, 4:size_type) -
trunk/processor/struct.m4
r534 r662 165 165 ') 166 166 dnl }}} 167 dnl {{{ STRUCT_ARRAY_I(1:count, 2:type, 3:elm, 4:name=type) 168 define(`STRUCT_ARRAY_I', ` 169 pushdef(`i', `ii') 170 STRUCT_ARRAY(`$1', `$2', `$3', `$4') 171 popdef(`i') 172 ') 173 dnl }}} 174 dnl {{{ STRUCT_ARRAY(1:count, 2:type, 3:elm, 4:name=type) 167 dnl {{{ STRUCT_ARRAY(1:count, 2:type, 3:elm, 4:name=type, 5:loopcounter) 175 168 define(`STRUCT_ARRAY', ` 176 169 if (src->$3) { 170 ifelse( 171 `$5', `', `int i; pushdef(`LOOPCOUNTER', `i')', 172 `', `', `pushdef(`LOOPCOUNTER', `$5')') 177 173 pushdefFUNC_NAME(`$2', `$4') 178 174 IFDASM(` … … 180 176 ALLOC_INIT_ZVAL(arr); 181 177 array_init(arr); 182 for ( i = 0; i < src->$1; i++) {178 for (LOOPCOUNTER = 0; LOOPCOUNTER < src->$1; LOOPCOUNTER ++) { 183 179 zval *zv; 184 180 185 181 ALLOC_INIT_ZVAL(zv); 186 182 array_init(zv); 187 FUNC_NAME (zv, &(src->$3[ i]) TSRMLS_CC);183 FUNC_NAME (zv, &(src->$3[LOOPCOUNTER]) TSRMLS_CC); 188 184 add_next_index_zval(arr, zv); 189 185 } … … 192 188 ALLOC(`dst->$3', `$2', `src->$1') 193 189 ifdef(`AFTER_ALLOC', AFTER_ALLOC) 194 for ( i = 0; i < src->$1; i++) {190 for (LOOPCOUNTER = 0; LOOPCOUNTER < src->$1; LOOPCOUNTER ++) { 195 191 DISABLECHECK(` 196 ifdef(`BEFORE_LOOP', `BEFORE_LOOP') 197 STRUCT(`$2', `$3[i]', `$4') 192 STRUCT(`$2', `$3[LOOPCOUNTER]', `$4') 198 193 ') 199 194 } … … 201 196 DONE(`$3') 202 197 popdef(`FUNC_NAME') 198 popdef(`LOOPCOUNTER') 203 199 } 204 200 else { -
trunk/utils.h
r640 r662 38 38 39 39 # define IFDEBUG(x) do { } while (0) 40 # ifndef NDEBUG41 # define NDEBUG42 # endif43 40 #endif /* XCACHE_DEBUG */ 44 41 #include <assert.h> … … 132 129 void xc_copy_internal_zend_constants(HashTable *target, HashTable *source); 133 130 #endif 131 132 typedef struct { 133 zend_uint size; 134 zend_uint cnt; 135 void *data; 136 } xc_vector_t; 137 138 #define xc_vector_init(type, vector) do { \ 139 (vector)->cnt = 0; \ 140 (vector)->size = 0; \ 141 (vector)->data = NULL; \ 142 } while (0) 143 144 #define xc_vector_add(type, vector, value) do { \ 145 if ((vector)->cnt == (vector)->size) { \ 146 if ((vector)->size) { \ 147 (vector)->size <<= 1; \ 148 (vector)->data = erealloc((vector)->data, sizeof(type) * (vector)->size); \ 149 } \ 150 else { \ 151 (vector)->size = 8; \ 152 (vector)->data = emalloc(sizeof(type) * (vector)->size); \ 153 } \ 154 } \ 155 ((type *) (vector)->data)[(vector)->cnt++] = value; \ 156 } while (0) 157 158 static inline void *xc_vector_detach_impl(xc_vector_t *vector) 159 { 160 void *data = vector->data; 161 vector->data = NULL; 162 vector->size = 0; 163 vector->cnt = 0; 164 return data; 165 } 166 167 #define xc_vector_detach(type, vector) ((type *) xc_vector_detach_impl(vector)) 168 169 static inline void xc_vector_free_impl(xc_vector_t *vector TSRMLS_DC) 170 { 171 if (vector->data) { 172 efree(vector->data); 173 } 174 vector->size = 0; 175 vector->cnt = 0; 176 } 177 178 #define xc_vector_free(type, vector) xc_vector_free_impl(vector TSRMLS_CC) 179 -
trunk/xcache.c
r661 r662 37 37 #include "opcode_spec.h" 38 38 #include "utils.h" 39 40 #ifndef ZEND_ENGINE_2_3 41 ZEND_API size_t zend_dirname(char *path, size_t len) 42 { 43 php_dirname(path, len); 44 return strlen(path); 45 } 46 #endif 39 47 40 48 #define VAR_ENTRY_EXPIRED(pentry) ((pentry)->ttl && XG(request_time) > pentry->ctime + (pentry)->ttl) … … 1005 1013 { 1006 1014 /* hash on filename, let's expand it to real path */ 1015 /* FIXME */ 1007 1016 filename = expand_filepath(filename, opened_path_buffer TSRMLS_CC); 1008 1017 if (filename == NULL) { … … 1108 1117 /* }}} */ 1109 1118 #endif 1119 1120 /* {{{ Constant Usage */ 1121 #define xcache_op1_is_file 1 1122 #define xcache_op1_is_dir 2 1123 #define xcache_op2_is_file 4 1124 #define xcache_op2_is_dir 8 1125 typedef struct { 1126 zend_bool filepath_used; 1127 zend_bool dirpath_used; 1128 zend_bool ufilepath_used; 1129 zend_bool udirpath_used; 1130 } xc_const_usage_t; 1131 /* }}} */ 1132 static void xc_collect_op_array_info(xc_entry_data_php_t *php, xc_const_usage_t *usage, xc_op_array_info_t *op_array_info, zend_op_array *op_array TSRMLS_DC) /* {{{ */ 1133 { 1134 int oplineno; 1135 xc_vector_t vector_int; 1136 1137 xc_vector_init(int, &vector_int); 1138 1139 #define XCACHE_CHECK_OP(type, op) \ 1140 if (zend_binary_strcmp(Z_STRVAL(opline->op.u.constant), Z_STRLEN(opline->op.u.constant), php->type##path, php->type##path_len) == 0) { \ 1141 usage->type##path_used = 1; \ 1142 oplineinfo |= xcache_##op##_is_##type; \ 1143 } 1144 1145 #define XCACHE_U_CHECK_OP(type, op) \ 1146 if (zend_u_##binary_strcmp(Z_USTRVAL(opline->op.u.constant), Z_USTRLEN(opline->op.u.constant), php->u##type##path, php->u##type##path_len) == 0) { \ 1147 usage->u##type##path_used = 1; \ 1148 oplineinfo |= xcache_##op##_is_##type; \ 1149 } 1150 1151 for (oplineno = 0; oplineno < op_array->last; oplineno++) { 1152 zend_op *opline = &op_array->opcodes[oplineno]; 1153 int oplineinfo = 0; 1154 if (opline->op1.op_type == IS_CONST) { 1155 if (Z_TYPE(opline->op1.u.constant) == IS_STRING) { 1156 XCACHE_CHECK_OP(file, op1) 1157 else XCACHE_CHECK_OP(dir, op1) 1158 } 1159 1160 #ifdef IS_UNICODE 1161 else if (Z_TYPE(opline->op1.u.constant) == IS_UNICODE) { 1162 XCACHE_U_CHECK_OP(file, op1) 1163 else XCACHE_U_CHECK_OP(dir, op1) 1164 } 1165 #endif 1166 } 1167 if (opline->op2.op_type == IS_CONST) { 1168 if (Z_TYPE(opline->op2.u.constant) == IS_STRING) { 1169 XCACHE_CHECK_OP(file, op2) 1170 else XCACHE_CHECK_OP(dir, op2) 1171 } 1172 1173 #ifdef IS_UNICODE 1174 else if (Z_TYPE(opline->op2.u.constant) == IS_UNICODE) { 1175 XCACHE_U_CHECK_OP(file, op2) 1176 else XCACHE_U_CHECK_OP(dir, op2) 1177 } 1178 #endif 1179 } 1180 if (oplineinfo) { 1181 xc_vector_add(int, &vector_int, oplineno); 1182 xc_vector_add(int, &vector_int, oplineinfo); 1183 } 1184 } 1185 1186 op_array_info->oplineinfo_cnt = vector_int.cnt; 1187 op_array_info->oplineinfos = xc_vector_detach(int, &vector_int); 1188 xc_vector_free(int, &vector_int); 1189 } 1190 /* }}} */ 1191 void xc_fix_op_array_info(const xc_entry_data_php_t *php, zend_op_array *op_array, int copy, const xc_op_array_info_t *op_array_info TSRMLS_DC) /* {{{ */ 1192 { 1193 int i; 1194 if (!op_array_info->oplineinfo_cnt) { 1195 return; 1196 } 1197 1198 for (i = 0; i < op_array_info->oplineinfo_cnt; i += 2) { 1199 int oplineno = op_array_info->oplineinfos[i]; 1200 int oplineinfo = op_array_info->oplineinfos[i + 1]; 1201 zend_op *opline = &op_array->opcodes[oplineno]; 1202 if ((oplineinfo & xcache_op1_is_file)) { 1203 assert(opline->op1.op_type == IS_CONST); 1204 if (copy) { 1205 efree(Z_STRVAL(opline->op1.u.constant)); 1206 } 1207 if (Z_TYPE(opline->op1.u.constant) == IS_STRING) { 1208 assert(php->filepath); 1209 ZVAL_STRINGL(&opline->op1.u.constant, php->filepath, php->filepath_len, copy); 1210 } 1211 #ifdef IS_UNICODE 1212 else if (Z_TYPE(opline->op1.u.constant) == IS_UNICODE) { 1213 assert(php->ufilepath); 1214 ZVAL_UNICODEL(&opline->op1.u.constant, php->ufilepath, php->ufilepath_len, copy); 1215 } 1216 #endif 1217 else { 1218 assert(0); 1219 } 1220 } 1221 else if ((oplineinfo & xcache_op1_is_dir)) { 1222 assert(opline->op1.op_type == IS_CONST); 1223 if (copy) { 1224 efree(Z_STRVAL(opline->op1.u.constant)); 1225 } 1226 if (Z_TYPE(opline->op1.u.constant) == IS_STRING) { 1227 assert(php->dirpath); 1228 ZVAL_STRINGL(&opline->op1.u.constant, php->dirpath, php->dirpath_len, copy); 1229 } 1230 #ifdef IS_UNICODE 1231 else if (Z_TYPE(opline->op1.u.constant) == IS_UNICODE) { 1232 assert(!php->udirpath); 1233 ZVAL_UNICODEL(&opline->op1.u.constant, php->udirpath, php->udirpath_len, copy); 1234 } 1235 #endif 1236 else { 1237 assert(0); 1238 } 1239 } 1240 1241 if ((oplineinfo & xcache_op2_is_file)) { 1242 assert(opline->op2.op_type == IS_CONST); 1243 if (copy) { 1244 efree(Z_STRVAL(opline->op2.u.constant)); 1245 } 1246 if (Z_TYPE(opline->op2.u.constant) == IS_STRING) { 1247 assert(php->filepath); 1248 ZVAL_STRINGL(&opline->op2.u.constant, php->filepath, php->filepath_len, copy); 1249 } 1250 #ifdef IS_UNICODE 1251 else if (Z_TYPE(opline->op2.u.constant) == IS_UNICODE) { 1252 assert(php->ufilepath); 1253 ZVAL_UNICODEL(&opline->op2.u.constant, php->ufilepath, php->ufilepath_len, copy); 1254 } 1255 #endif 1256 else { 1257 assert(0); 1258 } 1259 } 1260 else if ((oplineinfo & xcache_op2_is_dir)) { 1261 assert(opline->op2.op_type == IS_CONST); 1262 if (copy) { 1263 efree(Z_STRVAL(opline->op2.u.constant)); 1264 } 1265 if (Z_TYPE(opline->op2.u.constant) == IS_STRING) { 1266 assert(!php->dirpath); 1267 ZVAL_STRINGL(&opline->op2.u.constant, php->dirpath, php->dirpath_len, copy); 1268 } 1269 #ifdef IS_UNICODE 1270 else if (Z_TYPE(opline->op2.u.constant) == IS_UNICODE) { 1271 assert(!php->udirpath); 1272 ZVAL_UNICODEL(&opline->op2.u.constant, php->udirpath, php->udirpath_len, copy); 1273 } 1274 #endif 1275 else { 1276 assert(0); 1277 } 1278 } 1279 } 1280 } 1281 /* }}} */ 1282 static void xc_free_op_array_info(xc_op_array_info_t *op_array_info TSRMLS_DC) /* {{{ */ 1283 { 1284 if (op_array_info->oplineinfos) { 1285 efree(op_array_info->oplineinfos); 1286 } 1287 } 1288 /* }}} */ 1110 1289 static void xc_free_php(xc_entry_data_php_t *php TSRMLS_DC) /* {{{ */ 1111 1290 { 1291 int i; 1292 if (php->classinfos) { 1293 for (i = 0; i < php->classinfo_cnt; i ++) { 1294 xc_classinfo_t *classinfo = &php->classinfos[i]; 1295 int j; 1296 for (j = 0; j < classinfo->methodinfo_cnt; j ++) { 1297 xc_free_op_array_info(&classinfo->methodinfos[j] TSRMLS_CC); 1298 } 1299 1300 if (classinfo->methodinfos) { 1301 efree(classinfo->methodinfos); 1302 } 1303 } 1304 } 1305 if (php->funcinfos) { 1306 for (i = 0; i < php->funcinfo_cnt; i ++) { 1307 xc_free_op_array_info(&php->funcinfos[i].op_array_info TSRMLS_CC); 1308 } 1309 } 1310 xc_free_op_array_info(&php->op_array_info TSRMLS_CC); 1311 1112 1312 #define X_FREE(var) do {\ 1113 1313 if (php->var) { \ … … 1116 1316 } while (0) 1117 1317 1318 X_FREE(dirpath); 1319 #ifdef IS_UNICODE 1320 X_FREE(ufilepath); 1321 X_FREE(udirpath); 1322 #endif 1323 1118 1324 #ifdef ZEND_ENGINE_2_1 1119 1325 X_FREE(autoglobals); … … 1132 1338 int old_constinfo_cnt, old_funcinfo_cnt, old_classinfo_cnt; 1133 1339 zend_bool catched = 0; 1340 xc_const_usage_t const_usage; 1134 1341 1135 1342 /* {{{ compile */ … … 1162 1369 /* }}} */ 1163 1370 /* {{{ prepare */ 1371 zend_restore_compiled_filename(h->opened_path ? h->opened_path : h->filename TSRMLS_CC); 1164 1372 php->op_array = op_array; 1165 1373 … … 1206 1414 #endif 1207 1415 #undef X_ALLOC 1416 /* }}} */ 1417 1418 /* {{{ file/dir path init */ 1419 memset(&const_usage, 0, sizeof(const_usage)); 1420 php->filepath = zend_get_compiled_filename(TSRMLS_C); 1421 php->filepath_len = strlen(php->filepath); 1422 php->dirpath = estrndup(php->filepath, php->filepath_len); 1423 php->dirpath_len = zend_dirname(php->dirpath, php->filepath_len); 1424 #ifdef IS_UNICODE 1425 zend_string_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &php->ufilepath, &php->ufilepath_len, php->filepath, php->filepath_len TSRMLS_CC); 1426 zend_string_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &php->udirpath, &php->udirpath_len, php->dirpath, php->dirpath_len TSRMLS_CC); 1427 #endif 1208 1428 /* }}} */ 1209 1429 /* {{{ shallow copy, pointers only */ { … … 1242 1462 b = CG(class_table)->pListHead; COPY_H(xc_classinfo_t, classinfos, classinfo_cnt, cest, xc_cest_t); 1243 1463 1464 for (i = 0; i < php->classinfo_cnt; i ++) { 1465 xc_classinfo_t *classinfo = &php->classinfos[i]; 1466 zend_class_entry *ce = CestToCePtr(classinfo->cest); 1467 classinfo->methodinfo_cnt = ce->function_table.nTableSize; 1468 if (classinfo->methodinfo_cnt) { 1469 int j; 1470 1471 ECALLOC_N(classinfo->methodinfos, classinfo->methodinfo_cnt); 1472 if (!classinfo->methodinfos) { 1473 goto err_alloc; 1474 } 1475 1476 for (j = 0, b = ce->function_table.pListHead; b; j ++, b = b->pListNext) { 1477 xc_collect_op_array_info(php, &const_usage, &classinfo->methodinfos[j], (zend_op_array *) b->pData TSRMLS_CC); 1478 } 1479 } 1480 else { 1481 classinfo->methodinfos = NULL; 1482 } 1483 } 1484 1485 for (i = 0; i < php->funcinfo_cnt; i ++) { 1486 xc_collect_op_array_info(php, &const_usage, &php->funcinfos[i].op_array_info, (zend_op_array *) &php->funcinfos[i].func TSRMLS_CC); 1487 } 1488 1489 xc_collect_op_array_info(php, &const_usage, &php->op_array_info, php->op_array TSRMLS_CC); 1490 1244 1491 #undef COPY_H 1245 1492 … … 1271 1518 } 1272 1519 /* }}} */ 1520 /* {{{ file/dir path free unused */ 1521 #define X_FREE_UNUSED(var) \ 1522 if (!const_usage.var##path_used) { \ 1523 efree(php->var##path); \ 1524 php->var##path = NULL; \ 1525 php->var##path_len = 0; \ 1526 } 1527 if (!const_usage.filepath_used) { 1528 php->filepath = NULL; 1529 php->filepath_len = 0; 1530 } 1531 X_FREE_UNUSED(dir) 1532 #ifdef IS_UNICODE 1533 X_FREE_UNUSED(ufile) 1534 X_FREE_UNUSED(udir) 1535 #endif 1536 #undef X_FREE_UNUSED 1537 /* }}} */ 1273 1538 #ifdef E_STRICT 1274 1539 php->compilererrors = ((xc_sandbox_t *) XG(sandbox))->compilererrors; … … 1467 1732 php.autoglobals = NULL; 1468 1733 #endif 1734 memset(&php.op_array_info, 0, sizeof(php.op_array_info)); 1735 1469 1736 zend_try { 1470 1737 op_array = xc_compile_php(&php, h, type TSRMLS_CC); … … 1638 1905 /* }}} */ 1639 1906 1640 #ifdef ZEND_ENGINE_2 1641 /* {{{ xc_gc_op_array_t */ 1642 typedef struct { 1643 zend_uint num_args; 1644 zend_arg_info *arg_info; 1645 } xc_gc_op_array_t; 1646 /* }}} */ 1647 void xc_gc_add_op_array(zend_op_array *op_array TSRMLS_DC) /* {{{ */ 1648 { 1649 xc_gc_op_array_t gc_op_array; 1650 gc_op_array.num_args = op_array->num_args; 1651 gc_op_array.arg_info = op_array->arg_info; 1652 #ifdef ZEND_ENGINE_2 1653 zend_llist_add_element(&XG(gc_op_arrays), (void *) &gc_op_array); 1654 #endif 1907 void xc_gc_add_op_array(xc_gc_op_array_t *gc_op_array TSRMLS_DC) /* {{{ */ 1908 { 1909 zend_llist_add_element(&XG(gc_op_arrays), (void *) gc_op_array); 1655 1910 } 1656 1911 /* }}} */ … … 1659 1914 xc_gc_op_array_t *op_array = (xc_gc_op_array_t *) pDest; 1660 1915 zend_uint i; 1916 #ifdef ZEND_ENGINE_2 1661 1917 if (op_array->arg_info) { 1662 1918 for (i = 0; i < op_array->num_args; i++) { … … 1668 1924 efree(op_array->arg_info); 1669 1925 } 1670 } 1671 /* }}} */ 1672 #endif 1926 #endif 1927 if (op_array->opcodes) { 1928 efree(op_array->opcodes); 1929 } 1930 } 1931 /* }}} */ 1673 1932 1674 1933 /* module helper function */ -
trunk/xcache.h
r659 r662 62 62 #ifndef IS_CONSTANT_TYPE_MASK 63 63 # define IS_CONSTANT_TYPE_MASK (~IS_CONSTANT_INDEX) 64 #endif 65 66 #ifndef ZEND_ENGINE_2_3 67 #define zend_dirname(path, len) xc_dirname(path, len) 64 68 #endif 65 69 … … 238 242 } xc_cache_t; 239 243 /* }}} */ 244 /* {{{ xc_op_array_info_t */ 245 typedef struct { 246 zend_uint oplineinfo_cnt; 247 int *oplineinfos; 248 } xc_op_array_info_t; 249 /* }}} */ 240 250 /* {{{ xc_classinfo_t */ 241 251 typedef struct { … … 246 256 zend_uint key_size; 247 257 ulong h; 258 zend_uint methodinfo_cnt; 259 xc_op_array_info_t *methodinfos; 248 260 xc_cest_t cest; 249 261 #ifndef ZEND_COMPILE_DELAYED_BINDING … … 273 285 zend_uint key_size; 274 286 ulong h; 287 xc_op_array_info_t op_array_info; 275 288 zend_function func; 276 289 } xc_funcinfo_t; … … 311 324 size_t size; 312 325 326 int filepath_len; 327 char *filepath; 328 int dirpath_len; 329 char *dirpath; 330 #ifdef IS_UNICODE 331 UChar *ufilepath; 332 int ufilepath_len; 333 UChar *udirpath; 334 int udirpath_len; 335 #endif 336 337 xc_op_array_info_t op_array_info; 313 338 zend_op_array *op_array; 314 339 … … 387 412 int xc_is_ro(const void *p); 388 413 int xc_is_shm(const void *p); 389 void xc_gc_add_op_array(zend_op_array *op_array TSRMLS_DC); 414 /* {{{ xc_gc_op_array_t */ 415 typedef struct { 416 #ifdef ZEND_ENGINE_2 417 zend_uint num_args; 418 zend_arg_info *arg_info; 419 #endif 420 zend_uint last; 421 zend_op *opcodes; 422 } xc_gc_op_array_t; 423 /* }}} */ 424 void xc_gc_add_op_array(xc_gc_op_array_t *gc_op_array TSRMLS_DC); 425 void xc_fix_op_array_info(const xc_entry_data_php_t *php, zend_op_array *op_array, int shallow_copied, const xc_op_array_info_t *op_array_info TSRMLS_DC); 390 426 391 427 #endif /* __XCACHE_H */ -
trunk/xcache_globals.h
r656 r662 18 18 long var_ttl; 19 19 20 #ifdef ZEND_ENGINE_221 20 zend_llist gc_op_arrays; 22 #endif23 21 24 22 #ifdef HAVE_XCACHE_CONSTANT
Note: See TracChangeset
for help on using the changeset viewer.

