CVS update: php31/main

From: Date: Sat, 17 Oct 1998 18:19:49 +0000
Subject: CVS update: php31/main
Groups: php.dev 
Request: Send a blank email to php-dev+get-1867@lists.php.net to get a copy of this message
Date: Saturday October 17, 1998 @ 14:19 Author: zeev Update of /repository/php31/main In directory asf:/u2/tmp/cvs-serv13624/main Modified Files: alloc.c constants.c control_structures_inline.h language-parser.y language-scanner.l main.c mime.c tls.h token_cache.c token_cache.h Log Message: 3.0 patches: * mime.c leak fix * constant.c leak fix * token cache code optimization and limits * out of memory handling * token cache optimization & fixes * added uksort() Index: php31/main/alloc.c diff -c php31/main/alloc.c:2.6 php31/main/alloc.c:2.7 *** php31/main/alloc.c:2.6 Tue Sep 22 15:19:46 1998 --- php31/main/alloc.c Sat Oct 17 14:19:47 1998 *************** *** 129,134 **** --- 129,136 ---- } if (!p) { + fprintf(stderr,"FATAL: emalloc(): Unable to allocate %d bytes\n", size); + exit(1); UNBLOCK_INTERRUPTIONS; return (void *)p; } *************** *** 226,231 **** --- 228,235 ---- REMOVE_POINTER_FROM_LIST(p); p = (mem_header *) realloc(p,sizeof(mem_header)+size+PLATFORM_PADDING); if (!p) { + fprintf(stderr,"FATAL: erealloc(): Unable to allocate %d bytes\n", size); + exit(1); orig->pNext = GLOBAL(head); if (GLOBAL(head)) { GLOBAL(head)->pLast = orig; Index: php31/main/constants.c diff -c php31/main/constants.c:2.3 php31/main/constants.c:2.4 *** php31/main/constants.c:2.3 Thu Sep 10 20:22:50 1998 --- php31/main/constants.c Sat Oct 17 14:19:47 1998 *************** *** 219,225 **** #endif php3_str_tolower(lowercase_name, c->name_len); ! _php3_hash_add(&GLOBAL(php3_constants), lowercase_name, c->name_len, (void *) c, sizeof(php3_constant), NULL); free(lowercase_name); } --- 219,227 ---- #endif php3_str_tolower(lowercase_name, c->name_len); ! if (_php3_hash_add(&GLOBAL(php3_constants), lowercase_name, c->name_len, (void *) c, sizeof(php3_constant), NULL)==FAILURE) { ! pval_destructor(&c->value); ! } free(lowercase_name); } Index: php31/main/control_structures_inline.h diff -c php31/main/control_structures_inline.h:2.13 php31/main/control_structures_inline.h:2.14 *** php31/main/control_structures_inline.h:2.13 Wed Oct 7 15:58:08 1998 --- php31/main/control_structures_inline.h Sat Oct 17 14:19:47 1998 *************** *** 29,35 **** */ ! /* $Id: control_structures_inline.h,v 2.13 1998/10/07 19:58:08 zeev Exp $ */ #ifdef THREAD_SAFE #include "tls.h" --- 29,35 ---- */ ! /* $Id: control_structures_inline.h,v 2.14 1998/10/17 18:19:47 zeev Exp $ */ #ifdef THREAD_SAFE #include "tls.h" *************** *** 70,77 **** extern inline void for_pre_statement(pval *for_token, pval *expr2, pval *expr3 INLINE_TLS); extern inline void for_post_statement(pval *for_token, pval *first_semicolon, pval *second_semicolon, pval *close_parentheses INLINE_TLS); extern inline void cs_return(pval *expr INLINE_TLS); ! extern inline void cs_start_include(pval *include_token INLINE_TLS); ! extern inline void cs_end_include(pval *include_token, pval *expr INLINE_TLS); extern inline void cs_show_source(pval *expr INLINE_TLS); extern inline void cs_pre_boolean_or(pval *left_expr INLINE_TLS); extern inline void cs_post_boolean_or(pval *result, pval *left_expr, pval *right_expr INLINE_TLS); --- 70,77 ---- extern inline void for_pre_statement(pval *for_token, pval *expr2, pval *expr3 INLINE_TLS); extern inline void for_post_statement(pval *for_token, pval *first_semicolon, pval *second_semicolon, pval *close_parentheses INLINE_TLS); extern inline void cs_return(pval *expr INLINE_TLS); ! extern inline void php3cs_start_require(pval *include_token INLINE_TLS); ! extern inline void php3cs_end_require(pval *include_token, pval *expr INLINE_TLS); extern inline void cs_show_source(pval *expr INLINE_TLS); extern inline void cs_pre_boolean_or(pval *left_expr INLINE_TLS); extern inline void cs_post_boolean_or(pval *result, pval *left_expr, pval *right_expr INLINE_TLS); *************** *** 677,683 **** } ! inline void cs_start_include(pval *include_token INLINE_TLS) { /* evaluate the expression even at Execute=0, if it's the first time we see this include(), otherwise, * don't evaluate it. --- 677,683 ---- } ! inline void php3cs_start_require(pval *include_token INLINE_TLS) { /* evaluate the expression even at Execute=0, if it's the first time we see this include(), otherwise, * don't evaluate it. *************** *** 685,692 **** --- 685,697 ---- if (GLOBAL(php3_display_source)) { return; } + stack_push(&GLOBAL(css), &GLOBAL(ExecuteFlag), sizeof(int)); + GLOBAL(php3g_function_state_for_require) = GLOBAL(function_state); + if (!include_token->cs_data.included) { + GLOBAL(function_state).loop_nest_level = GLOBAL(function_state).loop_change_level = GLOBAL(function_state).loop_change_type = 0; + GLOBAL(function_state).returned = 0; GLOBAL(ExecuteFlag) = EXECUTE; GLOBAL(Execute) = SHOULD_EXECUTE; } else { *************** *** 695,708 **** } } ! inline void cs_end_include(pval *include_token, pval *expr INLINE_TLS) { if (GLOBAL(php3_display_source)) { return; } GLOBAL(ExecuteFlag) = stack_int_top(&GLOBAL(css)); stack_del_top(&GLOBAL(css)); GLOBAL(Execute) = SHOULD_EXECUTE; if (!include_token->cs_data.included) { if (!GLOBAL(php3_display_source)) { include_file(expr,0); --- 700,716 ---- } } ! ! inline void php3cs_end_require(pval *include_token, pval *expr INLINE_TLS) { if (GLOBAL(php3_display_source)) { return; } GLOBAL(ExecuteFlag) = stack_int_top(&GLOBAL(css)); stack_del_top(&GLOBAL(css)); + GLOBAL(function_state) = GLOBAL(php3g_function_state_for_require); GLOBAL(Execute) = SHOULD_EXECUTE; + if (!include_token->cs_data.included) { if (!GLOBAL(php3_display_source)) { include_file(expr,0); Index: php31/main/language-parser.y diff -c php31/main/language-parser.y:2.10 php31/main/language-parser.y:2.11 *** php31/main/language-parser.y:2.10 Sat Sep 19 12:50:32 1998 --- php31/main/language-parser.y Sat Oct 17 14:19:47 1998 *************** *** 31,37 **** */ ! /* $Id: language-parser.y,v 2.10 1998/09/19 16:50:32 rasmus Exp $ */ /* --- 31,37 ---- */ ! /* $Id: language-parser.y,v 2.11 1998/10/17 18:19:47 zeev Exp $ */ /* *************** *** 118,123 **** --- 118,124 ---- * soon-to-be-called function symbol table. */ FunctionState function_state; + FunctionState php3g_function_state_for_require; /* to save state when forcing execution in require() evaluation */ /* The following two variables are used when inside class definitions. */ char *class_name=NULL; *************** *** 131,136 **** --- 132,138 ---- pval *array_ptr; extern int shutdown_requested; + #endif /* THREAD SAFE*/ #include "control_structures_inline.h" *************** *** 320,326 **** | PHP_ECHO echo_expr_list ';' | INLINE_HTML { if (GLOBAL(Execute)) { if (php3_header()) PUTS($1.value.str.val); } } | expr ';' { if (GLOBAL(Execute)) pval_destructor(&$1 _INLINE_TLS); } ! | REQUIRE { cs_start_include(&$1 _INLINE_TLS); } expr ';' { cs_end_include(&$1,&$3 _INLINE_TLS); } | HIGHLIGHT_FILE expr ';' { if (GLOBAL(Execute)) cs_show_source(&$2 _INLINE_TLS); } | HIGHLIGHT_STRING '(' expr ')' ';' { if (GLOBAL(Execute)) eval_string(&$3,NULL,1 _INLINE_TLS); } | HIGHLIGHT_STRING '(' expr ',' expr ')' ';' { if (GLOBAL(Execute)) eval_string(&$3,&$5,2 _INLINE_TLS); } --- 322,328 ---- | PHP_ECHO echo_expr_list ';' | INLINE_HTML { if (GLOBAL(Execute)) { if (php3_header()) PUTS($1.value.str.val); } } | expr ';' { if (GLOBAL(Execute)) pval_destructor(&$1 _INLINE_TLS); } ! | REQUIRE { php3cs_start_require(&$1 _INLINE_TLS); } expr ';' { php3cs_end_require(&$1,&$3 _INLINE_TLS); } | HIGHLIGHT_FILE expr ';' { if (GLOBAL(Execute)) cs_show_source(&$2 _INLINE_TLS); } | HIGHLIGHT_STRING '(' expr ')' ';' { if (GLOBAL(Execute)) eval_string(&$3,NULL,1 _INLINE_TLS); } | HIGHLIGHT_STRING '(' expr ',' expr ')' ';' { if (GLOBAL(Execute)) eval_string(&$3,&$5,2 _INLINE_TLS); } *************** *** 761,766 **** --- 763,770 ---- int i; pval class_ptr; int original_shutdown_requested; + int original_execute_flag = GLOBAL(ExecuteFlag); + FunctionState original_function_state = GLOBAL(function_state); TLS_VARS; original_shutdown_requested=GLOBAL(shutdown_requested); *************** *** 778,786 **** } /* Do some magic... */ GLOBAL(ExecuteFlag) = EXECUTE; GLOBAL(Execute) = SHOULD_EXECUTE; - GLOBAL(shutdown_requested) = 0; tc_set_token(&GLOBAL(token_cache_manager), func->offset, IC_FUNCTION); if (object) { --- 782,792 ---- } /* Do some magic... */ + GLOBAL(shutdown_requested) = 0; + GLOBAL(function_state).loop_nest_level = GLOBAL(function_state).loop_change_level = GLOBAL(function_state).loop_change_type = 0; + GLOBAL(function_state).returned = 0; GLOBAL(ExecuteFlag) = EXECUTE; GLOBAL(Execute) = SHOULD_EXECUTE; tc_set_token(&GLOBAL(token_cache_manager), func->offset, IC_FUNCTION); if (object) { *************** *** 797,803 **** if (GLOBAL(shutdown_requested)) { /* we died during this function call */ return FAILURE; } - GLOBAL(shutdown_requested) = original_shutdown_requested; cs_functioncall_end(retval,function_name,&return_offset,0 _INLINE_TLS); return SUCCESS; } --- 803,812 ---- if (GLOBAL(shutdown_requested)) { /* we died during this function call */ return FAILURE; } cs_functioncall_end(retval,function_name,&return_offset,0 _INLINE_TLS); + GLOBAL(function_state) = original_function_state; + GLOBAL(ExecuteFlag) = original_execute_flag; + GLOBAL(shutdown_requested) = original_shutdown_requested; + GLOBAL(Execute) = SHOULD_EXECUTE; return SUCCESS; } Index: php31/main/language-scanner.l diff -c php31/main/language-scanner.l:2.12 php31/main/language-scanner.l:2.13 *** php31/main/language-scanner.l:2.12 Thu Sep 10 20:22:51 1998 --- php31/main/language-scanner.l Sat Oct 17 14:19:48 1998 *************** *** 181,187 **** yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE)); BEGIN(INITIAL); GLOBAL(include_count)++; ! GLOBAL(phplineno)=1+MAX_TOKENS_PER_CACHE*GLOBAL(include_count); filename = estrndup(file->value.str.val,file->value.str.len); _php3_hash_index_update(&GLOBAL(include_names),GLOBAL(include_count),(void *) &filename,sizeof(char *),NULL); --- 181,187 ---- yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE)); BEGIN(INITIAL); GLOBAL(include_count)++; ! GLOBAL(phplineno) = 1 + (GLOBAL(include_count)<<TOKEN_BITS); filename = estrndup(file->value.str.val,file->value.str.len); _php3_hash_index_update(&GLOBAL(include_names),GLOBAL(include_count),(void *) &filename,sizeof(char *),NULL); *************** *** 223,229 **** yyin=NULL; if (!display_source) { ! tcm_new(&GLOBAL(token_cache_manager)); } else { if (display_source==2 && !pval_is_true(return_offset)) { display_source=1; --- 223,232 ---- yyin=NULL; if (!display_source) { ! if (tcm_new(&GLOBAL(token_cache_manager),TOKEN_CACHE_EVAL_BLOCK_SIZE)==FAILURE) { ! php3_error(E_ERROR,"Unable to initialize a new token cache"); ! return; ! } } else { if (display_source==2 && !pval_is_true(return_offset)) { display_source=1; *************** *** 277,288 **** yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE)); BEGIN(INITIAL); GLOBAL(include_count)++; ! GLOBAL(phplineno)=1+MAX_TOKENS_PER_CACHE*GLOBAL(include_count); filename = file->value.str.val; _php3_hash_index_update(&GLOBAL(include_names),GLOBAL(include_count),(void *) &filename,sizeof(char *),NULL); ! tcm_new(&GLOBAL(token_cache_manager)); ! return SUCCESS; } /* returns 0 if scanning should be terminated */ --- 280,295 ---- yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE)); BEGIN(INITIAL); GLOBAL(include_count)++; ! GLOBAL(phplineno) = 1 + (GLOBAL(include_count)<<TOKEN_BITS); filename = file->value.str.val; _php3_hash_index_update(&GLOBAL(include_names),GLOBAL(include_count),(void *) &filename,sizeof(char *),NULL); ! if (tcm_new(&GLOBAL(token_cache_manager),TOKEN_CACHE_INCLUDE_BLOCK_SIZE)==FAILURE) { ! php3_error(E_ERROR,"Unable to initialize a new token cache"); ! return FAILURE; ! } else { ! return SUCCESS; ! } } /* returns 0 if scanning should be terminated */ Index: php31/main/main.c diff -c php31/main/main.c:2.42 php31/main/main.c:2.43 *** php31/main/main.c:2.42 Sun Oct 11 09:11:55 1998 --- php31/main/main.c Sat Oct 17 14:19:48 1998 *************** *** 29,35 **** +----------------------------------------------------------------------+ */ ! /* $Id: main.c,v 2.42 1998/10/11 13:11:55 zeev Exp $ */ /* #define CRASH_DETECTION */ --- 29,35 ---- +----------------------------------------------------------------------+ */ ! /* $Id: main.c,v 2.43 1998/10/17 18:19:48 zeev Exp $ */ /* #define CRASH_DETECTION */ *************** *** 181,193 **** int php3_get_lineno(int lineno) { ! return (lineno % MAX_TOKENS_PER_CACHE); } char *php3_get_filename(int lineno) { char **filename_ptr; ! int file_offset = lineno / MAX_TOKENS_PER_CACHE; TLS_VARS; if ((GLOBAL(initialized) & INIT_INCLUDE_NAMES_HASH) && _php3_hash_index_find(&GLOBAL(include_names), file_offset, (void **) &filename_ptr) == SUCCESS) { --- 181,193 ---- int php3_get_lineno(int lineno) { ! return LINE_OFFSET(lineno); } char *php3_get_filename(int lineno) { char **filename_ptr; ! int file_offset = FILE_OFFSET(lineno); TLS_VARS; if ((GLOBAL(initialized) & INIT_INCLUDE_NAMES_HASH) && _php3_hash_index_find(&GLOBAL(include_names), file_offset, (void **) &filename_ptr) == SUCCESS) { *************** *** 351,357 **** if (!php3_header()) { return; } ! php3_printf("<br>\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br>\n", error_type_str, buffer, filename, GLOBAL(current_lineno) % MAX_TOKENS_PER_CACHE); } } } --- 351,357 ---- if (!php3_header()) { return; } ! php3_printf("<br>\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br>\n", error_type_str, buffer, filename, php3_get_lineno(current_lineno)); } } } *************** *** 376,383 **** if (GLOBAL(debugger_on)) { va_start(args, format); vsnprintf(buffer, sizeof(buffer) - 1, format, args); ! php3_debugger_error(buffer, type, filename, ! GLOBAL(current_lineno) % MAX_TOKENS_PER_CACHE); va_end(args); } #endif --- 376,382 ---- if (GLOBAL(debugger_on)) { va_start(args, format); vsnprintf(buffer, sizeof(buffer) - 1, format, args); ! php3_debugger_error(buffer, type, filename, php3_get_lineno(GLOBAL(current_lineno))); va_end(args); } #endif Index: php31/main/mime.c diff -c php31/main/mime.c:2.4 php31/main/mime.c:2.5 *** php31/main/mime.c:2.4 Thu Aug 27 01:01:11 1998 --- php31/main/mime.c Sat Oct 17 14:19:48 1998 *************** *** 27,33 **** | | +----------------------------------------------------------------------+ */ ! /* $Id: mime.c,v 2.4 1998/08/27 05:01:11 shane Exp $ */ #ifdef THREAD_SAFE #include "tls.h" #endif --- 27,33 ---- | | +----------------------------------------------------------------------+ */ ! /* $Id: mime.c,v 2.5 1998/10/17 18:19:48 zeev Exp $ */ #ifdef THREAD_SAFE #include "tls.h" #endif *************** *** 98,104 **** --- 98,110 ---- php3_error(E_WARNING, "File Upload Mime headers garbled [%c%c%c%c%c]", *name, *(name + 1), *(name + 2), *(name + 3), *(name + 4)); SAFE_RETURN; } + if (namebuf) { + efree(namebuf); + } namebuf = estrndup(name, s-name); + if (lbuf) { + efree(lbuf); + } lbuf = emalloc(s-name + MAX(MAX(sizeof("_name"),sizeof("_size")),sizeof("_type"))); state = 2; loc2 = memchr(loc + 1, '\n', rem); *************** *** 115,120 **** --- 121,129 ---- if (!s) { php3_error(E_WARNING, "File Upload Mime headers garbled [%c%c%c%c%c]", *filename, *(filename + 1), *(filename + 2), *(filename + 3), *(filename + 4)); SAFE_RETURN; + } + if (filenamebuf) { + efree(filenamebuf); } filenamebuf = estrndup(filename, s-filename); sprintf(lbuf, "%s_name", namebuf); Index: php31/main/tls.h diff -c php31/main/tls.h:2.12 php31/main/tls.h:2.13 *** php31/main/tls.h:2.12 Tue Sep 15 18:35:41 1998 --- php31/main/tls.h Sat Oct 17 14:19:48 1998 *************** *** 105,110 **** --- 105,111 ---- int current_lineno; int include_count; FunctionState function_state; + FunctionState php3g_function_state_for_require; char *class_name; HashTable *class_symbol_table; pval return_value,globals; Index: php31/main/token_cache.c diff -c php31/main/token_cache.c:2.6 php31/main/token_cache.c:2.7 *** php31/main/token_cache.c:2.6 Thu Sep 10 20:22:53 1998 --- php31/main/token_cache.c Sat Oct 17 14:19:49 1998 *************** *** 29,35 **** */ ! /* $Id: token_cache.c,v 2.6 1998/09/11 00:22:53 zeev Exp $ */ #ifdef THREAD_SAFE #include "tls.h" --- 29,35 ---- */ ! /* $Id: token_cache.c,v 2.7 1998/10/17 18:19:49 zeev Exp $ */ #ifdef THREAD_SAFE #include "tls.h" *************** *** 83,92 **** /* prepare a new token cache */ ! int tcm_new(TokenCacheManager *tcm) { TLS_VARS; ! tcm->initialized++; if (tcm->initialized >= tcm->max) { tcm->token_caches = (TokenCache *) erealloc(tcm->token_caches, (tcm->max + TOKEN_CACHES_BLOCK_SIZE) * sizeof(TokenCache)); --- 83,95 ---- /* prepare a new token cache */ ! int tcm_new(TokenCacheManager *tcm, int block_size) { TLS_VARS; ! ! if (tcm->initialized >= (1<<TC_BITS)) { ! return FAILURE; ! } tcm->initialized++; if (tcm->initialized >= tcm->max) { tcm->token_caches = (TokenCache *) erealloc(tcm->token_caches, (tcm->max + TOKEN_CACHES_BLOCK_SIZE) * sizeof(TokenCache)); *************** *** 96,102 **** tcm->max += TOKEN_CACHES_BLOCK_SIZE; } tcm->active = tcm->initialized - 1; ! if (tc_init(&tcm->token_caches[tcm->active],TOKEN_CACHE_EVAL_BLOCK_SIZE) == FAILURE) { return FAILURE; } GLOBAL(tc) = &tcm->token_caches[tcm->active]; --- 99,105 ---- tcm->max += TOKEN_CACHES_BLOCK_SIZE; } tcm->active = tcm->initialized - 1; ! if (tc_init(&tcm->token_caches[tcm->active], block_size) == FAILURE) { return FAILURE; } GLOBAL(tc) = &tcm->token_caches[tcm->active]; *************** *** 147,153 **** } next_token.phplval = *phplval; next_token.lineno = GLOBAL(phplineno); ! next_token.phplval.offset = tcm->active * MAX_TOKENS_PER_CACHE + GLOBAL(tc)->count; /* ugly hack to support $keyword */ if (last_token_suggests_variable_reference() && is_reserved_word(next_token.token_type)) { --- 150,156 ---- } next_token.phplval = *phplval; next_token.lineno = GLOBAL(phplineno); ! next_token.phplval.offset = (tcm->active<<TOKEN_BITS) + GLOBAL(tc)->count; /* ugly hack to support $keyword */ if (last_token_suggests_variable_reference() && is_reserved_word(next_token.token_type)) { *************** *** 180,190 **** clear_lookahead(); ! tc_offset = token_number / MAX_TOKENS_PER_CACHE; if (tc_offset >= tcm->initialized) { return FAILURE; } ! t_offset = token_number % MAX_TOKENS_PER_CACHE; if (t_offset > tcm->token_caches[tc_offset].count) { return FAILURE; } --- 183,193 ---- clear_lookahead(); ! tc_offset = TC_OFFSET(token_number); if (tc_offset >= tcm->initialized) { return FAILURE; } ! t_offset = TOKEN_OFFSET(token_number); if (t_offset > tcm->token_caches[tc_offset].count) { return FAILURE; } *************** *** 198,210 **** /* switch tokens between start to middle-1, and middle+1 to end */ int tc_switch(TokenCacheManager *tcm, int start, int end, int middle) { ! TokenCache *tc = &tcm->token_caches[start / MAX_TOKENS_PER_CACHE]; Token *temp_tokens, middle_token; int first_chunk, second_chunk, i; ! start %= MAX_TOKENS_PER_CACHE; ! end %= MAX_TOKENS_PER_CACHE; ! middle %= MAX_TOKENS_PER_CACHE; if (start < 0 || end >= tc->count || middle < start || middle > end) { return FAILURE; --- 201,213 ---- /* switch tokens between start to middle-1, and middle+1 to end */ int tc_switch(TokenCacheManager *tcm, int start, int end, int middle) { ! TokenCache *tc = &tcm->token_caches[TC_OFFSET(start)]; Token *temp_tokens, middle_token; int first_chunk, second_chunk, i; ! start = TOKEN_OFFSET(start); ! end = TOKEN_OFFSET(end); ! middle = TOKEN_OFFSET(middle); if (start < 0 || end >= tc->count || middle < start || middle > end) { return FAILURE; *************** *** 235,241 **** tc->tokens[start + second_chunk] = middle_token; for (i = start; i <= end; i++) { ! tc->tokens[i].phplval.offset = (tcm->active) * MAX_TOKENS_PER_CACHE + i; } return SUCCESS; } --- 238,244 ---- tc->tokens[start + second_chunk] = middle_token; for (i = start; i <= end; i++) { ! tc->tokens[i].phplval.offset = (tcm->active<<TOKEN_BITS) + i; } return SUCCESS; } *************** *** 243,251 **** inline int tc_set_token(TokenCacheManager *tcm, int offset, int type) { ! TokenCache *tc = &tcm->token_caches[offset / MAX_TOKENS_PER_CACHE]; ! offset %= MAX_TOKENS_PER_CACHE; if (offset < 0 || offset >= tc->count) { return FAILURE; } --- 246,254 ---- inline int tc_set_token(TokenCacheManager *tcm, int offset, int type) { ! TokenCache *tc = &tcm->token_caches[TC_OFFSET(offset)]; ! offset = TOKEN_OFFSET(offset); if (offset < 0 || offset >= tc->count) { return FAILURE; } *************** *** 256,264 **** inline int tc_get_token(TokenCacheManager *tcm, int offset) { ! TokenCache *tc = &tcm->token_caches[offset / MAX_TOKENS_PER_CACHE]; ! offset %= MAX_TOKENS_PER_CACHE; if (offset < 0 || offset >= tc->count) { return FAILURE; } --- 259,267 ---- inline int tc_get_token(TokenCacheManager *tcm, int offset) { ! TokenCache *tc = &tcm->token_caches[TC_OFFSET(offset)]; ! offset = TOKEN_OFFSET(offset); if (offset < 0 || offset >= tc->count) { return FAILURE; } *************** *** 268,281 **** int tc_get_current_offset(TokenCacheManager *tcm INLINE_TLS) { ! return tcm->active * MAX_TOKENS_PER_CACHE + GLOBAL(tc)->pos; } inline int tc_set_switched(TokenCacheManager *tcm, int offset) { ! TokenCache *tc = &tcm->token_caches[offset / MAX_TOKENS_PER_CACHE]; ! offset %= MAX_TOKENS_PER_CACHE; if (offset < 0 || offset >= tc->count) { return FAILURE; } --- 271,284 ---- int tc_get_current_offset(TokenCacheManager *tcm INLINE_TLS) { ! return (tcm->active<<TOKEN_BITS) + GLOBAL(tc)->pos; } inline int tc_set_switched(TokenCacheManager *tcm, int offset) { ! TokenCache *tc = &tcm->token_caches[TC_OFFSET(offset)]; ! offset = TOKEN_OFFSET(offset); if (offset < 0 || offset >= tc->count) { return FAILURE; } *************** *** 287,295 **** inline int tc_set_included(TokenCacheManager *tcm, int offset) { ! TokenCache *tc = &tcm->token_caches[offset / MAX_TOKENS_PER_CACHE]; ! offset %= MAX_TOKENS_PER_CACHE; if (offset < 0 || offset >= tc->count) { return FAILURE; } --- 290,298 ---- inline int tc_set_included(TokenCacheManager *tcm, int offset) { ! TokenCache *tc = &tcm->token_caches[TC_OFFSET(offset)]; ! offset = TOKEN_OFFSET(offset); if (offset < 0 || offset >= tc->count) { return FAILURE; } Index: php31/main/token_cache.h diff -c php31/main/token_cache.h:2.2 php31/main/token_cache.h:2.3 *** php31/main/token_cache.h:2.2 Thu Aug 20 22:12:56 1998 --- php31/main/token_cache.h Sat Oct 17 14:19:49 1998 *************** *** 29,35 **** */ ! /* $Id: token_cache.h,v 2.2 1998/08/21 02:12:56 zeev Exp $ */ #ifndef _TOKEN_CACHE --- 29,35 ---- */ ! /* $Id: token_cache.h,v 2.3 1998/10/17 18:19:49 zeev Exp $ */ #ifndef _TOKEN_CACHE *************** *** 58,65 **** #define TOKEN_CACHE_BLOCK_SIZE 8192 #define TOKEN_CACHE_EVAL_BLOCK_SIZE 32 #define TOKEN_CACHES_BLOCK_SIZE 4 ! #define MAX_TOKENS_PER_CACHE 1048576 extern int tcm_init(TokenCacheManager *tcm); extern int tc_init(TokenCache *tc,int block_size); --- 58,74 ---- #define TOKEN_CACHE_BLOCK_SIZE 8192 #define TOKEN_CACHE_EVAL_BLOCK_SIZE 32 + #define TOKEN_CACHE_INCLUDE_BLOCK_SIZE 512 + #define TOKEN_CACHES_BLOCK_SIZE 4 ! ! #define TOKEN_BITS 20 ! #define TC_BITS ((sizeof(int))*8-TOKEN_BITS) ! ! #define TC_OFFSET(token_number) (token_number>>TOKEN_BITS) ! #define TOKEN_OFFSET(token_number) (token_number & ((1<<TOKEN_BITS)-1)) ! #define FILE_OFFSET TC_OFFSET ! #define LINE_OFFSET TOKEN_OFFSET extern int tcm_init(TokenCacheManager *tcm); extern int tc_init(TokenCache *tc,int block_size); *************** *** 75,81 **** extern int tc_get_current_offset(TokenCacheManager *tcm INLINE_TLS); extern int tc_destroy(TokenCache *tc); extern void tcm_destroy(TokenCacheManager *tcm); ! extern int tcm_new(TokenCacheManager *tcm); extern void tcm_save(TokenCacheManager *tcm); extern int tcm_load(TokenCacheManager *tcm, FILE *input); extern void clear_lookahead(); --- 84,90 ---- extern int tc_get_current_offset(TokenCacheManager *tcm INLINE_TLS); extern int tc_destroy(TokenCache *tc); extern void tcm_destroy(TokenCacheManager *tcm); ! extern int tcm_new(TokenCacheManager *tcm, int block_size); extern void tcm_save(TokenCacheManager *tcm); extern int tcm_load(TokenCacheManager *tcm, FILE *input); extern void clear_lookahead(); -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#1867) next »