From 0b26bdf5fb16514887772549fef2346ddeeebeeb Mon Sep 17 00:00:00 2001 From: ceriel Date: Fri, 11 Jan 1991 14:20:59 +0000 Subject: [PATCH] Some changes in search for more efficiency --- mach/proto/as/comm0.h | 2 +- mach/proto/as/comm1.h | 2 ++ mach/proto/as/comm2.y | 11 ++++++----- mach/proto/as/comm4.c | 12 ++++++------ mach/proto/as/comm5.c | 24 +++++++++++++++++------- mach/proto/as/comm6.c | 11 ++++------- mach/proto/as/comm7.c | 24 +++++++++++++++++++----- 7 files changed, 55 insertions(+), 31 deletions(-) diff --git a/mach/proto/as/comm0.h b/mach/proto/as/comm0.h index 4ae94aab1..c3ea04d07 100644 --- a/mach/proto/as/comm0.h +++ b/mach/proto/as/comm0.h @@ -135,7 +135,7 @@ _include #endif /* symbol table management */ -#define H_SIZE 256 /* hash size */ +#define H_SIZE 307 /* hash size, must be od */ #define H_KEY (0*H_SIZE) /* key symbol headers */ #define H_LOCAL (1*H_SIZE) /* module symbol headers */ #ifdef ASLD diff --git a/mach/proto/as/comm1.h b/mach/proto/as/comm1.h index 065ac9884..1a222e452 100644 --- a/mach/proto/as/comm1.h +++ b/mach/proto/as/comm1.h @@ -102,7 +102,9 @@ extern struct outhead outhead; #endif /* forward function declarations */ +#ifdef ASLD extern char *readident(); +#endif extern char *remember(); extern item_t *fb_shift(); extern item_t *fb_alloc(); diff --git a/mach/proto/as/comm2.y b/mach/proto/as/comm2.y index 627361792..98fc24001 100644 --- a/mach/proto/as/comm2.y +++ b/mach/proto/as/comm2.y @@ -92,7 +92,8 @@ static item_t *last_it, *o_it; /* ========== Machine independent rules ========== */ #ifdef LISTING -#define LISTLINE(n) listline(n) +#define LISTLINE(n) if (listflag) listline(n); \ + else if (listtemp) { listflag = listtemp; listeoln = 1; } #else #define LISTLINE(n) /* empty */ #endif LISTING @@ -229,8 +230,8 @@ operation hllino++; newsymb( (char *)0, - (short)(DOTTYP | S_LIN), - (short)hllino, + (DOTTYP | S_LIN), + hllino, (valu_t)DOTVAL ); } @@ -240,8 +241,8 @@ operation hllino = 0; newsymb( stringbuf, - (short)(DOTTYP | S_FIL), - (short)0, + (DOTTYP | S_FIL), + 0, (valu_t)DOTVAL ); } diff --git a/mach/proto/as/comm4.c b/mach/proto/as/comm4.c index 18658b5fe..2adcfe638 100644 --- a/mach/proto/as/comm4.c +++ b/mach/proto/as/comm4.c @@ -448,7 +448,7 @@ char *s; * the user is familiar with. Moreover, it is not reproducable. */ if ((sflag & (SYM_EXT|SYM_LOC|SYM_LAB)) && PASS_SYMB) - newsymb(s, S_MOD, (short)0, (valu_t)0); + newsymb(s, S_MOD, 0, (valu_t)0); #endif #ifdef LISTING listtemp = 0; @@ -531,7 +531,7 @@ commfinish() newsymb( ip->i_name, ip->i_type & (S_EXT|S_TYP), - (short)0, + 0, load(ip) ); #else not ASLD @@ -549,7 +549,7 @@ commfinish() newsymb( ip->i_name, ip->i_type, - (short) 0, + 0, cp->c_size ); } @@ -574,7 +574,7 @@ commfinish() newsymb( ip->i_name, S_EXT|S_UND, - (short)0, + 0, (valu_t)0 ); } @@ -587,8 +587,8 @@ commfinish() ip = sp->s_item; newsymb( ip->i_name, - (short)(ip->i_type | S_SCT), - (short)0, + (ip->i_type | S_SCT), + 0, load(ip) ); } diff --git a/mach/proto/as/comm5.c b/mach/proto/as/comm5.c index bcaf81aca..2eb8d1250 100644 --- a/mach/proto/as/comm5.c +++ b/mach/proto/as/comm5.c @@ -271,17 +271,26 @@ register c; return(c>>8); } +static char name[NAMEMAX+1]; + inident(c) -char c; +register c; { - register char *p; + register char *p = name; register item_t *ip; + register n = NAMEMAX; - p = readident(c); - ip = item_search(p); + do { + if (--n >= 0) + *p++ = c; + c = nextchar(); + } while (ISALNUM(c)); + *p = '\0'; + peekc = c; + ip = item_search(name); if (ip == 0) { ip = item_alloc(S_UND); - ip->i_name = remember(p); + ip->i_name = remember(name); /* printf("ident %s %o\n", ip->i_name, ip); */ unresolved++; item_insert(ip, H_LOCAL + (hashindex%H_SIZE)); @@ -294,11 +303,11 @@ char c; return(IDENT); } +#ifdef ASLD char * readident(c) register c; { - static char name[NAMEMAX+1]; register n = NAMEMAX; register char *p = name; @@ -311,6 +320,7 @@ register c; peekc = c; return(name); } +#endif innumber(c) register c; @@ -471,7 +481,7 @@ register char *p; item_t * item_search(p) -register char *p; +char *p; { register h; register item_t *ip; diff --git a/mach/proto/as/comm6.c b/mach/proto/as/comm6.c index cc86c4ff4..997b631ea 100644 --- a/mach/proto/as/comm6.c +++ b/mach/proto/as/comm6.c @@ -14,7 +14,7 @@ newequate(ip, typ) register item_t *ip; -register short typ; +register int typ; { typ &= ~S_EXT; if (typ & S_COM) @@ -69,7 +69,7 @@ register item_t *ip; newsymb( ip->i_name, ip->i_type & (S_EXT|S_TYP), - (short)0, + 0, load(ip) ); } @@ -97,7 +97,7 @@ register item_t *ip; newsect(ip) register item_t *ip; { - register short typ; + register int typ; register sect_t *sp = NULL; typ = ip->i_type & S_TYP; @@ -184,7 +184,7 @@ valu_t val; } switchsect(newtyp) -short newtyp; +int newtyp; { register sect_t *sp; @@ -243,7 +243,6 @@ valu_t bytes; #ifdef RELOCATION newrelo(s, n) -short s; { int iscomm; struct outrelo outrelo; @@ -328,8 +327,6 @@ new_string(s) newsymb(name, type, desc, valu) register char *name; -short type; -short desc; valu_t valu; { struct outname outname; diff --git a/mach/proto/as/comm7.c b/mach/proto/as/comm7.c index 3b347fbb6..0480ab0cb 100644 --- a/mach/proto/as/comm7.c +++ b/mach/proto/as/comm7.c @@ -17,7 +17,7 @@ load(ip) register item_t *ip; { #ifdef ASLD - register short typ; + register typ; typ = ip->i_type & S_TYP; if ((typ -= S_MIN) < 0) /* S_UND or S_ABS */ @@ -41,7 +41,7 @@ register item_t *ip; valu_t val; { #ifdef ASLD - register short typ; + register typ; typ = ip->i_type & S_TYP; if ((typ -= S_MIN) >= 0) @@ -232,6 +232,7 @@ small(fitsmall, gain) emit1(arg) { + static int olddottyp = -1; #ifdef LISTING if (listeoln) { if (listflag & 1) { @@ -253,7 +254,10 @@ emit1(arg) DOTSCT->s_zero = 0; break; case PASS_3: - wr_outsect(DOTTYP-S_MIN); + if (DOTTYP != olddottyp) { + wr_outsect(DOTTYP-S_MIN); + olddottyp = DOTTYP; + } while (DOTSCT->s_zero) { wr_putc(0); DOTSCT->s_zero--; @@ -292,9 +296,19 @@ int n; case 1: emit1((int)val); break; case 2: - emit2((int)val); break; +#ifdef BYTES_REVERSED + emit1(((int)val>>8)); emit1((int)val); +#else + emit1((int)val); emit1(((int)val>>8)); +#endif + break; case 4: - emit4((long)val); break; +#ifdef WORDS_REVERSED + emit2((int)(val>>16)); emit2((int)(val)); +#else + emit2((int)(val)); emit2((int)(val>>16)); +#endif + break; default: assert(0); } -- 2.34.1