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
/* 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

View file

@ -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();

View file

@ -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
);
}

View file

@ -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)
);
}

View file

@ -271,17 +271,26 @@ register c;
return(c>>8);
}
inident(c)
char c;
{
register char *p;
register item_t *ip;
static char name[NAMEMAX+1];
p = readident(c);
ip = item_search(p);
inident(c)
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) {
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;

View file

@ -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;

View file

@ -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);
}