Some changes in search for more efficiency

This commit is contained in:
ceriel 1991-01-11 14:20:59 +00:00
parent d9815cadcd
commit 0b26bdf5fb
7 changed files with 58 additions and 34 deletions

View file

@ -135,7 +135,7 @@ _include <signal.h>
#endif #endif
/* symbol table management */ /* 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_KEY (0*H_SIZE) /* key symbol headers */
#define H_LOCAL (1*H_SIZE) /* module symbol headers */ #define H_LOCAL (1*H_SIZE) /* module symbol headers */
#ifdef ASLD #ifdef ASLD

View file

@ -102,7 +102,9 @@ extern struct outhead outhead;
#endif #endif
/* forward function declarations */ /* forward function declarations */
#ifdef ASLD
extern char *readident(); extern char *readident();
#endif
extern char *remember(); extern char *remember();
extern item_t *fb_shift(); extern item_t *fb_shift();
extern item_t *fb_alloc(); extern item_t *fb_alloc();

View file

@ -92,7 +92,8 @@ static item_t *last_it, *o_it;
/* ========== Machine independent rules ========== */ /* ========== Machine independent rules ========== */
#ifdef LISTING #ifdef LISTING
#define LISTLINE(n) listline(n) #define LISTLINE(n) if (listflag) listline(n); \
else if (listtemp) { listflag = listtemp; listeoln = 1; }
#else #else
#define LISTLINE(n) /* empty */ #define LISTLINE(n) /* empty */
#endif LISTING #endif LISTING
@ -229,8 +230,8 @@ operation
hllino++; hllino++;
newsymb( newsymb(
(char *)0, (char *)0,
(short)(DOTTYP | S_LIN), (DOTTYP | S_LIN),
(short)hllino, hllino,
(valu_t)DOTVAL (valu_t)DOTVAL
); );
} }
@ -240,8 +241,8 @@ operation
hllino = 0; hllino = 0;
newsymb( newsymb(
stringbuf, stringbuf,
(short)(DOTTYP | S_FIL), (DOTTYP | S_FIL),
(short)0, 0,
(valu_t)DOTVAL (valu_t)DOTVAL
); );
} }

View file

@ -448,7 +448,7 @@ char *s;
* the user is familiar with. Moreover, it is not reproducable. * the user is familiar with. Moreover, it is not reproducable.
*/ */
if ((sflag & (SYM_EXT|SYM_LOC|SYM_LAB)) && PASS_SYMB) 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 #endif
#ifdef LISTING #ifdef LISTING
listtemp = 0; listtemp = 0;
@ -531,7 +531,7 @@ commfinish()
newsymb( newsymb(
ip->i_name, ip->i_name,
ip->i_type & (S_EXT|S_TYP), ip->i_type & (S_EXT|S_TYP),
(short)0, 0,
load(ip) load(ip)
); );
#else not ASLD #else not ASLD
@ -549,7 +549,7 @@ commfinish()
newsymb( newsymb(
ip->i_name, ip->i_name,
ip->i_type, ip->i_type,
(short) 0, 0,
cp->c_size cp->c_size
); );
} }
@ -574,7 +574,7 @@ commfinish()
newsymb( newsymb(
ip->i_name, ip->i_name,
S_EXT|S_UND, S_EXT|S_UND,
(short)0, 0,
(valu_t)0 (valu_t)0
); );
} }
@ -587,8 +587,8 @@ commfinish()
ip = sp->s_item; ip = sp->s_item;
newsymb( newsymb(
ip->i_name, ip->i_name,
(short)(ip->i_type | S_SCT), (ip->i_type | S_SCT),
(short)0, 0,
load(ip) load(ip)
); );
} }

View file

@ -271,17 +271,26 @@ register c;
return(c>>8); return(c>>8);
} }
inident(c) static char name[NAMEMAX+1];
char c;
{
register char *p;
register item_t *ip;
p = readident(c); inident(c)
ip = item_search(p); register c;
{
register char *p = name;
register item_t *ip;
register n = NAMEMAX;
do {
if (--n >= 0)
*p++ = c;
c = nextchar();
} while (ISALNUM(c));
*p = '\0';
peekc = c;
ip = item_search(name);
if (ip == 0) { if (ip == 0) {
ip = item_alloc(S_UND); ip = item_alloc(S_UND);
ip->i_name = remember(p); ip->i_name = remember(name);
/* printf("ident %s %o\n", ip->i_name, ip); */ /* printf("ident %s %o\n", ip->i_name, ip); */
unresolved++; unresolved++;
item_insert(ip, H_LOCAL + (hashindex%H_SIZE)); item_insert(ip, H_LOCAL + (hashindex%H_SIZE));
@ -294,11 +303,11 @@ char c;
return(IDENT); return(IDENT);
} }
#ifdef ASLD
char * char *
readident(c) readident(c)
register c; register c;
{ {
static char name[NAMEMAX+1];
register n = NAMEMAX; register n = NAMEMAX;
register char *p = name; register char *p = name;
@ -311,6 +320,7 @@ register c;
peekc = c; peekc = c;
return(name); return(name);
} }
#endif
innumber(c) innumber(c)
register c; register c;
@ -471,7 +481,7 @@ register char *p;
item_t * item_t *
item_search(p) item_search(p)
register char *p; char *p;
{ {
register h; register h;
register item_t *ip; register item_t *ip;

View file

@ -14,7 +14,7 @@
newequate(ip, typ) newequate(ip, typ)
register item_t *ip; register item_t *ip;
register short typ; register int typ;
{ {
typ &= ~S_EXT; typ &= ~S_EXT;
if (typ & S_COM) if (typ & S_COM)
@ -69,7 +69,7 @@ register item_t *ip;
newsymb( newsymb(
ip->i_name, ip->i_name,
ip->i_type & (S_EXT|S_TYP), ip->i_type & (S_EXT|S_TYP),
(short)0, 0,
load(ip) load(ip)
); );
} }
@ -97,7 +97,7 @@ register item_t *ip;
newsect(ip) newsect(ip)
register item_t *ip; register item_t *ip;
{ {
register short typ; register int typ;
register sect_t *sp = NULL; register sect_t *sp = NULL;
typ = ip->i_type & S_TYP; typ = ip->i_type & S_TYP;
@ -184,7 +184,7 @@ valu_t val;
} }
switchsect(newtyp) switchsect(newtyp)
short newtyp; int newtyp;
{ {
register sect_t *sp; register sect_t *sp;
@ -243,7 +243,6 @@ valu_t bytes;
#ifdef RELOCATION #ifdef RELOCATION
newrelo(s, n) newrelo(s, n)
short s;
{ {
int iscomm; int iscomm;
struct outrelo outrelo; struct outrelo outrelo;
@ -328,8 +327,6 @@ new_string(s)
newsymb(name, type, desc, valu) newsymb(name, type, desc, valu)
register char *name; register char *name;
short type;
short desc;
valu_t valu; valu_t valu;
{ {
struct outname outname; struct outname outname;

View file

@ -17,7 +17,7 @@ load(ip)
register item_t *ip; register item_t *ip;
{ {
#ifdef ASLD #ifdef ASLD
register short typ; register typ;
typ = ip->i_type & S_TYP; typ = ip->i_type & S_TYP;
if ((typ -= S_MIN) < 0) /* S_UND or S_ABS */ if ((typ -= S_MIN) < 0) /* S_UND or S_ABS */
@ -41,7 +41,7 @@ register item_t *ip;
valu_t val; valu_t val;
{ {
#ifdef ASLD #ifdef ASLD
register short typ; register typ;
typ = ip->i_type & S_TYP; typ = ip->i_type & S_TYP;
if ((typ -= S_MIN) >= 0) if ((typ -= S_MIN) >= 0)
@ -232,6 +232,7 @@ small(fitsmall, gain)
emit1(arg) emit1(arg)
{ {
static int olddottyp = -1;
#ifdef LISTING #ifdef LISTING
if (listeoln) { if (listeoln) {
if (listflag & 1) { if (listflag & 1) {
@ -253,7 +254,10 @@ emit1(arg)
DOTSCT->s_zero = 0; DOTSCT->s_zero = 0;
break; break;
case PASS_3: case PASS_3:
wr_outsect(DOTTYP-S_MIN); if (DOTTYP != olddottyp) {
wr_outsect(DOTTYP-S_MIN);
olddottyp = DOTTYP;
}
while (DOTSCT->s_zero) { while (DOTSCT->s_zero) {
wr_putc(0); wr_putc(0);
DOTSCT->s_zero--; DOTSCT->s_zero--;
@ -292,9 +296,19 @@ int n;
case 1: case 1:
emit1((int)val); break; emit1((int)val); break;
case 2: 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: 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: default:
assert(0); assert(0);
} }