From e8a8177196e0566aafccdd6239ee6ece3fb91db9 Mon Sep 17 00:00:00 2001 From: vsc Date: Sun, 19 Oct 2003 00:33:10 +0000 Subject: [PATCH] speed up search for DB terms git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@903 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/alloc.c | 4 +--- C/heapgc.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/C/alloc.c b/C/alloc.c index ab71de2e7..440206300 100644 --- a/C/alloc.c +++ b/C/alloc.c @@ -12,7 +12,7 @@ * Last rev: * * mods: * * comments: allocating space * -* version:$Id: alloc.c,v 1.35 2003-10-14 13:10:26 vsc Exp $ * +* version:$Id: alloc.c,v 1.36 2003-10-19 00:33:10 vsc Exp $ * *************************************************************************/ #ifdef SCCS static char SccsId[] = "%W% %G%"; @@ -237,8 +237,6 @@ AllocHeap(unsigned int size) #if SIZEOF_INT_P==8 size = (((size + 7) & 0xfffffffffffffff8LL) >> 3) + 2; /* size in dwords + 2 */ #endif - if (size < 6) - size = 6; LOCK(FreeBlocksLock); if ((b = GetBlock(size))) { if (b->b_size >= size + 6 + 1) { diff --git a/C/heapgc.c b/C/heapgc.c index e6060e5f1..3f7871672 100644 --- a/C/heapgc.c +++ b/C/heapgc.c @@ -481,10 +481,13 @@ count_cells_marked(void) /* straightforward binary tree scheme that, given a key, finds a matching dbref */ +#define XOR_BIT 32 + typedef enum { db_entry, cl_entry, lcl_entry, + li_entry, dcl_entry } db_entry_type; @@ -546,7 +549,7 @@ find_ref_in_dbtable(CODEADDR entry) if (current->val < entry && current->lim > entry) { return(current); } - if (entry < current->val) + if (((CELL)entry ^ (CELL)(current->val)) & XOR_BIT) current = current->right; else current = current->left; @@ -570,6 +573,9 @@ mark_db_fixed(CELL *ptr) { case lcl_entry: ((LogUpdClause *)(el->val))->ClFlags |= GcFoundMask; break; + case li_entry: + ((LogUpdIndex *)(el->val))->ClFlags |= GcFoundMask; + break; case dcl_entry: ((DeadClause *)(el->val))->ClFlags |= GcFoundMask; break; @@ -613,7 +619,11 @@ init_dbtable(tr_fr_ptr trail_ptr) { if (FlagOn(DBClMask, flags)) { store_in_dbtable((CODEADDR)DBStructFlagsToDBStruct(pt0), db_entry); } else if (flags & LogUpdMask) { - store_in_dbtable((CODEADDR)ClauseFlagsToLogUpdClause(pt0), lcl_entry); + if (flags & IndexMask) { + store_in_dbtable((CODEADDR)ClauseFlagsToLogUpdIndex(pt0), li_entry); + } else { + store_in_dbtable((CODEADDR)ClauseFlagsToLogUpdClause(pt0), lcl_entry); + } } else { store_in_dbtable((CODEADDR)ClauseFlagsToDynamicClause(pt0), cl_entry); }