new heap allocation code

new atom table growth code and hash algorithm
more fixes for new indexing algorithm


git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@905 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc
2003-10-28 01:16:03 +00:00
parent 5244795d97
commit 5e4816eb5a
27 changed files with 489 additions and 205 deletions

View File

@@ -148,7 +148,7 @@ LookupAtom(char *atom)
/* compute hash */
p = (unsigned char *)atom;
hash = HashFunction(p) % MaxHash;
hash = HashFunction(p) % AtomHashTableSize;
WRITE_LOCK(HashChain[hash].AERWLock);
a = HashChain[hash].Entry;
/* search atom in chain */
@@ -157,16 +157,20 @@ LookupAtom(char *atom)
WRITE_UNLOCK(HashChain[hash].AERWLock);
return(a);
}
NOfAtoms++;
/* add new atom to start of chain */
ae = (AtomEntry *) Yap_AllocAtomSpace((sizeof *ae) + strlen(atom) + 1);
a = AbsAtom(ae);
ae->NextOfAE = HashChain[hash].Entry;
HashChain[hash].Entry = a;
ae->PropsOfAE = NIL;
if (ae->StrOfAE != atom)
strcpy(ae->StrOfAE, atom);
ae->NextOfAE = HashChain[hash].Entry;
HashChain[hash].Entry = a;
INIT_RWLOCK(ae->ARWLock);
WRITE_UNLOCK(HashChain[hash].AERWLock);
if (NOfAtoms > 2*AtomHashTableSize) {
CreepFlag = Unsigned(LCL0+1);
}
return (a);
}
@@ -196,7 +200,7 @@ Yap_LookupAtomWithAddress(char *atom, AtomEntry *ae)
/* compute hash */
p = (unsigned char *)atom;
hash = HashFunction(p) % MaxHash;
hash = HashFunction(p) % AtomHashTableSize;
/* ask for a WRITE lock because it is highly unlikely we shall find anything */
WRITE_LOCK(HashChain[hash].AERWLock);
a = HashChain[hash].Entry;
@@ -226,9 +230,10 @@ Yap_ReleaseAtom(Atom atom)
/* compute hash */
p = (unsigned char *)name;
hash = HashFunction(p) % MaxHash;
hash = HashFunction(p) % AtomHashTableSize;
WRITE_LOCK(HashChain[hash].AERWLock);
if (HashChain[hash].Entry == atom) {
NOfAtoms--;
HashChain[hash].Entry = ap->NextOfAE;
WRITE_UNLOCK(HashChain[hash].AERWLock);
return;